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 TransactionManagerLookup> |
DEFAULT_TRANSACTION_MANAGER_LOOKUP_CLASS |
Constructor and Description |
---|
LocalEnvironment() |
LocalEnvironment(Class<? extends TransactionManagerLookup> transactionManagerLookupClass) |
Modifier and Type | Method and Description |
---|---|
CacheContainer |
addCacheContainer(String name,
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,
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 CacheContainer |
createContainer(GlobalConfigurationBuilder globalConfigurationBuilder,
ConfigurationBuilder configurationBuilder)
Create a cache container using the supplied configurations.
|
protected CacheContainer |
createContainer(GlobalConfiguration globalConfiguration,
Configuration configuration)
Deprecated.
|
protected CacheContainer |
createContainer(String configFile) |
protected Configuration |
createDefaultConfiguration()
Deprecated.
|
protected ConfigurationBuilder |
createDefaultConfigurationBuilder()
Create the default configuration.
|
protected GlobalConfiguration |
createGlobalConfiguration()
Deprecated.
|
protected GlobalConfigurationBuilder |
createGlobalConfigurationBuilder()
Create the global configuration.
|
Configuration |
defineCache(String cacheName,
Configuration configuration)
Define within the default cache container an Infinispan cache with the given cache name and configuration.
|
Configuration |
defineCache(String cacheContainerName,
String cacheName,
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.
|
CacheContainer |
getCacheContainer()
Get the default cache container.
|
CacheContainer |
getCacheContainer(String name)
Get the cache container with the given 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(CacheContainer container) |
protected Class<? extends TransactionManagerLookup> |
transactionManagerLookupClass() |
protected TransactionManagerLookup |
transactionManagerLookupInstance() |
public static final Class<? extends 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 TransactionManagerLookup> transactionManagerLookupClass)
public CacheContainer getCacheContainer() throws IOException, NamingException
IOException
NamingException
public CacheContainer getCacheContainer(String name) throws IOException, NamingException
Environment
getCacheContainer
in interface Environment
name
- 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 void shutdown()
This method does nothing if the environment has been marked as shared
.
shutdown
in interface Environment
protected void doShutdown()
public ClassLoader getClassLoader(ClassLoader fallbackLoader, String... classpathEntries)
Environment
getClassLoader
in interface Environment
fallbackLoader
- the classloader that should be used is the fallback class loaderclasspathEntries
- the logical classpath entriesprotected void shutdown(CacheContainer container)
protected Class<? extends TransactionManagerLookup> transactionManagerLookupClass()
protected TransactionManagerLookup transactionManagerLookupInstance()
protected CacheContainer createContainer(String configFile) throws IOException, NamingException
IOException
NamingException
protected ConfigurationBuilder createDefaultConfigurationBuilder()
protected GlobalConfigurationBuilder createGlobalConfigurationBuilder()
protected CacheContainer createContainer(GlobalConfigurationBuilder globalConfigurationBuilder, ConfigurationBuilder configurationBuilder)
globalConfigurationBuilder
- the global configuration builderconfigurationBuilder
- the default cache configuration builder@Deprecated protected Configuration createDefaultConfiguration()
createDefaultConfigurationBuilder()
@Deprecated protected GlobalConfiguration createGlobalConfiguration()
createGlobalConfigurationBuilder()
@Deprecated protected CacheContainer createContainer(GlobalConfiguration globalConfiguration, Configuration configuration)
createContainer(GlobalConfigurationBuilder, ConfigurationBuilder)
insteadglobalConfiguration
- the global configurationconfiguration
- the default cache configurationprotected Context jndiContext() throws NamingException
NamingException
public void addCacheContainerIfAbsent(String name, 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 CacheContainer addCacheContainer(String name, 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 Configuration defineCache(String cacheName, 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 Configuration defineCache(String cacheContainerName, String cacheName, 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.