Author: rhauch
Date: 2009-06-03 16:08:46 -0400 (Wed, 03 Jun 2009)
New Revision: 967
Added:
trunk/extensions/dna-sequencer-java/src/main/resources/org/jboss/dna/sequencer/java/javaSource.cnd
Removed:
trunk/extensions/dna-sequencer-java/src/main/resources/org/jboss/dna/sequencer/java/java-source-artifact.cnd
Modified:
trunk/dna-cnd/src/main/java/org/jboss/dna/cnd/CndImporter.java
trunk/dna-cnd/src/test/java/org/jboss/dna/cnd/CndImporterTest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/Location.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/AbstractPath.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/BatchRequestBuilder.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaLexicon.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrConfiguration.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrEngine.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryNodeTypeManager.java
trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties
trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/dna_builtins.cnd
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/CndNodeTypeRegistrationTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/InMemoryRepositoryStub.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrConfigurationTest.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/Configurator.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaConfiguration.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/DnaConfigurationTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/DnaEngineTest.java
trunk/docs/examples/gettingstarted/repositories/src/main/resources/aircraft.xml
trunk/docs/examples/gettingstarted/repositories/src/main/resources/cars.xml
trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/ConsoleInput.java
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java
Log:
DNA-436 Continued the work on the examples, with fairly substantial changes
(simplification) to the configuration frameworks.
Modified: trunk/dna-cnd/src/main/java/org/jboss/dna/cnd/CndImporter.java
===================================================================
--- trunk/dna-cnd/src/main/java/org/jboss/dna/cnd/CndImporter.java 2009-06-03 20:07:47 UTC
(rev 966)
+++ trunk/dna-cnd/src/main/java/org/jboss/dna/cnd/CndImporter.java 2009-06-03 20:08:46 UTC
(rev 967)
@@ -505,7 +505,7 @@
protected String propertyTypeNameFrom( CommonTree node,
int childType ) {
String text = stringFrom(node, childType);
- if (text.equals("*")) text = "undefined";
+ if ("*".equals(text)) text = "undefined";
String upperText = text.toUpperCase();
if (!VALID_PROPERTY_TYPES.contains(upperText)) {
recordError(node, CndI18n.expectedValidPropertyTypeName, text,
VALID_PROPERTY_TYPES);
Modified: trunk/dna-cnd/src/test/java/org/jboss/dna/cnd/CndImporterTest.java
===================================================================
--- trunk/dna-cnd/src/test/java/org/jboss/dna/cnd/CndImporterTest.java 2009-06-03 20:07:47
UTC (rev 966)
+++ trunk/dna-cnd/src/test/java/org/jboss/dna/cnd/CndImporterTest.java 2009-06-03 20:08:46
UTC (rev 967)
@@ -446,6 +446,13 @@
assertThat(problems.size(), is(0));
}
+ @Test
+ public void shouldImportCndForJavaSequencer() throws Exception {
+ importer.importFrom(openCndFile("javaSource.cnd"), problems);
+ if (problems.size() != 0) printProblems();
+ assertThat(problems.size(), is(0));
+ }
+
public static final String[] NO_DEFAULTS = {};
public static final String[] NO_SUPERTYPES = {};
public static final String[] NO_VALUE_CONSTRAINTS = {};
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java 2009-06-03 20:07:47 UTC
(rev 966)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java 2009-06-03 20:08:46 UTC
(rev 967)
@@ -1717,13 +1717,15 @@
}
public List<Location> under( Location at ) {
- return requests.readBlockOfChildren(at,
getCurrentWorkspaceName(), startingIndex, blockSize).getChildren();
+ return requests.readBlockOfChildren(at,
getCurrentWorkspaceName(), startingIndex, blockSize)
+ .getChildren();
}
};
}
public List<Location> startingAfter( final Location
previousSibling ) {
- return requests.readNextBlockOfChildren(previousSibling,
getCurrentWorkspaceName(), blockSize).getChildren();
+ return requests.readNextBlockOfChildren(previousSibling,
getCurrentWorkspaceName(), blockSize)
+ .getChildren();
}
public List<Location> startingAfter( String
pathOfPreviousSibling ) {
@@ -1941,7 +1943,7 @@
*/
public ImportInto<Conjunction<Graph>> importXmlFrom( final InputStream
stream ) {
CheckArg.isNotNull(stream, "stream");
-
+
return new ImportInto<Conjunction<Graph>>() {
private boolean skipRootElement = false;
@@ -3513,6 +3515,19 @@
}
return new BatchResults(request);
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Pending requests:\n");
+ sb.append(requestQueue.toString());
+ return sb.toString();
+ }
}
/**
@@ -5380,7 +5395,10 @@
}
public SubgraphNode getNode( Name relativePath ) {
- Path path =
getGraph().getContext().getValueFactories().getPathFactory().create(getLocation().getPath(),
relativePath);
+ Path path = getGraph().getContext()
+ .getValueFactories()
+ .getPathFactory()
+ .create(getLocation().getPath(), relativePath);
path = path.getNormalizedPath();
return getNode(path);
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/Location.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/Location.java 2009-06-03 20:07:47
UTC (rev 966)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/Location.java 2009-06-03 20:08:46
UTC (rev 967)
@@ -558,12 +558,15 @@
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
- sb.append("{ ");
boolean hasPath = this.hasPath();
+ boolean hasProps = this.hasIdProperties();
if (hasPath) {
+ if (hasProps) {
+ sb.append("<");
+ }
sb.append(this.getPath());
}
- if (this.hasIdProperties()) {
+ if (hasProps) {
if (hasPath) sb.append(" && ");
sb.append("[");
boolean first = true;
@@ -573,8 +576,10 @@
sb.append(idProperty);
}
sb.append("]");
+ if (hasPath) {
+ sb.append("<");
+ }
}
- sb.append(" }");
return sb.toString();
}
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/AbstractPath.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/AbstractPath.java 2009-06-03
20:07:47 UTC (rev 966)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/AbstractPath.java 2009-06-03
20:08:46 UTC (rev 967)
@@ -248,7 +248,7 @@
* {@inheritDoc}
*/
public String getString() {
- return doGetString(null, DEFAULT_ENCODER, null);
+ return doGetString(null, null, null);
}
/**
@@ -625,6 +625,6 @@
*/
@Override
public String toString() {
- return getString(Path.URL_ENCODER);
+ return getString(Path.NO_OP_ENCODER);
}
}
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/BatchRequestBuilder.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/BatchRequestBuilder.java 2009-06-03
20:07:47 UTC (rev 966)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/BatchRequestBuilder.java 2009-06-03
20:08:46 UTC (rev 967)
@@ -681,6 +681,21 @@
return add(new DeleteBranchRequest(at, workspaceName));
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ for (Request request : requests) {
+ sb.append(request.toString());
+ sb.append("\n");
+ }
+ return sb.toString();
+ }
+
protected class NodeChange {
protected final Location location;
protected final String workspaceName;
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaLexicon.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaLexicon.java 2009-06-03 20:07:47 UTC
(rev 966)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaLexicon.java 2009-06-03 20:08:46 UTC
(rev 967)
@@ -34,6 +34,7 @@
public static final Name BASE = new BasicName(Namespace.URI, "base");
public static final Name NAMESPACE = new BasicName(Namespace.URI,
"namespace");
public static final Name NODE_TYPES = new BasicName(Namespace.URI,
"nodeTypes");
+ public static final Name REPOSITORIES = new BasicName(Namespace.URI,
"repositories");
public static final Name ROOT = new BasicName(Namespace.URI, "root");
public static final Name SYSTEM = new BasicName(Namespace.URI, "system");
public static final Name URI = new BasicName(Namespace.URI, "uri");
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrConfiguration.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrConfiguration.java 2009-06-03
20:07:47 UTC (rev 966)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrConfiguration.java 2009-06-03
20:08:46 UTC (rev 967)
@@ -23,20 +23,31 @@
*/
package org.jboss.dna.jcr;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import org.jboss.dna.cnd.CndImporter;
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Graph;
+import org.jboss.dna.graph.Node;
import org.jboss.dna.graph.connector.RepositorySource;
+import org.jboss.dna.graph.io.Destination;
+import org.jboss.dna.graph.io.GraphBatchDestination;
import org.jboss.dna.graph.mimetype.MimeTypeDetector;
import org.jboss.dna.graph.property.Path;
+import org.jboss.dna.graph.sequencer.StreamSequencer;
import org.jboss.dna.repository.Configurator;
import org.jboss.dna.repository.DnaConfiguration;
import org.jboss.dna.repository.DnaConfigurationException;
-import org.jboss.dna.repository.DnaLexicon;
+import org.jboss.dna.repository.Configurator.And;
import org.jboss.dna.repository.Configurator.ChooseClass;
-import org.jboss.dna.repository.Configurator.ConfigRepositoryDetails;
+import org.jboss.dna.repository.Configurator.ConfigSourceDetails;
import org.jboss.dna.repository.Configurator.MimeTypeDetectorDetails;
-import org.jboss.dna.repository.Configurator.RepositoryDetails;
+import org.jboss.dna.repository.Configurator.RepositorySourceDetails;
+import org.jboss.dna.repository.Configurator.SequencerDetails;
+import org.jboss.dna.repository.Configurator.SetName;
/**
* A configuration builder for a {@link JcrEngine}. This class is an internal
domain-specific language (DSL), and is designed to
@@ -56,8 +67,8 @@
* </pre>
*/
public class JcrConfiguration
- implements Configurator.Initializer<JcrConfiguration>,
/*Configurator.SequencerConfigurator<JcrConfiguration>,*/
- Configurator.RepositoryConfigurator<JcrConfiguration>,
Configurator.MimeDetectorConfigurator<JcrConfiguration>,
+ implements Configurator.Initializer<JcrConfiguration>,
Configurator.SequencerConfigurator<JcrConfiguration>,
+ Configurator.RepositorySourceConfigurator<JcrConfiguration>,
Configurator.MimeDetectorConfigurator<JcrConfiguration>,
Configurator.Builder<JcrEngine> {
private final JcrConfiguration.Builder<JcrConfiguration> builder;
@@ -91,44 +102,65 @@
/**
* {@inheritDoc}
*
- * @see
org.jboss.dna.repository.Configurator.Initializer#withConfigurationRepository()
+ * @see org.jboss.dna.repository.Configurator.Initializer#withConfigurationSource()
*/
- public ChooseClass<RepositorySource,
ConfigRepositoryDetails<JcrConfiguration>> withConfigurationRepository() {
- return builder.withConfigurationRepository();
+ public ChooseClass<RepositorySource,
ConfigSourceDetails<JcrConfiguration>> withConfigurationSource() {
+ return builder.withConfigurationSource();
}
- // /**
- // * {@inheritDoc}
- // *
- // * @see
org.jboss.dna.repository.Configurator.SequencerConfigurator#addSequencer(java.lang.String)
- // */
- // public ChooseClass<Sequencer, SequencerDetails<JcrConfiguration>>
addSequencer( String id ) {
- // CheckArg.isNotEmpty(id, "id");
- // return builder.addSequencer(id);
- // }
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.repository.Configurator.SequencerConfigurator#addSequencer(java.lang.String)
+ */
+ public ChooseClass<StreamSequencer, SequencerDetails<JcrConfiguration>>
addSequencer( String id ) {
+ CheckArg.isNotEmpty(id, "id");
+ return builder.addSequencer(id);
+ }
/**
* {@inheritDoc}
*
- * @see
org.jboss.dna.repository.Configurator.RepositoryConfigurator#addRepository(java.lang.String)
+ * @see
org.jboss.dna.repository.Configurator.RepositorySourceConfigurator#addSource(java.lang.String)
*/
- public ChooseClass<RepositorySource,
JcrRepositoryDetails<JcrConfiguration>> addRepository( String id ) {
+ public ChooseClass<RepositorySource,
RepositorySourceDetails<JcrConfiguration>> addSource( String id ) {
CheckArg.isNotEmpty(id, "id");
- return builder.addRepository(id);
+ return builder.addSource(id);
}
/**
* {@inheritDoc}
*
- * @see
org.jboss.dna.repository.Configurator.RepositoryConfigurator#addRepository(org.jboss.dna.graph.connector.RepositorySource)
+ * @see
org.jboss.dna.repository.Configurator.RepositorySourceConfigurator#addSource(org.jboss.dna.graph.connector.RepositorySource)
*/
- public JcrConfiguration addRepository( RepositorySource source ) {
+ public JcrConfiguration addSource( RepositorySource source ) {
CheckArg.isNotNull(source, "source");
CheckArg.isNotEmpty(source.getName(), "source.getName()");
- return builder.addRepository(source);
+ return builder.addSource(source);
}
/**
+ * Add a JCR repository to this configuration.
+ *
+ * @param id the identifier for this repository; may not be null or empty
+ * @return the interface used to configure the repository
+ */
+ public SourceSetter<JcrRepositoryDetails<JcrConfiguration>>
addRepository( final String id ) {
+ CheckArg.isNotEmpty(id, "id");
+ final JcrConfiguration.Builder<JcrConfiguration> builder = this.builder;
+ return new SourceSetter<JcrRepositoryDetails<JcrConfiguration>>() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.jcr.JcrConfiguration.SourceSetter#usingSource(java.lang.String)
+ */
+ public JcrRepositoryDetails<JcrConfiguration> usingSource( String
sourceId ) {
+ return builder.addRepository(id, sourceId);
+ }
+ };
+ }
+
+ /**
* {@inheritDoc}
*
* @see
org.jboss.dna.repository.Configurator.MimeDetectorConfigurator#addMimeTypeDetector(java.lang.String)
@@ -161,9 +193,67 @@
return new JcrEngine(builder.buildDnaEngine());
}
+ /**
+ * The interface used to set the RepositorySource that should be used.
+ *
+ * @param <ReturnType> the interface returned from these methods
+ */
+ public interface SourceSetter<ReturnType> {
+ /**
+ * Set the repository source that should be used.
+ *
+ * @param sourceId that identifier of the repository source
+ * @return the next component to continue configuration; never null
+ */
+ ReturnType usingSource( String sourceId );
+ }
+
public interface JcrRepositoryDetails<ReturnType>
- extends RepositoryDetails<ReturnType>,
SetOptions<JcrRepositoryDetails<ReturnType>> {
+ extends SetOptions<JcrRepositoryDetails<ReturnType>>,
SetNamespace<JcrRepositoryDetails<ReturnType>>,
+ SetName<JcrRepositoryDetails<ReturnType>>,
+ /* SetDescription<JcrRepositoryDetails<ReturnType>>, */
+ And<ReturnType> {
+ /**
+ * Specify that the CND in the supplied string should be loaded into the
repository.
+ *
+ * @param cndContents the string containing the compact node definitions
+ * @return this object for chained method invocation
+ * @throws IllegalArgumentException if the string is null or empty
+ * @throws DnaConfigurationException if there is an error reading the CND
contents
+ */
+ JcrRepositoryDetails<ReturnType> withNodeTypes( String cndContents );
+
+ /**
+ * Specify that the CND file is to be loaded into the repository.
+ *
+ * @param cndFile the CND file
+ * @return this object for chained method invocation
+ * @throws IllegalArgumentException if the file is null
+ * @throws DnaConfigurationException if there is an error reading the file
+ */
+ JcrRepositoryDetails<ReturnType> withNodeTypes( File cndFile );
+
+ /**
+ * Specify that the CND file is to be loaded into the repository.
+ *
+ * @param urlOfCndFile the URL of the CND file
+ * @return this object for chained method invocation
+ * @throws IllegalArgumentException if the URL is null
+ * @throws DnaConfigurationException if there is an error reading the content at
the URL
+ */
+ JcrRepositoryDetails<ReturnType> withNodeTypes( URL urlOfCndFile );
+
+ /**
+ * Specify that the CND file is to be loaded into the repository.
+ *
+ * @param cndContent the stream containing the CND content
+ * @return this object for chained method invocation
+ * @throws IllegalArgumentException if the URL is null
+ * @throws DnaConfigurationException if there is an error reading the stream at
the URL
+ */
+ JcrRepositoryDetails<ReturnType> withNodeTypes( InputStream cndContent );
+
}
/**
@@ -198,8 +288,41 @@
ReturnType setTo( String value );
}
+ /**
+ * Interface for setting a namespace for a {@link JcrRepository JCR repository}.
+ *
+ * @param <ReturnType> the interface returned after the option has been set.
+ */
+ public interface SetNamespace<ReturnType> {
+ /**
+ * Specify the repository option that is to be set. The value may be set using
the interface returned by this method.
+ *
+ * @param uri the uri for the namespace
+ * @return the interface used to set the value for the property; never null
+ */
+ NamespaceSetter<ReturnType> withNamespace( String uri );
+ }
+
+ /**
+ * The interface used to set the prefix for a namespace.
+ *
+ * @param <ReturnType> the interface returned from these methods
+ * @see JcrConfiguration.SetNamespace#withNamespace(String)
+ */
+ public interface NamespaceSetter<ReturnType> {
+ /**
+ * Set the prefix for the namespace
+ *
+ * @param prefix the prefix for the namespace
+ * @return the next component to continue configuration; never null
+ */
+ ReturnType usingPrefix( String prefix );
+ }
+
public static class Builder<ReturnType> extends
DnaConfiguration.Builder<ReturnType> {
+ private Path repositoriesPath;
+
/**
* Specify a new {@link ExecutionContext} that should be used for this DNA
instance.
*
@@ -216,42 +339,183 @@
return graph();
}
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.dna.repository.Configurator.RepositoryConfigurator#addRepository(java.lang.String)
- */
- @Override
- public ChooseClass<RepositorySource,
JcrRepositoryDetails<ReturnType>> addRepository( String id ) {
+ protected Path repositoriesPath() {
+ // Make sure the "dna:repositories" node is there
+ if (repositoriesPath == null) {
+ Path path = pathFactory().create(this.configurationSource.getPath(),
DnaLexicon.REPOSITORIES);
+ Node node = graph().createIfMissing(path).andReturn();
+ this.repositoriesPath = node.getLocation().getPath();
+ }
+ return this.repositoriesPath;
+ }
+
+ public JcrRepositoryDetails<ReturnType> addRepository( String id,
+ String sourceId ) {
CheckArg.isNotEmpty(id, "id");
- // Now create the "dna:source" node with the supplied id ...
- Path path = createOrReplaceNode(sourcesPath(), id);
- JcrRepositoryDetails<ReturnType> details = new
JcrGraphRepositoryDetails<ReturnType>(path, builder);
- return new ClassChooser<RepositorySource,
JcrRepositoryDetails<ReturnType>>(path, details);
+ // Now create the "dna:repositories/id" node ...
+ Path path = createOrReplaceNode(repositoriesPath(), id);
+ configuration().set(DnaLexicon.SOURCE_NAME).to(sourceId).on(path);
+ return new JcrGraphRepositoryDetails<ReturnType>(path, builder);
}
- public class JcrGraphRepositoryDetails<RT> extends
GraphRepositoryDetails<RT> implements JcrRepositoryDetails<RT> {
+ public class JcrGraphRepositoryDetails<RT> implements
JcrRepositoryDetails<RT> {
+ private final Path path;
+ private final RT returnObject;
protected JcrGraphRepositoryDetails( Path path,
RT returnObject ) {
- super(path, returnObject);
+ this.path = path;
+ this.returnObject = returnObject;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.repository.Configurator.SetName#named(java.lang.String)
+ */
@SuppressWarnings( "synthetic-access" )
- public OptionSetter<JcrRepositoryDetails<RT>> with( final
JcrRepository.Option option ) {
- final Path optionsPath = createOrReplaceNode(path(),
DnaLexicon.OPTIONS);
+ public JcrRepositoryDetails<RT> named( String name ) {
+ configuration().set(DnaLexicon.READABLE_NAME).to(name).on(name);
+ return this;
+ }
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.jcr.JcrConfiguration.SetNamespace#withNamespace(java.lang.String)
+ */
+ @SuppressWarnings( "synthetic-access" )
+ public NamespaceSetter<JcrRepositoryDetails<RT>> withNamespace(
final String uri ) {
+ final Path namespacesPath = createOrReplaceNode(path,
DnaLexicon.NAMESPACES);
final JcrRepositoryDetails<RT> details = this;
+ return new NamespaceSetter<JcrRepositoryDetails<RT>>() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.jcr.JcrConfiguration.NamespaceSetter#usingPrefix(java.lang.String)
+ */
+ public JcrRepositoryDetails<RT> usingPrefix( String prefix ) {
+ Path nsPath = createOrReplaceNode(namespacesPath, prefix);
+ configuration().set(DnaLexicon.URI).to(uri).on(nsPath);
+ return details;
+ }
+ };
+ }
+ @SuppressWarnings( "synthetic-access" )
+ public OptionSetter<JcrRepositoryDetails<RT>> with( final
JcrRepository.Option option ) {
+ final Path optionsPath = createOrReplaceNode(path, DnaLexicon.OPTIONS);
+ final JcrRepositoryDetails<RT> details = this;
return new OptionSetter<JcrRepositoryDetails<RT>>() {
public JcrRepositoryDetails<RT> setTo( String value ) {
Path optionPath = createOrReplaceNode(optionsPath,
option.name());
configuration().set(DnaLexicon.VALUE).to(value).on(optionPath);
-
return details;
}
};
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.jcr.JcrConfiguration.JcrRepositoryDetails#withNodeTypes(java.lang.String)
+ */
+ public JcrRepositoryDetails<RT> withNodeTypes( String content ) {
+ CheckArg.isNotEmpty(content, "content");
+ CndImporter importer = createCndImporter();
+ try {
+ importer.importFrom(content, getProblems(), "stream");
+ } catch (IOException e) {
+ throw new DnaConfigurationException(e);
+ }
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.jcr.JcrConfiguration.JcrRepositoryDetails#withNodeTypes(java.net.URL)
+ */
+ public JcrRepositoryDetails<RT> withNodeTypes( URL url ) {
+ CheckArg.isNotNull(url, "url");
+ // Obtain the stream ...
+ InputStream stream = null;
+ boolean foundError = false;
+ try {
+ stream = url.openStream();
+ CndImporter importer = createCndImporter();
+ importer.importFrom(stream, getProblems(), url.toString());
+ } catch (IOException e) {
+ foundError = true;
+ throw new DnaConfigurationException(e);
+ } finally {
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ if (!foundError) {
+ throw new DnaConfigurationException(e);
+ }
+ }
+ }
+ }
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.jcr.JcrConfiguration.JcrRepositoryDetails#withNodeTypes(java.io.File)
+ */
+ public JcrRepositoryDetails<RT> withNodeTypes( File file ) {
+ CheckArg.isNotNull(file, "file");
+ if (file.exists() && file.canRead()) {
+ CndImporter importer = createCndImporter();
+ try {
+ importer.importFrom(file, getProblems());
+ } catch (IOException e) {
+ throw new DnaConfigurationException(e);
+ }
+ return this;
+ }
+ throw new
DnaConfigurationException(JcrI18n.fileDoesNotExist.text(file.getPath()));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.jcr.JcrConfiguration.JcrRepositoryDetails#withNodeTypes(java.io.InputStream)
+ */
+ public JcrRepositoryDetails<RT> withNodeTypes( InputStream stream ) {
+ CndImporter importer = createCndImporter();
+ try {
+ importer.importFrom(stream, getProblems(), "stream");
+ } catch (IOException e) {
+ throw new DnaConfigurationException(e);
+ }
+ return this;
+ }
+
+ @SuppressWarnings( "synthetic-access" )
+ protected CndImporter createCndImporter() {
+ // The node types will be loaded into
'dna:repositories/{repositoryName}/dna:nodeTypes/' ...
+ Path nodeTypesPath = createOrReplaceNode(path, DnaLexicon.NODE_TYPES);
+
+ // Now set up the destination ...
+ Destination destination = new GraphBatchDestination(graph().batch()); //
will be executed
+
+ // And create the importer that will load the CND content into the
repository ...
+ return new CndImporter(destination, nodeTypesPath);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.repository.Configurator.And#and()
+ */
+ public RT and() {
+ return returnObject;
+ }
}
}
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrEngine.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrEngine.java 2009-06-03 20:07:47 UTC
(rev 966)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrEngine.java 2009-06-03 20:08:46 UTC
(rev 967)
@@ -39,12 +39,14 @@
import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.Node;
+import org.jboss.dna.graph.Subgraph;
import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
import org.jboss.dna.graph.connector.RepositorySource;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.PathFactory;
import org.jboss.dna.graph.property.PathNotFoundException;
import org.jboss.dna.graph.property.Property;
+import org.jboss.dna.graph.property.basic.GraphNamespaceRegistry;
import org.jboss.dna.jcr.JcrRepository.Option;
import org.jboss.dna.repository.DnaEngine;
import org.jboss.dna.repository.RepositoryLibrary;
@@ -138,12 +140,13 @@
repositoriesLock.lock();
JcrRepository repository = repositories.get(repositoryName);
if (repository == null) {
- if (getRepositorySource(repositoryName) == null) {
+ try {
+ repository = doCreateJcrRepository(repositoryName);
+ } catch (PathNotFoundException e) {
// The repository name is not a valid repository ...
String msg = JcrI18n.repositoryDoesNotExist.text(repositoryName);
throw new RepositoryException(msg);
}
- repository = doCreateJcrRepository(repositoryName);
repositories.put(repositoryName, repository);
}
return repository;
@@ -155,50 +158,54 @@
protected JcrRepository doCreateJcrRepository( String repositoryName ) {
RepositoryConnectionFactory connectionFactory =
getRepositoryConnectionFactory();
Map<String, String> descriptors = null;
-
- /*
- * Extract the JCR options from the configuration graph
- */
- String configurationName =
dnaEngine.getRepositoryService().getConfigurationSourceName();
Map<Option, String> options = new HashMap<Option, String>();
+ // Read the subgraph that represents the repository ...
PathFactory pathFactory =
getExecutionContext().getValueFactories().getPathFactory();
+ Path repositoriesPath = pathFactory.create(DnaLexicon.REPOSITORIES);
+ Path repositoryPath = pathFactory.create(repositoriesPath, repositoryName);
+ String configurationName =
dnaEngine.getRepositoryService().getConfigurationSourceName();
Graph configuration =
Graph.create(connectionFactory.createConnection(configurationName),
getExecutionContext());
+ Subgraph subgraph = configuration.getSubgraphOfDepth(3).at(repositoryPath);
- try {
- Node sources =
configuration.getNodeAt(pathFactory.create(DnaLexicon.SOURCES));
+ // Read the options ...
+ Node optionsNode = subgraph.getNode(DnaLexicon.OPTIONS);
+ if (optionsNode != null) {
+ for (Location optionLocation : optionsNode.getChildren()) {
+ Node optionNode = configuration.getNodeAt(optionLocation);
+ Path.Segment segment = optionLocation.getPath().getLastSegment();
+ Property valueProperty = optionNode.getProperty(DnaLexicon.VALUE);
+ if (valueProperty == null) continue;
+ Option option = Option.findOption(segment.getName().getLocalName());
+ if (option == null) continue;
+ options.put(option, valueProperty.getFirstValue().toString());
+ }
+ }
- /*
- * Hopefully, this can all get cleaned up when the connector layer supports
queries
- */
- for (Location childLocation : sources.getChildren()) {
- Node source = configuration.getNodeAt(childLocation);
+ // Read the namespaces ...
+ ExecutionContext context = getExecutionContext();
+ Node namespacesNode = subgraph.getNode(DnaLexicon.NAMESPACES);
+ if (namespacesNode != null) {
+ GraphNamespaceRegistry registry = new GraphNamespaceRegistry(configuration,
namespacesNode.getLocation().getPath(),
+
DnaLexicon.NAMESPACE_URI);
+ context = context.with(registry);
+ }
- Property nameProperty = source.getProperty("name");
- if (nameProperty != null &&
nameProperty.getFirstValue().toString().equals(repositoryName)) {
- for (Location optionsLocation : source.getChildren()) {
- if
(DnaLexicon.OPTIONS.equals(optionsLocation.getPath().getLastSegment().getName())) {
- Node optionsNode = configuration.getNodeAt(optionsLocation);
+ // Create the repository ...
+ JcrRepository repository = new JcrRepository(context, connectionFactory,
repositoryName, descriptors, options);
- for (Location optionLocation : optionsNode.getChildren()) {
- Path.Segment segment =
optionLocation.getPath().getLastSegment();
- Node optionNode =
configuration.getNodeAt(optionLocation);
- Property valueProperty =
optionNode.getProperty(DnaLexicon.VALUE);
-
-
options.put(Option.valueOf(segment.getName().getLocalName()),
valueProperty.getFirstValue()
-
.toString());
-
- }
-
- }
- }
- }
+ // Register all the the node types ...
+ Node nodeTypesNode = subgraph.getNode(DnaLexicon.NODE_TYPES);
+ if (nodeTypesNode != null) {
+ try {
+ repository.getRepositoryTypeManager().registerNodeTypes(subgraph,
nodeTypesNode.getLocation());
+ } catch (RepositoryException e) {
+ // Error registering the node types ...
+ getProblems().addError(e, JcrI18n.errorRegisteringNodeTypes,
repositoryName);
}
- } catch (PathNotFoundException pnfe) {
- // Must not be any configuration set up
}
- return new JcrRepository(getExecutionContext(), connectionFactory,
repositoryName, descriptors, options);
+ return repository;
}
/*
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java 2009-06-03 20:07:47 UTC
(rev 966)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java 2009-06-03 20:08:46 UTC
(rev 967)
@@ -44,6 +44,7 @@
public static I18n repositoryMustBeConfigured;
public static I18n sourceInUse;
public static I18n repositoryDoesNotExist;
+ public static I18n fileDoesNotExist;
public static I18n noNamespaceWithPrefix;
public static I18n noNamespaceWithUri;
@@ -59,6 +60,7 @@
public static I18n unableToRemapUriNotRegisteredInNamespaceRegistry;
public static I18n unableToRemapUriUsingPrefixUsedInNamespaceRegistry;
+ public static I18n errorRegisteringNodeTypes;
public static I18n errorWhileInitializingTheNamespaceRegistry;
public static I18n invalidRelativePath;
public static I18n invalidPathParameter;
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2009-06-03 20:07:47
UTC (rev 966)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2009-06-03 20:08:46
UTC (rev 967)
@@ -40,6 +40,7 @@
import javax.security.auth.login.Configuration;
import javax.security.auth.login.LoginContext;
import net.jcip.annotations.ThreadSafe;
+import org.jboss.dna.common.text.Inflector;
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Graph;
@@ -90,7 +91,32 @@
* The {@link Configuration#getAppConfigurationEntry(String) JAAS application
configuration name} that specifies which
* login modules should be used to validate credentials.
*/
- JAAS_LOGIN_CONFIG_NAME,
+ JAAS_LOGIN_CONFIG_NAME;
+
+ /**
+ * Determine the option given the option name. This does more than {@link
Option#valueOf(String)}, since this method first
+ * tries to match the supplied string to the option's {@link Option#name()
name}, then the uppercase version of the
+ * supplied string to the option's name, and finally if the supplied string
is a camel-case version of the name (e.g.,
+ * "projectNodeTypes").
+ *
+ * @param option the string version of the option's name
+ * @return the matching Option instance, or null if an option could not be
matched using the supplied value
+ */
+ public static Option findOption( String option ) {
+ if (option == null) return null;
+ Option result = Option.valueOf(option);
+ if (result != null) return result;
+ // Try an uppercased version ...
+ result = Option.valueOf(option.toUpperCase());
+ if (result != null) return result;
+ // Try a camel-case version ...
+ String underscored = Inflector.getInstance().underscore(option,
'_');
+ if (underscored != null) {
+ result = Option.valueOf(underscored);
+ }
+
+ return result;
+ }
}
/**
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryNodeTypeManager.java
===================================================================
---
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryNodeTypeManager.java 2009-06-03
20:07:47 UTC (rev 966)
+++
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryNodeTypeManager.java 2009-06-03
20:08:46 UTC (rev 967)
@@ -1292,19 +1292,98 @@
*/
List<JcrNodeType> registerNodeTypes( JcrNodeTypeSource nodeTypeSource )
throws InvalidNodeTypeDefinitionException, NodeTypeExistsException,
RepositoryException {
-
assert nodeTypeSource != null;
+ Graph nodeTypesGraph = nodeTypeSource.getNodeTypes();
+ Subgraph nodeTypesSubgraph =
nodeTypesGraph.getSubgraphOfDepth(3).at("/");
+ return registerNodeTypes(nodeTypesSubgraph, nodeTypesSubgraph.getLocation());
+ }
- Graph nodeTypeBatch = nodeTypeSource.getNodeTypes();
+ /**
+ * Registers the node types from the given {@link JcrNodeTypeSource}.
+ * <p>
+ * The effect of this method is "all or nothing"; if an error
occurs, no node types are registered or updated.
+ * </p>
+ * <p>
+ * <b>DNA Implementation Notes</b>
+ * </p>
+ * <p>
+ * DNA currently supports registration of batches of types with some constraints. DNA
will allow types to be registered if
+ * they meet the following criteria:
+ * <ol>
+ * <li>Existing types cannot be modified in-place - They must be unregistered
and re-registered</li>
+ * <li>Types must have a non-null, non-empty name</li>
+ * <li>If a primary item name is specified for the node type, it must match the
name of a property OR a child node, not both</li>
+ * <li>Each type must have a valid set of supertypes - that is, the type's
supertypes must meet the following criteria:
+ * <ol>
+ * <li>The type must have at least one supertype (unless the type is {@code
nt:base}.</li>
+ * <li>No two supertypes {@code t1} and {@code t2} can declare each declare a
property ({@code p1} and {@code p2}) with the
+ * same name and cardinality ({@code p1.isMultiple() == p2.isMultiple()}). Note that
this does prohibit each {@code t1} and
+ * {@code t2} from having a common supertype (or super-supertype, etc.) that declares
a property).</li>
+ * <li>No two supertypes {@code t1} and {@code t2} can declare each declare a
child node ({@code n1} and {@code n2}) with the
+ * same name and SNS status ({@code p1.allowsSameNameSiblings() ==
p2.allowsSameNameSiblings()}). Note that this does prohibit
+ * each {@code t1} and {@code t2} from having a common supertype (or super-supertype,
etc.) that declares a child node).</li>
+ * </ol>
+ * </li>
+ * <li>Each type must have a valid set of properties - that is, the type's
properties must meet the following criteria:
+ * <ol>
+ * <li>Residual property definitions cannot be mandatory</li>
+ * <li>If the property is auto-created, it must specify a default
value</li>
+ * <li>If the property is single-valued, it can only specify a single default
value</li>
+ * <li>If the property overrides an existing property definition from a
supertype, the new definition must be mandatory if the
+ * old definition was mandatory</li>
+ * <li>The property cannot override an existing property definition from a
supertype if the ancestor definition is protected</li>
+ * <li>If the property overrides an existing property definition from a
supertype that specifies value constraints, the new
+ * definition must have the same value constraints as the old definition.
<i>This requirement may be relaxed in a future
+ * version of DNA.</i></li>
+ * <li>If the property overrides an existing property definition from a
supertype, the new definition must have the same
+ * required type as the old definition or a required type that can ALWAYS be cast to
the required type of the ancestor (see
+ * section 6.2.6 of the JCR 1.0.1 specification)</li>
+ * </ol>
+ * Note that an empty set of properties would meet the above criteria.</li>
+ * <li>The type must have a valid set of child nodes - that is, the types's
child nodes must meet the following criteria:
+ * <ol>
+ * <li>Residual child node definitions cannot be mandatory</li>
+ * <li>If the child node is auto-created, it must specify a default primary
type name</li>
+ * <li>All required primary types must already be fully registered with the
type manager or must have been defined earlier in
+ * the batch. <i>This requirement may be relaxed in a future version of
DNA.</i></li>
+ * <li>If the child node overrides an existing child node definition from a
supertype, the new definition must be mandatory if
+ * the old definition was mandatory</li>
+ * <li>The child node cannot override an existing child node definition from a
supertype if the ancestor definition is
+ * protected</li>
+ * <li>If the child node overrides an existing child node definition from a
supertype, the required primary types of the new
+ * definition must be more restrictive than the required primary types of the old
definition - that is, the new primary types
+ * must defined such that any type that satisfies all of the required primary types
for the new definition must also satisfy
+ * all of the required primary types for the old definition. This requirement is
analogous to the requirement that overriding
+ * property definitions have a required type that is always convertible to the
required type of the overridden definition.</li>
+ * </ol>
+ * Note that an empty set of child nodes would meet the above criteria.</li>
+ * </p>
+ *
+ * @param nodeTypeSubgraph the subgraph containing the of {@link NodeType node types}
to register
+ * @param locationOfParentOfNodeTypes the location of the parent node under which the
node types are found
+ * @return the newly registered (or updated) {@link NodeType NodeTypes}
+ * @throws UnsupportedRepositoryOperationException if {@code allowUpdates == true}.
DNA does not support this capability at
+ * this time but the parameter has been retained for API compatibility.
+ * @throws InvalidNodeTypeDefinitionException if the {@link NodeTypeDefinition} is
invalid
+ * @throws NodeTypeExistsException if <code>allowUpdate</code> is false
and the {@link NodeTypeDefinition} specifies a node
+ * type name that is already registered
+ * @throws RepositoryException if another error occurs
+ */
+ List<JcrNodeType> registerNodeTypes( Subgraph nodeTypeSubgraph,
+ Location locationOfParentOfNodeTypes )
+ throws InvalidNodeTypeDefinitionException, NodeTypeExistsException,
RepositoryException {
+ assert nodeTypeSubgraph != null;
+ assert locationOfParentOfNodeTypes != null;
+
NamespaceRegistry namespaces = this.context.getNamespaceRegistry();
- List<Location> nodeTypeLocations =
nodeTypeBatch.getChildren().of("/");
+ List<Location> nodeTypeLocations =
nodeTypeSubgraph.getNode(locationOfParentOfNodeTypes).getChildren();
List<JcrNodeType> typesPendingRegistration = new
ArrayList<JcrNodeType>(nodeTypeLocations.size());
try {
nodeTypeManagerLock.writeLock().lock();
for (Location location : nodeTypeLocations) {
- Node nodeTypeNode = nodeTypeBatch.getNodeAt(location);
+ Node nodeTypeNode = nodeTypeSubgraph.getNode(location);
assert location.getPath() != null;
Name internalName = location.getPath().getLastSegment().getName();
@@ -1319,7 +1398,7 @@
List<JcrNodeType> supertypes = supertypesFor(nodeTypeNode,
typesPendingRegistration);
// No need to re-parse the supertypes
- JcrNodeType nodeType =
nodeTypeFrom(nodeTypeBatch.getSubgraphOfDepth(2).at(location), supertypes);
+ JcrNodeType nodeType = nodeTypeFrom(nodeTypeSubgraph, location,
supertypes);
validate(nodeType, supertypes, typesPendingRegistration);
@@ -1383,8 +1462,9 @@
}
private JcrNodeType nodeTypeFrom( Subgraph nodeTypeGraph,
+ Location nodeTypeLocation,
List<JcrNodeType> supertypes ) {
- Node nodeTypeNode = nodeTypeGraph.getRoot();
+ Node nodeTypeNode = nodeTypeGraph.getNode(nodeTypeLocation);
List<Location> children = nodeTypeNode.getChildren();
List<JcrPropertyDefinition> properties = new
ArrayList<JcrPropertyDefinition>(children.size());
@@ -1726,13 +1806,15 @@
for (JcrNodeDefinition ancestor : ancestors) {
if (ancestor.isProtected()) {
throw new InvalidNodeTypeDefinitionException(
-
JcrI18n.cannotOverrideProtectedDefinition.text(ancestor.getDeclaringNodeType().getName(),
+
JcrI18n.cannotOverrideProtectedDefinition.text(ancestor.getDeclaringNodeType()
+
.getName(),
"child node"));
}
if (ancestor.isMandatory() && !node.isMandatory()) {
throw new InvalidNodeTypeDefinitionException(
-
JcrI18n.cannotMakeMandatoryDefinitionOptional.text(ancestor.getDeclaringNodeType().getName(),
+
JcrI18n.cannotMakeMandatoryDefinitionOptional.text(ancestor.getDeclaringNodeType()
+
.getName(),
"child node"));
}
@@ -1797,15 +1879,16 @@
Value[] defaultValues = prop.getDefaultValues();
if (prop.isAutoCreated() && !prop.isProtected() && (defaultValues
== null || defaultValues.length == 0)) {
- throw new InvalidNodeTypeDefinitionException(
-
JcrI18n.autocreatedPropertyNeedsDefault.text(prop.getName(),
-
prop.getDeclaringNodeType().getName()));
+ throw new
InvalidNodeTypeDefinitionException(JcrI18n.autocreatedPropertyNeedsDefault.text(prop.getName(),
+
prop.getDeclaringNodeType()
+
.getName()));
}
if (!prop.isMultiple() && (defaultValues != null &&
defaultValues.length > 1)) {
throw new InvalidNodeTypeDefinitionException(
JcrI18n.singleValuedPropertyNeedsSingleValuedDefault.text(prop.getName(),
-
prop.getDeclaringNodeType().getName()));
+
prop.getDeclaringNodeType()
+
.getName()));
}
Name propName =
context.getValueFactories().getNameFactory().create(prop.getName());
@@ -1819,13 +1902,15 @@
for (JcrPropertyDefinition ancestor : ancestors) {
if (ancestor.isProtected()) {
throw new InvalidNodeTypeDefinitionException(
-
JcrI18n.cannotOverrideProtectedDefinition.text(ancestor.getDeclaringNodeType().getName(),
+
JcrI18n.cannotOverrideProtectedDefinition.text(ancestor.getDeclaringNodeType()
+
.getName(),
"property"));
}
if (ancestor.isMandatory() && !prop.isMandatory()) {
throw new InvalidNodeTypeDefinitionException(
-
JcrI18n.cannotMakeMandatoryDefinitionOptional.text(ancestor.getDeclaringNodeType().getName(),
+
JcrI18n.cannotMakeMandatoryDefinitionOptional.text(ancestor.getDeclaringNodeType()
+
.getName(),
"property"));
}
@@ -1836,14 +1921,16 @@
&& !Arrays.equals(ancestor.getValueConstraints(),
prop.getValueConstraints())) {
throw new InvalidNodeTypeDefinitionException(
JcrI18n.constraintsChangedInSubtype.text(propName,
-
ancestor.getDeclaringNodeType().getName()));
+
ancestor.getDeclaringNodeType()
+
.getName()));
}
if (!isAlwaysSafeConversion(prop.getRequiredType(),
ancestor.getRequiredType())) {
throw new InvalidNodeTypeDefinitionException(
JcrI18n.cannotRedefineProperty.text(propName,
PropertyType.nameFromValue(prop.getRequiredType()),
-
ancestor.getDeclaringNodeType().getName(),
+
ancestor.getDeclaringNodeType()
+
.getName(),
PropertyType.nameFromValue(ancestor.getRequiredType())));
}
Modified: trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties
===================================================================
--- trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties 2009-06-03
20:07:47 UTC (rev 966)
+++ trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties 2009-06-03
20:08:46 UTC (rev 967)
@@ -34,6 +34,7 @@
repositoryMustBeConfigured = DNA repositories must be configured with either a repository
source factory or a repository source.
sourceInUse = All sessions must end before a new repository source can be set
repositoryDoesNotExist = There is no repository named "{0}"
+fileDoesNotExist = Unable to find or read the file "{0}"
noNamespaceWithPrefix = There is no namespace with prefix "{0}"
noNamespaceWithUri = There is no namespace with URI "{0}"
@@ -49,6 +50,7 @@
unableToRemapUriNotRegisteredInNamespaceRegistry = Unable to remap the namespace
"{1}" to prefix "{0}" because the URI is not already registered in the
workspace's namespace registry
unableToRemapUriUsingPrefixUsedInNamespaceRegistry = Unable to remap the namespace
"{1}" to prefix "{0}" because the prefix is already used as the prefix
for the namespace "{2}" in the workspace's namespace registry
+errorRegisteringNodeTypes = Error while registering the node types for repository
"{0}"
errorWhileInitializingTheNamespaceRegistry = Error while initializing the namespace
registry for workspace "{0}"
invalidRelativePath = "{0}" is not a valid relative path
invalidPathParameter = The "{1}" parameter value "{0}" was not a
valid path
Modified: trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/dna_builtins.cnd
===================================================================
--- trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/dna_builtins.cnd 2009-06-03
20:07:47 UTC (rev 966)
+++ trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/dna_builtins.cnd 2009-06-03
20:08:46 UTC (rev 967)
@@ -1,12 +1,38 @@
/*
- * DNA Built-In Types
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*/
-
+//------------------------------------------------------------------------------
+// N A M E S P A C E S
+//------------------------------------------------------------------------------
<nt = "http://www.jcp.org/jcr/nt/1.0">
<mix = "http://www.jcp.org/jcr/mix/1.0">
<dna = "http://www.jboss.org/dna/1.0">
+//------------------------------------------------------------------------------
+// N O D E T Y P E S
+//------------------------------------------------------------------------------
+
[dna:namespace] > nt:base
- dna:uri (string) primary protected version
@@ -25,3 +51,4 @@
- * (undefined) version
+ jcr:system (dna:system) = dna:system autocreated mandatory protected ignore
+ * (nt:base) = nt:base multiple version
+
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/CndNodeTypeRegistrationTest.java
===================================================================
---
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/CndNodeTypeRegistrationTest.java 2009-06-03
20:07:47 UTC (rev 966)
+++
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/CndNodeTypeRegistrationTest.java 2009-06-03
20:08:46 UTC (rev 967)
@@ -23,10 +23,10 @@
*/
package org.jboss.dna.jcr;
-import java.io.IOException;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;
+import java.io.IOException;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.jcr.nodetype.NodeType;
@@ -72,7 +72,7 @@
@Test( expected = AssertionError.class )
public void shouldNotAllowNullTypeSource() throws Exception {
- repoTypeManager.registerNodeTypes(null);
+ repoTypeManager.registerNodeTypes((JcrNodeTypeSource)null);
}
@Test( expected = RepositoryException.class )
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/InMemoryRepositoryStub.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/InMemoryRepositoryStub.java 2009-06-03
20:07:47 UTC (rev 966)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/InMemoryRepositoryStub.java 2009-06-03
20:08:46 UTC (rev 967)
@@ -23,16 +23,13 @@
*/
package org.jboss.dna.jcr;
-import java.io.File;
import java.net.URI;
import java.util.Properties;
import org.apache.jackrabbit.test.RepositoryStub;
import org.jboss.dna.common.collection.Problem;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Graph;
-import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
-import org.jboss.dna.graph.io.GraphImporter;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.jcr.JcrRepository.Option;
import org.jboss.security.config.IDTrustConfiguration;
@@ -42,7 +39,7 @@
*/
public class InMemoryRepositoryStub extends RepositoryStub {
private static final String REPOSITORY_SOURCE_NAME = "Test Repository
Source";
-
+
private JcrRepository repository;
static {
@@ -62,52 +59,57 @@
super(env);
// Create the in-memory (DNA) repository
- JcrEngine engine = new JcrConfiguration()
- .withConfigurationRepository()
- .usingClass(InMemoryRepositorySource.class.getName())
- .loadedFromClasspath()
- .describedAs("configuration repository")
- .with("name").setTo("configuration")
- .and()
- .addRepository("JCR Repository")
- .usingClass(InMemoryRepositorySource.class.getName())
- .loadedFromClasspath()
- .with(Option.PROJECT_NODE_TYPES).setTo(Boolean.FALSE.toString())
- .describedAs("JCR Repository")
- .with("name").setTo(REPOSITORY_SOURCE_NAME)
- .and().build();
+ JcrEngine engine = new JcrConfiguration().withConfigurationSource()
+
.usingClass(InMemoryRepositorySource.class.getName())
+ .loadedFromClasspath()
+ .describedAs("configuration
repository")
+ .usingWorkspace("configuration
workspace")
+ .with("name")
+ .setTo("configuration
repository")
+ .with("defaultWorkspaceName")
+ .setTo("configuration
workspace")
+ .and()
+ .addSource("Store")
+
.usingClass(InMemoryRepositorySource.class.getName())
+ .loadedFromClasspath()
+ .describedAs("JCR Repository
persistent store")
+ .and()
+ .addRepository(REPOSITORY_SOURCE_NAME)
+ .usingSource("Store")
+
.withNodeTypes(getClass().getClassLoader().getResource("tck_test_types.cnd"))
+ .with(Option.PROJECT_NODE_TYPES)
+ .setTo(Boolean.FALSE.toString())
+ .and()
+ .build();
engine.start();
-
+
+ // Print all of the problems from the engine configuration ...
+ for (Problem problem : engine.getProblems()) {
+ System.err.println(problem);
+ }
+ if (engine.getProblems().hasErrors()) {
+ throw new IllegalStateException("Problems starting JCR
repository");
+ }
+
ExecutionContext executionContext = engine.getExecutionContext();
executionContext.getNamespaceRegistry().register(TestLexicon.Namespace.PREFIX,
TestLexicon.Namespace.URI);
try {
repository = engine.getRepository(REPOSITORY_SOURCE_NAME);
- RepositoryNodeTypeManager nodeTypes = repository.getRepositoryTypeManager();
// Set up some sample nodes in the graph to match the expected test
configuration
- Graph graph = Graph.create(repository.getRepositorySourceName(),
engine.getRepositoryConnectionFactory(), executionContext);
- GraphImporter importer = new GraphImporter(graph);
+ Graph graph = Graph.create(repository.getRepositorySourceName(),
+ engine.getRepositoryConnectionFactory(),
+ executionContext);
Path destinationPath =
executionContext.getValueFactories().getPathFactory().createRootPath();
+ // URI xmlContent = new
File("src/test/resources/repositoryForTckTests.xml").toURI();
+ URI xmlContent =
getClass().getClassLoader().getResource("repositoryForTckTests.xml").toURI();
+ graph.importXmlFrom(xmlContent).into(destinationPath);
- CndNodeTypeSource nodeTypeSource = new
CndNodeTypeSource("/tck_test_types.cnd");
-
- for (Problem problem : nodeTypeSource.getProblems()) {
- System.err.println(problem);
- }
- if (!nodeTypeSource.isValid()) {
- throw new IllegalStateException("Problems loading TCK test node
types");
- }
-
- nodeTypes.registerNodeTypes(nodeTypeSource);
-
- URI xmlContent = new
File("src/test/resources/repositoryForTckTests.xml").toURI();
- importer.importXml(xmlContent, Location.create(destinationPath)).execute();
-
} catch (Exception ex) {
// The TCK tries to quash this exception. Print it out to be more obvious.
ex.printStackTrace();
- throw new IllegalStateException("Repository initialization
failed.", ex);
+ throw new IllegalStateException("Failed to initialize the repository
with text content.", ex);
}
}
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrConfigurationTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrConfigurationTest.java 2009-06-03
20:07:47 UTC (rev 966)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrConfigurationTest.java 2009-06-03
20:08:46 UTC (rev 967)
@@ -32,10 +32,12 @@
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.Subgraph;
import org.jboss.dna.graph.cache.CachePolicy;
import org.jboss.dna.graph.cache.ImmutableCachePolicy;
import org.jboss.dna.graph.connector.RepositoryConnection;
+import org.jboss.dna.graph.connector.RepositorySource;
import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
import org.jboss.dna.graph.mimetype.ExtensionBasedMimeTypeDetector;
import org.jboss.dna.graph.property.Path;
@@ -88,7 +90,7 @@
newSource.setRootNodeUuid(rootUuid);
// Update the configuration and save it ...
- configuration.addRepository(newSource).save();
+ configuration.addSource(newSource).save();
// Verify that the graph has been updated correctly ...
Subgraph subgraph =
configuration.graph().getSubgraphOfDepth(3).at("/");
@@ -102,9 +104,90 @@
}
@Test
+ public void
shouldAllowSettingUpConfigurationRepositoryWithDifferentConfigurationSourceName() throws
Exception {
+ JcrEngine engine = configuration.withConfigurationSource()
+
.usingClass(InMemoryRepositorySource.class.getName())
+ .loadedFromClasspath()
+ .describedAs("Configuration
Repository")
+ .with("name")
+ .setTo("config")
+ .with("retryLimit")
+ .setTo(5)
+ .and()
+ .addSource("Source2")
+
.usingClass(InMemoryRepositorySource.class.getName())
+ .loadedFromClasspath()
+ .describedAs("description")
+ .and()
+ .addRepository("JCR Repository")
+ .usingSource("Source2")
+ .with(Option.JAAS_LOGIN_CONFIG_NAME)
+ .setTo("test")
+ .and()
+ .build();
+ engine.start();
+ // Get a graph to the configuration source ...
+ RepositorySource configReposSource =
engine.getRepositoryService().getRepositoryLibrary().getSource("config");
+ assertThat(configReposSource, is(notNullValue()));
+ assertThat(configReposSource, is(instanceOf(InMemoryRepositorySource.class)));
+ assertThat(configReposSource.getName(), is("config"));
+ InMemoryRepositorySource configSource =
(InMemoryRepositorySource)configReposSource;
+ assertThat(configSource.getDefaultWorkspaceName(), is(""));
+ Graph graph = Graph.create("config",
engine.getRepositoryService().getRepositoryLibrary(), context);
+ assertThat(graph, is(notNullValue()));
+ assertThat(graph.getNodeAt("/"), is(notNullValue()));
+
+ // Get the repository ...
+ JcrRepository repository = engine.getRepository("JCR Repository");
+ assertThat(repository, is(notNullValue()));
+ }
+
+ @Test
+ public void shouldAllowSettingUpConfigurationRepositoryWithDifferentWorkspaceName()
throws Exception {
+ JcrEngine engine = configuration.withConfigurationSource()
+
.usingClass(InMemoryRepositorySource.class.getName())
+ .loadedFromClasspath()
+ .describedAs("Configuration
Repository")
+ .usingWorkspace("workspaceXYZ")
+ .with("name")
+ .setTo("config2")
+ .with("defaultWorkspaceName")
+ .setTo("workspaceXYZ")
+ .with("retryLimit")
+ .setTo(5)
+ .and()
+ .addSource("Source2")
+
.usingClass(InMemoryRepositorySource.class.getName())
+ .loadedFromClasspath()
+ .describedAs("description")
+ .and()
+ .addRepository("JCR Repository")
+ .usingSource("Source2")
+ .with(Option.JAAS_LOGIN_CONFIG_NAME)
+ .setTo("test")
+ .and()
+ .build();
+ engine.start();
+ // Get a graph to the configuration source ...
+ RepositorySource configReposSource =
engine.getRepositoryService().getRepositoryLibrary().getSource("config2");
+ assertThat(configReposSource, is(notNullValue()));
+ assertThat(configReposSource, is(instanceOf(InMemoryRepositorySource.class)));
+ assertThat(configReposSource.getName(), is("config2"));
+ InMemoryRepositorySource configSource =
(InMemoryRepositorySource)configReposSource;
+ assertThat(configSource.getDefaultWorkspaceName(),
is("workspaceXYZ"));
+ Graph graph = Graph.create("config2",
engine.getRepositoryService().getRepositoryLibrary(), context);
+ assertThat(graph, is(notNullValue()));
+ assertThat(graph.getNodeAt("/"), is(notNullValue()));
+
+ // Get the repository ...
+ JcrRepository repository = engine.getRepository("JCR Repository");
+ assertThat(repository, is(notNullValue()));
+ }
+
+ @Test
public void shouldAllowAddingRepositorySourceByClassNameAndSettingProperties() {
// Update the configuration and save it ...
- configuration.addRepository("Source1")
+ configuration.addSource("Source1")
.usingClass(InMemoryRepositorySource.class.getName())
.loadedFromClasspath()
.describedAs("description")
@@ -126,7 +209,7 @@
@Test
public void
shouldAllowAddingRepositorySourceByClassNameAndClasspathAndSettingProperties() {
// Update the configuration and save it ...
- configuration.addRepository("Source1")
+ configuration.addSource("Source1")
.usingClass(InMemoryRepositorySource.class.getName())
.loadedFrom("cp1", "cp2")
.describedAs("description")
@@ -149,7 +232,7 @@
@Test
public void shouldAllowAddingRepositorySourceByClassReferenceAndSettingProperties()
{
// Update the configuration and save it ...
- configuration.addRepository("Source1")
+ configuration.addSource("Source1")
.usingClass(InMemoryRepositorySource.class)
.describedAs("description")
.with("retryLimit")
@@ -171,13 +254,13 @@
@Test
public void shouldAllowOverwritingRepositorySourceByRepositoryName() {
// Update the configuration and save it ...
- configuration.addRepository("Source1")
+ configuration.addSource("Source1")
.usingClass(InMemoryRepositorySource.class)
.describedAs("description")
.with("retryLimit")
.setTo(3)
.and()
- .addRepository("Source1")
+ .addSource("Source1")
.usingClass(InMemoryRepositorySource.class)
.describedAs("new description")
.with("retryLimit")
@@ -200,7 +283,7 @@
@Test
public void shouldAllowAddingMimeTypeDetector() {
// Update the configuration and save it ...
- configuration.addRepository("Source1")
+ configuration.addSource("Source1")
.usingClass(InMemoryRepositorySource.class)
.describedAs("description")
.and()
@@ -228,7 +311,7 @@
@Test
public void shouldAllowConfigurationInMultipleSteps() {
-
configuration.addRepository("Source1").usingClass(InMemoryRepositorySource.class).describedAs("description");
+
configuration.addSource("Source1").usingClass(InMemoryRepositorySource.class).describedAs("description");
configuration.addMimeTypeDetector("detector")
.usingClass(ExtensionBasedMimeTypeDetector.class)
.describedAs("default detector");
@@ -254,49 +337,59 @@
public void shouldAllowSpecifyingOptions() throws Exception {
// Update the configuration and save it ...
- JcrEngine engine = configuration.withConfigurationRepository()
- .usingClass(InMemoryRepositorySource.class.getName())
- .loadedFromClasspath()
- .describedAs("Configuration Repository")
- .with("name").setTo("configuration")
- .with("retryLimit")
- .setTo(5)
- .and()
- .addRepository("Source2")
- .usingClass(InMemoryRepositorySource.class.getName())
- .loadedFromClasspath()
- .with(Option.JAAS_LOGIN_CONFIG_NAME).setTo("test")
- .describedAs("description")
- .with("name").setTo("JCR Repository")
- .and()
- .build();
+ JcrEngine engine = configuration.withConfigurationSource()
+
.usingClass(InMemoryRepositorySource.class.getName())
+ .loadedFromClasspath()
+ .describedAs("Configuration
Repository")
+ .with("name")
+ .setTo("configuration")
+ .with("retryLimit")
+ .setTo(5)
+ .and()
+ .addSource("Source2")
+
.usingClass(InMemoryRepositorySource.class.getName())
+ .loadedFromClasspath()
+ .describedAs("description")
+ .and()
+ .addRepository("JCR Repository")
+ .usingSource("Source2")
+ .with(Option.JAAS_LOGIN_CONFIG_NAME)
+ .setTo("test")
+ .and()
+ .build();
engine.start();
// Verify that the graph has been updated correctly ...
- Subgraph subgraph =
configuration.graph().getSubgraphOfDepth(3).at("/");
+ Subgraph subgraph =
configuration.graph().getSubgraphOfDepth(6).at("/");
assertThat(subgraph.getNode("/dna:sources"), is(notNullValue()));
assertThat(subgraph.getNode("/dna:sources/Source2"),
is(notNullValue()));
assertThat(subgraph.getNode("/dna:sources/Source2"),
hasProperty(DnaLexicon.READABLE_NAME, "Source2"));
assertThat(subgraph.getNode("/dna:sources/Source2"),
hasProperty(DnaLexicon.CLASSNAME,
InMemoryRepositorySource.class.getName()));
-
+ assertThat(subgraph.getNode("/dna:repositories"), is(notNullValue()));
+ assertThat(subgraph.getNode("/dna:repositories/JCR Repository"),
is(notNullValue()));
+ assertThat(subgraph.getNode("/dna:repositories/JCR Repository"),
hasProperty(DnaLexicon.SOURCE_NAME, "Source2"));
+ assertThat(subgraph.getNode("/dna:repositories/JCR
Repository/dna:options"), is(notNullValue()));
+ assertThat(subgraph.getNode("/dna:repositories/JCR
Repository/dna:options/JAAS_LOGIN_CONFIG_NAME"),
+ hasProperty(DnaLexicon.VALUE, "test"));
+
JcrRepository repository = engine.getRepository("JCR Repository");
-
+
Map<Option, String> options = new HashMap<Option, String>();
options.put(Option.JAAS_LOGIN_CONFIG_NAME, "test");
options.put(Option.PROJECT_NODE_TYPES, "false");
assertThat(repository.getOptions(), is(options));
}
-
+
@Test
public void shouldAllowCreatingWithConfigRepository() throws InterruptedException {
- DnaEngine engine = new DnaConfiguration().withConfigurationRepository()
- .usingClass(InMemoryRepositorySource.class)
- .describedAs("Configuration
Repository")
- .with("name")
- .setTo("config repo")
- .and()
- .build();
+ DnaEngine engine = new DnaConfiguration().withConfigurationSource()
+
.usingClass(InMemoryRepositorySource.class)
+ .describedAs("Configuration
Repository")
+ .with("name")
+ .setTo("config repo")
+ .and()
+ .build();
assertThat(engine.getRepositorySource("config repo"),
is(notNullValue()));
assertThat(engine.getRepositorySource("config repo"),
is(instanceOf(InMemoryRepositorySource.class)));
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/Configurator.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/Configurator.java 2009-06-03
20:07:47 UTC (rev 966)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/Configurator.java 2009-06-03
20:08:46 UTC (rev 967)
@@ -24,6 +24,8 @@
import java.util.ArrayList;
import java.util.List;
import net.jcip.annotations.Immutable;
+import org.jboss.dna.common.collection.Problems;
+import org.jboss.dna.common.collection.SimpleProblems;
import org.jboss.dna.common.component.ClassLoaderFactory;
import org.jboss.dna.common.i18n.I18n;
import org.jboss.dna.common.text.Inflector;
@@ -40,6 +42,7 @@
import org.jboss.dna.graph.property.PathFactory;
import org.jboss.dna.graph.property.ValueFormatException;
import org.jboss.dna.graph.property.basic.RootPath;
+import org.jboss.dna.graph.sequencer.StreamSequencer;
import org.jboss.dna.repository.sequencer.Sequencer;
/**
@@ -55,14 +58,22 @@
public interface SequencerConfigurator<ReturnType> {
/**
- * Add a new {@link Sequencer sequencer} to this configuration. The new sequencer
will have the supplied name, and if the
- * name of an existing sequencer is used, this will replace the existing
sequencer configuration.
+ * Add a new {@link StreamSequencer sequencer} to this configuration. The new
sequencer will have the supplied name, and
+ * if the name of an existing sequencer is used, this will replace the existing
sequencer configuration.
*
* @param id the identifier of the new sequencer
* @return the interface for choosing the class, which returns the interface used
to configure the sequencer; never null
* @throws IllegalArgumentException if the sequencer name is null, empty, or
otherwise invalid
*/
- public ChooseClass<Sequencer, SequencerDetails<ReturnType>>
addSequencer( final String id );
+ public ChooseClass<StreamSequencer, SequencerDetails<ReturnType>>
addSequencer( String id );
+
+ /**
+ * Get the details for the sequencer with the supplied identifier.
+ *
+ * @param id the identifier of the sequencer that is to be added
+ * @return the details for the repository source, or null if there is no such
source in this configuration
+ */
+ public SequencerDetails<ReturnType> sequencer( String id );
}
/**
@@ -76,10 +87,17 @@
* default each configuration uses an internal transient repository for its
configuration, but using this method will make
* the configuration use a different repository (that is perhaps shared with
other processes).
*
- * @return the interface for choosing the class, which returns the interface used
to configure the repository source that
- * will be used for the configuration repository; never null
+ * @return the interface for choosing the class, which returns the interface used
to configure the source that will be
+ * used for the configuration repository; never null
*/
- public ChooseClass<RepositorySource,
ConfigRepositoryDetails<ReturnType>> withConfigurationRepository();
+ public ChooseClass<RepositorySource, ConfigSourceDetails<ReturnType>>
withConfigurationSource();
+
+ /**
+ * Get the details for the configuration repository source.
+ *
+ * @return the details for the configuration's repository source; never null
+ */
+ public ConfigSourceDetails<ReturnType> configurationSource();
}
/**
@@ -87,7 +105,7 @@
*
* @param <ReturnType> the type of interface to return after the repository
source's configuration is completed
*/
- public interface RepositoryConfigurator<ReturnType> {
+ public interface RepositorySourceConfigurator<ReturnType> {
/**
* Add a new {@link RepositorySource repository} for this configuration. The new
repository will have the supplied name,
* and if the name of an existing repository is used, this will replace the
existing repository configuration.
@@ -96,9 +114,9 @@
* @return the interface for choosing the class, which returns the interface used
to configure the repository source;
* never null
* @throws IllegalArgumentException if the repository name is null, empty, or
otherwise invalid
- * @see #addRepository(RepositorySource)
+ * @see #addSource(RepositorySource)
*/
- public ChooseClass<RepositorySource, ? extends
RepositoryDetails<ReturnType>> addRepository( final String id );
+ public ChooseClass<RepositorySource,
RepositorySourceDetails<ReturnType>> addSource( final String id );
/**
* Add a new {@link RepositorySource repository} for this configuration. The new
repository will have the supplied name,
@@ -107,9 +125,17 @@
* @param source the {@link RepositorySource} instance that should be used
* @return this configuration object, for method-chaining purposes
* @throws IllegalArgumentException if the repository source reference is null
- * @see #addRepository(String)
+ * @see #addSource(String)
*/
- public ReturnType addRepository( RepositorySource source );
+ public ReturnType addSource( RepositorySource source );
+
+ /**
+ * Get the details for the repository source with the supplied identifier.
+ *
+ * @param id the identifier of the repository that is to be added
+ * @return the details for the repository source, or null if there is no such
source in this configuration
+ */
+ public RepositorySourceDetails<ReturnType> source( String id );
}
/**
@@ -127,6 +153,14 @@
* @throws IllegalArgumentException if the detector name is null, empty, or
otherwise invalid
*/
public ChooseClass<MimeTypeDetector,
MimeTypeDetectorDetails<ReturnType>> addMimeTypeDetector( final String id );
+
+ /**
+ * Get the details for the MIME type detector with the supplied identifier.
+ *
+ * @param id the identifier of the MIME type detector that is to be added
+ * @return the details for the MIME type detector, or null if there is no such
detector in this configuration
+ */
+ public MimeTypeDetectorDetails<ReturnType> mimeTypeDetector( String id );
}
/**
@@ -149,9 +183,9 @@
*
* @param <ReturnType>
*/
- public interface RepositoryDetails<ReturnType>
- extends SetName<RepositoryDetails<ReturnType>>,
SetDescription<RepositoryDetails<ReturnType>>,
- SetProperties<RepositoryDetails<ReturnType>>, And<ReturnType>
{
+ public interface RepositorySourceDetails<ReturnType>
+ extends SetName<RepositorySourceDetails<ReturnType>>,
SetDescription<RepositorySourceDetails<ReturnType>>,
+ SetProperties<RepositorySourceDetails<ReturnType>>,
And<ReturnType> {
}
/**
@@ -159,16 +193,15 @@
*
* @param <ReturnType>
*/
- public interface ConfigRepositoryDetails<ReturnType>
- extends SetDescription<ConfigRepositoryDetails<ReturnType>>,
SetProperties<ConfigRepositoryDetails<ReturnType>>,
- And<ReturnType> {
+ public interface ConfigSourceDetails<ReturnType>
+ extends SetDescription<ConfigSourceDetails<ReturnType>>,
SetProperties<ConfigSourceDetails<ReturnType>>, And<ReturnType> {
/**
* Specify the path under which the configuration content is to be found. This
path is assumed to be "/" by default.
*
* @param path the path to the configuration content in the configuration source;
may not be null
* @return this instance for method chaining purposes; never null
*/
- public ConfigRepositoryDetails<ReturnType> under( String path );
+ public ConfigSourceDetails<ReturnType> under( String path );
/**
* Specify the path under which the configuration content is to be found. This
path is assumed to be "/" by default.
@@ -176,7 +209,7 @@
* @param workspace the name of the workspace with the configuration content in
the configuration source; may not be null
* @return this instance for method chaining purposes; never null
*/
- public ConfigRepositoryDetails<ReturnType> inWorkspace( String workspace
);
+ public ConfigSourceDetails<ReturnType> usingWorkspace( String workspace );
}
/**
@@ -242,86 +275,84 @@
*/
public interface SetProperties<ReturnType> {
/**
- * Specify the name of the JavaBean-style property that is to be set. The value
may be set using the interface returned by
- * this method.
+ * Set the property value to an integer.
*
* @param beanPropertyName the name of the JavaBean-style property (e.g.,
"retryLimit")
- * @return the interface used to set the value for the property; never null
- */
- PropertySetter<ReturnType> with( String beanPropertyName );
- }
-
- /**
- * The interface used to set the value for a JavaBean-style property.
- *
- * @param <ReturnType> the interface returned from these methods
- * @author Randall Hauch
- * @see Configurator.SetProperties#with(String)
- */
- public interface PropertySetter<ReturnType> {
- /**
- * Set the property value to an integer.
- *
* @param value the new value for the property
* @return the next component to continue configuration; never null
*/
- ReturnType setTo( int value );
+ ReturnType setProperty( String beanPropertyName,
+ int value );
/**
* Set the property value to a long number.
*
+ * @param beanPropertyName the name of the JavaBean-style property (e.g.,
"retryLimit")
* @param value the new value for the property
* @return the next component to continue configuration; never null
*/
- ReturnType setTo( long value );
+ ReturnType setProperty( String beanPropertyName,
+ long value );
/**
* Set the property value to a short.
*
+ * @param beanPropertyName the name of the JavaBean-style property (e.g.,
"retryLimit")
* @param value the new value for the property
* @return the next component to continue configuration; never null
*/
- ReturnType setTo( short value );
+ ReturnType setProperty( String beanPropertyName,
+ short value );
/**
* Set the property value to a boolean.
*
+ * @param beanPropertyName the name of the JavaBean-style property (e.g.,
"retryLimit")
* @param value the new value for the property
* @return the next component to continue configuration; never null
*/
- ReturnType setTo( boolean value );
+ ReturnType setProperty( String beanPropertyName,
+ boolean value );
/**
* Set the property value to a float.
*
+ * @param beanPropertyName the name of the JavaBean-style property (e.g.,
"retryLimit")
* @param value the new value for the property
* @return the next component to continue configuration; never null
*/
- ReturnType setTo( float value );
+ ReturnType setProperty( String beanPropertyName,
+ float value );
/**
* Set the property value to a double.
*
+ * @param beanPropertyName the name of the JavaBean-style property (e.g.,
"retryLimit")
* @param value the new value for the property
* @return the next component to continue configuration; never null
*/
- ReturnType setTo( double value );
+ ReturnType setProperty( String beanPropertyName,
+ double value );
/**
* Set the property value to a string.
*
+ * @param beanPropertyName the name of the JavaBean-style property (e.g.,
"retryLimit")
* @param value the new value for the property
* @return the next component to continue configuration; never null
*/
- ReturnType setTo( String value );
+ ReturnType setProperty( String beanPropertyName,
+ String value );
/**
* Set the property value to an object.
*
+ * @param beanPropertyName the name of the JavaBean-style property (e.g.,
"retryLimit")
* @param value the new value for the property
* @return the next component to continue configuration; never null
*/
- ReturnType setTo( Object value );
+ ReturnType setProperty( String beanPropertyName,
+ Object value );
}
/**
@@ -378,10 +409,10 @@
/**
* Specify the human-readable name for this component.
*
- * @param description the description; may be null or empty
+ * @param name the name; may be null or empty
* @return the next component to continue configuration; never null
*/
- ReturnType named( String description );
+ ReturnType named( String name );
}
/**
@@ -434,6 +465,7 @@
protected ConfigurationRepository configurationSource;
private Graph graph;
private Graph.Batch batch;
+ private final Problems problems;
/**
* Specify a new {@link ExecutionContext} that should be used for this DNA instance.
@@ -448,12 +480,20 @@
CheckArg.isNotNull(builder, "builder");
this.context = context;
this.builder = builder;
+ this.problems = new SimpleProblems();
// Set up the default configuration repository ...
this.configurationSource = createDefaultConfigurationSource();
}
/**
+ * @return problems
+ */
+ public Problems getProblems() {
+ return problems;
+ }
+
+ /**
* Method that is used to set up the default configuration repository source. By
default, this method sets up the
* {@link InMemoryRepositorySource} loaded from the classpath.
*
@@ -522,9 +562,28 @@
protected abstract Name nameFor( String name );
protected Path createOrReplaceNode( Path parentPath,
+ String id,
+ Name propertyName,
+ Object value ) {
+ Path path = pathFactory().create(parentPath, id);
+ configuration().create(path).with(propertyName, value).and();
+ return path;
+
+ }
+
+ protected Path createOrReplaceNode( Path parentPath,
+ Name id,
+ Name propertyName,
+ Object value ) {
+ Path path = pathFactory().create(parentPath, id);
+ configuration().create(path).with(propertyName, value).and();
+ return path;
+ }
+
+ protected Path createOrReplaceNode( Path parentPath,
String id ) {
Path path = pathFactory().create(parentPath, id);
- configuration().create(path).with(DnaLexicon.READABLE_NAME, id).and();
+ configuration().create(path).and();
return path;
}
@@ -532,7 +591,7 @@
protected Path createOrReplaceNode( Path parentPath,
Name id ) {
Path path = pathFactory().create(parentPath, id);
- configuration().create(path).with(DnaLexicon.READABLE_NAME, id).and();
+ configuration().create(path).and();
return path;
}
@@ -555,7 +614,7 @@
}
protected class ConfigurationRepositoryClassChooser<ReturnType>
- implements ChooseClass<RepositorySource,
ConfigRepositoryDetails<ReturnType>> {
+ implements ChooseClass<RepositorySource,
ConfigSourceDetails<ReturnType>> {
private final ReturnType returnObject;
@@ -564,10 +623,10 @@
this.returnObject = returnObject;
}
- public LoadedFrom<ConfigRepositoryDetails<ReturnType>> usingClass(
final String className ) {
- return new LoadedFrom<ConfigRepositoryDetails<ReturnType>>() {
+ public LoadedFrom<ConfigSourceDetails<ReturnType>> usingClass( final
String className ) {
+ return new LoadedFrom<ConfigSourceDetails<ReturnType>>() {
@SuppressWarnings( "unchecked" )
- public ConfigRepositoryDetails loadedFrom( String... classpath ) {
+ public ConfigSourceDetails loadedFrom( String... classpath ) {
ClassLoader classLoader =
getExecutionContext().getClassLoader(classpath);
Class<? extends RepositorySource> clazz = null;
try {
@@ -580,7 +639,7 @@
}
@SuppressWarnings( "unchecked" )
- public ConfigRepositoryDetails loadedFromClasspath() {
+ public ConfigSourceDetails loadedFromClasspath() {
Class<? extends RepositorySource> clazz = null;
try {
clazz = (Class<? extends
RepositorySource>)Class.forName(className);
@@ -592,7 +651,7 @@
};
}
- public ConfigRepositoryDetails<ReturnType> usingClass( Class<? extends
RepositorySource> repositorySource ) {
+ public ConfigSourceDetails<ReturnType> usingClass( Class<? extends
RepositorySource> repositorySource ) {
try {
Configurator.this.configurationSource = new
ConfigurationRepository(repositorySource.newInstance());
} catch (InstantiationException err) {
@@ -606,7 +665,7 @@
}
}
- protected class ConfigurationSourceDetails<ReturnType> implements
ConfigRepositoryDetails<ReturnType> {
+ protected class ConfigurationSourceDetails<ReturnType> implements
ConfigSourceDetails<ReturnType> {
private final ReturnType returnObject;
protected ConfigurationSourceDetails( ReturnType returnObject ) {
@@ -619,7 +678,7 @@
*
* @see
org.jboss.dna.repository.Configurator.SetDescription#describedAs(java.lang.String)
*/
- public ConfigRepositoryDetails<ReturnType> describedAs( String description
) {
+ public ConfigSourceDetails<ReturnType> describedAs( String description ) {
Configurator.this.configurationSource =
Configurator.this.configurationSource.withDescription(description);
return this;
}
@@ -627,20 +686,98 @@
/**
* {@inheritDoc}
*
- * @see
org.jboss.dna.repository.Configurator.SetProperties#with(java.lang.String)
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String,
boolean)
*/
- public PropertySetter<ConfigRepositoryDetails<ReturnType>> with(
String propertyName ) {
- return new
BeanPropertySetter<ConfigRepositoryDetails<ReturnType>>(
-
Configurator.this.configurationSource.getRepositorySource(),
-
propertyName, this);
+ public ConfigSourceDetails<ReturnType> setProperty( String propertyName,
+ boolean value ) {
+ return setProperty(propertyName, (Object)value);
}
/**
* {@inheritDoc}
*
- * @see
org.jboss.dna.repository.Configurator.ConfigRepositoryDetails#inWorkspace(java.lang.String)
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String, int)
*/
- public ConfigRepositoryDetails<ReturnType> inWorkspace( String workspace )
{
+ public ConfigSourceDetails<ReturnType> setProperty( String propertyName,
+ int value ) {
+ return setProperty(propertyName, (Object)value);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String, short)
+ */
+ public ConfigSourceDetails<ReturnType> setProperty( String propertyName,
+ short value ) {
+ return setProperty(propertyName, (Object)value);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String, long)
+ */
+ public ConfigSourceDetails<ReturnType> setProperty( String propertyName,
+ long value ) {
+ return setProperty(propertyName, (Object)value);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String, float)
+ */
+ public ConfigSourceDetails<ReturnType> setProperty( String propertyName,
+ float value ) {
+ return setProperty(propertyName, (Object)value);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String, double)
+ */
+ public ConfigSourceDetails<ReturnType> setProperty( String propertyName,
+ double value ) {
+ return setProperty(propertyName, (Object)value);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String,
java.lang.String)
+ */
+ public ConfigSourceDetails<ReturnType> setProperty( String propertyName,
+ String value ) {
+ return setProperty(propertyName, (Object)value);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String,
java.lang.Object)
+ */
+ public ConfigSourceDetails<ReturnType> setProperty( String
beanPropertyName,
+ Object value ) {
+ // Set the JavaBean-style property on the RepositorySource instance ...
+ Object javaBean =
Configurator.this.configurationSource.getRepositorySource();
+ Reflection reflection = new Reflection(javaBean.getClass());
+ try {
+ reflection.invokeSetterMethodOnTarget(beanPropertyName, javaBean,
value);
+ } catch (Throwable err) {
+ I18n msg = RepositoryI18n.errorSettingJavaBeanPropertyOnInstanceOfClass;
+ throw new DnaConfigurationException(msg.text(beanPropertyName,
javaBean.getClass(), err.getMessage()), err);
+ }
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.repository.Configurator.ConfigSourceDetails#usingWorkspace(java.lang.String)
+ */
+ public ConfigSourceDetails<ReturnType> usingWorkspace( String workspace )
{
Configurator.this.configurationSource =
Configurator.this.configurationSource.withWorkspace(workspace);
return this;
}
@@ -648,9 +785,9 @@
/**
* {@inheritDoc}
*
- * @see
org.jboss.dna.repository.Configurator.ConfigRepositoryDetails#under(java.lang.String)
+ * @see
org.jboss.dna.repository.Configurator.ConfigSourceDetails#under(java.lang.String)
*/
- public ConfigRepositoryDetails<ReturnType> under( String path ) {
+ public ConfigSourceDetails<ReturnType> under( String path ) {
CheckArg.isNotNull(path, "path");
Path newPath =
getExecutionContext().getValueFactories().getPathFactory().create(path);
Configurator.this.configurationSource =
Configurator.this.configurationSource.with(newPath);
@@ -724,174 +861,142 @@
}
}
- /**
- * Reusable implementation of {@link Configurator.PropertySetter} that sets the
JavaBean-style property using reflection.
- *
- * @param <ReturnType>
- */
- protected class BeanPropertySetter<ReturnType> implements
Configurator.PropertySetter<ReturnType> {
- private final Object javaBean;
- private final String beanPropertyName;
- private final ReturnType returnObject;
-
- protected BeanPropertySetter( Object javaBean,
- String beanPropertyName,
- ReturnType returnObject ) {
- assert javaBean != null;
- assert beanPropertyName != null;
- assert returnObject != null;
- this.javaBean = javaBean;
- this.beanPropertyName = beanPropertyName;
- this.returnObject = returnObject;
- }
-
- public ReturnType setTo( boolean value ) {
- return setTo((Object)value);
- }
-
- public ReturnType setTo( int value ) {
- return setTo((Object)value);
- }
-
- public ReturnType setTo( long value ) {
- return setTo((Object)value);
- }
-
- public ReturnType setTo( short value ) {
- return setTo((Object)value);
- }
-
- public ReturnType setTo( float value ) {
- return setTo((Object)value);
- }
-
- public ReturnType setTo( double value ) {
- return setTo((Object)value);
- }
-
- public ReturnType setTo( String value ) {
- return setTo((Object)value);
- }
-
- public ReturnType setTo( Object value ) {
- // Set the JavaBean-style property on the RepositorySource instance ...
- Reflection reflection = new Reflection(javaBean.getClass());
- try {
- reflection.invokeSetterMethodOnTarget(beanPropertyName, javaBean,
value);
- } catch (Throwable err) {
- I18n msg = RepositoryI18n.errorSettingJavaBeanPropertyOnInstanceOfClass;
- throw new DnaConfigurationException(msg.text(beanPropertyName,
javaBean.getClass(), err.getMessage()), err);
- }
- return returnObject;
- }
+ protected <ReturnType> GraphRepositorySourceDetails<ReturnType>
createRepositoryDetails( Path path,
+
ReturnType returnObject ) {
+ return new GraphRepositorySourceDetails<ReturnType>(path, returnObject);
}
- /**
- * Reusable implementation of {@link Configurator.PropertySetter} that sets the
property on the specified node in the
- * configuration graph.
- *
- * @param <ReturnType>
- */
- protected class GraphPropertySetter<ReturnType> implements
Configurator.PropertySetter<ReturnType> {
+ protected class GraphRepositorySourceDetails<ReturnType> implements
RepositorySourceDetails<ReturnType> {
private final Path path;
- private final String beanPropertyName;
private final ReturnType returnObject;
- protected GraphPropertySetter( Path path,
- String beanPropertyName,
- ReturnType returnObject ) {
+ protected GraphRepositorySourceDetails( Path path,
+ ReturnType returnObject ) {
assert path != null;
- assert beanPropertyName != null;
assert returnObject != null;
this.path = path;
- this.beanPropertyName =
Inflector.getInstance().lowerCamelCase(beanPropertyName);
this.returnObject = returnObject;
}
- public ReturnType setTo( boolean value ) {
- configuration().set(nameFor(beanPropertyName)).to(value).on(path);
- return returnObject;
+ public Path path() {
+ return this.path;
}
- public ReturnType setTo( int value ) {
- configuration().set(nameFor(beanPropertyName)).to(value).on(path);
- return returnObject;
+ /**
+ * Get the name used for this source.
+ *
+ * @return the source's node name
+ */
+ public Name name() {
+ return path().getLastSegment().getName();
}
- public ReturnType setTo( long value ) {
- configuration().set(nameFor(beanPropertyName)).to(value).on(path);
- return returnObject;
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.repository.Configurator.SetName#named(java.lang.String)
+ */
+ public RepositorySourceDetails<ReturnType> named( String name ) {
+ configuration().set(DnaLexicon.READABLE_NAME).to(name).on(path);
+ return this;
}
- public ReturnType setTo( short value ) {
- configuration().set(nameFor(beanPropertyName)).to(value).on(path);
- return returnObject;
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.repository.Configurator.SetDescription#describedAs(java.lang.String)
+ */
+ public RepositorySourceDetails<ReturnType> describedAs( String description
) {
+ configuration().set(DnaLexicon.DESCRIPTION).to(description).on(path);
+ return this;
}
- public ReturnType setTo( float value ) {
- configuration().set(nameFor(beanPropertyName)).to(value).on(path);
- return returnObject;
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String,
boolean)
+ */
+ public RepositorySourceDetails<ReturnType> setProperty( String
propertyName,
+ boolean value ) {
+ configuration().set(nameFor(propertyName)).to(value).on(path);
+ return this;
}
- public ReturnType setTo( double value ) {
- configuration().set(nameFor(beanPropertyName)).to(value).on(path);
- return returnObject;
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String, int)
+ */
+ public RepositorySourceDetails<ReturnType> setProperty( String
propertyName,
+ int value ) {
+ configuration().set(nameFor(propertyName)).to(value).on(path);
+ return this;
}
- public ReturnType setTo( String value ) {
- configuration().set(nameFor(beanPropertyName)).to(value).on(path);
- return returnObject;
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String, short)
+ */
+ public RepositorySourceDetails<ReturnType> setProperty( String
propertyName,
+ short value ) {
+ configuration().set(nameFor(propertyName)).to(value).on(path);
+ return this;
}
- public ReturnType setTo( Object value ) {
- configuration().set(nameFor(beanPropertyName)).to(value).on(path);
- return returnObject;
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String, long)
+ */
+ public RepositorySourceDetails<ReturnType> setProperty( String
propertyName,
+ long value ) {
+ configuration().set(nameFor(propertyName)).to(value).on(path);
+ return this;
}
- }
- protected class GraphRepositoryDetails<ReturnType> implements
RepositoryDetails<ReturnType> {
- private final Path path;
- private final ReturnType returnObject;
-
- protected GraphRepositoryDetails( Path path,
- ReturnType returnObject ) {
- assert path != null;
- assert returnObject != null;
- this.path = path;
- this.returnObject = returnObject;
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String, float)
+ */
+ public RepositorySourceDetails<ReturnType> setProperty( String
propertyName,
+ float value ) {
+ configuration().set(nameFor(propertyName)).to(value).on(path);
+ return this;
}
- protected Path path() {
- return this.path;
- }
-
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.Configurator.SetName#named(java.lang.String)
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String, double)
*/
- public RepositoryDetails<ReturnType> named( String name ) {
- configuration().set(DnaLexicon.READABLE_NAME).to(name).on(path);
+ public RepositorySourceDetails<ReturnType> setProperty( String
propertyName,
+ double value ) {
+ configuration().set(nameFor(propertyName)).to(value).on(path);
return this;
}
/**
* {@inheritDoc}
*
- * @see
org.jboss.dna.repository.Configurator.SetDescription#describedAs(java.lang.String)
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String,
java.lang.String)
*/
- public RepositoryDetails<ReturnType> describedAs( String description ) {
- configuration().set(DnaLexicon.DESCRIPTION).to(description).on(path);
+ public RepositorySourceDetails<ReturnType> setProperty( String
propertyName,
+ String value ) {
+ configuration().set(nameFor(propertyName)).to(value).on(path);
return this;
}
/**
* {@inheritDoc}
*
- * @see
org.jboss.dna.repository.Configurator.SetProperties#with(java.lang.String)
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String,
java.lang.Object)
*/
- public PropertySetter<RepositoryDetails<ReturnType>> with( String
propertyName ) {
- return new
GraphPropertySetter<RepositoryDetails<ReturnType>>(path, propertyName, this);
+ public RepositorySourceDetails<ReturnType> setProperty( String
propertyName,
+ Object value ) {
+ configuration().set(nameFor(propertyName)).to(value).on(path);
+ return this;
}
/**
@@ -1005,15 +1110,94 @@
/**
* {@inheritDoc}
*
- * @see
org.jboss.dna.repository.Configurator.SetProperties#with(java.lang.String)
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String,
boolean)
*/
- public PropertySetter<MimeTypeDetectorDetails<ReturnType>> with(
String propertyName ) {
- return new
GraphPropertySetter<MimeTypeDetectorDetails<ReturnType>>(path, propertyName,
this);
+ public MimeTypeDetectorDetails<ReturnType> setProperty( String
propertyName,
+ boolean value ) {
+ configuration().set(nameFor(propertyName)).to(value).on(path);
+ return this;
}
/**
* {@inheritDoc}
*
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String, int)
+ */
+ public MimeTypeDetectorDetails<ReturnType> setProperty( String
propertyName,
+ int value ) {
+ configuration().set(nameFor(propertyName)).to(value).on(path);
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String, short)
+ */
+ public MimeTypeDetectorDetails<ReturnType> setProperty( String
propertyName,
+ short value ) {
+ configuration().set(nameFor(propertyName)).to(value).on(path);
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String, long)
+ */
+ public MimeTypeDetectorDetails<ReturnType> setProperty( String
propertyName,
+ long value ) {
+ configuration().set(nameFor(propertyName)).to(value).on(path);
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String, float)
+ */
+ public MimeTypeDetectorDetails<ReturnType> setProperty( String
propertyName,
+ float value ) {
+ configuration().set(nameFor(propertyName)).to(value).on(path);
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String, double)
+ */
+ public MimeTypeDetectorDetails<ReturnType> setProperty( String
propertyName,
+ double value ) {
+ configuration().set(nameFor(propertyName)).to(value).on(path);
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String,
java.lang.String)
+ */
+ public MimeTypeDetectorDetails<ReturnType> setProperty( String
propertyName,
+ String value ) {
+ configuration().set(nameFor(propertyName)).to(value).on(path);
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.repository.Configurator.SetProperties#setProperty(java.lang.String,
java.lang.Object)
+ */
+ public MimeTypeDetectorDetails<ReturnType> setProperty( String
propertyName,
+ Object value ) {
+ configuration().set(nameFor(propertyName)).to(value).on(path);
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see
org.jboss.dna.repository.Configurator.SetDescription#describedAs(java.lang.String)
*/
public MimeTypeDetectorDetails<ReturnType> describedAs( String description
) {
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaConfiguration.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaConfiguration.java 2009-06-03
20:07:47 UTC (rev 966)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaConfiguration.java 2009-06-03
20:08:46 UTC (rev 967)
@@ -34,20 +34,20 @@
import org.jboss.dna.graph.mimetype.MimeTypeDetector;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.Path;
+import org.jboss.dna.graph.sequencer.StreamSequencer;
import org.jboss.dna.repository.Configurator.ChooseClass;
-import org.jboss.dna.repository.Configurator.ConfigRepositoryDetails;
+import org.jboss.dna.repository.Configurator.ConfigSourceDetails;
import org.jboss.dna.repository.Configurator.ConfigurationRepository;
import org.jboss.dna.repository.Configurator.MimeTypeDetectorDetails;
-import org.jboss.dna.repository.Configurator.RepositoryDetails;
+import org.jboss.dna.repository.Configurator.RepositorySourceDetails;
import org.jboss.dna.repository.Configurator.SequencerDetails;
-import org.jboss.dna.repository.sequencer.Sequencer;
/**
*
*/
public class DnaConfiguration
implements Configurator.Initializer<DnaConfiguration>,
Configurator.SequencerConfigurator<DnaConfiguration>,
- Configurator.RepositoryConfigurator<DnaConfiguration>,
Configurator.MimeDetectorConfigurator<DnaConfiguration>,
+ Configurator.RepositorySourceConfigurator<DnaConfiguration>,
Configurator.MimeDetectorConfigurator<DnaConfiguration>,
Configurator.Builder<DnaEngine> {
protected static final Map<String, Name> NAMES_TO_MAP;
@@ -94,28 +94,28 @@
/**
* {@inheritDoc}
*
- * @see
org.jboss.dna.repository.Configurator.Initializer#withConfigurationRepository()
+ * @see org.jboss.dna.repository.Configurator.Initializer#withConfigurationSource()
*/
- public ChooseClass<RepositorySource,
ConfigRepositoryDetails<DnaConfiguration>> withConfigurationRepository() {
- return builder.withConfigurationRepository();
+ public ChooseClass<RepositorySource,
ConfigSourceDetails<DnaConfiguration>> withConfigurationSource() {
+ return builder.withConfigurationSource();
}
/**
* {@inheritDoc}
*
- * @see
org.jboss.dna.repository.Configurator.RepositoryConfigurator#addRepository(java.lang.String)
+ * @see
org.jboss.dna.repository.Configurator.RepositorySourceConfigurator#addSource(java.lang.String)
*/
- public ChooseClass<RepositorySource, ? extends
RepositoryDetails<DnaConfiguration>> addRepository( String id ) {
- return builder.addRepository(id);
+ public ChooseClass<RepositorySource,
RepositorySourceDetails<DnaConfiguration>> addSource( String id ) {
+ return builder.addSource(id);
}
/**
* {@inheritDoc}
*
- * @see
org.jboss.dna.repository.Configurator.RepositoryConfigurator#addRepository(org.jboss.dna.graph.connector.RepositorySource)
+ * @see
org.jboss.dna.repository.Configurator.RepositorySourceConfigurator#addSource(org.jboss.dna.graph.connector.RepositorySource)
*/
- public DnaConfiguration addRepository( RepositorySource source ) {
- return builder.addRepository(source);
+ public DnaConfiguration addSource( RepositorySource source ) {
+ return builder.addSource(source);
}
/**
@@ -123,7 +123,7 @@
*
* @see
org.jboss.dna.repository.Configurator.SequencerConfigurator#addSequencer(java.lang.String)
*/
- public ChooseClass<Sequencer, SequencerDetails<DnaConfiguration>>
addSequencer( String id ) {
+ public ChooseClass<StreamSequencer, SequencerDetails<DnaConfiguration>>
addSequencer( String id ) {
return builder.addSequencer(id);
}
@@ -165,7 +165,7 @@
public static class Builder<ReturnType> extends Configurator<ReturnType>
implements Configurator.Initializer<ReturnType>,
Configurator.SequencerConfigurator<ReturnType>,
- Configurator.RepositoryConfigurator<ReturnType>,
Configurator.MimeDetectorConfigurator<ReturnType> {
+ Configurator.RepositorySourceConfigurator<ReturnType>,
Configurator.MimeDetectorConfigurator<ReturnType> {
private Path sourcesPath;
private Path sequencersPath;
@@ -187,10 +187,6 @@
return new DnaEngine(context, configurationSource);
}
- public ConfigurationRepository getConfigurationRepository() {
- return configurationSource;
- }
-
protected Path sourcesPath() {
// Make sure the "dna:sources" node is there
if (sourcesPath == null) {
@@ -224,49 +220,58 @@
/**
* {@inheritDoc}
*
- * @see
org.jboss.dna.repository.Configurator.Initializer#withConfigurationRepository()
+ * @see
org.jboss.dna.repository.Configurator.Initializer#withConfigurationSource()
*/
- public ChooseClass<RepositorySource,
ConfigRepositoryDetails<ReturnType>> withConfigurationRepository() {
+ public ChooseClass<RepositorySource, ConfigSourceDetails<ReturnType>>
withConfigurationSource() {
return new ConfigurationRepositoryClassChooser<ReturnType>(builder);
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.repository.Configurator.Initializer#configurationSource()
+ */
+ public ConfigSourceDetails<ReturnType> configurationSource() {
+ return configurationSource;
+ }
/**
* {@inheritDoc}
*
* @see
org.jboss.dna.repository.Configurator.SequencerConfigurator#addSequencer(java.lang.String)
*/
- public ChooseClass<Sequencer, SequencerDetails<ReturnType>>
addSequencer( String id ) {
+ public ChooseClass<StreamSequencer, SequencerDetails<ReturnType>>
addSequencer( String id ) {
CheckArg.isNotEmpty(id, "id");
// Now create the "dna:sequencer" node with the supplied id ...
- Path path = createOrReplaceNode(sequencersPath(), id);
+ Path path = createOrReplaceNode(sequencersPath(), id,
DnaLexicon.READABLE_NAME, id);
SequencerDetails<ReturnType> details = new
GraphSequencerDetails<ReturnType>(path, builder);
- return new ClassChooser<Sequencer,
SequencerDetails<ReturnType>>(path, details);
+ return new ClassChooser<StreamSequencer,
SequencerDetails<ReturnType>>(path, details);
}
/**
* {@inheritDoc}
*
- * @see
org.jboss.dna.repository.Configurator.RepositoryConfigurator#addRepository(java.lang.String)
+ * @see
org.jboss.dna.repository.Configurator.RepositorySourceConfigurator#addSource(java.lang.String)
*/
- public ChooseClass<RepositorySource, ? extends
RepositoryDetails<ReturnType>> addRepository( String id ) {
+ public ChooseClass<RepositorySource,
RepositorySourceDetails<ReturnType>> addSource( String id ) {
CheckArg.isNotEmpty(id, "id");
// Now create the "dna:source" node with the supplied id ...
- Path path = createOrReplaceNode(sourcesPath(), id);
- RepositoryDetails<ReturnType> details = new
GraphRepositoryDetails<ReturnType>(path, builder);
- return new ClassChooser<RepositorySource,
RepositoryDetails<ReturnType>>(path, details);
+ Path path = createOrReplaceNode(sourcesPath(), id, DnaLexicon.READABLE_NAME,
id);
+ RepositorySourceDetails<ReturnType> details = new
GraphRepositorySourceDetails<ReturnType>(path, builder);
+ return new ClassChooser<RepositorySource,
RepositorySourceDetails<ReturnType>>(path, details);
}
/**
* {@inheritDoc}
*
- * @see
org.jboss.dna.repository.Configurator.RepositoryConfigurator#addRepository(org.jboss.dna.graph.connector.RepositorySource)
+ * @see
org.jboss.dna.repository.Configurator.RepositorySourceConfigurator#addSource(org.jboss.dna.graph.connector.RepositorySource)
*/
- public ReturnType addRepository( RepositorySource source ) {
+ public ReturnType addSource( RepositorySource source ) {
CheckArg.isNotNull(source, "source");
CheckArg.isNotEmpty(source.getName(), "source.getName()");
String name = source.getName();
- RepositoryDetails<ReturnType> details =
addRepository(source.getName()).usingClass(source.getClass().getName())
-
.loadedFromClasspath();
+ RepositorySourceDetails<ReturnType> details =
addSource(source.getName()).usingClass(source.getClass().getName())
+
.loadedFromClasspath();
// Record all of the bean properties ...
Path sourcePath = pathFactory().create(sourcesPath(), name);
recordBeanPropertiesInGraph(sourcePath, source);
@@ -281,7 +286,7 @@
public ChooseClass<MimeTypeDetector,
MimeTypeDetectorDetails<ReturnType>> addMimeTypeDetector( String id ) {
CheckArg.isNotEmpty(id, "id");
// Now create the "dna:sequencer" node with the supplied id ...
- Path detectorPath = createOrReplaceNode(detectorsPath(), id);
+ Path detectorPath = createOrReplaceNode(detectorsPath(), id,
DnaLexicon.READABLE_NAME, id);
MimeTypeDetectorDetails<ReturnType> details = new
GraphMimeTypeDetectorDetails<ReturnType>(detectorPath, builder);
return new ClassChooser<MimeTypeDetector,
MimeTypeDetectorDetails<ReturnType>>(detectorPath, details);
}
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java 2009-06-03
20:07:47 UTC (rev 966)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java 2009-06-03
20:08:46 UTC (rev 967)
@@ -147,7 +147,7 @@
CheckArg.isNotNull(context, "context");
if (pathToConfigurationRoot == null) pathToConfigurationRoot =
context.getValueFactories()
.getPathFactory()
-
.create("/jcr:system");
+
.create("/dna:system");
this.sources = sources;
this.pathToConfigurationRoot = pathToConfigurationRoot;
this.configurationSourceName = configurationSourceName;
@@ -304,6 +304,12 @@
path.getLastSegment().getName().getLocalName());
properties.put(JcrLexicon.NAME, nameProperty);
+ // Attempt to set the configuration information as bean properties,
+ // if they exist on the RepositorySource object and are not already set to some
value ...
+ setBeanPropertyIfExistsAndNotSet(source, "configurationSourceName",
getConfigurationSourceName());
+ setBeanPropertyIfExistsAndNotSet(source, "configurationWorkspaceName",
getConfigurationWorkspaceName());
+ setBeanPropertyIfExistsAndNotSet(source, "configurationPath",
stringFactory.create(path));
+
// Now set all the properties that we can, ignoring any property that doesn't
fit the pattern ...
Reflection reflection = new Reflection(source.getClass());
for (Map.Entry<Name, Property> entry : properties.entrySet()) {
@@ -417,6 +423,21 @@
return source;
}
+ protected boolean setBeanPropertyIfExistsAndNotSet( Object target,
+ String propertyName,
+ Object value ) {
+ Reflection reflection = new Reflection(target.getClass());
+ try {
+ if (reflection.invokeGetterMethodOnTarget(propertyName, target) == null) {
+ reflection.invokeSetterMethodOnTarget(propertyName, target, value);
+ return true;
+ }
+ return false;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
/**
* {@inheritDoc}
*/
Modified:
trunk/dna-repository/src/test/java/org/jboss/dna/repository/DnaConfigurationTest.java
===================================================================
---
trunk/dna-repository/src/test/java/org/jboss/dna/repository/DnaConfigurationTest.java 2009-06-03
20:07:47 UTC (rev 966)
+++
trunk/dna-repository/src/test/java/org/jboss/dna/repository/DnaConfigurationTest.java 2009-06-03
20:08:46 UTC (rev 967)
@@ -36,6 +36,7 @@
import org.jboss.dna.graph.mimetype.ExtensionBasedMimeTypeDetector;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.repository.sequencer.MockSequencerA;
+import org.jboss.dna.repository.sequencer.MockStreamSequencerA;
import org.junit.Before;
import org.junit.Test;
@@ -74,7 +75,7 @@
@Test
public void shouldAllowSpecifyingConfigurationRepository() {
- DnaConfiguration config = configuration.withConfigurationRepository()
+ DnaConfiguration config = configuration.withConfigurationSource()
.usingClass("org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource")
.loadedFromClasspath()
.describedAs("description")
@@ -103,7 +104,7 @@
newSource.setRootNodeUuid(rootUuid);
// Update the configuration and save it ...
- configuration.addRepository(newSource).save();
+ configuration.addSource(newSource).save();
// Verify that the graph has been updated correctly ...
Subgraph subgraph =
configuration.graph().getSubgraphOfDepth(3).at("/");
@@ -119,7 +120,7 @@
@Test
public void shouldAllowAddingRepositorySourceByClassNameAndSettingProperties() {
// Update the configuration and save it ...
- configuration.addRepository("Source1")
+ configuration.addSource("Source1")
.usingClass(InMemoryRepositorySource.class.getName())
.loadedFromClasspath()
.describedAs("description")
@@ -141,7 +142,7 @@
@Test
public void
shouldAllowAddingRepositorySourceByClassNameAndClasspathAndSettingProperties() {
// Update the configuration and save it ...
- configuration.addRepository("Source1")
+ configuration.addSource("Source1")
.usingClass(InMemoryRepositorySource.class.getName())
.loadedFrom("cp1", "cp2")
.describedAs("description")
@@ -164,7 +165,7 @@
@Test
public void shouldAllowAddingRepositorySourceByClassReferenceAndSettingProperties()
{
// Update the configuration and save it ...
- configuration.addRepository("Source1")
+ configuration.addSource("Source1")
.usingClass(InMemoryRepositorySource.class)
.describedAs("description")
.with("retryLimit")
@@ -186,13 +187,13 @@
@Test
public void shouldAllowOverwritingRepositorySourceByRepositoryName() {
// Update the configuration and save it ...
- configuration.addRepository("Source1")
+ configuration.addSource("Source1")
.usingClass(InMemoryRepositorySource.class)
.describedAs("description")
.with("retryLimit")
.setTo(3)
.and()
- .addRepository("Source1")
+ .addSource("Source1")
.usingClass(InMemoryRepositorySource.class)
.describedAs("new description")
.with("retryLimit")
@@ -215,7 +216,7 @@
@Test
public void shouldAllowAddingMimeTypeDetector() {
// Update the configuration and save it ...
- configuration.addRepository("Source1")
+ configuration.addSource("Source1")
.usingClass(InMemoryRepositorySource.class)
.describedAs("description")
.and()
@@ -244,13 +245,13 @@
@Test
public void shouldAllowAddingSequencer() {
// Update the configuration and save it ...
- configuration.addRepository("Source1")
+ configuration.addSource("Source1")
.usingClass(InMemoryRepositorySource.class)
.describedAs("description")
.named("A Source")
.and()
.addSequencer("sequencerA")
- .usingClass(MockSequencerA.class)
+ .usingClass(MockStreamSequencerA.class)
.named("The (Main) Sequencer")
.describedAs("Mock Sequencer A")
.sequencingFrom("/foo/source")
@@ -273,7 +274,7 @@
assertThat(subgraph.getNode("/dna:sequencers/sequencerA"),
hasProperty(DnaLexicon.READABLE_NAME, "The (Main) Sequencer"));
assertThat(subgraph.getNode("/dna:sequencers/sequencerA"),
hasProperty(DnaLexicon.DESCRIPTION, "Mock Sequencer A"));
assertThat(subgraph.getNode("/dna:sequencers/sequencerA"),
hasProperty(DnaLexicon.CLASSNAME,
-
MockSequencerA.class.getName()));
+
MockStreamSequencerA.class.getName()));
System.out.println(subgraph.getNode("/dna:sequencers/sequencerA").getProperty(DnaLexicon.PATH_EXPRESSIONS));
assertThat(subgraph.getNode("/dna:sequencers/sequencerA"),
hasProperty(DnaLexicon.PATH_EXPRESSIONS,
"/foo/source => /foo/target",
@@ -282,7 +283,7 @@
@Test
public void shouldAllowConfigurationInMultipleSteps() {
-
configuration.addRepository("Source1").usingClass(InMemoryRepositorySource.class).describedAs("description");
+
configuration.addSource("Source1").usingClass(InMemoryRepositorySource.class).describedAs("description");
configuration.addMimeTypeDetector("detector")
.usingClass(ExtensionBasedMimeTypeDetector.class)
.describedAs("default detector");
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/DnaEngineTest.java
===================================================================
---
trunk/dna-repository/src/test/java/org/jboss/dna/repository/DnaEngineTest.java 2009-06-03
20:07:47 UTC (rev 966)
+++
trunk/dna-repository/src/test/java/org/jboss/dna/repository/DnaEngineTest.java 2009-06-03
20:08:46 UTC (rev 967)
@@ -36,7 +36,7 @@
import org.jboss.dna.graph.connector.RepositoryConnection;
import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
import org.jboss.dna.graph.mimetype.MimeTypeDetector;
-import org.jboss.dna.repository.sequencer.MockSequencerA;
+import org.jboss.dna.repository.sequencer.MockStreamSequencerA;
import org.jboss.dna.repository.sequencer.SequencingService;
import org.junit.Before;
import org.junit.Test;
@@ -60,7 +60,7 @@
@Test
public void shouldAllowCreatingWithConfigRepository() throws InterruptedException {
- engine = new DnaConfiguration().withConfigurationRepository()
+ engine = new DnaConfiguration().withConfigurationSource()
.usingClass(InMemoryRepositorySource.class)
.describedAs("Configuration
Repository")
.with("name")
@@ -82,13 +82,13 @@
@Test
public void shouldAllowCreatingMultipleRepositories() throws Exception {
- engine = new DnaConfiguration().withConfigurationRepository()
+ engine = new DnaConfiguration().withConfigurationSource()
.usingClass(InMemoryRepositorySource.class)
.describedAs("Configuration
Repository")
.with("name")
.setTo("config repo")
.and()
- .addRepository("JCR")
+ .addSource("JCR")
.usingClass(InMemoryRepositorySource.class)
.describedAs("Backing Repository for JCR
Implementation")
.with("name")
@@ -115,7 +115,7 @@
@Test
public void shouldAllowAddingMimeTypeDetectors() throws Exception {
- engine = new DnaConfiguration().withConfigurationRepository()
+ engine = new DnaConfiguration().withConfigurationSource()
.usingClass(InMemoryRepositorySource.class)
.describedAs("Configuration
Repository")
.with("name")
@@ -138,14 +138,14 @@
@Test
public void shouldAllowAddingSequencers() throws Exception {
- engine = new DnaConfiguration().withConfigurationRepository()
+ engine = new DnaConfiguration().withConfigurationSource()
.usingClass(InMemoryRepositorySource.class)
.describedAs("Configuration
Repository")
.with("name")
.setTo("config repo")
.and()
.addSequencer("Mock Sequencer A")
- .usingClass(MockSequencerA.class)
+ .usingClass(MockStreamSequencerA.class)
.describedAs("A Mock Sequencer")
.sequencingFrom("/**")
.andOutputtingTo("/")
Modified: trunk/docs/examples/gettingstarted/repositories/src/main/resources/aircraft.xml
===================================================================
---
trunk/docs/examples/gettingstarted/repositories/src/main/resources/aircraft.xml 2009-06-03
20:07:47 UTC (rev 966)
+++
trunk/docs/examples/gettingstarted/repositories/src/main/resources/aircraft.xml 2009-06-03
20:08:46 UTC (rev 967)
@@ -24,31 +24,31 @@
~ 51 Franklin Street, Fifth Floor
~ Boston, MA 02110-1301 USA
-->
-<Aircraft
xmlns:jcr="http://www.jcp.org/jcr/1.0"
xmlns:nt="http://www.jcp.org/jcr/nt/1.0">
+<Aircraft
xmlns:jcr="http://www.jcp.org/jcr/1.0"
xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
xmlns="http://jboss.org/dna/examples/aircraft/1.0">
<Business>
- <nt:unstructured jcr:name="Gulfstream V"
maker="Gulfstream" model="G-V" introduced="1995"
range="5800nm" cruiseSpeed="488kt" crew="2"
emptyWeight="46200lb"
url="http://en.wikipedia.org/wiki/Gulfstream_V"/>
- <nt:unstructured jcr:name="Learjet 45" maker="Learjet"
model="LJ45" introduced="1995" numberBuilt="264+"
crew="2" emptyWeight="13695lb" range="2120nm"
cruiseSpeed="457kt"
url="http://en.wikipedia.org/wiki/Learjet_45"/>
+ <Aircraft jcr:name="Gulfstream V" maker="Gulfstream"
model="G-V" introduced="1995" range="5800nm"
cruiseSpeed="488kt" crew="2" emptyWeight="46200lb"
url="http://en.wikipedia.org/wiki/Gulfstream_V"/>
+ <Aircraft jcr:name="Learjet 45" maker="Learjet"
model="LJ45" introduced="1995" numberBuilt="264+"
crew="2" emptyWeight="13695lb" range="2120nm"
cruiseSpeed="457kt"
url="http://en.wikipedia.org/wiki/Learjet_45"/>
</Business>
<Commercial>
- <nt:unstructured jcr:name="Boeing 777" maker="Boeing"
model="777-200LR" introduced="1995" numberBuilt="731+"
maxRange="7500nm" emptyWeight="326000lb"
cruiseSpeed="560mph"
url="http://en.wikipedia.org/wiki/Boeing_777"/>
- <nt:unstructured jcr:name="Boeing 767" maker="Boeing"
model="767-200" introduced="1982" numberBuilt="966+"
maxRange="3950nm" emptyWeight="176650lb"
cruiseSpeed="530mph"
url="http://en.wikipedia.org/wiki/Boeing_767"/>
- <nt:unstructured jcr:name="Boeing 787" maker="Boeing"
model="787-3" introduced="2009" range="3050nm"
emptyWeight="223000lb" cruiseSpeed="561mph"
url="http://en.wikipedia.org/wiki/Boeing_787"/>
- <nt:unstructured jcr:name="Boeing 757" maker="Boeing"
model="757-200" introduced="1983" numberBuilt="1050"
range="3900nm" maxWeight="255000lb" cruiseSpeed="530mph"
url="http://en.wikipedia.org/wiki/Boeing_757"/>
- <nt:unstructured jcr:name="Airbus A380" maker="Airbus"
model="A380-800" introduced="2007" numberBuilt="18"
range="8200nm" maxWeight="1235000lb" cruiseSpeed="647mph"
url="http://en.wikipedia.org/wiki/Airbus_a380"/>
- <nt:unstructured jcr:name="Airbus A340" maker="Airbus"
model="A340-200" introduced="1993" numberBuilt="354"
range="8000nm" maxWeight="606300lb" cruiseSpeed="557mph"
url="http://en.wikipedia.org/wiki/Airbus_A-340"/>
- <nt:unstructured jcr:name="Airbus A310" maker="Airbus"
model="A310-200" introduced="1983" numberBuilt="255"
cruiseSpeed="850km/h" emptyWeight="176312lb" range="3670nm"
url="http://en.wikipedia.org/wiki/Airbus_A-310"/>
- <nt:unstructured jcr:name="Embraer RJ-175" maker="Embraer"
model="ERJ170-200" introduced="2004" range="3334km"
cruiseSpeed="481kt" emptyWeight="21810kg"
url="http://en.wikipedia.org/wiki/EMBRAER_170"/>
+ <Aircraft jcr:name="Boeing 777" maker="Boeing"
model="777-200LR" introduced="1995" numberBuilt="731+"
maxRange="7500nm" emptyWeight="326000lb"
cruiseSpeed="560mph"
url="http://en.wikipedia.org/wiki/Boeing_777"/>
+ <Aircraft jcr:name="Boeing 767" maker="Boeing"
model="767-200" introduced="1982" numberBuilt="966+"
maxRange="3950nm" emptyWeight="176650lb"
cruiseSpeed="530mph"
url="http://en.wikipedia.org/wiki/Boeing_767"/>
+ <Aircraft jcr:name="Boeing 787" maker="Boeing"
model="787-3" introduced="2009" range="3050nm"
emptyWeight="223000lb" cruiseSpeed="561mph"
url="http://en.wikipedia.org/wiki/Boeing_787"/>
+ <Aircraft jcr:name="Boeing 757" maker="Boeing"
model="757-200" introduced="1983" numberBuilt="1050"
range="3900nm" maxWeight="255000lb" cruiseSpeed="530mph"
url="http://en.wikipedia.org/wiki/Boeing_757"/>
+ <Aircraft jcr:name="Airbus A380" maker="Airbus"
model="A380-800" introduced="2007" numberBuilt="18"
range="8200nm" maxWeight="1235000lb" cruiseSpeed="647mph"
url="http://en.wikipedia.org/wiki/Airbus_a380"/>
+ <Aircraft jcr:name="Airbus A340" maker="Airbus"
model="A340-200" introduced="1993" numberBuilt="354"
range="8000nm" maxWeight="606300lb" cruiseSpeed="557mph"
url="http://en.wikipedia.org/wiki/Airbus_A-340"/>
+ <Aircraft jcr:name="Airbus A310" maker="Airbus"
model="A310-200" introduced="1983" numberBuilt="255"
cruiseSpeed="850km/h" emptyWeight="176312lb" range="3670nm"
url="http://en.wikipedia.org/wiki/Airbus_A-310"/>
+ <Aircraft jcr:name="Embraer RJ-175" maker="Embraer"
model="ERJ170-200" introduced="2004" range="3334km"
cruiseSpeed="481kt" emptyWeight="21810kg"
url="http://en.wikipedia.org/wiki/EMBRAER_170"/>
</Commercial>
<Vintage>
- <nt:unstructured jcr:name="Fokker Trimotor" maker="Fokker"
model="F.VII" introduced="1925" cruiseSpeed="170km/h"
emptyWeight="3050kg" crew="2"
url="http://en.wikipedia.org/wiki/Fokker_trimotor"/>
- <nt:unstructured jcr:name="P-38 Lightning"
maker="Lockheed" model="P-38" designedBy="Kelly Johnson"
introduced="1941" numberBuilt="10037"
rateOfClimb="4750ft/min" range="1300mi"
emptyWeight="12780lb" crew="1"
url="http://en.wikipedia.org/wiki/P-38_Lightning"/>
- <nt:unstructured jcr:name="A6M Zero" maker="Mitsubishi"
model="A6M" designedBy="Jiro Horikoshi" introduced="1940"
numberBuilt="11000" crew="1" emptyWeight="3704lb"
serviceCeiling="33000ft" maxSpeed="331mph" range="1929mi"
rateOfClimb="3100ft/min"
url="http://en.wikipedia.org/wiki/A6M_Zero"/>
- <nt:unstructured jcr:name="Bf 109" maker="Messerschmitt"
model="Bf 109" introduced="1937"
url="http://en.wikipedia.org/wiki/BF_109"/>
- <nt:unstructured jcr:name="Wright Flyer" maker="Wright
Brothers" introduced="1903" range="852ft"
maxSpeed="30mph" emptyWeight="605lb" crew="1"/>
+ <Aircraft jcr:name="Fokker Trimotor" maker="Fokker"
model="F.VII" introduced="1925" cruiseSpeed="170km/h"
emptyWeight="3050kg" crew="2"
url="http://en.wikipedia.org/wiki/Fokker_trimotor"/>
+ <Aircraft jcr:name="P-38 Lightning" maker="Lockheed"
model="P-38" designedBy="Kelly Johnson" introduced="1941"
numberBuilt="10037" rateOfClimb="4750ft/min" range="1300mi"
emptyWeight="12780lb" crew="1"
url="http://en.wikipedia.org/wiki/P-38_Lightning"/>
+ <Aircraft jcr:name="A6M Zero" maker="Mitsubishi"
model="A6M" designedBy="Jiro Horikoshi" introduced="1940"
numberBuilt="11000" crew="1" emptyWeight="3704lb"
serviceCeiling="33000ft" maxSpeed="331mph" range="1929mi"
rateOfClimb="3100ft/min"
url="http://en.wikipedia.org/wiki/A6M_Zero"/>
+ <Aircraft jcr:name="Bf 109" maker="Messerschmitt"
model="Bf 109" introduced="1937"
url="http://en.wikipedia.org/wiki/BF_109"/>
+ <Aircraft jcr:name="Wright Flyer" maker="Wright Brothers"
introduced="1903" range="852ft" maxSpeed="30mph"
emptyWeight="605lb" crew="1"/>
</Vintage>
<Homebuilt>
- <nt:unstructured jcr:name="Long-EZ" maker="Rutan Aircraft
Factory" model="61" emptyWeight="760lb"
fuelCapacity="200L" maxSpeed="185kt" since="1976"
range="1200nm"
url="http://en.wikipedia.org/wiki/Rutan_Long-EZ"/>
- <nt:unstructured jcr:name="Cirrus VK-30" maker="Cirrus
Design" model="VK-30" emptyWeight="2400lb"
maxLoad="1200lb" maxSpeed="250mph" rateOfClimb="1500ft/min"
range="1300mi"
url="http://en.wikipedia.org/wiki/Cirrus_VK-30"/>
- <nt:unstructured jcr:name="Van's RV-4" maker="Van's
Aircraft" model="RV-4" introduced="1980"
emptyWeight="905lb" maxLoad="500lb" maxSpeed="200mph"
rateOfClimb="2450ft/min" range="725mi"
url="http://en.wikipedia.org/wiki/Van%27s_Aircraft_RV-4"/>
+ <Aircraft jcr:name="Long-EZ" maker="Rutan Aircraft
Factory" model="61" emptyWeight="760lb"
fuelCapacity="200L" maxSpeed="185kt" since="1976"
range="1200nm"
url="http://en.wikipedia.org/wiki/Rutan_Long-EZ"/>
+ <Aircraft jcr:name="Cirrus VK-30" maker="Cirrus Design"
model="VK-30" emptyWeight="2400lb" maxLoad="1200lb"
maxSpeed="250mph" rateOfClimb="1500ft/min" range="1300mi"
url="http://en.wikipedia.org/wiki/Cirrus_VK-30"/>
+ <Aircraft jcr:name="Van's RV-4" maker="Van's
Aircraft" model="RV-4" introduced="1980"
emptyWeight="905lb" maxLoad="500lb" maxSpeed="200mph"
rateOfClimb="2450ft/min" range="725mi"
url="http://en.wikipedia.org/wiki/Van%27s_Aircraft_RV-4"/>
</Homebuilt>
</Aircraft>
\ No newline at end of file
Modified: trunk/docs/examples/gettingstarted/repositories/src/main/resources/cars.xml
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/main/resources/cars.xml 2009-06-03
20:07:47 UTC (rev 966)
+++ trunk/docs/examples/gettingstarted/repositories/src/main/resources/cars.xml 2009-06-03
20:08:46 UTC (rev 967)
@@ -24,25 +24,27 @@
~ 51 Franklin Street, Fifth Floor
~ Boston, MA 02110-1301 USA
-->
-<Cars
xmlns:jcr="http://www.jcp.org/jcr/1.0"
xmlns:nt="http://www.jcp.org/jcr/nt/1.0">
+<Cars
xmlns:jcr="http://www.jcp.org/jcr/1.0"
+
xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
+
xmlns="http://jboss.org/dna/examples/cars/1.0">
<Hybrid>
- <nt:unstructured jcr:name="Toyota Prius" maker="Toyota"
model="Prius" year="2008" msrp="$21,500"
userRating="4.2" valueRating="5" mpgCity="48"
mpgHighway="45"/>
- <nt:unstructured jcr:name="Toyota Highlander"
maker="Toyota" model="Highlander" year="2008"
msrp="$34,200" userRating="4" valueRating="5"
mpgCity="27" mpgHighway="25"/>
- <nt:unstructured jcr:name="Nissan Altima" maker="Nissan"
model="Altima" year="2008" msrp="$18,260"
mpgCity="23" mpgHighway="32"/>
+ <Car jcr:name="Toyota Prius" maker="Toyota"
model="Prius" year="2008" msrp="$21,500"
userRating="4.2" valueRating="5" mpgCity="48"
mpgHighway="45"/>
+ <Car jcr:name="Toyota Highlander" maker="Toyota"
model="Highlander" year="2008" msrp="$34,200"
userRating="4" valueRating="5" mpgCity="27"
mpgHighway="25"/>
+ <Car jcr:name="Nissan Altima" maker="Nissan"
model="Altima" year="2008" msrp="$18,260"
mpgCity="23" mpgHighway="32"/>
</Hybrid>
<Sports>
- <nt:unstructured jcr:name="Aston Martin DB9" maker="Aston
Martin" model="DB9" year="2008" msrp="$171,600"
userRating="5" mpgCity="12" mpgHighway="19"
lengthInInches="185.5" wheelbaseInInches="108.0" engine="5,935 cc
5.9 liters V 12"/>
- <nt:unstructured jcr:name="Infiniti G37" maker="Infiniti"
model="G37" year="2008" msrp="$34,900"
userRating="3.5" valueRating="4" mpgCity="18"
mpgHighway="24" />
+ <Car jcr:name="Aston Martin DB9" maker="Aston Martin"
model="DB9" year="2008" msrp="$171,600"
userRating="5" mpgCity="12" mpgHighway="19"
lengthInInches="185.5" wheelbaseInInches="108.0" engine="5,935 cc
5.9 liters V 12"/>
+ <Car jcr:name="Infiniti G37" maker="Infiniti"
model="G37" year="2008" msrp="$34,900"
userRating="3.5" valueRating="4" mpgCity="18"
mpgHighway="24" />
</Sports>
<Luxury>
- <nt:unstructured jcr:name="Cadillac DTS" maker="Cadillac"
model="DTS" year="2008" engine="3.6-liter V6"
userRating="0"/>
- <nt:unstructured jcr:name="Bentley Continental"
maker="Bentley" model="Continental" year="2008"
msrp="$170,990" mpgCity="10" mpgHighway="17" />
- <nt:unstructured jcr:name="Lexus IS350" maker="Lexus"
model="IS350" year="2008" msrp="$36,305"
mpgCity="18" mpgHighway="25" userRating="4"
valueRating="5" />
+ <Car jcr:name="Cadillac DTS" maker="Cadillac"
model="DTS" year="2008" engine="3.6-liter V6"
userRating="0"/>
+ <Car jcr:name="Bentley Continental" maker="Bentley"
model="Continental" year="2008" msrp="$170,990"
mpgCity="10" mpgHighway="17" />
+ <Car jcr:name="Lexus IS350" maker="Lexus"
model="IS350" year="2008" msrp="$36,305"
mpgCity="18" mpgHighway="25" userRating="4"
valueRating="5" />
</Luxury>
<Utility>
- <nt:unstructured jcr:name="Land Rover LR2" maker="Land
Rover" model="LR2" year="2008" msrp="$33,985"
userRating="4.5" valueRating="5" mpgCity="16"
mpgHighway="23" />
- <nt:unstructured jcr:name="Land Rover LR3" maker="Land
Rover" model="LR3" year="2008" msrp="$48,525"
userRating="5" valueRating="2" mpgCity="12"
mpgHighway="17" />
- <nt:unstructured jcr:name="Hummer H3" maker="Hummer"
model="H3" year="2008" msrp="$30,595"
userRating="3.5" valueRating="4" mpgCity="13"
mpgHighway="16" />
- <nt:unstructured jcr:name="Ford F-150" maker="Ford"
model="F-150" year="2008" msrp="$23,910"
userRating="4" valueRating="1" mpgCity="14"
mpgHighway="20" />
+ <Car jcr:name="Land Rover LR2" maker="Land Rover"
model="LR2" year="2008" msrp="$33,985"
userRating="4.5" valueRating="5" mpgCity="16"
mpgHighway="23" />
+ <Car jcr:name="Land Rover LR3" maker="Land Rover"
model="LR3" year="2008" msrp="$48,525"
userRating="5" valueRating="2" mpgCity="12"
mpgHighway="17" />
+ <Car jcr:name="Hummer H3" maker="Hummer"
model="H3" year="2008" msrp="$30,595"
userRating="3.5" valueRating="4" mpgCity="13"
mpgHighway="16" />
+ <Car jcr:name="Ford F-150" maker="Ford"
model="F-150" year="2008" msrp="$23,910"
userRating="4" valueRating="1" mpgCity="14"
mpgHighway="20" />
</Utility>
</Cars>
\ No newline at end of file
Modified:
trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml
===================================================================
---
trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml 2009-06-03
20:07:47 UTC (rev 966)
+++
trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml 2009-06-03
20:08:46 UTC (rev 967)
@@ -24,14 +24,58 @@
~ 51 Franklin Street, Fifth Floor
~ Boston, MA 02110-1301 USA
-->
-<jcr:system
xmlns:dna="http://www.jboss.org/dna/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0">
- <dna:namespaces jcr:primaryType="dna:namespaces">
- </dna:namespaces>
+<configuration
xmlns="http://www.jboss.org/dna/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0">
<!-- Define the sources from which content is made available -->
- <dna:sources jcr:primaryType="nt:unstructured">
- <dna:source jcr:name="SourceA"
jcr:primaryType="nt:unstructured" dna:name="Cars"
dna:classname="org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource"
dna:retryLimit="3" defaultWorkspaceName="default"/>
- <dna:source jcr:name="SourceB"
jcr:primaryType="nt:unstructured" dna:name="Aircraft"
dna:classname="org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource"
defaultWorkspaceName="default"/>
- <dna:source jcr:name="SourceC"
jcr:primaryType="nt:unstructured" dna:name="Vehicles"
dna:classname="org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource"
defaultWorkspaceName="default"/>
- <dna:source jcr:name="SourceD"
jcr:primaryType="nt:unstructured" dna:name="Cache"
dna:classname="org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource"
defaultWorkspaceName="default"/>
- </dna:sources>
-</jcr:system>
\ No newline at end of file
+ <sources jcr:primaryType="nt:unstructured">
+ <source jcr:name="Cars"
classname="org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource"
retryLimit="3" defaultWorkspaceName="default"/>
+ <source jcr:name="Aircraft"
classname="org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource">
+ <defaultWorkspaceName>default</defaultWorkspaceName>
+ </source>
+ <source jcr:name="Vehicles">
+
<classname>org.jboss.dna.graph.connector.federated.FederatedRepositorySource</classname>
+ <workspaces>
+ <workspace jcr:name="default">
+ <projections>
+ <projection jcr:name="Main projection"
source="Cars" workspace="default">
+ <projectionRules>/Vehicles =>
/</projectionRules>
+ </projection>
+ </projections>
+ </workspace>
+ </workspaces>
+ </source>
+ <source jcr:name="Cache"
classname="org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource">
+ <defaultWorkspaceName>default</defaultWorkspaceName>
+ </source>
+ </sources>
+ <!-- Define the JCR repositories -->
+ <repositories>
+ <repository jcr:name="cars">
+ <!-- Specify the source that should be used for the repository -->
+ <source>Cars</source>
+ <!-- Define the options for the JCR repository, using camelcase version of
JcrRepository.Option names -->
+ <options jcr:primaryType="dna:options"/>
+ <!-- Define any custom node types. Importing CND files via
JcrConfiguration is equivalent to specifying here. -->
+ <nodeTypes jcr:primaryType="dna:nodeTypes"/>
+ <!-- Define any namespaces for this repository, other than those already
defined by JCR or DNA -->
+ <namespaces jcr:primaryType="dna:namespaces">
+ <car jcr:primaryType="dna:namespace"
dna:uri="http://jboss.org/dna/examples/cars/1.0"/>
+ </namespaces>
+ </repository>
+ <repository jcr:name="vehicles">
+ <!-- Specify the source that should be used for the repository -->
+ <source>Vehicles</source>
+ <!-- Define the options for the JCR repository, using camelcase version of
JcrRepository.Option names -->
+ <options jcr:primaryType="dna:options">
+ <projectNodeTypes jcr:primaryType="dna:option"
dna:value="false"/>
+ <jaasLoginConfigName jcr:primaryType="dna:option"
dna:value="dna-jcr"/>
+ </options>
+ <!-- Define any custom node types. Importing CND files via
JcrConfiguration is equivalent to specifying here. -->
+ <nodeTypes jcr:primaryType="dna:nodeTypes"/>
+ <!-- Define any namespaces for this repository, other than those already
defined by JCR, DNA or by imported content. -->
+ <namespaces jcr:primaryType="dna:namespaces">
+ <car jcr:primaryType="dna:namespace"
dna:uri="http://jboss.org/dna/examples/cars/1.0"/>
+ <air jcr:primaryType="dna:namespace"
dna:uri="http://jboss.org/dna/examples/aircraft/1.0"/>
+ </namespaces>
+ </repository>
+ </repositories>
+</configuration>
\ No newline at end of file
Modified:
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/ConsoleInput.java
===================================================================
---
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/ConsoleInput.java 2009-06-03
20:07:47 UTC (rev 966)
+++
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/ConsoleInput.java 2009-06-03
20:08:46 UTC (rev 967)
@@ -41,10 +41,8 @@
public ConsoleInput( final SequencingClient client ) {
try {
System.out.println();
- System.out.print("Starting repository and sequencing service ...
");
+ System.out.print("Starting DNA repository and sequencing service ...
");
client.startRepository();
- System.out.print("done.\nStarting sequencing service ... ");
- client.startDnaServices();
System.out.println("done.");
System.out.println();
@@ -101,9 +99,7 @@
try {
// Terminate ...
System.out.println();
- System.out.print("Shutting down sequencing service ...
");
- client.shutdownDnaServices();
- System.out.print("done.\nShutting down repository ...
");
+ System.out.print("Shutting down repository ... ");
client.shutdownRepository();
System.out.print("done.");
System.out.println();
Modified:
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java
===================================================================
---
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java 2009-06-03
20:07:47 UTC (rev 966)
+++
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java 2009-06-03
20:08:46 UTC (rev 967)
@@ -23,7 +23,6 @@
*/
package org.jboss.example.dna.sequencer;
-import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.Calendar;
@@ -32,7 +31,6 @@
import java.util.Properties;
import java.util.TreeMap;
import java.util.concurrent.TimeUnit;
-import javax.jcr.Credentials;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.PathNotFoundException;
@@ -41,73 +39,97 @@
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
import javax.jcr.Value;
import javax.jcr.ValueFormatException;
-import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
-import org.apache.jackrabbit.core.TransientRepository;
-import org.jboss.dna.common.SystemFailureException;
+import javax.security.auth.login.LoginException;
import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.repository.sequencer.SequencerConfig;
+import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
+import org.jboss.dna.jcr.JcrConfiguration;
+import org.jboss.dna.jcr.JcrEngine;
import org.jboss.dna.repository.sequencer.SequencingService;
import org.jboss.dna.repository.util.SessionFactory;
-import org.jboss.dna.repository.util.SimpleSessionFactory;
+import org.jboss.dna.sequencer.image.ImageMetadataSequencer;
+import org.jboss.dna.sequencer.java.JavaMetadataSequencer;
+import org.jboss.dna.sequencer.mp3.Mp3MetadataSequencer;
/**
* @author Randall Hauch
*/
public class SequencingClient {
- public static final String DEFAULT_JACKRABBIT_CONFIG_PATH =
"jackrabbitConfig.xml";
- public static final String DEFAULT_WORKING_DIRECTORY = "repositoryData";
public static final String DEFAULT_REPOSITORY_NAME = "repo";
public static final String DEFAULT_WORKSPACE_NAME = "default";
public static final String DEFAULT_USERNAME = "jsmith";
public static final char[] DEFAULT_PASSWORD = "secret".toCharArray();
public static void main( String[] args ) {
- SequencingClient client = new SequencingClient();
- client.setRepositoryInformation(DEFAULT_REPOSITORY_NAME, DEFAULT_WORKSPACE_NAME,
DEFAULT_USERNAME, DEFAULT_PASSWORD);
+ // Set up an execution context in which we'll run, and authenticate using
JAAS ...
+ ExecutionContext context = new ExecutionContext();
+ String jaasAppContext = "myAppContext";
+ String username = "jsmith";
+ char[] password = "secrete".toCharArray();
+ try {
+ context.with(jaasAppContext, username, password);
+ } catch (LoginException err) {
+ System.err.println("Error authenticating \"" + username +
"\". Check username and password and try again.");
+ }
+
+ // Configure the DNA JCR engine ...
+ String repositoryId = "content";
+ String workspaceName = "default";
+ JcrConfiguration config = new JcrConfiguration(context);
+
config.withConfigurationSource().usingClass(InMemoryRepositorySource.class).usingWorkspace("default").under("/");
+ // Set up an in-memory repository where the uploaded and sequenced content will
be stored ...
+ config.addSource(repositoryId)
+ .usingClass(InMemoryRepositorySource.class)
+
.withNodeTypes(ImageMetadataSequencer.class.getResource("org/jboss/dna/sequencer/image/images.cnd"))
+
.withNodeTypes(Mp3MetadataSequencer.class.getResource("org/jboss/dna/sequencer/mp3/mp3.cnd"))
+
.withNodeTypes(JavaMetadataSequencer.class.getResource("org/jboss/dna/sequencer/java/javaSource.cnd"))
+ .named("Content Repository")
+ .describedAs("The repository for our content")
+ .with("defaultWorkspaceName")
+ .setTo(workspaceName);
+ // Set up the image sequencer ...
+ config.addSequencer("images")
+
.usingClass("org.jboss.dna.sequencer.image.ImageMetadataSequencer")
+ .loadedFromClasspath()
+ .describedAs("Sequences image files to extract the characteristics of
the image")
+ .named("Image Sequencer")
+
.sequencingFrom("//(*.(jpg|jpeg|gif|bmp|pcx|png|iff|ras|pbm|pgm|ppm|psd)[*])/jcr:content[@jcr:data]")
+ .andOutputtingTo("/images/$1");
+ // Set up the MP3 sequencer ...
+ config.addSequencer("mp3s")
+ .usingClass(Mp3MetadataSequencer.class)
+ .named("MP3 Sequencer")
+ .describedAs("Sequences mp3 files to extract the id3 tags of the audio
file")
+ .sequencingFrom("//(*.mp3[*])/jcr:content[@jcr:data]")
+ .andOutputtingTo("/mp3s/$1");
+ // Set up the Java source file sequencer ...
+ config.addSequencer("javaSource")
+ .usingClass(JavaMetadataSequencer.class)
+ .named("Java Sequencer")
+ .describedAs("Sequences mp3 files to extract the id3 tags of the audio
file")
+ .sequencingFrom("//(*.mp3[*])/jcr:content[@jcr:data]")
+ .andOutputtingTo("/mp3s/$1");
+
+ // Now start the client and tell it which repository and workspace to use ...
+ SequencingClient client = new SequencingClient(config, repositoryId,
workspaceName);
client.setUserInterface(new ConsoleInput(client));
}
- private String repositoryName;
- private String workspaceName;
- private String username;
- private char[] password;
- private String jackrabbitConfigPath;
- private String workingDirectory;
- private Session keepAliveSession;
- private Repository repository;
- private SequencingService sequencingService;
+ private final String repositoryName;
+ private final String workspaceName;
+ private final JcrConfiguration configuration;
+ private JcrEngine engine;
private UserInterface userInterface;
- private ExecutionContext executionContext;
+ private Repository repository;
- public SequencingClient() {
- setJackrabbitConfigPath(DEFAULT_JACKRABBIT_CONFIG_PATH);
- setWorkingDirectory(DEFAULT_WORKING_DIRECTORY);
- setRepositoryInformation(DEFAULT_REPOSITORY_NAME, DEFAULT_WORKSPACE_NAME,
DEFAULT_USERNAME, DEFAULT_PASSWORD);
- }
-
- protected void setWorkingDirectory( String workingDirectoryPath ) {
- this.workingDirectory = workingDirectoryPath != null ? workingDirectoryPath :
DEFAULT_WORKING_DIRECTORY;
- }
-
- protected void setJackrabbitConfigPath( String jackrabbitConfigPath ) {
- this.jackrabbitConfigPath = jackrabbitConfigPath != null ? jackrabbitConfigPath :
DEFAULT_JACKRABBIT_CONFIG_PATH;
- }
-
- protected void setRepositoryInformation( String repositoryName,
- String workspaceName,
- String username,
- char[] password ) {
- if (this.repository != null) {
- throw new IllegalArgumentException("Unable to set repository information
when repository is already running");
- }
+ public SequencingClient( JcrConfiguration config,
+ String repositoryName,
+ String workspaceName ) {
+ this.configuration = config;
this.repositoryName = repositoryName != null ? repositoryName :
DEFAULT_REPOSITORY_NAME;
this.workspaceName = workspaceName != null ? workspaceName :
DEFAULT_WORKSPACE_NAME;
- this.username = username;
- this.password = password;
}
/**
@@ -127,53 +149,15 @@
public void startRepository() throws Exception {
if (this.repository == null) {
try {
+ // Start the DNA engine ...
+ this.engine = this.configuration.build();
+ this.engine.start();
- // Load the Jackrabbit configuration ...
- File configFile = new File(this.jackrabbitConfigPath);
- if (!configFile.exists()) {
- throw new SystemFailureException("The Jackrabbit configuration
file cannot be found at "
- + configFile.getAbsoluteFile());
- }
- if (!configFile.canRead()) {
- throw new SystemFailureException("Unable to read the Jackrabbit
configuration file at "
- + configFile.getAbsoluteFile());
- }
- String pathToConfig = configFile.getAbsolutePath();
+ // Now get the repository instance ...
+ this.repository = this.engine.getRepository(repositoryName);
- // Find the directory where the Jackrabbit repository data will be stored
...
- File workingDirectory = new File(this.workingDirectory);
- if (workingDirectory.exists()) {
- if (!workingDirectory.isDirectory()) {
- throw new SystemFailureException("Unable to create working
directory at "
- +
workingDirectory.getAbsolutePath());
- }
- }
- String workingDirectoryPath = workingDirectory.getAbsolutePath();
-
- // Get the Jackrabbit custom node definition (CND) file ...
- URL cndFile =
Thread.currentThread().getContextClassLoader().getResource("jackrabbitNodeTypes.cnd");
-
- // Create the Jackrabbit repository instance and establish a session to
keep the repository alive ...
- this.repository = new TransientRepository(pathToConfig,
workingDirectoryPath);
- if (this.username != null) {
- Credentials credentials = new SimpleCredentials(this.username,
this.password);
- this.keepAliveSession = this.repository.login(credentials,
this.workspaceName);
- } else {
- this.keepAliveSession = this.repository.login();
- }
-
- try {
- // Register the node types (only valid the first time) ...
- JackrabbitNodeTypeManager mgr =
(JackrabbitNodeTypeManager)this.keepAliveSession.getWorkspace()
-
.getNodeTypeManager();
- mgr.registerNodeTypes(cndFile.openStream(),
JackrabbitNodeTypeManager.TEXT_X_JCR_CND);
- } catch (RepositoryException e) {
- if (!e.getMessage().contains("already exists")) throw e;
- }
-
} catch (Exception e) {
this.repository = null;
- this.keepAliveSession = null;
throw e;
}
}
@@ -187,104 +171,21 @@
public void shutdownRepository() throws Exception {
if (this.repository != null) {
try {
- this.keepAliveSession.logout();
+ this.engine.shutdown();
+ this.engine.awaitTermination(4, TimeUnit.SECONDS);
} finally {
this.repository = null;
- this.keepAliveSession = null;
}
}
}
/**
- * Start the DNA services.
- *
- * @throws Exception
- */
- public void startDnaServices() throws Exception {
- if (this.repository == null) {
- this.startRepository();
- }
- if (this.sequencingService == null) {
-
- // Create an execution context for the sequencing service. This execution
context provides an environment
- // for the DNA services which knows about the JCR repositories, workspaces,
and credentials used to
- // establish sessions to these workspaces.
- final String repositoryWorkspaceName = this.repositoryName + "/" +
this.workspaceName;
- SimpleSessionFactory sessionFactory = new SimpleSessionFactory();
- sessionFactory.registerRepository(this.repositoryName, this.repository);
- if (this.username != null) {
- Credentials credentials = new SimpleCredentials(this.username,
this.password);
- sessionFactory.registerCredentials(repositoryWorkspaceName,
credentials);
- }
- this.executionContext = new ExecutionContext();
-
- // Create the sequencing service, passing in the execution context and the
repository library ...
- this.sequencingService = new SequencingService();
- this.sequencingService.setExecutionContext(executionContext);
- // this.sequencingService.setRepositoryLibrary(repositoryLibrary);
-
- // Configure the sequencers. In this example, we only two sequencers that
processes image and mp3 files.
- // So create a configurations. Note that the sequencing service expects the
class to be on the thread's current
- // context
- // classloader, or if that's null the classloader that loaded the
SequencingService class.
- //
- // Part of the configuration includes telling DNA which JCR paths should be
processed by the sequencer.
- // These path expressions tell the service that this sequencer should be
invoked on the "jcr:data" property
- // on the "jcr:content" child node of any node uploaded to the
repository whose name ends with one of the
- // supported extensions, and the sequencer should place the generated output
metadata in a node with the same name as
- // the file but immediately below the "/images" node. Path
expressions can be fairly complex, and can even
- // specify that the generated information be placed in a different
repository.
- //
- // Sequencer configurations can be added before or after the service is
started, but here we do it before the service
- // is running.
- String name = "Image Sequencer";
- String desc = "Sequences image files to extract the characteristics of
the image";
- String classname =
"org.jboss.dna.sequencer.image.ImageMetadataSequencer";
- String[] classpath = null; // Use the current classpath
- String[] pathExpressions =
{"//(*.(jpg|jpeg|gif|bmp|pcx|png|iff|ras|pbm|pgm|ppm|psd)[*])/jcr:content[@jcr:data]
=> /images/$1"};
- SequencerConfig imageSequencerConfig = new SequencerConfig(name, desc,
classname, classpath, pathExpressions);
- this.sequencingService.addSequencer(imageSequencerConfig);
-
- // Set up the MP3 sequencer ...
- name = "Mp3 Sequencer";
- desc = "Sequences mp3 files to extract the id3 tags of the audio
file";
- classname = "org.jboss.dna.sequencer.mp3.Mp3MetadataSequencer";
- String[] mp3PathExpressions = {"//(*.mp3[*])/jcr:content[@jcr:data]
=> /mp3s/$1"};
- SequencerConfig mp3SequencerConfig = new SequencerConfig(name, desc,
classname, classpath, mp3PathExpressions);
- this.sequencingService.addSequencer(mp3SequencerConfig);
-
- // Set up the MP3 sequencer ...
- name = "Java Sequencer";
- desc = "Sequences java files to extract the characteristics of the java
sources";
- classname = "org.jboss.dna.sequencer.java.JavaMetadataSequencer";
- String[] javaPathExpressions = {"//(*.java[*])/jcr:content[@jcr:data]
=> /java/$1"};
- SequencerConfig javaSequencerConfig = new SequencerConfig(name, desc,
classname, classpath, javaPathExpressions);
- this.sequencingService.addSequencer(javaSequencerConfig);
- }
- // Start up the sequencing service ...
- this.sequencingService.getAdministrator().start();
- }
-
- /**
- * Shut down the DNA services.
- *
- * @throws Exception
- */
- public void shutdownDnaServices() throws Exception {
- if (this.sequencingService == null) return;
-
- // Shut down the service and wait until it's all shut down ...
- this.sequencingService.getAdministrator().shutdown();
- this.sequencingService.getAdministrator().awaitTermination(5, TimeUnit.SECONDS);
- }
-
- /**
* Get the sequencing statistics.
*
* @return the statistics; never null
*/
public SequencingService.Statistics getStatistics() {
- return this.sequencingService.getStatistics();
+ return this.engine.getSequencingService().getStatistics();
}
/**
@@ -538,7 +439,7 @@
* @throws RepositoryException
*/
protected Session createSession() throws RepositoryException {
- throw new UnsupportedOperationException();
+ return this.repository.login(workspaceName);
}
protected String getMimeType( URL file ) {
Deleted:
trunk/extensions/dna-sequencer-java/src/main/resources/org/jboss/dna/sequencer/java/java-source-artifact.cnd
===================================================================
---
trunk/extensions/dna-sequencer-java/src/main/resources/org/jboss/dna/sequencer/java/java-source-artifact.cnd 2009-06-03
20:07:47 UTC (rev 966)
+++
trunk/extensions/dna-sequencer-java/src/main/resources/org/jboss/dna/sequencer/java/java-source-artifact.cnd 2009-06-03
20:08:46 UTC (rev 967)
@@ -1,257 +0,0 @@
-/*
- * JBoss DNA (
http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-/**
- * @author Serge Pagop (serge.pagop(a)innoq.com)
- */
-
-//------------------------------------------------------------------------------
-// N A M E S P A C E S
-//------------------------------------------------------------------------------
-<java='http://www.jboss.org/dna/java/1.0'>
-<nt='http://www.jcp.org/jcr/nt/1.0'>
-<mix='http://www.jcp.org/jcr/mix/1.0'>
-
-//------------------------------------------------------------------------------
-// B A S E T Y P E S
-//------------------------------------------------------------------------------
-
-
-//------------------------------------------------------------------------------
-// V E R S I O N I N G
-//------------------------------------------------------------------------------
-
-
-//------------------------------------------------------------------------------
-// N O D E T Y P E S
-//------------------------------------------------------------------------------
-
-/**
- * Element-value
- */
-[java:elementValue] > nt:unstructured
- + java:kindOfvalues (java:conditionalExpression, java:annotationDeclaration,
java:elementValueArrayInitializer) mandatory
-
-/**
- * Modifiers
- */
-[java:modifierDeclaration] > nt:unstructured
- - java:modifierName (string) mandatory
-
-/**
- * Expression element-value type
- */
-[java:conditionalExpression] > nt:unstructured
- - java:expression (string)
-
-/**
- * Array initializer element-value type
- */
-[java:elementValueArrayInitializer] > nt:unstructured
- + java:elementValue (java:elementValue) = java:elementValue multiple
-
-/**
- * Identifier
- */
-[java:identifier] > nt:unstructured
- - java:identifierName (String) mandatory
- + java:value (java:elementValue) = java:elementValue mandatory
-
-/**
- * Element-value pair
- */
-[java:elementValuePair] > nt:unstructured
- + java:identifier (java:identifier) mandatory
-
-/**
- * Annotation type
- */
-[java:annotationDeclaration] > nt:unstructured
- + java:annotationType (java:normalAnnotation, java:markerAnnotation,
java:singleElementAnnotation) mandatory
-
-/**
- * Normal annotation e.g. @Entity(name="Customer")
- */
-[java:normalAnnotation] > nt:unstructured
- - java:normalAnnotationName (string) mandatory
- + java:elementValuePair (java:elementValuePair)
-
-/**
- * Marker annotation e.g. @GET
- */
-[java:markerAnnotation] > nt:unstructured
- - java:markerAnnotationName (string) mandatory
-
-/**
- * Single element annotation e.g. @Path("/book")
- */
-[java:singleElementAnnotation] > nt:unstructured
- - java:singleElementAnnotationNam
- + java:value (java:elementValue) = java:elementValue mandatory
-
-/**
- * Formal parameter
- */
-[java:formalParameter] > nt:unstructured
- + java:type (java:primitiveType, java:arrayType, java:simpleType, java:qualifiedType,
java:wildcardType, java:parameterizedType)
-
-/**
- * Primitive type:
- * - Integral type ('byte', 'short', 'int', 'long',
'char')
- * - Floating point type ('float', 'double')
- * - Boolean type ('boolean')
- * - No return type ('void')
- */
-[java:primitiveType] > nt:unstructured
- - java:primitiveTypeDescription (string)
- + java:modifier (java:modifierDeclaration) = java:modifierDeclaration
- - java:primitiveTypeName (string) mandatory
- + java:primitiveVariable (java:variable) = java:variable
-
- [java:variable] > nt:unstructured
- - java:variableName (string) mandatory
-
-/**
- * java:arrayType
- */
-[java:arrayType] > nt:unstructured
- - java:arrayTypeDescription (string)
- + java:arrayTypeModifier (java:modifierDeclaration) = java:modifierDeclaration
- - java:arrayTypeName (string) mandatory
- + java:arrayTypeVariable (java:variable) = java:variable
-
-[java:simpleType] > nt:unstructured
- - java:simpleTypeDescription (string)
- + java:simpleTypeModifier (java:modifierDeclaration) = java:modifierDeclaration
- - java:simpleTypeName (string) mandatory
- + java:simpleTypeVariable (java:variable) = java:variable
-
-[java:qualifiedType] > nt:unstructured
- - java:qualifiedTypeDescription (string)
- + java:qualifiedTypeModifier (java:modifierDeclaration) = java:modifierDeclaration
- - java:qualifiedTypeName (string) mandatory
- + java:qualifiedTypeVariable (java:variable) = java:variable
-
-[java:wildcardType] > nt:unstructured
- - java:wildcardTypeDescription (string)
- + java:wildcardTypeModifier (java:modifierDeclaration) = java:modifierDeclaration
- - java:wildcardTypeName (string) mandatory
- + java:wildcardTypeVariable (java:variable) = java:variable
-
-[java:parameterizedType] > nt:unstructured
- - java:parameterizedTypeDescription (string)
- + java:parameterizedTypeModifier (java:modifierDeclaration) = java:modifierDeclaration
- - java:parameterizedTypeName (string) mandatory
- + java:parameterizedTypeVariable (java:variable) = java:variable
-
-/**
- * Field type
- */
-[java:fieldType] > nt:unstructured
- + java:type (java:primitiveType, java:arrayType, java:simpleType, java:qualifiedType,
java:wildcardType, java:parameterizedType) mandatory multiple
-
- /**
- * Method declaration
- */
-[java:methodDeclaration] > nt:unstructured
- - java:methodDescription (string)
- + java:modifier (java:modifierDeclaration) = java:modifierDeclaration
- + java:resultType (java:primitiveType, java:arrayType, java:simpleType,
java:qualifiedType, java:wildcardType, java:parameterizedType) mandatory
- - java:methodName (string) mandatory
- + java:parameter (java:formalParameter) multiple
-
-/**
- * Constructor declarations
- */
-[java:constructorDeclaration] > nt:unstructured
- - java:constructorDescription (string)
- + java:modifier (java:modifierDeclaration) = java:modifierDeclaration
- - java:constructorName (string) mandatory
- + java:parameter (java:formalParameter)
-
-
-/**
- * Package declarations
- */
-[java:packageDeclaration] > nt:unstructured
- + java:annotation (java:annotationDeclaration) = java:annotationDeclaration
- - java:packageKeyword (string)
- < 'package'
- - java:packageName (string) mandatory
-
-/**
- * Import declarations
- */
-[java:singleTypeImportDeclaration] > nt:unstructured
- - java:singleTypeImportkeyword (string) mandatory
- < 'import'
- - java:singleImportName (string) mandatory
-
-[java:typeImportOnDemandDeclaration] > nt:unstructured
- - java:onDemandImportKeyword (string) mandatory
- < 'import'
- - java:onDemandImportName (string) mandatory
-
- [java:importDeclaration] > nt:unstructured
- + java:singleImport (java:singleTypeImportDeclaration) =
java:singleTypeImportDeclaration
- + java:importOnDemand (java:typeImportOnDemandDeclaration) =
java:typeImportOnDemandDeclaration
-
-
-/**
- * Class declaration
- *
- * The body of class declares members (fields and methods and nested classes and
interfaces),
- * instance and static initializers, and constructors
- */
-[java:normalClassDeclaration] > nt:unstructured
- - java:description (string)
- + java:modifier (java:modifierDeclaration) = java:modifierDeclaration
- - java:normalClassName (string) mandatory
- + java:field (java:fieldType) = java:fieldType multiple
- + java:method (java:methodDeclaration) = java:methodDeclaration multiple
- + java:constructor (java:constructorDeclaration) = java:constructorDeclaration multiple
-
-[java:enumDeclaration] > nt:unstructured // TODO
-
-[java:classDeclaration] > nt:unstructured
- + java:normalClass (java:normalClassDeclaration) = java:normalClassDeclaration
- + java:enum (java:enumDeclaration) = java:enumDeclaration
-
-/**
- * Interface declaration
- *
- * The body of class declares members (fields and methods and nested classes and
interfaces),
- * instance and static initializers, and constructors
- */
- //TODO
-[java:interfaceDeclaration] > nt:unstructured
-
-
-/**
- * Compilation unit
- */
-[java:compilationUnit] > nt:unstructured
- + java:package (java:packageDeclaration) = java:packageDeclaration
- + java:import (java:importDeclaration) = java:importDeclaration
- + java:unitType (java:classDeclaration, java:interfaceDeclaration)
\ No newline at end of file
Copied:
trunk/extensions/dna-sequencer-java/src/main/resources/org/jboss/dna/sequencer/java/javaSource.cnd
(from rev 966,
trunk/extensions/dna-sequencer-java/src/main/resources/org/jboss/dna/sequencer/java/java-source-artifact.cnd)
===================================================================
---
trunk/extensions/dna-sequencer-java/src/main/resources/org/jboss/dna/sequencer/java/javaSource.cnd
(rev 0)
+++
trunk/extensions/dna-sequencer-java/src/main/resources/org/jboss/dna/sequencer/java/javaSource.cnd 2009-06-03
20:08:46 UTC (rev 967)
@@ -0,0 +1,257 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+/**
+ * @author Serge Pagop (serge.pagop(a)innoq.com)
+ */
+
+//------------------------------------------------------------------------------
+// N A M E S P A C E S
+//------------------------------------------------------------------------------
+<java='http://www.jboss.org/dna/java/1.0'>
+<nt='http://www.jcp.org/jcr/nt/1.0'>
+<mix='http://www.jcp.org/jcr/mix/1.0'>
+
+//------------------------------------------------------------------------------
+// B A S E T Y P E S
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+// V E R S I O N I N G
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+// N O D E T Y P E S
+//------------------------------------------------------------------------------
+
+/**
+ * Element-value
+ */
+[java:elementValue] > nt:unstructured
+ + java:kindOfvalues (java:conditionalExpression, java:annotationDeclaration,
java:elementValueArrayInitializer) mandatory
+
+/**
+ * Modifiers
+ */
+[java:modifierDeclaration] > nt:unstructured
+ - java:modifierName (string) mandatory
+
+/**
+ * Expression element-value type
+ */
+[java:conditionalExpression] > nt:unstructured
+ - java:expression (string)
+
+/**
+ * Array initializer element-value type
+ */
+[java:elementValueArrayInitializer] > nt:unstructured
+ + java:elementValue (java:elementValue) = java:elementValue multiple
+
+/**
+ * Identifier
+ */
+[java:identifier] > nt:unstructured
+ - java:identifierName (String) mandatory
+ + java:value (java:elementValue) = java:elementValue mandatory
+
+/**
+ * Element-value pair
+ */
+[java:elementValuePair] > nt:unstructured
+ + java:identifier (java:identifier) mandatory
+
+/**
+ * Annotation type
+ */
+[java:annotationDeclaration] > nt:unstructured
+ + java:annotationType (java:normalAnnotation, java:markerAnnotation,
java:singleElementAnnotation) mandatory
+
+/**
+ * Normal annotation e.g. @Entity(name="Customer")
+ */
+[java:normalAnnotation] > nt:unstructured
+ - java:normalAnnotationName (string) mandatory
+ + java:elementValuePair (java:elementValuePair)
+
+/**
+ * Marker annotation e.g. @GET
+ */
+[java:markerAnnotation] > nt:unstructured
+ - java:markerAnnotationName (string) mandatory
+
+/**
+ * Single element annotation e.g. @Path("/book")
+ */
+[java:singleElementAnnotation] > nt:unstructured
+ - java:singleElementAnnotationNam
+ + java:value (java:elementValue) = java:elementValue mandatory
+
+/**
+ * Formal parameter
+ */
+[java:formalParameter] > nt:unstructured
+ + java:type (java:primitiveType, java:arrayType, java:simpleType, java:qualifiedType,
java:wildcardType, java:parameterizedType)
+
+/**
+ * Primitive type:
+ * - Integral type ('byte', 'short', 'int', 'long',
'char')
+ * - Floating point type ('float', 'double')
+ * - Boolean type ('boolean')
+ * - No return type ('void')
+ */
+[java:primitiveType] > nt:unstructured
+ - java:primitiveTypeDescription (string)
+ + java:modifier (java:modifierDeclaration) = java:modifierDeclaration
+ - java:primitiveTypeName (string) mandatory
+ + java:primitiveVariable (java:variable) = java:variable
+
+ [java:variable] > nt:unstructured
+ - java:variableName (string) mandatory
+
+/**
+ * java:arrayType
+ */
+[java:arrayType] > nt:unstructured
+ - java:arrayTypeDescription (string)
+ + java:arrayTypeModifier (java:modifierDeclaration) = java:modifierDeclaration
+ - java:arrayTypeName (string) mandatory
+ + java:arrayTypeVariable (java:variable) = java:variable
+
+[java:simpleType] > nt:unstructured
+ - java:simpleTypeDescription (string)
+ + java:simpleTypeModifier (java:modifierDeclaration) = java:modifierDeclaration
+ - java:simpleTypeName (string) mandatory
+ + java:simpleTypeVariable (java:variable) = java:variable
+
+[java:qualifiedType] > nt:unstructured
+ - java:qualifiedTypeDescription (string)
+ + java:qualifiedTypeModifier (java:modifierDeclaration) = java:modifierDeclaration
+ - java:qualifiedTypeName (string) mandatory
+ + java:qualifiedTypeVariable (java:variable) = java:variable
+
+[java:wildcardType] > nt:unstructured
+ - java:wildcardTypeDescription (string)
+ + java:wildcardTypeModifier (java:modifierDeclaration) = java:modifierDeclaration
+ - java:wildcardTypeName (string) mandatory
+ + java:wildcardTypeVariable (java:variable) = java:variable
+
+[java:parameterizedType] > nt:unstructured
+ - java:parameterizedTypeDescription (string)
+ + java:parameterizedTypeModifier (java:modifierDeclaration) = java:modifierDeclaration
+ - java:parameterizedTypeName (string) mandatory
+ + java:parameterizedTypeVariable (java:variable) = java:variable
+
+/**
+ * Field type
+ */
+[java:fieldType] > nt:unstructured
+ + java:type (java:primitiveType, java:arrayType, java:simpleType, java:qualifiedType,
java:wildcardType, java:parameterizedType) mandatory multiple
+
+ /**
+ * Method declaration
+ */
+[java:methodDeclaration] > nt:unstructured
+ - java:methodDescription (string)
+ + java:modifier (java:modifierDeclaration) = java:modifierDeclaration
+ + java:resultType (java:primitiveType, java:arrayType, java:simpleType,
java:qualifiedType, java:wildcardType, java:parameterizedType) mandatory
+ - java:methodName (string) mandatory
+ + java:parameter (java:formalParameter) multiple
+
+/**
+ * Constructor declarations
+ */
+[java:constructorDeclaration] > nt:unstructured
+ - java:constructorDescription (string)
+ + java:modifier (java:modifierDeclaration) = java:modifierDeclaration
+ - java:constructorName (string) mandatory
+ + java:parameter (java:formalParameter)
+
+
+/**
+ * Package declarations
+ */
+[java:packageDeclaration] > nt:unstructured
+ + java:annotation (java:annotationDeclaration) = java:annotationDeclaration
+ - java:packageKeyword (string)
+ < 'package'
+ - java:packageName (string) mandatory
+
+/**
+ * Import declarations
+ */
+[java:singleTypeImportDeclaration] > nt:unstructured
+ - java:singleTypeImportkeyword (string) mandatory
+ < 'import'
+ - java:singleImportName (string) mandatory
+
+[java:typeImportOnDemandDeclaration] > nt:unstructured
+ - java:onDemandImportKeyword (string) mandatory
+ < 'import'
+ - java:onDemandImportName (string) mandatory
+
+ [java:importDeclaration] > nt:unstructured
+ + java:singleImport (java:singleTypeImportDeclaration) =
java:singleTypeImportDeclaration
+ + java:importOnDemand (java:typeImportOnDemandDeclaration) =
java:typeImportOnDemandDeclaration
+
+
+/**
+ * Class declaration
+ *
+ * The body of class declares members (fields and methods and nested classes and
interfaces),
+ * instance and static initializers, and constructors
+ */
+[java:normalClassDeclaration] > nt:unstructured
+ - java:description (string)
+ + java:modifier (java:modifierDeclaration) = java:modifierDeclaration
+ - java:normalClassName (string) mandatory
+ + java:field (java:fieldType) = java:fieldType multiple
+ + java:method (java:methodDeclaration) = java:methodDeclaration multiple
+ + java:constructor (java:constructorDeclaration) = java:constructorDeclaration multiple
+
+[java:enumDeclaration] > nt:unstructured // TODO
+
+[java:classDeclaration] > nt:unstructured
+ + java:normalClass (java:normalClassDeclaration) = java:normalClassDeclaration
+ + java:enum (java:enumDeclaration) = java:enumDeclaration
+
+/**
+ * Interface declaration
+ *
+ * The body of class declares members (fields and methods and nested classes and
interfaces),
+ * instance and static initializers, and constructors
+ */
+ //TODO
+[java:interfaceDeclaration] > nt:unstructured
+
+
+/**
+ * Compilation unit
+ */
+[java:compilationUnit] > nt:unstructured
+ + java:package (java:packageDeclaration) = java:packageDeclaration
+ + java:import (java:importDeclaration) = java:importDeclaration
+ + java:unitType (java:classDeclaration, java:interfaceDeclaration)
\ No newline at end of file