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.
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.

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 int32_t getEdition () const
 Get the product edition.

Returns:
the product edition

virtual void setEdition (int32_t nEdition)
 Set the product edition.

Parameters:
nEdition the product edition

virtual Member::View getLocalMember () const
 Get the local member.

Returns:
the local member

virtual void setLocalMember (Member::View vMemberLocal)
 Set the local member.

Parameters:
vMemberLocal the local member

virtual Map::View getFilterConfigMap () const
 Get the filter config map.

Returns:
the filter config map

virtual void setFilterConfigMap (Map::View vMapFilterConfig)
 Set the filter config map.

Parameters:
vMapFilterConfig the filter config map

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)
 

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< XmlElementm_vXmlConfig
 XmlElement that corresponds to used XML cache configuration.
MemberView< Mapm_vMapFilterConfig
 Filter map config.
MemberView< Memberm_vMemberLocal
 The local member.
FinalHandle< Mapm_hMapCache
 Map of cache names to NamedCache instances.
FinalHandle< Mapm_hMapService
 Map of service names to Service instances.
int32_t m_nEdition
 The configured edition.

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 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 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


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