org.objectweb.jonas.resource.pool.api
Interface Pool

All Known Implementing Classes:
HArrayPool

public interface Pool

The interface Pool defines an object that pools resources of any kind. Resources must be requested (getResource) and released (releaseResource) on demand. A Pool object can be parameterized along different dimensions. All these dimensions are represented by accessor methods (getters and setters) assigned to each of them:


Method Summary
 PoolMatchFactory getMatchFactory()
          getMatchFactory retrieves the PoolMatchFactory assigned to this Pool.
 int getMaxSize()
          getMaxSize retrieves the maximum size assigned to this Pool.
 int getMinSize()
          getMinSize retrieves the minimum size assigned to this Pool.
 java.lang.Object getResource(java.lang.Object hints)
          getResource is used to allocate a Object from the Pool.
 int getSize()
          getSize retrieves the current size of this Pool.
 long getTimeout()
          getTimeout retrieves the timeout assigned to this Pool.
 void releaseResource(java.lang.Object resource, boolean destroy)
          releaseResource releases a Object in order to allow the Pool to recycle this Object.
 void setInitSize(int initsize)
          setInitSize creates initsize resoures to this Pool.
 void setMatchFactory(PoolMatchFactory pmf)
          setMatchFactory assigns a PoolMatchFactory to this Pool.
 void setMaxSize(int maxsize)
          setMaxSize assigns a maximum size to this Pool.
 void setMinSize(int minsize)
          setMinSize assigns a minimum size to this Pool.
 void setTimeout(long crto)
          setTimeout assigns a timeout to this Pool.
 

Method Detail

getMatchFactory

public PoolMatchFactory getMatchFactory()
getMatchFactory retrieves the PoolMatchFactory assigned to this Pool.
Returns:
The PoolMatchFactory currently assigned to this Pool.

getMaxSize

public int getMaxSize()
getMaxSize retrieves the maximum size assigned to this Pool.
Returns:
The maximum size currently assigned to this Pool.

getMinSize

public int getMinSize()
getMinSize retrieves the minimum size assigned to this Pool.
Returns:
The minimum size currently assigned to this Pool.

getResource

public java.lang.Object getResource(java.lang.Object hints)
                             throws java.lang.Exception
getResource is used to allocate a Object from the Pool. Some hints are passed in order to specialise the matching or creation of Object.
Parameters:
hints - Some properties to specialise the matching or the creation of Object.
Returns:
The Object allocated from the Pool.

getTimeout

public long getTimeout()
getTimeout retrieves the timeout assigned to this Pool.
Returns:
The timeout currently assigned to this Pool.

getSize

public int getSize()
getSize retrieves the current size of this Pool.
Returns:
The current size of this Pool.

releaseResource

public void releaseResource(java.lang.Object resource,
                            boolean destroy)
                     throws java.lang.Exception
releaseResource releases a Object in order to allow the Pool to recycle this Object.
Parameters:
resource - The Object to be released.
destroy - boolean to remove the object from the pool and destroy it

setInitSize

public void setInitSize(int initsize)
                 throws java.lang.Exception
setInitSize creates initsize resoures to this Pool.
Parameters:
initsize - The init size to be created.

setMatchFactory

public void setMatchFactory(PoolMatchFactory pmf)
setMatchFactory assigns a PoolMatchFactory to this Pool.
Parameters:
pmf - The PoolMatchFactory to be assigned.

setMaxSize

public void setMaxSize(int maxsize)
                throws java.lang.Exception
setMaxSize assigns a maximum size to this Pool.
Parameters:
maxsize - The maximum size to be assigned.

setMinSize

public void setMinSize(int minsize)
                throws java.lang.Exception
setMinSize assigns a minimum size to this Pool.
Parameters:
minsize - The minimum size to be assigned.

setTimeout

public void setTimeout(long crto)
setTimeout assigns a timeout to this Pool.
Parameters:
crto - The timeout to be assigned.