org.objectweb.perseus.pool.lib

Class ArrayListPool

Implemented Interfaces:
AttributeController, BindingController, Pool, PoolAttributes

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

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 a TTL for the free pooled resources, but by default the resource has not a TTL (0 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 String
DEPENDENCY_GRAPH_BINDING
static String
POOL_MATCH_FACTORY_BINDING
static int
UNLIMITED
The int value used for the timeout or the max size

Method Summary

void
bindFc(String clientItfName, Object serverItf)
int
getMaxSize()
getMaxSize retrieves the maximum size assigned to this Pool.
int
getMinSize()
getMinSize retrieves the minimum size assigned to this Pool.
Object
getResource(Object hints)
getResource is used to allocate a PoolResource from the Pool.
Object
getResource(Object hints, Object user)
getResource is used to allocate a PoolResource from the Pool.
int
getSize()
long
getTTL()
getTTL retrieves the time to live of pool resources (in milisecond).
long
getTimeout()
getTimeout retrieves the timeout assigned to this Pool.
String[]
listFc()
Object
lookupFc(String clientItfName)
void
releaseResource(Object resource)
releaseResource releases a PoolResource in order to allow the Pool to recycle this PoolResource.
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
setTTL(long ttl)
setTTL assignes the time (in milisecond) to live of pool resources.
void
setTimeout(long crto)
setTimeout assigns a timeout to this Pool.
void
unbindFc(String clientItfName)

Field Details

DEFAULT_MAX_SIZE

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

Field Value:
-1


DEFAULT_MIN_SIZE

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

Field Value:
0


DEFAULT_TIME_OUT

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

Field Value:
300


DEPENDENCY_GRAPH_BINDING

public static final String DEPENDENCY_GRAPH_BINDING


POOL_MATCH_FACTORY_BINDING

public static final String POOL_MATCH_FACTORY_BINDING


UNLIMITED

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

Field Value:
-1

Method Details

bindFc

public void bindFc(String clientItfName,
                   Object serverItf)


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.


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.


getResource

public Object getResource(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.


getResource

public Object getResource(Object hints,
                          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.
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.


getSize

public int getSize()
Specified by:
getSize in interface Pool

Returns:
the number resource used and free


getTTL

public long getTTL()
getTTL retrieves the time to live of pool resources (in milisecond).
Specified by:
getTTL in interface PoolAttributes


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.


listFc

public String[] listFc()


lookupFc

public Object lookupFc(String clientItfName)


releaseResource

public void releaseResource(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.


setMaxSize

public void setMaxSize(int maxsize)
            throws Exception
setMaxSize assigns a maximum size to this Pool.
Specified by:
setMaxSize in interface PoolAttributes

Parameters:
maxsize - The maximum size to be assigned.


setMinSize

public void setMinSize(int minsize)
            throws Exception
setMinSize assigns a minimum size to this Pool.
Specified by:
setMinSize in interface PoolAttributes

Parameters:
minsize - The minimum size to be assigned.


setTTL

public void setTTL(long ttl)
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


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.


unbindFc

public void unbindFc(String clientItfName)


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