cziegeler    2004/01/21 00:34:24

  Modified:    component/src/java/org/apache/avalon/excalibur/component
                        DefaultComponentFactory.java
                        ExcaliburComponentSelector.java
                        ExcaliburComponentManager.java
  Log:
  Remove use of component.toString() as this causes threading problems in some cases
  Change from StaticBucketMap to HashMap as the StaticBucketMap seems not to be thread 
safe in all situations
  
  Revision  Changes    Path
  1.2       +5 -3      
avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/DefaultComponentFactory.java
  
  Index: DefaultComponentFactory.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/DefaultComponentFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultComponentFactory.java      9 Nov 2003 12:45:26 -0000       1.1
  +++ DefaultComponentFactory.java      21 Jan 2004 08:34:24 -0000      1.2
  @@ -49,6 +49,9 @@
   */
   package org.apache.avalon.excalibur.component;
   
  +import java.util.HashMap;
  +import java.util.Map;
  +
   import org.apache.avalon.excalibur.logger.LogKitManageable;
   import org.apache.avalon.excalibur.pool.ObjectFactory;
   import org.apache.avalon.framework.activity.Disposable;
  @@ -66,7 +69,6 @@
   import org.apache.avalon.framework.service.Serviceable;
   import org.apache.avalon.framework.service.WrapperServiceManager;
   import org.apache.avalon.framework.thread.ThreadSafe;
  -import org.apache.commons.collections.StaticBucketMap;
   import org.apache.excalibur.instrument.InstrumentManageable;
   import org.apache.excalibur.instrument.InstrumentManager;
   import org.apache.excalibur.instrument.Instrumentable;
  @@ -120,7 +122,7 @@
        *  proxies, if they are Composables.  These must be seperate maps in case
        *  a component falls into more than one category, which they often do.
        */
  -    private final StaticBucketMap m_componentProxies = new StaticBucketMap();
  +    private final Map m_componentProxies = new HashMap();
   
       /** Instrument Manager to register objects created by this factory with (May be 
null). */
       private InstrumentManager m_instrumentManager;
  
  
  
  1.2       +10 -9     
avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentSelector.java
  
  Index: ExcaliburComponentSelector.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentSelector.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExcaliburComponentSelector.java   9 Nov 2003 12:45:27 -0000       1.1
  +++ ExcaliburComponentSelector.java   21 Jan 2004 08:34:24 -0000      1.2
  @@ -50,8 +50,10 @@
   package org.apache.avalon.excalibur.component;
   
   import java.util.ArrayList;
  +import java.util.HashMap;
   import java.util.Iterator;
   import java.util.List;
  +import java.util.Map;
   
   import org.apache.avalon.excalibur.logger.LogKitManageable;
   import org.apache.avalon.excalibur.logger.LogKitManager;
  @@ -69,7 +71,6 @@
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.thread.ThreadSafe;
  -import org.apache.commons.collections.StaticBucketMap;
   import org.apache.excalibur.instrument.Instrument;
   import org.apache.excalibur.instrument.InstrumentManageable;
   import org.apache.excalibur.instrument.InstrumentManager;
  @@ -125,11 +126,11 @@
   
       /** Static component handlers.
        */
  -    private StaticBucketMap m_componentHandlers = new StaticBucketMap();
  +    private Map m_componentHandlers = new HashMap();
   
       /** Dynamic component handlers mapping.
        */
  -    private StaticBucketMap m_componentMapping = new StaticBucketMap();
  +    private Map m_componentMapping = new HashMap();
   
       /** Flag for if this is disposed or not.
        */
  @@ -273,7 +274,7 @@
               throw new ComponentException( hint.toString(), message );
           }
   
  -        m_componentMapping.put( component.toString(), handler );
  +        m_componentMapping.put( component, handler );
           return component;
       }
   
  @@ -311,7 +312,7 @@
           }
   
           final ComponentHandler handler =
  -            (ComponentHandler)m_componentMapping.get( component.toString() );
  +            (ComponentHandler)m_componentMapping.get( component );
   
           if( null == handler )
           {
  @@ -330,7 +331,7 @@
               // Remove the component before calling put.  This is critical to avoid 
the
               //  problem where another thread calls put on the same component before
               //  remove can be called.
  -            m_componentMapping.remove( component.toString() );
  +            m_componentMapping.remove( component );
           }
   
           try
  @@ -350,7 +351,7 @@
        * Is this component looked up using this selector?
        */
       protected boolean canRelease(final Component component) {
  -          return m_componentMapping.containsKey( component.toString() );
  +          return m_componentMapping.containsKey( component );
       }
   
       /*---------------------------------------------------------------
  @@ -700,7 +701,7 @@
        *
        * @return A reference to the componentHandler Map.
        */
  -    protected StaticBucketMap getComponentHandlers()
  +    protected Map getComponentHandlers()
       {
           return m_componentHandlers;
       }
  
  
  
  1.2       +5 -4      
avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentManager.java
  
  Index: ExcaliburComponentManager.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExcaliburComponentManager.java    9 Nov 2003 12:45:27 -0000       1.1
  +++ ExcaliburComponentManager.java    21 Jan 2004 08:34:24 -0000      1.2
  @@ -50,8 +50,10 @@
   package org.apache.avalon.excalibur.component;
   
   import java.util.ArrayList;
  +import java.util.HashMap;
   import java.util.Iterator;
   import java.util.List;
  +import java.util.Map;
   
   import org.apache.avalon.excalibur.logger.LogKitManageable;
   import org.apache.avalon.excalibur.logger.LogKitManager;
  @@ -67,7 +69,6 @@
   import org.apache.avalon.framework.configuration.DefaultConfiguration;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.Contextualizable;
  -import org.apache.commons.collections.StaticBucketMap;
   import org.apache.excalibur.instrument.Instrument;
   import org.apache.excalibur.instrument.InstrumentManageable;
   import org.apache.excalibur.instrument.InstrumentManager;
  @@ -112,10 +113,10 @@
       private Context m_context;
   
       /** Static component mapping handlers. */
  -    private final StaticBucketMap m_componentMapping = new StaticBucketMap();
  +    private final Map m_componentMapping = new HashMap();
   
       /** Used to map roles to ComponentHandlers. */
  -    private final StaticBucketMap m_componentHandlers = new StaticBucketMap();
  +    private final Map m_componentHandlers = new HashMap();
   
       /** added component handlers before initialization to maintain
        *  the order of initialization
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to