org.infinispan.manager
Interface EmbeddedCacheManager

All Superinterfaces:
BasicCacheContainer, CacheContainer, Lifecycle, Listenable
All Known Subinterfaces:
CacheManager
All Known Implementing Classes:
AbstractDelegatingEmbeddedCacheManager, DefaultCacheManager

public interface EmbeddedCacheManager
extends CacheContainer, Listenable

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 a 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.

Since:
4.1
Author:
Manik Surtani (manik@jboss.org), Galder Zamarreno, Mircea.Markus@jboss.com
See Also:
DefaultCacheManager

Field Summary
 
Fields inherited from interface org.infinispan.api.BasicCacheContainer
DEFAULT_CACHE_NAME
 
Method Summary
 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 configurationOverride)
          Deprecated. Use #defineConfiguration(String, String, org.infinispan.configuration.cache.Configuration) instead
 Configuration defineConfiguration(String cacheName, Configuration configurationOverride)
          Defines a named cache's configuration using the following algorithm:

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)
          Deprecated. Use defineConfiguration(String, org.infinispan.configuration.cache.Configuration) instead
 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.
 Configuration getCacheConfiguration(String name)
          Returns the configuration for the given cache.
 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
 Configuration getDefaultConfiguration()
          Deprecated. 
 GlobalConfiguration getGlobalConfiguration()
          Returns global configuration for this CacheManager
 List<Address> getMembers()
           
 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.
 
Methods inherited from interface org.infinispan.manager.CacheContainer
getCache, getCache
 
Methods inherited from interface org.infinispan.lifecycle.Lifecycle
start, stop
 
Methods inherited from interface org.infinispan.notifications.Listenable
addListener, getListeners, removeListener
 

Method Detail

defineConfiguration

@Deprecated
Configuration defineConfiguration(String cacheName,
                                             Configuration configurationOverride)
Deprecated. Use #defineConfiguration(String, String, org.infinispan.configuration.cache.Configuration) instead

Defines a named cache's configuration using the following algorithm:

If cache name hasn't been defined before, this method creates a clone of the default cache's configuration, applies a clone of the configuration overrides passed in and returns this configuration instance.

If cache name has been previously defined, this method creates a clone of this cache's existing configuration, applies a clone of the configuration overrides passed in and returns the configuration instance.

The other way to define named cache's configuration is declaratively, in the XML file passed in to the cache manager. This method enables you to override certain properties that have previously been defined via XML.

Passing a brand new Configuration instance as configuration override without having called any of its setters will effectively return the named cache's configuration since no overrides where passed to it.

Parameters:
cacheName - name of cache whose configuration is being defined
configurationOverride - configuration overrides to use
Returns:
a cloned configuration instance

defineConfiguration

Configuration defineConfiguration(String cacheName,
                                  Configuration configurationOverride)
Defines a named cache's configuration using the following algorithm:

Unlike previous versions of Infinispan, this method does not build on an existing configuration (default or named). If you want this behavior, then use 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. This method enables you to override certain properties that have previously been defined via XML.

Passing a brand new Configuration instance as configuration override without having called any of its setters will effectively return the named cache's configuration since no overrides where passed to it.

Parameters:
cacheName - name of cache whose configuration is being defined
configurationOverride - configuration overrides to use
Returns:
a cloned configuration instance

defineConfiguration

@Deprecated
Configuration defineConfiguration(String cacheName,
                                             String templateCacheName,
                                             Configuration configurationOverride)
Deprecated. Use defineConfiguration(String, org.infinispan.configuration.cache.Configuration) instead

Defines a named cache's configuration using the following algorithm:

Regardless of whether the cache name has been defined or not, this method creates a clone of the configuration of the cache whose name matches the given template cache name, then applies a clone of the configuration overrides passed in and finally returns this configuration instance.

The other way to define named cache's configuration is declaratively, in the XML file passed in to the cache manager. This method enables you to override certain properties that have previously been defined via XML.

Passing a brand new Configuration instance as configuration override without having called any of its setters will effectively return the named cache's configuration since no overrides where passed to it.

If templateName is null or there isn't any named cache with that name, this methods works exactly like defineConfiguration(String, Configuration) in the sense that the base configuration used is the default cache configuration.

Parameters:
cacheName - name of cache whose configuration is being defined
templateCacheName - name of cache to which to which apply overrides if cache name has not been previously defined
configurationOverride - configuration overrides to use
Returns:
a cloned configuration instance

getClusterName

String getClusterName()
Returns:
the name of the cluster. Null if running in local mode.

getMembers

List<Address> getMembers()
Returns:
the addresses of all the members in the cluster.

getAddress

Address getAddress()
Returns:
the address of the local node

getCoordinator

Address getCoordinator()
Returns:
the address of the cluster's coordinator

isCoordinator

boolean isCoordinator()
Returns:
whether the local node is the cluster's coordinator

getStatus

ComponentStatus getStatus()
Returns:
the status of the cache manager

getGlobalConfiguration

GlobalConfiguration getGlobalConfiguration()
Returns global configuration for this CacheManager

Returns:
the global configuration object associated to this CacheManager

getCacheManagerConfiguration

GlobalConfiguration getCacheManagerConfiguration()
Returns global configuration for this CacheManager

Returns:
the global configuration object associated to this CacheManager

getCacheConfiguration

Configuration 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

getDefaultConfiguration

@Deprecated
Configuration getDefaultConfiguration()
Deprecated. 

Returns default configuration for this CacheManager

Returns:
the default configuration associated with this CacheManager

getDefaultCacheConfiguration

Configuration getDefaultCacheConfiguration()
Returns default configuration for this CacheManager

Returns:
the default configuration associated with this CacheManager

getCacheNames

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. If no named caches are registered or no caches have been created, this method returns an empty set. The default cache is never included in this set of cache names.

Returns:
an immutable set of non-default named caches registered or created with this cache manager.

isRunning

boolean isRunning(String cacheName)
Tests whether a named cache is running.

Parameters:
cacheName - name of cache to test.
Returns:
true if the named cache exists and is running; false otherwise.

isDefaultRunning

boolean isDefaultRunning()
Tests whether the default cache is running.

Returns:
true if the default cache is running; false otherwise.

cacheExists

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).

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 -
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(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.

Parameters:
cacheName - name of cache to retrieve
createIfAbsent - 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)
Returns:
null if no named cache exists as per rules set above, otherwise returns a cache instance identified by cacheName

startCaches

EmbeddedCacheManager startCaches(String... cacheNames)
Starts a set of caches in parallel. Infinispan doesn't yet support asymmetric clusters (that is, two nodes having different sets of caches running). 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

void removeCache(String cacheName)
Removes 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

getTransport

Transport getTransport()
Since:
5.1

-->

Copyright © 2012 JBoss, a division of Red Hat. All Rights Reserved.