Package org.apache.xml.security.utils
Class WeakObjectPool<T,E extends java.lang.Throwable>
- java.lang.Object
-
- org.apache.xml.security.utils.WeakObjectPool<T,E>
-
public abstract class WeakObjectPool<T,E extends java.lang.Throwable> extends java.lang.ObjectAbstract base class for pooling objects. The two public methods aregetObject()and (repool(Object). Objects are held through weak references so even objects that are not repooled are subject to garbage collection. Subclasses must implement the abstractcreateObject().Internally, the pool is stored in a java.util.concurrent.LinkedBlockingDeque instance.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedWeakObjectPool()The lone constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract TcreateObject()Called whenever a new pool object is desired; subclasses must implement.TgetObject()Subclasses can subclass to return a more specific type.booleanrepool(T obj)Adds the given object to the pool, provided that the object was created by this pool.
-
-
-
Method Detail
-
createObject
protected abstract T createObject() throws E extends java.lang.Throwable
Called whenever a new pool object is desired; subclasses must implement.- Returns:
- object of the type desired by the subclass
- Throws:
parameterizable- Throwable's subclassE extends java.lang.Throwable
-
getObject
public T getObject() throws E extends java.lang.Throwable
Subclasses can subclass to return a more specific type.
-
repool
public boolean repool(T obj)
Adds the given object to the pool, provided that the object was created by this pool.- Parameters:
obj- the object to return to the pool- Returns:
- whether the object was successfully added as available
-
-