Class SharedResourceManager
- java.lang.Object
- 
- org.apache.bookkeeper.common.util.SharedResourceManager
 
- 
 public class SharedResourceManager extends java.lang.ObjectA holder for shared resource singletons.Components like clients and servers need certain resources, e.g. a scheduler, to run. If the user has not provided such resources, these components will use a default one, which is shared as a static resource. This class holds these default resources and manages their lifecycles. A resource is identified by the reference of a SharedResourceManager.Resourceobject, which is typically a singleton, provided to the get() and release() methods. Each resource object (not its class) maps to an object cached in the holder.Resources are ref-counted and shut down after a delay when the refcount reaches zero. 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static interfaceSharedResourceManager.Resource<T>Defines a resource, and the way to create and destroy instances of it.
 - 
Field SummaryFields Modifier and Type Field Description (package private) static longDESTROY_DELAY_SECONDS
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SharedResourceManagercreate()static SharedResourceManagercreate(java.util.function.Supplier<java.util.concurrent.ScheduledExecutorService> destroyerFactory)<T> Tget(SharedResourceManager.Resource<T> resource)<T> voidrelease(SharedResourceManager.Resource<T> resource, T instance)static SharedResourceManagershared()
 
- 
- 
- 
Field Detail- 
DESTROY_DELAY_SECONDSstatic final long DESTROY_DELAY_SECONDS - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
sharedpublic static SharedResourceManager shared() 
 - 
createpublic static SharedResourceManager create() 
 - 
createpublic static SharedResourceManager create(java.util.function.Supplier<java.util.concurrent.ScheduledExecutorService> destroyerFactory) 
 - 
getpublic <T> T get(SharedResourceManager.Resource<T> resource) 
 - 
releasepublic <T> void release(SharedResourceManager.Resource<T> resource, T instance) 
 
- 
 
-