public class AcrossEhCacheManagerFactoryBean extends Object implements org.springframework.beans.factory.FactoryBean<net.sf.ehcache.CacheManager>, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
logger |
Constructor and Description |
---|
AcrossEhCacheManagerFactoryBean() |
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 |
setAcceptExisting(boolean acceptExisting)
Set whether an existing EhCache CacheManager of the same name will be accepted
for this EhCacheManagerFactoryBean setup.
|
void |
setCacheManagerName(String cacheManagerName)
Set the name of the EhCache CacheManager (if a specific name is desired).
|
void |
setConfigLocation(org.springframework.core.io.Resource resource)
Set the location of the EhCache config file.
|
void |
setConfiguration(net.sf.ehcache.config.Configuration configuration) |
void |
setShared(boolean shared)
Set whether the EhCache CacheManager should be shared (as a singleton at the
ClassLoader level) or independent (typically local within the application).
|
public void setConfigLocation(org.springframework.core.io.Resource resource)
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 setConfiguration(net.sf.ehcache.config.Configuration configuration)
public void setCacheManagerName(String cacheManagerName)
net.sf.ehcache.CacheManager#setName(String)
public void setAcceptExisting(boolean acceptExisting)
Typically used in combination with "cacheManagerName"
but will simply work with the default CacheManager name if none specified.
All references to the same CacheManager name (or the same default) in the
same ClassLoader space will share the specified CacheManager then.
NOTE: This feature requires EhCache 2.5 or higher. In contrast to
the "shared"
flag, it supports controlled shutdown of the
CacheManager by the EhCacheManagerFactoryBean that actually created it.
setCacheManagerName(java.lang.String)
,
setShared(boolean)
,
CacheManager.getCacheManager(String)
,
CacheManager.CacheManager()
public void setShared(boolean shared)
NOTE: This feature allows for sharing this EhCacheManagerFactoryBean's
CacheManager with any code calling CacheManager.create()
in the same
ClassLoader space, with no need to agree on a specific CacheManager name.
However, it only supports a single EhCacheManagerFactoryBean involved which will
control the lifecycle of the underlying CacheManager (in particular, its shutdown).
This flag overrides "acceptExisting"
if both are set,
since it indicates the 'stronger' mode of sharing.
setCacheManagerName(java.lang.String)
,
setAcceptExisting(boolean)
,
CacheManager.create()
,
CacheManager.CacheManager()
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
Copyright © 2020 Pivotal Software, Inc.. All rights reserved.