org.modeshape.jcr
Class JcrEngine

java.lang.Object
  extended by org.modeshape.repository.ModeShapeEngine
      extended by org.modeshape.jcr.JcrEngine
All Implemented Interfaces:
Repositories

@ThreadSafe
public class JcrEngine
extends ModeShapeEngine
implements Repositories

The basic component that encapsulates the ModeShape services, including the Repository instances.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.modeshape.repository.ModeShapeEngine
ModeShapeEngine.ConfigurationScanner
 
Field Summary
 
Fields inherited from class org.modeshape.repository.ModeShapeEngine
configuration, CONFIGURATION_REPOSITORY_NAME, context, DEFAULT_GARBAGE_COLLECTION_INTERVAL_IN_SECONDS, problems, scanner
 
Method Summary
 boolean awaitTermination(long timeout, TimeUnit unit)
          Blocks until the shutdown has completed, or the timeout occurs, or the current thread is interrupted, whichever happens first.
protected  void checkConfiguration(Subgraph configuration)
          Check the configuration given by the supplied graph.
protected  JcrRepository doCreateJcrRepository(String repositoryName)
           
 String getEngineVersion()
          Get the version of this engine.
 JcrRepository getRepository(String repositoryName)
          Get the Repository implementation for the named repository.
 Set<String> getRepositoryNames()
          Get the names of each of the JCR repositories.
 Map<String,Object> initDescriptors()
           
protected  boolean isTrue(Object value)
           
protected  ModeShapeConfigurationException newConfigurationException(String msg)
          Construct a new ModeShapeConfigurationException.
protected  void preShutdown()
           
protected  String readable(Location location)
           
protected  String readable(Name name)
           
protected  String readable(Path path)
           
 void shutdownAndAwaitTermination(long timeout, TimeUnit unit)
          This method is equivalent to calling ModeShapeEngine.shutdown() followed by awaitTermination(long, TimeUnit), except that after those methods are called any remaining JCR sessions are terminated automatically.
 void start()
          Start this engine to make it available for use.
 void start(boolean validateRepositoryConfigs)
          Start this engine to make it available for use, and optionally start each of the repositories in the configuration.
protected  String string(Object value)
           
 
Methods inherited from class org.modeshape.repository.ModeShapeEngine
checkProblemsOnStartup, checkRunning, getConfigurationGraph, getConfigurationSubgraph, getExecutionContext, getGraph, getGraph, getMimeTypeDetector, getProblems, getRepositoryConnectionFactory, getRepositoryService, getRepositorySource, getSequencingService, getTextExtractor, logger, newConfigurationScanner, postShutdown, shutdown, startGcService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

preShutdown

protected void preShutdown()
Overrides:
preShutdown in class ModeShapeEngine

awaitTermination

public boolean awaitTermination(long timeout,
                                TimeUnit unit)
                         throws InterruptedException
Blocks until the shutdown has completed, or the timeout occurs, or the current thread is interrupted, whichever happens first.

Overrides:
awaitTermination in class ModeShapeEngine
Parameters:
timeout - the maximum time to wait for each component in this engine
unit - the time unit of the timeout argument
Returns:
true if this service complete shut down and false if the timeout elapsed before it was shut down completely
Throws:
InterruptedException - if interrupted while waiting

checkConfiguration

protected void checkConfiguration(Subgraph configuration)
Check the configuration given by the supplied graph.

Overrides:
checkConfiguration in class ModeShapeEngine
Parameters:
configuration - the configuration subgraph
See Also:
ModeShapeEngine.checkConfiguration(org.modeshape.graph.Subgraph)

start

public void start()
Start this engine to make it available for use.

Overrides:
start in class ModeShapeEngine
Throws:
IllegalStateException - if this method is called when already shut down.
JcrConfigurationException - if there is an error in the configuration or any of the services that prevents proper startup
See Also:
start(boolean), ModeShapeEngine.shutdown()

start

public void start(boolean validateRepositoryConfigs)
Start this engine to make it available for use, and optionally start each of the repositories in the configuration. Any errors starting the repositories will be logged as problems.

Parameters:
validateRepositoryConfigs - true if the configurations of each repository should be validated and each repository started/initialized, or false otherwise
Throws:
IllegalStateException - if this method is called when already shut down.
JcrConfigurationException - if there is an error in the configuration or any of the services that prevents proper startup
See Also:
start(), ModeShapeEngine.shutdown()

newConfigurationException

protected ModeShapeConfigurationException newConfigurationException(String msg)
Construct a new ModeShapeConfigurationException. This method can be overridden by subclasses when a subclass of ModeShapeConfigurationException is to be thrown from ModeShapeEngine.start().

Overrides:
newConfigurationException in class ModeShapeEngine
Parameters:
msg - the message
Returns:
the exception; may not be null
See Also:
ModeShapeEngine.newConfigurationException(java.lang.String)

getEngineVersion

public String getEngineVersion()
Get the version of this engine.

Returns:
version

getRepository

public final JcrRepository getRepository(String repositoryName)
                                  throws RepositoryException
Get the Repository implementation for the named repository.

Specified by:
getRepository in interface Repositories
Parameters:
repositoryName - the name of the repository, which corresponds to the name of a configured RepositorySource
Returns:
the named repository instance
Throws:
IllegalArgumentException - if the repository name is null, blank or invalid
RepositoryException - if there is no repository with the specified name
IllegalStateException - if this engine was not started

getRepositoryNames

public Set<String> getRepositoryNames()
Get the names of each of the JCR repositories.

Specified by:
getRepositoryNames in interface Repositories
Returns:
the immutable names of the repositories that exist at the time this method is called

doCreateJcrRepository

protected JcrRepository doCreateJcrRepository(String repositoryName)
                                       throws RepositoryException,
                                              PathNotFoundException
Throws:
RepositoryException
PathNotFoundException

readable

protected final String readable(Name name)

readable

protected final String readable(Path path)

readable

protected final String readable(Location location)

string

protected final String string(Object value)

isTrue

protected final boolean isTrue(Object value)

initDescriptors

public Map<String,Object> initDescriptors()
Returns:
descriptors

shutdownAndAwaitTermination

public void shutdownAndAwaitTermination(long timeout,
                                        TimeUnit unit)
                                 throws InterruptedException
This method is equivalent to calling ModeShapeEngine.shutdown() followed by awaitTermination(long, TimeUnit), except that after those methods are called any remaining JCR sessions are terminated automatically. This is useful when shutting down while there are long-running JCR sessions (such as for event listeners).

Parameters:
timeout - the maximum time to wait for each component in this engine
unit - the time unit of the timeout argument
Throws:
InterruptedException - if interrupted while waiting


Copyright © 2008-2011 JBoss, a division of Red Hat. All Rights Reserved.