|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.repository.ModeShapeConfiguration
@NotThreadSafe public class ModeShapeConfiguration
A configuration builder for a ModeShapeEngine
. This class is an internal domain-specific language (DSL), and is
designed to be used in a traditional way or in a method-chained manner:
configuration.repositorySource("Source1").setClass(InMemoryRepositorySource.class).setDescription("description"); configuration.mimeTypeDetector("detector").setClass(ExtensionBasedMimeTypeDetector.class).setDescription("default detector"); configuration.sequencer("MicrosoftDocs") .setClass("org.modeshape.sequencer.msoffice.MSOfficeMetadataSequencer") .setDescription("Our primary sequencer for all .doc files") .sequencingFrom("/public//(*.(doc|xml|ppt)[*]/jcr:content[@jcr:data]") .andOutputtingTo("/documents/$1"); configuration.save();
Nested Class Summary | |
---|---|
protected static class |
ModeShapeConfiguration.BaseReturnable<ReturnType>
|
static interface |
ModeShapeConfiguration.ChooseClass<ComponentClassType,ReturnType>
The interface used to configure the class used for a component. |
protected static class |
ModeShapeConfiguration.ClusterBuilder<ReturnType>
|
static interface |
ModeShapeConfiguration.ClusterDefinition<ReturnType>
Interface used to set up and define the cluster configuration. |
static class |
ModeShapeConfiguration.ConfigurationDefinition
Representation of the current configuration content. |
protected static class |
ModeShapeConfiguration.GlobalProperties<ReturnType>
|
protected static class |
ModeShapeConfiguration.GraphComponentBuilder<ReturnType,ThisType,ComponentType>
Base class for ModeShapeConfiguration.Returnable types that work on a node in the graph. |
protected static class |
ModeShapeConfiguration.GraphReturnable<ReturnType,ThisType>
Base class for ModeShapeConfiguration.Returnable types that work on a node in the graph. |
static interface |
ModeShapeConfiguration.HasName
Interface for a component that has a name. |
static interface |
ModeShapeConfiguration.LoadedFrom<ReturnType>
Interface for specifying from where the component's class is to be loaded. |
protected static class |
ModeShapeConfiguration.MimeTypeDetectorBuilder<ReturnType>
|
static interface |
ModeShapeConfiguration.MimeTypeDetectorDefinition<ReturnType>
Interface used to set up and define a MIME type detector instance. |
static interface |
ModeShapeConfiguration.PathExpressionOutput<ReturnType>
Interface used to specify the output path expression for a sequencer configuration . |
static interface |
ModeShapeConfiguration.Removable<ReturnType>
Interface that defines the ability to remove the configuration component. |
static interface |
ModeShapeConfiguration.RepositorySourceDefinition<ReturnType>
Interface used to set up and define a RepositorySource instance. |
static interface |
ModeShapeConfiguration.Returnable<ReturnType>
Interface that defines the ability to obtain the configuration component. |
protected static class |
ModeShapeConfiguration.SequencerBuilder<ReturnType>
|
static interface |
ModeShapeConfiguration.SequencerDefinition<ReturnType>
Interface used to set up and define a sequencer instance. |
static interface |
ModeShapeConfiguration.SetDescription<ReturnType>
The interface used to set a description on a component. |
static interface |
ModeShapeConfiguration.SetProperties<ReturnType>
Interface for configuring the JavaBean-style properties of an object. |
protected static class |
ModeShapeConfiguration.SourceBuilder<ReturnType>
|
protected static class |
ModeShapeConfiguration.TextExtractorBuilder<ReturnType>
|
static interface |
ModeShapeConfiguration.TextExtractorDefinition<ReturnType>
Interface used to set up and define a text extractor instance. |
Field Summary | |
---|---|
static String |
DEFAULT_CONFIGURATION_SOURCE_NAME
|
static String |
DEFAULT_PATH
|
static String |
DEFAULT_WORKSPACE_NAME
|
Constructor Summary | |
---|---|
ModeShapeConfiguration()
Create a new configuration, using a default-constructed ExecutionContext . |
|
ModeShapeConfiguration(ExecutionContext context)
Create a new configuration using the supplied ExecutionContext . |
Method Summary | ||
---|---|---|
ModeShapeConfiguration |
and()
Convenience method to make the code that sets up this configuration easier to read. |
|
ModeShapeEngine |
build()
Construct an engine that reflects the current state of this configuration. |
|
protected Graph.Batch |
changes()
|
|
protected
|
clusterDefinition(ReturnType returnObject)
Utility method to construct a definition object for the clustering with the supplied name and return type. |
|
ModeShapeConfiguration.ClusterDefinition<? extends ModeShapeConfiguration> |
clustering()
Obtain the definition for this engine's clustering. |
|
protected Graph |
configurationGraph()
|
|
ModeShapeConfiguration.ConfigurationDefinition |
getConfigurationDefinition()
Get the immutable representation of the information defining where the configuration content can be found. |
|
protected ExecutionContext |
getExecutionContext()
|
|
protected ExecutionContext |
getExecutionContextForEngine()
Utility method used by build() to get the ExecutionContext instance for the engine. |
|
protected Set<String> |
getNamesOfComponentsUnder(Name parentName)
|
|
Problems |
getProblems()
Get the problems (if any) that are associated with this configuration. |
|
ModeShapeConfiguration.GlobalProperties<? extends ModeShapeConfiguration> |
globalProperties()
Obtain the definition for this engine's global properties. |
|
protected
|
globalProperties(ReturnType returnObject)
Utility method to construct a setter for global properties. |
|
boolean |
hasChanges()
Determine if there are any unsaved changes to this configuration that must be saved before they take
effect. |
|
ModeShapeConfiguration |
loadFrom(File configurationFile)
Load the configuration from a file. |
|
ModeShapeConfiguration |
loadFrom(File configurationFile,
String path)
Load the configuration from a file. |
|
ModeShapeConfiguration |
loadFrom(InputStream configurationFileInputStream)
Load the configuration from a file at the supplied URL. |
|
ModeShapeConfiguration |
loadFrom(InputStream configurationFileInputStream,
String path)
Load the configuration from a file at the supplied URL. |
|
ModeShapeConfiguration |
loadFrom(RepositorySource source)
Load the configuration from the repository content using the supplied repository source. |
|
ModeShapeConfiguration |
loadFrom(RepositorySource source,
String workspaceName)
Load the configuration from the repository content using the workspace in the supplied repository source. |
|
ModeShapeConfiguration |
loadFrom(RepositorySource source,
String workspaceName,
String pathInWorkspace)
Load the configuration from the repository content at the supplied path in the workspace in the supplied repository source. |
|
ModeShapeConfiguration |
loadFrom(String pathToConfigurationFile)
Load the configuration from a file at the given path. |
|
ModeShapeConfiguration |
loadFrom(String pathToConfigurationFile,
String path)
Load the configuration from a file at the given path. |
|
ModeShapeConfiguration |
loadFrom(URL urlToConfigurationFile)
Load the configuration from a file at the supplied URL. |
|
ModeShapeConfiguration |
loadFrom(URL urlToConfigurationFile,
String path)
Load the configuration from a file at the supplied URL. |
|
ModeShapeConfiguration.MimeTypeDetectorDefinition<? extends ModeShapeConfiguration> |
mimeTypeDetector(String name)
Obtain or create a definition for the MIME type detector with the supplied name or identifier. |
|
protected
|
mimeTypeDetectorDefinition(ReturnType returnObject,
String name)
Utility method to construct a definition object for the detector with the supplied name and return type. |
|
Set<ModeShapeConfiguration.MimeTypeDetectorDefinition<? extends ModeShapeConfiguration>> |
mimeTypeDetectors()
Get the list of MIME type detector definitions. |
|
protected Name |
name(String name)
|
|
protected Path |
path()
|
|
protected Path |
path(String path)
|
|
ModeShapeConfiguration.RepositorySourceDefinition<? extends ModeShapeConfiguration> |
repositorySource(String name)
Obtain or create a definition for the RepositorySource with the supplied name or identifier. |
|
protected
|
repositorySourceDefinition(ReturnType returnObject,
String name)
Utility method to construct a definition object for the repository source with the supplied name and return type. |
|
Set<ModeShapeConfiguration.RepositorySourceDefinition<? extends ModeShapeConfiguration>> |
repositorySources()
Get the list of repository source definitions. |
|
ModeShapeConfiguration |
save()
Persist any unsaved changes that have been made to this configuration. |
|
ModeShapeConfiguration.SequencerDefinition<? extends ModeShapeConfiguration> |
sequencer(String name)
Obtain or create a definition for the sequencer with the supplied name or identifier. |
|
protected
|
sequencerDefinition(ReturnType returnObject,
String name)
Utility method to construct a definition object for the sequencer with the supplied name and return type. |
|
Set<ModeShapeConfiguration.SequencerDefinition<? extends ModeShapeConfiguration>> |
sequencers()
Get the list of sequencer definitions. |
|
void |
storeTo(ContentHandler handler)
Traverse the saved configuration graph treating it as an XML document and calling the corresponding SAX event on the provided ContentHandler . |
|
void |
storeTo(File file)
Store the saved configuration to the given file. |
|
void |
storeTo(OutputStream os)
Store the saved configuration to the stream. |
|
void |
storeTo(String file)
Store the saved configuration to the file with the given name. |
|
ModeShapeConfiguration.TextExtractorDefinition<? extends ModeShapeConfiguration> |
textExtractor(String name)
Obtain or create a definition for the text extractor with the supplied name or identifier. |
|
protected
|
textExtractorDefinition(ReturnType returnObject,
String name)
Utility method to construct a definition object for the text extractor with the supplied name and return type. |
|
Set<ModeShapeConfiguration.TextExtractorDefinition<? extends ModeShapeConfiguration>> |
textExtractors()
Get the list of text extractor definitions. |
|
ModeShapeConfiguration |
withClassLoaderFactory(ClassLoaderFactory classLoaderFactory)
Specify the ClassLoaderFactory that should be used to load the classes for the various components. |
|
ModeShapeConfiguration |
withGarbageCollectionInterval(long interval,
TimeUnit unit)
Set the interval for garbage collection, should garbage collection be required by the sources). |
|
ModeShapeConfiguration |
withName(String name)
Set the name of this configuration. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_WORKSPACE_NAME
public static final String DEFAULT_PATH
public static final String DEFAULT_CONFIGURATION_SOURCE_NAME
Constructor Detail |
---|
public ModeShapeConfiguration()
ExecutionContext
.
public ModeShapeConfiguration(ExecutionContext context)
ExecutionContext
.
context
- the execution context
IllegalArgumentException
- if the path is null or emptyMethod Detail |
---|
public ModeShapeConfiguration withName(String name)
name
- the configuration name; may be null if the default name should be used
public ModeShapeConfiguration loadFrom(String pathToConfigurationFile) throws IOException, SAXException
pathToConfigurationFile
- the path the file containing the configuration information
IOException
- if there is an error or problem reading the file at the supplied location
SAXException
- if the file is not a valid XML format
IllegalArgumentException
- if the path is null or emptypublic ModeShapeConfiguration loadFrom(String pathToConfigurationFile, String path) throws IOException, SAXException
pathToConfigurationFile
- the path the file containing the configuration informationpath
- path within the content to the parent containing the configuration information, or null if the
default path
should be used
IOException
- if there is an error or problem reading the file at the supplied location
SAXException
- if the file is not a valid XML format
IllegalArgumentException
- if the path is null or emptypublic ModeShapeConfiguration loadFrom(File configurationFile) throws IOException, SAXException
configurationFile
- the file containing the configuration information
IOException
- if there is an error or problem reading the supplied file
SAXException
- if the file is not a valid XML format
IllegalArgumentException
- if the file reference is nullpublic ModeShapeConfiguration loadFrom(File configurationFile, String path) throws IOException, SAXException
configurationFile
- the file containing the configuration informationpath
- path within the content to the parent containing the configuration information, or null if the
default path
should be used
IOException
- if there is an error or problem reading the supplied file
SAXException
- if the file is not a valid XML format
IllegalArgumentException
- if the file reference is nullpublic ModeShapeConfiguration loadFrom(URL urlToConfigurationFile) throws IOException, SAXException
urlToConfigurationFile
- the URL of the file containing the configuration information
IOException
- if there is an error or problem reading the file at the supplied URL
SAXException
- if the file is not a valid XML format
IllegalArgumentException
- if the URL is nullpublic ModeShapeConfiguration loadFrom(URL urlToConfigurationFile, String path) throws IOException, SAXException
urlToConfigurationFile
- the URL of the file containing the configuration informationpath
- path within the content to the parent containing the configuration information, or null if the
default path
should be used
IOException
- if there is an error or problem reading the file at the supplied URL
SAXException
- if the file is not a valid XML format
IllegalArgumentException
- if the URL is nullpublic ModeShapeConfiguration loadFrom(InputStream configurationFileInputStream) throws IOException, SAXException
configurationFileInputStream
- the stream with the configuration information
IOException
- if there is an error or problem reading the file at the supplied URL
SAXException
- if the file is not a valid XML format
IllegalArgumentException
- if the stream is nullpublic ModeShapeConfiguration loadFrom(InputStream configurationFileInputStream, String path) throws IOException, SAXException
configurationFileInputStream
- the stream with the configuration informationpath
- path within the content to the parent containing the configuration information, or null if the
default path
should be used
IOException
- if there is an error or problem reading the file at the supplied URL
SAXException
- if the file is not a valid XML format
IllegalArgumentException
- if the stream is nullpublic ModeShapeConfiguration loadFrom(RepositorySource source)
create connections
.
Also, the default workspace of the source will be used, and the configuration content may be found directly under the root
node.
source
- the source that defines the repository with the configuration content
IllegalArgumentException
- if the source is nullpublic ModeShapeConfiguration loadFrom(RepositorySource source, String workspaceName)
create
connections
. Also, the configuration content may be found directly under the root node.
source
- the source that defines the repository with the configuration contentworkspaceName
- the name of the workspace with the configuration content, or null if the source's default workspace
should be used
IllegalArgumentException
- if the source is nullpublic ModeShapeConfiguration loadFrom(RepositorySource source, String workspaceName, String pathInWorkspace)
create connections
.
source
- the source that defines the repository with the configuration contentworkspaceName
- the name of the workspace with the configuration content, or null if the source's default workspace
should be usedpathInWorkspace
- the path to the parent node under which the configuration content may be found, or null if the
content may be found under the root node
IllegalArgumentException
- if the source is nullpublic void storeTo(String file) throws SAXException, IOException
save()
will not be
written to the file.
file
- the name of the file to which the configuration should be stored
SAXException
- if there is an error saving the configuration
IOException
- if the file cannot be created or if there is an error writing the configuration to the file.public void storeTo(File file) throws SAXException, IOException
save()
will not be written to the
file.
file
- the name of the file to which the configuration should be stored
SAXException
- if there is an error saving the configuration
IOException
- if the file cannot be created or if there is an error writing the configuration to the file.public void storeTo(OutputStream os) throws SAXException
save()
will not be written to the
stream.
os
- the name of the file to which the configuration should be stored
SAXException
- if there is an error saving the configurationpublic void storeTo(ContentHandler handler) throws SAXException
ContentHandler
. Changes made without calling save()
will not be written to the stream.
handler
- the content handler that will receive the SAX events
SAXException
- if there is an error saving the configurationpublic ModeShapeConfiguration.ConfigurationDefinition getConfigurationDefinition()
protected ExecutionContext getExecutionContext()
protected Path path()
protected Path path(String path)
protected Name name(String name)
public Problems getProblems()
protected Graph configurationGraph()
protected Graph.Batch changes()
public boolean hasChanges()
saved
before they take
effect.
save()
is required, or false no changes have been made to the configuration since the last
save()
public ModeShapeConfiguration save()
no unsaved changes
.
public ModeShapeConfiguration withClassLoaderFactory(ClassLoaderFactory classLoaderFactory)
ClassLoaderFactory
that should be used to load the classes for the various components. Most of the
definitions can specify the classpath
that should be used, and that classpath is
passed to the supplied ClassLoaderFactory instance to obtain a ClassLoader
for the class.
If not called, this configuration will use the class loader that loaded this configuration's class.
classLoaderFactory
- the class loader factory implementation, or null if the classes should be loaded using the class
loader of this object
protected Set<String> getNamesOfComponentsUnder(Name parentName)
public Set<ModeShapeConfiguration.MimeTypeDetectorDefinition<? extends ModeShapeConfiguration>> mimeTypeDetectors()
public Set<ModeShapeConfiguration.TextExtractorDefinition<? extends ModeShapeConfiguration>> textExtractors()
public Set<ModeShapeConfiguration.RepositorySourceDefinition<? extends ModeShapeConfiguration>> repositorySources()
public Set<ModeShapeConfiguration.SequencerDefinition<? extends ModeShapeConfiguration>> sequencers()
public ModeShapeConfiguration.MimeTypeDetectorDefinition<? extends ModeShapeConfiguration> mimeTypeDetector(String name)
MIME type detector
with the supplied name or identifier. A
new definition will be created if there currently is no MIME type detector defined with the supplied name.
name
- the name or identifier of the detector
public ModeShapeConfiguration.TextExtractorDefinition<? extends ModeShapeConfiguration> textExtractor(String name)
text extractor
with the supplied name or identifier. A new
definition will be created if there currently is no text extractor defined with the supplied name.
name
- the name or identifier of the extractor
public ModeShapeConfiguration.RepositorySourceDefinition<? extends ModeShapeConfiguration> repositorySource(String name)
RepositorySource
with the supplied name or identifier. A new definition will
be created if there currently is no repository source defined with the supplied name.
name
- the name or identifier of the repository source
public ModeShapeConfiguration.SequencerDefinition<? extends ModeShapeConfiguration> sequencer(String name)
sequencer
with the supplied name or identifier. A new
definition will be created if there currently is no sequencer defined with the supplied name.
name
- the name or identifier of the sequencer
public ModeShapeConfiguration.ClusterDefinition<? extends ModeShapeConfiguration> clustering()
public ModeShapeConfiguration.GlobalProperties<? extends ModeShapeConfiguration> globalProperties()
public ModeShapeConfiguration withGarbageCollectionInterval(long interval, TimeUnit unit)
interval
- the interval magnitudeunit
- the interval time unit
public ModeShapeConfiguration and()
public ModeShapeEngine build()
getExecutionContextForEngine()
protected ExecutionContext getExecutionContextForEngine()
build()
to get the ExecutionContext
instance for the engine. This method gives
subclasses the ability to override this behavior.
Currently, this method wraps the configuration's execution context
to provide
backward-compability with JBoss DNA namespaces. See MODE-647 for details.
build()
protected <ReturnType extends ModeShapeConfiguration> ModeShapeConfiguration.MimeTypeDetectorDefinition<ReturnType> mimeTypeDetectorDefinition(ReturnType returnObject, String name)
ReturnType
- the type of the return objectreturnObject
- the return objectname
- the name of the detector
protected <ReturnType extends ModeShapeConfiguration> ModeShapeConfiguration.TextExtractorDefinition<ReturnType> textExtractorDefinition(ReturnType returnObject, String name)
ReturnType
- the type of the return objectreturnObject
- the return objectname
- the name of the extractor
protected <ReturnType extends ModeShapeConfiguration> ModeShapeConfiguration.RepositorySourceDefinition<ReturnType> repositorySourceDefinition(ReturnType returnObject, String name)
ReturnType
- the type of the return objectreturnObject
- the return objectname
- the name of the repository source
protected <ReturnType extends ModeShapeConfiguration> ModeShapeConfiguration.SequencerDefinition<ReturnType> sequencerDefinition(ReturnType returnObject, String name)
ReturnType
- the type of the return objectreturnObject
- the return objectname
- the name of the sequencer
protected <ReturnType extends ModeShapeConfiguration> ModeShapeConfiguration.ClusterDefinition<ReturnType> clusterDefinition(ReturnType returnObject)
ReturnType
- the type of the return objectreturnObject
- the return object
protected <ReturnType extends ModeShapeConfiguration> ModeShapeConfiguration.GlobalProperties<ReturnType> globalProperties(ReturnType returnObject)
ReturnType
- the type of the return objectreturnObject
- the return object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |