Package org.apache.fulcrum.cache.impl
Class EHCacheService
- java.lang.Object
- 
- org.apache.avalon.framework.logger.AbstractLogEnabled
- 
- org.apache.fulcrum.cache.impl.EHCacheService
 
 
- 
- All Implemented Interfaces:
- Runnable,- org.apache.avalon.framework.activity.Disposable,- org.apache.avalon.framework.activity.Initializable,- org.apache.avalon.framework.configuration.Configurable,- org.apache.avalon.framework.logger.LogEnabled,- org.apache.avalon.framework.thread.ThreadSafe,- GlobalCacheService
 
 public class EHCacheService extends org.apache.avalon.framework.logger.AbstractLogEnabled implements GlobalCacheService, Runnable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.thread.ThreadSafe Default implementation of EHCacheService (Ehcache 2)- Author:
- Eric Pugh, Thomas Vandahl
 
- 
- 
Field SummaryFields Modifier and Type Field Description static longDEFAULT_CACHE_CHECK_FREQUENCYCache check frequency in Millis (1000 Millis = 1 second).- 
Fields inherited from interface org.apache.fulcrum.cache.GlobalCacheServiceROLE
 
- 
 - 
Constructor SummaryConstructors Constructor Description EHCacheService()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> voidaddObject(String objectId, CachedObject<T> object)Adds an object to the cache.voidconfigure(org.apache.avalon.framework.configuration.Configuration config)voiddispose()voidflushCache()Flush the cache of all objects.List<CachedObject<?>>getCachedObjects()Returns a copy of the non-expired CachedObjects in the cache as a list.intgetCacheSize()Returns the current size of the cache.List<String>getKeys()Returns a copy of keys to objects in the cache as a list.intgetNumberOfObjects()Returns the number of objects in the cache.<T> CachedObject<T>getObject(String objectId)Gets a cached object given its id (a String).voidinitialize()voidremoveObject(String objectId)Removes an object from the cache.voidrun()Circle through the cache and refresh stale objects.
 
- 
- 
- 
Field Detail- 
DEFAULT_CACHE_CHECK_FREQUENCYpublic static final long DEFAULT_CACHE_CHECK_FREQUENCY Cache check frequency in Millis (1000 Millis = 1 second). Value must be > 0. Default = 5 seconds- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
configurepublic void configure(org.apache.avalon.framework.configuration.Configuration config) throws org.apache.avalon.framework.configuration.ConfigurationException- Specified by:
- configurein interface- org.apache.avalon.framework.configuration.Configurable
- Throws:
- org.apache.avalon.framework.configuration.ConfigurationException
- See Also:
- Configurable.configure(org.apache.avalon.framework.configuration.Configuration)
 
 - 
initializepublic void initialize() throws Exception- Specified by:
- initializein interface- org.apache.avalon.framework.activity.Initializable
- Throws:
- Exception
- See Also:
- Initializable.initialize()
 
 - 
disposepublic void dispose() - Specified by:
- disposein interface- org.apache.avalon.framework.activity.Disposable
- See Also:
- Disposable.dispose()
 
 - 
addObjectpublic <T> void addObject(String objectId, CachedObject<T> object) Description copied from interface:GlobalCacheServiceAdds an object to the cache.- Specified by:
- addObjectin interface- GlobalCacheService
- Type Parameters:
- T- type of object to add
- Parameters:
- objectId- The String id for the object.
- object- The object to add to the cache.
- See Also:
- GlobalCacheService.addObject(java.lang.String, org.apache.fulcrum.cache.CachedObject)
 
 - 
flushCachepublic void flushCache() Description copied from interface:GlobalCacheServiceFlush the cache of all objects.- Specified by:
- flushCachein interface- GlobalCacheService
- See Also:
- GlobalCacheService.flushCache()
 
 - 
getCachedObjectspublic List<CachedObject<?>> getCachedObjects() Description copied from interface:GlobalCacheServiceReturns a copy of the non-expired CachedObjects in the cache as a list.- Specified by:
- getCachedObjectsin interface- GlobalCacheService
- Returns:
- A List of CachedObjectobjects held in the cache
- See Also:
- GlobalCacheService.getCachedObjects()
 
 - 
getCacheSizepublic int getCacheSize() throws IOExceptionDescription copied from interface:GlobalCacheServiceReturns the current size of the cache.- Specified by:
- getCacheSizein interface- GlobalCacheService
- Returns:
- int representing current cache size in number of bytes
- Throws:
- IOException- if unable to return cache size
- See Also:
- GlobalCacheService.getCacheSize()
 
 - 
getKeyspublic List<String> getKeys() Description copied from interface:GlobalCacheServiceReturns a copy of keys to objects in the cache as a list. Note that keys to expired objects are not returned.- Specified by:
- getKeysin interface- GlobalCacheService
- Returns:
- A List of String's representing the keys to objects in the cache.
- See Also:
- GlobalCacheService.getKeys()
 
 - 
getNumberOfObjectspublic int getNumberOfObjects() Description copied from interface:GlobalCacheServiceReturns the number of objects in the cache.- Specified by:
- getNumberOfObjectsin interface- GlobalCacheService
- Returns:
- int The current number of objects in the cache.
- See Also:
- GlobalCacheService.getNumberOfObjects()
 
 - 
getObjectpublic <T> CachedObject<T> getObject(String objectId) throws ObjectExpiredException Description copied from interface:GlobalCacheServiceGets a cached object given its id (a String).- Specified by:
- getObjectin interface- GlobalCacheService
- Type Parameters:
- T- type of object to return
- Parameters:
- objectId- The String id for the object.
- Returns:
- A CachedObject.
- Throws:
- ObjectExpiredException- if the object has expired in the cache.
- See Also:
- GlobalCacheService.getObject(java.lang.String)
 
 - 
removeObjectpublic void removeObject(String objectId) Description copied from interface:GlobalCacheServiceRemoves an object from the cache.- Specified by:
- removeObjectin interface- GlobalCacheService
- Parameters:
- objectId- The String id for the object.
- See Also:
- GlobalCacheService.removeObject(java.lang.String)
 
 
- 
 
-