org.objectweb.perseus.pool.lib
Class ArrayListPool

java.lang.Object
  extended byorg.objectweb.perseus.pool.lib.ArrayListPool
All Implemented Interfaces:
Pool, PoolAttributes

public class ArrayListPool
extends java.lang.Object
implements Pool, PoolAttributes

The class LArrayPool implements a Pool as an array of PoolResource, managing free/active resources through two ArrayList objects. An unlimited size and a timeout features are supported. This implementation is thread safe. This implementation is able to manage an InactiveTTL for the free pooled resources, but by default the resource has not a TTL (negative value). This implementation is able to manage a TTL for each pooled resources, but by default the resource has not a TTL (negative value).

Author:
S.Chassande-Barrioz

Field Summary
static int DEFAULT_MAX_SIZE
          The default maximum size of the pool: UNLIMITED
static int DEFAULT_MIN_SIZE
          The default minimum size of the pool: 0
static int DEFAULT_TIME_OUT
          The default time out for a request: 100ms
static java.lang.String DEPENDENCY_GRAPH_BINDING
           
static java.lang.String POOL_MATCH_FACTORY_BINDING
           
static int UNLIMITED
          The int value used for the timeout or the max size
 
Constructor Summary
ArrayListPool()
           
 
Method Summary
 void bindFc(java.lang.String clientItfName, java.lang.Object serverItf)
           
 int getFreeResourceNumber()
           
 long getInactiveTTL()
          getTTL retrieves the time to live of pool resources when they are unused (in milisecond).
 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 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()
           
 long getTimeout()
          getTimeout retrieves the timeout assigned to this Pool.
 long getTTL()
          getTTL retrieves the time to live of pool resources (in milisecond).
 int getUsedResourceNumber()
           
 java.util.Collection getUsers()
           
 java.lang.String[] listFc()
           
 java.lang.Object lookupFc(java.lang.String clientItfName)
           
 void releaseResource(java.lang.Object resource)
          releaseResource releases a PoolResource in order to allow the Pool to recycle this PoolResource.
 void setInactiveTTL(long fttl)
          setTTL assignes the time (in milisecond) to live of pool resources when they are unused.
 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 setTTL(long ttl)
          setTTL assignes the time (in milisecond) to live of pool resources.
 void unbindFc(java.lang.String clientItfName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POOL_MATCH_FACTORY_BINDING

public static final java.lang.String POOL_MATCH_FACTORY_BINDING
See Also:
Constant Field Values

DEPENDENCY_GRAPH_BINDING

public static final java.lang.String DEPENDENCY_GRAPH_BINDING
See Also:
Constant Field Values

UNLIMITED

public static final int UNLIMITED
The int value used for the timeout or the max size

See Also:
Constant Field Values

DEFAULT_MIN_SIZE

public static final int DEFAULT_MIN_SIZE
The default minimum size of the pool: 0

See Also:
Constant Field Values

DEFAULT_MAX_SIZE

public static final int DEFAULT_MAX_SIZE
The default maximum size of the pool: UNLIMITED

See Also:
Constant Field Values

DEFAULT_TIME_OUT

public static final int DEFAULT_TIME_OUT
The default time out for a request: 100ms

See Also:
Constant Field Values
Constructor Detail

ArrayListPool

public ArrayListPool()
Method Detail

listFc

public java.lang.String[] listFc()

lookupFc

public java.lang.Object lookupFc(java.lang.String clientItfName)

bindFc

public void bindFc(java.lang.String clientItfName,
                   java.lang.Object serverItf)

unbindFc

public void unbindFc(java.lang.String clientItfName)

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.

Specified by:
getResource in interface Pool
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
Description copied from interface: Pool
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.

Specified by:
getResource in interface Pool
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

getSize

public int getSize()
Specified by:
getSize in interface Pool
Returns:
the number resource used and free

getFreeResourceNumber

public int getFreeResourceNumber()
Specified by:
getFreeResourceNumber in interface Pool
Returns:
the number of unsused resource

getUsedResourceNumber

public int getUsedResourceNumber()
Specified by:
getUsedResourceNumber in interface Pool
Returns:
the number of used resource

getUsers

public java.util.Collection getUsers()
Specified by:
getUsers in interface Pool
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.

releaseResource

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

Specified by:
releaseResource in interface Pool
Parameters:
resource - The PoolResource to be released.
Throws:
PoolException

getTimeout

public long getTimeout()
getTimeout retrieves the timeout assigned to this Pool.

Specified by:
getTimeout in interface PoolAttributes
Returns:
The timeout currently assigned to this Pool.

getMinSize

public int getMinSize()
getMinSize retrieves the minimum size assigned to this Pool.

Specified by:
getMinSize in interface PoolAttributes
Returns:
The minimum size currently assigned to this Pool.

getMaxSize

public int getMaxSize()
getMaxSize retrieves the maximum size assigned to this Pool.

Specified by:
getMaxSize in interface PoolAttributes
Returns:
The maximum size currently assigned to this Pool.

setTimeout

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

Specified by:
setTimeout in interface PoolAttributes
Parameters:
crto - The timeout to be assigned.

setMinSize

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

Specified by:
setMinSize in interface PoolAttributes
Parameters:
minsize - The minimum size to be assigned.
Throws:
java.lang.Exception

setMaxSize

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

Specified by:
setMaxSize in interface PoolAttributes
Parameters:
maxsize - The maximum size to be assigned.
Throws:
java.lang.Exception

getTTL

public long getTTL()
Description copied from interface: PoolAttributes
getTTL retrieves the time to live of pool resources (in milisecond).

Specified by:
getTTL in interface PoolAttributes

setTTL

public void setTTL(long ttl)
Description copied from interface: PoolAttributes
setTTL assignes the time (in milisecond) to live of pool resources. If the value is lesser or equal to 0 then pool resources do not have a TTL.

Specified by:
setTTL in interface PoolAttributes

getInactiveTTL

public long getInactiveTTL()
Description copied from interface: PoolAttributes
getTTL retrieves the time to live of pool resources when they are unused (in milisecond).

Specified by:
getInactiveTTL in interface PoolAttributes

setInactiveTTL

public void setInactiveTTL(long fttl)
Description copied from interface: PoolAttributes
setTTL assignes the time (in milisecond) to live of pool resources when they are unused. If the value is lesser or equal to 0 then pool resources do not have a TTL.

Specified by:
setInactiveTTL in interface PoolAttributes


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