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 FactoryBean
named
Infinispan
, delegating to a
org.infinispan.Cache
configurable
. If no cache name is explicitly set,
this org.infinispan.manager.EmbeddedCacheManager
FactoryBean
'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 modes
Configuration
to start before further
customizing it as described above:
-
NONE
: Configuration starts with a newConfiguration
instance. Note that this mode may only be used if no named configuration having the same name as theCache
to be created already exists. It is therefore illegal to use this mode to create aCache
named, say, "cacheName" if the configuration file used to configure theEmbeddedCacheManager
contains a configuration section named "cacheName". -
DEFAULT
: Configuration starts with theEmbeddedCacheManager
's defaultConfiguration
instance, 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 theCache
to be created already exists. It is therefore illegal to use this mode to create aCache
named, say, "cacheName" if the configuration file used to configure theEmbeddedCacheManager
contains a configuration section named "cacheName". -
CUSTOM
: This is where a user will provide a custom-builtConfigurationBuilder
object which will be used to configure aCache
instance. If asetCacheName(String)
has already been called, then that name will be used. -
NAMED
: Configuration starts with theEmbeddedCacheManager
'sConfiguration
instance having the same name as theCache
to be created. For aCache
named, 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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
API to introduce a customisedConfigurationBuilder
that will override the default configurations which are already available on this class.void
void
destroy()
Shuts down theorg.infinispan.Cache
created by thisFactoryBean
.boolean
Always returnstrue
.void
setBeanName
(String name) void
setCacheName
(String cacheName) Sets thename
of the
to be created.org.infinispan.Cache
void
setConfigurationTemplateMode
(String configurationTemplateMode) void
setInfinispanEmbeddedCacheManager
(EmbeddedCacheManager infinispanEmbeddedCacheManager) Sets the
to be used for creating ourorg.infinispan.manager.EmbeddedCacheManager
instance.Cache
-
Constructor Details
-
InfinispanNamedEmbeddedCacheFactoryBean
public InfinispanNamedEmbeddedCacheFactoryBean()
-
-
Method Details
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
- See Also:
-
getObject
-
getObjectType
- Specified by:
getObjectType
in interfaceorg.springframework.beans.factory.FactoryBean<K>
- See Also:
-
isSingleton
public boolean isSingleton()Always returnstrue
.- Specified by:
isSingleton
in interfaceorg.springframework.beans.factory.FactoryBean<K>
- Returns:
- Always
true
- See Also:
-
setBeanName
- Specified by:
setBeanName
in interfaceorg.springframework.beans.factory.BeanNameAware
- See Also:
-
destroy
Shuts down theorg.infinispan.Cache
created by thisFactoryBean
.- Specified by:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
- Throws:
Exception
- See Also:
-
setCacheName
Sets the
name
of the
to be created. If no explicitorg.infinispan.Cache
cacheName
is set, thisFactoryBean
will use its
as thebeanName
cacheName
.- Parameters:
cacheName
- Thename
of the
to be createdorg.infinispan.Cache
-
setInfinispanEmbeddedCacheManager
Sets the
to be used for creating ourorg.infinispan.manager.EmbeddedCacheManager
instance. Note that this is a mandatory property.Cache
- Parameters:
infinispanEmbeddedCacheManager
- The
to be used for creating ourorg.infinispan.manager.EmbeddedCacheManager
instanceCache
-
setConfigurationTemplateMode
public void setConfigurationTemplateMode(String configurationTemplateMode) throws IllegalArgumentException - Parameters:
configurationTemplateMode
-- Throws:
IllegalArgumentException
-
addCustomConfiguration
API to introduce a customisedConfigurationBuilder
that 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
-
-