|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.fulcrum.pool.DefaultPoolService
public class DefaultPoolService
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 instance will be requested from the FactoryService. For objects implementing the Recyclable interface, a recycle method will be called, when they taken from the pool, and a dispose method, when they are returned to the pool.
Field Summary | |
---|---|
static String |
POOL_CAPACITY
The property specifying the pool capacity. |
Fields inherited from interface org.apache.fulcrum.pool.PoolService |
---|
DEFAULT_POOL_CAPACITY, ROLE |
Constructor Summary | |
---|---|
DefaultPoolService()
|
Method Summary | |
---|---|
void |
clearPool()
Clears all instances from the pool. |
void |
clearPool(String className)
Clears instances of a named class from the pool. |
void |
configure(org.apache.avalon.framework.configuration.Configuration conf)
Avalon component lifecycle method |
void |
dispose()
Avalon component lifecycle method |
int |
getCapacity(String className)
Gets the capacity of the pool for a named class. |
protected org.apache.fulcrum.factory.FactoryService |
getFactory()
Gets the factory service. |
Object |
getInstance(Class clazz)
Gets an instance of a specified class either from the pool or by instatiating 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 instatiating from the class if the pool is empty. |
Object |
getInstance(String className)
Gets an instance of a named class either from the pool or by calling the Factory Service if the pool is empty. |
Object |
getInstance(String className,
ClassLoader loader)
Gets an instance of a named class either from the pool or by calling the Factory Service if the pool is empty. |
Object |
getInstance(String className,
ClassLoader loader,
Object[] params,
String[] signature)
Gets an instance of a named class either from the pool or by calling the Factory Service if the pool is empty. |
Object |
getInstance(String className,
Object[] params,
String[] signature)
Gets an instance of a named class either from the pool or by calling the Factory Service if the pool is empty. |
int |
getSize(String className)
Gets the current size of the pool for a named class. |
void |
initialize()
Avalon component lifecycle method Initializes the service by loading default class loaders and customized object factories. |
boolean |
isLoaderSupported(String className)
Tests if specified class loaders are supported for a named class. |
boolean |
putInstance(Object instance)
Puts a used object back to the pool. |
void |
service(org.apache.avalon.framework.service.ServiceManager manager)
Avalon component lifecycle method |
void |
setCapacity(String className,
int capacity)
Sets the capacity of the pool for a named class. |
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
---|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String POOL_CAPACITY
Constructor Detail |
---|
public DefaultPoolService()
Method Detail |
---|
public Object getInstance(String className) throws PoolException
className
- the name of the class.
PoolException
- if recycling fails.public Object getInstance(String className, ClassLoader loader) throws PoolException
className
- the name of the class.loader
- the class loader.
PoolException
- if recycling fails.public Object getInstance(String className, Object[] params, String[] signature) throws PoolException
className
- the name of the class.loader
- the class loader.params
- an array containing the parameters of the constructor.signature
- an array containing the signature of the constructor.
PoolException
- if recycling fails.public Object getInstance(String className, ClassLoader loader, Object[] params, String[] signature) throws PoolException
className
- the name of the class.loader
- the class loader.params
- an array containing the parameters of the constructor.signature
- an array containing the signature of the constructor.
PoolException
- if recycling fails.public boolean isLoaderSupported(String className) throws org.apache.fulcrum.factory.FactoryException
className
- the name of the class.
PoolException
- if test fails.
org.apache.fulcrum.factory.FactoryException
public Object getInstance(Class clazz) throws PoolException
getInstance
in interface PoolService
clazz
- the class.
PoolException
- if recycling fails.public Object getInstance(Class clazz, Object[] params, String[] signature) throws PoolException
getInstance
in interface PoolService
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.public boolean putInstance(Object instance)
putInstance
in interface PoolService
instance
- the object instance to recycle.
public int getCapacity(String className)
getCapacity
in interface PoolService
className
- the name of the class.public void setCapacity(String className, int capacity)
setCapacity
in interface PoolService
className
- the name of the class.capacity
- the new capacity.public int getSize(String className)
getSize
in interface PoolService
className
- the name of the class.public void clearPool(String className)
clearPool
in interface PoolService
className
- the name of the class.public void clearPool()
clearPool
in interface PoolService
protected org.apache.fulcrum.factory.FactoryService getFactory()
public void configure(org.apache.avalon.framework.configuration.Configuration conf)
configure
in interface org.apache.avalon.framework.configuration.Configurable
public void service(org.apache.avalon.framework.service.ServiceManager manager)
service
in interface org.apache.avalon.framework.service.Serviceable
public void initialize() throws Exception
initialize
in interface org.apache.avalon.framework.activity.Initializable
InitializationException
- if initialization fails.
Exception
public void dispose()
dispose
in interface org.apache.avalon.framework.activity.Disposable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |