org.apache.excalibur.mpool
Interface Pool

All Known Subinterfaces:
ManagablePool
All Known Implementing Classes:
BlockingFixedSizePool, FixedSizePool, 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.

Since:
4.1.2
Version:
CVS $Revision: 1.4 $ $Date: 2004/02/28 11:47:33 $
Author:
Avalon Development Team

Method Summary
 java.lang.Object acquire()
          Acquire an instance of the pooled object.
 java.lang.Object newInstance()
          Create a new instance of the object being pooled.
 void release(java.lang.Object pooledObject)
          Release the instance of the pooled object.
 

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.

newInstance

public java.lang.Object newInstance()
                             throws java.lang.Exception
Create a new instance of the object being pooled.

Returns:
the pooled Object instance
Throws:
java.lang.Exception - if the instance cannot be created


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.