avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/handler PoolableComponentHandler.java
Date Mon, 18 Feb 2002 15:40:46 GMT
bloritsch    02/02/18 07:40:46

  Modified:    src/scratchpad/org/apache/avalon/excalibur/mpool
                        DefaultPoolManager.java VariableSizePool.java
               src/scratchpad/org/apache/avalon/excalibur/system
                        AbstractContainer.java
               src/scratchpad/org/apache/avalon/excalibur/system/handler
                        PoolableComponentHandler.java
  Log:
  make ContainerProfile actually run, it is *alot* faster
  
  Revision  Changes    Path
  1.2       +9 -10     jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/mpool/DefaultPoolManager.java
  
  Index: DefaultPoolManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/mpool/DefaultPoolManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultPoolManager.java	12 Feb 2002 21:30:42 -0000	1.1
  +++ DefaultPoolManager.java	18 Feb 2002 15:40:46 -0000	1.2
  @@ -7,12 +7,11 @@
    */
   package org.apache.avalon.excalibur.mpool;
   
  +import org.apache.avalon.excalibur.collections.BucketMap;
   import org.apache.avalon.excalibur.command.RepeatedCommand;
   import org.apache.avalon.excalibur.event.Queue;
   
  -import java.util.HashMap;
   import java.util.Iterator;
  -import java.util.Map;
   import java.util.Random;
   
   /**
  @@ -21,15 +20,15 @@
    * the constructor.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/02/12 21:30:42 $
  + * @version CVS $Revision: 1.2 $ $Date: 2002/02/18 15:40:46 $
    * @since 4.1
    */
   public class DefaultPoolManager implements PoolManager
   {
       private final long          m_managerKey;
       private final Random        m_keyGenerator;
  -    private final HashMap       m_keyMap = new HashMap();
  -    private final HashMap       m_factoryMap = new HashMap();
  +    private final BucketMap     m_keyMap = new BucketMap();
  +    private final BucketMap     m_factoryMap = new BucketMap();
   
       public DefaultPoolManager()
       {
  @@ -83,12 +82,12 @@
   
       private final static class PoolManagerCommand implements RepeatedCommand
       {
  -        private final Map m_map;
  -        private final int m_min = 4;
  -        private final int m_max = 256;
  -        private final int m_grow = 4;
  +        private final BucketMap m_map;
  +        private final int       m_min = 4;
  +        private final int       m_max = 256;
  +        private final int       m_grow = 4;
   
  -        protected PoolManagerCommand( Map map )
  +        protected PoolManagerCommand( BucketMap map )
           {
               m_map = map;
           }
  
  
  
  1.3       +6 -3      jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/mpool/VariableSizePool.java
  
  Index: VariableSizePool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/mpool/VariableSizePool.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- VariableSizePool.java	13 Feb 2002 16:19:53 -0000	1.2
  +++ VariableSizePool.java	18 Feb 2002 15:40:46 -0000	1.3
  @@ -18,7 +18,7 @@
    * Please note that this pool offers no resource limiting whatsoever.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2002/02/13 16:19:53 $
  + * @version CVS $Revision: 1.3 $ $Date: 2002/02/18 15:40:46 $
    * @since 4.1
    */
   public final class VariableSizePool
  @@ -48,9 +48,12 @@
           m_factory = factory;
           m_key = key;
   
  -        for ( int i = 0; i < size; i++ )
  +        synchronized (m_factory)
           {
  -            m_buffer.add( newInstance() );
  +            for ( int i = 0; i < size; i++ )
  +            {
  +                m_buffer.add( newInstance() );
  +            }
           }
       }
   
  
  
  
  1.21      +20 -9     jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/AbstractContainer.java
  
  Index: AbstractContainer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/AbstractContainer.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- AbstractContainer.java	18 Feb 2002 14:21:01 -0000	1.20
  +++ AbstractContainer.java	18 Feb 2002 15:40:46 -0000	1.21
  @@ -34,7 +34,7 @@
    * Manager can expose that to the instantiating class.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.20 $ $Date: 2002/02/18 14:21:01 $
  + * @version CVS $Revision: 1.21 $ $Date: 2002/02/18 15:40:46 $
    */
   public abstract class AbstractContainer
      extends AbstractLogEnabled
  @@ -42,7 +42,6 @@
   {
       protected Context                m_context;
       private   ComponentManager       m_manager;
  -    protected ComponentManager       m_childManager;
       protected LoggerManager          m_logManager;
       protected PoolManager            m_poolManager;
       protected Queue                  m_commandQueue;
  @@ -248,7 +247,10 @@
               Class handlerKlass = m_classLoader.loadClass( handlerClassName );
               constructor = handlerKlass.getConstructor( ComponentHandler.HANDLER_CONSTRUCTOR
);
               handler = (ComponentHandler) constructor.newInstance(new Object[] {
  -                klass, configuration, m_childManager, m_context
  +                klass,
  +                configuration,
  +                new ContainerComponentManager( this, m_manager ),
  +                m_context
               });
           }
           catch ( Exception e )
  @@ -331,13 +333,24 @@
        */
       protected boolean has( final String role, final Object hint )
       {
  +        BucketMap hintMap = (BucketMap) m_mapper.get( role );
  +
  +        if ( null == hintMap )
  +        {
  +            return false;
  +        }
  +
           if ( null == hint )
           {
  -            return m_mapper.keySet().contains( role );
  +            if ( ! hintMap.containsKey( "selector" ) )
  +            {
  +                return hintMap.containsKey( "default" );
  +            }
  +
  +            return false;
           }
   
  -        BucketMap hintMap = (BucketMap) m_mapper.get( role );
  -        return hintMap.keySet().contains( hint );
  +        return hintMap.containsKey( hint );
       }
   
       /**
  @@ -356,8 +369,6 @@
       public void initialize()
           throws Exception
       {
  -        m_childManager = new ContainerComponentManager( this, m_manager );
  -
           Iterator i = m_components.iterator();
           FixedSizeBuffer buffer = new FixedSizeBuffer( m_components.size() );
   
  @@ -439,7 +450,7 @@
        * @return the child component manager
        */
       protected final ComponentManager getComponentManager() {
  -        return m_childManager;
  +        return new ContainerComponentManager( this, m_manager );
       }
   
       /**
  
  
  
  1.7       +2 -2      jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/handler/PoolableComponentHandler.java
  
  Index: PoolableComponentHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/handler/PoolableComponentHandler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PoolableComponentHandler.java	14 Feb 2002 22:00:29 -0000	1.6
  +++ PoolableComponentHandler.java	18 Feb 2002 15:40:46 -0000	1.7
  @@ -25,7 +25,7 @@
    * and destroyed correctly.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.6 $ $Date: 2002/02/14 22:00:29 $
  + * @version CVS $Revision: 1.7 $ $Date: 2002/02/18 15:40:46 $
    * @since 4.0
    */
   public final class PoolableComponentHandler implements ComponentHandler {
  @@ -61,9 +61,9 @@
           m_factory =
               new ComponentFactory( componentClass, config, manager, context, roles, logkit
);
   
  +        m_logger = logkit.getLoggerForCategory("system.handler.poolable");
           PoolManager poolManager = (PoolManager) context.get( Container.POOL_MANAGER );
           m_pool = poolManager.getManagedPool( m_factory, config.getAttributeAsInteger( "pool-min",
10 ) );
  -        m_logger = logkit.getLoggerForCategory("system.handler.poolable");
       }
   
       public boolean isInitialized()
  
  
  

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


Mime
View raw message