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 Details

    • cacheManager

      protected net.sf.ehcache.CacheManager cacheManager
    • cacheConfigurations

      protected final Map<String,net.sf.ehcache.config.CacheConfiguration> cacheConfigurations
  • Constructor Details

    • EhCacheCacheService

      public EhCacheCacheService(List<CacheConfiguration> cacheConfigurations, @Qualifier("defaultCacheConfiguration") CacheConfiguration defaultCacheConfiguration, @Value("java.io.tmpdir/platform.cache") String diskStorePath)
  • Method Details

    • getCacheConfigurationNames

      protected Set<String> getCacheConfigurationNames()
    • getEhCacheConfiguration

      protected net.sf.ehcache.config.CacheConfiguration getEhCacheConfiguration(CacheConfiguration cacheConfig)
    • getCachesNames

      public List<String> getCachesNames()
      Description copied from interface: CacheService
      Get the names of all the caches
      Specified by:
      getCachesNames in interface CacheService
      Returns:
      a list of caches names
    • stop

      public void stop()
      Specified by:
      stop in interface LifecycleService
    • pause

      public void pause()
      Description copied from interface: LifecycleService
      Temporary halt the execution of this service.
      Specified by:
      pause in interface LifecycleService
    • resume

      public void resume() throws SCacheException
      Description copied from interface: LifecycleService
      resume the execution the service
      Specified by:
      resume in interface LifecycleService
      Throws:
      SCacheException
    • createCache

      protected net.sf.ehcache.Cache createCache(String cacheName) throws SCacheException
      Throws:
      SCacheException
    • store

      public void store(String cacheName, Serializable key, Object value) throws SCacheException
      Description copied from interface: CacheService
      Store an object in the cache. If the cache don't exists it will be created.
      Specified by:
      store in interface CacheService
      Parameters:
      cacheName - The name of the cache in which the object must be stored
      key - The key that will allow to retrieve the object
      value - The object to store
      Throws:
      SCacheException - Error thrown if has exceptions during the cache store.
    • get

      public Object get(String cacheName, Object key) throws SCacheException
      Description copied from interface: CacheService
      Get a cached object.
      Specified by:
      get in interface CacheService
      Parameters:
      cacheName - The name of the cache on which to get the object
      key - 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(String cacheName) throws SCacheException
      Description copied from interface: CacheService
      Clear the cache named by cacheName
      Specified by:
      clear in interface CacheService
      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(String cacheName) throws SCacheException
      Description copied from interface: CacheService
      Return the size of the cache with cacheName.
      Specified by:
      getCacheSize in interface CacheService
      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 SCacheException
      Description copied from interface: CacheService
      Clear all cache of the service
      Specified by:
      clearAll in interface CacheService
      Throws:
      SCacheException - Error thrown if has exceptions during the cache clear.
    • remove

      public boolean remove(String cacheName, Object key) throws SCacheException
      Description copied from interface: CacheService
      Remove the element according to the cache name and the key
      Specified by:
      remove in interface CacheService
      key - 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 List<Object> getKeys(String cacheName) throws SCacheException
      Description copied from interface: CacheService
      Get list of keys on a cache.
      Specified by:
      getKeys in interface CacheService
      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:
      isStopped in interface CacheService
    • getCacheManagerName

      protected String getCacheManagerName()
    • start

      public void start() throws SCacheException
      Description copied from interface: LifecycleService
      Start the service
      Specified by:
      start in interface LifecycleService
      Throws:
      SCacheException