org.apache.avalon.excalibur.pool
Class ValidatedResourceLimitingPool

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLogEnabled
        |
        +--org.apache.avalon.excalibur.pool.ResourceLimitingPool
              |
              +--org.apache.avalon.excalibur.pool.ValidatedResourceLimitingPool
All Implemented Interfaces:
org.apache.avalon.framework.component.Component, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.logger.LogEnabled, Pool, org.apache.avalon.framework.thread.ThreadSafe
Direct Known Subclasses:
ResourceLimitingJdbcConnectionPool

public class ValidatedResourceLimitingPool
extends ResourceLimitingPool

A ResourceLimitingPool which validates reused poolables before they are returned with a call get().

Since:
4.1
Version:
CVS $Revision: 1.2 $ $Date: 2002/01/25 01:24:27 $
Author:
Leif Mortenson

Fields inherited from class org.apache.avalon.excalibur.pool.ResourceLimitingPool
m_semaphore
 
Constructor Summary
ValidatedResourceLimitingPool(ObjectFactory factory, int max, boolean maxStrict, boolean blocking, long blockTimeout, long trimInterval)
          Creates a new ValidatedResourceLimitingPool
 
Method Summary
 Poolable get()
          Gets a Poolable from the pool.
protected  Poolable newPoolable()
          Create a new poolable instance by by calling the newInstance method on the pool's ObjectFactory.
protected  boolean validatePoolable(Poolable poolable)
          If the poolable implements Validatable, then its validate() method will be called to give the poolable a chance to validate itself.
 
Methods inherited from class org.apache.avalon.excalibur.pool.ResourceLimitingPool
dispose, getReadySize, getSize, permanentlyRemovePoolable, put, removePoolable, trim
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.avalon.framework.logger.LogEnabled
enableLogging
 

Constructor Detail

ValidatedResourceLimitingPool

public ValidatedResourceLimitingPool(ObjectFactory factory,
                                     int max,
                                     boolean maxStrict,
                                     boolean blocking,
                                     long blockTimeout,
                                     long trimInterval)
Creates a new ValidatedResourceLimitingPool
Parameters:
factory - The ObjectFactory which will be used to create new Poolables as needed by the pool.
max - Maximum number of Poolables which can be stored in the pool, 0 implies no limit.
maxStrict - true if the pool should never allow more than max Poolable to be created. Will cause an exception to be thrown if more than max Poolables are requested and blocking is false.
blocking - true if the pool should cause a thread calling get() to block when Poolables are not currently available on the pool.
blockTimeout - The maximum amount of time, in milliseconds, that a call to get() will block before an exception is thrown. A value of 0 implies an indefinate wait.
trimInterval - The minimum interval with which old unused poolables will be removed from the pool. A value of 0 will cause the pool to never trim poolables.
Method Detail

get

public Poolable get()
             throws java.lang.Exception
Gets a Poolable from the pool. If there is room in the pool, a new Poolable will be created. Depending on the parameters to the constructor, the method may block or throw an exception if a Poolable is not available on the pool.
Overrides:
get in class ResourceLimitingPool
Throws:
java.lang.Exception - An exception may be thrown as described above or if there is an exception thrown by the ObjectFactory's newInstance() method.

newPoolable

protected Poolable newPoolable()
                        throws java.lang.Exception
Create a new poolable instance by by calling the newInstance method on the pool's ObjectFactory. This is the method to override when you need to enforce creational policies. This method is only called by threads that have m_semaphore locked.
Overrides:
newPoolable in class ResourceLimitingPool

validatePoolable

protected boolean validatePoolable(Poolable poolable)
                            throws java.lang.Exception
If the poolable implements Validatable, then its validate() method will be called to give the poolable a chance to validate itself. Different functionality can be achieved by overriding this method. This method is only called by threads that have m_semaphore locked.
Parameters:
poolable - The Poolable to be validated


Copyright 2001 Apache Jakarta Project. All Rights Reserved.