java.lang.Object | |
↳ | org.springframework.cache.ehcache.EhCacheFactoryBean |
FactoryBean
that creates a named EHCache net.sf.ehcache.Cache instance
(or a decorator that implements the net.sf.ehcache.Ehcache interface),
representing a cache region within an EHCache net.sf.ehcache.CacheManager.
If the specified named cache is not configured in the cache configuration descriptor, this FactoryBean will construct an instance of a Cache with the provided name and the specified cache properties and add it to the CacheManager for later retrieval. If some or all properties are not set at configuration time, this FactoryBean will use defaults.
Note: If the named Cache instance is found, the properties will be ignored and the Cache instance will be retrieved from the CacheManager.
Note: As of Spring 3.0, Spring's EHCache support requires EHCache 1.3 or higher.
setCacheManager(CacheManager)
EhCacheManagerFactoryBean
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
logger |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Invoked by a BeanFactory after it has set all bean properties supplied
(and satisfied BeanFactoryAware and ApplicationContextAware).
| |||||||||||
Return an instance (possibly shared or independent) of the object
managed by this factory.
| |||||||||||
Return the type of object that this FactoryBean creates,
or
null if not known in advance. | |||||||||||
Is the object managed by this factory a singleton? That is,
will
getObject() always return the same object
(a reference that can be cached)?
NOTE: If a FactoryBean indicates to hold a singleton object,
the object returned from | |||||||||||
Set the name of the bean in the bean factory that created this bean.
| |||||||||||
Set whether to use a blocking cache that lets read attempts block
until the requested element is created.
| |||||||||||
Set an EHCache net.sf.ehcache.bootstrap.BootstrapCacheLoader
for this cache, if any.
| |||||||||||
Set an EHCache net.sf.ehcache.constructs.blocking.CacheEntryFactory
to use for a self-populating cache.
| |||||||||||
Specify EHCache net.sf.ehcache.event.CacheEventListener cache event listeners
to registered with this cache.
| |||||||||||
Set a CacheManager from which to retrieve a named Cache instance.
| |||||||||||
Set a name for which to retrieve or create a cache instance.
| |||||||||||
Set whether the memory store should be cleared when flush is called on the cache.
| |||||||||||
Set the number of seconds between runs of the disk expiry thread.
| |||||||||||
Set whether the disk store persists between restarts of the Virtual Machine.
| |||||||||||
Set the amount of memory to allocate the write buffer for puts to the disk store.
| |||||||||||
Set whether elements are considered as eternal.
| |||||||||||
Specify the maximum number of cached objects in memory.
| |||||||||||
Specify the maximum number of cached objects on disk.
| |||||||||||
Set the memory style eviction policy for this cache.
| |||||||||||
Set whether elements can overflow to disk when the in-memory cache
has reached the maximum size limit.
| |||||||||||
Set the time in seconds to idle for an element before it expires, that is,
the maximum amount of time between accesses before an element expires.
| |||||||||||
Set the time in seconds to live for an element before it expires,
i.e.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a raw Cache object based on the configuration of this FactoryBean.
| |||||||||||
Decorate the given Cache, if necessary.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.beans.factory.BeanNameAware
| |||||||||||
From interface
org.springframework.beans.factory.FactoryBean
| |||||||||||
From interface
org.springframework.beans.factory.InitializingBean
|
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
CacheException | |
---|---|
IOException |
Return an instance (possibly shared or independent) of the object managed by this factory.
As with a BeanFactory
, this allows support for both the
Singleton and Prototype design pattern.
If this FactoryBean is not fully initialized yet at the time of
the call (for example because it is involved in a circular reference),
throw a corresponding FactoryBeanNotInitializedException
.
As of Spring 2.0, FactoryBeans are allowed to return null
objects. The factory will consider this as normal value to be used; it
will not throw a FactoryBeanNotInitializedException in this case anymore.
FactoryBean implementations are encouraged to throw
FactoryBeanNotInitializedException themselves now, as appropriate.
null
)Return the type of object that this FactoryBean creates,
or null
if not known in advance.
This allows one to check for specific types of beans without instantiating objects, for example on autowiring.
In the case of implementations that are creating a singleton object, this method should try to avoid singleton creation as far as possible; it should rather estimate the type in advance. For prototypes, returning a meaningful type here is advisable too.
This method can be called before this FactoryBean has been fully initialized. It must not rely on state created during initialization; of course, it can still use such state if available.
NOTE: Autowiring will simply ignore FactoryBeans that return
null
here. Therefore it is highly recommended to implement
this method properly, using the current state of the FactoryBean.
null
if not known at the time of the callIs the object managed by this factory a singleton? That is,
will getObject()
always return the same object
(a reference that can be cached)?
NOTE: If a FactoryBean indicates to hold a singleton object,
the object returned from getObject()
might get cached
by the owning BeanFactory. Hence, do not return true
unless the FactoryBean always exposes the same reference.
The singleton status of the FactoryBean itself will generally be provided by the owning BeanFactory; usually, it has to be defined as singleton there.
NOTE: This method returning false
does not
necessarily indicate that returned objects are independent instances.
An implementation of the extended SmartFactoryBean
interface
may explicitly indicate independent instances through its
isPrototype()
method. Plain FactoryBean
implementations which do not implement this extended interface are
simply assumed to always return independent instances if the
isSingleton()
implementation returns false
.
Set the name of the bean in the bean factory that created this bean.
Invoked after population of normal bean properties but before an
init callback such as afterPropertiesSet()
or a custom init-method.
name | the name of the bean in the factory. Note that this name is the actual bean name used in the factory, which may differ from the originally specified name: in particular for inner bean names, the actual bean name might have been made unique through appending "#..." suffixes. Use the BeanFactoryUtils#originalBeanName(String) method to extract the original bean name (without suffix), if desired. |
---|
Set whether to use a blocking cache that lets read attempts block until the requested element is created.
If you intend to build a self-populating blocking cache,
consider specifying a CacheEntryFactory
.
setCacheEntryFactory(CacheEntryFactory)
Set an EHCache net.sf.ehcache.bootstrap.BootstrapCacheLoader for this cache, if any.
Set an EHCache net.sf.ehcache.constructs.blocking.CacheEntryFactory to use for a self-populating cache. If such a factory is specified, the cache will be decorated with EHCache's net.sf.ehcache.constructs.blocking.SelfPopulatingCache.
The specified factory can be of type net.sf.ehcache.constructs.blocking.UpdatingCacheEntryFactory, which will lead to the use of an net.sf.ehcache.constructs.blocking.UpdatingSelfPopulatingCache.
Note: Any such self-populating cache is automatically a blocking cache.
Specify EHCache net.sf.ehcache.event.CacheEventListener cache event listeners to registered with this cache.
Set a CacheManager from which to retrieve a named Cache instance.
By default, CacheManager.getInstance()
will be called.
Note that in particular for persistent caches, it is advisable to properly handle the shutdown of the CacheManager: Set up a separate EhCacheManagerFactoryBean and pass a reference to this bean property.
A separate EhCacheManagerFactoryBean is also necessary for loading EHCache configuration from a non-default config location.
EhCacheManagerFactoryBean
Set a name for which to retrieve or create a cache instance. Default is the bean name of this EhCacheFactoryBean.
Set whether the memory store should be cleared when flush is called on the cache. Default is "true".
Set the number of seconds between runs of the disk expiry thread. Default is 120 seconds.
Set whether the disk store persists between restarts of the Virtual Machine. Default is "false".
Set the amount of memory to allocate the write buffer for puts to the disk store. Default is 0.
Set whether elements are considered as eternal. If "true", timeouts are ignored and the element is never expired. Default is "false".
Specify the maximum number of cached objects in memory. Default is 10000 elements.
Specify the maximum number of cached objects on disk. Default is 10000000 elements.
Set the memory style eviction policy for this cache.
Supported values are "LRU", "LFU" and "FIFO", according to the constants defined in EHCache's MemoryStoreEvictionPolicy class. Default is "LRU".
Set whether elements can overflow to disk when the in-memory cache has reached the maximum size limit. Default is "true".
Set the time in seconds to idle for an element before it expires, that is, the maximum amount of time between accesses before an element expires.
This is only used if the element is not eternal. Default is 120 seconds.
Set the time in seconds to live for an element before it expires, i.e. the maximum time between creation time and when an element expires.
This is only used if the element is not eternal. Default is 120 seconds.
Create a raw Cache object based on the configuration of this FactoryBean.
Decorate the given Cache, if necessary.
cache | the raw Cache object, based on the configuration of this FactoryBean |
---|