|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.lucene.gdata.utils.SimpleObjectPool<Type>
Type
- public class SimpleObjectPool<Type>
A Simple implementation of the Pool
interface using a Stack
as a buffer for the pooled objects.
This implementation does not provide any timeout mechanismn. Objects will
stay inside the pool until the pool is destroyed.
If any object will be released e.g. handover to the pool and the pool has already enought objects in the pool the released object will be destroyed. If the pool is empty a new Object will be created.
This implementation does not track any references to the objects aquired by any other resource. The objects must be destroyed manually if not released to the pool after aquired.
Constructor Summary | |
---|---|
SimpleObjectPool(int size,
PoolObjectFactory<Type> factory)
Constructs a new SimpleObjectPool and sets the ObjectFactory and the pool size |
|
SimpleObjectPool(PoolObjectFactory<Type> factory)
|
Method Summary | |
---|---|
Type |
aquire()
Return an object from the pool or create one if the pool is empty. |
void |
destroy()
releases all pooled objects using PoolObjectFactory.destroyInstance(Object) method. |
boolean |
expires()
|
long |
getExpireTime()
|
int |
getSize()
|
void |
release(Type type)
Adds a previously aquired object to the pool. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimpleObjectPool(int size, PoolObjectFactory<Type> factory)
SimpleObjectPool
and sets the ObjectFactory and the pool size
size
- - the maximum size of the poolfactory
- - factory to create and destroy pooled objectspublic SimpleObjectPool(PoolObjectFactory<Type> factory)
factory
- Method Detail |
---|
public Type aquire()
Pool
aquire
in interface Pool<Type>
Pool.aquire()
public void release(Type type)
Pool
PoolObjectFactory.destroyInstance(Object)
method.
release
in interface Pool<Type>
type
- - generic typePool.release(Object)
public int getSize()
getSize
in interface Pool<Type>
Pool.getSize()
public long getExpireTime()
getExpireTime
in interface Pool<Type>
Pool.getExpireTime()
public boolean expires()
expires
in interface Pool<Type>
true
if and only if the pool uses an expire
mechanismn, otherwith false
Pool.expires()
public void destroy()
Pool
PoolObjectFactory.destroyInstance(Object)
method. The pool can not
be reused after this method has been called
destroy
in interface Pool<Type>
Pool.destroy()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |