@ThreadSafe public final class JcrRepositoriesContainer extends Object implements RepositoriesContainer
RepositoriesContainer
interface.Modifier and Type | Class and Description |
---|---|
protected class |
JcrRepositoriesContainer.JNDIRepositoryLookup |
protected class |
JcrRepositoriesContainer.UrlRepositoryLookup |
Modifier and Type | Field and Description |
---|---|
protected static ModeShapeEngine |
ENGINE
The engine that hosts the deployed repository instances.
|
protected static String |
FILE_PROTOCOL |
protected static String |
JNDI_PROTOCOL |
protected static Logger |
LOG |
protected static String |
REPOSITORY_NAME_URL_PARAM |
REPOSITORY_NAME, URL
Constructor and Description |
---|
JcrRepositoriesContainer() |
Modifier and Type | Method and Description |
---|---|
protected ModeShapeEngine |
engine() |
JcrRepository |
getRepository(String repositoryName,
Map parameters)
Return the JCR Repository with the supplied name and an optional map of parameters which can be used to initialize the
repository.
|
Set<String> |
getRepositoryNames(Map<?,?> parameters)
Returns the names of all the available repositories, using an optional map of parameters which may be used to initialize
additional repositories, which will also be returned.
|
protected String |
repositoryNameFrom(String url,
Map<?,?> parameters) |
Future<Boolean> |
shutdown()
Shutdown this engine to stop all repositories created by calls to
RepositoriesContainer.getRepository(String, java.util.Map) , terminate any ongoing
background operations (such as sequencing), and reclaim any resources that were acquired by the repositories. |
boolean |
shutdown(long timeout,
TimeUnit unit)
Shutdown this engine to stop all repositories created by calls to
RepositoriesContainer.getRepository(String, java.util.Map) , terminate any ongoing
background operations (such as sequencing), and reclaim any resources that were acquired by the repositories. |
Future<Boolean> |
shutdownRepository(String repositoryName)
Asynchronously shutdown the deployed
Repository instance with the given the name, and return a future that will
return whether the Repository instance is shutdown. |
protected static final Logger LOG
protected static final String REPOSITORY_NAME_URL_PARAM
protected static final String FILE_PROTOCOL
protected static final String JNDI_PROTOCOL
protected static final ModeShapeEngine ENGINE
public JcrRepository getRepository(String repositoryName, Map parameters) throws RepositoryException
RepositoriesContainer
getRepository
in interface RepositoriesContainer
repositoryName
- the name of the repository to return; may be null
if, for example, the parameters map already
contains this information.parameters
- map of string key/value pairs as repository arguments. My be null
if no configuration parameters
exist.null
if no repository is foundRepositoryException
- if there is an error communicating with the repositoryRepositoryFactory.getRepository(java.util.Map)
public Set<String> getRepositoryNames(Map<?,?> parameters) throws RepositoryException
RepositoriesContainer
getRepositoryNames
in interface RepositoriesContainer
parameters
- map of string key/value pairs as repository arguments or null
if none are providednull
RepositoryException
- if there is an error performing the lookup.RepositoryFactory.getRepository(java.util.Map)
public Future<Boolean> shutdown()
RepositoriesContainer
RepositoriesContainer.getRepository(String, java.util.Map)
, terminate any ongoing
background operations (such as sequencing), and reclaim any resources that were acquired by the repositories. This method
may be called multiple times, but only the first time has an effect.
Invoking this method does not preclude creating new Repository
instances with future calls to
RepositoriesContainer.getRepository(String, java.util.Map)
. Any caller using this method as part of an application shutdown process should take care to
cease invocations of RepositoriesContainer.getRepository(String, java.util.Map)
prior to invoking this method.
This method returns immediately, even before the repositories have been shut down. However, the caller can simply call the
get()
method on the returned Future
to block until all repositories have shut down. Note that
the Future.get(long, java.util.concurrent.TimeUnit)
method can be called to block for a maximum amount of time.
shutdown
in interface RepositoriesContainer
getting
the repository from the future, where the exception is wrapped in a
ExecutionException
. The value returned from the future will always be true if the engine shutdown (or was
not running), or false if the engine is still running.public boolean shutdown(long timeout, TimeUnit unit) throws InterruptedException
RepositoriesContainer
RepositoriesContainer.getRepository(String, java.util.Map)
, terminate any ongoing
background operations (such as sequencing), and reclaim any resources that were acquired by the repositories. This method
may be called multiple times, but only the first time has an effect.
This method is equivalent to calling "shutdown().get(timeout,unit)
" on this method.
Invoking this method does not preclude creating new Repository
instances with future calls to
RepositoriesContainer.getRepository(String, java.util.Map)
. Any caller using this method as part of an application shutdown process should take care to
cease invocations of RepositoriesContainer.getRepository(String, java.util.Map)
prior to invoking this method.
This method waits until all the repositories have been successfully shut-down, or the given timeout has elapsed.
shutdown
in interface RepositoriesContainer
timeout
- the maximum time per engine to allow for shutdownunit
- the time unit of the timeout argumentInterruptedException
- if interrupted while waitingpublic Future<Boolean> shutdownRepository(String repositoryName) throws RepositoryException
RepositoriesContainer
Repository
instance with the given the name, and return a future that will
return whether the Repository instance is shutdown. If the Repository is not running, the resulting future will return
immediately.
Note that the caller does not have to wait for the shutdown to completed. However, to do so the caller merely calls
get()
or get(long,TimeUnit)
on the future to return a boolean flag
specifying whether the Repository instance is shutdown (not running). Note that any exceptions thrown during the shutdown
will be wrapped in an ExecutionException
thrown by the Future's get
methods.
shutdownRepository
in interface RepositoriesContainer
repositoryName
- the name of the deployed repositoryFuture.get()
will return whether theRepositoryException
- if there is no repository with the specified name or if any other unexpected error occurs.protected ModeShapeEngine engine()
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.