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
 void adjust()
          adjust checks the age of the entries and removes them if they are too old
 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, boolean adjustment)
          releaseResource releases a Object in order to allow the Pool to recycle this Object.
 void sampling()
          sampling updates the interval pool information
 void setInitSize(int initsize)
          setInitSize creates initsize resoures to this Pool.
 void setMatchFactory(PoolMatchFactory pmf)
          setMatchFactory assigns a PoolMatchFactory to this Pool.
 void setMaxAge(long maxAge)
          setMaxAge sets the max age for a pool entry
 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.
 void validateMCs()
          validateMCs validates ManagedConnections in Pool every 10 minutes
 

Method Detail

adjust

public void adjust()
            throws java.lang.Exception
adjust checks the age of the entries and removes them if they are too old

Throws:
java.lang.Exception - if an error occurs

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.
Throws:
java.lang.Exception - if an error occurs

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,
                            boolean adjustment)
                     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
adjustment - boolean to determine if a pool adjustment should be done
Throws:
java.lang.Exception - if an error occurs

sampling

public void sampling()
              throws java.lang.Exception
sampling updates the interval pool information

Throws:
java.lang.Exception - if an error occurs

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.
Throws:
java.lang.Exception - if an error occurs

setMatchFactory

public void setMatchFactory(PoolMatchFactory pmf)
setMatchFactory assigns a PoolMatchFactory to this Pool.

Parameters:
pmf - The PoolMatchFactory to be assigned.

setMaxAge

public void setMaxAge(long maxAge)
setMaxAge sets the max age for a pool entry

Parameters:
maxAge - long max number of milliseconds to keep a connection in the pool.

setMaxSize

public void setMaxSize(int maxsize)
                throws java.lang.Exception
setMaxSize assigns a maximum size to this Pool.

Parameters:
maxsize - int maximum size to be assigned.
Throws:
java.lang.Exception - if an error occurs

setMinSize

public void setMinSize(int minsize)
                throws java.lang.Exception
setMinSize assigns a minimum size to this Pool.

Parameters:
minsize - int minimum size to be assigned.
Throws:
java.lang.Exception - if an error occurs

setTimeout

public void setTimeout(long crto)
setTimeout assigns a timeout to this Pool.

Parameters:
crto - long timeout to be assigned.

validateMCs

public void validateMCs()
                 throws java.lang.Exception
validateMCs validates ManagedConnections in Pool every 10 minutes

Throws:
java.lang.Exception - if an error occurs