Class CommonEhCacheCacheService
- java.lang.Object
-
- org.bonitasoft.engine.cache.ehcache.CommonEhCacheCacheService
-
- All Implemented Interfaces:
CommonCacheService
- Direct Known Subclasses:
EhCacheCacheService,PlatformEhCacheCacheService
public abstract class CommonEhCacheCacheService extends java.lang.Object implements CommonCacheService
- Author:
- Matthieu Chaffotte
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,net.sf.ehcache.config.CacheConfiguration>cacheConfigurationsprotected net.sf.ehcache.CacheManagercacheManagerprotected TechnicalLoggerServicelogger
-
Constructor Summary
Constructors Constructor Description CommonEhCacheCacheService(TechnicalLoggerService logger, java.util.List<CacheConfiguration> cacheConfigurations, CacheConfiguration defaultCacheConfiguration, java.lang.String diskStorePath)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidbuildCacheManagerWithDefaultConfiguration()booleanclear(java.lang.String cacheName)Clear the cache named by cacheNamevoidclearAll()Clear all cache of the serviceprotected net.sf.ehcache.CachecreateCache(java.lang.String cacheName, java.lang.String internalCacheName)java.lang.Objectget(java.lang.String cacheName, java.lang.Object key)Get a cached object.protected abstract java.lang.StringgetCacheManagerIdentifier()protected abstract java.lang.StringgetCacheManagerName()intgetCacheSize(java.lang.String cacheName)Return the size of the cache with cacheName.protected net.sf.ehcache.config.CacheConfigurationgetEhCacheConfiguration(CacheConfiguration cacheConfig)protected abstract java.lang.StringgetKeyFromCacheName(java.lang.String cacheName)java.util.List<java.lang.Object>getKeys(java.lang.String cacheName)Get list of keys on a cache.booleanisStopped()booleanremove(java.lang.String cacheName, java.lang.Object key)Remove the element according to the cache name and the keyprotected voidshutdownCacheManager()voidstore(java.lang.String cacheName, java.io.Serializable key, java.lang.Object value)Store an object in the cache.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.bonitasoft.engine.cache.CommonCacheService
getCachesNames
-
-
-
-
Field Detail
-
cacheManager
protected net.sf.ehcache.CacheManager cacheManager
-
logger
protected final TechnicalLoggerService logger
-
cacheConfigurations
protected final java.util.Map<java.lang.String,net.sf.ehcache.config.CacheConfiguration> cacheConfigurations
-
-
Constructor Detail
-
CommonEhCacheCacheService
public CommonEhCacheCacheService(TechnicalLoggerService logger, java.util.List<CacheConfiguration> cacheConfigurations, CacheConfiguration defaultCacheConfiguration, java.lang.String diskStorePath)
-
-
Method Detail
-
getEhCacheConfiguration
protected net.sf.ehcache.config.CacheConfiguration getEhCacheConfiguration(CacheConfiguration cacheConfig)
-
buildCacheManagerWithDefaultConfiguration
protected void buildCacheManagerWithDefaultConfiguration()
-
getCacheManagerIdentifier
protected abstract java.lang.String getCacheManagerIdentifier()
-
createCache
protected net.sf.ehcache.Cache createCache(java.lang.String cacheName, java.lang.String internalCacheName) throws SCacheException- Throws:
SCacheException
-
store
public void store(java.lang.String cacheName, java.io.Serializable key, java.lang.Object value) throws SCacheExceptionDescription copied from interface:CommonCacheServiceStore an object in the cache. If the cache don't exists it will be created.- Specified by:
storein interfaceCommonCacheService- Parameters:
cacheName- The name of the cache in which the object must be storedkey- The key that will allow to retrieve the objectvalue- The object to store- Throws:
SCacheException- Error thrown if has exceptions during the cache store.
-
getKeyFromCacheName
protected abstract java.lang.String getKeyFromCacheName(java.lang.String cacheName) throws SCacheException- Throws:
SCacheException
-
get
public java.lang.Object get(java.lang.String cacheName, java.lang.Object key) throws SCacheExceptionDescription copied from interface:CommonCacheServiceGet a cached object.- Specified by:
getin interfaceCommonCacheService- Parameters:
cacheName- The name of the cache on which to get the objectkey- The key that is used to store the object- Returns:
- the cached object, or null if it doesn't exists
- Throws:
SCacheException- Error thrown if has exceptions during the cache object get.
-
clear
public boolean clear(java.lang.String cacheName) throws SCacheExceptionDescription copied from interface:CommonCacheServiceClear the cache named by cacheName- Specified by:
clearin interfaceCommonCacheService- Parameters:
cacheName- The name of the cache to clear- Returns:
- Throws:
SCacheException- Error thrown if has exceptions during the cache clear.
-
getCacheSize
public int getCacheSize(java.lang.String cacheName) throws SCacheExceptionDescription copied from interface:CommonCacheServiceReturn the size of the cache with cacheName.- Specified by:
getCacheSizein interfaceCommonCacheService- Parameters:
cacheName- The name of cache- Returns:
- the size of the named cache
- Throws:
SCacheException- if no cache is found with that name.
-
clearAll
public void clearAll() throws SCacheExceptionDescription copied from interface:CommonCacheServiceClear all cache of the service- Specified by:
clearAllin interfaceCommonCacheService- Throws:
SCacheException- Error thrown if has exceptions during the cache clear.
-
remove
public boolean remove(java.lang.String cacheName, java.lang.Object key) throws SCacheExceptionDescription copied from interface:CommonCacheServiceRemove the element according to the cache name and the key- Specified by:
removein interfaceCommonCacheServicekey- The name of the cache where the object must be stored The key that will allow to retrieve the object- Returns:
- true if an element was removed
- Throws:
SCacheException- Error thrown if has exceptions during the cache remove.
-
getKeys
public java.util.List<java.lang.Object> getKeys(java.lang.String cacheName) throws SCacheExceptionDescription copied from interface:CommonCacheServiceGet list of keys on a cache.- Specified by:
getKeysin interfaceCommonCacheService- Parameters:
cacheName- The name of the cache on which to get the key list- Returns:
- the list of keys on the cache, or null if no keys exist
- Throws:
SCacheException
-
shutdownCacheManager
protected void shutdownCacheManager()
-
isStopped
public boolean isStopped()
- Specified by:
isStoppedin interfaceCommonCacheService
-
getCacheManagerName
protected abstract java.lang.String getCacheManagerName()
-
-