org.jboss.dna.repository
Class DnaConfiguration

java.lang.Object
  extended by org.jboss.dna.repository.DnaConfiguration
Direct Known Subclasses:
JcrConfiguration

@NotThreadSafe
public class DnaConfiguration
extends Object

A configuration builder for a DnaEngine. 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.jboss.dna.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
static interface DnaConfiguration.ChooseClass<ComponentClassType,ReturnType>
          The interface used to configure the class used for a component.
static class DnaConfiguration.ConfigurationDefinition
          Representation of the current configuration content.
static interface DnaConfiguration.HasName
          Interface for a component that has a name.
static interface DnaConfiguration.LoadedFrom<ReturnType>
          Interface for specifying from where the component's class is to be loaded.
static interface DnaConfiguration.MimeTypeDetectorDefinition<ReturnType>
          Interface used to set up and define a MIME type detector instance.
static interface DnaConfiguration.PathExpressionOutput<ReturnType>
          Interface used to specify the output path expression for a sequencer configuration.
static interface DnaConfiguration.Removable<ReturnType>
          Interface that defines the ability to remove the configuration component.
static interface DnaConfiguration.RepositorySourceDefinition<ReturnType>
          Interface used to set up and define a RepositorySource instance.
static interface DnaConfiguration.Returnable<ReturnType>
          Interface that defines the ability to obtain the configuration component.
static interface DnaConfiguration.SequencerDefinition<ReturnType>
          Interface used to set up and define a sequencer instance.
static interface DnaConfiguration.SetDescription<ReturnType>
          The interface used to set a description on a component.
static interface DnaConfiguration.SetProperties<ReturnType>
          Interface for configuring the JavaBean-style properties of an object.
 
Field Summary
static String DEFAULT_CONFIGURATION_SOURCE_NAME
           
static String DEFAULT_PATH
           
static String DEFAULT_WORKSPACE_NAME
           
 
Constructor Summary
DnaConfiguration()
          Create a new configuration, using a default-constructed ExecutionContext.
DnaConfiguration(ExecutionContext context)
          Create a new configuration using the supplied ExecutionContext.
 
Method Summary
 DnaConfiguration and()
          Convenience method to make the code that sets up this configuration easier to read.
 DnaEngine build()
          Construct an engine that reflects the current state of this configuration.
 DnaConfiguration.ConfigurationDefinition getConfigurationDefinition()
          Get the immutable representation of the information defining where the configuration content can be found.
 Problems getProblems()
          Get the problems (if any) that are associated with this configuration.
 boolean hasChanges()
          Determine if there are any unsaved changes to this configuration that must be saved before they take effect.
 DnaConfiguration loadFrom(File configurationFile)
          Load the configuration from a file.
 DnaConfiguration loadFrom(File configurationFile, String path)
          Load the configuration from a file.
 DnaConfiguration loadFrom(InputStream configurationFileInputStream)
          Load the configuration from a file at the supplied URL.
 DnaConfiguration loadFrom(InputStream configurationFileInputStream, String path)
          Load the configuration from a file at the supplied URL.
 DnaConfiguration loadFrom(RepositorySource source)
          Load the configuration from the repository content using the supplied repository source.
 DnaConfiguration loadFrom(RepositorySource source, String workspaceName)
          Load the configuration from the repository content using the workspace in the supplied repository source.
 DnaConfiguration 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.
 DnaConfiguration loadFrom(String pathToConfigurationFile)
          Load the configuration from a file at the given path.
 DnaConfiguration loadFrom(String pathToConfigurationFile, String path)
          Load the configuration from a file at the given path.
 DnaConfiguration loadFrom(URL urlToConfigurationFile)
          Load the configuration from a file at the supplied URL.
 DnaConfiguration loadFrom(URL urlToConfigurationFile, String path)
          Load the configuration from a file at the supplied URL.
 DnaConfiguration.MimeTypeDetectorDefinition<? extends DnaConfiguration> mimeTypeDetector(String name)
          Obtain or create a definition for the MIME type detector with the supplied name or identifier.
 Set<DnaConfiguration.MimeTypeDetectorDefinition<? extends DnaConfiguration>> mimeTypeDetectors()
          Get the list of MIME type detector definitions.
 DnaConfiguration.RepositorySourceDefinition<? extends DnaConfiguration> repositorySource(String name)
          Obtain or create a definition for the RepositorySource with the supplied name or identifier.
 Set<DnaConfiguration.RepositorySourceDefinition<? extends DnaConfiguration>> repositorySources()
          Get the list of repository source definitions.
 DnaConfiguration save()
          Persist any unsaved changes that have been made to this configuration.
 DnaConfiguration.SequencerDefinition<? extends DnaConfiguration> sequencer(String name)
          Obtain or create a definition for the sequencer with the supplied name or identifier.
 Set<DnaConfiguration.SequencerDefinition<? extends DnaConfiguration>> sequencers()
          Get the list of sequencer definitions.
 DnaConfiguration withClassLoaderFactory(ClassLoaderFactory classLoaderFactory)
          Specify the ClassLoaderFactory that should be used to load the classes for the various components.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_WORKSPACE_NAME

public static final String DEFAULT_WORKSPACE_NAME
See Also:
Constant Field Values

DEFAULT_PATH

public static final String DEFAULT_PATH
See Also:
Constant Field Values

DEFAULT_CONFIGURATION_SOURCE_NAME

public static final String DEFAULT_CONFIGURATION_SOURCE_NAME
See Also:
Constant Field Values
Constructor Detail

DnaConfiguration

public DnaConfiguration()
Create a new configuration, using a default-constructed ExecutionContext.


DnaConfiguration

public DnaConfiguration(ExecutionContext context)
Create a new configuration using the supplied ExecutionContext.

Parameters:
context - the execution context
Throws:
IllegalArgumentException - if the path is null or empty
Method Detail

loadFrom

public DnaConfiguration loadFrom(String pathToConfigurationFile)
                          throws IOException,
                                 SAXException
Load the configuration from a file at the given path.

Parameters:
pathToConfigurationFile - the path the file containing the configuration information
Returns:
this configuration object, for convenience and method chaining
Throws:
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 empty

loadFrom

public DnaConfiguration loadFrom(String pathToConfigurationFile,
                                 String path)
                          throws IOException,
                                 SAXException
Load the configuration from a file at the given path.

Parameters:
pathToConfigurationFile - the path the file containing the configuration information
path - path within the content to the parent containing the configuration information, or null if the default path should be used
Returns:
this configuration object, for convenience and method chaining
Throws:
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 empty

loadFrom

public DnaConfiguration loadFrom(File configurationFile)
                          throws IOException,
                                 SAXException
Load the configuration from a file.

Parameters:
configurationFile - the file containing the configuration information
Returns:
this configuration object, for convenience and method chaining
Throws:
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 null

loadFrom

public DnaConfiguration loadFrom(File configurationFile,
                                 String path)
                          throws IOException,
                                 SAXException
Load the configuration from a file.

Parameters:
configurationFile - the file containing the configuration information
path - path within the content to the parent containing the configuration information, or null if the default path should be used
Returns:
this configuration object, for convenience and method chaining
Throws:
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 null

loadFrom

public DnaConfiguration loadFrom(URL urlToConfigurationFile)
                          throws IOException,
                                 SAXException
Load the configuration from a file at the supplied URL.

Parameters:
urlToConfigurationFile - the URL of the file containing the configuration information
Returns:
this configuration object, for convenience and method chaining
Throws:
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 null

loadFrom

public DnaConfiguration loadFrom(URL urlToConfigurationFile,
                                 String path)
                          throws IOException,
                                 SAXException
Load the configuration from a file at the supplied URL.

Parameters:
urlToConfigurationFile - the URL of the file containing the configuration information
path - path within the content to the parent containing the configuration information, or null if the default path should be used
Returns:
this configuration object, for convenience and method chaining
Throws:
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 null

loadFrom

public DnaConfiguration loadFrom(InputStream configurationFileInputStream)
                          throws IOException,
                                 SAXException
Load the configuration from a file at the supplied URL.

Parameters:
configurationFileInputStream - the stream with the configuration information
Returns:
this configuration object, for convenience and method chaining
Throws:
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 null

loadFrom

public DnaConfiguration loadFrom(InputStream configurationFileInputStream,
                                 String path)
                          throws IOException,
                                 SAXException
Load the configuration from a file at the supplied URL.

Parameters:
configurationFileInputStream - the stream with the configuration information
path - path within the content to the parent containing the configuration information, or null if the default path should be used
Returns:
this configuration object, for convenience and method chaining
Throws:
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 null

loadFrom

public DnaConfiguration loadFrom(RepositorySource source)
Load the configuration from the repository content using the supplied repository source. This method assumes that the supplied source has already been configured and is ready to create connections. Also, the default workspace of the source will be used, and the configuration content may be found directly under the root node.

Parameters:
source - the source that defines the repository with the configuration content
Returns:
this configuration object, for convenience and method chaining
Throws:
IllegalArgumentException - if the source is null

loadFrom

public DnaConfiguration loadFrom(RepositorySource source,
                                 String workspaceName)
Load the configuration from the repository content using the workspace in the supplied repository source. This method assumes that the supplied source has already been configured and is ready to create connections. Also, the configuration content may be found directly under the root node.

Parameters:
source - the source that defines the repository with the configuration content
workspaceName - the name of the workspace with the configuration content, or null if the source's default workspace should be used
Returns:
this configuration object, for convenience and method chaining
Throws:
IllegalArgumentException - if the source is null

loadFrom

public DnaConfiguration 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. This method assumes that the supplied source has already been configured and is ready to create connections.

Parameters:
source - the source that defines the repository with the configuration content
workspaceName - the name of the workspace with the configuration content, or null if the source's default workspace should be used
pathInWorkspace - 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
Returns:
this configuration object, for convenience and method chaining
Throws:
IllegalArgumentException - if the source is null

getConfigurationDefinition

public DnaConfiguration.ConfigurationDefinition getConfigurationDefinition()
Get the immutable representation of the information defining where the configuration content can be found.

Returns:
the configuration definition

getProblems

public Problems getProblems()
Get the problems (if any) that are associated with this configuration.

Returns:
the problems

hasChanges

public boolean hasChanges()
Determine if there are any unsaved changes to this configuration that must be saved before they take effect.

Returns:
true if a save() is required, or false no changes have been made to the configuration since the last save()

save

public DnaConfiguration save()
Persist any unsaved changes that have been made to this configuration. This method has no effect if there are currently no unsaved changes.

Returns:
this configuration, for method chaining purposes

withClassLoaderFactory

public DnaConfiguration withClassLoaderFactory(ClassLoaderFactory classLoaderFactory)
Specify the 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.

Parameters:
classLoaderFactory - the class loader factory implementation, or null if the classes should be loaded using the class loader of this object
Returns:
this configuration, for method chaining purposes

mimeTypeDetectors

public Set<DnaConfiguration.MimeTypeDetectorDefinition<? extends DnaConfiguration>> mimeTypeDetectors()
Get the list of MIME type detector definitions.

Returns:
the unmodifiable set of definitions; never null but possibly empty if there are no definitions

repositorySources

public Set<DnaConfiguration.RepositorySourceDefinition<? extends DnaConfiguration>> repositorySources()
Get the list of repository source definitions.

Returns:
the unmodifiable set of definitions; never null but possibly empty if there are no definitions

sequencers

public Set<DnaConfiguration.SequencerDefinition<? extends DnaConfiguration>> sequencers()
Get the list of sequencer definitions.

Returns:
the unmodifiable set of definitions; never null but possibly empty if there are no definitions

mimeTypeDetector

public DnaConfiguration.MimeTypeDetectorDefinition<? extends DnaConfiguration> mimeTypeDetector(String name)
Obtain or create a definition for the 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.

Parameters:
name - the name or identifier of the detector
Returns:
the details of the MIME type detector definition; never null

repositorySource

public DnaConfiguration.RepositorySourceDefinition<? extends DnaConfiguration> repositorySource(String name)
Obtain or create a definition for the 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.

Parameters:
name - the name or identifier of the repository source
Returns:
the details of the repository source definition; never null

sequencer

public DnaConfiguration.SequencerDefinition<? extends DnaConfiguration> sequencer(String name)
Obtain or create a definition for the sequencer with the supplied name or identifier. A new definition will be created if there currently is no sequencer defined with the supplied name.

Parameters:
name - the name or identifier of the sequencer
Returns:
the details of the sequencer definition; never null

and

public DnaConfiguration and()
Convenience method to make the code that sets up this configuration easier to read. This method simply returns this object.

Returns:
this configuration component; never null

build

public DnaEngine build()
Construct an engine that reflects the current state of this configuration. This method always creates a new instance.

Returns:
the resulting engine; never null


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