avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component DefaultComponentPool.java DefaultComponentPoolController.java PoolableComponentHandler.java
Date Mon, 18 Feb 2002 10:14:44 GMT
leif        02/02/18 02:14:44

  Modified:    src/java/org/apache/avalon/excalibur/component
                        DefaultComponentPool.java
                        DefaultComponentPoolController.java
                        PoolableComponentHandler.java
  Log:
  Modified PoolableComponentHandler to make use of the
  ResourceLimitingPool.
  
  Revision  Changes    Path
  1.4       +3 -1      jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component/DefaultComponentPool.java
  
  Index: DefaultComponentPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component/DefaultComponentPool.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultComponentPool.java	11 Dec 2001 09:53:27 -0000	1.3
  +++ DefaultComponentPool.java	18 Feb 2002 10:14:44 -0000	1.4
  @@ -22,8 +22,10 @@
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  - * @version CVS $Revision: 1.3 $ $Date: 2001/12/11 09:53:27 $
  + * @version CVS $Revision: 1.4 $ $Date: 2002/02/18 10:14:44 $
    * @since 4.0
  + *
  + * @deprecated DefaultComponentPool is no longer used by the PoolableComponentHandler.
    */
   public class DefaultComponentPool
       extends SoftResourceLimitingPool
  
  
  
  1.5       +3 -1      jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component/DefaultComponentPoolController.java
  
  Index: DefaultComponentPoolController.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component/DefaultComponentPoolController.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultComponentPoolController.java	11 Dec 2001 09:53:27 -0000	1.4
  +++ DefaultComponentPoolController.java	18 Feb 2002 10:14:44 -0000	1.5
  @@ -16,8 +16,10 @@
    *
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.4 $ $Date: 2001/12/11 09:53:27 $
  + * @version CVS $Revision: 1.5 $ $Date: 2002/02/18 10:14:44 $
    * @since 4.0
  + *
  + * @deprecated DefaultComponentPool is no longer used by the PoolableComponentHandler.
    */
   public class DefaultComponentPoolController
       implements PoolController, ThreadSafe
  
  
  
  1.8       +79 -30    jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component/PoolableComponentHandler.java
  
  Index: PoolableComponentHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component/PoolableComponentHandler.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PoolableComponentHandler.java	11 Dec 2001 09:53:27 -0000	1.7
  +++ PoolableComponentHandler.java	18 Feb 2002 10:14:44 -0000	1.8
  @@ -7,35 +7,96 @@
    */
   package org.apache.avalon.excalibur.component;
   
  +import org.apache.avalon.excalibur.pool.Poolable;
  +import org.apache.avalon.excalibur.pool.ResourceLimitingPool;
  +import org.apache.avalon.excalibur.logger.LogKitManager;
  +
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.context.Context;
  -import org.apache.avalon.excalibur.pool.Poolable;
  -import org.apache.avalon.excalibur.logger.LogKitManager;
  +import org.apache.avalon.framework.logger.LogKitLogger;
  +
   import org.apache.log.Logger;
   
   /**
  - * The PoolableComponentHandler to make sure components are initialized
  - * and destroyed correctly.
  + * The PoolableComponentHandler to make sure that poolable components are initialized
  + * destroyed and pooled correctly.
  + * <p>
  + * Components which implement Poolable may be configured to be pooled using the following
  + *  example configuration.  This example assumes that the user component class MyComp
  + *  implements Poolable.
  + * <p>
  + * Configuration Example:
  + * <pre>
  + *   &lt;my-comp pool-max="8" pool-max-strict="false" pool-blocking="true" pool-timeout="0"
  + *            pool-trim-interval="0"/&gt;
  + * </pre>
  + * <p>
  + * Roles Example:
  + * <pre>
  + *   &lt;role name="com.mypkg.MyComponent"
  + *         shorthand="my-comp"
  + *         default-class="com.mypkg.DefaultMyComponent"/&gt;
  + * </pre>
  + * <p>
  + * Configuration Attributes:
  + * <ul>
  + * <li>The <code>pool-max</code> attribute is used to set the maximum
number of components which
  + *  will be pooled.  See the <code>pool-max-scrict</code> and <code>pool-blocking</code>
  + *  attributes.  (Defaults to "8")</li>
  + *
  + * <li>The <code>pool-max-scrict</code> attribute is used to configure
whether the Component
  + *  Manager should allow more than <code>pool-max</code> Poolables to be looked
up at the same
  + *  time.  Setting this to true will throw an exception if the <code>pool-blocking</code>
attribute
  + *  is false.  A value of false will allow additional instances of the Component to be
created
  + *  to serve requests, but the additional instances will not be pooled.  (Defaults to "false")
  + *
  + * <li>The <code>pool-blocking</code> attributes is used to configure
whether the Component Manager
  + *  should block or throw an Exception when more than <code>pool-max</code>
Poolables are looked
  + *  up at the same time.  Setting this to true will cause requests to block until another
thread
  + *  releases a Poolable back to the Component Manager.  False will cause an exception to
be thrown.
  + *  This attribute is ignored if <code>pool-max-scrict</code> is false.  (Defaults
to "true")</li>
  + *
  + * <li>The <code>pool-timeout</code> attribute is used to specify the
maximum amount of time in
  + *  milliseconds that a lookup will block for if Poolables are unavailable.  If the timeout
expires
  + *  before another thread releases a Poolable back to the Component Managaer then an Exception
  + *  will be thrown.  A value of "0" specifies that the block will never timeout.
  + *  (Defaults to "0")</li>
  + *
  + * <li>The <code>pool-trim-interval</code> attribute is used to specify
how long idle Poolables
  + *  will be maintained in the pool before being closed.  For a complete explanation on
how this
  + *  works, see {@link org.apache.avalon.excalibur.pool.ResourceLimitingPool#trim()}
  + *  (Defaults to "0", trimming disabled)</li>
  + *
  + * <li>The <code>pool-min</code> and <code>pool-grow</code>
attributes were deprecated as the
  + *  underlying Pool ({@link org.apache.avalon.excalibur.pool.ResourceLimitingPool}) does
not make
  + *  use of them.  Configurations which still use these attributes will continue to function
  + *  however, a minimum pool size is no longer applicable.
  + *
  + * </ul>
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.7 $ $Date: 2001/12/11 09:53:27 $
  + * @author <a href="mailto:leif@silveregg.co.jp">Leif Mortenson</a>
  + * @version CVS $Revision: 1.8 $ $Date: 2002/02/18 10:14:44 $
    * @since 4.0
    */
   public class PoolableComponentHandler extends ComponentHandler {
  +    /** The default max size of the pool */
  +    public static final int DEFAULT_MAX_POOL_SIZE  = 8;
  +    
       /** The instance of the ComponentFactory that creates and disposes of the Component
*/
  -    private final DefaultComponentFactory    m_factory;
  +    private final DefaultComponentFactory m_factory;
   
       /** The pool of components for <code>Poolable</code> Components */
  -    private final DefaultComponentPool                m_pool;
  +    private final ResourceLimitingPool    m_pool;
   
       /** State management boolean stating whether the Handler is initialized or not */
  -    private boolean                    m_initialized   = false;
  +    private boolean                       m_initialized   = false;
   
       /** State management boolean stating whether the Handler is disposed or not */
  -    private boolean                    m_disposed      = false;
  +    private boolean                       m_disposed      = false;
   
       /**
        * Create a ComponentHandler that takes care of hiding the details of
  @@ -53,13 +114,14 @@
           m_factory =
               new DefaultComponentFactory( componentClass, config, manager, context, roles,
logkit );
   
  -        int min = config.getAttributeAsInteger("pool-min", DefaultComponentPool.DEFAULT_POOL_SIZE/4);
  -        int max = config.getAttributeAsInteger("pool-max", DefaultComponentPool.DEFAULT_POOL_SIZE);
  -        int grow = config.getAttributeAsInteger("pool-grow", min);
  -        DefaultComponentPoolController controller =
  -            new DefaultComponentPoolController(grow);
  -
  -        m_pool = new DefaultComponentPool( m_factory, controller, min, max );
  +        int     poolMax       = config.getAttributeAsInteger( "pool-max", DEFAULT_MAX_POOL_SIZE
);
  +        boolean poolMaxStrict = config.getAttributeAsBoolean( "pool-max-strict", false
);
  +        boolean poolBlocking  = config.getAttributeAsBoolean( "pool-blocking", true );
  +        long    poolTimeout   = config.getAttributeAsLong   ( "pool-timeout", 0 );
  +        long    poolTrimInterval = config.getAttributeAsLong( "pool-trim-interval", 0 );
  +        
  +        m_pool = new ResourceLimitingPool( m_factory, poolMax, poolMaxStrict, poolBlocking,
  +                                           poolTimeout, poolTrimInterval );
       }
   
       /**
  @@ -68,7 +130,7 @@
       public void setLogger( final Logger logger )
       {
           m_factory.setLogger( logger );
  -        m_pool.setLogger( logger );
  +        m_pool.enableLogging( new LogKitLogger( logger ) );
   
           super.setLogger( logger );
       }
  @@ -81,19 +143,6 @@
           if( m_initialized )
           {
               return;
  -        }
  -
  -        try
  -        {
  -            m_pool.initialize();
  -        }
  -        catch( Exception e )
  -        {
  -            if (getLogger().isErrorEnabled())
  -            {
  -                getLogger().error( "Cannot use component: " +
  -                                   m_factory.getCreatedClass().getName(), e );
  -            }
           }
   
           if (getLogger().isDebugEnabled())
  
  
  

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