You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by br...@apache.org on 2003/05/20 14:38:28 UTC

cvs commit: cocoon-2.1/src/webapp/WEB-INF web.xml

bruno       2003/05/20 05:38:27

  Modified:    src/java/org/apache/cocoon/servlet CocoonServlet.java
               src/webapp/WEB-INF web.xml
  Log:
  * Applied patch by Unico Hommes (unico@hippo.nl) to dispose the parent
  component manager (if any). (bugzilla 15312)
  * Fixed a problem with the init-param for parent component manager being
  null on cocoon-reload.
  
  Revision  Changes    Path
  1.7       +20 -10    cocoon-2.1/src/java/org/apache/cocoon/servlet/CocoonServlet.java
  
  Index: CocoonServlet.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/servlet/CocoonServlet.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- CocoonServlet.java	29 Apr 2003 10:45:21 -0000	1.6
  +++ CocoonServlet.java	20 May 2003 12:38:27 -0000	1.7
  @@ -79,6 +79,7 @@
   
   import org.apache.avalon.excalibur.logger.DefaultLogKitManager;
   import org.apache.avalon.excalibur.logger.LogKitManager;
  +import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.configuration.Configuration;
  @@ -209,6 +210,10 @@
       protected boolean initClassLoader = false;
   
       private String parentComponentManagerClass;
  +    private String parentComponentManagerInitParam;
  +
  +    /** The parent ComponentManager, if any. Stored here in order to be able to dispose it in destroy(). */
  +    private ComponentManager parentComponentManager;
   
       protected String forceLoadParameter;
       protected String forceSystemProperty;
  @@ -509,6 +514,12 @@
               if (log.isDebugEnabled()) {
                   log.debug("parent-component-manager was not set - defaulting to null.");
               }
  +        } else {
  +            int dividerPos = parentComponentManagerClass.indexOf('/');
  +            if (dividerPos != -1) {
  +                parentComponentManagerInitParam = parentComponentManagerClass.substring(dividerPos + 1);
  +                parentComponentManagerClass = parentComponentManagerClass.substring(0, dividerPos);
  +            }
           }
   
           this.containerEncoding = conf.getInitParameter("container-encoding");
  @@ -575,6 +586,10 @@
           if (this.enableInstrumentation) {
               this.instrumentManager.dispose();
           }
  +        
  +        if (this.parentComponentManager != null && this.parentComponentManager instanceof Disposable) {
  +            ((Disposable)this.parentComponentManager).dispose();
  +        }
       }
   
       /**
  @@ -1308,19 +1323,14 @@
        * @return the parent component manager, or <code>null</code>.
        */
       protected synchronized ComponentManager getParentComponentManager() {
  -        ComponentManager parentComponentManager = null;
  +        if (parentComponentManager != null && parentComponentManager instanceof Disposable)
  +            ((Disposable)parentComponentManager).dispose();
  +        parentComponentManager = null;
           if (parentComponentManagerClass != null) {
               try {
  -                String initParam = null;
  -                int dividerPos = parentComponentManagerClass.indexOf('/');
  -                if (dividerPos != -1) {
  -                    initParam = parentComponentManagerClass.substring(dividerPos + 1);
  -                    parentComponentManagerClass = parentComponentManagerClass.substring(0, dividerPos);
  -                }
  -
                   Class pcm = ClassUtils.loadClass(parentComponentManagerClass);
                   Constructor pcmc = pcm.getConstructor(new Class[]{String.class});
  -                parentComponentManager = (ComponentManager) pcmc.newInstance(new Object[]{initParam});
  +                parentComponentManager = (ComponentManager) pcmc.newInstance(new Object[]{parentComponentManagerInitParam});
   
                   if (parentComponentManager instanceof LogEnabled) {
                       ((LogEnabled) parentComponentManager).enableLogging(new LogKitLogger(log));
  
  
  
  1.4       +1 -1      cocoon-2.1/src/webapp/WEB-INF/web.xml
  
  Index: web.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/webapp/WEB-INF/web.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- web.xml	27 Apr 2003 18:10:29 -0000	1.3
  +++ web.xml	20 May 2003 12:38:27 -0000	1.4
  @@ -238,7 +238,7 @@
         String as a parameter. That String will be equal to the text after the
         '/'.
   
  -      Cocoon honors the LogEnabled and Initializable interfaces for this class,
  +      Cocoon honors the LogEnabled, Initializable and Disposable interfaces for this class,
         if it implements them.
   
         If you uncomment the following lines the parent CM is set to the Parent CM sample, which will look up