de.intarsys.tools.pool
Class GenericPool

java.lang.Object
  extended by de.intarsys.tools.pool.GenericPool
All Implemented Interfaces:
IPool

public class GenericPool
extends java.lang.Object
implements IPool

A very simple implementation of a generic IPool.


Constructor Summary
GenericPool(IPoolObjectFactory objectFactory)
           
 
Method Summary
protected  void activateObject(java.lang.Object object)
           
protected  void assertOpen()
           
 void checkin(java.lang.Object object)
          Add an object to the pool.
 java.lang.Object checkout(long timeout)
          Get an object from the pool.
 void close()
          Close the pool.
protected  java.lang.Object createObject()
           
protected  void deactivateObject(java.lang.Object object)
           
 void destroy(java.lang.Object object)
          Destroy an object previously allocated from the pool.
protected  void destroyObject(java.lang.Object object)
           
protected  boolean isClosed()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericPool

public GenericPool(IPoolObjectFactory objectFactory)
Method Detail

checkin

public void checkin(java.lang.Object object)
             throws java.lang.Exception
Description copied from interface: IPool
Add an object to the pool.

Specified by:
checkin in interface IPool
Parameters:
object - The object to be added to the pool.
Throws:
java.lang.Exception

deactivateObject

protected void deactivateObject(java.lang.Object object)
                         throws java.lang.Exception
Throws:
java.lang.Exception

destroyObject

protected void destroyObject(java.lang.Object object)
                      throws java.lang.Exception
Throws:
java.lang.Exception

isClosed

protected boolean isClosed()

assertOpen

protected void assertOpen()

checkout

public java.lang.Object checkout(long timeout)
                          throws java.lang.Exception
Description copied from interface: IPool
Get an object from the pool.

This may be a reused object or a new one, up to the pool strategy and size.

Specified by:
checkout in interface IPool
Parameters:
timeout - The maximum time to wait for an instance to be available in milliseconds. -1 will wait indefinitely, 0 will not wait.
Returns:
A new object from the pool.
Throws:
java.lang.Exception

activateObject

protected void activateObject(java.lang.Object object)
                       throws java.lang.Exception
Throws:
java.lang.Exception

createObject

protected java.lang.Object createObject()
                                 throws java.lang.Exception
Throws:
java.lang.Exception

close

public void close()
           throws java.lang.Exception
Description copied from interface: IPool
Close the pool.

Specified by:
close in interface IPool
Throws:
java.lang.Exception

destroy

public void destroy(java.lang.Object object)
             throws java.lang.Exception
Description copied from interface: IPool
Destroy an object previously allocated from the pool.

Specified by:
destroy in interface IPool
Parameters:
object - The object to be destroyed.
Throws:
java.lang.Exception