cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject svn commit: r124094 - cocoon/trunk/src/core/java/org/apache/cocoon/core/container
Date Tue, 04 Jan 2005 10:58:24 GMT
Author: sylvain
Date: Tue Jan  4 02:58:22 2005
New Revision: 124094

URL: http://svn.apache.org/viewcvs?view=rev&rev=124094
Log:
remove the parentAware stuff which is specific to StandaloneServiceManager. It's now handled
in StandaloneServiceManager.Factory
Modified:
   cocoon/trunk/src/core/java/org/apache/cocoon/core/container/AbstractComponentHandler.java
   cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CoreServiceManager.java
   cocoon/trunk/src/core/java/org/apache/cocoon/core/container/RoleManager.java
   cocoon/trunk/src/core/java/org/apache/cocoon/core/container/StandaloneServiceSelector.java

Modified: cocoon/trunk/src/core/java/org/apache/cocoon/core/container/AbstractComponentHandler.java
Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/core/java/org/apache/cocoon/core/container/AbstractComponentHandler.java?view=diff&rev=124094&p1=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/AbstractComponentHandler.java&r1=124093&p2=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/AbstractComponentHandler.java&r2=124094
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/core/container/AbstractComponentHandler.java
(original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/core/container/AbstractComponentHandler.java
Tue Jan  4 02:58:22 2005
@@ -127,7 +127,7 @@
             
         } else if (StandaloneServiceSelector.class.isAssignableFrom(componentClass)) {
             // Special factory for StandaloneServiceSelector
-            factory = new StandaloneServiceSelector.Factory(env, roleManager, info);
+            factory = new StandaloneServiceSelector.Factory(env, roleManager, info, role);
                 
         } else {
             factory = new ComponentFactory(env, info);

Modified: cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CoreServiceManager.java
Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CoreServiceManager.java?view=diff&rev=124094&p1=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CoreServiceManager.java&r1=124093&p2=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CoreServiceManager.java&r2=124094
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CoreServiceManager.java	(original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CoreServiceManager.java	Tue
Jan  4 02:58:22 2005
@@ -65,10 +65,6 @@
      */
     private final List newComponentHandlers = new ArrayList();
 
-    /** Temporary list of parent-aware components.  Will be null for most of
-     * our lifecycle. */
-    private ArrayList parentAwareComponents = new ArrayList();
-
     /** The resolver used to resolve includes. It is lazily loaded in {@link #getSourceResolver()}.
*/
     private SourceResolver cachedSourceResolver;
 
@@ -106,6 +102,13 @@
     public void contextualize( final Context context ) {
         this.context = context;
     }
+    
+    public void setRoleManager (RoleManager rm) {
+        if (rm != null) {
+            // Override the one eventually got in the parent (see constructor)
+            this.roleManager = new RoleManager(rm);
+        }
+    }
 
     /* (non-Javadoc)
      * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
@@ -182,30 +185,6 @@
         }
         this.newComponentHandlers.clear();
         
-        // Initialize parent aware components
-        if (this.parentAwareComponents == null) {
-            throw new ServiceException(null, "CoreServiceManager already initialized");
-        }
-
-        // Set parents for parentAware components
-        Iterator iter = this.parentAwareComponents.iterator();
-        while (iter.hasNext()) {
-            String role = (String)iter.next();
-            if ( this.parentManager != null && this.parentManager.hasService( role
) ) {
-                // lookup new component
-                Object component = null;
-                try {
-                    component = this.lookup( role );
-                    ((CocoonServiceSelector)component).setParentLocator( this.parentManager,
role );
-                } catch (ServiceException ignore) {
-                    // we don't set the parent then
-                } finally {
-                    this.release( component );
-                }
-            }
-        }
-        this.parentAwareComponents = null;  // null to save memory, and catch logic bugs.
-        
 //        Object[] keyArray = this.componentHandlers.keySet().toArray();
 //        java.util.Arrays.sort(keyArray);
 //        for (int i = 0; i < keyArray.length; i++) {
@@ -498,9 +477,6 @@
             throw new ServiceException( role, "Could not set up component handler.", e );
         }
         
-        if ( CocoonServiceSelector.class.isAssignableFrom( component ) ) {
-            this.parentAwareComponents.add(role);
-        }
         // Initialize shadow selector now, it will feed this service manager
         if ( DefaultServiceSelector.class.isAssignableFrom( component )) {
             try {

Modified: cocoon/trunk/src/core/java/org/apache/cocoon/core/container/RoleManager.java
Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/core/java/org/apache/cocoon/core/container/RoleManager.java?view=diff&rev=124094&p1=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/RoleManager.java&r1=124093&p2=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/RoleManager.java&r2=124094
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/core/container/RoleManager.java	(original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/core/container/RoleManager.java	Tue Jan 
4 02:58:22 2005
@@ -251,32 +251,4 @@
             }
         }
     }
-    
-    
-    
-    private Set loadedURLs = new HashSet();
-    
-    public void loadFromClassPath() throws Exception {
-        ClassLoader cl = Thread.currentThread().getContextClassLoader();
-        Enumeration resources = cl.getResources("/org/apache/cocoon/cocoon.roles");
-        
-        while(resources.hasMoreElements()) {
-            URL url = (URL)resources.nextElement();
-            loadURL(url.toExternalForm());
-        }
-    }
-    
-    public void loadURL(String resource) throws Exception {
-        if (!hasLoaded(resource)) {
-            loadedURLs.add(resource);
-
-            ConfigurationBuilder builder = new ConfigurationBuilder();
-            Configuration config = builder.build(resource);
-            configure(config);
-        }
-    }
-    
-    public boolean hasLoaded(String resource) {
-        return loadedURLs.contains(resource) || (parent != null && parent.hasLoaded(resource));
-    }
 }

Modified: cocoon/trunk/src/core/java/org/apache/cocoon/core/container/StandaloneServiceSelector.java
Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/core/java/org/apache/cocoon/core/container/StandaloneServiceSelector.java?view=diff&rev=124094&p1=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/StandaloneServiceSelector.java&r1=124093&p2=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/StandaloneServiceSelector.java&r2=124094
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/core/container/StandaloneServiceSelector.java
(original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/core/container/StandaloneServiceSelector.java
Tue Jan  4 02:58:22 2005
@@ -426,20 +426,22 @@
      * @param locator
      * @throws ServiceException
      */
-    public void setParentLocator(ServiceManager locator, String role)
+    private void setParentLocator(ServiceManager locator, String role)
     throws ServiceException {
         if (this.parentSelector != null) {
             throw new ServiceException(null, "Parent selector is already set");
         }
         this.parentLocator = locator;
         
-        // Get the parent, unwrapping it as far as needed
-        Object parent = locator.lookup(role);
-        
-        if (parent instanceof CocoonServiceSelector) {
-            this.parentSelector = (CocoonServiceSelector)parent;
-        } else {
-            throw new IllegalArgumentException("Parent selector is not an extended component
selector (" + parent + ")");
+        if (locator != null && locator.hasService(role)) {
+            // Get the parent, unwrapping it as far as needed
+            Object parent = locator.lookup(role);
+            
+            if (parent instanceof CocoonServiceSelector) {
+                this.parentSelector = (CocoonServiceSelector)parent;
+            } else {
+                throw new IllegalArgumentException("Parent selector is not an extended component
selector (" + parent + ")");
+            }
         }
     }
 
@@ -457,11 +459,13 @@
     public static class Factory extends ComponentFactory {
         
         private final RoleManager roleManager;
+        private final String role;
         
-        public Factory(ComponentEnvironment env, RoleManager roleManager, ServiceInfo info)

+        public Factory(ComponentEnvironment env, RoleManager roleManager, ServiceInfo info,
String role) 
         throws Exception {
             super(env, info);
             this.roleManager = roleManager;
+            this.role = role;
         }
         
         protected void setupObject(Object obj)
@@ -474,6 +478,12 @@
             
             component.setLoggerManager(this.environment.loggerManager);
             component.setRoleManager(this.roleManager);
+
+            ServiceManager manager = this.environment.serviceManager;
+            if (manager instanceof CoreServiceManager) {
+                // Can it be something else?
+                component.setParentLocator( ((CoreServiceManager)manager).parentManager,
this.role);
+            }
             
             ContainerUtil.configure(component, this.serviceInfo.getConfiguration());
             ContainerUtil.initialize(component);

Mime
View raw message