|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface PoolService
The Pool Service extends the Factory Service by adding support for pooling instantiated objects. When a new instance is requested, the service first checks its pool if one is available. If the the pool is empty, a new object will be instantiated from the specified class. If only class name is given, the request to create an instance will be forwarded to the Factory Service.
For objects implementing the Recyclable interface, a recycle method will be called, when they are taken from the pool, and a dispose method, when they are returned to the pool.
Field Summary | |
---|---|
static int |
DEFAULT_POOL_CAPACITY
The default pool capacity. |
static String |
ROLE
Avalon role - used to id the component within the manager |
Method Summary | |
---|---|
void |
clearPool()
Clears all instances from the pool. |
void |
clearPool(String className)
Clears instances of a named class from the pool. |
int |
getCapacity(String className)
Gets the capacity of the pool for a named class. |
Object |
getInstance(Class clazz)
Gets an instance of a specified class either from the pool or by instantiating from the class if the pool is empty. |
Object |
getInstance(Class clazz,
Object[] params,
String[] signature)
Gets an instance of a specified class either from the pool or by instantiating from the class if the pool is empty. |
int |
getSize(String className)
Gets the current size of the pool for a named class. |
boolean |
putInstance(Object instance)
Puts a used object back to the pool. |
void |
setCapacity(String className,
int capacity)
Sets the capacity of the pool for a named class. |
Field Detail |
---|
static final String ROLE
static final int DEFAULT_POOL_CAPACITY
Method Detail |
---|
Object getInstance(Class clazz) throws PoolException
clazz
- the class.
PoolException
- if recycling fails.Object getInstance(Class clazz, Object[] params, String[] signature) throws PoolException
clazz
- the class.params
- an array containing the parameters of the constructor.signature
- an array containing the signature of the constructor.
PoolException
- if recycling fails.boolean putInstance(Object instance)
instance
- the object instance to recycle.
int getCapacity(String className)
className
- the name of the class.void setCapacity(String className, int capacity)
className
- the name of the class.capacity
- the new capacity.int getSize(String className)
className
- the name of the class.void clearPool(String className)
className
- the name of the class.void clearPool()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |