public class EhCacheManagerFactoryBean extends Object implements org.springframework.beans.factory.FactoryBean<net.sf.ehcache.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 3.0, Spring's EHCache support requires EHCache 1.3 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() |
net.sf.ehcache.CacheManager |
getObject() |
Class<? extends net.sf.ehcache.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).
CacheManager.create(java.io.InputStream)
,
CacheManager.CacheManager(java.io.InputStream)
public void setShared(boolean shared)
CacheManager.create()
,
CacheManager.CacheManager()
public void setCacheManagerName(String cacheManagerName)
CacheManager.setName(String)
public void afterPropertiesSet() throws IOException, net.sf.ehcache.CacheException
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
IOException
net.sf.ehcache.CacheException
public net.sf.ehcache.CacheManager getObject()
getObject
in interface org.springframework.beans.factory.FactoryBean<net.sf.ehcache.CacheManager>
public Class<? extends net.sf.ehcache.CacheManager> getObjectType()
getObjectType
in interface org.springframework.beans.factory.FactoryBean<net.sf.ehcache.CacheManager>
public boolean isSingleton()
isSingleton
in interface org.springframework.beans.factory.FactoryBean<net.sf.ehcache.CacheManager>
public void destroy()
destroy
in interface org.springframework.beans.factory.DisposableBean