Class EhCacheCacheService
- java.lang.Object
-
- org.bonitasoft.engine.cache.ehcache.EhCacheCacheService
-
- All Implemented Interfaces:
CacheService,LifecycleService,PlatformLifecycleService
@Order(2) @Component @ConditionalOnSingleCandidate(CacheService.class) public class EhCacheCacheService extends java.lang.Object implements CacheService, PlatformLifecycleService
- 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.CacheManagercacheManager
-
Constructor Summary
Constructors Constructor Description EhCacheCacheService(java.util.List<CacheConfiguration> cacheConfigurations, CacheConfiguration defaultCacheConfiguration, java.lang.String diskStorePath)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 java.util.Set<java.lang.String>getCacheConfigurationNames()protected java.lang.StringgetCacheManagerName()intgetCacheSize(java.lang.String cacheName)Return the size of the cache with cacheName.java.util.List<java.lang.String>getCachesNames()Get the names of all the cachesprotected net.sf.ehcache.config.CacheConfigurationgetEhCacheConfiguration(CacheConfiguration cacheConfig)java.util.List<java.lang.Object>getKeys(java.lang.String cacheName)Get list of keys on a cache.booleanisStopped()voidpause()Temporary halt the execution of this service.booleanremove(java.lang.String cacheName, java.lang.Object key)Remove the element according to the cache name and the keyvoidresume()resume the execution the serviceprotected voidshutdownCacheManager()voidstart()Start the servicevoidstop()voidstore(java.lang.String cacheName, java.io.Serializable key, java.lang.Object value)Store an object in the cache.
-
-
-
Constructor Detail
-
EhCacheCacheService
public EhCacheCacheService(java.util.List<CacheConfiguration> cacheConfigurations, @Qualifier("defaultCacheConfiguration") CacheConfiguration defaultCacheConfiguration, @Value("java.io.tmpdir/platform.cache") java.lang.String diskStorePath)
-
-
Method Detail
-
getCacheConfigurationNames
protected java.util.Set<java.lang.String> getCacheConfigurationNames()
-
getEhCacheConfiguration
protected net.sf.ehcache.config.CacheConfiguration getEhCacheConfiguration(CacheConfiguration cacheConfig)
-
getCachesNames
public java.util.List<java.lang.String> getCachesNames()
Description copied from interface:CacheServiceGet the names of all the caches- Specified by:
getCachesNamesin interfaceCacheService- Returns:
- a list of caches names
-
stop
public void stop()
- Specified by:
stopin interfaceLifecycleService
-
pause
public void pause()
Description copied from interface:LifecycleServiceTemporary halt the execution of this service.- Specified by:
pausein interfaceLifecycleService
-
resume
public void resume() throws SCacheExceptionDescription copied from interface:LifecycleServiceresume the execution the service- Specified by:
resumein interfaceLifecycleService- Throws:
SCacheException
-
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:CacheServiceStore an object in the cache. If the cache don't exists it will be created.- Specified by:
storein interfaceCacheService- 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.
-
get
public java.lang.Object get(java.lang.String cacheName, java.lang.Object key) throws SCacheExceptionDescription copied from interface:CacheServiceGet a cached object.- Specified by:
getin interfaceCacheService- 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:CacheServiceClear the cache named by cacheName- Specified by:
clearin interfaceCacheService- 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:CacheServiceReturn the size of the cache with cacheName.- Specified by:
getCacheSizein interfaceCacheService- 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:CacheServiceClear all cache of the service- Specified by:
clearAllin interfaceCacheService- 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:CacheServiceRemove the element according to the cache name and the key- Specified by:
removein interfaceCacheServicekey- 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:CacheServiceGet list of keys on a cache.- Specified by:
getKeysin interfaceCacheService- 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 interfaceCacheService
-
getCacheManagerName
protected java.lang.String getCacheManagerName()
-
start
public void start() throws SCacheExceptionDescription copied from interface:LifecycleServiceStart the service- Specified by:
startin interfaceLifecycleService- Throws:
SCacheException
-
-