org.objectweb.perseus.pool.api
Interface Pool

All Known Implementing Classes:
ArrayListPool, LArrayPool

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 PoolAttributes interface.


Method Summary
 int getFreeResourceNumber()
           
 java.lang.Object getResource(java.lang.Object hints)
          getResource is used to allocate a PoolResource from the Pool.
 java.lang.Object getResource(java.lang.Object hints, java.lang.Object user)
          getResource is used to allocate a PoolResource from the Pool.
 int getSize()
           
 int getUsedResourceNumber()
           
 java.util.Collection getUsers()
           
 void releaseResource(java.lang.Object resource)
          releaseResource releases a PoolResource in order to allow the Pool to recycle this PoolResource.
 

Method Detail

getResource

public java.lang.Object getResource(java.lang.Object hints)
                             throws PoolException
getResource is used to allocate a PoolResource from the Pool. Some hints are passed in order to specialise the matching or creation of PoolResource.

Parameters:
hints - Some properties to specialise the matching or the creation of PoolResource.
Returns:
The PoolResource allocated from the Pool.
Throws:
PoolException

getResource

public java.lang.Object getResource(java.lang.Object hints,
                                    java.lang.Object user)
                             throws PoolException,
                                    DeadLockException
getResource is used to allocate a PoolResource from the Pool. Some hints are passed in order to specialise the matching or creation of PoolResource. The user parameter avoids dead lock by the use of a dependency graph.

Parameters:
hints - Some properties to specialise the matching or the creation of PoolResource.
user - is an identifier of the context wanting a resource in the pool.
Returns:
The PoolResource allocated from the Pool.
Throws:
PoolException
DeadLockException

releaseResource

public void releaseResource(java.lang.Object resource)
                     throws PoolException
releaseResource releases a PoolResource in order to allow the Pool to recycle this PoolResource.

Parameters:
resource - The PoolResource to be released.
Throws:
PoolException

getSize

public int getSize()
Returns:
the number resource used and free

getFreeResourceNumber

public int getFreeResourceNumber()
Returns:
the number of unsused resource

getUsedResourceNumber

public int getUsedResourceNumber()
Returns:
the number of used resource

getUsers

public java.util.Collection getUsers()
Returns:
collection of user. The collection can be empty even if resource are used, in case of the user did not specify any reference on getResource.


Copyright © 2000-2002 France Telecom S.A., INRIA, IMAG-LSR All Rights Reserved.