org.springframework.cache.ehcache

## Class EhCacheManagerUtils

- java.lang.Object
- - org.springframework.cache.ehcache.EhCacheManagerUtils

-     public abstract class EhCacheManagerUtils
      extends Object

  Convenient builder methods for EhCache 2.5+ `CacheManager` setup, providing easy programmatic bootstrapping from a Spring-provided resource. This is primarily intended for use within `@Bean` methods in a Spring configuration class.

  These methods are a simple alternative to custom `CacheManager` setup code. For any advanced purposes, consider using `parseConfiguration(org.springframework.core.io.Resource)`, customizing the configuration object, and then calling the `CacheManager(Configuration)` constructor.

  Since:
    4.1
  Author:
    Juergen Hoeller

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `EhCacheManagerUtils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static net.sf.ehcache.CacheManager` | `buildCacheManager()` Build an EhCache `CacheManager` from the default configuration.
    `static net.sf.ehcache.CacheManager` | `buildCacheManager(Resource configLocation)` Build an EhCache `CacheManager` from the given configuration resource.
    `static net.sf.ehcache.CacheManager` | `buildCacheManager(String name)` Build an EhCache `CacheManager` from the default configuration.
    `static net.sf.ehcache.CacheManager` | `buildCacheManager(String name, Resource configLocation)` Build an EhCache `CacheManager` from the given configuration resource.
    `static net.sf.ehcache.config.Configuration` | `parseConfiguration(Resource configLocation)` Parse EhCache configuration from the given resource, for further use with custom `CacheManager` creation.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### EhCacheManagerUtils

          public EhCacheManagerUtils()

  - ### Method Detail

    - #### buildCacheManager

          public static net.sf.ehcache.CacheManager buildCacheManager()
                                                               throws net.sf.ehcache.CacheException

      Build an EhCache `CacheManager` from the default configuration.

      The CacheManager will be configured from "ehcache.xml" in the root of the class path (that is, default EhCache initialization - as defined in the EhCache docs - will apply). If no configuration file can be found, a fail-safe fallback configuration will be used.

      Returns:
        the new EhCache CacheManager
      Throws:
        `net.sf.ehcache.CacheException` - in case of configuration parsing failure

    - #### buildCacheManager

          public static net.sf.ehcache.CacheManager buildCacheManager(String name)
                                                               throws net.sf.ehcache.CacheException

      Build an EhCache `CacheManager` from the default configuration.

      The CacheManager will be configured from "ehcache.xml" in the root of the class path (that is, default EhCache initialization - as defined in the EhCache docs - will apply). If no configuration file can be found, a fail-safe fallback configuration will be used.

      Parameters:
        `name` - the desired name of the cache manager
      Returns:
        the new EhCache CacheManager
      Throws:
        `net.sf.ehcache.CacheException` - in case of configuration parsing failure

    - #### buildCacheManager

          public static net.sf.ehcache.CacheManager buildCacheManager(Resource configLocation)
                                                               throws net.sf.ehcache.CacheException

      Build an EhCache `CacheManager` from the given configuration resource.
      Parameters:
        `configLocation` - the location of the configuration file (as a Spring resource)
      Returns:
        the new EhCache CacheManager
      Throws:
        `net.sf.ehcache.CacheException` - in case of configuration parsing failure

    - #### buildCacheManager

          public static net.sf.ehcache.CacheManager buildCacheManager(String name,
                                                                      Resource configLocation)
                                                               throws net.sf.ehcache.CacheException

      Build an EhCache `CacheManager` from the given configuration resource.
      Parameters:
        `name` - the desired name of the cache manager
        `configLocation` - the location of the configuration file (as a Spring resource)
      Returns:
        the new EhCache CacheManager
      Throws:
        `net.sf.ehcache.CacheException` - in case of configuration parsing failure

    - #### parseConfiguration

          public static net.sf.ehcache.config.Configuration parseConfiguration(Resource configLocation)
                                                                        throws net.sf.ehcache.CacheException

      Parse EhCache configuration from the given resource, for further use with custom `CacheManager` creation.
      Parameters:
        `configLocation` - the location of the configuration file (as a Spring resource)
      Returns:
        the EhCache Configuration handle
      Throws:
        `net.sf.ehcache.CacheException` - in case of configuration parsing failure
      See Also:
        `CacheManager(Configuration)`, `CacheManager.create(Configuration)`