Package com.tangosol.util
Class NullImplementation.NullResourceRegistry
java.lang.Object
com.tangosol.util.NullImplementation.NullResourceRegistry
- All Implemented Interfaces:
Disposable
,ResourceRegistry
,ResourceResolver
,AutoCloseable
- Enclosing class:
NullImplementation
public static class NullImplementation.NullResourceRegistry
extends Object
implements ResourceRegistry
A
ResourceRegistry
implementation that does nothing.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.tangosol.util.ResourceRegistry
ResourceRegistry.ResourceLifecycleObserver<R>
-
Field Summary
Modifier and TypeFieldDescriptionstatic final NullImplementation.NullResourceRegistry
Singleton instance of a NullResourceRegistry.Fields inherited from interface com.tangosol.util.ResourceRegistry
DEFAULT_NAME
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
Invoked when all resources owned by the implementer can safely be released.<R> R
getResource
(Class<R> clsResource) Attempts to retrieve the resource that was registered with the specified class.<R> R
getResource
(Class<R> clsResource, String sResourceName) Attempts to retrieve the resource that was registered with the specified class and name.<R> String
registerResource
(Class<R> clzResource, Builder<? extends R> bldrResource, RegistrationBehavior behavior, ResourceRegistry.ResourceLifecycleObserver<R> observer) Registers a resource according to the specifiedRegistrationBehavior
.<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
.<R> String
registerResource
(Class<R> clzResource, String sResourceName, R resource) Registers the resource with the specified name for later retrieval withResourceResolver.getResource(Class, String)
.<R> String
registerResource
(Class<R> clzResource, R resource) Registers the resource for later retrieval withResourceResolver.getResource(Class)
.<R> void
unregisterResource
(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, wait
Methods inherited from interface com.oracle.coherence.common.base.Disposable
close
-
Field Details
-
INSTANCE
Singleton instance of a NullResourceRegistry.
-
-
Constructor Details
-
NullResourceRegistry
public NullResourceRegistry()
-
-
Method Details
-
registerResource
Description copied from interface:ResourceRegistry
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
Disposable
will be disposed when theResourceRegistry
is disposed.
- Specified by:
registerResource
in 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
Description copied from interface:ResourceRegistry
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
Disposable
will be disposed when theResourceRegistry
is disposed.
- Specified by:
registerResource
in 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) Description copied from interface:ResourceRegistry
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
Disposable
will be disposed when theResourceRegistry
is disposed.
- Specified by:
registerResource
in interfaceResourceRegistry
- Type Parameters:
R
- the type of the resource- Parameters:
clzResource
- the class of the resourcebldrResource
- theBuilder
to realize the resource to register (if required the specified behavior requires a resource)behavior
- theRegistrationBehavior
to useobserver
- an optionalResourceRegistry.ResourceLifecycleObserver
that 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) throws IllegalArgumentException Description copied from interface:ResourceRegistry
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
Disposable
will be disposed when theResourceRegistry
is disposed.
- Specified by:
registerResource
in interfaceResourceRegistry
- Type Parameters:
R
- the type of the resource- Parameters:
clzResource
- the class of the resourcesResourceName
- the proposed name of the resourcebldrResource
- theBuilder
to realize the resource to register (if required the specified behavior requires a resource)behavior
- theRegistrationBehavior
to useobserver
- an optionalResourceRegistry.ResourceLifecycleObserver
that 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 theResourceRegistry
and the behavior wasRegistrationBehavior.FAIL
-
unregisterResource
Description copied from interface:ResourceRegistry
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:
unregisterResource
in interfaceResourceRegistry
- Type Parameters:
R
- the type of the resource- Parameters:
clzResource
- the class of the resourcesResourceName
- the name of the resource
-
getResource
Description copied from interface:ResourceResolver
Attempts to retrieve the resource that was registered with the specified class.- Specified by:
getResource
in interfaceResourceResolver
- Type Parameters:
R
- the type of the resource- Parameters:
clsResource
- the class of the resource- Returns:
- the registered resource or
null
if the resource is unknown to theResourceRegistry
-
getResource
Description copied from interface:ResourceResolver
Attempts to retrieve the resource that was registered with the specified class and name.- Specified by:
getResource
in interfaceResourceResolver
- Type Parameters:
R
- the type of the resource- Parameters:
clsResource
- the class of the resourcesResourceName
- the name of the resource- Returns:
- the registered resource or
null
if the resource is unknown to theResourceRegistry
-
dispose
public void dispose()Description copied from interface:Disposable
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:
dispose
in interfaceDisposable
-