cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pruss...@apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon DefaultComponentManager.java CocoonComponentSelector.java
Date Sat, 03 Mar 2001 16:00:40 GMT
prussell    01/03/03 08:00:40

  Modified:    src/org/apache/cocoon Tag: xml-cocoon2
                        DefaultComponentManager.java
                        CocoonComponentSelector.java
  Log:
  Fixed lifecycle semantic, and added handling for Disposable components.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.23  +17 -3     xml-cocoon/src/org/apache/cocoon/Attic/DefaultComponentManager.java
  
  Index: DefaultComponentManager.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Attic/DefaultComponentManager.java,v
  retrieving revision 1.1.2.22
  retrieving revision 1.1.2.23
  diff -u -r1.1.2.22 -r1.1.2.23
  --- DefaultComponentManager.java	2001/02/28 17:40:25	1.1.2.22
  +++ DefaultComponentManager.java	2001/03/03 16:00:35	1.1.2.23
  @@ -24,6 +24,7 @@
   import org.apache.avalon.ThreadSafe;
   import org.apache.avalon.Poolable;
   import org.apache.avalon.Recyclable;
  +import org.apache.avalon.Disposable;
   import org.apache.avalon.Configurable;
   import org.apache.avalon.Configuration;
   import org.apache.avalon.Composer;
  @@ -41,7 +42,7 @@
   
   /** Default component manager for Cocoon's non sitemap components.
    * @author <a href="mailto:paul@luminas.co.uk">Paul Russell</a>
  - * @version CVS $Revision: 1.1.2.22 $ $Date: 2001/02/28 17:40:25 $
  + * @version CVS $Revision: 1.1.2.23 $ $Date: 2001/03/03 16:00:35 $
    */
   public class DefaultComponentManager implements ComponentManager, Loggable, Configurable,
Contextualizable {
   
  @@ -295,14 +296,27 @@
       }
   
       public void release(Component component) {
  +        if (component instanceof Disposable) {
  +            try { 
  +                ((Disposable) component).dispose();
  +            } catch ( Exception e ) {
  +                this.log.warn(
  +                    "Exception while disposing of an instance of " + component.getClass().getName()
+ ".",
  +                    e
  +                );
  +            }
  +        }
  +        
  +        if (component instanceof Recyclable) {
  +            ((Recyclable) component).recycle();
  +        }
  +        
           if (component instanceof Poolable) {
               ComponentPool pool = (ComponentPool) pools.get(component.getClass());
   
               if (pool != null) {
                   pool.put((Poolable) component);
               }
  -        } else if (component instanceof Recyclable) {
  -            ((Recyclable) component).recycle();
           }
       }
   
  
  
  
  1.1.2.26  +18 -3     xml-cocoon/src/org/apache/cocoon/Attic/CocoonComponentSelector.java
  
  Index: CocoonComponentSelector.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Attic/CocoonComponentSelector.java,v
  retrieving revision 1.1.2.25
  retrieving revision 1.1.2.26
  diff -u -r1.1.2.25 -r1.1.2.26
  --- CocoonComponentSelector.java	2001/03/01 15:45:26	1.1.2.25
  +++ CocoonComponentSelector.java	2001/03/03 16:00:36	1.1.2.26
  @@ -28,6 +28,7 @@
   import org.apache.avalon.SingleThreaded;
   import org.apache.avalon.ThreadSafe;
   import org.apache.avalon.Poolable;
  +import org.apache.avalon.Disposable;
   import org.apache.avalon.Configurable;
   import org.apache.avalon.Configuration;
   import org.apache.avalon.Composer;
  @@ -43,7 +44,7 @@
   /** Default component manager for Cocoon's non sitemap components.
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:paul@luminas.co.uk">Paul Russell</a>
  - * @version CVS $Revision: 1.1.2.25 $ $Date: 2001/03/01 15:45:26 $
  + * @version CVS $Revision: 1.1.2.26 $ $Date: 2001/03/03 16:00:36 $
    */
   public class CocoonComponentSelector implements Contextualizable, ComponentSelector, Composer,
Configurable, ThreadSafe, Loggable {
       protected Logger log;
  @@ -259,6 +260,21 @@
       }
   
       public void release(Component component) {
  +        if (component instanceof Disposable) {
  +            try {
  +                ((Disposable) component).dispose();
  +            } catch (Exception e) {
  +                this.log.warn(
  +                    "Could not dispose of instance of component " + component.getClass().getName()
+ ".",
  +                    e
  +                );
  +            }
  +        }
  +        
  +        if (component instanceof Recyclable) {
  +            ((Recyclable) component).recycle();
  +        }
  +        
           if (component instanceof Poolable) {
               ComponentPool pool = (ComponentPool) pools.get(component.getClass());
   
  @@ -267,9 +283,8 @@
               } else {
                   log.debug("Could not find pool for:" + component.getClass());
               }
  -        } else if (component instanceof Recyclable) {
  -            ((Recyclable) component).recycle();
           }
  +
       }
   
       /** Configure a new component.
  
  
  

Mime
View raw message