public class InfinispanNamedEmbeddedCacheFactoryBean<K,V> extends Object implements org.springframework.beans.factory.FactoryBean<org.infinispan.Cache<K,V>>, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
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 new
Configuration instance. Note that this mode may only be used if
no named configuration having the same name as the Cache to be
created already exists. It is therefore illegal to use this mode to create a
Cache named, say, "cacheName" if the configuration
file used to configure the EmbeddedCacheManager contains a
configuration section named "cacheName".DEFAULT: Configuration starts with the
EmbeddedCacheManager's default
Configuration 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 the Cache
to be created already exists. It is therefore illegal to use this mode to
create a Cache named, say, "cacheName" if the
configuration file used to configure the EmbeddedCacheManager
contains a configuration section named "cacheName".CUSTOM: This is where a user will provide a custom-built
ConfigurationBuilder object which will be used to configure a
Cache instance. If a setCacheName(String) has already
been called, then that name will be used.NAMED: Configuration starts with the
EmbeddedCacheManager's Configuration instance
having the same name as the Cache to be created. For a
Cache named, say, "cacheName" this is the
configuration section named "cacheName" as defined in the
EmbeddedCacheManager's configuration file. Note that this mode
is only useful if such a named configuration section does indeed exist.
Otherwise, it is equivalent to using DEFAULT.
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.
| 构造器和说明 |
|---|
InfinispanNamedEmbeddedCacheFactoryBean() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addCustomConfiguration(org.infinispan.configuration.cache.ConfigurationBuilder builder)
API to introduce a customised
ConfigurationBuilder that will
override the default configurations which are already available on this
class. |
void |
afterPropertiesSet() |
void |
destroy()
Shuts down the
org.infinispan.Cache created by this
FactoryBean. |
org.infinispan.Cache<K,V> |
getObject() |
Class<? extends org.infinispan.Cache> |
getObjectType() |
boolean |
isSingleton()
Always returns
true. |
void |
setBeanName(String name) |
void |
setCacheName(String cacheName)
Sets the
name of the
to be
created. |
void |
setConfigurationTemplateMode(String configurationTemplateMode) |
void |
setInfinispanEmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager infinispanEmbeddedCacheManager)
Sets the
to be used for
creating our instance. |
public void afterPropertiesSet()
throws Exception
afterPropertiesSet 在接口中 org.springframework.beans.factory.InitializingBeanExceptionInitializingBean.afterPropertiesSet()public Class<? extends org.infinispan.Cache> getObjectType()
public boolean isSingleton()
true.public void setBeanName(String name)
setBeanName 在接口中 org.springframework.beans.factory.BeanNameAwareBeanNameAware.setBeanName(java.lang.String)public void destroy()
throws Exception
org.infinispan.Cache created by this
FactoryBean.destroy 在接口中 org.springframework.beans.factory.DisposableBeanExceptionDisposableBean.destroy(),
Lifecycle.stop()public void setCacheName(String cacheName)
Sets the name of the
to be
created. If no explicit org.infinispan.CachecacheName is set, this
FactoryBean will use its as the beanNamecacheName.
cacheName - The name of the
org.infinispan.Cache
to be createdpublic void setInfinispanEmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager infinispanEmbeddedCacheManager)
Sets the to be used for
creating our org.infinispan.manager.EmbeddedCacheManager instance.
Note that this is a mandatory property.
Cache
infinispanEmbeddedCacheManager - The org.infinispan.manager.EmbeddedCacheManager to
be used for creating our Cache instancepublic void setConfigurationTemplateMode(String configurationTemplateMode) throws IllegalArgumentException
configurationTemplateMode - IllegalArgumentExceptionpublic void addCustomConfiguration(org.infinispan.configuration.cache.ConfigurationBuilder builder)
ConfigurationBuilder that will
override the default configurations which are already available on this
class. This can only be used if
setConfigurationTemplateMode(String) has been set to
CUSTOM.builder - Copyright © 2017 airlenet. All rights reserved.