#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. | ||||
enum | ProductEdition | |||
Extend editions. | ||||
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 int32_t | getEdition () const | |||
Get the product edition.
| ||||
virtual void | setEdition (int32_t nEdition) | |||
Set the product edition.
| ||||
virtual Member::View | getLocalMember () const | |||
Get the local member.
| ||||
virtual void | setLocalMember (Member::View vMemberLocal) | |||
Set the local member.
| ||||
virtual Map::View | getFilterConfigMap () const | |||
Get the filter config map.
| ||||
virtual void | setFilterConfigMap (Map::View vMapFilterConfig) | |||
Set the filter config map.
| ||||
virtual void | shutdown () | |||
Shutdown all services related to this ConfigurableCacheFactory. | ||||
virtual IdentityAsserter::Handle | getIdentityAsserter () const | |||
Get the IdentityAsserter. | ||||
virtual void | setIdentityAsserter (IdentityAsserter::Handle hAsserter) | |||
Set the IdentityAsserter.
| ||||
virtual IdentityTransformer::Handle | getIdentityTransformer () const | |||
Get the IdentityTranformer. | ||||
virtual void | setIdentityTransformer (IdentityTransformer::Handle hTransformer) | |||
Set the IdentityTranformer.
| ||||
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) | |||
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 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 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. | ||||
Protected Attributes | ||||
MemberView< XmlElement > | m_vXmlConfig | |||
XmlElement that corresponds to used XML cache configuration. | ||||
MemberView< Map > | m_vMapFilterConfig | |||
Filter map config. | ||||
MemberView< Member > | m_vMemberLocal | |||
The local member. | ||||
FinalHandle< Object > | m_hStoreCache | |||
Store that holds cache references by name and optionally, if configured, Subject. | ||||
FinalHandle< Object > | m_hStoreService | |||
Store that holds service references by name and optionally, if configured, Subject. | ||||
int32_t | m_nEdition | |||
The configured edition. | ||||
FinalHandle < ThreadGroup > | m_hThreadGroup | |||
The parent ThreadGroup for all Services associated with this factory. | ||||
MemberHandle < IdentityAsserter > | m_hAsserter | |||
The IdentityAsserter available for Services. | ||||
MemberHandle < IdentityTransformer > | m_hTransformer | |||
The IdentityTransformer available for Services. | ||||
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 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 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 |