avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: avalon/fortress/container/src/impl/org/apache/avalon/fortress/impl/handler PerThreadComponentHandler.java
Date Wed, 01 Oct 2003 12:30:00 GMT
bloritsch    2003/10/01 05:30:00

  Modified:    fortress/container/src/impl/org/apache/avalon/fortress/impl/handler
                        PerThreadComponentHandler.java
  Log:
  Update the BCEL code again to avoid the erronious INVUpdate the PerThreadComponentHandler
to clean up all components, not just the current thread's
  
  Revision  Changes    Path
  1.7       +19 -3     avalon/fortress/container/src/impl/org/apache/avalon/fortress/impl/handler/PerThreadComponentHandler.java
  
  Index: PerThreadComponentHandler.java
  ===================================================================
  RCS file: /home/cvs/avalon/fortress/container/src/impl/org/apache/avalon/fortress/impl/handler/PerThreadComponentHandler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PerThreadComponentHandler.java	18 Apr 2003 20:02:29 -0000	1.6
  +++ PerThreadComponentHandler.java	1 Oct 2003 12:30:00 -0000	1.7
  @@ -48,6 +48,12 @@
   */
   package org.apache.avalon.fortress.impl.handler;
   
  +import java.util.Collections;
  +import java.util.Iterator;
  +import java.util.LinkedList;
  +import java.util.List;
  +
  +
   /**
    * The ThreadSafeComponentHandler to make sure components are initialized
    * and destroyed correctly.
  @@ -60,12 +66,14 @@
       extends AbstractComponentHandler
   {
       private ThreadLocalComponent m_instance;
  +    private List m_instances;
   
       public void initialize()
           throws Exception
       {
           super.initialize();
           m_instance = new ThreadLocalComponent( this );
  +        m_instances = Collections.synchronizedList(new LinkedList());
       }
   
       /**
  @@ -85,8 +93,14 @@
   
       protected void doDispose()
       {
  -        disposeComponent( m_instance.get() );
  +        Iterator it = m_instances.iterator();
  +        while (it.hasNext())
  +        {
  +            disposeComponent( it.next() );
  +            it.remove();
  +        }
           m_instance = null;
  +        m_instances = null;
       }
   
       private static final class ThreadLocalComponent
  @@ -103,7 +117,9 @@
           {
               try
               {
  -                return m_handler.newComponent();
  +                Object component = m_handler.newComponent();
  +                m_handler.m_instances.add(component);
  +                return component;
               }
               catch ( final Exception e )
               {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message