Class InfinispanNamedEmbeddedCacheFactoryBean<K,V>
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.FactoryBean<Cache<K,,V>> org.springframework.beans.factory.InitializingBean
A for creating a
native FactoryBeannamed Infinispan , delegating to a
org.infinispan.Cacheconfigurable. If no cache name is explicitly set,
this org.infinispan.manager.EmbeddedCacheManagerFactoryBean's will be used
instead.
beanName
Beyond merely creating named Cache instances, this FactoryBean offers
great flexibility in configuring those Caches. It has setters for all non-global
configuration settings, i.e. all settings that are specific to a single Cache. The
configuration settings thus defined override those settings obtained from the
EmbeddedCacheManager.
There are different configuration that control with what modesConfiguration to start before further
customizing it as described above:
-
NONE: Configuration starts with a newConfigurationinstance. Note that this mode may only be used if no named configuration having the same name as theCacheto be created already exists. It is therefore illegal to use this mode to create aCachenamed, say, "cacheName" if the configuration file used to configure theEmbeddedCacheManagercontains a configuration section named "cacheName". -
DEFAULT: Configuration starts with theEmbeddedCacheManager's defaultConfigurationinstance, i.e. the configuration settings defined in its configuration file's default section. Note that this mode may only be used if no named configuration having the same name as theCacheto be created already exists. It is therefore illegal to use this mode to create aCachenamed, say, "cacheName" if the configuration file used to configure theEmbeddedCacheManagercontains a configuration section named "cacheName". -
CUSTOM: This is where a user will provide a custom-builtConfigurationBuilderobject which will be used to configure aCacheinstance. If asetCacheName(String)has already been called, then that name will be used. -
NAMED: Configuration starts with theEmbeddedCacheManager'sConfigurationinstance having the same name as theCacheto be created. For aCachenamed, say, "cacheName" this is the configuration section named "cacheName" as defined in theEmbeddedCacheManager's configuration file. Note that this mode is only useful if such a named configuration section does indeed exist. Otherwise, it is equivalent to usingDEFAULT.
In addition to creating a named Cache this FactoryBean does also
control that Cache' lifecycle by shutting
it down when the enclosing Spring application context is closed. It is therefore advisable to
always use this FactoryBean when creating a named Cache.
- Author:
- Olaf Bergner, Marius Bogoevici
-
Field Summary
Fields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAPI to introduce a customisedConfigurationBuilderthat will override the default configurations which are already available on this class.voidvoiddestroy()Shuts down theorg.infinispan.Cachecreated by thisFactoryBean.booleanAlways returnstrue.voidsetBeanName(String name) voidsetCacheName(String cacheName) Sets thenameof theto be created.org.infinispan.CachevoidsetConfigurationTemplateMode(String configurationTemplateMode) voidsetInfinispanEmbeddedCacheManager(EmbeddedCacheManager infinispanEmbeddedCacheManager) Sets theto be used for creating ourorg.infinispan.manager.EmbeddedCacheManagerinstance.Cache
-
Constructor Details
-
InfinispanNamedEmbeddedCacheFactoryBean
public InfinispanNamedEmbeddedCacheFactoryBean()
-
-
Method Details
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception- See Also:
-
InitializingBean.afterPropertiesSet()
-
getObject
-
getObjectType
- Specified by:
getObjectTypein interfaceorg.springframework.beans.factory.FactoryBean<K>- See Also:
-
FactoryBean.getObjectType()
-
isSingleton
public boolean isSingleton()Always returnstrue.- Specified by:
isSingletonin interfaceorg.springframework.beans.factory.FactoryBean<K>- Returns:
- Always
true - See Also:
-
FactoryBean.isSingleton()
-
setBeanName
- Specified by:
setBeanNamein interfaceorg.springframework.beans.factory.BeanNameAware- See Also:
-
BeanNameAware.setBeanName(String)
-
destroy
Shuts down theorg.infinispan.Cachecreated by thisFactoryBean.- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean- Throws:
Exception- See Also:
-
DisposableBean.destroy()Cache.stop()
-
setCacheName
Sets the
nameof theto be created. If no explicitorg.infinispan.CachecacheNameis set, thisFactoryBeanwill use itsas thebeanNamecacheName.- Parameters:
cacheName- Thenameof theto be createdorg.infinispan.Cache
-
setInfinispanEmbeddedCacheManager
Sets the
to be used for creating ourorg.infinispan.manager.EmbeddedCacheManagerinstance. Note that this is a mandatory property.Cache- Parameters:
infinispanEmbeddedCacheManager- Theto be used for creating ourorg.infinispan.manager.EmbeddedCacheManagerinstanceCache
-
setConfigurationTemplateMode
public void setConfigurationTemplateMode(String configurationTemplateMode) throws IllegalArgumentException - Parameters:
configurationTemplateMode-- Throws:
IllegalArgumentException
-
addCustomConfiguration
API to introduce a customisedConfigurationBuilderthat will override the default configurations which are already available on this class. This can only be used ifsetConfigurationTemplateMode(String)has been set toCUSTOM.- Parameters:
builder-
-