public class EhCacheManagerFactoryBean extends Object implements org.springframework.beans.factory.FactoryBean<CacheManager>, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
FactoryBean
that exposes an EhCache CacheManager
instance (independent or shared), configured from a specified config location.
If no config location is specified, a 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).
Setting up a separate EhCacheManagerFactoryBean is also advisable when using EhCacheFactoryBean, as it provides a (by default) independent CacheManager instance and cares for proper shutdown of the CacheManager. EhCacheManagerFactoryBean is also necessary for loading EhCache configuration from a non-default config location.
Note: As of Spring 4.0, Spring's EhCache support requires EhCache 2.1 or higher.
setConfigLocation(org.springframework.core.io.Resource)
,
setShared(boolean)
,
EhCacheFactoryBean
,
CacheManager
Constructor and Description |
---|
EhCacheManagerFactoryBean() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
void |
destroy() |
CacheManager |
getObject() |
Class<? extends CacheManager> |
getObjectType() |
boolean |
isSingleton() |
void |
setCacheManagerName(String cacheManagerName)
Set the name of the EhCache CacheManager (if a specific name is desired).
|
void |
setConfigLocation(org.springframework.core.io.Resource configLocation)
Set the location of the EhCache config file.
|
void |
setShared(boolean shared)
Set whether the EhCache CacheManager should be shared (as a singleton at the VM level)
or independent (typically local within the application).
|
protected final Log logger
public void setConfigLocation(org.springframework.core.io.Resource configLocation)
Default is "ehcache.xml" in the root of the class path, or if not found, "ehcache-failsafe.xml" in the EhCache jar (default EhCache initialization).
public void setShared(boolean shared)
CacheManager.create()
,
CacheManager.CacheManager()
public void setCacheManagerName(String cacheManagerName)
CacheManager.setName(String)
public void afterPropertiesSet() throws IOException, CacheException
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
IOException
CacheException
public CacheManager getObject()
getObject
in interface org.springframework.beans.factory.FactoryBean<CacheManager>
public Class<? extends CacheManager> getObjectType()
getObjectType
in interface org.springframework.beans.factory.FactoryBean<CacheManager>
public boolean isSingleton()
isSingleton
in interface org.springframework.beans.factory.FactoryBean<CacheManager>
public void destroy()
destroy
in interface org.springframework.beans.factory.DisposableBean