|
Carrot2 v3.6.0-SNAPSHOT
API Documentation |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.carrot2.util.pool.SoftUnboundedPool<T,P>
public final class SoftUnboundedPool<T,P>
An extremely simple, unbounded object pool. The pool can provide objects of may types,
objects get created using parameterless constructors. The pool holds objects using
SoftReferences, so they can be garbage collected when memory is needed.
| Constructor Summary | |
|---|---|
SoftUnboundedPool()
|
|
| Method Summary | ||
|---|---|---|
|
borrowObject(Class<I> clazz,
P parameter)
Borrows an object from the pool. |
|
void |
dispose()
Disposes of the pool. |
|
void |
init(IInstantiationListener<T,P> objectInstantiationListener,
IActivationListener<T,P> objectActivationListener,
IPassivationListener<T,P> objectPassivationListener,
IDisposalListener<T,P> objectDisposalListener)
Initializes the pool with a number of listeners. |
|
void |
returnObject(T object,
P parameter)
Returns an 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 SoftUnboundedPool()
| Method Detail |
|---|
public void init(IInstantiationListener<T,P> objectInstantiationListener,
IActivationListener<T,P> objectActivationListener,
IPassivationListener<T,P> objectPassivationListener,
IDisposalListener<T,P> objectDisposalListener)
IParameterizedPool
init in interface IParameterizedPool<T,P>
public <I extends T> I borrowObject(Class<I> clazz,
P parameter)
throws InstantiationException,
IllegalAccessException
IParameterizedPool
borrowObject in interface IParameterizedPool<T,P>clazz - class of object to be borrowedparameter - additional parameter determining a possible sub type within the
same class of objects being borrowed. A combination of class and
parameter uniquely identifies a "class" (equivalence class) of pooled
objects. The parameter is assumed to correctly implement the
Object.equals(Object) and Object.hashCode() methods. The
parameter can be null. The implementation must pass the
parameter to all listeners when managing the life cycle of the pooled
object. It is the callers responsibility to ensure that exactly the same
value of the parameter is passed to the corresponding
IParameterizedPool.borrowObject(Class, Object) and
IParameterizedPool.returnObject(Object, Object) methods.
InstantiationException
IllegalAccessException
public void returnObject(T object,
P parameter)
IParameterizedPool
returnObject in interface IParameterizedPool<T,P>object - object to returnparameter - parameter provided when borrowing the object. If the parameter was
not null when borrowing the object, the same value will be
passed here.public void dispose()
IParameterizedPool
dispose in interface IParameterizedPool<T,P>
|
Please refer to project documentation at
http://project.carrot2.org |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||