Package com.helger.commons.pool
Interface IObjectPoolFactory<DATATYPE>
- Type Parameters:
DATATYPE- the type of results supplied by this factory
public interface IObjectPoolFactory<DATATYPE>
An extended factory for objects in the
ObjectPool.- Since:
- 11.1.0
- Author:
- Philip Helger
-
Method Summary
Modifier and TypeMethodDescriptionCalled when an existing object is borrowed from the pool.create()Create a new object for usage in the pool.voidCalled when an object is returned to the pool.static <T> IObjectPoolFactory<T> Wrapper aroundSupplierto create anIObjectPoolFactory.
-
Method Details
-
create
Create a new object for usage in the pool. This method is called if no object is in the pool, or if activation of a pooled object failed.- Returns:
- A new object of data type. Never
null.
-
activate
Called when an existing object is borrowed from the pool. If activation failed, a new object will be created.- Parameters:
aItem- The item to be borrowed. Nevernull.- Returns:
ESuccess.SUCCESSif the object can be reused,ESuccess.FAILUREif not.
-
passivate
Called when an object is returned to the pool. This method has no return value - onlyactivate(Object)can change the path.- Parameters:
aItem- The item to be returned. Nevernull.
-
wrap
Wrapper aroundSupplierto create anIObjectPoolFactory.- Type Parameters:
T- Type the object pool is supplying.- Parameters:
aSupplier- The supplier to wrap. May not benull.- Returns:
- A new instance of
IObjectPoolFactory.
-