org.springframework.cache.support

Class AbstractCacheManager

  • java.lang.Object
    • org.springframework.cache.support.AbstractCacheManager
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method and Description
      protected void addCache(Cache cache)
      Deprecated. 
      as of Spring 4.3, in favor of getMissingCache(String)
      void afterPropertiesSet()
      Invoked by the containing BeanFactory after it has set all bean properties and satisfied BeanFactoryAware, ApplicationContextAware etc.
      protected Cache decorateCache(Cache cache)
      Decorate the given Cache object if necessary.
      Cache getCache(java.lang.String name)
      Return the cache associated with the given name.
      java.util.Collection<java.lang.String> getCacheNames()
      Return a collection of the cache names known by this manager.
      protected Cache getMissingCache(java.lang.String name)
      Return a missing cache with the specified name or null if such cache does not exist or could not be created on the fly.
      void initializeCaches()
      Initialize the static configuration of caches.
      protected abstract java.util.Collection<? extends Cache> loadCaches()
      Load the initial caches for this cache manager.
      protected Cache lookupCache(java.lang.String name)
      Check for a registered cache of the given name.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractCacheManager

        public AbstractCacheManager()
    • Method Detail

      • afterPropertiesSet

        public void afterPropertiesSet()
        Description copied from interface: InitializingBean
        Invoked by the containing BeanFactory after it has set all bean properties and satisfied BeanFactoryAware, ApplicationContextAware etc.

        This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.

        Specified by:
        afterPropertiesSet in interface InitializingBean
      • initializeCaches

        public void initializeCaches()
        Initialize the static configuration of caches.

        Triggered on startup through afterPropertiesSet(); can also be called to re-initialize at runtime.

        Since:
        4.2.2
        See Also:
        loadCaches()
      • loadCaches

        protected abstract java.util.Collection<? extends Cache> loadCaches()
        Load the initial caches for this cache manager.

        Called by afterPropertiesSet() on startup. The returned collection may be empty but must not be null.

      • getCache

        @Nullable
        public Cache getCache(java.lang.String name)
        Description copied from interface: CacheManager
        Return the cache associated with the given name.
        Specified by:
        getCache in interface CacheManager
        Parameters:
        name - the cache identifier (must not be null)
        Returns:
        the associated cache, or null if none found
      • getCacheNames

        public java.util.Collection<java.lang.String> getCacheNames()
        Description copied from interface: CacheManager
        Return a collection of the cache names known by this manager.
        Specified by:
        getCacheNames in interface CacheManager
        Returns:
        the names of all caches known by the cache manager
      • addCache

        @Deprecated
        protected final void addCache(Cache cache)
        Deprecated. as of Spring 4.3, in favor of getMissingCache(String)
        Dynamically register an additional Cache with this manager.
        Parameters:
        cache - the Cache to register
      • decorateCache

        protected Cache decorateCache(Cache cache)
        Decorate the given Cache object if necessary.
        Parameters:
        cache - the Cache object to be added to this CacheManager
        Returns:
        the decorated Cache object to be used instead, or simply the passed-in Cache object by default
      • getMissingCache

        @Nullable
        protected Cache getMissingCache(java.lang.String name)
        Return a missing cache with the specified name or null if such cache does not exist or could not be created on the fly.

        Some caches may be created at runtime if the native provider supports it. If a lookup by name does not yield any result, a subclass gets a chance to register such a cache at runtime. The returned cache will be automatically added to this instance.

        Parameters:
        name - the name of the cache to retrieve
        Returns:
        the missing cache or null if no such cache exists or could be created
        Since:
        4.1
        See Also:
        getCache(String)