Oracle® Fusion Middleware C++ API Reference for Oracle Coherence
12c (12.2.1.3.0)

E80355-01

DefaultConfigurableCacheFactory Class Reference

#include <coherence/net/DefaultConfigurableCacheFactory.hpp>

Inherits Object, and ConfigurableCacheFactory.

List of all members.


Detailed Description

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::Handle factory =
       DefaultConfigurableCacheFactory::create(sPath);
   ...
   NamedCache::Handle cacheOne = factory->ensureCache("one");
   NamedCache::Handle cacheTwo = factory->ensureCache("two");
 
This approach allows an easy customization by extending the DefaultConfigurableCacheFactory and changing the instantiation line:
   ConfigurableCacheFactory::Handle factory =
       CustomConfigurableCacheFactory::create();
   ...
 

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

   NamedCache cacheOne = CacheFactory::getCache("one");
   NamedCache cacheTwo = CacheFactory::getCache("two");
 
which uses an instance of ConfigurableCacheFactory obtained by CacheFactory#getConfigurableCacheFactory().

See also:
CacheFactory::getCache(String::View)
Author:
mf 2008.04.08

Public Types

enum  SchemeType
 Scheme types.
typedef spec::Handle Handle
 DefaultConfigurableCacheFactory Handle definition.
typedef spec::View View
 DefaultConfigurableCacheFactory View definition.
typedef spec::Holder Holder
 DefaultConfigurableCacheFactory Holder definition.

Public Member Functions

virtual CacheInfo::View findSchemeMapping (String::View vsCacheName)
 In the configuration XML find a "cache-mapping" element associated with a given cache name.
virtual XmlElement::View resolveScheme (CacheInfo::View vInfo)
 In the configuration XML find a "scheme" element associated with a given cache and resolve it (recursively) using the "scheme-ref" elements.
virtual SchemeType translateSchemeType (String::View vsScheme)
 Translate the scheme name into the scheme type.
virtual Object::Handle instantiateAny (CacheInfo::View vInfo, XmlElement::View vXmlScheme)
 Create an Object using "class-scheme" element.
virtual
NamedCache::Handle 
ensureCache (String::View vsCacheName)
 Ensure a cache for the given name using the corresponding XML configuration.

Parameters:
vsCacheName the cache name
Returns:
a handle to a NamedCache created according to the configuration XML

virtual void destroyCache (NamedCache::Handle hCache)
 Releases and destroys the specified 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 resources will be released.

Parameters:
hCache the NamedCache object to be destroyed
See also:
releaseCache

virtual void releaseCache (NamedCache::Handle hCache)
 Release local resources associated with the specified instance of the cache.

Releasing a NamedCache reference makes it no longer usable, but does not affect the content of the cache. In other words, all other references to the cache will still be valid, and the cache data is not affected by releasing the reference.

The reference that is released using this method can no longer be used; any attempt to use the reference will result in an exception.

Parameters:
hCache the NamedCache object to be released
See also:
destroyCache

virtual Service::Handle ensureService (String::View vsServiceName)
 Ensure a service for the given name using the corresponding XML configuration.

Parameters:
vsServiceName the service name
Returns:
a handle to a service created according to the configuration XML

virtual void shutdown ()
 Shutdown all services related to this ConfigurableCacheFactory.
virtual XmlElement::View getConfig () const
 If this Object was previously configured using some XML configuration, the corresponding XmlElement is returned.

Returns:
a view of the XmlElement used to configure this Object

virtual void setConfig (XmlElement::View vXml)
 
virtual
OperationalContext::View 
ensureOperationalContext ()
 Return the OperationalContext for this cache factory.
virtual void setOperationalContext (OperationalContext::View vContext)
 Set the OperationalContext for this cache factory.

Static Public Member Functions

static
XmlDocument::Handle 
getDefaultCacheConfig ()
 The default XML configuration used when one isn't explicitly passed in the constructor for this class.

Protected Member Functions

 DefaultConfigurableCacheFactory (String::View vsFile=String::null_string)
 Create a new cache factory.
virtual
XmlElement::Handle 
resolveScheme (XmlElement::View vXmlScheme, CacheInfo::View vInfo, bool fChild, bool 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.
virtual
XmlElement::Handle 
findScheme (String::View vsSchemeName)
 In the configuration XML find a "scheme" element associated with a given cache name.
virtual
XmlElement::Handle 
findServiceScheme (String::View vsServiceName)
 In the configuration XML find a "scheme" element associated with a given service name.
virtual
NamedCache::Handle 
configureCache (CacheInfo::View vInfo, XmlElement::View vXmlScheme)
 Ensures a cache for given scheme.
virtual void releaseCache (NamedCache::Handle hCache, bool fDestroy)
 Release a cache managed by this factory, optionally destroying it.
virtual Service::Handle configureService (XmlElement::View vXmlScheme)
 Ensure the service for the specified scheme.
virtual CacheMap::Handle configureBackingMap (CacheInfo::View vInfo, XmlElement::View vXmlScheme)
 Configures a backing map according to the scheme.
virtual
BundlingNamedCache::Handle 
instantiateBundlingNamedCache (NamedCache::Handle hCache, XmlElement::View vXmlBundling)
 Instantiate a BundlingNamedCache based on the "operation-bundling" configuration.
virtual void initializeBundler (AbstractBundler::Handle hBundler, XmlElement::View vXmlBundle)
 Initialize the specified bundler using the "bundle-config" element.
virtual
NamedCache::Handle 
instantiateCustomCache (CacheInfo::View vInfo, XmlElement::View vXmlScheme)
 Instantiate a custom (class-name) based cache based on the supplied configuration and scheme.
virtual
NamedCache::Handle 
instantiateLocalCache (CacheInfo::View vInfo, XmlElement::View vXmlScheme)
 Instantiate a local cache based on the supplied configuration and scheme.
virtual
MapListener::Handle 
instantiateMapListener (CacheInfo::View vInfo, XmlElement::View vXmlClass)
 Create a MapListener using the using the "class-scheme" element.
virtual
NamedCache::Handle 
ensureRemoteCache (CacheInfo::View vInfo, XmlElement::View vXmlScheme)
 Instantiate a remote cache based on the supplied configuration and scheme.
virtual
NamedCache::Handle 
ensureNearCache (CacheInfo::View vInfo, XmlElement::View vXmlScheme)
 Instantiate a near cache based on the supplied configuration and scheme.
virtual Map::Handle instantiateMap (CacheInfo::View vInfo, XmlElement::View vXmlScheme)
 Create a backing Map using the "class-scheme" element.
virtual
CacheLoader::Handle 
instantiateCacheStore (CacheInfo::View vInfo, XmlElement::View vXmlStore)
 Create a CacheLoader or CacheStore using the "cachestore-scheme" element.
virtual int32_t convertInt (XmlValue::View vXmlValue) const
 Convert the value in the specified XmlValue to an int.
virtual int32_t convertInt (XmlValue::View vXmlValue, int32_t nDefault) const
 Convert the value in the specified XmlValue to an int.
virtual void reportConversionError (XmlValue::View vXmlValue, String::View vsType, String::View vsDefault, RuntimeException::View e) const
 Log a failed type conversion.
virtual void resolveSerializer (XmlElement::Handle hXmlConfig) const
 Resolve and inject service serializer elements based on defaults defined in the cache configuration.
virtual void verifyMapListener (CacheInfo::View vInfo, Map::Handle hMap, XmlElement::View vXmlScheme, Map::Handle hMapListeners)
 Check whether or not a MapListener has to be instantiated and added to a Map according to a scheme definition.
virtual Object::Handle ensureStoreCache ()
 Return the cache reference store for this cache factory.
virtual Object::Handle ensureStoreService ()
 Return the service reference store for this cache factory.

Protected Attributes

FinalView
< OperationalContext
f_vContext
 Operational Context for all Services associated with this factory.
FinalView< XmlElementf_vXmlConfig
 XmlElement that corresponds to used XML cache configuration.
FinalHandle< Objectf_hStoreCache
 Store that holds cache references by name and optionally, if configured, Subject.
FinalHandle< Objectf_hStoreService
 Store that holds service references by name and optionally, if configured, Subject.
FinalHandle
< ThreadGroup
f_hThreadGroup
 The parent ThreadGroup for all Services associated with this factory.

Classes

class  CacheInfo
 CacheInfo is a placeholder for cache attributes retrieved during parsing the corresponding cache mapping element. More...

Constructor & Destructor Documentation

DefaultConfigurableCacheFactory ( String::View  vsFile = String::null_string  )  [protected]

Create a new cache factory.

Parameters:
vsFile the name of the configuration file to load relative to the current working directory, or NULL for an unconfigured CacheFactory


Member Function Documentation

virtual CacheInfo::View findSchemeMapping ( String::View  vsCacheName  )  [virtual]

In the configuration XML find a "cache-mapping" element associated with a given cache name.

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

virtual XmlElement::View resolveScheme ( CacheInfo::View  vInfo  )  [virtual]

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:
vInfo the cache info
Returns:
a resolved "scheme" element associated with a given cache

virtual SchemeType translateSchemeType ( String::View  vsScheme  )  [virtual]

Translate the scheme name into the scheme type.

Valid scheme types are any of the SCHEME_* constants.

Parameters:
vsScheme the scheme name
Returns:
the scheme type

virtual Object::Handle instantiateAny ( CacheInfo::View  vInfo,
XmlElement::View  vXmlScheme 
) [virtual]

Create an Object using "class-scheme" element.

Parameters:
vInfo the cache info
vXmlScheme "class-scheme" element.
Returns:
a newly instantiated Object

virtual XmlElement::Handle resolveScheme ( XmlElement::View  vXmlScheme,
CacheInfo::View  vInfo,
bool  fChild,
bool  fRequired 
) [protected, virtual]

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:
vXmlScheme a scheme element to resolve
vInfo 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

virtual XmlElement::Handle findScheme ( String::View  vsSchemeName  )  [protected, virtual]

In the configuration XML find a "scheme" element associated with a given cache name.

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

virtual XmlElement::Handle findServiceScheme ( String::View  vsServiceName  )  [protected, virtual]

In the configuration XML find a "scheme" element associated with a given service name.

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

virtual NamedCache::Handle configureCache ( CacheInfo::View  vInfo,
XmlElement::View  vXmlScheme 
) [protected, virtual]

Ensures a cache for given scheme.

Parameters:
vInfo the cache info
vXmlScheme the corresponding scheme
Returns:
a named cache created according to the description in the configuration

virtual void releaseCache ( NamedCache::Handle  hCache,
bool  fDestroy 
) [protected, virtual]

Release a cache managed by this factory, optionally destroying it.

Parameters:
cache the cache to release
fDestroy true to destroy the cache as well

virtual Service::Handle configureService ( XmlElement::View  vXmlScheme  )  [protected, virtual]

Ensure the service for the specified scheme.

Parameters:
vXmlScheme the scheme
Returns:
running Service corresponding to the scheme

virtual CacheMap::Handle configureBackingMap ( CacheInfo::View  vInfo,
XmlElement::View  vXmlScheme 
) [protected, virtual]

Configures a backing map according to the scheme.

Parameters:
vInfo the cache info
vXmlScheme the scheme element for cache configuration
Returns:
a backing map configured according to the scheme

virtual BundlingNamedCache::Handle instantiateBundlingNamedCache ( NamedCache::Handle  hCache,
XmlElement::View  vXmlBundling 
) [protected, virtual]

Instantiate a BundlingNamedCache based on the "operation-bundling" configuration.

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

virtual void initializeBundler ( AbstractBundler::Handle  hBundler,
XmlElement::View  vXmlBundle 
) [protected, virtual]

Initialize the specified bundler using the "bundle-config" element.

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

virtual NamedCache::Handle instantiateCustomCache ( CacheInfo::View  vInfo,
XmlElement::View  vXmlScheme 
) [protected, virtual]

Instantiate a custom (class-name) based cache based on the supplied configuration and scheme.

Parameters:
vInfo the CacheInfo
vXmlScheme the cache scheme
Returns:
a new NamedCache instance.

virtual NamedCache::Handle instantiateLocalCache ( CacheInfo::View  vInfo,
XmlElement::View  vXmlScheme 
) [protected, virtual]

Instantiate a local cache based on the supplied configuration and scheme.

Parameters:
vInfo the CacheInfo
vXmlScheme the cache scheme
Returns:
a new NamedCache instance.

virtual MapListener::Handle instantiateMapListener ( CacheInfo::View  vInfo,
XmlElement::View  vXmlClass 
) [protected, virtual]

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:
vInfo the cache info
vXmlClass "class-scheme" element
Returns:
a newly instantiated MapListener
Since:
Coherence 12.1.2

virtual NamedCache::Handle ensureRemoteCache ( CacheInfo::View  vInfo,
XmlElement::View  vXmlScheme 
) [protected, virtual]

Instantiate a remote cache based on the supplied configuration and scheme.

Parameters:
vInfo the CacheInfo
vXmlScheme the cache scheme
Returns:
a new NamedCache instance.

virtual NamedCache::Handle ensureNearCache ( CacheInfo::View  vInfo,
XmlElement::View  vXmlScheme 
) [protected, virtual]

Instantiate a near cache based on the supplied configuration and scheme.

Parameters:
vInfo the CacheInfo
vXmlScheme the cache scheme
Returns:
a new NamedCache instance.

virtual Map::Handle instantiateMap ( CacheInfo::View  vInfo,
XmlElement::View  vXmlScheme 
) [protected, virtual]

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

This method is a thin wrapper around instantiateAny.

Parameters:
vInfo the cache info
vXmlScheme "class-scheme" element.
Returns:
a newly instantiated Map

virtual CacheLoader::Handle instantiateCacheStore ( CacheInfo::View  vInfo,
XmlElement::View  vXmlStore 
) [protected, virtual]

Create a CacheLoader or CacheStore using the "cachestore-scheme" element.

Parameters:
vInfo the cache info
vXmlStore "cachestore-scheme" element for the store or loader
Returns:
a newly instantiated CacheStore or CacheLoader

virtual int32_t convertInt ( XmlValue::View  vXmlValue  )  const [protected, virtual]

Convert the value in the specified XmlValue to an int.

If the conversion fails, a warning will be logged.

Parameters:
vXmlValue the element expected to contain an int value
Returns:
the int value in the provided element, or 0 upon a conversion failure

virtual int32_t convertInt ( XmlValue::View  vXmlValue,
int32_t  nDefault 
) const [protected, virtual]

Convert the value in the specified XmlValue to an int.

If the conversion fails, a warning will be logged.

Parameters:
vXmlValue the element expected to contain an int value
nDefault the value that will be returned if the element does not contain a value that can be converted to int
Returns:
the int value in the provided element, or nDefault upon a conversion failure

virtual void reportConversionError ( XmlValue::View  vXmlValue,
String::View  vsType,
String::View  vsDefault,
RuntimeException::View  e 
) const [protected, virtual]

Log a failed type conversion.

Parameters:
vXmlValue element that contains the value that failed conversion
vsType type that conversion was attempted to
vsDefault default value that will be substituted
e root cause of failed type conversion

virtual void resolveSerializer ( XmlElement::Handle  hXmlConfig  )  const [protected, virtual]

Resolve and inject service serializer elements based on defaults defined in the cache configuration.

Parameters:
hXmlConfig the configuration element to examine and modify
Since:
Coherence 12.1.2

virtual void verifyMapListener ( CacheInfo::View  vInfo,
Map::Handle  hMap,
XmlElement::View  vXmlScheme,
Map::Handle  hMapListeners 
) [protected, virtual]

Check whether or not a MapListener has to be instantiated and added to a Map according to a scheme definition.

Parameters:
vInfo the cache info
hMap an ObservableMap to add a listener to
vXmlScheme the corresponding scheme
hMapListeners map of registered map listeners keyed by the corresponding map references
Exceptions:
IllegalArgumentException if the listener is required, but the map does not implement ObservableMap interface or if the listener cannot be instantiated
Since:
Coherence 12.1.2

virtual OperationalContext::View ensureOperationalContext (  )  [virtual]

Return the OperationalContext for this cache factory.

Returns:
the OperationalContext for this cache factory
Since:
Coherence 3.7

virtual void setOperationalContext ( OperationalContext::View  vContext  )  [virtual]

Set the OperationalContext for this cache factory.

Parameters:
vContext the OperationalContext for this cache factory
Exceptions:
IllegalStateException if an OperationalContext was already set
Since:
Coherence 3.7

static XmlDocument::Handle getDefaultCacheConfig (  )  [static]

The default XML configuration used when one isn't explicitly passed in the constructor for this class.

Returns:
the default XML configuration
Since:
Coherence 3.7

virtual Object::Handle ensureStoreCache (  )  [protected, virtual]

Return the cache reference store for this cache factory.

Returns:
the cache reference store for this cache factory
Since:
Coherence 3.7

virtual Object::Handle ensureStoreService (  )  [protected, virtual]

Return the service reference store for this cache factory.

Returns:
the service reference store for this cache factory
Since:
Coherence 3.7


The documentation for this class was generated from the following file:
Copyright © 2000, 2017, Oracle and/or its affiliates. All rights reserved.