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 Object
implements CacheService, PlatformLifecycleService
- Author:
- Matthieu Chaffotte
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected net.sf.ehcache.CacheManager -
Constructor Summary
ConstructorsConstructorDescriptionEhCacheCacheService(List<CacheConfiguration> cacheConfigurations, CacheConfiguration defaultCacheConfiguration, String diskStorePath) -
Method Summary
Modifier and TypeMethodDescriptionbooleanClear the cache named by cacheNamevoidclearAll()Clear all cache of the serviceprotected net.sf.ehcache.CachecreateCache(String cacheName) Get a cached object.protected StringintgetCacheSize(String cacheName) Return the size of the cache with cacheName.Get the names of all the cachesprotected net.sf.ehcache.config.CacheConfigurationgetEhCacheConfiguration(CacheConfiguration cacheConfig) Get list of keys on a cache.booleanvoidpause()Temporary halt the execution of this service.booleanRemove the element according to the cache name and the keyvoidresume()resume the execution the serviceprotected voidvoidstart()Start the servicevoidstop()voidstore(String cacheName, Serializable key, Object value) Store an object in the cache.
-
Field Details
-
cacheManager
protected net.sf.ehcache.CacheManager cacheManager -
cacheConfigurations
-
-
Constructor Details
-
EhCacheCacheService
public EhCacheCacheService(List<CacheConfiguration> cacheConfigurations, @Qualifier("defaultCacheConfiguration") CacheConfiguration defaultCacheConfiguration, @Value("java.io.tmpdir/platform.cache") String diskStorePath)
-
-
Method Details
-
getCacheConfigurationNames
-
getEhCacheConfiguration
protected net.sf.ehcache.config.CacheConfiguration getEhCacheConfiguration(CacheConfiguration cacheConfig) -
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
Description copied from interface:LifecycleServiceresume the execution the service- Specified by:
resumein interfaceLifecycleService- Throws:
SCacheException
-
createCache
- Throws:
SCacheException
-
store
Description 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
Description 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
Description 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
Description 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
Description 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
Description 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
Description 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
-
start
Description copied from interface:LifecycleServiceStart the service- Specified by:
startin interfaceLifecycleService- Throws:
SCacheException
-