public abstract class EhCacheManagerUtils extends Object
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.
Constructor and Description |
---|
EhCacheManagerUtils() |
Modifier and Type | Method and Description |
---|---|
static CacheManager |
buildCacheManager()
Build an EhCache
CacheManager from the default configuration. |
static CacheManager |
buildCacheManager(Resource configLocation)
Build an EhCache
CacheManager from the given configuration resource. |
static CacheManager |
buildCacheManager(String name)
Build an EhCache
CacheManager from the default configuration. |
static CacheManager |
buildCacheManager(String name,
Resource configLocation)
Build an EhCache
CacheManager from the given configuration resource. |
static Configuration |
parseConfiguration(Resource configLocation)
Parse EhCache configuration from the given resource, for further use with
custom
CacheManager creation. |
public static CacheManager buildCacheManager() throws CacheException
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.
CacheException
- in case of configuration parsing failurepublic static CacheManager buildCacheManager(String name) throws CacheException
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.
name
- the desired name of the cache managerCacheException
- in case of configuration parsing failurepublic static CacheManager buildCacheManager(Resource configLocation) throws CacheException
CacheManager
from the given configuration resource.configLocation
- the location of the configuration file (as a Spring resource)CacheException
- in case of configuration parsing failurepublic static CacheManager buildCacheManager(String name, Resource configLocation) throws CacheException
CacheManager
from the given configuration resource.name
- the desired name of the cache managerconfigLocation
- the location of the configuration file (as a Spring resource)CacheException
- in case of configuration parsing failurepublic static Configuration parseConfiguration(Resource configLocation) throws CacheException
CacheManager
creation.configLocation
- the location of the configuration file (as a Spring resource)CacheException
- in case of configuration parsing failureCacheManager(Configuration)
,
CacheManager.create(Configuration)