weaver      2004/03/09 08:18:47

  Modified:    components/registry/src/java/org/apache/jetspeed/containers
                        registry.container.groovy
  Log:
  refactored to support container embedding via scripts
  
  Revision  Changes    Path
  1.6       +25 -52    
jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/containers/registry.container.groovy
  
  Index: registry.container.groovy
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/containers/registry.container.groovy,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- registry.container.groovy 4 Mar 2004 21:21:36 -0000       1.5
  +++ registry.container.groovy 9 Mar 2004 16:18:47 -0000       1.6
  @@ -1,70 +1,43 @@
   import org.picocontainer.defaults.DefaultPicoContainer

  -import org.picocontainer.defaults.ConstantParameter

  -import org.picocontainer.ComponentAdapter

  -import org.picocontainer.defaults.ConstructorComponentAdapter

   import org.picocontainer.Parameter

   import org.picocontainer.defaults.ConstantParameter

   import org.picocontainer.defaults.ComponentParameter

  -import org.hsqldb.jdbcDriver

  -import org.apache.jetspeed.components.jndi.JNDIComponent

  -import org.apache.jetspeed.components.jndi.TyrexJNDIComponent

  -import org.apache.jetspeed.components.datasource.BoundDBCPDatasourceComponent

  -import org.apache.jetspeed.components.datasource.DatasourceComponent

  -import org.apache.commons.pool.impl.GenericObjectPool

  -import org.apache.jetspeed.components.persistence.store.ojb.OJBTypeIntializer

  -import org.apache.jetspeed.components.persistence.store.ojb.pb.PBStore

  +

   import 
org.apache.jetspeed.components.persistence.store.impl.DefaultPersistenceStoreContainer

   import org.apache.jetspeed.components.persistence.store.PersistenceStoreContainer

   import org.apache.jetspeed.components.util.system.FSSystemResourceUtilImpl

   

   import org.apache.jetspeed.components.portletregsitry.PortletRegistryComponentImpl

   import org.apache.jetspeed.components.portletregsitry.PortletRegistryComponent

  +import org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent

  +import org.apache.jetspeed.components.portletentity.PortletEntityAccessComponentImpl

   

   import java.io.File

   

  -// WARNING!!!!!!

  -// DO NOT use {Class}.class as it appears to be broken in Groovy

  -// You end getting a Class instance of the type java.lang.Class

  -// instead of the requested type!  This causes AssignabilityExceptions

  -// in pico.  You need to use Class.forName() instead.

  -

  -

  -

  -// create the root container

  -container = new DefaultPicoContainer()

  -

  -

  -

  -

  -// This JNDI component helps us publish the datasource

  -Class jndiClass = JNDIComponent

  -JNDIComponent jndiImpl = new TyrexJNDIComponent()

  -container.registerComponentInstance(jndiClass, jndiImpl)

  -

  -String url = System.getProperty("org.apache.jetspeed.database.url")

  -String driver = System.getProperty("org.apache.jetspeed.database.driver")

  -String user = System.getProperty("org.apache.jetspeed.database.user")

  -String password = System.getProperty("org.apache.jetspeed.database.password")

  -

  -if(url != null)

  +/**

  + * This is the standard assembly for a Regsitry

  + * component.  We want the Registry component to be exposed

  + * at as high the container hierarchy as possibly so, if a

  + * parent container is provided, we will regsiter to the parent

  + * and use it as the container for the Regsitry.

  + */

  +

  +// Prior to this, you will need to have an Implementation

  +// of org.apache.jetspeed.components.persistence.store.PersistenceStoreContainer

  +// registered.

  +if(parent != null)

   {

  -     container.registerComponentInstance(DatasourceComponent, new 
BoundDBCPDatasourceComponent(user, password, driver, url, 20, 5000, 
GenericObjectPool.WHEN_EXHAUSTED_GROW, true, "jetspeed", jndiImpl))

  +     container = new DefaultPicoContainer(parent)

  +     parent.registerComponentImplementation(PortletRegistryComponent, 
PortletRegistryComponentImpl, new Parameter[] {new 
ComponentParameter(PersistenceStoreContainer), new ConstantParameter("jetspeed")} )

  +    parent.registerComponentImplementation(PortletEntityAccessComponent, 
PortletEntityAccessComponentImpl, new Parameter[] {new 
ComponentParameter(PersistenceStoreContainer), new ConstantParameter("jetspeed")} )

  +}

  +else

  +{

  +    container = new DefaultPicoContainer()

  +    container.registerComponentImplementation(PortletRegistryComponent, 
PortletRegistryComponentImpl, new Parameter[] {new 
ComponentParameter(PersistenceStoreContainer), new ConstantParameter("jetspeed")} )

  +    container.registerComponentImplementation(PortletEntityAccessComponent, 
PortletEntityAccessComponentImpl, new Parameter[] {new 
ComponentParameter(PersistenceStoreContainer), new ConstantParameter("jetspeed")} )

   }

   

  -//

  -// Persistence

  -PersistenceContainer pContainer = new DefaultPersistenceStoreContainer(300000, 
10000)

  -

  -// ComponentAdapter ca = new ConstructorComponentAdapter("jetspeed", OTMStoreImpl, 
new Parameter[] {new ConstantParameter("jetspeed")})

  -ComponentAdapter ca = new ConstructorComponentAdapter("jetspeed", PBStore, new 
Parameter[] {new ConstantParameter("jetspeed")})

  -

  -pContainer.registerComponent(ca)

  -

  -container.registerComponentInstance(PersistenceStoreContainer, pContainer);

  -

  -//

  -// Portlet Registry

  -//

  -container.registerComponentImplementation(PortletRegistryComponent, 
PortletRegistryComponentImpl, new Parameter[] {new 
ComponentParameter(PersistenceStoreContainer), new ConstantParameter("jetspeed")} );

   

  +// This will be an empty container if "parent" was not null

   return container

  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to