Skip navigation links

Oracle® Fusion Middleware Java API Reference for Oracle Coherence
12c (12.1.3.0.0)

E47890-01


com.tangosol.util
Interface ResourceRegistry

All Superinterfaces:
com.oracle.common.base.Disposable, ResourceResolver
All Known Implementing Classes:
SimpleResourceRegistry, SimpleResourceResolver

public interface ResourceRegistry
extends ResourceResolver, com.oracle.common.base.Disposable

A ResourceRegistry is a registry and owner of strongly typed and explicitly named resources.

When a resource is registered with a ResourceRegistry, the ResourceRegistry assumes ownership of the said resource, up until at which point the ResourceRegistry is disposed.

Important: Although a ResourceRegistry manages resources in a thread-safe manner, it is possible for a thread calling ResourceResolver.getResource(Class, String) to receive a null return value while another thread is registering a resource.

Since:
Coherence 12.1.2
Author:
bo 2011.06.05

Nested Class Summary
static interface ResourceRegistry.ResourceLifecycleObserver
          The ResourceRegistry.ResourceLifecycleObserver interface defines lifecycle handlers for resources registered with a ResourceRegistry.

 

Field Summary
static java.lang.String DEFAULT_NAME
          The name to use for the registration of a singleton and thus default resource.

 

Method Summary
 java.lang.String registerResource(java.lang.Class clzResource, Builder bldrResource, RegistrationBehavior behavior, ResourceRegistry.ResourceLifecycleObserver observer)
          Registers a resource according to the specified RegistrationBehavior.
 java.lang.String registerResource(java.lang.Class clzResource, java.lang.Object resource)
          Registers the resource for later retrieval with ResourceResolver.getResource(Class).
 java.lang.String registerResource(java.lang.Class clzResource, java.lang.String sResourceName, Builder bldrResource, RegistrationBehavior behavior, ResourceRegistry.ResourceLifecycleObserver observer)
          Registers a resource according to the specified RegistrationBehavior.
 java.lang.String registerResource(java.lang.Class clzResource, java.lang.String sResourceName, java.lang.Object resource)
          Registers the resource with the specified name for later retrieval with ResourceResolver.getResource(Class, String).
 void unregisterResource(java.lang.Class clzResource, java.lang.String sResourceName)
          Unregisters the resource that was previously registered of the specified class and name.

 

Methods inherited from interface com.tangosol.util.ResourceResolver
getResource, getResource

 

Methods inherited from interface com.oracle.common.base.Disposable
dispose

 

Field Detail

DEFAULT_NAME

static final java.lang.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

java.lang.String registerResource(java.lang.Class clzResource,
                                  java.lang.Object resource)
                                  throws java.lang.IllegalArgumentException
Registers the resource for later retrieval with ResourceResolver.getResource(Class).

Notes:

  1. Multiple resources for the same class can be registered if each resource is registered with a unique name via registerResource(Class, String, Object)
  2. Registration of resources will occur in a thread-safe manner.
  3. Resources that are Disposable will be disposed when the ResourceRegistry is disposed.
Parameters:
clzResource - the class of the resource
resource - the resource
Returns:
the actual name used to register the resource
Throws:
java.lang.IllegalArgumentException - if a resource of the same specified type is already registered

registerResource

java.lang.String registerResource(java.lang.Class clzResource,
                                  java.lang.String sResourceName,
                                  java.lang.Object resource)
                                  throws java.lang.IllegalArgumentException
Registers the resource with the specified name for later retrieval with ResourceResolver.getResource(Class, String).

Notes:

  1. Registration of resources will occur in a thread-safe manner.
  2. Resources that are Disposable will be disposed when the ResourceRegistry is disposed.
Parameters:
clzResource - the class of the resource
resource - the resource
sResourceName - the proposed name of the resource
Returns:
the actual name used to register the resource
Throws:
java.lang.IllegalArgumentException - if a resource of the same specified type and name is already registered

registerResource

java.lang.String registerResource(java.lang.Class clzResource,
                                  Builder bldrResource,
                                  RegistrationBehavior behavior,
                                  ResourceRegistry.ResourceLifecycleObserver observer)
                                  throws java.lang.IllegalArgumentException
Registers a resource according to the specified RegistrationBehavior. If successful the registered resource may later be retrieved using method ResourceResolver.getResource(Class).

Notes:

  1. 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)
  2. Registration of resources will occur in a thread-safe manner.
  3. Resources that are Disposable will be disposed when the ResourceRegistry is disposed.
Parameters:
clzResource - the class of the resource
bldrResource - the Builder to realize the resource to register (if required the specified behavior requires a resource)
behavior - the RegistrationBehavior to use
observer - an optional ResourceRegistry.ResourceLifecycleObserver that will be called when the resource is being released from the ResourceRegistry (may be null)
Returns:
the actual name used to register the resource
Throws:
java.lang.IllegalArgumentException - if a resource with the specified class is already registered with the ResourceRegistry and the behavior was RegistrationBehavior.FAIL

registerResource

java.lang.String registerResource(java.lang.Class clzResource,
                                  java.lang.String sResourceName,
                                  Builder bldrResource,
                                  RegistrationBehavior behavior,
                                  ResourceRegistry.ResourceLifecycleObserver observer)
                                  throws java.lang.IllegalArgumentException
Registers a resource according to the specified RegistrationBehavior. If successful the registered resource may later be retrieved using method ResourceResolver.getResource(Class, String).

Notes:

  1. Registration of resources will occur in a thread-safe manner.
  2. Resources that are Disposable will be disposed when the ResourceRegistry is disposed.
Parameters:
clzResource - the class of the resource
sResourceName - the proposed name of the resource
bldrResource - the Builder to realize the resource to register (if required the specified behavior requires a resource)
behavior - the RegistrationBehavior to use
observer - an optional ResourceRegistry.ResourceLifecycleObserver that will be called when the resource is being released from the ResourceRegistry (may be null)
Returns:
the actual name used to register the resource
Throws:
java.lang.IllegalArgumentException - if a resource with the specified class is already registered with the ResourceRegistry and the behavior was RegistrationBehavior.FAIL

unregisterResource

void unregisterResource(java.lang.Class clzResource,
                        java.lang.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.

Parameters:
clzResource - the class of the resource
sResourceName - the name of the resource

Skip navigation links

Oracle® Fusion Middleware Java API Reference for Oracle Coherence
12c (12.1.3.0.0)

E47890-01


Copyright © 2000, 2014, Oracle and/or its affiliates. All rights reserved.