You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by bl...@apache.org on 2003/10/01 14:30:00 UTC

cvs commit: avalon/fortress/container/src/impl/org/apache/avalon/fortress/impl/handler PerThreadComponentHandler.java

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