bloritsch    01/03/16 13:46:08

  Modified:    src/org/apache/cocoon Tag: xml-cocoon2 Cocoon.java
               src/org/apache/cocoon/components Tag: xml-cocoon2
                        CocoonComponentHandler.java
                        CocoonComponentManager.java
  Log:
  Fixed ordering dependency from new ComponentManagement architecture
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.4.2.64  +2 -1      xml-cocoon/src/org/apache/cocoon/Cocoon.java
  
  Index: Cocoon.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Cocoon.java,v
  retrieving revision 1.4.2.63
  retrieving revision 1.4.2.64
  diff -u -r1.4.2.63 -r1.4.2.64
  --- Cocoon.java       2001/03/12 05:55:17     1.4.2.63
  +++ Cocoon.java       2001/03/16 21:45:57     1.4.2.64
  @@ -47,7 +47,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a> 
(Apache Software Foundation, Exoffice Technologies)
    * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.4.2.63 $ $Date: 2001/03/12 05:55:17 $
  + * @version CVS $Revision: 1.4.2.64 $ $Date: 2001/03/16 21:45:57 $
    */
   public class Cocoon extends AbstractLoggable implements Component, 
Initializable, Modifiable, Processor, Contextualizable {
       /** The application context */
  @@ -160,6 +160,7 @@
           }
           getLogger().debug("Setting up components...");
           this.componentManager.configure(conf);
  +        this.componentManager.init();
           getLogger().debug("Setting up the sitemap.");
           // Create the sitemap
           Configuration sconf = conf.getChild("sitemap");
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +2 -0      
xml-cocoon/src/org/apache/cocoon/components/Attic/CocoonComponentHandler.java
  
  Index: CocoonComponentHandler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/Attic/CocoonComponentHandler.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- CocoonComponentHandler.java       2001/03/16 19:54:04     1.1.2.1
  +++ CocoonComponentHandler.java       2001/03/16 21:46:03     1.1.2.2
  @@ -82,6 +82,8 @@
        * Initialize the ComponentHandler.
        */
       public void init() {
  +        if (this.initialized) return;
  +
           switch (this.type) {
               case CocoonComponentHandler.THREADSAFE:
                   try {
  
  
  
  1.1.2.4   +37 -30    
xml-cocoon/src/org/apache/cocoon/components/Attic/CocoonComponentManager.java
  
  Index: CocoonComponentManager.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/Attic/CocoonComponentManager.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- CocoonComponentManager.java       2001/03/16 20:13:50     1.1.2.3
  +++ CocoonComponentManager.java       2001/03/16 21:46:04     1.1.2.4
  @@ -23,6 +23,7 @@
   import org.apache.avalon.Composer;
   import org.apache.avalon.configuration.ConfigurationException;
   import org.apache.avalon.configuration.DefaultConfiguration;
  +import org.apache.avalon.Initializable;
   
   import org.apache.cocoon.util.ClassUtils;
   import org.apache.cocoon.util.RoleUtils;
  @@ -33,9 +34,9 @@
   
   /** Default component manager for Cocoon's non sitemap components.
    * @author <a href="mailto:[EMAIL PROTECTED]">Paul Russell</a>
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2001/03/16 20:13:50 $
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2001/03/16 21:46:04 $
    */
  -public class CocoonComponentManager implements ComponentManager, Loggable, 
Configurable, Contextualizable {
  +public class CocoonComponentManager implements ComponentManager, Loggable, 
Configurable, Contextualizable, Initializable {
   
       protected Logger log;
   
  @@ -43,7 +44,7 @@
        */
       private Context context;
   
  -    /** Static component handlers.
  +    /** Static component mapping handlers.
        */
       private Map componentMapping;
   
  @@ -71,6 +72,15 @@
           }
       }
   
  +    public void init() {
  +        Iterator i = this.componentHandlers.keySet().iterator();
  +
  +        while (i.hasNext()) {
  +            CocoonComponentHandler handler = (CocoonComponentHandler) 
this.componentHandlers.get(i.next());
  +            handler.init();
  +        }
  +    }
  +
       /** Return an instance of a component.
        */
       public Component lookup( String role )
  @@ -86,42 +96,41 @@
   
           handler = (CocoonComponentHandler) this.componentHandlers.get(role);
           // Retrieve the instance of the requested component
  -        if ( handler != null ) {
  +        if ( handler == null ) {
  +            this.log.debug("Could not find ComponentHandler, attempting to 
create one for role: " + role);
  +            Class componentClass = null;
  +            Configuration config = new DefaultConfiguration("", "-");
  +
               try {
  -                component = handler.get();
  +                componentClass = 
ClassUtils.loadClass(RoleUtils.defaultClass(role));
  +
  +                handler = new CocoonComponentHandler(componentClass, config, 
this, this.context);
  +                handler.setLogger(this.log);
  +                handler.init();
               } catch (Exception e) {
  -                throw new ComponentManagerException("Could not access the 
Component for you", e);
  +                log.error("CocoonComponentManager Could not find component 
for role: " + role, e);
  +                throw new ComponentManagerException("Could not find 
component for role: " + role, e);
               }
  -        }
   
  -        if (component != null) {
  -            this.componentMapping.put(component, handler);
  -            return component;
  -        }
  -
  -        Class componentClass = null;
  -        Configuration config = new DefaultConfiguration("", "-");
  -
  -        try {
  -            componentClass = 
ClassUtils.loadClass(RoleUtils.defaultClass(role));
  -        } catch (Exception e) {
  -            log.error("CocoonComponentManager Could not find component for 
role: " + role, e);
  -            throw new ComponentManagerException("Could not find component 
for role: " + role, e);
  +            this.componentHandlers.put(role, handler);
           }
   
           try {
  -            handler = new CocoonComponentHandler(componentClass, config, 
this, this.context);
  -            handler.setLogger(this.log);
  -            handler.init();
  -
  -            this.componentHandlers.put(role, handler);
               component = handler.get();
  -            this.componentMapping.put(component, handler);
  +        } catch (IllegalStateException ise) {
  +            handler.init();
   
  -            return component;
  +            try {
  +                component = handler.get();
  +            } catch (Exception ee) {
  +                throw new ComponentManagerException("Could not access the 
Component for you", ee);
  +            }
           } catch (Exception e) {
  -            throw new ComponentManagerException("Could not access the 
component for role: " + role, e);
  +            throw new ComponentManagerException("Could not access the 
Component for you", e);
           }
  +
  +        this.componentMapping.put(component, handler);
  +        return component;
       }
   
       public void configure(Configuration conf) throws ConfigurationException {
  @@ -193,7 +202,6 @@
           try {
               CocoonComponentHandler handler = new 
CocoonComponentHandler(component, config, this, this.context);
               handler.setLogger(this.log);
  -            handler.init();
               this.componentHandlers.put(role, handler);
           } catch (Exception e) {
               throw new ComponentManagerException ("Could not set up Component 
for role: " + role, e);
  @@ -208,7 +216,6 @@
           try {
               CocoonComponentHandler handler = new 
CocoonComponentHandler((Component) instance);
               handler.setLogger(this.log);
  -            handler.init();
               this.componentHandlers.put(role, handler);
           } catch (Exception e) {
               this.log.warn("Could not set up Component for role: " + role, e);
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to