#include <coherence/net/DefaultConfigurableCacheFactory.hpp>
Inherits Object, and ConfigurableCacheFactory.
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().
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.
| ||||
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.
| ||||
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.
| ||||
virtual Service::Handle | ensureService (String::View vsServiceName) | |||
Ensure a service for the given name using the corresponding XML configuration.
| ||||
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.
| ||||
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< XmlElement > | f_vXmlConfig | |||
XmlElement that corresponds to used XML cache configuration. | ||||
FinalHandle< Object > | f_hStoreCache | |||
Store that holds cache references by name and optionally, if configured, Subject. | ||||
FinalHandle< Object > | f_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... |
DefaultConfigurableCacheFactory | ( | String::View | vsFile = String::null_string |
) | [protected] |
Create a new cache factory.
vsFile | the name of the configuration file to load relative to the current working directory, or NULL for an unconfigured CacheFactory |
virtual CacheInfo::View findSchemeMapping | ( | String::View | vsCacheName | ) | [virtual] |
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.
vInfo | the cache info |
virtual SchemeType translateSchemeType | ( | String::View | vsScheme | ) | [virtual] |
Translate the scheme name into the scheme type.
Valid scheme types are any of the SCHEME_* constants.
vsScheme | the scheme name |
virtual Object::Handle instantiateAny | ( | CacheInfo::View | vInfo, | |
XmlElement::View | vXmlScheme | |||
) | [virtual] |
Create an Object using "class-scheme" element.
vInfo | the cache info | |
vXmlScheme | "class-scheme" element. |
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.
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 |
virtual XmlElement::Handle findScheme | ( | String::View | vsSchemeName | ) | [protected, virtual] |
virtual XmlElement::Handle findServiceScheme | ( | String::View | vsServiceName | ) | [protected, virtual] |
In the configuration XML find a "scheme" element associated with a given service name.
vsServiceName | the value of the "service-name" element to look for |
virtual NamedCache::Handle configureCache | ( | CacheInfo::View | vInfo, | |
XmlElement::View | vXmlScheme | |||
) | [protected, virtual] |
virtual void releaseCache | ( | NamedCache::Handle | hCache, | |
bool | fDestroy | |||
) | [protected, virtual] |
virtual Service::Handle configureService | ( | XmlElement::View | vXmlScheme | ) | [protected, virtual] |
Ensure the service for the specified scheme.
vXmlScheme | the scheme |
virtual CacheMap::Handle configureBackingMap | ( | CacheInfo::View | vInfo, | |
XmlElement::View | vXmlScheme | |||
) | [protected, virtual] |
virtual BundlingNamedCache::Handle instantiateBundlingNamedCache | ( | NamedCache::Handle | hCache, | |
XmlElement::View | vXmlBundling | |||
) | [protected, virtual] |
Instantiate a BundlingNamedCache based on the "operation-bundling" configuration.
hCache | the wrapped cache | |
vXmlBundling | the "operation-bundling" element |
virtual void initializeBundler | ( | AbstractBundler::Handle | hBundler, | |
XmlElement::View | vXmlBundle | |||
) | [protected, virtual] |
Initialize the specified bundler using the "bundle-config" element.
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.
virtual NamedCache::Handle instantiateLocalCache | ( | CacheInfo::View | vInfo, | |
XmlElement::View | vXmlScheme | |||
) | [protected, virtual] |
Instantiate a local cache based on the supplied configuration and scheme.
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.
vInfo | the cache info | |
vXmlClass | "class-scheme" element |
virtual NamedCache::Handle ensureRemoteCache | ( | CacheInfo::View | vInfo, | |
XmlElement::View | vXmlScheme | |||
) | [protected, virtual] |
Instantiate a remote cache based on the supplied configuration and scheme.
virtual NamedCache::Handle ensureNearCache | ( | CacheInfo::View | vInfo, | |
XmlElement::View | vXmlScheme | |||
) | [protected, virtual] |
Instantiate a near cache based on the supplied configuration and scheme.
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.
vInfo | the cache info | |
vXmlScheme | "class-scheme" element. |
virtual CacheLoader::Handle instantiateCacheStore | ( | CacheInfo::View | vInfo, | |
XmlElement::View | vXmlStore | |||
) | [protected, virtual] |
Create a CacheLoader or CacheStore using the "cachestore-scheme" element.
vInfo | the cache info | |
vXmlStore | "cachestore-scheme" element for the store or loader |
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.
vXmlValue | the element expected to contain an int value |
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.
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 |
virtual void reportConversionError | ( | XmlValue::View | vXmlValue, | |
String::View | vsType, | |||
String::View | vsDefault, | |||
RuntimeException::View | e | |||
) | const [protected, virtual] |
Log a failed type conversion.
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.
hXmlConfig | the configuration element to examine and modify |
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.
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 |
IllegalArgumentException | if the listener is required, but the map does not implement ObservableMap interface or if the listener cannot be instantiated |
virtual OperationalContext::View ensureOperationalContext | ( | ) | [virtual] |
Return the OperationalContext for this cache factory.
virtual void setOperationalContext | ( | OperationalContext::View | vContext | ) | [virtual] |
Set the OperationalContext for this cache factory.
vContext | the OperationalContext for this cache factory |
IllegalStateException | if an OperationalContext was already set |
static XmlDocument::Handle getDefaultCacheConfig | ( | ) | [static] |
The default XML configuration used when one isn't explicitly passed in the constructor for this class.
virtual Object::Handle ensureStoreCache | ( | ) | [protected, virtual] |
virtual Object::Handle ensureStoreService | ( | ) | [protected, virtual] |