org.jasig.portal.utils.cache
Class EhCacheFacade

java.lang.Object
  extended by org.springmodules.cache.provider.AbstractCacheProviderFacade
      extended by org.jasig.portal.utils.cache.EhCacheFacade
All Implemented Interfaces:
InitializingBean, org.springmodules.cache.provider.CacheProviderFacade

public class EhCacheFacade
extends org.springmodules.cache.provider.AbstractCacheProviderFacade

Similar to the spring-modules EhCacheFacade except this will create a cache if it does not already exist.

Version:
$Revision$
Author:
Eric Dalquist

Field Summary
protected  org.apache.commons.logging.Log logger
           
 
Constructor Summary
EhCacheFacade()
           
 
Method Summary
protected  net.sf.ehcache.Cache getCache(org.springmodules.cache.CachingModel model)
          Returns a EHCache cache from the cache manager.
protected  net.sf.ehcache.Cache getCache(String name)
          Returns a EHCache cache from the cache manager.
 net.sf.ehcache.CacheManager getCacheManager()
           
 PropertyEditor getCachingModelEditor()
           
 PropertyEditor getFlushingModelEditor()
           
 boolean isCreateMissingCaches()
           
protected  boolean isSerializableCacheElementRequired()
           
 org.springmodules.cache.provider.CacheModelValidator modelValidator()
          Returns the validator of cache models.
protected  void onFlushCache(org.springmodules.cache.FlushingModel model)
          Removes all the entries in the caches specified in the given flushing model.
protected  Object onGetFromCache(Serializable key, org.springmodules.cache.CachingModel model)
          Retrieves an object stored under the given key from the cache specified in the given caching model.
protected  void onPutInCache(Serializable key, org.springmodules.cache.CachingModel model, Object obj)
          Stores the given object under the given key in the cache specified in the given caching model.
protected  void onRemoveFromCache(Serializable key, org.springmodules.cache.CachingModel model)
          Removes the object stored under the given key from the cache specified in the given caching model.
 void setCacheManager(net.sf.ehcache.CacheManager newCacheManager)
          Sets the EHCache cache manager to use.
 void setCreateMissingCaches(boolean createMissingCaches)
           
protected  void validateCacheManager()
           
 
Methods inherited from class org.springmodules.cache.provider.AbstractCacheProviderFacade
afterPropertiesSet, assertCacheManagerIsNotNull, cancelCacheUpdate, flushCache, getFromCache, handleCatchedException, isFailQuietlyEnabled, makeSerializableIfNecessary, onAfterPropertiesSet, onCancelCacheUpdate, putInCache, removeFromCache, setFailQuietlyEnabled, setSerializableFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

EhCacheFacade

public EhCacheFacade()
Method Detail

isCreateMissingCaches

public boolean isCreateMissingCaches()
Returns:
the createMissingCaches

setCreateMissingCaches

public void setCreateMissingCaches(boolean createMissingCaches)
Parameters:
createMissingCaches - the createMissingCaches to set

getCacheManager

public net.sf.ehcache.CacheManager getCacheManager()
Returns:
the cacheManager

setCacheManager

public void setCacheManager(net.sf.ehcache.CacheManager newCacheManager)
Sets the EHCache cache manager to use.

Parameters:
newCacheManager - the new cache manager

modelValidator

public org.springmodules.cache.provider.CacheModelValidator modelValidator()
Returns the validator of cache models. It is always an instance of EhCacheModelValidator.

Returns:
the validator of cache models

getCachingModelEditor

public PropertyEditor getCachingModelEditor()
See Also:
CacheProviderFacade.getCachingModelEditor()

getFlushingModelEditor

public PropertyEditor getFlushingModelEditor()
See Also:
CacheProviderFacade.getFlushingModelEditor()

getCache

protected net.sf.ehcache.Cache getCache(org.springmodules.cache.CachingModel model)
                                 throws org.springmodules.cache.provider.CacheNotFoundException,
                                        org.springmodules.cache.provider.CacheAccessException
Returns a EHCache cache from the cache manager.

Parameters:
model - the model containing the name of the cache to retrieve
Returns:
the cache retrieved from the cache manager
Throws:
org.springmodules.cache.provider.CacheNotFoundException - if the cache does not exist
org.springmodules.cache.provider.CacheAccessException - wrapping any unexpected exception thrown by the cache

getCache

protected net.sf.ehcache.Cache getCache(String name)
                                 throws org.springmodules.cache.provider.CacheNotFoundException,
                                        org.springmodules.cache.provider.CacheAccessException
Returns a EHCache cache from the cache manager.

Parameters:
name - the name of the cache
Returns:
the cache retrieved from the cache manager
Throws:
org.springmodules.cache.provider.CacheNotFoundException - if the cache does not exist
org.springmodules.cache.provider.CacheAccessException - wrapping any unexpected exception thrown by the cache

isSerializableCacheElementRequired

protected boolean isSerializableCacheElementRequired()
Specified by:
isSerializableCacheElementRequired in class org.springmodules.cache.provider.AbstractCacheProviderFacade
Returns:
true. EHCache can only store Serializable objects
See Also:
AbstractCacheProviderFacade.isSerializableCacheElementRequired()

onFlushCache

protected void onFlushCache(org.springmodules.cache.FlushingModel model)
                     throws org.springmodules.cache.CacheException
Removes all the entries in the caches specified in the given flushing model. The flushing model should be an instance of EhCacheFlushingModel.

Specified by:
onFlushCache in class org.springmodules.cache.provider.AbstractCacheProviderFacade
Parameters:
model - the flushing model.
Throws:
org.springmodules.cache.provider.CacheNotFoundException - if the cache specified in the given model cannot be found.
org.springmodules.cache.provider.CacheAccessException - wrapping any unexpected exception thrown by the cache.
org.springmodules.cache.CacheException
See Also:
AbstractCacheProviderFacade.onFlushCache(FlushingModel)

onGetFromCache

protected Object onGetFromCache(Serializable key,
                                org.springmodules.cache.CachingModel model)
                         throws org.springmodules.cache.CacheException
Retrieves an object stored under the given key from the cache specified in the given caching model. The caching model should be an instance of EhCacheCachingModel.

Specified by:
onGetFromCache in class org.springmodules.cache.provider.AbstractCacheProviderFacade
Parameters:
key - the key of the cache entry
model - the caching model
Returns:
the object retrieved from the cache. Can be null.
Throws:
org.springmodules.cache.provider.CacheNotFoundException - if the cache specified in the given model cannot be found.
org.springmodules.cache.provider.CacheAccessException - wrapping any unexpected exception thrown by the cache.
org.springmodules.cache.CacheException
See Also:
AbstractCacheProviderFacade.onGetFromCache(Serializable, CachingModel)

onPutInCache

protected void onPutInCache(Serializable key,
                            org.springmodules.cache.CachingModel model,
                            Object obj)
                     throws org.springmodules.cache.CacheException
Stores the given object under the given key in the cache specified in the given caching model. The caching model should be an instance of EhCacheCachingModel.

Specified by:
onPutInCache in class org.springmodules.cache.provider.AbstractCacheProviderFacade
Parameters:
key - the key of the cache entry
model - the caching model
obj - the object to store in the cache
Throws:
ObjectCannotBeCachedException - if the object to store is not an implementation of java.io.Serializable.
org.springmodules.cache.provider.CacheNotFoundException - if the cache specified in the given model cannot be found.
org.springmodules.cache.provider.CacheAccessException - wrapping any unexpected exception thrown by the cache.
org.springmodules.cache.CacheException
See Also:
AbstractCacheProviderFacade.onPutInCache(Serializable, CachingModel, Object)

onRemoveFromCache

protected void onRemoveFromCache(Serializable key,
                                 org.springmodules.cache.CachingModel model)
                          throws org.springmodules.cache.CacheException
Removes the object stored under the given key from the cache specified in the given caching model. The caching model should be an instance of EhCacheCachingModel.

Specified by:
onRemoveFromCache in class org.springmodules.cache.provider.AbstractCacheProviderFacade
Parameters:
key - the key of the cache entry
model - the caching model
Throws:
org.springmodules.cache.provider.CacheNotFoundException - if the cache specified in the given model cannot be found.
org.springmodules.cache.provider.CacheAccessException - wrapping any unexpected exception thrown by the cache.
org.springmodules.cache.CacheException
See Also:
AbstractCacheProviderFacade.onRemoveFromCache(Serializable, CachingModel)

validateCacheManager

protected void validateCacheManager()
                             throws org.springmodules.cache.FatalCacheException
Specified by:
validateCacheManager in class org.springmodules.cache.provider.AbstractCacheProviderFacade
Throws:
org.springmodules.cache.FatalCacheException - if the cache manager is null.
See Also:
AbstractCacheProviderFacade.validateCacheManager()


Copyright © 2010 Jasig. All Rights Reserved.