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 theObjectPool.- Since:
- 11.1.0
- Author:
- Philip Helger
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description ESuccessactivate(DATATYPE aItem)Called when an existing object is borrowed from the pool.DATATYPEcreate()Create a new object for usage in the pool.voidpassivate(DATATYPE aItem)Called when an object is returned to the pool.static <T> IObjectPoolFactory<T>wrap(Supplier<? extends T> aSupplier)Wrapper aroundSupplierto create anIObjectPoolFactory.
-
-
-
Method Detail
-
create
@Nonnull DATATYPE 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
@Nonnull ESuccess activate(@Nonnull DATATYPE aItem)
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
void passivate(@Nonnull DATATYPE aItem)
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
@Nonnull static <T> IObjectPoolFactory<T> wrap(@Nonnull Supplier<? extends T> aSupplier)
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.
-
-