Skip navigation links

Oracle® Coherence Java API Reference
Release 12.1.2.0.3

E26043-02


com.tangosol.util
Class SimpleResourceRegistry

java.lang.Object
  extended by com.tangosol.util.SimpleResourceRegistry

All Implemented Interfaces:
com.oracle.common.base.Disposable, ResourceRegistry, ResourceResolver
Direct Known Subclasses:
SimpleResourceResolver

public class SimpleResourceRegistry
extends java.lang.Object
implements ResourceRegistry

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
protected  class SimpleResourceRegistry.RegistryKey
          Key class for a registered resource.
protected  class SimpleResourceRegistry.RegistryValue
          A holder for resource objects and their (optional) respective ResourceLifecycleObservers.

 

Nested classes/interfaces inherited from interface com.tangosol.util.ResourceRegistry
ResourceRegistry.ResourceLifecycleObserver

 

Field Summary

 

Fields inherited from interface com.tangosol.util.ResourceRegistry
DEFAULT_NAME

 

Constructor Summary
SimpleResourceRegistry()
          Construct a SimpleResourceRegistry.

 

Method Summary
 void dispose()
          
 java.lang.Object getResource(java.lang.Class clzResource)
          Attempts to retrieve the resource that was registered with the specified class.
 java.lang.Object getResource(java.lang.Class clzResource, java.lang.String sResourceName)
          Attempts to retrieve the resource that was registered with the specified class and name.
 boolean isEmpty()
          Determine if the ResourceRegistry is empty (contains no resource registrations).
 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.

 

Constructor Detail

SimpleResourceRegistry

public SimpleResourceRegistry()
Construct a SimpleResourceRegistry.

Method Detail

isEmpty

public boolean isEmpty()
Determine if the ResourceRegistry is empty (contains no resource registrations).
Returns:
true if the registry contains no resource registrations

dispose

public void dispose()
Specified by:
dispose in interface com.oracle.common.base.Disposable

getResource

public java.lang.Object getResource(java.lang.Class clzResource)
Attempts to retrieve the resource that was registered with the specified class.
Specified by:
getResource in interface ResourceResolver
Parameters:
clzResource - the class of the resource
Returns:
the registered resource or null if the resource is unknown to the ResourceRegistry

getResource

public java.lang.Object getResource(java.lang.Class clzResource,
                                    java.lang.String sResourceName)
Attempts to retrieve the resource that was registered with the specified class and name.
Specified by:
getResource in interface ResourceResolver
Parameters:
clzResource - the class of the resource
sResourceName - the name of the resource
Returns:
the registered resource or null if the resource is unknown to the ResourceRegistry

registerResource

public 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 ResourceRegistry.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.
Specified by:
registerResource in interface ResourceRegistry
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

public 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.
Specified by:
registerResource in interface ResourceRegistry
Parameters:
clzResource - the class of the resource
sResourceName - the proposed name 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 and name is already registered

registerResource

public 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 ResourceRegistry.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.
Specified by:
registerResource in interface ResourceRegistry
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

public 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.
Specified by:
registerResource in interface ResourceRegistry
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

public 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.

Specified by:
unregisterResource in interface ResourceRegistry
Parameters:
clzResource - the class of the resource
sResourceName - the name of the resource

Skip navigation links

Oracle® Coherence Java API Reference
Release 12.1.2.0.3

E26043-02


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