org.d_haven.mpool
Interface Pool

All Known Subinterfaces:
ManagablePool
All Known Implementing Classes:
AbstractPool, VariableSizePool

public interface Pool

This interface is to define how a Pool is used. We have determined by using the previous Pool implementations that the Pool marker interface is considered harmful. When generics are introduced in JDK 1.5, this interface will be a prime candidate for those improvements.

It is important to realize that some objects are cheaper to simply allow the garbage collector to take care of them. Therefore, only pool objects that are computationally expensive to create. Prime candidates would be Components, JDBC Connection objects, Socket connections, etc.

The interface is inspired by both the Mutex acquire/release and the structure of the ThreadLocal object. In fact, it would be trivial to implement a "ThreadLocal" pool.

Version:
CVS $Revision: 1.4 $ $Date: 2004/06/21 17:03:46 $
Author:
Berin Loritsch

Method Summary
 java.lang.Object acquire()
          Acquire an instance of the pooled object.
 void addPoolListener(PoolListener listener)
          Add a pool listener to the pool.
 void release(java.lang.Object pooledObject)
          Release the instance of the pooled object.
 void removePoolListener(PoolListener listener)
          Remove a pool listener from the pool.
 

Method Detail

acquire

public java.lang.Object acquire()
                         throws java.lang.Exception
Acquire an instance of the pooled object.

Returns:
the pooled Object instance
Throws:
java.lang.Exception - if the Pool is not able to return an object.

release

public void release(java.lang.Object pooledObject)
Release the instance of the pooled object.

Parameters:
pooledObject - The pooled object to release to the pool.

addPoolListener

public void addPoolListener(PoolListener listener)
Add a pool listener to the pool. If you add a listener twice it will be notified twice and you will have to remove it twice.

Parameters:
listener - the listener to add.

removePoolListener

public void removePoolListener(PoolListener listener)
Remove a pool listener from the pool. If you add a listener twice it will be notified twice and you will have to remove it twice.

Parameters:
listener - the listener to remove


Copyright © 2004-2007 D-Haven.org. All Rights Reserved.