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 16:14:32 GMT
bloritsch    02/02/18 08:14:32

  Modified:    src/scratchpad/org/apache/avalon/excalibur/system/handler
                        PoolableComponentHandler.java
  Log:
  make pool initialization asynchronous
  
  Revision  Changes    Path
  1.8       +17 -13    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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PoolableComponentHandler.java	18 Feb 2002 15:40:46 -0000	1.7
  +++ PoolableComponentHandler.java	18 Feb 2002 16:14:32 -0000	1.8
  @@ -25,18 +25,18 @@
    * and destroyed correctly.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.7 $ $Date: 2002/02/18 15:40:46 $
  + * @version CVS $Revision: 1.8 $ $Date: 2002/02/18 16:14:32 $
    * @since 4.0
    */
   public final class PoolableComponentHandler implements ComponentHandler {
       /** The instance of the ComponentFactory that creates and disposes of the Component
*/
       private final ComponentFactory     m_factory;
   
  -    /** The pool of components for <code>Poolable</code> Components */
  -    private final Pool                 m_pool;
  +    /** The instance of the PoolManager to create the Pool for the Handler */
  +    private final PoolManager          m_poolManager;
   
  -    /** State management boolean stating whether the Handler is initialized or not */
  -    private boolean                    m_initialized   = false;
  +    /** The pool of components for <code>Poolable</code> Components */
  +    private       Pool                 m_pool;
   
       /** State management boolean stating whether the Handler is disposed or not */
       private boolean                    m_disposed      = false;
  @@ -44,6 +44,9 @@
       /** Logger for PoolableComponentHandler */
       private final Logger               m_logger;
   
  +    /** The Config element for the poolable */
  +    private final int                  m_poolMin;
  +
   
       /**
        * Create a ComponentHandler that takes care of hiding the details of
  @@ -56,38 +59,39 @@
                                           final Context context )
           throws Exception
       {
  +        m_poolMin = config.getAttributeAsInteger( "pool-min", 10 );
           RoleManager roles = (RoleManager) context.get( Container.ROLE_MANAGER );
           LoggerManager logkit = (LoggerManager) context.get( Container.LOGGER_MANAGER );
           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_poolManager = (PoolManager) context.get( Container.POOL_MANAGER );
       }
   
       public boolean isInitialized()
       {
  -        return m_initialized;
  +        return null != m_pool;
       }
   
       /**
        * Initialize the ComponentHandler.
        */
       public void initialize()
  +        throws Exception
       {
  -        if( m_initialized )
  +        if( null != m_pool )
           {
               return;
           }
   
  +        m_pool = m_poolManager.getManagedPool( m_factory, m_poolMin );
  +
           if (m_logger.isDebugEnabled())
           {
               m_logger.debug( "ComponentHandler initialized for: " +
                                  m_factory.getCreatedClass().getName() );
           }
  -
  -        m_initialized = true;
       }
   
       /**
  @@ -96,7 +100,7 @@
       public Component get()
           throws Exception
       {
  -        if( ! m_initialized )
  +        if( null == m_pool )
           {
               throw new IllegalStateException( "You cannot get a component from an " +
                                                "uninitialized holder." );
  @@ -116,7 +120,7 @@
        */
       public void put( final Component component )
       {
  -        if( !m_initialized )
  +        if( null == m_pool )
           {
               throw new IllegalStateException( "You cannot put a component in " +
                                                "an uninitialized holder." );
  
  
  

--
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