public class ExtensibleConfigurableCacheFactory extends Base implements ConfigurableCacheFactory
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:
ExtensibleConfigurableCacheFactory.Dependencies deps = ExtensibleConfigurableCacheFactory.DependenciesHelper.newInstance("my-cache-config.xml"); ExtensibleConfigurableCacheFactory factory = new ExtensibleConfigurableCacheFactory(deps); ... 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()
.CacheFactory.getCache(String, ClassLoader)
Modifier and Type | Class and Description |
---|---|
static class |
ExtensibleConfigurableCacheFactory.DefaultDependencies
The
ExtensibleConfigurableCacheFactory.DefaultDependencies is a simple implementation of the ExtensibleConfigurableCacheFactory ExtensibleConfigurableCacheFactory.Dependencies interface. |
static interface |
ExtensibleConfigurableCacheFactory.Dependencies
|
static class |
ExtensibleConfigurableCacheFactory.DependenciesHelper
The
ExtensibleConfigurableCacheFactory.DependenciesHelper provides helper method for constructing ExtensibleConfigurableCacheFactory.Dependencies implementations for ExtensibleConfigurableCacheFactory s. |
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.
|
Base.LoggingWriter, Base.StackFrame
Modifier and Type | Field and Description |
---|---|
static String |
CACHE_NAME
The name of the replaceable parameter representing the cache name.
|
static String |
CACHE_REF
The name of the replaceable parameter representing a cache reference.
|
static 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.ScopedCacheReferenceStore |
f_store
Store that holds cache references scoped by class loader and optionally, if configured, Subject.
|
static 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 Map<Service,String> |
m_mapServices
Map used to hold references to services that are ensured by this factory where values are non-scoped service names.
|
protected Set<BackingMapManager> |
m_setManager
A Set of BackingMapManager instances registered by this factory.
|
static HashMap<String,Integer> |
MAP_SCHEMETYPE_BY_SCHEMENAME
The mappings from scheme name to scheme type.
|
static 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 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 and Description |
---|
ExtensibleConfigurableCacheFactory(ExtensibleConfigurableCacheFactory.Dependencies dependencies)
Constructs an
ExtensibleConfigurableCacheFactory using the specified ExtensibleConfigurableCacheFactory.Dependencies . |
Modifier and Type | Method and Description |
---|---|
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. |
com.tangosol.config.expression.ParameterResolver |
createParameterResolver(ClassLoader loader, BackingMapManagerContext ctxBMM)
Return the ParameterResolver that has been initialized with the built-in Coherence parameters.
|
void |
destroyCache(NamedCache cache)
Release and destroy this instance of NamedCache.
|
void |
dispose()
Dispose of this factory.
|
Service |
ensureService(ServiceScheme scheme)
Ensure the service for the specified scheme then start the service if it isn't running.
|
Service |
ensureService(String sServiceName)
Ensure a service for the given name.
|
<K,V> NamedCache<K,V> |
ensureTypedCache(String sCacheName, ClassLoader loader, TypeAssertion<K,V> assertion)
Ensure a cache for the given name satisfying the specified type assertion.
|
Context |
getApplicationContext()
Return the application Context associated with this ECCF.
|
CacheConfig |
getCacheConfig()
Return the
CacheConfig that contains the configuration used by this factory. |
protected ClassLoader |
getConfigClassLoader()
Return the class loader used to load the configuration for this factory.
|
ContainerContext |
getContainerContext()
Return the ContainerContext associated with this ECCF.
|
InterceptorRegistry |
getInterceptorRegistry()
Return the
InterceptorRegistry for this factory. |
com.tangosol.config.expression.ParameterResolver |
getParameterResolver(String sCacheName, ClassLoader loader, BackingMapManagerContext ctxBMM, ContainerContext ctxContainer)
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. |
String |
getScopeName()
Return the scope name for this ConfigurableCacheFactory.
|
Map<Service,String> |
getServiceMap()
Return a map of services that were successfully started by this factory where values are corresponding non-scoped service names.
|
boolean |
isCacheActive(String sCacheName, ClassLoader loader)
Validate whether a cache with the given name is active in the context of the given
ClassLoader . |
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 |
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(Map map, 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 void |
setConfigClassLoader(ClassLoader loader)
Set the class loader used to load the configuration for this factory.
|
protected void |
startService(Service service)
Start the given
Service . |
void |
startServices()
Start all services that are declared as requiring an "autostart".
|
protected static int |
translateStandardSchemeType(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.
|
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
ensureCache
public static final String FILE_CFG_CACHE
public static final String CACHE_NAME
public static final String CLASS_LOADER
public static final String MGR_CONTEXT
public static final String SCHEME_REF
public static final String CACHE_REF
public static final int SCHEME_UNKNOWN
public static final int SCHEME_REPLICATED
public static final int SCHEME_OPTIMISTIC
public static final int SCHEME_DISTRIBUTED
public static final int SCHEME_NEAR
public static final int SCHEME_VERSIONED_NEAR
public static final int SCHEME_LOCAL
public static final int SCHEME_OVERFLOW
public static final int SCHEME_DISK
SCHEME_EXTERNAL
and SCHEME_EXTERNAL_PAGED
public static final int SCHEME_EXTERNAL
public static final int SCHEME_EXTERNAL_PAGED
public static final int SCHEME_CLASS
public static final int SCHEME_READ_WRITE_BACKING
public static final int SCHEME_VERSIONED_BACKING
public static final int SCHEME_INVOCATION
public static final int SCHEME_PROXY
public static final int SCHEME_REMOTE_CACHE
public static final int SCHEME_REMOTE_INVOCATION
public static final int SCHEME_TRANSACTIONAL
public static final int SCHEME_FLASHJOURNAL
public static final int SCHEME_RAMJOURNAL
public static final HashMap<String,Integer> MAP_SCHEMETYPE_BY_SCHEMENAME
protected final com.tangosol.net.internal.ScopedCacheReferenceStore f_store
protected final com.tangosol.net.events.internal.ConfigurableCacheFactoryDispatcher f_dispatcher
protected Map<Service,String> m_mapServices
protected Set<BackingMapManager> m_setManager
Note: we rely on the BackingMapManager classes *not* to override the hashCode() and equals() methods.
protected boolean m_fActivated
protected boolean m_fDisposed
public ExtensibleConfigurableCacheFactory(ExtensibleConfigurableCacheFactory.Dependencies dependencies)
ExtensibleConfigurableCacheFactory
using the specified ExtensibleConfigurableCacheFactory.Dependencies
.dependencies
- the ExtensibleConfigurableCacheFactory.Dependencies
public <K,V> NamedCache<K,V> ensureTypedCache(String sCacheName, ClassLoader loader, TypeAssertion<K,V> assertion)
ensureTypedCache
in interface ConfigurableCacheFactory
sCacheName
- the cache nameloader
- the ClassLoader
to use for deserializing cache entriesassertion
- the TypeAssertion
for asserting the type of keys and values for the NamedCachepublic void releaseCache(NamedCache cache)
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.
releaseCache
in interface ConfigurableCacheFactory
cache
- the cache to releasepublic void destroyCache(NamedCache cache)
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.
destroyCache
in interface ConfigurableCacheFactory
cache
- the cache to releasepublic Service ensureService(String sServiceName)
ensureService
in interface ConfigurableCacheFactory
sServiceName
- the service namepublic void activate()
activate
in interface ConfigurableCacheFactory
public void dispose()
ConfigurableCacheFactory.getResourceRegistry()
. This factory may not be used after invoking dispose.dispose
in interface ConfigurableCacheFactory
public ResourceRegistry getResourceRegistry()
ResourceRegistry
for this factory.getResourceRegistry
in interface ConfigurableCacheFactory
public InterceptorRegistry getInterceptorRegistry()
InterceptorRegistry
for this factory. EventInterceptor
s registered with this registry will be scoped to services and caches created by this factory.getInterceptorRegistry
in interface ConfigurableCacheFactory
InterceptorRegistry
for this factorypublic String getScopeName()
public Context getApplicationContext()
public ContainerContext getContainerContext()
protected long getRequestTimeout(ServiceScheme scheme)
ServiceScheme
.scheme
- the scheme that determines the request timeoutprotected boolean isDisposed()
dispose()
.protected void assertNotDisposed()
IllegalStateException
if this factory has been disposed via invocation of dispose()
.protected void configure()
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.
public Service ensureService(ServiceScheme scheme)
scheme
- the scheme referring to the servicepublic CacheConfig getCacheConfig()
CacheConfig
that contains the configuration used by this factory.protected static int translateStandardSchemeType(String sScheme)
sScheme
- the scheme namepublic void startServices()
public Map<Service,String> getServiceMap()
Note, that this method returns a copy of the underlying map
protected void startService(Service service)
Service
. Extensions of this class can override this method to provide pre/post start functionality.service
- the Service
to startprotected void setConfigClassLoader(ClassLoader loader)
loader
- the class loader to use for loading the configurationprotected ClassLoader getConfigClassLoader()
protected static void checkPermission(NamedCache cache)
cache
- the cachepublic com.tangosol.config.expression.ParameterResolver getParameterResolver(String sCacheName, ClassLoader loader, BackingMapManagerContext ctxBMM, ContainerContext ctxContainer)
sCacheName
- the cache nameloader
- the ClassLoaderctxBMM
- the BackingMapManagerContextctxContainer
- the ContainerContextpublic com.tangosol.config.expression.ParameterResolver createParameterResolver(ClassLoader loader, BackingMapManagerContext ctxBMM)
loader
- the ClassLoaderctxBMM
- the BackingMapManagerContextprotected void registerBackingMapManager(BackingMapManager mgr)
mgr
- a BackingMapManager instance instantiated by this factoryprotected void validateBackingMapManager(CacheService service) throws IllegalStateException
service
- the CacheService to validateIllegalStateException
- if the backing map for the provided service does not reference the expected factoryprotected void release(Map map, Map mapListeners)
map
- the map being releasedmapListeners
- map of registered map listeners keyed by the corresponding map referencesprotected void release(CacheLoader loader)
loader
- the cache loader being releasedprotected void release(BinaryStore store)
store
- the binary store being releasedprotected void releaseCache(NamedCache cache, boolean fDestroy)
cache
- the cache to releasefDestroy
- true to destroy the cache as wellpublic boolean isCacheActive(String sCacheName, ClassLoader loader)
ClassLoader
. The ClassLoader should be the same as provided to a previous call to ConfigurableCacheFactory.ensureCache(String sCacheName, ClassLoader loader)
.isCacheActive
in interface ConfigurableCacheFactory
sCacheName
- the cache nameloader
- the ClassLoader that should be used to deserialize objects in the cache