CVS: plexus-container-new/src/java/org/apache/plexus DefaultPlexusContainer.java,1.16,1.17

[email protected] Mon, 28 Apr 2003 08:04:50 -0500
Newsgroups gmane.comp.java.plexus.devel
Message-ID <[email protected]>
Update of /cvsroot/plexus/plexus-container-new/src/java/org/apache/plexus
In directory eng.werken.com:/tmp/cvs-serv15437/src/java/org/apache/plexus

Modified Files:
	DefaultPlexusContainer.java 
Log Message:
o Making the resource manager pluggable and it's about to be cleaned up.


Index: DefaultPlexusContainer.java
===================================================================
RCS file: /cvsroot/plexus/plexus-container-new/src/java/org/apache/plexus/DefaultPlexusContainer.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- DefaultPlexusContainer.java	28 Apr 2003 04:46:15 -0000	1.16
+++ DefaultPlexusContainer.java	28 Apr 2003 13:04:48 -0000	1.17
@@ -60,7 +60,8 @@
 import com.werken.classworlds.NoSuchRealmException;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.service.ServiceException;
-import org.apache.plexus.classloader.ResourceManager;
+import org.apache.plexus.classloader.DefaultResourceManager;
+import org.apache.plexus.classloader.ResourceManagerFactory;
 import org.apache.plexus.configuration.ConfigurationResourceException;
 import org.apache.plexus.configuration.DefaultConfigurationBuilder;
 import org.apache.plexus.context.DefaultContext;
@@ -87,6 +88,10 @@
  *  @version $Id$
  *
  *  @todo Make ClassWorlds optional so we can make the runtime tiny.
+ *  @todo the container itself must be able to behave like a normal
+ *        component so that we can deal with hierachies. In the majority of
+ *        cases the derived container will take a lot of configuration information
+ *        from the parent.
  */
 public class DefaultPlexusContainer
     extends AbstractLogEnabled
@@ -133,7 +138,7 @@
      *  Resource manager for this container. It is available via the context using
      *  plexus:resource-manager key.
      */
-    private ResourceManager resourceManager;
+    private DefaultResourceManager resourceManager;
 
     /** Default Configuration Builder. */
     private DefaultConfigurationBuilder builder;
@@ -376,11 +381,18 @@
     protected void initializeResourceManager()
         throws Exception
     {
-        // Resource Manager
-        setResourceManager( new ResourceManager( getClassLoader() ) );
-        setupLogger( getResourceManager(), "resource-manager" );
-        getResourceManager().configure( configuration.getChild( "resources" ) );
-        setClassLoader( getResourceManager().getClassLoader() );
+        DefaultResourceManager rm =
+            ResourceManagerFactory.create( getDefaultConfiguration(),
+                                           getConfiguration(),
+                                           getLoggerManager(),
+                                           getClassLoader() );
+
+        // This needs to be completely clarified. If the container becomes the boundary
+        // and barrier between all behaviour in plexus then the subsystems like classworlds
+        // can't undermine the barrier. This behaviour is also dependent on composite
+        // and primitive components a la SOFA.
+        setResourceManager( rm );
+        setClassLoader( rm.getPlexusClassLoader() );
         Thread.currentThread().setContextClassLoader( getClassLoader() );
     }
 
@@ -487,7 +499,7 @@
      *
      * @param resourceManager
      */
-    void setResourceManager( ResourceManager resourceManager )
+    void setResourceManager( DefaultResourceManager resourceManager )
     {
         this.resourceManager = resourceManager;
     }
@@ -497,7 +509,7 @@
      *
      *  @return The resource manager.
      */
-    ResourceManager getResourceManager()
+    DefaultResourceManager getResourceManager()
     {
         return resourceManager;
     }