org.modeshape.repository
Class ModeShapeEngine

java.lang.Object
  extended by org.modeshape.repository.ModeShapeEngine
Direct Known Subclasses:
JcrEngine

@Immutable
public class ModeShapeEngine
extends Object

A single instance of the ModeShape services, which is obtained after setting up the configuration.

See Also:
ModeShapeConfiguration

Nested Class Summary
protected  class ModeShapeEngine.ConfigurationScanner
          The component responsible for reading the configuration repository and (eventually) for propagating changes in the configuration repository into the services.
 
Field Summary
protected  ModeShapeConfiguration.ConfigurationDefinition configuration
           
static String CONFIGURATION_REPOSITORY_NAME
           
protected  ExecutionContext context
           
 
Constructor Summary
protected ModeShapeEngine(ExecutionContext context, ModeShapeConfiguration.ConfigurationDefinition configuration)
           
 
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  boolean checkRunning()
           
protected  Graph getConfigurationGraph()
          Get a graph to the configuration content.
 ExecutionContext getExecutionContext()
          Get the context in which this engine is executing.
 Graph getGraph(ExecutionContext context, String sourceName)
          Get a graph to the underlying source, using the supplied context.
 Graph getGraph(String sourceName)
          Get a graph to the underlying source.
protected  MimeTypeDetector getMimeTypeDetector()
          Return the component that is able to detect MIME types given the name of a stream and a stream.
 Problems getProblems()
          Get the problems that were encountered when setting up this engine from the configuration.
 RepositoryConnectionFactory getRepositoryConnectionFactory()
          Get a factory of connections, backed by the RepositorySor
 RepositoryService getRepositoryService()
          Get the repository service.
 RepositorySource getRepositorySource(String repositoryName)
          Get the RepositorySource instance used by this engine.
 SequencingService getSequencingService()
          Get the sequencing service.
 void shutdown()
          Shutdown this engine to close all connections, terminate any ongoing background operations (such as sequencing), and reclaim any resources that were acquired by this engine.
 void start()
          Start this engine to make it available for use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIGURATION_REPOSITORY_NAME

public static final String CONFIGURATION_REPOSITORY_NAME
See Also:
Constant Field Values

configuration

protected final ModeShapeConfiguration.ConfigurationDefinition configuration

context

protected final ExecutionContext context
Constructor Detail

ModeShapeEngine

protected ModeShapeEngine(ExecutionContext context,
                          ModeShapeConfiguration.ConfigurationDefinition configuration)
Method Detail

getProblems

public Problems getProblems()
Get the problems that were encountered when setting up this engine from the configuration.

Returns:
the problems, which may be empty but will never be null

getExecutionContext

public final ExecutionContext getExecutionContext()
Get the context in which this engine is executing.

Returns:
the execution context; never null

getRepositorySource

public final RepositorySource getRepositorySource(String repositoryName)
Get the RepositorySource instance used by this engine.

Parameters:
repositoryName - the name of the repository source
Returns:
the source, or null if no source with the given name exists
Throws:
IllegalStateException - if this engine was not started

getRepositoryConnectionFactory

public final RepositoryConnectionFactory getRepositoryConnectionFactory()
Get a factory of connections, backed by the RepositorySor

Returns:
the connection factory; never null
Throws:
IllegalStateException - if this engine was not started

getRepositoryService

public final RepositoryService getRepositoryService()
Get the repository service.

Returns:
the repository service owned by this engine; never null
Throws:
IllegalStateException - if this engine was not started

getGraph

public final Graph getGraph(String sourceName)
Get a graph to the underlying source.

Parameters:
sourceName - the name of the source
Returns:
the graph
Throws:
IllegalArgumentException - if the source name is null
RepositorySourceException - if a source with the supplied name does not exist
IllegalStateException - if this engine was not started

getGraph

public final Graph getGraph(ExecutionContext context,
                            String sourceName)
Get a graph to the underlying source, using the supplied context. Note that the supplied context should be a derivative of the engine's context.

Parameters:
context - the context of execution for this graph; may not be null
sourceName - the name of the source
Returns:
the graph
Throws:
IllegalArgumentException - if the context or source name are null
RepositorySourceException - if a source with the supplied name does not exist
IllegalStateException - if this engine was not started

getSequencingService

public final SequencingService getSequencingService()
Get the sequencing service.

Returns:
the sequencing service owned by this engine; never null
Throws:
IllegalStateException - if this engine was not started

getMimeTypeDetector

protected final MimeTypeDetector getMimeTypeDetector()
Return the component that is able to detect MIME types given the name of a stream and a stream.

Returns:
the MIME type detector used by this engine; never null
Throws:
IllegalStateException - if this engine was not started

checkRunning

protected final boolean checkRunning()

start

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

Throws:
IllegalStateException - if this method is called when already shut down.
See Also:
shutdown()

shutdown

public void shutdown()
Shutdown this engine to close all connections, terminate any ongoing background operations (such as sequencing), and reclaim any resources that were acquired by this engine. This method may be called multiple times, but only the first time has an effect.

See Also:
start()

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.

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

getConfigurationGraph

protected Graph getConfigurationGraph()
Get a graph to the configuration content.

Returns:
a graph to the configuration content


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