org.apache.jcs
Class JCS<K extends Serializable,V extends Serializable>

java.lang.Object
  extended by org.apache.jcs.access.CacheAccess<K,V>
      extended by org.apache.jcs.access.GroupCacheAccess<K,V>
          extended by org.apache.jcs.JCS<K,V>
All Implemented Interfaces:
ICacheAccess<K,V>, IGroupCacheAccess<K,V>

public class JCS<K extends Serializable,V extends Serializable>
extends GroupCacheAccess<K,V>

Simple class for using JCS. To use JCS in your application, you can use the static methods of this class to get access objects (instances of this class) for your cache regions. Ideally this class should be all you need to import to use JCS. One JCS should be created for each region you want to access. If you have several regions, then get instances for each. For best performance the getInstance call should be made in an initialization method.


Field Summary
 
Fields inherited from class org.apache.jcs.access.CacheAccess
cacheControl
 
Constructor Summary
protected JCS(CompositeCache<K,V> cacheControl)
          Protected constructor for use by the static factory methods.
 
Method Summary
protected static CompositeCacheManager getCacheManager()
          Gets an instance of CompositeCacheManager and stores it in the cacheMgr class field, if it is not already set.
static
<K extends Serializable,V extends Serializable>
JCS<K,V>
getInstance(String region)
          Get a JCS which accesses the provided region.
static
<K extends Serializable,V extends Serializable>
JCS<K,V>
getInstance(String region, ICompositeCacheAttributes icca)
          Get a JCS which accesses the provided region.
static void setConfigFilename(String configFilename)
          Set the filename that the cache manager will be initialized with.
static void setConfigProperties(Properties configProps)
          Set the properties that the cache manager will be initialized with.
 
Methods inherited from class org.apache.jcs.access.GroupCacheAccess
getFromGroup, getGroupAccess, getGroupAccess, getGroupKeys, getGroupNames, invalidateGroup, putInGroup, putInGroup, remove
 
Methods inherited from class org.apache.jcs.access.CacheAccess
clear, defineRegion, defineRegion, defineRegion, destroy, destroy, dispose, freeMemoryElements, get, getAccess, getAccess, getCacheAttributes, getCacheElement, getCacheElements, getDefaultElementAttributes, getElementAttributes, getElementAttributes, getMatching, getMatchingCacheElements, getStatistics, getStats, put, put, putSafe, remove, remove, resetElementAttributes, resetElementAttributes, setCacheAttributes, setDefaultElementAttributes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JCS

protected JCS(CompositeCache<K,V> cacheControl)
Protected constructor for use by the static factory methods.

Parameters:
cacheControl - Cache which the instance will provide access to
Method Detail

getInstance

public static <K extends Serializable,V extends Serializable> JCS<K,V> getInstance(String region)
                                                                      throws CacheException
Get a JCS which accesses the provided region.

Parameters:
region - Region that return JCS will provide access to
Returns:
A JCS which provides access to a given region.
Throws:
CacheException

getInstance

public static <K extends Serializable,V extends Serializable> JCS<K,V> getInstance(String region,
                                                                                   ICompositeCacheAttributes icca)
                                                                      throws CacheException
Get a JCS which accesses the provided region.

Parameters:
region - Region that return JCS will provide access to
icca - CacheAttributes for region
Returns:
A JCS which provides access to a given region.
Throws:
CacheException

getCacheManager

protected static CompositeCacheManager getCacheManager()
                                                throws CacheException
Gets an instance of CompositeCacheManager and stores it in the cacheMgr class field, if it is not already set. Unlike the implementation in CacheAccess, the cache manager is a CompositeCacheManager. NOTE: This can be moved up into GroupCacheAccess.

Throws:
CacheException - if the configuration cannot be loaded

setConfigFilename

public static void setConfigFilename(String configFilename)
Set the filename that the cache manager will be initialized with. Only matters before the instance is initialized.

Parameters:
configFilename -

setConfigProperties

public static void setConfigProperties(Properties configProps)
Set the properties that the cache manager will be initialized with. Only matters before the instance is initialized.

Parameters:
configProps -


Copyright © 2002-2013 The Apache Software Foundation. All Rights Reserved.