Package com.pnfsoftware.jeb.util.base
Class ReusableObjectFactory<T>
java.lang.Object
com.pnfsoftware.jeb.util.base.ReusableObjectFactory<T>
Unbounded, concurrency-friendly object factory for objects that can be used, released, and
re-used.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionget()
Retrieve or create an object.int
Get the number of times the supplier created a new object.list()
Get a copy of the list of all objects (in-use and available) created by this factory.void
Release an object provided by ths factory, making it usable by other callers.
-
Constructor Details
-
ReusableObjectFactory
Create a factory.- Parameters:
supplier
- object creator, must support concurrency (the supplier may be requested to create object by multiple threads at the same time)
-
-
Method Details
-
getSuppliedCount
public int getSuppliedCount()Get the number of times the supplier created a new object.- Returns:
- the number of created objects
-
get
Retrieve or create an object. If all objects created by this factory are in-use, a new object is created.- Returns:
- an object
-
release
Release an object provided by ths factory, making it usable by other callers.- Parameters:
o
- an object provided byget()
-
list
Get a copy of the list of all objects (in-use and available) created by this factory.- Returns:
-