org.apache.jcs.engine.control
Class CompositeCacheManager

java.lang.Object
  extended byorg.apache.jcs.engine.control.CompositeCacheManager
All Implemented Interfaces:
ICompositeCacheManager, IRemoteCacheConstants, IShutdownObservable, java.io.Serializable

public class CompositeCacheManager
extends java.lang.Object
implements IRemoteCacheConstants, java.io.Serializable, ICompositeCacheManager, IShutdownObservable

Manages a composite cache. This provides access to caches and is the primary way to shutdown the caching system as a whole.

See Also:
Serialized Form

Field Summary
protected  java.util.Hashtable auxAttrs
          ???
protected  java.util.Hashtable auxFacs
          Used to keep track of configured auxiliaries
protected  java.util.Hashtable caches
          Caches managed by this cache manager
protected  java.lang.String defaultAuxValues
          The default auxiliary caches to be used if not preconfigured
protected  ICompositeCacheAttributes defaultCacheAttr
          Default cache attributes for this cache manager
protected  IElementAttributes defaultElementAttr
          Default elemeent attributes for this cache manager
protected static CompositeCacheManager instance
          The Singleton Instance
protected  java.util.Properties props
          Properties with which this manager was configured
protected  java.util.Hashtable systemCaches
          Internal system caches for this cache manager
 
Fields inherited from interface org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheConstants
REMOTE_ALLOW_CLUSTER_GET, REMOTE_CACHE_SERVICE_NAME, REMOTE_CACHE_SERVICE_PORT, REMOTE_CACHE_SERVICE_VAL, REMOTE_LOCAL_CLUSTER_CONSISTENCY, TOMCAT_ON, TOMCAT_XML
 
Constructor Summary
CompositeCacheManager()
           
 
Method Summary
 void configure()
          Configure with default properties file
 void configure(java.util.Properties props)
          Configure from properties object.
 void configure(java.util.Properties props, boolean useSystemProperties)
          Configure from properties object, overriding with values from the system properteis if instructed.
 void configure(java.lang.String propFile)
          Configure from specific properties file.
protected static CompositeCacheManager createInstance()
          Simple factory method, must override in subclasses so getInstance creates / returns the correct object.
 void deregisterShutdownObserver(IShutdownObserver observer)
          Deregisters the observer with the observable.
 void freeCache(java.lang.String name)
           
 void freeCache(java.lang.String name, boolean fromRemote)
           
 CompositeCache getCache(ICompositeCacheAttributes cattr)
          Gets the cache attribute of the CacheHub object
 CompositeCache getCache(ICompositeCacheAttributes cattr, IElementAttributes attr)
          If the cache is created the CacheAttributes and the element Attributes will be ignored.
 CompositeCache getCache(java.lang.String cacheName)
          Gets the cache attribute of the CacheHub object
 CompositeCache getCache(java.lang.String cacheName, ICompositeCacheAttributes cattr)
          Gets the cache attribute of the CacheHub object
 CompositeCache getCache(java.lang.String cacheName, ICompositeCacheAttributes cattr, IElementAttributes attr)
          Gets the cache attribute of the CacheHub object
 java.lang.String[] getCacheNames()
          Returns a list of the current cache names.
 int getCacheType()
           
 ICompositeCacheAttributes getDefaultCacheAttributes()
          Gets the defaultCacheAttributes attribute of the CacheHub object
 ICompositeCacheAttributes getDefaultCattr()
           
 IElementAttributes getDefaultElementAttributes()
          Gets the defaultElementAttributes attribute of the CacheHub object
static CompositeCacheManager getInstance()
          Gets the CacheHub instance.
static CompositeCacheManager getInstance(java.lang.String propsFilename)
          Initializes the cache manager using the props file for the given name.
 ICacheStats[] getStatistics()
          This returns data gathered for all regions and all the auxiliaries they currently uses.
 java.lang.String getStats()
          Gets stats for debugging.
static CompositeCacheManager getUnconfiguredInstance()
          Get a CacheHub instance which is not configured.
protected  void incrementClients()
           
 void registerShutdownObserver(IShutdownObserver observer)
          Perhaps the composite cache itself should be the observable object.
 void release()
           
 void setDefaultCacheAttributes(ICompositeCacheAttributes icca)
          Sets the defaultCacheAttributes attribute of the CacheHub object
 void setDefaultElementAttributes(IElementAttributes iea)
          Sets the defaultElementAttributes attribute of the CacheHub object
 void shutDown()
          Calls freeCache on all regions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

caches

protected java.util.Hashtable caches
Caches managed by this cache manager


systemCaches

protected java.util.Hashtable systemCaches
Internal system caches for this cache manager


defaultCacheAttr

protected ICompositeCacheAttributes defaultCacheAttr
Default cache attributes for this cache manager


defaultElementAttr

protected IElementAttributes defaultElementAttr
Default elemeent attributes for this cache manager


auxFacs

protected java.util.Hashtable auxFacs
Used to keep track of configured auxiliaries


auxAttrs

protected java.util.Hashtable auxAttrs
???


props

protected java.util.Properties props
Properties with which this manager was configured


defaultAuxValues

protected java.lang.String defaultAuxValues
The default auxiliary caches to be used if not preconfigured


instance

protected static CompositeCacheManager instance
The Singleton Instance

Constructor Detail

CompositeCacheManager

public CompositeCacheManager()
Method Detail

getInstance

public static CompositeCacheManager getInstance()
Gets the CacheHub instance. For backward compatibility, if this creates the instance it will attempt to configure it with the default configuration. If you want to configure from your own source, use getUnconfiguredInstance()and then call configure()

Returns:

getInstance

public static CompositeCacheManager getInstance(java.lang.String propsFilename)
Initializes the cache manager using the props file for the given name.

Parameters:
propsFilename -
Returns:
CompositeCacheManager configured from the give propsFileName

getUnconfiguredInstance

public static CompositeCacheManager getUnconfiguredInstance()
Get a CacheHub instance which is not configured. If an instance already exists, it will be returned.

Returns:

createInstance

protected static CompositeCacheManager createInstance()
Simple factory method, must override in subclasses so getInstance creates / returns the correct object.

Returns:
CompositeCacheManager

configure

public void configure()
Configure with default properties file


configure

public void configure(java.lang.String propFile)
Configure from specific properties file.

Parameters:
propFile - Path within classpath to load configuration from

configure

public void configure(java.util.Properties props)
Configure from properties object.

This method will call confiure, instructing it to use ssytem properties as a default.

Parameters:
props -

configure

public void configure(java.util.Properties props,
                      boolean useSystemProperties)
Configure from properties object, overriding with values from the system properteis if instructed.

You can override a specif value by passing in a ssytem property:

For example, you could override this value in the cache.ccf file by starting up your program with the argument: -Djcs.auxiliary.LTCP.attributes.TcpListenerPort=1111

Parameters:
props -
useSystemProperties - -- if true, values starting with jcs will be put into the props file prior to configuring the cache.

getDefaultCacheAttributes

public ICompositeCacheAttributes getDefaultCacheAttributes()
Gets the defaultCacheAttributes attribute of the CacheHub object

Returns:
The defaultCacheAttributes value

setDefaultCacheAttributes

public void setDefaultCacheAttributes(ICompositeCacheAttributes icca)
Sets the defaultCacheAttributes attribute of the CacheHub object

Parameters:
icca - The new defaultCacheAttributes value

setDefaultElementAttributes

public void setDefaultElementAttributes(IElementAttributes iea)
Sets the defaultElementAttributes attribute of the CacheHub object

Parameters:
iea - The new defaultElementAttributes value

getDefaultElementAttributes

public IElementAttributes getDefaultElementAttributes()
Gets the defaultElementAttributes attribute of the CacheHub object

Returns:
The defaultElementAttributes value

getCache

public CompositeCache getCache(java.lang.String cacheName)
Gets the cache attribute of the CacheHub object

Specified by:
getCache in interface ICompositeCacheManager
Parameters:
cacheName -
Returns:
CompositeCache -- the cache region controller

getCache

public CompositeCache getCache(java.lang.String cacheName,
                               ICompositeCacheAttributes cattr)
Gets the cache attribute of the CacheHub object

Parameters:
cacheName -
cattr -
Returns:

getCache

public CompositeCache getCache(java.lang.String cacheName,
                               ICompositeCacheAttributes cattr,
                               IElementAttributes attr)
Gets the cache attribute of the CacheHub object

Parameters:
cacheName -
cattr -
attr -
Returns:

getCache

public CompositeCache getCache(ICompositeCacheAttributes cattr)
Gets the cache attribute of the CacheHub object

Parameters:
cattr -
Returns:

getCache

public CompositeCache getCache(ICompositeCacheAttributes cattr,
                               IElementAttributes attr)
If the cache is created the CacheAttributes and the element Attributes will be ignored. Currently there is no overiding once it is set up.

Overriding hte default elemental atributes will require cahnging the way the atributes are assigned to elements. Get cache creates a cache with defaults if none are specified. We might want to create separate method for creating/getting. . .

Parameters:
cattr -
attr -
Returns:

freeCache

public void freeCache(java.lang.String name)
Parameters:
name -

freeCache

public void freeCache(java.lang.String name,
                      boolean fromRemote)
Parameters:
name -
fromRemote -

shutDown

public void shutDown()
Calls freeCache on all regions


incrementClients

protected void incrementClients()

release

public void release()

getCacheNames

public java.lang.String[] getCacheNames()
Returns a list of the current cache names.

Returns:
String[]

getCacheType

public int getCacheType()
Returns:

getDefaultCattr

public ICompositeCacheAttributes getDefaultCattr()
Returns:
ICompositeCacheAttributes

getStats

public java.lang.String getStats()
Gets stats for debugging. This calls gets statistics and then puts all the results in a string. This returns data for all regions.

Returns:
String

getStatistics

public ICacheStats[] getStatistics()
This returns data gathered for all regions and all the auxiliaries they currently uses.

Returns:

registerShutdownObserver

public void registerShutdownObserver(IShutdownObserver observer)
Perhaps the composite cache itself should be the observable object. It doesn't make much of a difference. There are some problems with region by region shutdown. Some auxiliaries are global. They will need to track when every region has shutdown before doing things like closing the socket with a lateral.

Specified by:
registerShutdownObserver in interface IShutdownObservable
Parameters:
observer -

deregisterShutdownObserver

public void deregisterShutdownObserver(IShutdownObserver observer)
Description copied from interface: IShutdownObservable
Deregisters the observer with the observable.

Specified by:
deregisterShutdownObserver in interface IShutdownObservable
Parameters:
observer -


Copyright © 2002-2007 Apache Software Foundation. All Rights Reserved.