|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cocoon.core.container.handler.AbstractComponentHandler
org.apache.cocoon.core.container.handler.AbstractFactoryHandler
org.apache.cocoon.core.container.handler.NonThreadSafePoolableComponentHandler
The PoolableComponentHandler to make sure that poolable components are initialized destroyed and pooled correctly.
Components which implement Poolable may be configured to be pooled using the following example configuration. This example assumes that the user component class MyComp implements Poolable.
Configuration Example:
<my-comp pool-max="8"/>
Roles Example:
<role name="com.mypkg.MyComponent" shorthand="my-comp" default-class="com.mypkg.DefaultMyComponent"/>
Configuration Attributes:
pool-max
attribute is used to set the maximum number of components which
will be pooled. (Defaults to "8") If additional instances are required, they're created,
but not pooled.
Field Summary | |
static int |
DEFAULT_MAX_POOL_SIZE
The default max size of the pool |
protected Object |
semaphore
Object used to synchronize access to the get and put methods |
Fields inherited from class org.apache.cocoon.core.container.handler.AbstractFactoryHandler |
factory |
Fields inherited from class org.apache.cocoon.core.container.handler.AbstractComponentHandler |
disposed, logger |
Constructor Summary | |
NonThreadSafePoolableComponentHandler(ComponentInfo info,
Logger logger,
ComponentFactory factory,
Configuration config)
Create a PoolableComponentHandler which manages a pool of Components created by the specified factory object. |
Method Summary | |
void |
dispose()
Dispose of the ComponentHandler and any associated Pools and Factories. |
protected Object |
doGet()
Concrete implementation of getting a component. |
protected void |
doInitialize()
|
protected void |
doPut(Object component)
Concrete implementation of putting back a component. |
protected Object |
getFromPool()
Gets a Poolable from the pool. |
protected void |
permanentlyRemovePoolable(Object poolable)
Permanently removes a poolable from the pool's active list and destroys it so that it will not ever be reused. |
protected void |
putIntoPool(Object poolable)
Returns a poolable to the pool |
Methods inherited from class org.apache.cocoon.core.container.handler.AbstractFactoryHandler |
decommission |
Methods inherited from class org.apache.cocoon.core.container.handler.AbstractComponentHandler |
canBeDisposed, get, getComponentHandler, getComponentHandler, getInfo, initialize, isSingleton, put |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEFAULT_MAX_POOL_SIZE
protected final Object semaphore
Constructor Detail |
public NonThreadSafePoolableComponentHandler(ComponentInfo info, Logger logger, ComponentFactory factory, Configuration config) throws Exception
factory
- The factory object which is responsible for creating the components
managed by the ComponentHandler.config
- The configuration to use to configure the pool.Method Detail |
public void dispose()
dispose
in interface ComponentHandler
dispose
in class AbstractComponentHandler
protected void permanentlyRemovePoolable(Object poolable)
This method is only called by threads that have m_semaphore locked.
protected Object getFromPool() throws Exception
Exception
- An exception may be thrown as described above or if there is an exception
thrown by the ObjectFactory's newInstance() method.protected void putIntoPool(Object poolable)
poolable
- Poolable to return to the pool.protected void doInitialize()
doInitialize
in class AbstractComponentHandler
protected Object doGet() throws Exception
AbstractComponentHandler
doGet
in class AbstractComponentHandler
Exception
- if an error occursprotected void doPut(Object component) throws Exception
AbstractComponentHandler
doPut
in class AbstractComponentHandler
component
- a Component
value
Exception
- if an error occurs
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |