org.pentaho.platform.engine.core.system
Class SimpleMapCacheManager

java.lang.Object
  extended by org.pentaho.platform.engine.core.system.SimpleMapCacheManager
All Implemented Interfaces:
ICacheManager, ILogoutListener

public class SimpleMapCacheManager
extends Object
implements ICacheManager

Author:
rmansoor

Field Summary
 
Fields inherited from interface org.pentaho.platform.api.engine.ICacheManager
GLOBAL, SESSION
 
Constructor Summary
SimpleMapCacheManager()
           
 
Method Summary
 boolean addCacheRegion(String region)
           
 boolean addCacheRegion(String region, Properties cacheProperties)
           
 boolean cacheEnabled()
          Returns the enablement state of the cache.
 boolean cacheEnabled(String region)
          Returns the enablement state of the cache.
 void cacheStop()
          Stops the cache by calling the cacheProvider stop method.
 void clearCache()
          Entirely clears the cache.
 void clearRegionCache(String region)
          Clears any data for the specified for a specific region(For example region could be session, global etc)
 Set getAllEntriesFromRegionCache(String region)
          Get a Set of Map.Entry objects from the cache within a specific region
 Set getAllKeysFromRegionCache(String region)
          Get a Set of Key objects from the cache within a specific region
 List getAllValuesFromRegionCache(String region)
          Get a list of values from the cache within a specific region
 Object getFromGlobalCache(Object key)
          Gets an object from the cache without translating the passed in key.
 Object getFromRegionCache(String region, Object key)
          Gets an object from the cache within a specific region
 Object getFromSessionCache(IPentahoSession session, String key)
          Gets an object from the user session specific cache.
static SimpleMapCacheManager getInstance()
           
 void killSessionCache(IPentahoSession session)
          Removes any session-based data for the specified IPentahoSession.
 void killSessionCaches()
          Removes all cached items that are session-based.
 void onLogout(IPentahoSession session)
           
 void putInGlobalCache(Object key, Object value)
          Puts an object directly into the cache without translating the passed in key.
 void putInRegionCache(String region, Object key, Object value)
          Puts an object directly into the cache of a specific region
 void putInSessionCache(IPentahoSession session, String key, Object value)
          Puts an object in the session-specific cache.
 void removeFromGlobalCache(Object key)
          Removes an object from the cache
 void removeFromRegionCache(String region, Object key)
          Removes an object from the cache within a specific region
 void removeFromSessionCache(IPentahoSession session, String key)
          Removes a data item from the user session specific cache
 void removeRegionCache(String region)
          Clears any data for the specified for a specific region(For example region could be session, global etc) and removed the region from the map
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleMapCacheManager

public SimpleMapCacheManager()
Method Detail

getInstance

public static SimpleMapCacheManager getInstance()

cacheStop

public void cacheStop()
Description copied from interface: ICacheManager
Stops the cache by calling the cacheProvider stop method. This method should be called either when the VM goes away, or when the web context goes away. This performs required cleanup in the underlying cache implementation. In some cases, failure to stop the cache will cause cached items saved to disk to be un-recoverable.

Specified by:
cacheStop in interface ICacheManager

cacheEnabled

public boolean cacheEnabled(String region)
Description copied from interface: ICacheManager
Returns the enablement state of the cache.

Specified by:
cacheEnabled in interface ICacheManager
Returns:
true if the cache has been initialized and is ready for use.

onLogout

public void onLogout(IPentahoSession session)
Specified by:
onLogout in interface ICacheManager
Specified by:
onLogout in interface ILogoutListener
Parameters:
session - Performs any logout actions based on this session.

addCacheRegion

public boolean addCacheRegion(String region,
                              Properties cacheProperties)
Specified by:
addCacheRegion in interface ICacheManager

addCacheRegion

public boolean addCacheRegion(String region)
Specified by:
addCacheRegion in interface ICacheManager

clearRegionCache

public void clearRegionCache(String region)
Description copied from interface: ICacheManager
Clears any data for the specified for a specific region(For example region could be session, global etc)

Specified by:
clearRegionCache in interface ICacheManager
Parameters:
region - The region whose objects needs to be removed from the cache.

removeRegionCache

public void removeRegionCache(String region)
Description copied from interface: ICacheManager
Clears any data for the specified for a specific region(For example region could be session, global etc) and removed the region from the map

Specified by:
removeRegionCache in interface ICacheManager
Parameters:
region - The region whose objects needs to be removed from the cache.

putInRegionCache

public void putInRegionCache(String region,
                             Object key,
                             Object value)
Description copied from interface: ICacheManager
Puts an object directly into the cache of a specific region

Important note - most cache implementations require both the key and the value to be serializable.

Specified by:
putInRegionCache in interface ICacheManager
key - Object by which the data is indexed
value - The data to store in the cache.

getFromRegionCache

public Object getFromRegionCache(String region,
                                 Object key)
Description copied from interface: ICacheManager
Gets an object from the cache within a specific region

Specified by:
getFromRegionCache in interface ICacheManager
Parameters:
region - the region where the object was put in the cache
key - The key that the data object was stored with
Returns:
The corresponding data object

getAllEntriesFromRegionCache

public Set getAllEntriesFromRegionCache(String region)
Description copied from interface: ICacheManager
Get a Set of Map.Entry objects from the cache within a specific region

Specified by:
getAllEntriesFromRegionCache in interface ICacheManager
Parameters:
region - the region where the object was put in the cache
Returns:
The corresponding list of objects

getAllKeysFromRegionCache

public Set getAllKeysFromRegionCache(String region)
Description copied from interface: ICacheManager
Get a Set of Key objects from the cache within a specific region

Specified by:
getAllKeysFromRegionCache in interface ICacheManager
Parameters:
region - the region where the object was put in the cache
Returns:
The corresponding list of objects

getAllValuesFromRegionCache

public List getAllValuesFromRegionCache(String region)
Description copied from interface: ICacheManager
Get a list of values from the cache within a specific region

Specified by:
getAllValuesFromRegionCache in interface ICacheManager
Parameters:
region - the region where the object was put in the cache
Returns:
The corresponding list of objects

removeFromRegionCache

public void removeFromRegionCache(String region,
                                  Object key)
Description copied from interface: ICacheManager
Removes an object from the cache within a specific region

Specified by:
removeFromRegionCache in interface ICacheManager
Parameters:
region - the region where the object was put in the cache
key - The key that the data object was stored with

cacheEnabled

public boolean cacheEnabled()
Description copied from interface: ICacheManager
Returns the enablement state of the cache.

Specified by:
cacheEnabled in interface ICacheManager
Returns:
true if the cache has been initialized and is ready for use.

clearCache

public void clearCache()
Description copied from interface: ICacheManager
Entirely clears the cache.

Specified by:
clearCache in interface ICacheManager

getFromGlobalCache

public Object getFromGlobalCache(Object key)
Description copied from interface: ICacheManager
Gets an object from the cache without translating the passed in key.

Specified by:
getFromGlobalCache in interface ICacheManager
Parameters:
key - The key that the data object was stored with
Returns:
The corresponding data object

getFromSessionCache

public Object getFromSessionCache(IPentahoSession session,
                                  String key)
Description copied from interface: ICacheManager
Gets an object from the user session specific cache. If the object doesn't exist in the cache, null is returned.

Specified by:
getFromSessionCache in interface ICacheManager
Parameters:
session - The users IPentahoSession
key - The key that maps to the data to get from the cache
Returns:
Object that was stored in the cache

killSessionCache

public void killSessionCache(IPentahoSession session)
Description copied from interface: ICacheManager
Removes any session-based data for the specified IPentahoSession.

Specified by:
killSessionCache in interface ICacheManager
Parameters:
session - The session whose objects needs to be removed from the cache.

killSessionCaches

public void killSessionCaches()
Description copied from interface: ICacheManager
Removes all cached items that are session-based.

Specified by:
killSessionCaches in interface ICacheManager

putInGlobalCache

public void putInGlobalCache(Object key,
                             Object value)
Description copied from interface: ICacheManager
Puts an object directly into the cache without translating the passed in key.

Important note - most cache implementations require both the key and the value to be serializable.

Specified by:
putInGlobalCache in interface ICacheManager
Parameters:
key - Object by which the data is indexed
value - The data to store in the cache.

putInSessionCache

public void putInSessionCache(IPentahoSession session,
                              String key,
                              Object value)
Description copied from interface: ICacheManager
Puts an object in the session-specific cache. The session specified must have a valid session id.

Take special care that, in a TestCase, you don't have multiple StandaloneSession objects with the same session key. Consider using UUIDUtil to generate a unique sessionId for each standalone session.

Specified by:
putInSessionCache in interface ICacheManager
Parameters:
session - The users IPentahoSession
key - The key by which you want to retrieve the data back out
value - The data item to place into the cache

removeFromGlobalCache

public void removeFromGlobalCache(Object key)
Description copied from interface: ICacheManager
Removes an object from the cache

Specified by:
removeFromGlobalCache in interface ICacheManager
Parameters:
key - The key that the data object was stored with

removeFromSessionCache

public void removeFromSessionCache(IPentahoSession session,
                                   String key)
Description copied from interface: ICacheManager
Removes a data item from the user session specific cache

Specified by:
removeFromSessionCache in interface ICacheManager
Parameters:
session - The users IPentahoSession
key - The key that maps to the value needing removed