public interface EmbeddedCacheManager extends CacheContainer, Listenable
Configuration
or a path or URL to a configuration XML file: see DefaultCacheManager
.
Lifecycle - EmbeddedCacheManagers have a lifecycle (it implements Lifecycle
) and
the default constructors also call Lifecycle.start()
. Overloaded versions of the constructors are available, that do
not start the CacheManager, although it must be kept in mind that CacheManagers need to be started
before they can be used to create Cache instances.
Once constructed, EmbeddedCacheManagers should be made available to any component that requires a Cache,
via JNDI or via some other mechanism
such as an dependency injection framework.
DefaultCacheManager
DEFAULT_CACHE_NAME
Modifier and Type | Method and Description |
---|---|
void |
addCacheDependency(String from,
String to)
Add a dependency between two caches.
|
boolean |
cacheExists(String cacheName)
A cache is considered to exist if it has been created and started via
one of the
CacheContainer.getCache() methods and has not yet been removed via
removeCache(String) . |
Configuration |
defineConfiguration(String cacheName,
Configuration configuration)
Defines a named cache's configuration by using the provided configuration
Unlike previous versions of Infinispan, this method does not build on an existing configuration (default or named).
|
Configuration |
defineConfiguration(String cacheName,
String templateCacheName,
Configuration configurationOverride)
Defines a named cache's configuration using by first reading the template configuration and then applying
the override afterwards to generate a configuration.
|
default ClusterExecutor |
executor()
Providess the cache manager based executor.
|
Address |
getAddress() |
<K,V> Cache<K,V> |
getCache(String cacheName,
boolean createIfAbsent)
Retrieves a named cache from the system in the same way that
CacheContainer.getCache(String) does except that if offers the possibility for the
named cache not to be retrieved if it has not yet been started, or if
it's been removed after being started. |
<K,V> Cache<K,V> |
getCache(String cacheName,
String configurationName)
Deprecated.
as of 9.0. Use
defineConfiguration(String, String, Configuration) and
CacheContainer.getCache(String) instead |
<K,V> Cache<K,V> |
getCache(String cacheName,
String configurationTemplate,
boolean createIfAbsent)
Deprecated.
as of 9.0. Use
defineConfiguration(String, String, Configuration) and
getCache(String, boolean) instead |
Configuration |
getCacheConfiguration(String name)
Returns the configuration for the given cache.
|
default Set<String> |
getCacheConfigurationNames()
This method returns a collection of cache configuration names which contains the
cache configurations that have been defined via XML or programmatically, and the
cache configurations that have been defined at runtime via this cache manager
instance.
|
GlobalConfiguration |
getCacheManagerConfiguration()
Returns global configuration for this CacheManager
|
Set<String> |
getCacheNames()
This method returns a collection of caches names which contains the
caches that have been defined via XML or programmatically, and the
caches that have been created at runtime via this cache manager
instance.
|
String |
getClusterName() |
Address |
getCoordinator() |
Configuration |
getDefaultCacheConfiguration()
Returns default configuration for this CacheManager
|
GlobalComponentRegistry |
getGlobalComponentRegistry() |
Health |
getHealth()
Returns an entry point for a Health Check API.
|
List<Address> |
getMembers() |
CacheContainerStats |
getStats()
Returns statistics for this cache manager
since 7.1
|
ComponentStatus |
getStatus() |
Transport |
getTransport() |
boolean |
isCoordinator() |
boolean |
isDefaultRunning()
Tests whether the default cache is running.
|
boolean |
isRunning(String cacheName)
Tests whether a named cache is running.
|
void |
removeCache(String cacheName)
Removes a cache with the given name from the system.
|
EmbeddedCacheManager |
startCaches(String... cacheNames)
Starts a set of caches in parallel.
|
void |
undefineConfiguration(String configurationName)
Removes a configuration from the set of defined configurations.
|
getCache, getCache
addListener, getListeners, removeListener
Configuration defineConfiguration(String cacheName, Configuration configuration)
ConfigurationBuilder.read(org.infinispan.configuration.cache.Configuration)
.
The other way to define named cache's configuration is declaratively, in the XML file passed in to the cache
manager.
If this cache was already configured either declaritively or programmatically this method will throw a
CacheConfigurationException
.cacheName
- name of cache whose configuration is being definedconfiguration
- configuration overrides to useConfiguration defineConfiguration(String cacheName, String templateCacheName, Configuration configurationOverride)
defineConfiguration(String, Configuration)
.
If this cache was already configured either declaritively or programmatically this method will throw a
CacheConfigurationException
.cacheName
- name of cache whose configuration is being definedtemplateCacheName
- name of cache to use as a template before overrides are applied to itconfigurationOverride
- configuration overrides to usevoid undefineConfiguration(String configurationName)
IllegalStateException
is thrown. If the named configuration does not exist, nothing
happensconfigurationName
- the named configurationString getClusterName()
Address getAddress()
Address getCoordinator()
boolean isCoordinator()
ComponentStatus getStatus()
GlobalConfiguration getCacheManagerConfiguration()
Configuration getCacheConfiguration(String name)
Configuration getDefaultCacheConfiguration()
Set<String> getCacheNames()
InternalCacheRegistry
default Set<String> getCacheConfigurationNames()
InternalCacheRegistry
boolean isRunning(String cacheName)
cacheName
- name of cache to test.boolean isDefaultRunning()
boolean cacheExists(String cacheName)
CacheContainer.getCache()
methods and has not yet been removed via
removeCache(String)
.
In environments when caches are continuously created and removed, this
method offers the possibility to find out whether a cache has either,
not been started, or if it was started, whether it's been removed already
or not.cacheName
- <K,V> Cache<K,V> getCache(String cacheName, boolean createIfAbsent)
CacheContainer.getCache(String)
does except that if offers the possibility for the
named cache not to be retrieved if it has not yet been started, or if
it's been removed after being started. If a non-template configuration
exists with the same name, it will be used to configure the cache.cacheName
- name of cache to retrievecreateIfAbsent
- if false, the named cache will not be
retrieved if it hasn't been retrieved previously or if it's been
removed. If true, this methods works just like CacheContainer.getCache(String)
<K,V> Cache<K,V> getCache(String cacheName, String configurationName)
defineConfiguration(String, String, Configuration)
and
CacheContainer.getCache(String)
insteadCacheContainer.getCache(String)
does except that if offers the possibility to specify
a specific configuration template. Multiple caches can be created using
the same configuration.cacheName
- name of cache to retrieveconfigurationName
- name of the configuration template to use<K,V> Cache<K,V> getCache(String cacheName, String configurationTemplate, boolean createIfAbsent)
defineConfiguration(String, String, Configuration)
and
getCache(String, boolean)
insteadCacheContainer.getCache(String)
does except that if offers the possibility to specify
a specific configuration template. Multiple caches can be created using
the same configuration. Tihs method also offers the possibility for the
named cache not to be retrieved if it has not yet been started, or if
it's been removed after being started.cacheName
- name of cache to retrieveconfigurationTemplate
- name of the configuration template to usecreateIfAbsent
- if false, the named cache will not be
retrieved if it hasn't been retrieved previously or if it's been
removed. If true, this methods works just like getCache(String, String)
EmbeddedCacheManager startCaches(String... cacheNames)
cacheNames
- the names of the caches to startvoid removeCache(String cacheName)
cacheName
- name of cache to removeTransport getTransport()
GlobalComponentRegistry getGlobalComponentRegistry()
void addCacheDependency(String from, String to)
from
- cache nameto
- cache nameCacheContainerStats getStats()
default ClusterExecutor executor()
Note that not all EmbeddedCacheManager
implementations may implement this. Those that don't will throw
a UnsupportedOperationException
upon invocation.
Health getHealth()
EmbeddedCacheManager
.Copyright © 2017 JBoss, a division of Red Hat. All rights reserved.