dlestrat 2004/03/09 14:32:42
Modified: components/prefs/src/java/org/apache/jetspeed/containers
prefs.container.groovy
Log:
Now using container assembly. Would like to get component instance for
PreferencesProvider in the container assembly. Not working for some reason.
Getting the provider instance when needed in the tests.
Revision Changes Path
1.6 +28 -54
jakarta-jetspeed-2/components/prefs/src/java/org/apache/jetspeed/containers/prefs.container.groovy
Index: prefs.container.groovy
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/components/prefs/src/java/org/apache/jetspeed/containers/prefs.container.groovy,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- prefs.container.groovy 9 Mar 2004 15:57:58 -0000 1.5
+++ prefs.container.groovy 9 Mar 2004 22:32:42 -0000 1.6
@@ -1,18 +1,9 @@
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.picocontainer.defaults.ConstructorComponentAdapter
+
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
@@ -24,48 +15,31 @@
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 Preferences
+ * component. We want the Preferences 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 Preferences.
+ */
+
+// 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(PropertyManager, PropertyManagerImpl,
new Parameter[] {new ComponentParameter(PersistenceStoreContainer), new
ConstantParameter("jetspeed")} );
+ ComponentAdapter ca = new ConstructorComponentAdapter(PreferencesProvider,
PreferencesProviderImpl, new Parameter[] {new
ComponentParameter(PersistenceStoreContainer), new ConstantParameter("jetspeed"), new
ConstantParameter("org.apache.jetspeed.prefs.impl.PreferencesFactoryImpl")})
+ parent.registerComponent(ca)
}
-
-//
-// Persistence
-PersistenceStoreContainer pContainer = new DefaultPersistenceStoreContainer(300000,
10000)
-
-ComponentAdapter ca = new ConstructorComponentAdapter("jetspeed", PBStore, new
Parameter[] {new ConstantParameter("jetspeed")})
-
-pContainer.registerComponent(ca)
-
-container.registerComponentInstance(PersistenceStoreContainer, pContainer);
-
-container.registerComponentInstance(PreferencesProvider, new
PreferencesProviderImpl(pContainer, "jetspeed",
"org.apache.jetspeed.prefs.impl.PreferencesFactoryImpl"))
-
-//
-// Property Manager
-//
-container.registerComponentImplementation(PropertyManager, PropertyManagerImpl, new
Parameter[] {new ComponentParameter(PersistenceStoreContainer), new
ConstantParameter("jetspeed")} );
-
-return container
+else
+{
+ container = new DefaultPicoContainer()
+ container.registerComponentImplementation(PropertyManager, PropertyManagerImpl,
new Parameter[] {new ComponentParameter(PersistenceStoreContainer), new
ConstantParameter("jetspeed")} );
+ ComponentAdapter ca = new ConstructorComponentAdapter(PreferencesProvider,
PreferencesProviderImpl, new Parameter[] {new
ComponentParameter(PersistenceStoreContainer), new ConstantParameter("jetspeed"), new
ConstantParameter("org.apache.jetspeed.prefs.impl.PreferencesFactoryImpl")})
+ container.registerComponent(ca)
+}
+
+// This will be an empty container if "parent" was not null
+return container
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]