Package org.infinispan.manager
Interface EmbeddedCacheManager
- 
- All Superinterfaces:
- AutoCloseable,- BasicCacheContainer,- CacheContainer,- Closeable,- Lifecycle,- Listenable
 - All Known Implementing Classes:
- DefaultCacheManager
 
 public interface EmbeddedCacheManager extends CacheContainer, Listenable, Closeable EmbeddedCacheManager is an CacheManager that runs in the same JVM as the client. Constructing a EmbeddedCacheManager is done via one of its constructors, which optionally take in aConfigurationor a path or URL to a configuration XML file: seeDefaultCacheManager. Lifecycle - EmbeddedCacheManagers have a lifecycle (it implementsLifecycle) and the default constructors also callLifecycle.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 readWriteMap 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.- Since:
- 4.1
- Author:
- Manik Surtani (manik@jboss.org), Galder Zamarreno, Mircea.Markus@jboss.com
- See Also:
- DefaultCacheManager
 
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description voidaddCacheDependency(String from, String to)Add a dependency between two caches.default EmbeddedCacheManagerAdminadministration()Provides anEmbeddedCacheManagerAdminwhose methods affect the entire cluster as opposed to a single node.booleancacheExists(String cacheName)A cache is considered to exist if it has been created and started via one of thegetCache()methods and has not yet been removed viaremoveCache(String).<K,V>
 Cache<K,V>createCache(String name, Configuration configuration)Creates a cache on the local node using the supplied configuration.ConfigurationdefineConfiguration(String cacheName, String templateCacheName, Configuration configurationOverride)Defines a cache configuration by first reading the template configuration and then applying the override.ConfigurationdefineConfiguration(String cacheName, Configuration configuration)Register a cache configuration in the cache manager.default ClusterExecutorexecutor()Providess the cache manager based executor.org.infinispan.remoting.transport.AddressgetAddress()Warning: the address may benullbefore the first clustered cache starts and after all the clustered caches have been stopped.<K,V>
 Cache<K,V>getCache()Retrieves the default cache associated with this cache container.<K,V>
 Cache<K,V>getCache(String cacheName)Retrieves a cache by name.<K,V>
 Cache<K,V>getCache(String cacheName, boolean createIfAbsent)Similar togetCache(String), except if has the option to not create the cache if it is not already running.<K,V>
 Cache<K,V>getCache(String cacheName, String configurationName)Deprecated.as of 9.0.<K,V>
 Cache<K,V>getCache(String cacheName, String configurationTemplate, boolean createIfAbsent)Deprecated.as of 9.0.ConfigurationgetCacheConfiguration(String name)Returns the configuration for the given cache.default Set<String>getCacheConfigurationNames()This method returns a collection of all cache configuration names.GlobalConfigurationgetCacheManagerConfiguration()Returns global configuration for this CacheManagerCacheManagerInfogetCacheManagerInfo()ClassWhiteListgetClassWhiteList()StringgetClusterName()org.infinispan.remoting.transport.AddressgetCoordinator()ConfigurationgetDefaultCacheConfiguration()org.infinispan.factories.GlobalComponentRegistrygetGlobalComponentRegistry()Deprecated.Since 10.0, with no public API replacementorg.infinispan.health.HealthgetHealth()Returns an entry point for a Health Check API.List<org.infinispan.remoting.transport.Address>getMembers()CacheContainerStatsgetStats()Deprecated.Since 10.1.3.ComponentStatusgetStatus()SubjectgetSubject()org.infinispan.remoting.transport.TransportgetTransport()Deprecated.booleanisCoordinator()booleanisDefaultRunning()Tests whether the default cache is running.booleanisRunning(String cacheName)Tests whether a cache is running.voidremoveCache(String cacheName)Deprecated.Since 9.2, obtain aCacheContainerAdmininstance usingadministration()and invoke theCacheContainerAdmin.removeCache(String)methodEmbeddedCacheManagerstartCaches(String... cacheNames)Starts a set of caches in parallel.voidundefineConfiguration(String configurationName)Removes a configuration from the set of defined configurations.EmbeddedCacheManagerwithSubject(Subject subject)- 
Methods inherited from interface org.infinispan.commons.api.BasicCacheContainergetCacheNames
 - 
Methods inherited from interface org.infinispan.notifications.ListenableaddListener, addListenerAsync, getListeners, removeListener, removeListenerAsync
 
- 
 
- 
- 
- 
Method Detail- 
defineConfigurationConfiguration defineConfiguration(String cacheName, Configuration configuration) Register a cache configuration in the cache manager. The configuration will be automatically used when creating a cache with the same name, unless it is a template. If it is a template and it contains wildcards (`*` or `?`), it will be automatically used when creating caches that match the template. In order to extend an existing configuration, useConfigurationBuilder.read(org.infinispan.configuration.cache.Configuration). The other way to define a cache configuration is declaratively, in the XML file passed in to the cache manager.- Parameters:
- cacheName- name of the cache configuration
- configuration- the cache configuration
- Returns:
- the cache configuration
- Throws:
- CacheConfigurationException- if a configuration with the same name already exists.
 
 - 
defineConfigurationConfiguration defineConfiguration(String cacheName, String templateCacheName, Configuration configurationOverride) Defines a cache configuration by first reading the template configuration and then applying the override. The configuration will be automatically used when creating a cache with the same name, unless it is a template. If it is a template and it contains wildcards (`*` or `?`), it will be automatically used when creating caches that match the template. The other way to define a cache configuration is declaratively, in the XML file passed in to the cache manager. If templateName is null, this method works exactly likedefineConfiguration(String, Configuration).- Parameters:
- cacheName- name of cache whose configuration is being defined
- templateCacheName- configuration to use as a template
- configurationOverride- configuration overrides on top of the template
- Returns:
- the configuration
- Throws:
- CacheConfigurationException- if a configuration with the same name already exists.
 
 - 
undefineConfigurationvoid undefineConfiguration(String configurationName) Removes a configuration from the set of defined configurations. If the named configuration does not exist, nothing happens.- Parameters:
- configurationName- the named configuration
- Throws:
- IllegalStateException- if the configuration is in use
 
 - 
getClusterNameString getClusterName() - Returns:
- the name of the cluster. Null if running in local mode.
 
 - 
getMembersList<org.infinispan.remoting.transport.Address> getMembers() - Returns:
- the addresses of all the members in the cluster, or nullif not connected
 
 - 
getAddressorg.infinispan.remoting.transport.Address getAddress() Warning: the address may benullbefore the first clustered cache starts and after all the clustered caches have been stopped.- Returns:
- the address of the local node, or nullif not connected
 
 - 
getCoordinatororg.infinispan.remoting.transport.Address getCoordinator() - Returns:
- the address of the cluster's coordinator, or nullif not connected
 
 - 
isCoordinatorboolean isCoordinator() - Returns:
- whether the local node is the cluster's coordinator, or nullif not connected
 
 - 
getStatusComponentStatus getStatus() - Returns:
- the status of the cache manager
 
 - 
getCacheManagerConfigurationGlobalConfiguration getCacheManagerConfiguration() Returns global configuration for this CacheManager- Returns:
- the global configuration object associated to this CacheManager
 
 - 
getCacheConfigurationConfiguration getCacheConfiguration(String name) Returns the configuration for the given cache.- Returns:
- the configuration for the given cache or null if no such cache is defined
 
 - 
getDefaultCacheConfigurationConfiguration getDefaultCacheConfiguration() - Returns:
- the default cache's configuration, or nullif there is no default cache.
 
 - 
getCacheConfigurationNamesdefault Set<String> getCacheConfigurationNames() This method returns a collection of all cache configuration names. The configurations may have been defined via XML, programmatically viaConfigurationBuilderHolder, or at runtime viadefineConfiguration(String, Configuration). Internal caches defined viaInternalCacheRegistryare not included.- Returns:
- an immutable set of configuration names registered in this cache manager.
- Since:
- 8.2
 
 - 
isRunningboolean isRunning(String cacheName) Tests whether a cache is running.- Parameters:
- cacheName- name of cache to test.
- Returns:
- true if the cache exists and is running; false otherwise.
 
 - 
isDefaultRunningboolean isDefaultRunning() Tests whether the default cache is running.- Returns:
- true if the default cache is running; false otherwise.
 
 - 
cacheExistsboolean cacheExists(String cacheName) A cache is considered to exist if it has been created and started via one of thegetCache()methods and has not yet been removed viaremoveCache(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.- Parameters:
- cacheName- cache to check
- Returns:
- true if the cache with the given name has not yet been started, or if it was started, whether it's been removed or not.
 
 - 
getCache<K,V> Cache<K,V> getCache() Retrieves the default cache associated with this cache container.- Specified by:
- getCachein interface- BasicCacheContainer
- Specified by:
- getCachein interface- CacheContainer
- Returns:
- the default cache.
- Throws:
- CacheConfigurationException- if a default cache does not exist.
 
 - 
getCache<K,V> Cache<K,V> getCache(String cacheName) Retrieves a cache by name. If the cache has been previously created with the same name, the running cache instance is returned. Otherwise, this method attempts to create the cache first. When creating a new cache, this method requires a defined configuration that either has exactly the same name, or is a template with wildcards and matches the cache name.- Specified by:
- getCachein interface- BasicCacheContainer
- Specified by:
- getCachein interface- CacheContainer
- Parameters:
- cacheName- name of cache to retrieve
- Returns:
- a cache instance identified by cacheName
 
 - 
createCache<K,V> Cache<K,V> createCache(String name, Configuration configuration) Creates a cache on the local node using the supplied configuration. The cache may be clustered, but this method (or the equivalent combination ofdefineConfiguration(String, Configuration)andgetCache(String, boolean)) needs to be invoked on all nodes.- Type Parameters:
- K- the generic type of the key
- V- the generic type of the value
- Parameters:
- name- the name of the cache
- configuration- the configuration to use.
- Returns:
- the cache
 
 - 
getCache<K,V> Cache<K,V> getCache(String cacheName, boolean createIfAbsent) Similar togetCache(String), except if has the option to not create the cache if it is not already running.- Parameters:
- cacheName- name of cache to retrieve
- createIfAbsent- if false, the cache must be running. If true, this methods works just like- getCache(String).
- Returns:
- null if the cache does not exist and createIfAbsent == false, otherwise a cache instance identified by cacheName
 
 - 
getCache<K,V> Cache<K,V> getCache(String cacheName, String configurationName) Deprecated.as of 9.0. UsedefineConfiguration(String, String, Configuration)andgetCache(String)insteadSimilar togetCache(String), only with an explicit configuration template name. Multiple caches can be created using the same configuration.- Parameters:
- cacheName- name of cache to retrieve
- configurationName- name of the configuration template to use
- Returns:
- a cache instance identified by cacheName
- Throws:
- CacheConfigurationException- if the configuration does not exist or if a configuration named cacheName already exists.
 
 - 
getCache<K,V> Cache<K,V> getCache(String cacheName, String configurationTemplate, boolean createIfAbsent) Deprecated.as of 9.0. UsedefineConfiguration(String, String, Configuration)andgetCache(String, boolean)insteadSimilar togetCache(String, boolean), only with an explicit configuration template name. Multiple caches can be created using the same configuration.- Parameters:
- cacheName- name of cache to retrieve
- configurationTemplate- name of the configuration template to use
- createIfAbsent- if false, the cache must be running. If true, this methods works just like- getCache(String).
- Returns:
- null if the cache does not exist and createIfAbsent == false, otherwise a cache instance identified by cacheName
- Throws:
- CacheConfigurationException- if the configuration does not exist or if a configuration named cacheName already exists.
 
 - 
startCachesEmbeddedCacheManager startCaches(String... cacheNames) Starts a set of caches in parallel. Infinispan supports both symmetric and asymmetric clusters; that is, multiple nodes having the same or different sets of caches running, respectively. Calling this method on application/application server startup with all your cache names will ensure that the cluster is symmetric.- Parameters:
- cacheNames- the names of the caches to start
- Since:
- 5.0
 
 - 
removeCache@Deprecated void removeCache(String cacheName) Deprecated.Since 9.2, obtain aCacheContainerAdmininstance usingadministration()and invoke theCacheContainerAdmin.removeCache(String)methodRemoves a cache with the given name from the system. This is a cluster wide operation that results not only in stopping the cache with the given name in all nodes in the cluster, but also deletes its contents both in memory and in any backing cache store.- Parameters:
- cacheName- name of cache to remove
 
 - 
getTransportorg.infinispan.remoting.transport.Transport getTransport() Deprecated.
 - 
getGlobalComponentRegistry@Deprecated org.infinispan.factories.GlobalComponentRegistry getGlobalComponentRegistry() Deprecated.Since 10.0, with no public API replacement
 - 
addCacheDependencyvoid addCacheDependency(String from, String to) Add a dependency between two caches. The cache manager will make sure that a cache is stopped before any of its dependencies- Parameters:
- from- cache name
- to- cache name
- Since:
- 7.0
 
 - 
getStats@Deprecated CacheContainerStats getStats() Deprecated.Since 10.1.3. This mixes statistics across unrelated caches so the reported numbers don't have too much relevance.Returns statistics for this cache manager- Returns:
- statistics for this cache manager
- Since:
- 7.1
 
 - 
executordefault ClusterExecutor executor() Providess the cache manager based executor. This can be used to execute a given operation upon the cluster or a single node if desired. If this manager is not clustered this will execute locally only.Note that not all EmbeddedCacheManagerimplementations may implement this. Those that don't will throw aUnsupportedOperationExceptionupon invocation.- Returns:
 
 - 
getHealthorg.infinispan.health.Health getHealth() Returns an entry point for a Health Check API.- Returns:
- Health API for this EmbeddedCacheManager.
- Since:
- 9.0
 
 - 
getCacheManagerInfoCacheManagerInfo getCacheManagerInfo() - Returns:
- an instance of CacheManagerInfoused to get basic info about the cache manager.
 
 - 
administrationdefault EmbeddedCacheManagerAdmin administration() Provides anEmbeddedCacheManagerAdminwhose methods affect the entire cluster as opposed to a single node.- Specified by:
- administrationin interface- CacheContainer
- Returns:
- a cluster-aware EmbeddedCacheManagerAdmin
- Since:
- 9.2
 
 - 
getClassWhiteListClassWhiteList getClassWhiteList() 
 - 
getSubjectSubject getSubject() 
 - 
withSubjectEmbeddedCacheManager withSubject(Subject subject) 
 
- 
 
-