|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.sadun.util.pool.ExtendedObjectPool
An object pool identical to ObjectPool
but which requires
the acquiring object to identify itself.
Constructor Summary | |
ExtendedObjectPool(int n,
java.lang.Class cls)
Create a pool of n object of the given class using the default constructor. |
|
ExtendedObjectPool(int n,
java.lang.Class cls,
java.lang.Object[] params)
Create a pool of n object of the given class using the given construction parameters. |
|
ExtendedObjectPool(int n,
java.lang.Class cls,
java.lang.Object[] params,
Setup ps)
Create a pool of n object of the given class using the given construction parameters. |
|
ExtendedObjectPool(int n,
ObjectPool.Factory factory)
Create a pool of n objects using the given factory |
|
ExtendedObjectPool(int n,
java.lang.String clsName)
Create a pool of n object of the given class (by name) using the default constructor. |
|
ExtendedObjectPool(int n,
java.lang.String clsName,
java.lang.Object[] params)
Create a pool of n object of the given class (by name) using the given construction parameters. |
|
ExtendedObjectPool(int n,
java.lang.String clsName,
java.lang.Object[] params,
Setup ps)
Create a pool of n object of the given class (by name) using the given construction parameters. |
Method Summary | |
java.lang.Object |
acquire(java.lang.Object requester)
Attempt to acquire an object. |
java.lang.Object |
acquire(java.lang.Object requester,
boolean waitIfUnavailable)
Attempt to acquire an object. |
java.lang.Object |
acquire(java.lang.Object requester,
int i)
Attempt to acquire the i-th object. |
int |
getFreeCount()
Return the number of available objects in the pool |
int |
getSize()
Return the size of the pool |
int |
getUsedCount()
Return the number of used objects in the pool |
static void |
main(java.lang.String[] args)
|
void |
release(java.lang.Object obj)
Release an object, notifying waiting thread (if any) that one pooled object has become available. |
void |
release(java.lang.Object obj,
boolean releaseWaitingCalls)
Release an object. |
java.lang.Object |
renew(java.lang.Object owner,
java.lang.Object obj)
Renew one object in the pool. |
java.lang.String |
toString()
Return a string description of the pool |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ExtendedObjectPool(int n, ObjectPool.Factory factory)
public ExtendedObjectPool(int n, java.lang.String clsName, java.lang.Object[] params, Setup ps) throws java.lang.ClassNotFoundException
If some post-construction setup is needed, it can be provided as an Setup object.
n
- the size of the poolclsName
- the name of the class of the objects to poolparams
- the construction parameters, or null
java.lang.ClassNotFoundException
- if the given class name cannot be resolvedpublic ExtendedObjectPool(int n, java.lang.String clsName, java.lang.Object[] params) throws java.lang.ClassNotFoundException
n
- the size of the poolclsName
- the name of the class of the objects to poolparams
- the construction parameters, or null
java.lang.ClassNotFoundException
- if the given class name cannot be resolvedpublic ExtendedObjectPool(int n, java.lang.String clsName) throws java.lang.ClassNotFoundException
n
- the size of the poolclsName
- the name of the class of the objects to pool
java.lang.ClassNotFoundException
- if the given class name cannot be resolvedpublic ExtendedObjectPool(int n, java.lang.Class cls, java.lang.Object[] params, Setup ps)
If some post-construction setup is needed, it can be provided as an Setup object.
n
- the size of the poolcls
- the class of the objects to poolparams
- the construction parameters, or nullpublic ExtendedObjectPool(int n, java.lang.Class cls, java.lang.Object[] params)
n
- the size of the poolcls
- the class of the objects to poolparams
- the construction parameters, or nullpublic ExtendedObjectPool(int n, java.lang.Class cls)
n
- the size of the poolcls
- the class of the objects to poolMethod Detail |
public int getFreeCount()
public int getUsedCount()
public int getSize()
public java.lang.Object acquire(java.lang.Object requester, boolean waitIfUnavailable)
requester
- the object performing the attemptwaitIfUnavailable
- if true, in case all the pooled objects
are used, the call will block until an object is released.
If false, in the same condition the method returns null.
public java.lang.Object acquire(java.lang.Object requester)
If there aren't any objects available, this method blocks until one becomes available.
requester
- the object performing the attempt
public java.lang.Object acquire(java.lang.Object requester, int i)
If the object is not available, this method blocks until the object becomes available.
requester
- the object performing the attempt
public void release(java.lang.Object obj, boolean releaseWaitingCalls)
releaseWaitingCalls
- if true, the method notifies waiting objects that
one pooled object has become available.public void release(java.lang.Object obj)
public java.lang.Object renew(java.lang.Object owner, java.lang.Object obj)
A new instance is created substituting the passed object in the pool, and the new instance is returned. The object is released() but any thread waiting on that object shifts waiting for another object.
public java.lang.String toString()
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |