public class LocalEnvironment extends Object implements Environment
Environment that can be used within a local (non-clustered) process.
To use a custom Environment instance, simply create a RepositoryConfiguration as usual but then call the
RepositoryConfiguration.with(Environment) with the Environment instance and then use the resulting
RepositoryConfiguration instance.
When a ModeShape repository configuration defines cache containers with configuration files on
the file system or the classpath, then a LocalEnvironment instance can be used as-is with no other configuration or
setup.
If applications wish to programmatically configure the Infinispan caches or cache containers, then those configurations can be
registered with a LocalEnvironment instance. Specifically, the addCacheContainer(String, CacheContainer) and
addCacheContainerIfAbsent(String, CacheContainer) methods register a programmatically created instance of a
CacheContainer. Alternatively, the defineCache(String, String, Configuration) method can be used to register a
named cache with a programmatically created Infinispan cache configuration.
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_CONFIGURATION_NAME
The name for the default cache container that is used when
getCacheContainer() is called or if null is supplied as
the name in getCacheContainer(String). |
static Class<? extends org.infinispan.transaction.lookup.TransactionManagerLookup> |
DEFAULT_TRANSACTION_MANAGER_LOOKUP_CLASS |
| Constructor and Description |
|---|
LocalEnvironment() |
LocalEnvironment(Class<? extends org.infinispan.transaction.lookup.TransactionManagerLookup> transactionManagerLookupClass) |
| Modifier and Type | Method and Description |
|---|---|
org.infinispan.manager.CacheContainer |
addCacheContainer(String name,
org.infinispan.manager.CacheContainer cacheContainer)
Add the supplied
CacheContainer under the supplied name if and only if there is not already a cache container
registered at that name. |
void |
addCacheContainerIfAbsent(String name,
org.infinispan.manager.CacheContainer cacheContainer)
Add the supplied
CacheContainer under the supplied name if and only if there is not already a cache container
registered at that name. |
protected org.infinispan.manager.CacheContainer |
createContainer(org.infinispan.configuration.global.GlobalConfigurationBuilder globalConfigurationBuilder,
org.infinispan.configuration.cache.ConfigurationBuilder configurationBuilder)
Create a cache container using the supplied configurations.
|
protected org.infinispan.manager.CacheContainer |
createContainer(org.infinispan.configuration.global.GlobalConfiguration globalConfiguration,
org.infinispan.configuration.cache.Configuration configuration)
Deprecated.
|
protected org.infinispan.manager.CacheContainer |
createContainer(String configFile) |
protected org.infinispan.configuration.cache.Configuration |
createDefaultConfiguration()
Deprecated.
|
protected org.infinispan.configuration.cache.ConfigurationBuilder |
createDefaultConfigurationBuilder()
Create the default configuration.
|
protected org.infinispan.configuration.global.GlobalConfiguration |
createGlobalConfiguration()
Deprecated.
|
protected org.infinispan.configuration.global.GlobalConfigurationBuilder |
createGlobalConfigurationBuilder()
Create the global configuration.
|
org.infinispan.configuration.cache.Configuration |
defineCache(String cacheName,
org.infinispan.configuration.cache.Configuration configuration)
Define within the default cache container an Infinispan cache with the given cache name and configuration.
|
org.infinispan.configuration.cache.Configuration |
defineCache(String cacheContainerName,
String cacheName,
org.infinispan.configuration.cache.Configuration configuration)
Define within the named cache container an Infinispan cache with the given cache name and configuration.
|
protected void |
doShutdown()
Shutdown all containers and caches.
|
org.infinispan.manager.CacheContainer |
getCacheContainer()
Get the default cache container.
|
org.infinispan.manager.CacheContainer |
getCacheContainer(String name)
Get the cache container with the given name.
|
org.jgroups.Channel |
getChannel(String name)
Get the JGroups channel with the given logical name.
|
ClassLoader |
getClassLoader(ClassLoader fallbackLoader,
String... classpathEntries)
Get a classloader given the supplied set of logical classpath entries, which the implementation can interpret however it
needs.
|
boolean |
isShared()
Return whether this environment is shared amongst multiple repositories.
|
protected Context |
jndiContext() |
void |
setShared(boolean shared)
Set whether this environment is shared amongst multiple repositories.
|
void |
shutdown()
Shutdown this environment, allowing it to reclaim any resources.
|
protected void |
shutdown(org.infinispan.manager.CacheContainer container) |
protected Class<? extends org.infinispan.transaction.lookup.TransactionManagerLookup> |
transactionManagerLookupClass() |
protected org.infinispan.transaction.lookup.TransactionManagerLookup |
transactionManagerLookupInstance() |
public static final Class<? extends org.infinispan.transaction.lookup.TransactionManagerLookup> DEFAULT_TRANSACTION_MANAGER_LOOKUP_CLASS
public static final String DEFAULT_CONFIGURATION_NAME
getCacheContainer() is called or if null is supplied as
the name in getCacheContainer(String).public LocalEnvironment()
public LocalEnvironment(Class<? extends org.infinispan.transaction.lookup.TransactionManagerLookup> transactionManagerLookupClass)
public org.infinispan.manager.CacheContainer getCacheContainer()
throws IOException,
NamingException
IOExceptionNamingExceptionpublic org.infinispan.manager.CacheContainer getCacheContainer(String name) throws IOException, NamingException
EnvironmentgetCacheContainer in interface Environmentname - the name of the cache container; may be nullIOException - if there is an error accessing any resources required to start the containerNamingException - if there is an error accessing JNDI (if that is used in the implementation)public org.jgroups.Channel getChannel(String name)
EnvironmentgetChannel in interface Environmentname - the name of the channel; may not be nullpublic void shutdown()
This method does nothing if the environment has been marked as shared.
shutdown in interface Environmentprotected void doShutdown()
public ClassLoader getClassLoader(ClassLoader fallbackLoader, String... classpathEntries)
EnvironmentgetClassLoader in interface EnvironmentfallbackLoader - the classloader that should be used is the fallback class loaderclasspathEntries - the logical classpath entriesprotected void shutdown(org.infinispan.manager.CacheContainer container)
protected Class<? extends org.infinispan.transaction.lookup.TransactionManagerLookup> transactionManagerLookupClass()
protected org.infinispan.transaction.lookup.TransactionManagerLookup transactionManagerLookupInstance()
protected org.infinispan.manager.CacheContainer createContainer(String configFile) throws IOException, NamingException
IOExceptionNamingExceptionprotected org.infinispan.configuration.cache.ConfigurationBuilder createDefaultConfigurationBuilder()
protected org.infinispan.configuration.global.GlobalConfigurationBuilder createGlobalConfigurationBuilder()
protected org.infinispan.manager.CacheContainer createContainer(org.infinispan.configuration.global.GlobalConfigurationBuilder globalConfigurationBuilder,
org.infinispan.configuration.cache.ConfigurationBuilder configurationBuilder)
globalConfigurationBuilder - the global configuration builderconfigurationBuilder - the default cache configuration builder@Deprecated protected org.infinispan.configuration.cache.Configuration createDefaultConfiguration()
createDefaultConfigurationBuilder()@Deprecated protected org.infinispan.configuration.global.GlobalConfiguration createGlobalConfiguration()
createGlobalConfigurationBuilder()@Deprecated protected org.infinispan.manager.CacheContainer createContainer(org.infinispan.configuration.global.GlobalConfiguration globalConfiguration, org.infinispan.configuration.cache.Configuration configuration)
createContainer(GlobalConfigurationBuilder, ConfigurationBuilder) insteadglobalConfiguration - the global configurationconfiguration - the default cache configurationprotected Context jndiContext() throws NamingException
NamingExceptionpublic void addCacheContainerIfAbsent(String name, org.infinispan.manager.CacheContainer cacheContainer)
CacheContainer under the supplied name if and only if there is not already a cache container
registered at that name.name - the cache container name; may be null if the default configuration name
should be usedcacheContainer - the cache container; may not be nullpublic org.infinispan.manager.CacheContainer addCacheContainer(String name, org.infinispan.manager.CacheContainer cacheContainer)
CacheContainer under the supplied name if and only if there is not already a cache container
registered at that name.name - the cache container name; may be null if the default configuration name
should be usedcacheContainer - the cache container; may not be nullpublic org.infinispan.configuration.cache.Configuration defineCache(String cacheName, org.infinispan.configuration.cache.Configuration configuration)
EmbeddedCacheManager interface for
this method to succeed.cacheName - the name of the cache being defined; may not be nullconfiguration - the cache configuration; may not be nullpublic org.infinispan.configuration.cache.Configuration defineCache(String cacheContainerName, String cacheName, org.infinispan.configuration.cache.Configuration configuration)
EmbeddedCacheManager interface for
this method to succeed.cacheContainerName - the name of the cache container; if null, the default
container name is usedcacheName - the name of the cache being defined; may not be nullconfiguration - the cache configuration; may not be nullpublic void setShared(boolean shared)
true.shared - true if this environment is shared, or false otherwiseisShared()public boolean isShared()
setShared(boolean)Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.