Package com.tangosol.util
Interface ResourceRegistry
-
- All Superinterfaces:
AutoCloseable,Disposable,ResourceResolver
- All Known Implementing Classes:
NullImplementation.NullResourceRegistry,SimpleResourceRegistry,SimpleResourceResolver
public interface ResourceRegistry extends ResourceResolver, Disposable
AResourceRegistryis a registry and owner of strongly typed and explicitly named resources.When a resource is registered with a
ResourceRegistry, theResourceRegistryassumes ownership of the said resource, up until at which point theResourceRegistryisdisposed.Important: Although a
ResourceRegistrymanages resources in a thread-safe manner, it is possible for a thread callingResourceResolver.getResource(Class, String)to receive anullreturn value while another thread is registering a resource.- Since:
- Coherence 12.1.2
- Author:
- bo 2011.06.05
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceResourceRegistry.ResourceLifecycleObserver<R>TheResourceRegistry.ResourceLifecycleObserverinterface defines lifecycle handlers for resources registered with aResourceRegistry.
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_NAMEThe name to use for the registration of a singleton and thus default resource.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <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).<R> voidunregisterResource(Class<R> clzResource, String sResourceName)Unregisters the resource that was previously registered of the specified class and name.-
Methods inherited from interface com.oracle.coherence.common.base.Disposable
close, dispose
-
Methods inherited from interface com.tangosol.util.ResourceResolver
getResource, getResource
-
-
-
-
Field Detail
-
DEFAULT_NAME
static final String DEFAULT_NAME
The name to use for the registration of a singleton and thus default resource.- See Also:
- Constant Field Values
-
-
Method Detail
-
registerResource
<R> String registerResource(Class<R> clzResource, R resource) throws IllegalArgumentException
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
registerResource(Class, String, Object) - Registration of resources will occur in a thread-safe manner.
- Resources that are
Disposablewill be disposed when theResourceRegistryis disposed.
- Parameters:
clzResource- the class of the resourceresource- the resource- Returns:
- the actual name used to register the resource
- Throws:
IllegalArgumentException- if a resource of the same specified type is already registered
- Multiple resources for the same class can be registered if each
resource is registered with a unique name via
-
registerResource
<R> String registerResource(Class<R> clzResource, String sResourceName, R resource) throws IllegalArgumentException
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.
- Parameters:
clzResource- the class of the resourceresource- the resourcesResourceName- the proposed name of the resource- Returns:
- the actual name used to register the resource
- Throws:
IllegalArgumentException- if a resource of the same specified type and name is already registered
-
registerResource
<R> String registerResource(Class<R> clzResource, Builder<? extends R> bldrResource, RegistrationBehavior behavior, ResourceRegistry.ResourceLifecycleObserver<R> observer) throws IllegalArgumentException
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
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.
- 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
- Throws:
IllegalArgumentException- if a resource with the specified class is already registered with theResourceRegistryand the behavior wasRegistrationBehavior.FAIL
- Multiple resources for the same class can be registered if each
resource is registered with a unique name via
-
registerResource
<R> String registerResource(Class<R> clzResource, String sResourceName, Builder<? extends R> bldrResource, RegistrationBehavior behavior, ResourceRegistry.ResourceLifecycleObserver<R> observer) throws IllegalArgumentException
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.
- 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
- Throws:
IllegalArgumentException- if a resource with the specified class is already registered with theResourceRegistryand the behavior wasRegistrationBehavior.FAIL
-
unregisterResource
<R> void unregisterResource(Class<R> clzResource, String sResourceName)
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.- Type Parameters:
R- the type of the resource- Parameters:
clzResource- the class of the resourcesResourceName- the name of the resource
-
-