|
Oracle | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.compoze.util.ObjectFactoryPool
public class ObjectFactoryPool
This class keeps a pool of objects that may be obtained in a thread-safe fashion. When it becomes empty it is filled when new objects instantiated by an implementation of IObjectFactory. Client code should do something like the following to use this class to insure that instances are properly returned to the pool:
Object obj = null; try { Object obj = pool.get (); // ... do something with obj } finally { if (null != obj) pool.put (obj); }This pool is particularly useful for large objects that take a long time to instantiate and are not thread-safe (for example, XML parser factories), and when clients spend a long time using them such that synchronization around one object would bottleneck performance.
Nested Class Summary | |
---|---|
static class |
ObjectFactoryPool.ThreadUnsafeObject
This class is a test class that is not thread-safe. |
Constructor Summary | |
---|---|
ObjectFactoryPool(IObjectFactory factory)
Constructor. |
|
ObjectFactoryPool(IObjectFactory factory,
int iInitialSize,
int iMinimumAvailableSize,
int iIncrement)
Constructor. |
Method Summary | |
---|---|
java.lang.Object |
get()
Gets an object from the pool, waiting until one is available. |
static void |
main(java.lang.String[] args)
Main. |
void |
put(java.lang.Object obj)
Puts an object back into the pool. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ObjectFactoryPool(IObjectFactory factory)
public ObjectFactoryPool(IObjectFactory factory, int iInitialSize, int iMinimumAvailableSize, int iIncrement)
Method Detail |
---|
public java.lang.Object get()
public void put(java.lang.Object obj)
public static void main(java.lang.String[] args)
|
Oracle | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |