|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectnet.jackofalltrades.util.PoolHouse
Provides a means maintaining ObjectPool instances in memory
for use by components in a non-web environment. The method provides
a means to allow multiple components access to the same
ObjectPool without keeping a separate pool, or passing it
like a ball.
// determine if an ObjectPool for java.lang.Integer can be used.
// if not, then create one and add it to the PoolHouse.
if (PoolHouse.getObjectPool(Integer.class) == null) {
PoolHouse.setObjectPool(Integer.class,
new IntegerPool(new PoolableIntegerFactory()));
}
// grab the ObjectPool and borrow and object from it.
if (PoolHouse.getObjectPool(Integer.class) != null) {
Integer pooledInteger
= PoolHouse.getObjectPool(Integer.class).borrowObject();
} else {
throw new IllegalStateException("IntegerPool is not initialized.");
}
NOTE: All operations against the ObjectPool store
are synchronzied.
| Method Summary | |
static void |
addObjectPool(java.lang.Class clazz,
org.apache.commons.pool.ObjectPool objectPool)
Adds a new ObjectPool to the current Map. |
static org.apache.commons.pool.ObjectPool |
getObjectPool(java.lang.Class clazz)
Returns the ObjectPool instance associated with the
clazz key. |
static void |
removeObjectPool(java.lang.Class clazz)
Removes an ObjectPool from the Map. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static void addObjectPool(java.lang.Class clazz,
org.apache.commons.pool.ObjectPool objectPool)
ObjectPool to the current Map. If
an entry for a Class->ObjectPool relationship
exists, then the new ObjectPool overrides the old.
clazz - the Class object representing the type of
objects stored in the ObjectPool.objectPool - an instance of a class implementing the
org.apache.commons.pool.ObjectPool interface, which
produces instances of the type represented by clazz.public static void removeObjectPool(java.lang.Class clazz)
ObjectPool from the Map.
clazz - a Class object representing the type of
objects stored in the ObjectPool to be removed.public static org.apache.commons.pool.ObjectPool getObjectPool(java.lang.Class clazz)
ObjectPool instance associated with the
clazz key.
clazz - the Class object key used to map the
ObjectPool returned.
ObjectPool instance mapped to
clazz, or null if not such pool is
exists.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||