|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
jet.pool.ObjectPool
public class ObjectPool
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
private boolean |
continued
Variable that indicates to stop running |
private java.util.concurrent.locks.ReentrantLock |
lock
|
private int |
objectCount
The count - how much object should be pooled for each given Poolable object |
private java.util.HashMap<java.lang.String,java.lang.Object> |
orgs
Holds the original object from which the pooled objects were cloned |
private java.util.HashMap<java.lang.String,java.lang.Object> |
pool
Holds the pooled objects |
private java.util.concurrent.locks.ReentrantLock |
stacklock
|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
ObjectPool(int objectCount)
Creates a new instance of ObjectPool |
Method Summary | |
---|---|
void |
add(Poolable o)
This methods adds a new Poolable object |
void |
addAll(java.util.Collection c)
This method adds all Objects from the colletion |
Poolable |
getCloneFromOriginalObject(java.lang.String identifier)
Returns a clone from pooled object |
boolean |
getContinued()
Returns the flag if the ObjectPoolThread should continue running. |
Poolable |
getInstanceFor(java.lang.String identifier)
Returns a pooled object or a new one if pool empty |
int |
getObjectCount()
Returns the count how many objects should be pooled |
java.util.HashMap |
getPool()
Returns the pool |
void |
pushBack(Poolable o)
This method returns the object to the pool |
void |
run()
This method checks from time to time if there are too much objectspooled. |
void |
setContinued(boolean val)
Sets the flag if the ObjectPoolThread should continue running. |
void |
setObjectCount(int objectCount)
Sets the object count to use (TODO? |
void |
setPool(java.util.HashMap<java.lang.String,java.lang.Object> pool)
Sets the internal pool |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private boolean continued
private java.util.HashMap<java.lang.String,java.lang.Object> pool
private java.util.HashMap<java.lang.String,java.lang.Object> orgs
private java.util.concurrent.locks.ReentrantLock stacklock
private java.util.concurrent.locks.ReentrantLock lock
private int objectCount
Constructor Detail |
---|
public ObjectPool(int objectCount)
objectCount
- the count how many objects should be pooledMethod Detail |
---|
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public java.util.HashMap getPool()
public void setPool(java.util.HashMap<java.lang.String,java.lang.Object> pool)
public int getObjectCount()
public void setObjectCount(int objectCount)
objectCount
- the countpublic void add(Poolable o)
o
- the object to poolpublic void pushBack(Poolable o)
o
- object to returnpublic void addAll(java.util.Collection c) throws java.lang.CloneNotSupportedException
c
- collection to add objects from
java.lang.CloneNotSupportedException
public Poolable getInstanceFor(java.lang.String identifier)
identifier
- the identifierer
public Poolable getCloneFromOriginalObject(java.lang.String identifier)
identifier
- the identifierer
public boolean getContinued()
public void setContinued(boolean val)
val
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |