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.CacheManager(Configuration)
constructor.
Constructor and Description |
---|
EhCacheManagerUtils() |
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. |
public static net.sf.ehcache.CacheManager buildCacheManager() throws net.sf.ehcache.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.
net.sf.ehcache.CacheException
- in case of configuration parsing failurepublic static net.sf.ehcache.CacheManager buildCacheManager(String name) throws net.sf.ehcache.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 managernet.sf.ehcache.CacheException
- in case of configuration parsing failurepublic static net.sf.ehcache.CacheManager buildCacheManager(Resource configLocation) throws net.sf.ehcache.CacheException
CacheManager
from the given configuration resource.configLocation
- the location of the configuration file (as a Spring resource)net.sf.ehcache.CacheException
- in case of configuration parsing failurepublic static net.sf.ehcache.CacheManager buildCacheManager(String name, Resource configLocation) throws net.sf.ehcache.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)net.sf.ehcache.CacheException
- in case of configuration parsing failurepublic static net.sf.ehcache.config.Configuration parseConfiguration(Resource configLocation) throws net.sf.ehcache.CacheException
CacheManager
creation.configLocation
- the location of the configuration file (as a Spring resource)net.sf.ehcache.CacheException
- in case of configuration parsing failureCacheManager.CacheManager(Configuration)
,
CacheManager.create(Configuration)