Class EhCacheCacheService

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<java.lang.String,​net.sf.ehcache.config.CacheConfiguration> cacheConfigurations  
      protected net.sf.ehcache.CacheManager cacheManager  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean clear​(java.lang.String cacheName)
      Clear the cache named by cacheName
      void clearAll()
      Clear all cache of the service
      protected net.sf.ehcache.Cache createCache​(java.lang.String cacheName, java.lang.String internalCacheName)  
      java.lang.Object get​(java.lang.String cacheName, java.lang.Object key)
      Get a cached object.
      protected java.util.Set<java.lang.String> getCacheConfigurationNames()  
      protected java.lang.String getCacheManagerName()  
      int getCacheSize​(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 caches
      protected net.sf.ehcache.config.CacheConfiguration getEhCacheConfiguration​(CacheConfiguration cacheConfig)  
      java.util.List<java.lang.Object> getKeys​(java.lang.String cacheName)
      Get list of keys on a cache.
      boolean isStopped()  
      void pause()
      Temporary halt the execution of this service.
      boolean remove​(java.lang.String cacheName, java.lang.Object key)
      Remove the element according to the cache name and the key
      void resume()
      resume the execution the service
      protected void shutdownCacheManager()  
      void start()
      Start the service
      void stop()  
      void store​(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
    • Field Detail

      • cacheManager

        protected net.sf.ehcache.CacheManager cacheManager
      • cacheConfigurations

        protected final java.util.Map<java.lang.String,​net.sf.ehcache.config.CacheConfiguration> cacheConfigurations
    • 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: CacheService
        Get the names of all the caches
        Specified by:
        getCachesNames in interface CacheService
        Returns:
        a list of caches names
      • 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 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 java.lang.Object get​(java.lang.String cacheName,
                                    java.lang.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​(java.lang.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​(java.lang.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.
      • remove

        public boolean remove​(java.lang.String cacheName,
                              java.lang.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 java.util.List<java.lang.Object> getKeys​(java.lang.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()
      • getCacheManagerName

        protected java.lang.String getCacheManagerName()