Package com.tangosol.util
Class SimpleResourceRegistry
java.lang.Object
com.tangosol.util.SimpleResourceRegistry
- All Implemented Interfaces:
 Disposable,ResourceRegistry,ResourceResolver,AutoCloseable
- Direct Known Subclasses:
 SimpleResourceResolver
A 
SimpleResourceRegistry is a basic implementation of a ResourceRegistry.- Since:
 - Coherence 12.1.2
 - Author:
 - bo 2011.06.22, pp 2012.02.29
 
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classKey class for a registered resource.protected classA holder for resource objects and their (optional) respectiveResourceLifecycleObservers.Nested classes/interfaces inherited from interface com.tangosol.util.ResourceRegistry
ResourceRegistry.ResourceLifecycleObserver<R> - 
Field Summary
Fields inherited from interface com.tangosol.util.ResourceRegistry
DEFAULT_NAME - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()Invoked when all resources owned by the implementer can safely be released.<R> RgetResource(Class<R> clzResource) Attempts to retrieve the resource that was registered with the specified class.<R> RgetResource(Class<R> clzResource, String sResourceName) Attempts to retrieve the resource that was registered with the specified class and name.booleanisEmpty()Determine if theResourceRegistryis empty (contains no resource registrations).<R> StringregisterResource(Class<R> clzResource, Builder<? extends R> bldrResource, RegistrationBehavior behavior, ResourceRegistry.ResourceLifecycleObserver<R> observer) Registers a resource according to the specifiedRegistrationBehavior.<R> StringregisterResource(Class<R> clzResource, String sResourceName, Builder<? extends R> bldrResource, RegistrationBehavior behavior, ResourceRegistry.ResourceLifecycleObserver<R> observer) Registers a resource according to the specifiedRegistrationBehavior.<R> StringregisterResource(Class<R> clzResource, String sResourceName, R resource) Registers the resource with the specified name for later retrieval withResourceResolver.getResource(Class, String).<R> StringregisterResource(Class<R> clzResource, R resource) Registers the resource for later retrieval withResourceResolver.getResource(Class).voidregisterResources(ResourceRegistry registry) Register all the resources contained in this registry with the target registry.voidregisterResources(ResourceRegistry registry, RegistrationBehavior behavior) Register all the resources contained in this registry with the target registry.<R> voidunregisterResource(Class<R> clzResource, String sResourceName) Unregisters the resource that was previously registered of the specified class and name.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.oracle.coherence.common.base.Disposable
close 
- 
Constructor Details
- 
SimpleResourceRegistry
public SimpleResourceRegistry()Construct aSimpleResourceRegistry. 
 - 
 - 
Method Details
- 
isEmpty
public boolean isEmpty()Determine if theResourceRegistryis empty (contains no resource registrations).- Returns:
 - true if the registry contains no resource registrations
 
 - 
registerResources
Register all the resources contained in this registry with the target registry.- Parameters:
 registry- the targetResourceRegistryto register resources with
 - 
registerResources
Register all the resources contained in this registry with the target registry.- Parameters:
 registry- the targetResourceRegistryto register resources withbehavior- theRegistrationBehaviorto use
 - 
dispose
public void dispose()Invoked when all resources owned by the implementer can safely be released.Once disposed of the object should no longer be considered to be usable.
Note the Disposable interface is compatible with try-with-resources which will automatically invoke this method.
- Specified by:
 disposein interfaceDisposable
 - 
getResource
Attempts to retrieve the resource that was registered with the specified class.- Specified by:
 getResourcein interfaceResourceResolver- Type Parameters:
 R- the type of the resource- Parameters:
 clzResource- the class of the resource- Returns:
 - the registered resource or 
nullif the resource is unknown to theResourceRegistry 
 - 
getResource
Attempts to retrieve the resource that was registered with the specified class and name.- Specified by:
 getResourcein interfaceResourceResolver- Type Parameters:
 R- the type of the resource- Parameters:
 clzResource- the class of the resourcesResourceName- the name of the resource- Returns:
 - the registered resource or 
nullif the resource is unknown to theResourceRegistry 
 - 
registerResource
Registers the resource for later retrieval withResourceResolver.getResource(Class).Notes:
- Multiple resources for the same class can be registered if each
      resource is registered with a unique name via
      
ResourceRegistry.registerResource(Class, String, Object) - Registration of resources will occur in a thread-safe manner.
 - Resources that are 
Disposablewill be disposed when theResourceRegistryis disposed. 
- Specified by:
 registerResourcein interfaceResourceRegistry- Parameters:
 clzResource- the class of the resourceresource- the resource- Returns:
 - the actual name used to register the resource
 
 - Multiple resources for the same class can be registered if each
      resource is registered with a unique name via
      
 - 
registerResource
Registers the resource with the specified name for later retrieval withResourceResolver.getResource(Class, String).Notes:
- Registration of resources will occur in a thread-safe manner.
 - Resources that are 
Disposablewill be disposed when theResourceRegistryis disposed. 
- Specified by:
 registerResourcein interfaceResourceRegistry- Parameters:
 clzResource- the class of the resourcesResourceName- the proposed name of the resourceresource- the resource- Returns:
 - the actual name used to register the resource
 
 - 
registerResource
public <R> String registerResource(Class<R> clzResource, Builder<? extends R> bldrResource, RegistrationBehavior behavior, ResourceRegistry.ResourceLifecycleObserver<R> observer) Registers a resource according to the specifiedRegistrationBehavior. If successful the registered resource may later be retrieved using methodResourceResolver.getResource(Class).Notes:
- Multiple resources for the same class can be registered if each
      resource is registered with a unique name via
      
ResourceRegistry.registerResource(Class, String, Builder, RegistrationBehavior, ResourceLifecycleObserver) - Registration of resources will occur in a thread-safe manner.
 - Resources that are 
Disposablewill be disposed when theResourceRegistryis disposed. 
- Specified by:
 registerResourcein interfaceResourceRegistry- Type Parameters:
 R- the type of the resource- Parameters:
 clzResource- the class of the resourcebldrResource- theBuilderto realize the resource to register (if required the specified behavior requires a resource)behavior- theRegistrationBehaviorto useobserver- an optionalResourceRegistry.ResourceLifecycleObserverthat will be called when the resource is being released from theResourceRegistry(may be null)- Returns:
 - the actual name used to register the resource
 
 - Multiple resources for the same class can be registered if each
      resource is registered with a unique name via
      
 - 
registerResource
public <R> String registerResource(Class<R> clzResource, String sResourceName, Builder<? extends R> bldrResource, RegistrationBehavior behavior, ResourceRegistry.ResourceLifecycleObserver<R> observer) Registers a resource according to the specifiedRegistrationBehavior. If successful the registered resource may later be retrieved using methodResourceResolver.getResource(Class, String).Notes:
- Registration of resources will occur in a thread-safe manner.
 - Resources that are 
Disposablewill be disposed when theResourceRegistryis disposed. 
- Specified by:
 registerResourcein interfaceResourceRegistry- Type Parameters:
 R- the type of the resource- Parameters:
 clzResource- the class of the resourcesResourceName- the proposed name of the resourcebldrResource- theBuilderto realize the resource to register (if required the specified behavior requires a resource)behavior- theRegistrationBehaviorto useobserver- an optionalResourceRegistry.ResourceLifecycleObserverthat will be called when the resource is being released from theResourceRegistry(may be null)- Returns:
 - the actual name used to register the resource
 
 - 
unregisterResource
Unregisters the resource that was previously registered of the specified class and name.Note: Unregistering a resource does not cause it to be disposed, but it does call
ResourceRegistry.ResourceLifecycleObserver.onRelease(Object)if an observer was provided at the time of registration.- Specified by:
 unregisterResourcein interfaceResourceRegistry- Type Parameters:
 R- the type of the resource- Parameters:
 clzResource- the class of the resourcesResourceName- the name of the resource
 
 -