public static class NullImplementation.NullResourceRegistry extends Object implements ResourceRegistry
ResourceRegistry
implementation that does nothing.ResourceRegistry.ResourceLifecycleObserver<R>
Modifier and Type | Field and Description |
---|---|
static NullImplementation.NullResourceRegistry |
INSTANCE
Singleton instance of a NullResourceRegistry.
|
DEFAULT_NAME
Constructor and Description |
---|
NullResourceRegistry() |
Modifier and Type | Method and Description |
---|---|
void |
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 specified
RegistrationBehavior . |
<R> String |
registerResource(Class<R> clzResource,
R resource)
Registers the resource for later retrieval with
ResourceResolver.getResource(Class) . |
<R> String |
registerResource(Class<R> clzResource,
String sResourceName,
Builder<? extends R> bldrResource,
RegistrationBehavior behavior,
ResourceRegistry.ResourceLifecycleObserver<R> observer)
Registers a resource according to the specified
RegistrationBehavior . |
<R> String |
registerResource(Class<R> clzResource,
String sResourceName,
R resource)
Registers the resource with the specified name for later retrieval with
ResourceResolver.getResource(Class, String) . |
<R> void |
unregisterResource(Class<R> clzResource,
String sResourceName)
Unregisters the resource that was previously registered of the specified class and name.
|
public static final NullImplementation.NullResourceRegistry INSTANCE
public <R> String registerResource(Class<R> clzResource, R resource)
ResourceRegistry
ResourceResolver.getResource(Class)
.
Notes:
ResourceRegistry.registerResource(Class, String, Object)
Disposable
will be disposed when the
ResourceRegistry
is disposed.
registerResource
in interface ResourceRegistry
clzResource
- the class of the resourceresource
- the resourcepublic <R> String registerResource(Class<R> clzResource, String sResourceName, R resource)
ResourceRegistry
ResourceResolver.getResource(Class, String)
.
Notes:
Disposable
will be disposed when the
ResourceRegistry
is disposed.
registerResource
in interface ResourceRegistry
clzResource
- the class of the resourcesResourceName
- the proposed name of the resourceresource
- the resourcepublic <R> String registerResource(Class<R> clzResource, Builder<? extends R> bldrResource, RegistrationBehavior behavior, ResourceRegistry.ResourceLifecycleObserver<R> observer)
ResourceRegistry
RegistrationBehavior
.
If successful the registered resource may later be retrieved using method
ResourceResolver.getResource(Class)
.
Notes:
ResourceRegistry.registerResource(Class, String, Builder, RegistrationBehavior, ResourceLifecycleObserver)
Disposable
will be disposed when the
ResourceRegistry
is disposed.
registerResource
in interface ResourceRegistry
R
- the type of the resourceclzResource
- the class of the resourcebldrResource
- the Builder
to realize the resource
to register (if required the specified behavior
requires a resource)behavior
- the RegistrationBehavior
to useobserver
- an optional ResourceRegistry.ResourceLifecycleObserver
that
will be called when the resource is being released
from the ResourceRegistry
(may be null)public <R> String registerResource(Class<R> clzResource, String sResourceName, Builder<? extends R> bldrResource, RegistrationBehavior behavior, ResourceRegistry.ResourceLifecycleObserver<R> observer) throws IllegalArgumentException
ResourceRegistry
RegistrationBehavior
.
If successful the registered resource may later be retrieved using method
ResourceResolver.getResource(Class, String)
.
Notes:
Disposable
will be disposed when the
ResourceRegistry
is disposed.
registerResource
in interface ResourceRegistry
R
- the type of the resourceclzResource
- the class of the resourcesResourceName
- the proposed name of the resourcebldrResource
- the Builder
to realize the resource
to register (if required the specified behavior
requires a resource)behavior
- the RegistrationBehavior
to useobserver
- an optional ResourceRegistry.ResourceLifecycleObserver
that
will be called when the resource is being released
from the ResourceRegistry
(may be null)IllegalArgumentException
- if a resource with the specified class
is already registered with
the ResourceRegistry
and
the behavior was RegistrationBehavior.FAIL
public <R> void unregisterResource(Class<R> clzResource, String sResourceName)
ResourceRegistry
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.
unregisterResource
in interface ResourceRegistry
R
- the type of the resourceclzResource
- the class of the resourcesResourceName
- the name of the resourcepublic <R> R getResource(Class<R> clsResource)
ResourceResolver
getResource
in interface ResourceResolver
R
- the type of the resourceclsResource
- the class of the resourcenull
if the resource is
unknown to the ResourceRegistry
public <R> R getResource(Class<R> clsResource, String sResourceName)
ResourceResolver
getResource
in interface ResourceResolver
R
- the type of the resourceclsResource
- the class of the resourcesResourceName
- the name of the resourcenull
if the resource is
unknown to the ResourceRegistry
public void dispose()
com.oracle.coherence.common.base.Disposable
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.
dispose
in interface com.oracle.coherence.common.base.Disposable