CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation

com.tangosol.net
Class DefaultConfigurableCacheFactory

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.net.DefaultConfigurableCacheFactory
All Implemented Interfaces:
ConfigurableCacheFactory, XmlConfigurable

public class DefaultConfigurableCacheFactory
extends Base
implements ConfigurableCacheFactory

DefaultConfigurableCacheFactory provides a facility to access caches declared in a "cache-config.dtd" compliant configuration file.

This class is designed to be easily extendable with a collection of factory methods allowing subclasses to customize it by overriding any subset of cache instantiation routines or even allowing addition of custom schemes.

There are various ways of using this factory:

   ConfigurableCacheFactory factory =
       new DefaultConfigurableCacheFactory(sPath);
   ...
   ClassLoader loader  = getClass().getClassLoader();
   NamedCache cacheOne = factory.ensureCache("one", loader);
   NamedCache cacheTwo = factory.ensureCache("two", loader);
 
Using this approach allows an easy customization by extending the DefaultConfigurableCacheFactory and changing the instantiation line:
   ConfigurableCacheFactory factory = new CustomConfigurableCacheFactory();
   ...
 
Another option is using the static version of the "ensureCache" call:
   ClassLoader loader  = getClass().getClassLoader();
   NamedCache cacheOne = CacheFactory.getCache("one", loader);
   NamedCache cacheTwo = CacheFactory.getCache("two", loader);
 
which uses an instance of ConfigurableCacheFactory obtained by CacheFactory.getConfigurableCacheFactory().

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

Nested Class Summary
static class DefaultConfigurableCacheFactory.CacheInfo
          CacheInfo is a placeholder for cache attributes retrieved during parsing the corresponding cache mapping element.
 class DefaultConfigurableCacheFactory.Manager
          BackingMapManager implementation that uses the configuration XML to create the required backing maps and provides client access to those maps.
 
Field Summary
static String CACHE_NAME
          The name of the replaceable parameter representing the cache name.
static String CLASS_LOADER
          The name of the replaceable parameter representing the class loader.
static String FILE_CFG_CACHE
          The default configuration file name.
protected  ConcurrentMap m_mapByName
          Map keyed by a cache name with a corresponding value being a map keyed by a class loader with a corresponding value being a NamedCache reference.
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_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_READ_WRITE_BACKING
          The read write backing map scheme.
static String SCHEME_REF
          The name of the replaceable parameter representing the 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_UNKNOWN
          The unknwown scheme type.
static int SCHEME_VERSIONED_BACKING
          The versioned backing map scheme.
static int SCHEME_VERSIONED_NEAR
          The versioned near cache scheme.
 
Constructor Summary
DefaultConfigurableCacheFactory()
          Construct a default DefaultConfigurableCacheFactory using the default configuration file name.
DefaultConfigurableCacheFactory(String sPath)
          Construct a DefaultConfigurableCacheFactory using the specified path to a "cache-config.dtd" compliant configuration file or resource.
DefaultConfigurableCacheFactory(String sPath, ClassLoader loader)
          Construct a DefaultConfigurableCacheFactory using the specified path to a "cache-config.dtd" compliant configuration file or resource.
DefaultConfigurableCacheFactory(XmlElement xmlConfig)
          Construct a DefaultConfigurableCacheFactory using the specified configuration XML.
 
Method Summary
 Map configureBackingMap(DefaultConfigurableCacheFactory.CacheInfo info, XmlElement xmlScheme, BackingMapManagerContext context, ClassLoader loader, Map mapListeners)
          Configures a backing map according to the scheme.
protected  NamedCache configureCache(DefaultConfigurableCacheFactory.CacheInfo info, XmlElement xmlScheme, ClassLoader loader)
          Ensures a cache for given scheme.
protected  NamedCache ensureCache(DefaultConfigurableCacheFactory.CacheInfo info, XmlElement xmlScheme, ClassLoader loader)
          Obtain the NamedCache reference for the cache service defined by the specified scheme.
 NamedCache ensureCache(String sCacheName, ClassLoader loader)
          Ensure a cache for the given name using the corresponding XML configuration.
 Service ensureService(String sServiceName)
          Ensure a service for the given name using the corresponding XML configuration.
 Service ensureService(XmlElement xmlScheme)
          Ensure the service for the specified scheme.
protected  XmlElement findScheme(String sSchemeName)
          In the configuration XML find a "scheme" element associated with a given cache name.
 DefaultConfigurableCacheFactory.CacheInfo findSchemeMapping(String sCacheName)
          In the configuration XML find a "cache-mapping" element associated with a given cache name.
protected  XmlElement findServiceScheme(String sServiceName)
          In the configuration XML find a "scheme" element associated with a given service name.
 XmlElement getConfig()
          Obtain the factory configuration XML.
protected  void initializeBundler(AbstractBundler bundler, XmlElement xmlBundle)
          Initialize the specified bundler using the "bundle-config" element.
protected  Object instantiateAny(DefaultConfigurableCacheFactory.CacheInfo info, XmlElement xmlClass, BackingMapManagerContext context, ClassLoader loader)
          Create an Object using "class-scheme" element.
protected  AsyncBinaryStore instantiateAsyncBinaryStore(BinaryStore store, int cbMaxAsync)
          Construct an AsyncBinaryStore using the specified parameters.
protected  AsyncBinaryStoreManager instantiateAsyncBinaryStoreManager(BinaryStoreManager storeMgr, int cbMaxAsync)
          Construct an AsyncBinaryStoreManager using the specified parameters.
protected  BinaryStoreManager instantiateBinaryStoreManager(XmlElement xmlConfig, ClassLoader loader, boolean fPaged)
          Create a BinaryStoreManager using the specified XML configuration.
protected  BundlingNamedCache instantiateBundlingNamedCache(NamedCache cache, XmlElement xmlBundling)
          Create a BundlingNamedCache using the "operation-bundling" element.
protected  CacheLoader instantiateCacheStore(DefaultConfigurableCacheFactory.CacheInfo info, XmlElement xmlStore, BackingMapManagerContext context, ClassLoader loader)
          Create a CacheLoader or CacheStore using the "cachestore-scheme" element.
protected  Map instantiateDiskBackingMap(DefaultConfigurableCacheFactory.CacheInfo info, XmlElement xmlDisk, BackingMapManagerContext context, ClassLoader loader)
          Deprecated. As of Coherence 3.0, replaced by instantiateExternalBackingMap(com.tangosol.net.DefaultConfigurableCacheFactory.CacheInfo, com.tangosol.run.xml.XmlElement, com.tangosol.net.BackingMapManagerContext, java.lang.ClassLoader) and instantiatePagedExternalBackingMap(com.tangosol.net.DefaultConfigurableCacheFactory.CacheInfo, com.tangosol.run.xml.XmlElement, com.tangosol.net.BackingMapManagerContext, java.lang.ClassLoader)
protected  Map instantiateExternalBackingMap(DefaultConfigurableCacheFactory.CacheInfo info, XmlElement xmlExternal, BackingMapManagerContext context, ClassLoader loader)
          Create a backing Map using the "external-scheme" element.
protected  Map instantiateLocalCache(DefaultConfigurableCacheFactory.CacheInfo info, XmlElement xmlLocal, ClassLoader loader)
          Create a backing Map using the "local-scheme" element.
protected  LocalCache instantiateLocalCache(int cUnits, int cExpiryMillis)
          Construct a LocalCache using the specified parameters.
protected  Map instantiateMap(DefaultConfigurableCacheFactory.CacheInfo info, XmlElement xmlClass, BackingMapManagerContext context, ClassLoader loader)
          Create a backing Map using the "class-scheme" element.
protected  MapListener instantiateMapListener(DefaultConfigurableCacheFactory.CacheInfo info, XmlElement xmlClass, BackingMapManagerContext context, ClassLoader loader)
          Create a MapListener using the using the "class-scheme" element.
protected  NearCache instantiateNearCache(Map mapFront, NamedCache mapBack, int nStrategy)
          Construct an NearCache using the specified parameters.
protected  Map instantiateOverflowBackingMap(DefaultConfigurableCacheFactory.CacheInfo info, XmlElement xmlOverflow, BackingMapManagerContext context, ClassLoader loader, Map mapListeners)
          Create a backing Map using the "overflow-scheme" element.
protected  OverflowMap instantiateOverflowMap(ObservableMap mapFront, Map mapBack, boolean fExpiry)
          Construct an OverflowMap using the specified parameters.
protected  Map instantiatePagedExternalBackingMap(DefaultConfigurableCacheFactory.CacheInfo info, XmlElement xmlPaged, BackingMapManagerContext context, ClassLoader loader)
          Create a backing Map using the "paged-external-scheme" element.
protected  ReadWriteBackingMap instantiateReadWriteBackingMap(BackingMapManagerContext context, ObservableMap mapInternal, Map mapMisses, CacheLoader loader)
          Construct a ReadWriteBackingMap using the specified parameters.
protected  ReadWriteBackingMap instantiateReadWriteBackingMap(BackingMapManagerContext context, ObservableMap mapInternal, Map mapMisses, CacheStore store, boolean fReadOnly, int cWriteBehindSeconds, double dflRefreshAheadFactor)
          Construct a ReadWriteBackingMap using the specified parameters.
protected  Map instantiateReadWriteBackingMap(DefaultConfigurableCacheFactory.CacheInfo info, XmlElement xmlRWBM, BackingMapManagerContext context, Map mapListeners)
          Create a ReadWriteBackingMap using the "read-write-backing-map-scheme" element.
protected  SerializationCache instantiateSerializationCache(BinaryStore store, int cMax, boolean fBinaryMap)
          Construct an SerializationCache using the specified parameters.
protected  SerializationCache instantiateSerializationCache(BinaryStore store, int cMax, ClassLoader loader)
          Construct an SerializationCache using the specified parameters.
protected  SerializationMap instantiateSerializationMap(BinaryStore store, boolean fBinaryMap)
          Construct an SerializationMap using the specified parameters.
protected  Map instantiateSerializationMap(BinaryStore store, boolean fBinaryMap, ClassLoader loader, int cHighUnits, int cExpiryMillis, String sSubclass, XmlElement xmlInitParams)
          Instantiate a SerializationMap, SerializationCache, SimpleSerializationMap, or any sub-class thereof.
protected  SerializationMap instantiateSerializationMap(BinaryStore store, ClassLoader loader)
          Construct an SerializationMap using the specified parameters.
protected  SerializationPagedCache instantiateSerializationPagedCache(BinaryStoreManager storeMgr, int cPages, int cPageSecs, boolean fBinaryMap, boolean fPassive)
          Construct an SerializationPagedCache using the specified parameters.
protected  SerializationPagedCache instantiateSerializationPagedCache(BinaryStoreManager storeMgr, int cPages, int cPageSecs, ClassLoader loader)
          Construct an SerializationPagedCache using the specified parameters.
protected  SimpleOverflowMap instantiateSimpleOverflowMap(ObservableMap mapFront, Map mapBack, Map mapMisses)
          Construct a SimpleOverflowMap using the specified parameters.
protected  Object instantiateSubclass(String sClass, Class clzSuper, ClassLoader loader, Object[] aoParam, XmlElement xmlParams)
          Construct an instance of the specified class using the specified parameters.
protected  VersionedBackingMap instantiateVersionedBackingMap(BackingMapManagerContext context, ObservableMap mapInternal, Map mapMisses, CacheLoader loader, NamedCache mapVersionTransient, NamedCache mapVersionPersist, boolean fManageTransient)
          Construct a VersionedBackingMap using the specified parameters.
protected  VersionedBackingMap instantiateVersionedBackingMap(BackingMapManagerContext context, ObservableMap mapInternal, Map mapMisses, CacheStore store, boolean fReadOnly, int cWriteBehindSeconds, double dflRefreshAheadFactor, NamedCache mapVersionTransient, NamedCache mapVersionPersist, boolean fManageTransient)
          Construct a VersionedBackingMap using the specified parameters.
protected  Map instantiateVersionedBackingMap(DefaultConfigurableCacheFactory.CacheInfo info, XmlElement xmlVBM, BackingMapManagerContext context, Map mapListeners)
          Create a VersionedBackingMap using the "versioned-backing-map-scheme" element.
protected  VersionedNearCache instantiateVersionedNearCache(Map mapLocal, NamedCache mapDist, NamedCache mapVersion)
          Construct an VersionedNearCache using the specified parameters.
static boolean isPutAllOptimized(Map map)
          Determines whether or not the specified Map is optimized for a putAll() operation versus a regular put() operation.
static XmlDocument loadConfig(String sName)
          Load the configuration from a file or resource.
static XmlDocument loadConfig(String sName, ClassLoader loader)
          Load the configuration from a file or resource.
static XmlDocument loadConfigAsResource(String sResource, ClassLoader loader)
          Load the configuration as a resource.
static XmlDocument loadConfigFromFile(File file)
          Load the configuration from a file or directory.
protected  String popCacheContext()
          Pop cache context from a thread-local storage.
protected  void pushCacheContext(String sContext)
          Push cache context into a thread-local storage.
protected  void register(CacheService service, String sCacheName, String sContext, Map map)
          Register the specified cache with the cluster registry.
protected  void register(NamedCache cache, String sContext)
          Register the specified NamedCache with the cluster registry.
protected  void release(BinaryStore store)
          Release all resources assosiated with the specified binary store.
protected  void release(CacheLoader loader)
          Release all resources assosiated with the specified loader.
 void release(Map map, Map mapListeners)
          Release all resources assosiated with the specified backing map.
 XmlElement resolveScheme(DefaultConfigurableCacheFactory.CacheInfo info)
          In the configuration XML find a "scheme" element associated with a given cache and resolve it (recursively) using the "scheme-ref" elements.
protected  XmlElement resolveScheme(XmlElement xmlScheme, DefaultConfigurableCacheFactory.CacheInfo info, boolean fChild, boolean fRequired)
          Resolve the specified "XYZ-scheme" by retrieving the base element refered to by the "scheme-ref" element, resolving it recursively, and combining it with the specified overrides and cache specific attributes.
 void setConfig(XmlElement xmlConfig)
          Specify the factory configuration XML.
 int translateSchemeType(String sScheme)
          Translate the scheme name into the scheme type.
protected  void unregister(CacheService service, String sCacheName)
          Unregister all the managed objects theat belong to the specified cache from the cluster registry.
protected  void unregister(String sCacheName, String sContext)
          Unregister the caches for a given cache name and context from the cluster registry.
protected  void verifyMapListener(DefaultConfigurableCacheFactory.CacheInfo info, Map map, XmlElement xmlScheme, BackingMapManagerContext context, ClassLoader loader, Map mapListeners)
          Check whether or not a MapListener has to be instantiated and added to a Map according to a scheme definition.
 

Field Detail

FILE_CFG_CACHE

public static final String FILE_CFG_CACHE
The default configuration file name.

See Also:
Constant Field Values

CACHE_NAME

public static final String CACHE_NAME
The name of the replaceable parameter representing the cache name.

See Also:
Constant Field Values

CLASS_LOADER

public static final String CLASS_LOADER
The name of the replaceable parameter representing the class loader.

See Also:
Constant Field Values

MGR_CONTEXT

public static final 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 String SCHEME_REF
The name of the replaceable parameter representing the scheme reference.

See Also:
Constant Field Values

SCHEME_UNKNOWN

public static final int SCHEME_UNKNOWN
The unknwown 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

m_mapByName

protected ConcurrentMap m_mapByName
Map keyed by a cache name with a corresponding value being a map keyed by a class loader with a corresponding value being a NamedCache reference.

Constructor Detail

DefaultConfigurableCacheFactory

public DefaultConfigurableCacheFactory()
Construct a default DefaultConfigurableCacheFactory using the default configuration file name.


DefaultConfigurableCacheFactory

public DefaultConfigurableCacheFactory(String sPath)
Construct a DefaultConfigurableCacheFactory using the specified path to a "cache-config.dtd" compliant configuration file or resource.

Parameters:
sPath - the configuration resource name or file path

DefaultConfigurableCacheFactory

public DefaultConfigurableCacheFactory(String sPath,
                                       ClassLoader loader)
Construct a DefaultConfigurableCacheFactory using the specified path to a "cache-config.dtd" compliant configuration file or resource.

Parameters:
sPath - the configuration resource name or file path
loader - (optional) ClassLoader that should be used to load the configration resource

DefaultConfigurableCacheFactory

public DefaultConfigurableCacheFactory(XmlElement xmlConfig)
Construct a DefaultConfigurableCacheFactory using the specified configuration XML.

Parameters:
xmlConfig - the configuration XmlElement
Method Detail

getConfig

public XmlElement getConfig()
Obtain the factory configuration XML.

Specified by:
getConfig in interface ConfigurableCacheFactory
Specified by:
getConfig in interface XmlConfigurable
Returns:
the configuration XML

setConfig

public void setConfig(XmlElement xmlConfig)
Specify the factory configuration XML.

Specified by:
setConfig in interface ConfigurableCacheFactory
Specified by:
setConfig in interface XmlConfigurable
Parameters:
xmlConfig - the configuration XML

ensureCache

public NamedCache ensureCache(String sCacheName,
                              ClassLoader loader)
Ensure a cache for the given name using the corresponding XML configuration.

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 according to the configuration XML

ensureService

public Service ensureService(String sServiceName)
Ensure a service for the given name using the corresponding XML configuration.

Specified by:
ensureService in interface ConfigurableCacheFactory
Parameters:
sServiceName - the service name
Returns:
a Service created according to the configuration XML

loadConfig

public static XmlDocument loadConfig(String sName)
Load the configuration from a file or resource.

Parameters:
sName - the name of file or resource.
Returns:
the configuration XML

loadConfig

public static XmlDocument loadConfig(String sName,
                                     ClassLoader loader)
Load the configuration from a file or resource.

Parameters:
sName - the name of file or resource.
loader - (optional) ClassLoader that should be used to load the configration resource
Returns:
the configuration XML

loadConfigAsResource

public static XmlDocument loadConfigAsResource(String sResource,
                                               ClassLoader loader)
Load the configuration as a resource.

Parameters:
sResource - the resource name
loader - (optional) ClassLoader that should be used to load the configration resource
Returns:
the configuration XML

loadConfigFromFile

public static XmlDocument loadConfigFromFile(File file)
Load the configuration from a file or directory.

Parameters:
file - file or directory to load the configuration from
Returns:
the configuration XML

findSchemeMapping

public DefaultConfigurableCacheFactory.CacheInfo findSchemeMapping(String sCacheName)
In the configuration XML find a "cache-mapping" element associated with a given cache name.

Parameters:
sCacheName - the value of the "cache-name" element to look for
Returns:
a CacheInfo object associated with a given cache name

resolveScheme

public XmlElement resolveScheme(DefaultConfigurableCacheFactory.CacheInfo info)
In the configuration XML find a "scheme" element associated with a given cache and resolve it (recursively) using the "scheme-ref" elements. The returned XML is always a clone of the actual configuration and could be safely modified.

Parameters:
info - the cache info
Returns:
a resolved "scheme" element associated with a given cache

findScheme

protected XmlElement findScheme(String sSchemeName)
In the configuration XML find a "scheme" element associated with a given cache name.

Parameters:
sSchemeName - the value of the "cache-name" element to look for
Returns:
a "scheme" element associated with a given cache name

findServiceScheme

protected XmlElement findServiceScheme(String sServiceName)
In the configuration XML find a "scheme" element associated with a given service name.

Parameters:
sServiceName - the value of the "service-name" element to look for
Returns:
a "scheme" element associated with a given service name

resolveScheme

protected XmlElement resolveScheme(XmlElement xmlScheme,
                                   DefaultConfigurableCacheFactory.CacheInfo info,
                                   boolean fChild,
                                   boolean fRequired)
Resolve the specified "XYZ-scheme" by retrieving the base element refered to by the "scheme-ref" element, resolving it recursively, and combining it with the specified overrides and cache specific attributes.

Parameters:
xmlScheme - a scheme element to resolve
info - the cache info (optional)
fChild - if true, the actual cache scheme is the only "xyz-scheme" child of the specified xmlScheme element; otherwise it's the xmlScheme element itself
fRequired - if true, the child scheme must be present; false otherwise
Returns:
a "scheme" element associated with a given cache name; null if the child is missing and is not required

ensureCache

protected NamedCache ensureCache(DefaultConfigurableCacheFactory.CacheInfo info,
                                 XmlElement xmlScheme,
                                 ClassLoader loader)
Obtain the NamedCache reference for the cache service defined by the specified scheme.

Parameters:
info - the cache info
xmlScheme - the scheme element for the cache
loader - (optional) ClassLoader that should be used to deserialize objects in the cache
Returns:
NamedCache instance

ensureService

public Service ensureService(XmlElement xmlScheme)
Ensure the service for the specified scheme.

Parameters:
xmlScheme - the scheme
Returns:
running Service corresponding to the scheme

configureCache

protected NamedCache configureCache(DefaultConfigurableCacheFactory.CacheInfo info,
                                    XmlElement xmlScheme,
                                    ClassLoader loader)
Ensures a cache for given scheme.

Parameters:
info - the cache info
xmlScheme - the corresponding scheme
loader - ClassLoader that should be used to deserialize objects in the cache
Returns:
a named cache created according to the description in the configuration

instantiateNearCache

protected NearCache instantiateNearCache(Map mapFront,
                                         NamedCache mapBack,
                                         int nStrategy)
Construct an NearCache using the specified parameters.

This method exposes a corresponding NearCache constructor and is provided for the express purpose of allowing its override.


instantiateVersionedNearCache

protected VersionedNearCache instantiateVersionedNearCache(Map mapLocal,
                                                           NamedCache mapDist,
                                                           NamedCache mapVersion)
Construct an VersionedNearCache using the specified parameters.

This method exposes a corresponding VersionedNearCache constructor and is provided for the express purpose of allowing its override.


configureBackingMap

public Map configureBackingMap(DefaultConfigurableCacheFactory.CacheInfo info,
                               XmlElement xmlScheme,
                               BackingMapManagerContext context,
                               ClassLoader loader,
                               Map mapListeners)
Configures a backing map according to the scheme.

Parameters:
info - the cache info
xmlScheme - the scheme element for cache configuration
context - BackingMapManagerContext to be used
loader - the ClassLoader to instantiate necessary classes
mapListeners - map of registered map listeners keyed by the corresponding map identities
Returns:
a backing map configured according to the scheme

verifyMapListener

protected void verifyMapListener(DefaultConfigurableCacheFactory.CacheInfo info,
                                 Map map,
                                 XmlElement xmlScheme,
                                 BackingMapManagerContext context,
                                 ClassLoader loader,
                                 Map mapListeners)
Check whether or not a MapListener has to be instantiated and added to a Map according to a scheme definition.

Parameters:
info - the cache info
map - an ObservableMap to add a listener to
xmlScheme - the corresponding scheme
context - BackingMapManagerContext to be used
loader - ClassLoader that should be used to instantiate a MapListener object
mapListeners - map of registered map listeners keyed by the corresponding map identities
Throws:
IllegalArgumentException - if the listener is required, but the map does not implement ObservableMap interface or if the listener cannot be instanitated

instantiateReadWriteBackingMap

protected Map instantiateReadWriteBackingMap(DefaultConfigurableCacheFactory.CacheInfo info,
                                             XmlElement xmlRWBM,
                                             BackingMapManagerContext context,
                                             Map mapListeners)
Create a ReadWriteBackingMap using the "read-write-backing-map-scheme" element.

Parameters:
info - the cache info
xmlRWBM - "read-write-backing-map-scheme" element.
context - BackingMapManagerContext to be used
mapListeners - map of registered map listeners keyed by the corresponding map identities
Returns:
a newly instantiated Map

instantiateReadWriteBackingMap

protected ReadWriteBackingMap instantiateReadWriteBackingMap(BackingMapManagerContext context,
                                                             ObservableMap mapInternal,
                                                             Map mapMisses,
                                                             CacheStore store,
                                                             boolean fReadOnly,
                                                             int cWriteBehindSeconds,
                                                             double dflRefreshAheadFactor)
Construct a ReadWriteBackingMap using the specified parameters.

This method exposes a corresponding ReadWriteBackingMap constructor and is provided for the express purpose of allowing its override.


instantiateReadWriteBackingMap

protected ReadWriteBackingMap instantiateReadWriteBackingMap(BackingMapManagerContext context,
                                                             ObservableMap mapInternal,
                                                             Map mapMisses,
                                                             CacheLoader loader)
Construct a ReadWriteBackingMap using the specified parameters.

This method exposes a corresponding ReadWriteBackingMap constructor and is provided for the express purpose of allowing its override.


instantiateVersionedBackingMap

protected Map instantiateVersionedBackingMap(DefaultConfigurableCacheFactory.CacheInfo info,
                                             XmlElement xmlVBM,
                                             BackingMapManagerContext context,
                                             Map mapListeners)
Create a VersionedBackingMap using the "versioned-backing-map-scheme" element.

Parameters:
info - the cache info
xmlVBM - "versioned-backing-map-scheme" element.
context - BackingMapManagerContext to be used
mapListeners - map of registered map listeners keyed by the corresponding map identities
Returns:
a newly instantiated Map

instantiateVersionedBackingMap

protected VersionedBackingMap instantiateVersionedBackingMap(BackingMapManagerContext context,
                                                             ObservableMap mapInternal,
                                                             Map mapMisses,
                                                             CacheStore store,
                                                             boolean fReadOnly,
                                                             int cWriteBehindSeconds,
                                                             double dflRefreshAheadFactor,
                                                             NamedCache mapVersionTransient,
                                                             NamedCache mapVersionPersist,
                                                             boolean fManageTransient)
Construct a VersionedBackingMap using the specified parameters.

This method exposes a corresponding VersionedBackingMap constructor and is provided for the express purpose of allowing its override.


instantiateVersionedBackingMap

protected VersionedBackingMap instantiateVersionedBackingMap(BackingMapManagerContext context,
                                                             ObservableMap mapInternal,
                                                             Map mapMisses,
                                                             CacheLoader loader,
                                                             NamedCache mapVersionTransient,
                                                             NamedCache mapVersionPersist,
                                                             boolean fManageTransient)
Construct a VersionedBackingMap using the specified parameters.

This method exposes a corresponding VersionedBackingMap constructor and is provided for the express purpose of allowing its override.


instantiateLocalCache

protected Map instantiateLocalCache(DefaultConfigurableCacheFactory.CacheInfo info,
                                    XmlElement xmlLocal,
                                    ClassLoader loader)
Create a backing Map using the "local-scheme" element.

Parameters:
info - the cache info
xmlLocal - "local-scheme" element.
loader - the ClassLoader to instantiate necessary classes
Returns:
a newly instantiated Map

instantiateLocalCache

protected LocalCache instantiateLocalCache(int cUnits,
                                           int cExpiryMillis)
Construct a LocalCache using the specified parameters.

This method exposes a corresponding LocalCache constructor and is provided for the express purpose of allowing its override.


instantiateOverflowBackingMap

protected Map instantiateOverflowBackingMap(DefaultConfigurableCacheFactory.CacheInfo info,
                                            XmlElement xmlOverflow,
                                            BackingMapManagerContext context,
                                            ClassLoader loader,
                                            Map mapListeners)
Create a backing Map using the "overflow-scheme" element.

Parameters:
info - the cache info
xmlOverflow - "overflow-scheme" element.
context - BackingMapManagerContext to be used
loader - the ClassLoader to instantiate necessary classes
mapListeners - map of registered map listeners keyed by the corresponding map identities
Returns:
a newly instantiated Map

instantiateOverflowMap

protected OverflowMap instantiateOverflowMap(ObservableMap mapFront,
                                             Map mapBack,
                                             boolean fExpiry)
Construct an OverflowMap using the specified parameters.

This method exposes a corresponding OverflowMap constructor and is provided for the express purpose of allowing its override.


instantiateSimpleOverflowMap

protected SimpleOverflowMap instantiateSimpleOverflowMap(ObservableMap mapFront,
                                                         Map mapBack,
                                                         Map mapMisses)
Construct a SimpleOverflowMap using the specified parameters.

This method exposes a corresponding SimpleOverflowMap constructor and is provided for the express purpose of allowing its override.


instantiateDiskBackingMap

protected Map instantiateDiskBackingMap(DefaultConfigurableCacheFactory.CacheInfo info,
                                        XmlElement xmlDisk,
                                        BackingMapManagerContext context,
                                        ClassLoader loader)
Deprecated. As of Coherence 3.0, replaced by instantiateExternalBackingMap(com.tangosol.net.DefaultConfigurableCacheFactory.CacheInfo, com.tangosol.run.xml.XmlElement, com.tangosol.net.BackingMapManagerContext, java.lang.ClassLoader) and instantiatePagedExternalBackingMap(com.tangosol.net.DefaultConfigurableCacheFactory.CacheInfo, com.tangosol.run.xml.XmlElement, com.tangosol.net.BackingMapManagerContext, java.lang.ClassLoader)

Create a backing Map using the "disk-scheme" element.

Parameters:
info - the cache info
xmlDisk - "disk-scheme" element.
context - BackingMapManagerContext to be used
loader - the ClassLoader to instantiate necessary classes
Returns:
a newly instantiated Map

instantiateSerializationMap

protected Map instantiateSerializationMap(BinaryStore store,
                                          boolean fBinaryMap,
                                          ClassLoader loader,
                                          int cHighUnits,
                                          int cExpiryMillis,
                                          String sSubclass,
                                          XmlElement xmlInitParams)
Instantiate a SerializationMap, SerializationCache, SimpleSerializationMap, or any sub-class thereof.

Parameters:
store - a BinaryStore to use to write serialized data to
fBinaryMap - true if the only data written to the Map will already be in Binary form
loader - the ClassLoader to use (if not a Binary map)
cHighUnits - the max size in units for the serialization cache
cExpiryMillis - the expiry time in milliseconds for the cache
sSubclass - the sub-class name (or "")
xmlInitParams - the init params for the sub-class
Returns:
a SerializationMap, SerializationCache, SimpleSerializationMap, or a subclass thereof

instantiateExternalBackingMap

protected Map instantiateExternalBackingMap(DefaultConfigurableCacheFactory.CacheInfo info,
                                            XmlElement xmlExternal,
                                            BackingMapManagerContext context,
                                            ClassLoader loader)
Create a backing Map using the "external-scheme" element.

Parameters:
info - the cache info
xmlExternal - "external-scheme" element.
context - BackingMapManagerContext to be used
loader - the ClassLoader to instantiate necessary classes
Returns:
a newly instantiated Map

instantiatePagedExternalBackingMap

protected Map instantiatePagedExternalBackingMap(DefaultConfigurableCacheFactory.CacheInfo info,
                                                 XmlElement xmlPaged,
                                                 BackingMapManagerContext context,
                                                 ClassLoader loader)
Create a backing Map using the "paged-external-scheme" element.

Parameters:
info - the cache info
xmlPaged - "paged-external-scheme" element.
context - BackingMapManagerContext to be used
loader - the ClassLoader to instantiate necessary classes
Returns:
a newly instantiated Map

instantiateBinaryStoreManager

protected BinaryStoreManager instantiateBinaryStoreManager(XmlElement xmlConfig,
                                                           ClassLoader loader,
                                                           boolean fPaged)
Create a BinaryStoreManager using the specified XML configuration. The given XML configuration must contain a valid child BinaryStoreManager element:

Parameters:
xmlConfig - the XmlElement that contains the configuration info for the BinaryStoreManager that will be instantiated
loader - the ClassLoader to instantiate necessary classes
fPaged - flag indicating whether or not the returned BinaryStoreManager will be used by a SerializationPagedCache
Returns:
a newly instantiated BinaryStoreManager created using the given XML configuration

instantiateAsyncBinaryStore

protected AsyncBinaryStore instantiateAsyncBinaryStore(BinaryStore store,
                                                       int cbMaxAsync)
Construct an AsyncBinaryStore using the specified parameters.

Parameters:
store - the BinaryStore to make asynchronous
cbMaxAsync - the maximum amount of "async writes" data that will be queued
Returns:
a new AsyncBinaryStore wrapping the passed BinaryStore

instantiateAsyncBinaryStoreManager

protected AsyncBinaryStoreManager instantiateAsyncBinaryStoreManager(BinaryStoreManager storeMgr,
                                                                     int cbMaxAsync)
Construct an AsyncBinaryStoreManager using the specified parameters.

Parameters:
storeMgr - the BinaryStoreManager to make asynchronous
cbMaxAsync - the maximum amount of "async writes" data that will be queued
Returns:
a new AsyncBinaryStoreManager wrapping the passed BinaryStoreManager

instantiateSerializationPagedCache

protected SerializationPagedCache instantiateSerializationPagedCache(BinaryStoreManager storeMgr,
                                                                     int cPages,
                                                                     int cPageSecs,
                                                                     ClassLoader loader)
Construct an SerializationPagedCache using the specified parameters.

This method exposes a corresponding SerializationPagedCache constructor and is provided for the express purpose of allowing its override.


instantiateSerializationPagedCache

protected SerializationPagedCache instantiateSerializationPagedCache(BinaryStoreManager storeMgr,
                                                                     int cPages,
                                                                     int cPageSecs,
                                                                     boolean fBinaryMap,
                                                                     boolean fPassive)
Construct an SerializationPagedCache using the specified parameters.

This method exposes a corresponding SerializationPagedCache constructor and is provided for the express purpose of allowing its override.


instantiateSerializationCache

protected SerializationCache instantiateSerializationCache(BinaryStore store,
                                                           int cMax,
                                                           ClassLoader loader)
Construct an SerializationCache using the specified parameters.

This method exposes a corresponding SerializationCache constructor and is provided for the express purpose of allowing its override.


instantiateSerializationCache

protected SerializationCache instantiateSerializationCache(BinaryStore store,
                                                           int cMax,
                                                           boolean fBinaryMap)
Construct an SerializationCache using the specified parameters.

This method exposes a corresponding SerializationCache constructor and is provided for the express purpose of allowing its override.


instantiateSerializationMap

protected SerializationMap instantiateSerializationMap(BinaryStore store,
                                                       ClassLoader loader)
Construct an SerializationMap using the specified parameters.

This method exposes a corresponding SerializationMap constructor and is provided for the express purpose of allowing its override.


instantiateSerializationMap

protected SerializationMap instantiateSerializationMap(BinaryStore store,
                                                       boolean fBinaryMap)
Construct an SerializationMap using the specified parameters.

This method exposes a corresponding SerializationMap constructor and is provided for the express purpose of allowing its override.


instantiateBundlingNamedCache

protected BundlingNamedCache instantiateBundlingNamedCache(NamedCache cache,
                                                           XmlElement xmlBundling)
Create a BundlingNamedCache using the "operation-bundling" element.

Parameters:
cache - the wrapped cache
xmlBundling - the "operation-bundling" element
Returns:
a newly instantiated BundlingNamedCache

initializeBundler

protected void initializeBundler(AbstractBundler bundler,
                                 XmlElement xmlBundle)
Initialize the specified bundler using the "bundle-config" element.

Parameters:
bundler - the bundler
xmlBundle - a "bundle-config" element

instantiateMap

protected Map instantiateMap(DefaultConfigurableCacheFactory.CacheInfo info,
                             XmlElement xmlClass,
                             BackingMapManagerContext context,
                             ClassLoader loader)
Create a backing Map using the "class-scheme" element. This method is a thin wrapper around instantiateAny.

Parameters:
info - the cache info
xmlClass - "class-scheme" element
context - BackingMapManagerContext to be used
loader - the ClassLoader to instantiate necessary classes
Returns:
a newly instantiated Map

instantiateCacheStore

protected CacheLoader instantiateCacheStore(DefaultConfigurableCacheFactory.CacheInfo info,
                                            XmlElement xmlStore,
                                            BackingMapManagerContext context,
                                            ClassLoader loader)
Create a CacheLoader or CacheStore using the "cachestore-scheme" element.

Parameters:
info - the cache info
xmlStore - "cachestore-scheme" element for the store or loader
loader - the ClassLoader to instantiate necessary classes
Returns:
a newly instantiated CacheStore or CacheLoader

instantiateMapListener

protected MapListener instantiateMapListener(DefaultConfigurableCacheFactory.CacheInfo info,
                                             XmlElement xmlClass,
                                             BackingMapManagerContext context,
                                             ClassLoader loader)
Create a MapListener using the using the "class-scheme" element. If the value of any "param-value" element contains the literal "{cache-name}", replace it with the actual cache name.

Parameters:
info - the cache info
xmlClass - "class-scheme" element
context - BackingMapManagerContext to be used
loader - the ClassLoader to instantiate necessary classes

instantiateAny

protected Object instantiateAny(DefaultConfigurableCacheFactory.CacheInfo info,
                                XmlElement xmlClass,
                                BackingMapManagerContext context,
                                ClassLoader loader)
Create an Object using "class-scheme" element.

If the value of any "param-value" element contains the literal "{cache-name}", replace it with the actual cache name.
If the value of "param-value" element is "{class-loader}" and "param-type" element is "java.lang.ClassLoader" replace it with the current ClassLoader object.
If the value of "param-value" element is "{manager-context}" and "param-type" element is "com.tangosol.net.BackingMapManagerContext" replace it with the current BackingMapManagerContext object.
Finally, if the value of "param-type" is "{scheme-ref}" then the "param-value" should be a name of the scheme that will be used in place of the value.

Parameters:
info - the cache info
xmlClass - "class-scheme" element.
context - BackingMapManagerContext to be used
loader - the ClassLoader to instantiate necessary classes
Returns:
a newly instantiated Object

instantiateSubclass

protected Object instantiateSubclass(String sClass,
                                     Class clzSuper,
                                     ClassLoader loader,
                                     Object[] aoParam,
                                     XmlElement xmlParams)
Construct an instance of the specified class using the specified parameters.

Parameters:
sClass - the class name
clzSuper - the super class of the newly instantiated class
loader - the ClassLoader to instantiate necessary classes
aoParam - the constructor paramters
xmlParams - the "init-params" XmlElement (optional)
Returns:
a newly instantiated Object

release

public void release(Map map,
                    Map mapListeners)
Release all resources assosiated with the specified backing map.

Parameters:
map - the map being released
mapListeners - map of registered map listeners keyed by the corresponding map identities

release

protected void release(CacheLoader loader)
Release all resources assosiated with the specified loader.

Parameters:
loader - the cache loader being released

release

protected void release(BinaryStore store)
Release all resources assosiated with the specified binary store.

Parameters:
store - the binary store being released

translateSchemeType

public int translateSchemeType(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

isPutAllOptimized

public static boolean isPutAllOptimized(Map map)
Determines whether or not the specified Map is optimized for a putAll() operation versus a regular put() operation.

Parameters:
map - a Map instance to check
Returns:
true if putAll should be preferred over put if the return value is not needed; false otherwise

register

protected void register(NamedCache cache,
                        String sContext)
Register the specified NamedCache with the cluster registry.

Parameters:
cache - the NamedCache object to register
sContext - the cache context (tier)

register

protected void register(CacheService service,
                        String sCacheName,
                        String sContext,
                        Map map)
Register the specified cache with the cluster registry.

Parameters:
service - the CacheService that the cache belongs to
sCacheName - the cache name
sContext - the cache context (tier)
map - the cache object to register

unregister

protected void unregister(CacheService service,
                          String sCacheName)
Unregister all the managed objects theat belong to the specified cache from the cluster registry.

Parameters:
service - the CacheService that the cache belongs to
sCacheName - the cache name

unregister

protected void unregister(String sCacheName,
                          String sContext)
Unregister the caches for a given cache name and context from the cluster registry.

Parameters:
sCacheName - the cache name
sContext - the cache context (tier)

pushCacheContext

protected void pushCacheContext(String sContext)
Push cache context into a thread-local storage.

Parameters:
sContext - cache context (tag)

popCacheContext

protected String popCacheContext()
Pop cache context from a thread-local storage.

Returns:
the poped cache context

CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation