@ThreadSafe public class ModeShapeEngine extends Object implements Repositories
Modifier and Type | Class and Description |
---|---|
static class |
ModeShapeEngine.State |
Constructor and Description |
---|
ModeShapeEngine() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkRunning() |
JcrRepository |
deploy(RepositoryConfiguration repositoryConfiguration)
Deploy a new repository with the given configuration.
|
protected JcrRepository |
deploy(RepositoryConfiguration repositoryConfiguration,
String repositoryKey)
Deploy a new repository with the given configuration.
|
protected boolean |
doShutdown()
Do the work of shutting down this engine and its repositories.
|
Map<String,ModeShapeEngine.State> |
getRepositories()
Get an instantaneous snapshot of the JCR repositories and their state.
|
JcrRepository |
getRepository(String repositoryName)
Get the deployed
Repository instance with the given the name. |
RepositoryConfiguration |
getRepositoryConfiguration(String repositoryName)
Get the immutable configuration for the repository with the supplied name.
|
protected Set<String> |
getRepositoryKeys() |
Set<String> |
getRepositoryNames()
Get the names of the available repositories.
|
ModeShapeEngine.State |
getRepositoryState(String repositoryName)
Get the state of the deployed
Repository instance with the given the name. |
ModeShapeEngine.State |
getState()
Get the running state of this engine.
|
protected Collection<JcrRepository> |
repositories()
Returns a copy of the repositories.
|
Future<Boolean> |
shutdown()
Shutdown this engine to stop all repositories, terminate any ongoing background operations (such as sequencing), and
reclaim any resources that were acquired by this engine.
|
Future<Boolean> |
shutdown(boolean forceShutdownOfAllRepositories)
Shutdown this engine, optionally stopping all still-running 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. |
void |
start()
Start this engine to make it available for use.
|
Future<JcrRepository> |
startRepository(String repositoryName)
Asynchronously start the deployed
Repository instance with the given the name, and return a future that will return
the Repository instance. |
Future<Boolean> |
undeploy(String repositoryName)
Stop and undeploy the named
Repository . |
Future<JcrRepository> |
update(String repositoryName,
Changes changes)
Update the configuration of a deployed repository by applying the set of changes to that repository's configuration.
|
protected final boolean checkRunning()
public ModeShapeEngine.State getState()
public void start()
shutdown()
public Future<Boolean> shutdown()
This is equivalent to calling shutdown(true)
getting
the result 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.start()
public Future<Boolean> shutdown(boolean forceShutdownOfAllRepositories)
forceShutdownOfAllRepositories
- true if the engine should be shutdown even if there are currently-running
repositories, or false if the engine should not be shutdown if at least one repository is still running.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.start()
protected boolean doShutdown()
public final JcrRepository getRepository(String repositoryName) throws NoSuchRepositoryException
Repository
instance with the given the name.getRepository
in interface Repositories
repositoryName
- the name of the deployed repositoryIllegalArgumentException
- if the repository name is null, blank or invalidNoSuchRepositoryException
- if there is no repository with the specified nameIllegalStateException
- if this engine is not running
deploy(RepositoryConfiguration)
,
undeploy(String)
public Set<String> getRepositoryNames()
Repositories
getRepositoryNames
in interface Repositories
public final ModeShapeEngine.State getRepositoryState(String repositoryName) throws NoSuchRepositoryException
Repository
instance with the given the name.repositoryName
- the name of the deployed repositoryIllegalArgumentException
- if the repository name is null, blank or invalidNoSuchRepositoryException
- if there is no repository with the specified nameIllegalStateException
- if this engine is not running
deploy(RepositoryConfiguration)
,
undeploy(String)
public final RepositoryConfiguration getRepositoryConfiguration(String repositoryName) throws NoSuchRepositoryException
repositoryName
- the name of the deployed repositoryIllegalArgumentException
- if the repository name is null, blank or invalidNoSuchRepositoryException
- if there is no repository with the specified nameIllegalStateException
- if this engine is not running
public final Future<JcrRepository> startRepository(String repositoryName) throws NoSuchRepositoryException
Repository
instance with the given the name, and return a future that will return
the Repository instance. If the Repository is already running, this method returns a future that returns immediately.
Note that the caller does not have to wait for the startup process to complete. However, to do so the caller merely calls
get()
or get(long,TimeUnit)
on the future to return the repository
instance. Note that any exceptions thrown during the startup process will be wrapped in an ExecutionException
thrown by the Future's get
methods.
repositoryName
- the name of the deployed repositoryIllegalArgumentException
- if the repository name is null, blank or invalidNoSuchRepositoryException
- if there is no repository with the specified nameIllegalStateException
- if this engine is not running
deploy(RepositoryConfiguration)
,
undeploy(String)
public final Future<Boolean> shutdownRepository(String repositoryName) throws NoSuchRepositoryException
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.
repositoryName
- the name of the deployed repositoryFuture.get()
will return whether theIllegalArgumentException
- if the repository name is null, blank or invalidNoSuchRepositoryException
- if there is no repository with the specified nameIllegalStateException
- if this engine is not running
deploy(RepositoryConfiguration)
,
undeploy(String)
public Map<String,ModeShapeEngine.State> getRepositories()
protected Collection<JcrRepository> repositories()
public JcrRepository deploy(RepositoryConfiguration repositoryConfiguration) throws ConfigurationException, RepositoryException
repositoryConfiguration
- the configuration for the repositorystarted
before it can be used;
never nullConfigurationException
- if the configuration is not validRepositoryException
- if there is already a deployed repository with the specified name, or if there is a problem
deploying the repositoryIllegalArgumentException
- if the configuration is nulldeploy(RepositoryConfiguration)
,
update(String, Changes)
,
undeploy(String)
protected JcrRepository deploy(RepositoryConfiguration repositoryConfiguration, String repositoryKey) throws ConfigurationException, RepositoryException
repositoryConfiguration
- the configuration for the repositoryrepositoryKey
- the key by which this repository is known to this engine; may be null if the
repository's name
should be usedstarted
before it can be used;
never nullConfigurationException
- if the configuration is not validRepositoryException
- if there is already a deployed repository with the specified name, or if there is a problem
deploying the repositoryIllegalArgumentException
- if the configuration is nulldeploy(RepositoryConfiguration)
,
update(String, Changes)
,
undeploy(String)
public Future<JcrRepository> update(String repositoryName, Changes changes) throws ConfigurationException, NoSuchRepositoryException, RepositoryException
The basic outline for modifying a repository's configuration is as follows:
ModeShapeEngine engine = ... Repository deployed = engine.getRepository("repo")
; RepositoryConfiguration deployedConfig = deployed.getConfiguration()
; // Create an editor, which is actually manipulating a copy of the configuration document ... Editor editor = deployedConfig.edit()
; // Modify the copy of the configuration (we'll do something trivial here) ... editor.setNumber(FieldName.LARGE_VALUE_SIZE_IN_BYTES,8096); // Get our changes and validate them ... Changes changes = editor.getChanges()
; Results validationResults = deployedConfig.validate(changes)
; if ( validationResults.hasErrors() ) { // you've done something wrong with your editor } else { // Update the deployed repository's configuration with these changes ... Future<Boolean> future = engine.update("repo",changes)
; // Optionally block while the repository instance is changed to // reflect the new configuration ... JcrRepository updated = future.get(); }
Note that this method blocks while the changes to the configuration are validated and applied, but before the repository has changed to reflect the new configuration, which is done asynchronously. The resulting future represents that asynchronous process, and the future can be used to block until that updating is completed.
repositoryName
- the name of the repositorychanges
- the changes that should be applied to the repository's configurationConfigurationException
- if the configuration is not valid with the supplied changesNoSuchRepositoryException
- if there is no repository with the specified nameRepositoryException
- if there is a problem updating the repositoryIllegalArgumentException
- if any of the parameters are null or invaliddeploy(RepositoryConfiguration)
,
undeploy(String)
public Future<Boolean> undeploy(String repositoryName) throws NoSuchRepositoryException
Repository
.repositoryName
- the name of the deployed repositorygetting
the repository from the future will throw the exception wrapped in a
ExecutionException
IllegalArgumentException
- if the repository name is null, blank or invalidNoSuchRepositoryException
- if there is no repository with the specified nameIllegalStateException
- if this engine was not started
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.