Skip navigation links

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

E47890-01


com.tangosol.net
Class ExtensibleConfigurableCacheFactory

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.net.ExtensibleConfigurableCacheFactory

All Implemented Interfaces:
ConfigurableCacheFactory

public class ExtensibleConfigurableCacheFactory
extends Base
implements ConfigurableCacheFactory

ExtensibleConfigurableCacheFactory provides a facility to access caches declared in a "coherence-cache-config.xsd" compliant configuration file.

It is strongly recommended that developers get a ConfigurableCacheFactory instance via CacheFactory.getCacheFactoryBuilder().getConfigurableCacheFactory(), rather than instantiate an ExtensibleConfigurableCacheFactory instance directly.

There are various ways of using this factory:

   ConfigurableCacheFactory factory =
       new ExtensibleConfigurableCacheFactory(sPath);
   ...
   ClassLoader loader  = getClass().getClassLoader();
   NamedCache cacheOne = factory.ensureCache("one", loader);
   NamedCache cacheTwo = factory.ensureCache("two", loader);
 

Another option is using the static version of the "ensureCache" call:

   ClassLoader loader  = getClass().getClassLoader();
   NamedCache cacheOne = CacheFactory.getCache("one", loader);
 

which uses an instance of ConfigurableCacheFactory obtained by CacheFactory.getConfigurableCacheFactory().

Since:
Coherence 12.1.2
Author:
gg 2003.05.26, pfm 2012.12.19
See Also:
CacheFactory.getCache(String, ClassLoader)

Nested Class Summary
static class ExtensibleConfigurableCacheFactory.DefaultDependencies
          The ExtensibleConfigurableCacheFactory.DefaultDependencies is a simple implementation of the ExtensibleConfigurableCacheFactory ExtensibleConfigurableCacheFactory.Dependencies interface.
static interface ExtensibleConfigurableCacheFactory.Dependencies
          The ExtensibleConfigurableCacheFactory.Dependencies for the ExtensibleConfigurableCacheFactory.
static class ExtensibleConfigurableCacheFactory.DependenciesHelper
          The ExtensibleConfigurableCacheFactory.DependenciesHelper provides helper method for constructing ExtensibleConfigurableCacheFactory.Dependencies implementations for ExtensibleConfigurableCacheFactorys.
static class ExtensibleConfigurableCacheFactory.Manager
          The Manager class uses builders to create the required backing maps and provides client access to those maps.
static class ExtensibleConfigurableCacheFactory.PartitionedBackingMapManager
          The PartitionedBackingMapManager is used by PartitionAwareBackingMap(s) to lazily configure the enclosing PABM based on the configuration settings of the enclosed maps.

 

Field Summary
static java.lang.String CACHE_NAME
          The name of the replaceable parameter representing the cache name.
static java.lang.String CACHE_REF
          The name of the replaceable parameter representing a cache reference.
static java.lang.String CLASS_LOADER
          The name of the replaceable parameter representing the class loader.
protected  com.tangosol.net.events.internal.ConfigurableCacheFactoryDispatcher f_dispatcher
          ConfigurableCacheFactoryDispatcher linked to this cache factory.
protected  com.tangosol.net.internal.ScopedReferenceStore f_store
          Store that holds cache references scoped by class loader and optionally, if configured, Subject.
static java.lang.String FILE_CFG_CACHE
          The default configuration file name.
protected  boolean m_fActivated
          Indicates whether this factory has been activated.
protected  boolean m_fDisposed
          Indicates whether this factory has been disposed.
protected  ScopeResolver m_scopeResolver
          The ScopeResolver used for modifying the scope name in the cache configuration.
protected  java.util.Set m_setManager
          A Set of BackingMapManager instances registered by this factory.
protected  java.util.Set m_setServices
          Set used to hold references to services that are ensured by this factory.
static java.util.HashMap MAP_SCHEMETYPE_BY_SCHEMENAME
          The mappings from scheme name to scheme type.
static java.lang.String MGR_CONTEXT
          The name of the replaceable parameter representing the backing map manager context.
static int SCHEME_CLASS
          The custom class scheme.
static int SCHEME_DISK
          Deprecated. As of Coherence 3.0, replaced by SCHEME_EXTERNAL and SCHEME_EXTERNAL_PAGED
static int SCHEME_DISTRIBUTED
          The distributed cache scheme.
static int SCHEME_EXTERNAL
          The external scheme.
static int SCHEME_EXTERNAL_PAGED
          The paged-external scheme.
static int SCHEME_FLASHJOURNAL
          The flash journal cache scheme.
static int SCHEME_INVOCATION
          The invocation service scheme.
static int SCHEME_LOCAL
          The local cache scheme.
static int SCHEME_NEAR
          The near cache scheme.
static int SCHEME_OPTIMISTIC
          The optimistic cache scheme.
static int SCHEME_OVERFLOW
          The overflow map scheme.
static int SCHEME_PROXY
          The proxy service scheme.
static int SCHEME_RAMJOURNAL
          The ram journal cache scheme.
static int SCHEME_READ_WRITE_BACKING
          The read write backing map scheme.
static java.lang.String SCHEME_REF
          The name of the replaceable parameter representing a scheme reference.
static int SCHEME_REMOTE_CACHE
          The remote cache scheme.
static int SCHEME_REMOTE_INVOCATION
          The remote invocation scheme.
static int SCHEME_REPLICATED
          The replicated cache scheme.
static int SCHEME_TRANSACTIONAL
          The transactional cache scheme.
static int SCHEME_UNKNOWN
          The unknown scheme type.
static int SCHEME_VERSIONED_BACKING
          The versioned backing map scheme.
static int SCHEME_VERSIONED_NEAR
          The versioned near cache scheme.

 

Constructor Summary
ExtensibleConfigurableCacheFactory(ExtensibleConfigurableCacheFactory.Dependencies dependencies)
          Constructs an ExtensibleConfigurableCacheFactory using the specified ExtensibleConfigurableCacheFactory.Dependencies.

 

Method Summary
 void activate()
          Activate prepares the factory to be used within a container and should be called before any other factory method.
protected  void assertNotDisposed()
          Throws IllegalStateException if this factory has been disposed via invocation of dispose().
protected static void checkPermission(NamedCache cache)
          Check if the current user is allowed to "join" the cache.
protected  void configure()
          Performs final configuration of an ExtensibleConfigurableCacheFactory instance prior to it being used by Coherence.
 void destroyCache(NamedCache cache)
          Release and destroy this instance of NamedCache.
 void dispose()
          Dispose of this factory.
 NamedCache ensureCache(java.lang.String sCacheName, java.lang.ClassLoader loader)
          Ensure a cache for the given name.
 Service ensureService(ServiceScheme scheme)
          Ensure the service for the specified scheme then start the service if it isn't running.
 Service ensureService(java.lang.String sServiceName)
          Ensure a service for the given name.
 CacheConfig getCacheConfig()
          Return the CacheConfig that contains the configuration used by this factory.
protected  java.lang.ClassLoader getConfigClassLoader()
          Return the class loader used to load the configuration for this factory.
 InterceptorRegistry getInterceptorRegistry()
          Return the InterceptorRegistry for this factory.
 com.tangosol.config.expression.ParameterResolver getParameterResolver(java.lang.String sCacheName, java.lang.ClassLoader loader, BackingMapManagerContext context)
          Return the ParameterResolver that has been initialized with the built-in Coherence parameters.
protected  long getRequestTimeout(ServiceScheme scheme)
          Return the request timeout determined by the ServiceScheme.
 ResourceRegistry getResourceRegistry()
          Return the ResourceRegistry for this factory.
 java.lang.String getScopeName()
          Return the scope name for this ConfigurableCacheFactory.
protected  boolean isDisposed()
          Return true if this factory has been disposed via invocation of dispose().
protected  void registerBackingMapManager(BackingMapManager mgr)
          Register the specified BackingMapManager as a "valid" one.
protected  void registerEventInterceptors(java.util.List listBuilders, ResolvableParameterList parameters)
          Register the NamedEventInterceptors generated by the provided builders with the InterceptorRegistry.
protected  void release(BinaryStore store)
          Release all resources associated with the specified binary store.
protected  void release(CacheLoader loader)
          Release all resources associated with the specified loader.
protected  void release(java.util.Map map, java.util.Map mapListeners)
          Release all resources associated with the specified backing map.
 void releaseCache(NamedCache cache)
          Release a cache and its associated resources.
protected  void releaseCache(NamedCache cache, boolean fDestroy)
          Release a cache managed by this factory, optionally destroying it.
protected  java.lang.String resolveScopeName(ServiceBuilder bldrService)
          Determine the scope name for the given ServiceBuilder.
protected  void setConfigClassLoader(java.lang.ClassLoader loader)
          Set the class loader used to load the configuration for this factory.
 void setScopeName(java.lang.String sScopeName)
          Set the scope name for this ConfigurableCacheFactory.
protected  void startService(Service service)
          Start the given Service.
 java.util.Map startServices()
          Start all services that are declared as requiring an "autostart".
protected  int translateSchemeType(java.lang.String sScheme)
          Translate the scheme name into the scheme type.
protected static int translateStandardSchemeType(java.lang.String sScheme)
          Translate the scheme name into the scheme type.
protected  void validateBackingMapManager(CacheService service)
          Ensures that the backing map manager of the specified service was configured by this (or equivalent) factory.

 

Field Detail

FILE_CFG_CACHE

public static final java.lang.String FILE_CFG_CACHE
The default configuration file name.
See Also:
Constant Field Values

CACHE_NAME

public static final java.lang.String CACHE_NAME
The name of the replaceable parameter representing the cache name.
See Also:
Constant Field Values

CLASS_LOADER

public static final java.lang.String CLASS_LOADER
The name of the replaceable parameter representing the class loader.
See Also:
Constant Field Values

MGR_CONTEXT

public static final java.lang.String MGR_CONTEXT
The name of the replaceable parameter representing the backing map manager context.
See Also:
Constant Field Values

SCHEME_REF

public static final java.lang.String SCHEME_REF
The name of the replaceable parameter representing a scheme reference.
See Also:
Constant Field Values

CACHE_REF

public static final java.lang.String CACHE_REF
The name of the replaceable parameter representing a cache reference.
See Also:
Constant Field Values

SCHEME_UNKNOWN

public static final int SCHEME_UNKNOWN
The unknown scheme type.
See Also:
Constant Field Values

SCHEME_REPLICATED

public static final int SCHEME_REPLICATED
The replicated cache scheme.
See Also:
Constant Field Values

SCHEME_OPTIMISTIC

public static final int SCHEME_OPTIMISTIC
The optimistic cache scheme.
See Also:
Constant Field Values

SCHEME_DISTRIBUTED

public static final int SCHEME_DISTRIBUTED
The distributed cache scheme.
See Also:
Constant Field Values

SCHEME_NEAR

public static final int SCHEME_NEAR
The near cache scheme.
See Also:
Constant Field Values

SCHEME_VERSIONED_NEAR

public static final int SCHEME_VERSIONED_NEAR
The versioned near cache scheme.
See Also:
Constant Field Values

SCHEME_LOCAL

public static final int SCHEME_LOCAL
The local cache scheme.
See Also:
Constant Field Values

SCHEME_OVERFLOW

public static final int SCHEME_OVERFLOW
The overflow map scheme.
See Also:
Constant Field Values

SCHEME_DISK

public static final int SCHEME_DISK
Deprecated. As of Coherence 3.0, replaced by SCHEME_EXTERNAL and SCHEME_EXTERNAL_PAGED
The disk scheme.
See Also:
Constant Field Values

SCHEME_EXTERNAL

public static final int SCHEME_EXTERNAL
The external scheme.
See Also:
Constant Field Values

SCHEME_EXTERNAL_PAGED

public static final int SCHEME_EXTERNAL_PAGED
The paged-external scheme.
See Also:
Constant Field Values

SCHEME_CLASS

public static final int SCHEME_CLASS
The custom class scheme.
See Also:
Constant Field Values

SCHEME_READ_WRITE_BACKING

public static final int SCHEME_READ_WRITE_BACKING
The read write backing map scheme.
See Also:
Constant Field Values

SCHEME_VERSIONED_BACKING

public static final int SCHEME_VERSIONED_BACKING
The versioned backing map scheme.
See Also:
Constant Field Values

SCHEME_INVOCATION

public static final int SCHEME_INVOCATION
The invocation service scheme.
See Also:
Constant Field Values

SCHEME_PROXY

public static final int SCHEME_PROXY
The proxy service scheme.
See Also:
Constant Field Values

SCHEME_REMOTE_CACHE

public static final int SCHEME_REMOTE_CACHE
The remote cache scheme.
See Also:
Constant Field Values

SCHEME_REMOTE_INVOCATION

public static final int SCHEME_REMOTE_INVOCATION
The remote invocation scheme.
See Also:
Constant Field Values

SCHEME_TRANSACTIONAL

public static final int SCHEME_TRANSACTIONAL
The transactional cache scheme.
See Also:
Constant Field Values

SCHEME_FLASHJOURNAL

public static final int SCHEME_FLASHJOURNAL
The flash journal cache scheme.
See Also:
Constant Field Values

SCHEME_RAMJOURNAL

public static final int SCHEME_RAMJOURNAL
The ram journal cache scheme.
See Also:
Constant Field Values

MAP_SCHEMETYPE_BY_SCHEMENAME

public static final java.util.HashMap MAP_SCHEMETYPE_BY_SCHEMENAME
The mappings from scheme name to scheme type.

f_store

protected final com.tangosol.net.internal.ScopedReferenceStore f_store
Store that holds cache references scoped by class loader and optionally, if configured, Subject.

f_dispatcher

protected final com.tangosol.net.events.internal.ConfigurableCacheFactoryDispatcher f_dispatcher
ConfigurableCacheFactoryDispatcher linked to this cache factory.

m_setServices

protected java.util.Set m_setServices
Set used to hold references to services that are ensured by this factory.

m_scopeResolver

protected ScopeResolver m_scopeResolver
The ScopeResolver used for modifying the scope name in the cache configuration.

m_setManager

protected java.util.Set m_setManager
A Set of BackingMapManager instances registered by this factory.

Note: we rely on the BackingMapManager classes *not* to override the hashCode() and equals() methods.


m_fActivated

protected boolean m_fActivated
Indicates whether this factory has been activated.

m_fDisposed

protected boolean m_fDisposed
Indicates whether this factory has been disposed.

Constructor Detail

ExtensibleConfigurableCacheFactory

public ExtensibleConfigurableCacheFactory(ExtensibleConfigurableCacheFactory.Dependencies dependencies)
Constructs an ExtensibleConfigurableCacheFactory using the specified ExtensibleConfigurableCacheFactory.Dependencies.
Parameters:
dependencies - the ExtensibleConfigurableCacheFactory.Dependencies

Method Detail

ensureCache

public NamedCache ensureCache(java.lang.String sCacheName,
                              java.lang.ClassLoader loader)
Ensure a cache for the given name.
Specified by:
ensureCache in interface ConfigurableCacheFactory
Parameters:
sCacheName - the cache name
loader - ClassLoader that should be used to deserialize objects in the cache
Returns:
a NamedCache created

releaseCache

public void releaseCache(NamedCache cache)
Release a cache and its associated resources.

Releasing a cache makes it no longer usable, but does not affect the cache itself. In other words, all other references to the cache will still be valid, and the cache data is not affected by releasing the reference. Any attempt to use the released cache reference afterword will result in an exception.

Specified by:
releaseCache in interface ConfigurableCacheFactory
Parameters:
cache - the cache to release

destroyCache

public void destroyCache(NamedCache cache)
Release and destroy this instance of NamedCache.

Warning: This method is used to completely destroy the specified cache across the cluster. All references in the entire cluster to this cache will be invalidated, the cached data will be cleared, and all internal and associated resources will be released.

Specified by:
destroyCache in interface ConfigurableCacheFactory
Parameters:
cache - the cache to release

ensureService

public Service ensureService(java.lang.String sServiceName)
Ensure a service for the given name.
Specified by:
ensureService in interface ConfigurableCacheFactory
Parameters:
sServiceName - the service name
Returns:
a Service created

activate

public void activate()
Activate prepares the factory to be used within a container and should be called before any other factory method. Note that this factory can only be activated once and disposed of once.
Specified by:
activate in interface ConfigurableCacheFactory

dispose

public void dispose()
Dispose of this factory. This will stop all services that were started by this factory and dispose of all resources registered via ConfigurableCacheFactory.getResourceRegistry(). This factory may not be used after invoking dispose.
Specified by:
dispose in interface ConfigurableCacheFactory

getResourceRegistry

public ResourceRegistry getResourceRegistry()
Return the ResourceRegistry for this factory.
Specified by:
getResourceRegistry in interface ConfigurableCacheFactory
Returns:
the ResourceRegistry for this factory

getInterceptorRegistry

public InterceptorRegistry getInterceptorRegistry()
Return the InterceptorRegistry for this factory. EventInterceptors registered with this registry will be scoped to services and caches created by this factory.
Specified by:
getInterceptorRegistry in interface ConfigurableCacheFactory
Returns:
the InterceptorRegistry for this factory

setScopeName

public void setScopeName(java.lang.String sScopeName)
Set the scope name for this ConfigurableCacheFactory. Note that this method should only be invoked by a CacheFactoryBuilder when initializing this ConfigurableCacheFactory instance.

This method will be removed in a future release.

Parameters:
sScopeName - the scope name for this ConfigurableCacheFactory
Throws:
java.lang.IllegalStateException - if this setter is invoked after a service start

getScopeName

public java.lang.String getScopeName()
Return the scope name for this ConfigurableCacheFactory. If specified, this name will be used as a prefix for the name of all services created by this factory.
Returns:
the scope name for this ConfigurableCacheFactory; may be null

getRequestTimeout

protected long getRequestTimeout(ServiceScheme scheme)
Return the request timeout determined by the ServiceScheme.
Parameters:
scheme - the scheme that determines the request timeout
Returns:
the request timeout

isDisposed

protected boolean isDisposed()
Return true if this factory has been disposed via invocation of dispose().
Returns:
true if this factory has been disposed

assertNotDisposed

protected void assertNotDisposed()
Throws IllegalStateException if this factory has been disposed via invocation of dispose().
Throws:
java.lang.IllegalStateException - if this factory has been disposed

configure

protected void configure()
Performs final configuration of an ExtensibleConfigurableCacheFactory instance prior to it being used by Coherence.

This method is called by the ExtensibleConfigurableCacheFactory constructor, just after the internal state has been initialized and before the ExtensibleConfigurableCacheFactory instance is returned to the caller.

This method allows those that need to sub-class an ExtensibleConfigurableCacheFactory to override the final stages of configuration. Anyone overriding this method must be sure to call super.configure() in order to ensure correction configuration semantics.


registerEventInterceptors

protected void registerEventInterceptors(java.util.List listBuilders,
                                         ResolvableParameterList parameters)
Register the NamedEventInterceptors generated by the provided builders with the InterceptorRegistry.
Parameters:
listBuilders - the builders that generate NamedEventInterceptors to register
parameters - the parameters that can be consumed by the EventInterceptors

ensureService

public Service ensureService(ServiceScheme scheme)
Ensure the service for the specified scheme then start the service if it isn't running.
Parameters:
scheme - the scheme needed to ensure the service.
Returns:
the Service

getCacheConfig

public CacheConfig getCacheConfig()
Return the CacheConfig that contains the configuration used by this factory.
Returns:
the CacheConfig

translateSchemeType

protected int translateSchemeType(java.lang.String sScheme)
Translate the scheme name into the scheme type. Valid scheme types are any of the SCHEME_* constants.
Parameters:
sScheme - the scheme name
Returns:
the scheme type

translateStandardSchemeType

protected static int translateStandardSchemeType(java.lang.String sScheme)
Translate the scheme name into the scheme type. Valid scheme types are any of the SCHEME_* constants.
Parameters:
sScheme - the scheme name
Returns:
the scheme type

startServices

public java.util.Map startServices()
Start all services that are declared as requiring an "autostart".
Returns:
a Map of Services by service name that were successfully started

startService

protected void startService(Service service)
Start the given Service. Extensions of this class can override this method to provide pre/post start functionality.
Parameters:
service - the Service to start

setConfigClassLoader

protected void setConfigClassLoader(java.lang.ClassLoader loader)
Set the class loader used to load the configuration for this factory.
Parameters:
loader - the class loader to use for loading the configuration

getConfigClassLoader

protected java.lang.ClassLoader getConfigClassLoader()
Return the class loader used to load the configuration for this factory.
Returns:
the class loader to use for loading the configuration

checkPermission

protected static void checkPermission(NamedCache cache)
Check if the current user is allowed to "join" the cache.
Parameters:
cache - the cache
Throws:
java.lang.SecurityException - if permission is denied

getParameterResolver

public com.tangosol.config.expression.ParameterResolver getParameterResolver(java.lang.String sCacheName,
                                                                             java.lang.ClassLoader loader,
                                                                             BackingMapManagerContext context)
Return the ParameterResolver that has been initialized with the built-in Coherence parameters. Schemes may use expressions (macros) and the resolver contains the parameters that are defined in the cache mapping needed to translate those expressions into values.
Parameters:
sCacheName - the cache name
loader - the ClassLoader
context - the BackingMapManagerContext
Returns:
the ParameterResolver

resolveScopeName

protected java.lang.String resolveScopeName(ServiceBuilder bldrService)
Determine the scope name for the given ServiceBuilder.

Note: If the ServiceBuilder does not have a scope name defined, then the scope name configured for this ConfigurableCacheFactory will be used.

Parameters:
bldrService - the ServiceBuilder
Returns:
the resolved scope name for the ServiceBuilder

registerBackingMapManager

protected void registerBackingMapManager(BackingMapManager mgr)
Register the specified BackingMapManager as a "valid" one. That registry is used to identify services configured and started by this factory and prevent accidental usage of (potentially incompatible) cache services with the same name created by other factories.
Parameters:
mgr - a BackingMapManager instance instantiated by this factory

validateBackingMapManager

protected void validateBackingMapManager(CacheService service)
                                  throws java.lang.IllegalStateException
Ensures that the backing map manager of the specified service was configured by this (or equivalent) factory. This validation is performed to prevent accidental usage of (potentially incompatible) cache services with the same name created by other factories.
Parameters:
service - the CacheService to validate
Throws:
java.lang.IllegalStateException - if the backing map for the provided service does not reference the expected factory

release

protected void release(java.util.Map map,
                       java.util.Map mapListeners)
Release all resources associated with the specified backing map.
Parameters:
map - the map being released
mapListeners - map of registered map listeners keyed by the corresponding map references

release

protected void release(CacheLoader loader)
Release all resources associated with the specified loader.
Parameters:
loader - the cache loader being released

release

protected void release(BinaryStore store)
Release all resources associated with the specified binary store.
Parameters:
store - the binary store being released

releaseCache

protected void releaseCache(NamedCache cache,
                            boolean fDestroy)
Release a cache managed by this factory, optionally destroying it.
Parameters:
cache - the cache to release
fDestroy - true to destroy the cache as well

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.