|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.spy.SpyObject
net.spy.pool.ObjectPool
public class ObjectPool
ObjectPool is the entry point for all object pooling facilities in net.spy.pool.*. ObjectPools have a shared reference to a pool, so there is exactly one set of pools per ClassLoader. This can be very useful in consolidating applications' pools into one.
Pools are referenced by name, so as long as two pools have two different names, they will be used independently.
When creating a pool, you must have a PoolFiller that will populate the pool with objects when it needs them.
The following is an example demonstrating how to instantiate a JDBC pool using JDBCPoolFiller:
SpyConfig conf=new SpyConfig("pool.conf");
ObjectPool op=new ObjectPool(conf);
JDBCPoolFiller pf=new JDBCPoolFiller("db", conf);
op.createPool("db", pf);
| Constructor Summary | |
|---|---|
ObjectPool(SpyConfig conf)
|
|
| Method Summary | |
|---|---|
void |
createPool(java.lang.String name,
PoolFiller pf)
Create a new object pool. |
void |
destroyPool(java.lang.String name)
Destory a pool. |
PooledObject |
getObject(java.lang.String name)
Get an object from a pool. |
boolean |
hasPool(java.lang.String name)
Find out if the ObjectPool contains the named pool. |
int |
numPools()
Get a count of the number of object pools. |
void |
prune()
Prune the object pools. |
java.lang.String |
toString()
Dump out the object pools. |
| Methods inherited from class net.spy.SpyObject |
|---|
getLogger |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ObjectPool(SpyConfig conf)
| Method Detail |
|---|
public void createPool(java.lang.String name,
PoolFiller pf)
throws PoolException
name - The name of the object pool.pf - The PoolFiller object that will be used to create new
objects within the pool.
PoolException - when bad things happen
public void destroyPool(java.lang.String name)
throws PoolException
name - The pool to destroy.
PoolException - if there's a problem removing the pool
NoSuchPoolException - if the pool we want to remove doesn't
existpublic boolean hasPool(java.lang.String name)
name - the name of the pool we're looking for
public PooledObject getObject(java.lang.String name)
throws PoolException
name - The pool from which we'll get our object.
PoolException - if it can't get an object
NoSuchPoolException - if there isn't a pool by that namepublic int numPools()
public java.lang.String toString()
toString in class java.lang.Object
public void prune()
throws PoolException
PoolException - if something bad happens
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||