DNA SVN: r468 - trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/java.
by dna-commits@lists.jboss.org
Author: spagop
Date: 2008-08-26 03:32:23 -0400 (Tue, 26 Aug 2008)
New Revision: 468
Modified:
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/java/ConsoleInput.java
Log:
make some small text change
Modified: trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/java/ConsoleInput.java
===================================================================
--- trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/java/ConsoleInput.java 2008-08-26 00:07:20 UTC (rev 467)
+++ trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/java/ConsoleInput.java 2008-08-26 07:32:23 UTC (rev 468)
@@ -179,13 +179,13 @@
return;
}
if (javaInfos.size() == 1) {
- System.out.println("1 image was found:");
+ System.out.println("1 java source was found:");
} else {
System.out.println("" + javaInfos.size() + " java sources were found:");
}
int counter = 1;
for (JavaInfo javaInfo : javaInfos) {
- System.out.println(" Media " + counter++);
+ System.out.println(" Java Compilation unit " + counter++);
System.out.println(" Name: " + javaInfo.getName());
System.out.println(" Path: " + javaInfo.getPath());
System.out.println(" Type: " + javaInfo.getType());
15 years, 9 months
DNA SVN: r467 - trunk/docs/examples/gettingstarted.
by dna-commits@lists.jboss.org
Author: spagop
Date: 2008-08-25 20:07:20 -0400 (Mon, 25 Aug 2008)
New Revision: 467
Modified:
trunk/docs/examples/gettingstarted/pom.xml
Log:
add experimeental java sequencer client example
Modified: trunk/docs/examples/gettingstarted/pom.xml
===================================================================
--- trunk/docs/examples/gettingstarted/pom.xml 2008-08-25 23:56:33 UTC (rev 466)
+++ trunk/docs/examples/gettingstarted/pom.xml 2008-08-26 00:07:20 UTC (rev 467)
@@ -10,6 +10,7 @@
<modules>
<module>sequencers</module>
+ <module>dna-example-java-sequencer</module>
</modules>
<properties>
15 years, 9 months
DNA SVN: r466 - in trunk/docs/examples/gettingstarted: dna-example-java-sequencer and 22 other directories.
by dna-commits@lists.jboss.org
Author: spagop
Date: 2008-08-25 19:56:33 -0400 (Mon, 25 Aug 2008)
New Revision: 466
Added:
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/pom.xml
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/config/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/java/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/java/ConsoleInput.java
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/java/JavaInfo.java
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/java/JavaSequencingClient.java
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/java/UserInterface.java
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/resources/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/resources/jackrabbitConfig.xml
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/resources/java-source-artifact.cnd
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/resources/log4j.properties
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/test/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/test/java/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/test/java/org/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/test/java/org/jboss/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/test/java/org/jboss/dna/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/test/java/org/jboss/dna/sequencer/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/test/java/org/jboss/dna/sequencer/java/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/test/java/org/jboss/dna/sequencer/java/JavaSequencingClientTest.java
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/test/java/org/jboss/dna/sequencer/java/MockUserInterface.java
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/workspace/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/workspace/project1/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/workspace/project1/src/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/workspace/project1/src/org/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/workspace/project1/src/org/acme/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/workspace/project1/src/org/acme/MySource.java
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/workspace/project1/src/org/acme/annotation/
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/workspace/project1/src/org/acme/annotation/MyClassAnnotation.java
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/workspace/project1/src/org/acme/annotation/MyPackageAnnotation.java
trunk/docs/examples/gettingstarted/dna-example-java-sequencer/workspace/project1/src/org/acme/package-info.java
Log:
initila java sequencer client exmaple
Added: trunk/docs/examples/gettingstarted/dna-example-java-sequencer/pom.xml
===================================================================
--- trunk/docs/examples/gettingstarted/dna-example-java-sequencer/pom.xml (rev 0)
+++ trunk/docs/examples/gettingstarted/dna-example-java-sequencer/pom.xml 2008-08-25 23:56:33 UTC (rev 466)
@@ -0,0 +1,121 @@
+<?xml version="1.0"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <artifactId>getting_started</artifactId>
+ <groupId>org.jboss.dna.examples</groupId>
+ <version>0.2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.dna.sequencer.java</groupId>
+ <artifactId>dna-example-java-sequencer</artifactId>
+ <version>0.2-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Java Sequencer Example</name>
+ <description>
+ Examples that show case how to use Java Sequencer with a JCR
+ repository.
+ </description>
+ <properties>
+ <dna-version>0.2-SNAPSHOT</dna-version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-repository</artifactId>
+ <version>${dna-version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-common</artifactId>
+ <version>${dna-version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-sequencer-java</artifactId>
+ <version>${dna-version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- collection framework -->
+ <dependency>
+ <groupId>com.google.code.google-collections</groupId>
+ <artifactId>google-collect</artifactId>
+ <version>snapshot-20080530</version>
+ </dependency>
+ <!--
+ Logging (require SLF4J API for compiling, but use Log4J and its SLF4J binding for testing)
+ -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+
+ <!--
+ Java Content Repository API
+ -->
+ <dependency>
+ <groupId>javax.jcr</groupId>
+ <artifactId>jcr</artifactId>
+ </dependency>
+ <!--
+ Apache Jackrabbit (JCR Implementation) for repository implementation
+ -->
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-core</artifactId>
+ </dependency>
+ <!--
+ Test cases use JUnit
+ -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/basic.xml</descriptor>
+ </descriptors>
+ <finalName>${pom.artifactId}</finalName>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>directory-inline</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ -->
+
+
+</project>
Added: trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/java/ConsoleInput.java
===================================================================
--- trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/java/ConsoleInput.java (rev 0)
+++ trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/java/ConsoleInput.java 2008-08-25 23:56:33 UTC (rev 466)
@@ -0,0 +1,207 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * 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.
+ *
+ * This software 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.
+ */
+package org.jboss.dna.sequencer.java;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+import org.jboss.dna.repository.sequencers.SequencingService;
+
+/**
+ * @author Randall Hauch
+ */
+public class ConsoleInput implements UserInterface {
+
+ protected static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+
+ public ConsoleInput( final JavaSequencingClient client ) {
+ try {
+ System.out.println();
+ System.out.print("Starting repository and sequencing service ... ");
+ client.startRepository();
+ System.out.print("done.\nStarting sequencing service ... ");
+ client.startDnaServices();
+ System.out.println("done.");
+ System.out.println();
+
+ System.out.println(getMenu());
+ Thread eventThread = new Thread(new Runnable() {
+
+ private boolean quit = false;
+
+ public void run() {
+ try {
+ while (!quit) {
+ System.out.print(">");
+ try {
+ String input = in.readLine();
+ if (input.length() != 1) {
+ System.out.println("Please enter a valid option.");
+ continue;
+ }
+
+ char option = input.charAt(0);
+ switch (option) {
+ case 'u':
+ client.uploadFile();
+ break;
+ case 's':
+ client.search();
+ break;
+ case 'm':
+ case '?':
+ case 'h':
+ System.out.println(getMenu());
+ break;
+ case 'd':
+ System.out.println(getStatistics(client.getStatistics()));
+ break;
+ case 'q':
+ quit = true;
+ break;
+ default:
+ System.out.println("Invalid option.");
+ break;
+ }
+ } catch (NumberFormatException e) {
+ System.out.println("Invalid integer " + e.getMessage());
+ } catch (IllegalArgumentException e) {
+ System.out.println(e.getMessage());
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+ } finally {
+ try {
+ // Terminate ...
+ System.out.println();
+ System.out.print("Shutting down sequencing service ... ");
+ client.shutdownDnaServices();
+ System.out.print("done.\nShutting down repository ... ");
+ client.shutdownRepository();
+ System.out.print("done.");
+ System.out.println();
+ System.out.println();
+ } catch (Exception err) {
+ System.out.println("Error shutting down sequencing service and repository: " + err.getLocalizedMessage());
+ err.printStackTrace(System.err);
+ }
+ }
+ }
+ });
+
+ eventThread.start();
+ } catch (Exception err) {
+ System.out.println("Error: " + err.getLocalizedMessage());
+ err.printStackTrace(System.err);
+ }
+ }
+
+ protected String getMenu() {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("-----------------------------------\n");
+ buffer.append("Menu:\n");
+ buffer.append("\n");
+ buffer.append("u) Upload a file to the repository\n");
+ buffer.append("s) Search the repository using extracted metadata\n");
+ buffer.append("\n");
+ buffer.append("d) Display statistics\n");
+ buffer.append("\n");
+ buffer.append("?) Show this menu\n");
+ buffer.append("q) Quit");
+ return buffer.toString();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public URL getFileToUpload() throws IllegalArgumentException, IOException {
+ System.out.println("Please enter the file to upload:");
+ String path = in.readLine();
+ File file = new File(path);
+ if (!file.exists()) {
+ throw new IllegalArgumentException("The file \"" + file.getAbsolutePath() + "\" does not exist.");
+ }
+ if (!file.canRead()) {
+ throw new IllegalArgumentException("Unable to read \"" + file.getAbsolutePath() + "\".");
+ }
+ if (!file.isFile()) {
+ throw new IllegalArgumentException("Please specify a file. The file \"" + file.getAbsolutePath() + "\" is a directory.");
+ }
+ return file.toURL();
+ }
+
+ public String getRepositoryPath( String defaultPath ) throws IllegalArgumentException, IOException {
+ if (defaultPath != null) defaultPath = defaultPath.trim();
+ if (defaultPath.length() == 0) defaultPath = null;
+ String displayDefaultPath = defaultPath == null ? "" : " [" + defaultPath.trim() + "]";
+ System.out.println("Please enter the repository path where the file should be placed" + displayDefaultPath + ":");
+ String path = in.readLine().trim();
+ if (path.length() == 0) {
+ if (defaultPath == null) {
+ throw new IllegalArgumentException("The path \"" + path + "\" is not valid.");
+ }
+ path = defaultPath;
+ }
+ return path;
+ }
+
+ public void displaySearchResults( List<JavaInfo> javaInfos ) {
+ System.out.println();
+ if (javaInfos.isEmpty()) {
+ System.out.println("No results were found.");
+ System.out.println();
+ return;
+ }
+ if (javaInfos.size() == 1) {
+ System.out.println("1 image was found:");
+ } else {
+ System.out.println("" + javaInfos.size() + " java sources were found:");
+ }
+ int counter = 1;
+ for (JavaInfo javaInfo : javaInfos) {
+ System.out.println(" Media " + counter++);
+ System.out.println(" Name: " + javaInfo.getName());
+ System.out.println(" Path: " + javaInfo.getPath());
+ System.out.println(" Type: " + javaInfo.getType());
+ for (Map.Entry<String, String> entry : javaInfo.getMap().entries()) {
+ System.out.println(" " + entry.getKey() + ": " + entry.getValue());
+ }
+ }
+ System.out.println();
+ }
+
+ public String getStatistics( SequencingService.Statistics stats ) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("\n");
+ sb.append("# nodes sequenced: ").append(stats.getNumberOfNodesSequenced()).append("\n");
+ sb.append("# nodes skipped: ").append(stats.getNumberOfNodesSkipped()).append("\n");
+ sb.append("\n");
+ return sb.toString();
+ }
+}
Added: trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/java/JavaInfo.java
===================================================================
--- trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/java/JavaInfo.java (rev 0)
+++ trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/java/JavaInfo.java 2008-08-25 23:56:33 UTC (rev 466)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * 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.
+ *
+ * This software 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.
+ */
+package org.jboss.dna.sequencer.java;
+
+import java.util.Map;
+import java.util.Properties;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
+
+/**
+ * @author Serge Pagop
+ *
+ */
+public class JavaInfo {
+
+ private final Multimap<String, String> map = new ArrayListMultimap<String, String>();
+
+ private final String name;
+ private final String path;
+ private final String type;
+
+ protected JavaInfo( String path, String name, String type, Multimap<String, String> map) {
+ this.name = name;
+ this.path = path;
+ this.type = type;
+ if (map != null) this.map.putAll(map);
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public String getPath() {
+ return this.path;
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ boolean first = true;
+ for (Map.Entry<String, String> entry : map.entries()) {
+ sb.append(entry.getKey()).append("=>").append(entry.getValue());
+ if (first) {
+ first = false;
+ } else {
+ sb.append(", ");
+ }
+ }
+ return this.name + " (at " + this.path + ") of type \"" + this.type + "\" with properties {" + sb.toString() + "}";
+ }
+
+ /**
+ * @return map
+ */
+ public Multimap<String, String> getMap() {
+ return map;
+ }
+
+}
Added: trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/java/JavaSequencingClient.java
===================================================================
--- trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/java/JavaSequencingClient.java (rev 0)
+++ trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/java/JavaSequencingClient.java 2008-08-25 23:56:33 UTC (rev 466)
@@ -0,0 +1,434 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * 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.
+ *
+ * This software 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.
+ */
+package org.jboss.dna.sequencer.java;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.SortedMap;
+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;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+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 javax.jcr.observation.Event;
+import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
+import org.apache.jackrabbit.core.TransientRepository;
+import org.jboss.dna.common.SystemFailureException;
+import org.jboss.dna.repository.observation.ObservationService;
+import org.jboss.dna.repository.sequencers.SequencerConfig;
+import org.jboss.dna.repository.sequencers.SequencingService;
+import org.jboss.dna.repository.util.BasicJcrExecutionContext;
+import org.jboss.dna.repository.util.JcrExecutionContext;
+import org.jboss.dna.repository.util.JcrTools;
+import org.jboss.dna.repository.util.SessionFactory;
+import org.jboss.dna.repository.util.SimpleSessionFactory;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
+import com.google.common.collect.Multiset.Entry;
+
+/**
+ * @author serge pagop
+ */
+public class JavaSequencingClient {
+
+ 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();
+
+ private Map<String, String> map = new HashMap<String, String>();
+
+ public static void main( String[] args ) {
+ JavaSequencingClient client = new JavaSequencingClient();
+ client.setRepositoryInformation(DEFAULT_REPOSITORY_NAME, DEFAULT_WORKSPACE_NAME, DEFAULT_USERNAME, DEFAULT_PASSWORD);
+ 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 ObservationService observationService;
+ private UserInterface userInterface;
+ private JcrExecutionContext executionContext;
+
+ public JavaSequencingClient() {
+ 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");
+ }
+ this.repositoryName = repositoryName != null ? repositoryName : DEFAULT_REPOSITORY_NAME;
+ this.workspaceName = workspaceName != null ? workspaceName : DEFAULT_WORKSPACE_NAME;
+ this.username = username;
+ this.password = password;
+ }
+
+ /**
+ * Set the user interface that this client should use.
+ *
+ * @param userInterface
+ */
+ public void setUserInterface( UserInterface userInterface ) {
+ this.userInterface = userInterface;
+ }
+
+ /**
+ * Start up the JCR repository. This method only operates using the JCR API and Jackrabbit-specific API.
+ *
+ * @throws Exception
+ */
+ public void startRepository() throws Exception {
+ if (this.repository == null) {
+ try {
+
+ // 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();
+
+ // 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("java-source-artifact.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;
+ }
+ }
+ }
+
+ /**
+ * Shutdown the repository. This method only uses the JCR API.
+ *
+ * @throws Exception
+ */
+ public void shutdownRepository() throws Exception {
+ if (this.repository != null) {
+ try {
+ this.keepAliveSession.logout();
+ } 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. This example uses the BasicJcrExecutionContext, but there is
+ // implementation for use with JCR repositories registered in JNDI.
+ 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 BasicJcrExecutionContext(sessionFactory, repositoryWorkspaceName);
+
+ // Create the sequencing service, passing in the execution context ...
+ this.sequencingService = new SequencingService();
+ this.sequencingService.setExecutionContext(executionContext);
+
+ // Configure the sequencers. In this example, we only one sequencers that processes java source.
+ // So create a configurations. Note that the sequencing service expects the class to be on the thread's current
+ // context
+ // class loader, or if that's null the class loader 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 meta data in a node with the same name as
+ // the file but immediately below the "/compilationUnits" 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 = "Java Sequencer";
+ String desc = "Sequences java files to extract the characteristics of the java sources";
+ String classname = "org.jboss.dna.sequencer.java.JavaMetadataSequencer";
+ String[] classpath = null; // Use the current class path
+ String[] pathExpressions = {"//(*.java)[*]/jcr:content[@jcr:data] => /compilationUnits/$1"};
+ SequencerConfig javaSequencerConfig = new SequencerConfig(name, desc, classname, classpath, pathExpressions);
+ this.sequencingService.addSequencer(javaSequencerConfig);
+
+ // Use the DNA observation service to listen to the JCR repository (or multiple ones), and
+ // then register the sequencing service as a listener to this observation service...
+ this.observationService = new ObservationService(this.executionContext.getSessionFactory());
+ this.observationService.getAdministrator().start();
+ this.observationService.addListener(this.sequencingService);
+ this.observationService.monitor(repositoryWorkspaceName, Event.NODE_ADDED | Event.PROPERTY_ADDED
+ | Event.PROPERTY_CHANGED);
+ }
+ // 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);
+
+ // Shut down the observation service ...
+ this.observationService.getAdministrator().shutdown();
+ this.observationService.getAdministrator().awaitTermination(5, TimeUnit.SECONDS);
+ }
+
+ /**
+ * Get the sequencing statistics.
+ *
+ * @return the statistics; never null
+ */
+ public SequencingService.Statistics getStatistics() {
+ return this.sequencingService.getStatistics();
+ }
+
+ /**
+ * Prompt the user interface for the file to upload into the JCR repository, then upload it using the JCR API.
+ *
+ * @throws Exception
+ */
+ public void uploadFile() throws Exception {
+ URL url = this.userInterface.getFileToUpload();
+ // Grab the last segment of the URL path, using it as the filename
+ String filename = url.getPath().replaceAll("([^/]*/)*", "");
+ String nodePath = this.userInterface.getRepositoryPath("/a/b/" + filename);
+ String mimeType = getMimeType(url);
+
+ // Now use the JCR API to upload the file ...
+ Session session = createSession();
+ JcrTools tools = this.executionContext.getTools();
+ try {
+ // Create the node at the supplied path ...
+ Node node = tools.findOrCreateNode(session, nodePath, "nt:folder", "nt:file");
+
+ // Upload the file to that node ...
+ Node contentNode = tools.findOrCreateChild(session, node, "jcr:content", "nt:resource");
+ contentNode.setProperty("jcr:mimeType", mimeType);
+ contentNode.setProperty("jcr:lastModified", Calendar.getInstance());
+ contentNode.setProperty("jcr:data", url.openStream());
+
+ // Save the session ...
+ session.save();
+ } finally {
+ session.logout();
+ }
+ }
+
+ /**
+ * Perform a search of the repository for all java compilation units automatically created by the java sequencer.
+ *
+ * @throws Exception
+ */
+ public void search() throws Exception {
+ // Use JCR to search the repository for image meta data ...
+ List<JavaInfo> javaInfos = new ArrayList<JavaInfo>();
+ Multimap<String, String> multimap = new ArrayListMultimap<String, String>();
+ Session session = createSession();
+ try {
+ // Find the compilation unit node ...
+ Node root = session.getRootNode();
+ JavaInfo javaInfo = null;
+ if (root.hasNode("compilationUnits")) {
+ Node javaSourcesNode = root.getNode("compilationUnits");
+ for (NodeIterator i = javaSourcesNode.getNodes(); i.hasNext();) {
+ for (NodeIterator j = javaSourcesNode.getNodes(); i.hasNext();) {
+ Node javaSourceNode = i.nextNode();
+ if (javaSourceNode.hasNodes()) {
+ Node javaCompilationUnit = javaSourceNode.getNodes().nextNode();
+ // package info
+ if (javaCompilationUnit.hasNode("java:package")) {
+ Node javaPackageDeclarationNode = javaCompilationUnit.getNode("java:package");
+ extractInfo(javaPackageDeclarationNode, multimap);
+ }
+ // import infos
+ if (javaCompilationUnit.hasNode("java:import")) {
+ // single type import
+ Node javaImport = javaCompilationUnit.getNode("java:import")
+ .getNode("java:importDeclaration");
+ extractInfo(javaImport, multimap);
+ }
+ // class infos
+ if (javaCompilationUnit.hasNode("java:unitType")) {
+ Node javaNormalClassNode = javaCompilationUnit.getNode("java:unitType")
+ .getNode("java:classDeclaration")
+ .getNode("java:normalClass")
+ .getNode("java:normalClassDeclaration");
+ extractInfo(javaNormalClassNode, multimap);
+
+ }
+ javaInfo = new JavaInfo(javaCompilationUnit.getPath(), javaCompilationUnit.getName(), "java:compilationUnit", multimap);
+ javaInfos.add(javaInfo);
+ }
+ }
+ }
+ }
+
+ } finally {
+ session.logout();
+ }
+
+ // Display the search results ...
+ this.userInterface.displaySearchResults(javaInfos);
+ }
+
+ /**
+ * Extract informations from a specific node.
+ *
+ * @param node - node, that contains informations.
+ * @param multimap - a google collection, that support duplicate keys.
+ * @throws RepositoryException
+ * @throws IllegalStateException
+ * @throws ValueFormatException
+ */
+ private void extractInfo( Node node,
+ Multimap<String, String> multimap )
+ throws ValueFormatException, IllegalStateException, RepositoryException {
+ if (node.hasProperties()) {
+ int index = 1;
+ for (PropertyIterator propertyIter = node.getProperties(); propertyIter.hasNext();) {
+ Property property = propertyIter.nextProperty();
+ String name = property.getName();
+ String stringValue = property.getValue().getString();
+ if (!name.equals("jcr:primaryType")) {
+ multimap.put(name, stringValue);
+ }
+ }
+ }
+ if (node.hasNodes()) {
+ for (NodeIterator iterator = node.getNodes(); iterator.hasNext();) {
+ extractInfo(iterator.nextNode(), multimap);
+ }
+ }
+ }
+
+ /**
+ * Utility method to create a new JCR session from the execution context's {@link SessionFactory}.
+ *
+ * @return the session
+ * @throws RepositoryException
+ */
+ protected Session createSession() throws RepositoryException {
+ return this.executionContext.getSessionFactory().createSession(this.repositoryName + "/" + this.workspaceName);
+ }
+
+ protected String getMimeType( URL file ) {
+ String filename = file.getPath().toLowerCase();
+ if (filename.endsWith(".java")) return "text/x-java-source";
+ throw new SystemFailureException("Unknown mime type for " + file);
+ }
+
+}
Added: trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/java/UserInterface.java
===================================================================
--- trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/java/UserInterface.java (rev 0)
+++ trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/java/org/jboss/dna/sequencer/java/UserInterface.java 2008-08-25 23:56:33 UTC (rev 466)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * 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.
+ *
+ * This software 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.
+ */
+package org.jboss.dna.sequencer.java;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+
+/**
+ * @author Randall Hauch
+ */
+public interface UserInterface {
+
+ public URL getFileToUpload() throws IllegalArgumentException, IOException;
+
+ public String getRepositoryPath( String defaultPath ) throws IllegalArgumentException, IOException;
+
+ public void displaySearchResults( List<JavaInfo> javaInfos ) throws IOException;
+}
Added: trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/resources/jackrabbitConfig.xml
===================================================================
--- trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/resources/jackrabbitConfig.xml (rev 0)
+++ trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/resources/jackrabbitConfig.xml 2008-08-25 23:56:33 UTC (rev 466)
@@ -0,0 +1,115 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!DOCTYPE Repository PUBLIC "-//The Apache Software Foundation//DTD Jackrabbit 1.2//EN"
+ "http://jackrabbit.apache.org/dtd/repository-1.2.dtd">
+<!-- Example Repository Configuration File -->
+<Repository>
+ <!--
+ virtual file system where the repository stores global state
+ (e.g. registered namespaces, custom node types, etc.)
+ -->
+ <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+ <param name="path" value="${rep.home}/repository"/>
+ </FileSystem>
+
+ <!--
+ security configuration
+ -->
+ <Security appName="Jackrabbit">
+ <!--
+ access manager:
+ class: FQN of class implementing the AccessManager interface
+ -->
+ <AccessManager class="org.apache.jackrabbit.core.security.SimpleAccessManager">
+ <!-- <param name="config" value="${rep.home}/access.xml"/> -->
+ </AccessManager>
+
+ <LoginModule class="org.apache.jackrabbit.core.security.SimpleLoginModule">
+ <!-- anonymous user name ('anonymous' is the default value) -->
+ <param name="anonymousId" value="anonymous"/>
+ <!--
+ default user name to be used instead of the anonymous user
+ when no login credentials are provided (unset by default)
+ -->
+ <!-- <param name="defaultUserId" value="superuser"/> -->
+ </LoginModule>
+ </Security>
+
+ <!--
+ location of workspaces root directory and name of default workspace
+ -->
+ <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default"/>
+ <!--
+ workspace configuration template:
+ used to create the initial workspace if there's no workspace yet
+ -->
+ <Workspace name="Jackrabbit Core">
+ <!--
+ virtual file system of the workspace:
+ class: FQN of class implementing the FileSystem interface
+ -->
+ <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+ <param name="path" value="${wsp.home}"/>
+ </FileSystem>
+ <!--
+ persistence manager of the workspace:
+ class: FQN of class implementing the PersistenceManager interface
+ -->
+ <PersistenceManager class="org.apache.jackrabbit.core.persistence.mem.InMemPersistenceManager">
+ <param name="persistent" value="false"/>
+ </PersistenceManager>
+ <!--
+ Search index and the file system it uses.
+ class: FQN of class implementing the QueryHandler interface
+ -->
+ <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+ <param name="path" value="${wsp.home}/index"/>
+ </SearchIndex>
+ </Workspace>
+
+ <!--
+ Configures the versioning
+ -->
+ <Versioning rootPath="${rep.home}/version">
+ <!--
+ Configures the filesystem to use for versioning for the respective
+ persistence manager
+ -->
+ <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+ <param name="path" value="${rep.home}/version" />
+ </FileSystem>
+
+ <!--
+ Configures the persistence manager to be used for persisting version state.
+ Please note that the current versioning implementation is based on
+ a 'normal' persistence manager, but this could change in future
+ implementations.
+ -->
+ <PersistenceManager class="org.apache.jackrabbit.core.persistence.mem.InMemPersistenceManager">
+ <param name="persistent" value="false"/>
+ </PersistenceManager>
+ </Versioning>
+
+ <!--
+ Search index for content that is shared repository wide
+ (/jcr:system tree, contains mainly versions)
+ -->
+ <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+ <param name="path" value="${rep.home}/repository/index"/>
+ </SearchIndex>
+</Repository>
Added: trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/resources/java-source-artifact.cnd
===================================================================
--- trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/resources/java-source-artifact.cnd (rev 0)
+++ trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/resources/java-source-artifact.cnd 2008-08-25 23:56:33 UTC (rev 466)
@@ -0,0 +1,230 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * 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.
+ *
+ * This software 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:referenceType) mandatory multiple
+
+/**
+ * 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)
+
+/**
+ * Reference type (TODO to enhance)
+ */
+[java:referenceType] > nt:unstructured
+ - java:ReferenceDescription (string)
+ + java:modifier (java:modifierDeclaration) = java:modifierDeclaration
+ - java:referenceName (string) mandatory
+
+/**
+ * Field type
+ */
+[java:fieldType] > nt:unstructured
+ + java:type (java:primitiveType, java:referenceType) mandatory multiple
+
+ /**
+ * Method declaration
+ */
+[java:methodDeclaration] > nt:unstructured
+ - java:methodDescription (string)
+ + java:modifier (java:modifierDeclaration) = java:modifierDeclaration
+ + java:resultType (java:primitiveType, java:referenceType) 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
+
+[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
Added: trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/resources/log4j.properties
===================================================================
--- trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/resources/log4j.properties (rev 0)
+++ trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/main/resources/log4j.properties 2008-08-25 23:56:33 UTC (rev 466)
@@ -0,0 +1,17 @@
+# Direct log messages to stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %m%n
+
+# Root logger option
+log4j.rootLogger=INFO, stdout
+
+# Set up the default logging to be INFO level, then override specific units
+log4j.logger.org.jboss.dna=INFO
+log4j.logger.org.jboss.dna.tests.integration.jackrabbit.JackrabbitMySqlStressTest=DEBUG
+
+# Jackrabbit logging
+log4j.logger.org.apache.jackrabbit=WARN, stdout
+log4j.logger.org.apache.derby=INFO, stdout
+
Added: trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/test/java/org/jboss/dna/sequencer/java/JavaSequencingClientTest.java
===================================================================
--- trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/test/java/org/jboss/dna/sequencer/java/JavaSequencingClientTest.java (rev 0)
+++ trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/test/java/org/jboss/dna/sequencer/java/JavaSequencingClientTest.java 2008-08-25 23:56:33 UTC (rev 466)
@@ -0,0 +1,86 @@
+package org.jboss.dna.sequencer.java;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.junit.Assert.assertThat;
+import java.net.URL;
+import org.jboss.dna.common.util.FileUtil;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Unit test for simple App.
+ */
+public class JavaSequencingClientTest {
+
+ private URL javaSourceUrl;
+
+ private JavaSequencingClient client;
+
+ @Before
+ public void beforeEach() throws Exception {
+
+ // Get the URL of source (MySource.java), that have to be sequencing
+ this.javaSourceUrl = FileUtil.convertFileToURL("workspace/project1/src/org/acme/MySource.java");
+
+ // create the sequencing client
+ client = new JavaSequencingClient();
+
+ // the repository
+ client.setWorkingDirectory("target/repositoryData");
+
+ // for our content repository, we need a configuration file
+ client.setJackrabbitConfigPath("src/main/resources/jackrabbitConfig.xml");
+
+ // after all tests we have to deleted the local content repository
+ FileUtil.delete("target/repositoryData");
+ }
+
+ @After
+ public void afterEach() throws Exception {
+ client.shutdownDnaServices();
+ client.shutdownRepository();
+ FileUtil.delete("target/repositoryData");
+ }
+
+ @Test
+ public void shouldFindCompilationUnitSource() {
+ assertThat(this.javaSourceUrl, is(notNullValue()));
+ }
+
+ @Test
+ public void shouldStartupAndShutdownRepository() throws Exception {
+ client.startRepository();
+ client.shutdownRepository();
+
+ }
+
+ @Test
+ public void shouldStartupAndShutdownRepositoryAndSequencingService() throws Exception {
+ client.startRepository();
+ client.startDnaServices();
+ client.shutdownDnaServices();
+ client.shutdownRepository();
+ }
+
+ @Test
+ public void shouldUploadAndSequenceJavaSourceFile() throws Exception {
+ client.setUserInterface(new MockUserInterface(this.javaSourceUrl, "/a/b/MySource.java", 1));
+ client.startRepository();
+ client.startDnaServices();
+ client.uploadFile();
+
+ // Use a trick to wait until the sequencing has been done by sleeping (to give the sequencing time to start)
+ // and to then shut down the DNA services (which will block until all sequencing has been completed) ...
+ Thread.sleep(1000);
+ client.shutdownDnaServices();
+
+ // The sequencers should have run, so perform the search.
+ // The mock user interface checks the results.
+ // TODO
+ client.search();
+ assertThat(client.getStatistics().getNumberOfNodesSequenced(), is(1l));
+ }
+
+}
Added: trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/test/java/org/jboss/dna/sequencer/java/MockUserInterface.java
===================================================================
--- trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/test/java/org/jboss/dna/sequencer/java/MockUserInterface.java (rev 0)
+++ trunk/docs/examples/gettingstarted/dna-example-java-sequencer/src/test/java/org/jboss/dna/sequencer/java/MockUserInterface.java 2008-08-25 23:56:33 UTC (rev 466)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * 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.
+ *
+ * This software 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.
+ */
+package org.jboss.dna.sequencer.java;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+import java.net.URL;
+import java.util.List;
+
+/**
+ * @author Randall Hauch
+ * @author Serge Pagop
+ *
+ */
+public class MockUserInterface implements UserInterface {
+
+ private final String repositoryPath;
+ private final URL fileToUpload;
+ private final int numberOfSearchResults;
+
+ public MockUserInterface( URL fileToUpload,
+ String repositoryPath,
+ int numSearchResults ) {
+ this.repositoryPath = repositoryPath;
+ this.fileToUpload = fileToUpload;
+ this.numberOfSearchResults = numSearchResults;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void displaySearchResults( List<JavaInfo> infos ) {
+ assertThat(infos.size(), is(this.numberOfSearchResults));
+ for (JavaInfo info : infos) {
+ System.out.println("Java Info: " + info);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public URL getFileToUpload() {
+ return this.fileToUpload;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getRepositoryPath( String defaultPath ) {
+ return this.repositoryPath != null ? this.repositoryPath : defaultPath;
+ }
+
+}
Added: trunk/docs/examples/gettingstarted/dna-example-java-sequencer/workspace/project1/src/org/acme/MySource.java
===================================================================
--- trunk/docs/examples/gettingstarted/dna-example-java-sequencer/workspace/project1/src/org/acme/MySource.java (rev 0)
+++ trunk/docs/examples/gettingstarted/dna-example-java-sequencer/workspace/project1/src/org/acme/MySource.java 2008-08-25 23:56:33 UTC (rev 466)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * 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.
+ *
+ * This software 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.
+ */
+package org.acme;
+
+import org.acme.annotation.MyClassAnnotation;
+import java.util.*;
+
+/**
+ * @author Serge Pagop
+ */
+@MyClassAnnotation
+public class MySource {
+
+ private int i, j;
+ private static double a;
+ private List<String> l;
+ private A<Integer> o;
+ private X x;
+
+ MySource() {
+ }
+ public MySource(int i, int j) {
+ this.i = i;
+ this.j = j;
+ }
+
+
+ public int getI() {
+ return this.i;
+ }
+
+ public void setI( int i ) {
+ this.i = i;
+ }
+
+ public void setJ( int j ) {
+ this.j = j;
+ }
+
+ public void doSomething(int p1, double p2) {
+ l = new ArrayList<String>();
+ l.add("N1");
+ }
+
+ // nested class
+ class A<E> {
+ E e;
+
+ A( E e ) {
+ this.e = e;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(this.e);
+ }
+
+ class B<T> {
+ T t;
+
+ B( T t ) {
+ this.t = t;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(this.t);
+ }
+ }
+ }
+
+ class X {
+
+ }
+}
Added: trunk/docs/examples/gettingstarted/dna-example-java-sequencer/workspace/project1/src/org/acme/annotation/MyClassAnnotation.java
===================================================================
--- trunk/docs/examples/gettingstarted/dna-example-java-sequencer/workspace/project1/src/org/acme/annotation/MyClassAnnotation.java (rev 0)
+++ trunk/docs/examples/gettingstarted/dna-example-java-sequencer/workspace/project1/src/org/acme/annotation/MyClassAnnotation.java 2008-08-25 23:56:33 UTC (rev 466)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * 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.
+ *
+ * This software 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.
+ */
+package org.acme.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author Randall Hauch
+ */
+@Retention( RetentionPolicy.CLASS )
+@Target( ElementType.TYPE )
+public @interface MyClassAnnotation {
+
+}
Added: trunk/docs/examples/gettingstarted/dna-example-java-sequencer/workspace/project1/src/org/acme/annotation/MyPackageAnnotation.java
===================================================================
--- trunk/docs/examples/gettingstarted/dna-example-java-sequencer/workspace/project1/src/org/acme/annotation/MyPackageAnnotation.java (rev 0)
+++ trunk/docs/examples/gettingstarted/dna-example-java-sequencer/workspace/project1/src/org/acme/annotation/MyPackageAnnotation.java 2008-08-25 23:56:33 UTC (rev 466)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * 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.
+ *
+ * This software 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.
+ */
+package org.acme.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author Randall Hauch
+ */
+@Retention( RetentionPolicy.CLASS )
+@Target( ElementType.PACKAGE )
+public @interface MyPackageAnnotation {
+
+}
Added: trunk/docs/examples/gettingstarted/dna-example-java-sequencer/workspace/project1/src/org/acme/package-info.java
===================================================================
--- trunk/docs/examples/gettingstarted/dna-example-java-sequencer/workspace/project1/src/org/acme/package-info.java (rev 0)
+++ trunk/docs/examples/gettingstarted/dna-example-java-sequencer/workspace/project1/src/org/acme/package-info.java 2008-08-25 23:56:33 UTC (rev 466)
@@ -0,0 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * 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.
+ *
+ * This software 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.
+ */
+@MyPackageAnnotation
+package org.acme;
+
+import org.acme.annotation.MyPackageAnnotation;
+
15 years, 9 months
DNA SVN: r465 - trunk/extensions/dna-sequencer-java/src/test/resources.
by dna-commits@lists.jboss.org
Author: spagop
Date: 2008-08-25 18:49:11 -0400 (Mon, 25 Aug 2008)
New Revision: 465
Modified:
trunk/extensions/dna-sequencer-java/src/test/resources/java-source-artifact.cnd
Log:
enhancement of CND and also in java sequencer for a clearness of properties in the tree
Modified: trunk/extensions/dna-sequencer-java/src/test/resources/java-source-artifact.cnd
===================================================================
--- trunk/extensions/dna-sequencer-java/src/test/resources/java-source-artifact.cnd 2008-08-25 22:48:47 UTC (rev 464)
+++ trunk/extensions/dna-sequencer-java/src/test/resources/java-source-artifact.cnd 2008-08-25 22:49:11 UTC (rev 465)
@@ -55,7 +55,7 @@
* Modifiers
*/
[java:modifierDeclaration] > nt:unstructured
- - java:name (string) mandatory
+ - java:modifierName (string) mandatory
/**
* Expression element-value type
@@ -73,7 +73,7 @@
* Identifier
*/
[java:identifier] > nt:unstructured
- - java:sampleName (String) mandatory
+ - java:identifierName (String) mandatory
+ java:value (java:elementValue) = java:elementValue mandatory
/**
@@ -92,19 +92,20 @@
* Normal annotation e.g. @Entity(name="Customer")
*/
[java:normalAnnotation] > nt:unstructured
- - java:typeName (string) mandatory
+ - java:normalAnnotationName (string) mandatory
+ java:elementValuePair (java:elementValuePair)
/**
* Marker annotation e.g. @GET
*/
[java:markerAnnotation] > nt:unstructured
- - java:typeName (string) mandatory
+ - java:markerAnnotationName (string) mandatory
/**
* Single element annotation e.g. @Path("/book")
*/
[java:singleElementAnnotation] > nt:unstructured
+ - java:singleElementAnnotationNam
+ java:value (java:elementValue) = java:elementValue mandatory
/**
@@ -121,10 +122,10 @@
* - No return type (''void')
*/
[java:primitiveType] > nt:unstructured
- - java:description (string)
+ - java:primitiveTypeDescription (string)
+ java:modifier (java:modifierDeclaration) = java:modifierDeclaration
- - java:typeName (string)
- + java:variable (java:variable) = java:variable
+ - java:primitiveTypeName (string) mandatory
+ + java:primitiveVariable (java:variable) = java:variable
[java:variable] > nt:unstructured
- java:variableName (string)
@@ -133,9 +134,9 @@
* Reference type (TODO to enhance)
*/
[java:referenceType] > nt:unstructured
- - java:description (string)
+ - java:ReferenceDescription (string)
+ java:modifier (java:modifierDeclaration) = java:modifierDeclaration
- - java:name (string) mandatory
+ - java:referenceName (string) mandatory
/**
* Field type
@@ -147,19 +148,19 @@
* Method declaration
*/
[java:methodDeclaration] > nt:unstructured
- - java:description (string)
+ - java:methodDescription (string)
+ java:modifier (java:modifierDeclaration) = java:modifierDeclaration
+ java:resultType (java:primitiveType, java:referenceType) mandatory
- - java:name (string) mandatory
+ - java:methodName (string) mandatory
+ java:parameter (java:formalParameter) multiple
/**
* Constructor declarations
*/
[java:constructorDeclaration] > nt:unstructured
- - java:description (string)
+ - java:constructorDescription (string)
+ java:modifier (java:modifierDeclaration) = java:modifierDeclaration
- - java:name (string) mandatory
+ - java:constructorName (string) mandatory
+ java:parameter (java:formalParameter)
@@ -168,7 +169,7 @@
*/
[java:packageDeclaration] > nt:unstructured
+ java:annotation (java:annotationDeclaration) = java:annotationDeclaration
- - java:keyword (string)
+ - java:packageKeyword (string)
< 'package'
- java:packageName (string) mandatory
@@ -176,14 +177,14 @@
* Import declarations
*/
[java:singleTypeImportDeclaration] > nt:unstructured
- - java:keyword (string) mandatory
+ - java:singleTypeImportkeyword (string) mandatory
< 'import'
- - java:typeName (string) mandatory
+ - java:singleImportName (string) mandatory
[java:typeImportOnDemandDeclaration] > nt:unstructured
- - java:keyword (string) mandatory
+ - java:onDemandImportKeyword (string) mandatory
< 'import'
- - java:typeName (string) mandatory
+ - java:onDemandImportName (string) mandatory
[java:importDeclaration] > nt:unstructured
+ java:singleImport (java:singleTypeImportDeclaration) = java:singleTypeImportDeclaration
@@ -199,7 +200,7 @@
[java:normalClassDeclaration] > nt:unstructured
- java:description (string)
+ java:modifier (java:modifierDeclaration) = java:modifierDeclaration
- - java:name (string) mandatory
+ - 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
15 years, 9 months
DNA SVN: r464 - trunk/extensions/dna-sequencer-java/src/test/java/org/jboss/dna/sequencer/java.
by dna-commits@lists.jboss.org
Author: spagop
Date: 2008-08-25 18:48:47 -0400 (Mon, 25 Aug 2008)
New Revision: 464
Modified:
trunk/extensions/dna-sequencer-java/src/test/java/org/jboss/dna/sequencer/java/JavaMetadataSequencerTest.java
Log:
enhancement of CND and also in java sequencer for a clearness of properties in the tree and also testing
Modified: trunk/extensions/dna-sequencer-java/src/test/java/org/jboss/dna/sequencer/java/JavaMetadataSequencerTest.java
===================================================================
--- trunk/extensions/dna-sequencer-java/src/test/java/org/jboss/dna/sequencer/java/JavaMetadataSequencerTest.java 2008-08-25 22:48:23 UTC (rev 463)
+++ trunk/extensions/dna-sequencer-java/src/test/java/org/jboss/dna/sequencer/java/JavaMetadataSequencerTest.java 2008-08-25 22:48:47 UTC (rev 464)
@@ -99,10 +99,10 @@
// support for sequencing imports (single import and import on demand)
assertThat(output.getPropertyValues("java:compilationUnit/java:import/java:importDeclaration/java:singleImport/java:singleTypeImportDeclaration[1]",
- "java:typeName"),
+ "java:singleImportName"),
is(new Object[] {"org.acme.annotation.MyClassAnnotation"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:import/java:importDeclaration/java:importOnDemand/java:typeImportOnDemandDeclaration[1]",
- "java:typeName"),
+ "java:onDemandImportName"),
is(new Object[] {"java.util"}));
// support for sequencing class definition (modifiers, class name)
@@ -110,7 +110,7 @@
"java:modifierName"),
is(new Object[] {"public"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration",
- "java:name"),
+ "java:normalClassName"),
is(new Object[] {"MySource"}));
// support for primitive type sequencing (modifiers, types, variables).Not supported is the javadoc
@@ -119,7 +119,7 @@
is(new Object[] {"private"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:field/java:fieldType/java:type/java:primitiveType[1]",
- "java:typeName"),
+ "java:primitiveTypeName"),
is(new Object[] {"int"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:field/java:fieldType/java:type/java:primitiveType[1]/java:variable[1]",
@@ -139,7 +139,7 @@
is(new Object[] {"static"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:field/java:fieldType/java:type/java:primitiveType[2]",
- "java:typeName"),
+ "java:primitiveTypeName"),
is(new Object[] {"double"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:field/java:fieldType/java:type/java:primitiveType[2]/java:variable[1]",
@@ -162,7 +162,7 @@
// MySource() constructor
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:constructor/java:constructorDeclaration[1]",
- "java:name"),
+ "java:constructorName"),
is(new Object[] {"MySource"}));
// public MySource(int i, int j) constructor with parameters
@@ -171,18 +171,18 @@
is(new Object[] {"public"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:constructor/java:constructorDeclaration[2]",
- "java:name"),
+ "java:constructorName"),
is(new Object[] {"MySource"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:constructor/java:constructorDeclaration[2]/java:parameter/java:formalParameter[1]/java:type/java:primitiveType",
- "java:typeName"),
+ "java:primitiveTypeName"),
is(new Object[] {"int"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:constructor/java:constructorDeclaration[2]/java:parameter/java:formalParameter[1]/java:type/java:primitiveType/java:variable",
"java:variableName"),
is(new Object[] {"i"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:constructor/java:constructorDeclaration[2]/java:parameter/java:formalParameter[1]/java:type/java:primitiveType",
- "java:typeName"),
+ "java:primitiveTypeName"),
is(new Object[] {"int"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:constructor/java:constructorDeclaration[2]/java:parameter/java:formalParameter[2]/java:type/java:primitiveType/java:variable",
"java:variableName"),
@@ -193,10 +193,10 @@
"java:modifierName"),
is(new Object[] {"public"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:method/java:methodDeclaration[1]/java:resultType/java:primitiveType",
- "java:typeName"),
+ "java:primitiveTypeName"),
is(new Object[] {"int"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:method/java:methodDeclaration[1]",
- "java:name"),
+ "java:methodName"),
is(new Object[] {"getI"}));
// public void setI(int i) method
@@ -204,13 +204,13 @@
"java:modifierName"),
is(new Object[] {"public"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:method/java:methodDeclaration[2]/java:resultType/java:primitiveType",
- "java:typeName"),
+ "java:primitiveTypeName"),
is(new Object[] {"void"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:method/java:methodDeclaration[2]",
- "java:name"),
+ "java:methodName"),
is(new Object[] {"setI"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:method/java:methodDeclaration[2]/java:parameter/java:formalParameter[1]/java:type/java:primitiveType",
- "java:typeName"),
+ "java:primitiveTypeName"),
is(new Object[] {"int"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:method/java:methodDeclaration[2]/java:parameter/java:formalParameter[1]/java:type/java:primitiveType/java:variable",
"java:variableName"),
@@ -221,19 +221,19 @@
"java:modifierName"),
is(new Object[] {"public"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:method/java:methodDeclaration[4]/java:resultType/java:primitiveType",
- "java:typeName"),
+ "java:primitiveTypeName"),
is(new Object[] {"void"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:method/java:methodDeclaration[4]",
- "java:name"),
+ "java:methodName"),
is(new Object[] {"doSomething"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:method/java:methodDeclaration[4]/java:parameter/java:formalParameter[1]/java:type/java:primitiveType",
- "java:typeName"),
+ "java:primitiveTypeName"),
is(new Object[] {"int"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:method/java:methodDeclaration[4]/java:parameter/java:formalParameter[1]/java:type/java:primitiveType/java:variable",
"java:variableName"),
is(new Object[] {"p1"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:method/java:methodDeclaration[4]/java:parameter/java:formalParameter[2]/java:type/java:primitiveType",
- "java:typeName"),
+ "java:primitiveTypeName"),
is(new Object[] {"double"}));
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:method/java:methodDeclaration[4]/java:parameter/java:formalParameter[2]/java:type/java:primitiveType/java:variable",
"java:variableName"),
15 years, 9 months
DNA SVN: r463 - trunk/extensions/dna-sequencer-java/src/main/resources/org/jboss/dna/sequencer/java.
by dna-commits@lists.jboss.org
Author: spagop
Date: 2008-08-25 18:48:23 -0400 (Mon, 25 Aug 2008)
New Revision: 463
Modified:
trunk/extensions/dna-sequencer-java/src/main/resources/org/jboss/dna/sequencer/java/java-source-artifact.cnd
Log:
enhancement of CND and also in java sequencer for a clearness of properties in the tree
Modified: 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 2008-08-25 22:48:04 UTC (rev 462)
+++ trunk/extensions/dna-sequencer-java/src/main/resources/org/jboss/dna/sequencer/java/java-source-artifact.cnd 2008-08-25 22:48:23 UTC (rev 463)
@@ -55,7 +55,7 @@
* Modifiers
*/
[java:modifierDeclaration] > nt:unstructured
- - java:name (string) mandatory
+ - java:modifierName (string) mandatory
/**
* Expression element-value type
@@ -73,7 +73,7 @@
* Identifier
*/
[java:identifier] > nt:unstructured
- - java:sampleName (String) mandatory
+ - java:identifierName (String) mandatory
+ java:value (java:elementValue) = java:elementValue mandatory
/**
@@ -92,19 +92,20 @@
* Normal annotation e.g. @Entity(name="Customer")
*/
[java:normalAnnotation] > nt:unstructured
- - java:typeName (string) mandatory
+ - java:normalAnnotationName (string) mandatory
+ java:elementValuePair (java:elementValuePair)
/**
* Marker annotation e.g. @GET
*/
[java:markerAnnotation] > nt:unstructured
- - java:typeName (string) mandatory
+ - java:markerAnnotationName (string) mandatory
/**
* Single element annotation e.g. @Path("/book")
*/
[java:singleElementAnnotation] > nt:unstructured
+ - java:singleElementAnnotationNam
+ java:value (java:elementValue) = java:elementValue mandatory
/**
@@ -118,13 +119,13 @@
* - Integral type ('byte', 'short', 'int', 'long', 'char')
* - Floating point type ('float', 'double')
* - Boolean type ('boolean')
- * - No return type (''void')
+ * - No return type ('void')
*/
[java:primitiveType] > nt:unstructured
- - java:description (string)
+ - java:primitiveTypeDescription (string)
+ java:modifier (java:modifierDeclaration) = java:modifierDeclaration
- - java:typeName (string)
- + java:variable (java:variable) = java:variable
+ - java:primitiveTypeName (string) mandatory
+ + java:primitiveVariable (java:variable) = java:variable
[java:variable] > nt:unstructured
- java:variableName (string)
@@ -133,9 +134,9 @@
* Reference type (TODO to enhance)
*/
[java:referenceType] > nt:unstructured
- - java:description (string)
+ - java:ReferenceDescription (string)
+ java:modifier (java:modifierDeclaration) = java:modifierDeclaration
- - java:name (string) mandatory
+ - java:referenceName (string) mandatory
/**
* Field type
@@ -147,19 +148,19 @@
* Method declaration
*/
[java:methodDeclaration] > nt:unstructured
- - java:description (string)
+ - java:methodDescription (string)
+ java:modifier (java:modifierDeclaration) = java:modifierDeclaration
+ java:resultType (java:primitiveType, java:referenceType) mandatory
- - java:name (string) mandatory
+ - java:methodName (string) mandatory
+ java:parameter (java:formalParameter) multiple
/**
* Constructor declarations
*/
[java:constructorDeclaration] > nt:unstructured
- - java:description (string)
+ - java:constructorDescription (string)
+ java:modifier (java:modifierDeclaration) = java:modifierDeclaration
- - java:name (string) mandatory
+ - java:constructorName (string) mandatory
+ java:parameter (java:formalParameter)
@@ -168,7 +169,7 @@
*/
[java:packageDeclaration] > nt:unstructured
+ java:annotation (java:annotationDeclaration) = java:annotationDeclaration
- - java:keyword (string)
+ - java:packageKeyword (string)
< 'package'
- java:packageName (string) mandatory
@@ -176,14 +177,14 @@
* Import declarations
*/
[java:singleTypeImportDeclaration] > nt:unstructured
- - java:keyword (string) mandatory
+ - java:singleTypeImportkeyword (string) mandatory
< 'import'
- - java:typeName (string) mandatory
+ - java:singleImportName (string) mandatory
[java:typeImportOnDemandDeclaration] > nt:unstructured
- - java:keyword (string) mandatory
+ - java:onDemandImportKeyword (string) mandatory
< 'import'
- - java:typeName (string) mandatory
+ - java:onDemandImportName (string) mandatory
[java:importDeclaration] > nt:unstructured
+ java:singleImport (java:singleTypeImportDeclaration) = java:singleTypeImportDeclaration
@@ -199,7 +200,7 @@
[java:normalClassDeclaration] > nt:unstructured
- java:description (string)
+ java:modifier (java:modifierDeclaration) = java:modifierDeclaration
- - java:name (string) mandatory
+ - 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
15 years, 9 months
DNA SVN: r462 - trunk/extensions/dna-sequencer-java/src/main/java/org/jboss/dna/sequencer/java.
by dna-commits@lists.jboss.org
Author: spagop
Date: 2008-08-25 18:48:04 -0400 (Mon, 25 Aug 2008)
New Revision: 462
Modified:
trunk/extensions/dna-sequencer-java/src/main/java/org/jboss/dna/sequencer/java/JavaMetadataSequencer.java
Log:
enhancement of CND and also in java sequencer for a clearness of properties in the tree
Modified: trunk/extensions/dna-sequencer-java/src/main/java/org/jboss/dna/sequencer/java/JavaMetadataSequencer.java
===================================================================
--- trunk/extensions/dna-sequencer-java/src/main/java/org/jboss/dna/sequencer/java/JavaMetadataSequencer.java 2008-08-22 19:32:12 UTC (rev 461)
+++ trunk/extensions/dna-sequencer-java/src/main/java/org/jboss/dna/sequencer/java/JavaMetadataSequencer.java 2008-08-25 22:48:04 UTC (rev 462)
@@ -130,57 +130,82 @@
public static final String JAVA_COMPILATION_UNIT_NODE = "java:compilationUnit";
public static final String JAVA_COMPILATION_UNIT_PRIMARY_TYPE = "jcr:primaryType";
+
// package declaration
public static final String JAVA_PACKAGE_CHILD_NODE = "java:package";
public static final String JAVA_PACKAGE_DECLARATION_CHILD_NODE = "java:packageDeclaration";
public static final String JAVA_PACKAGE_NAME = "java:packageName";
+
// Annnotation declaration
public static final String JAVA_ANNOTATION_CHILD_NODE = "java:annotation";
public static final String JAVA_ANNOTATION_DECLARATION_CHILD_NODE = "java:annotationDeclaration";
public static final String JAVA_ANNOTATION_TYPE_CHILD_NODE = "java:annotationType";
+
+ // Marker annotation
public static final String JAVA_MARKER_ANNOTATION_CHILD_NODE = "java:markerAnnotation";
+ public static final String JAVA_MARKER_ANNOTATION_NAME ="java:markerAnnotationName ";
+
+ // Normal annotation
public static final String JAVA_NORMAL_ANNOTATION_CHILD_NODE = "java:normalAnnotation";
+ public static final String JAVA_NORMALANNOTATION_NAME ="java:normalAnnotationName";
+
+ // Single element annotation
public static final String JAVA_SINGLE_ELEMENT_ANNOTATION_CHILD_NODE = "java:singleElementAnnotation";
- public static final String JAVA_ANNOTATION_TYPE_NAME = "java:typeName";
+ public static final String JAVA_SINGLE_ANNOTATION_NAME ="java:singleElementAnnotationName";
+
// Import declaration
public static final String JAVA_IMPORT_CHILD_NODE = "java:import";
public static final String JAVA_IMPORT_DECLARATION_CHILD_NODE = "java:importDeclaration";
+
+ // Single import declaration
public static final String JAVA_SINGLE_IMPORT_CHILD_NODE = "java:singleImport";
- public static final String JAVA_SINGLE_TYPE_IMPORT_DECLARATION_CHILD_NODE = "java:singleTypeImportDeclaration";
- public static final String JAVA_IMPORT_ON_DEMAND_CHILD_NODE = "java:importOnDemand";
- public static final String JAVA_TYPE_IMPORT_ON_DEMAND_DECLARATION_CHILD_NODE = "java:typeImportOnDemandDeclaration";
- public static final String JAVA_IMPORT_TYPE_NAME = "java:typeName";
- // normal class declaration
+ public static final String JAVA_SINGLE_IMPORT_TYPE_DECLARATION_CHILD_NODE = "java:singleTypeImportDeclaration";
+ public static final String JAVA_SINGLE_IMPORT_NAME = "java:singleImportName ";
+
+
+ // OnDemand import declaration
+ public static final String JAVA_ON_DEMAND_IMPORT_CHILD_NODE = "java:importOnDemand";
+ public static final String JAVA_ON_DEMAND_IMPORT_TYPE_DECLARATION_CHILD_NODE = "java:typeImportOnDemandDeclaration";
+ public static final String JAVA_ON_DEMAND_IMPORT_NAME ="java:onDemandImportName";
+
+
+ // Class declaration
public static final String JAVA_UNIT_TYPE_CHILD_NODE = "java:unitType";
public static final String JAVA_CLASS_DECLARATION_CHILD_NODE = "java:classDeclaration";
+
+ // Normal class declaration
public static final String JAVA_NORMAL_CLASS_CHILD_NODE = "java:normalClass";
public static final String JAVA_NORMAL_CLASS_DECLARATION_CHILD_NODE = "java:normalClassDeclaration";
- public static final String JAVA_CLASS_NAME = "java:name";
+ public static final String JAVA_NORMAL_CLASS_NAME = "java:normalClassName";
+
+ // Modifier declaration
public static final String JAVA_MODIFIER_CHILD_NODE = "java:modifier";
public static final String JAVA_MODIFIER_DECLARATION_CHILD_NODE = "java:modifierDeclaration";
public static final String JAVA_MODIFIER_NAME = "java:modifierName";
+ // Variable declaration
public static final String JAVA_VARIABLE = "java:variable";
public static final String JAVA_VARIABLE_NAME = "java:variableName";
- public static final String JAVA_TYPE = "java:typeName";
- // primitive type
+ // Primitive type
public static final String JAVA_FIELD_CHILD_NODE = "java:field";
public static final String JAVA_FIELD_TYPE_CHILD_NODE = "java:fieldType";
public static final String JAVA_TYPE_CHILD_NODE = "java:type";
public static final String JAVA_PRIMITIVE_TYPE_CHILD_NODE = "java:primitiveType";
+ public static final String JAVA_PRIMITIVE_TYPE_NAME="java:primitiveTypeName";
- // reference type
+ // Reference type
public static final String JAVA_REFERENCE_TYPE_CHILD_NODE = "java:referenceType";
// method declaration
public static final String JAVA_METHOD_CHILD_NODE = "java:method";
public static final String JAVA_METHOD_DECLARATION_CHILD_NODE = "java:methodDeclaration";
- public static final String JAVA_METHOD_NAME = "java:name";
+ public static final String JAVA_METHOD_NAME = "java:methodName";
// constructor
public static final String JAVA_CONSTRUCTOR_CHILD_NODE = "java:constructor";
public static final String JAVA_CONSTRUCTOR_DECLARATION_CHILD_NODE = "java:constructorDeclaration";
+ public static final String JAVA_CONSTRUCTOR_NAME = "java:constructorName";
// parameter
public static final String JAVA_PARAMETER = "java:parameter";
@@ -189,6 +214,9 @@
public static final String JAVA_RETURN_TYPE = "java:resultType";
+
+
+
/**
* {@inheritDoc}
*
@@ -247,7 +275,7 @@
+ JAVA_MARKER_ANNOTATION_CHILD_NODE + "["
+ markerAnnotationIndex + "]");
output.setProperty(markerAnnotationChildNode,
- nameFactory.create(JAVA_ANNOTATION_TYPE_NAME),
+ nameFactory.create(JAVA_MARKER_ANNOTATION_NAME),
markerAnnotationMetadata.getName());
markerAnnotationIndex++;
}
@@ -263,7 +291,7 @@
+ JAVA_SINGLE_ELEMENT_ANNOTATION_CHILD_NODE
+ "[" + singleAnnatationIndex + "]");
output.setProperty(singleMemberAnnotationChildNode,
- nameFactory.create(JAVA_ANNOTATION_TYPE_NAME),
+ nameFactory.create(JAVA_SINGLE_ANNOTATION_NAME),
singleMemberAnnotationMetadata.getName());
singleAnnatationIndex++;
}
@@ -279,7 +307,7 @@
+ normalAnnotationIndex + "]");
output.setProperty(normalAnnotationChildNode,
- nameFactory.create(JAVA_ANNOTATION_TYPE_NAME),
+ nameFactory.create(JAVA_NORMALANNOTATION_NAME),
normalAnnotationMetadata.getName());
normalAnnotationIndex++;
}
@@ -294,11 +322,11 @@
ImportOnDemandMetadata importOnDemandMetadata = (ImportOnDemandMetadata)importMetadata;
Path importOnDemandChildNode = pathFactory.create(JAVA_COMPILATION_UNIT_NODE + SLASH + JAVA_IMPORT_CHILD_NODE
+ SLASH + JAVA_IMPORT_DECLARATION_CHILD_NODE + SLASH
- + JAVA_IMPORT_ON_DEMAND_CHILD_NODE + SLASH
- + JAVA_TYPE_IMPORT_ON_DEMAND_DECLARATION_CHILD_NODE + "["
+ + JAVA_ON_DEMAND_IMPORT_CHILD_NODE + SLASH
+ + JAVA_ON_DEMAND_IMPORT_TYPE_DECLARATION_CHILD_NODE + "["
+ importOnDemandIndex + "]");
output.setProperty(importOnDemandChildNode,
- nameFactory.create(JAVA_IMPORT_TYPE_NAME),
+ nameFactory.create(JAVA_ON_DEMAND_IMPORT_NAME),
importOnDemandMetadata.getName());
importOnDemandIndex++;
}
@@ -307,10 +335,10 @@
Path singleImportChildNode = pathFactory.create(JAVA_COMPILATION_UNIT_NODE + SLASH + JAVA_IMPORT_CHILD_NODE
+ SLASH + JAVA_IMPORT_DECLARATION_CHILD_NODE + SLASH
+ JAVA_SINGLE_IMPORT_CHILD_NODE + SLASH
- + JAVA_SINGLE_TYPE_IMPORT_DECLARATION_CHILD_NODE + "["
+ + JAVA_SINGLE_IMPORT_TYPE_DECLARATION_CHILD_NODE + "["
+ singleImportIndex + "]");
output.setProperty(singleImportChildNode,
- nameFactory.create(JAVA_IMPORT_TYPE_NAME),
+ nameFactory.create(JAVA_SINGLE_IMPORT_NAME),
singleImportMetadata.getName());
singleImportIndex++;
}
@@ -325,7 +353,7 @@
+ SLASH + JAVA_CLASS_DECLARATION_CHILD_NODE + SLASH
+ JAVA_NORMAL_CLASS_CHILD_NODE + SLASH
+ JAVA_NORMAL_CLASS_DECLARATION_CHILD_NODE);
- output.setProperty(classChildNode, nameFactory.create(JAVA_CLASS_NAME), classMetadata.getName());
+ output.setProperty(classChildNode, nameFactory.create(JAVA_NORMAL_CLASS_NAME), classMetadata.getName());
// process modifiers of the class declaration
List<ModifierMetadata> classModifiers = classMetadata.getModifiers();
@@ -363,7 +391,7 @@
// type
Path primitiveTypeChildNode = pathFactory.create(primitiveFieldRootPath);
output.setProperty(primitiveTypeChildNode,
- nameFactory.create(JAVA_TYPE),
+ nameFactory.create(JAVA_PRIMITIVE_TYPE_NAME),
primitiveFieldMetadata.getType());
// modifiers
List<ModifierMetadata> modifiers = primitiveFieldMetadata.getModifiers();
@@ -416,7 +444,7 @@
constructorIndex);
Path constructorChildNode = pathFactory.create(constructorRootPath);
output.setProperty(constructorChildNode,
- nameFactory.create(JAVA_METHOD_NAME),
+ nameFactory.create(JAVA_CONSTRUCTOR_NAME),
constructorMetadata.getName());
List<ModifierMetadata> modifiers = constructorMetadata.getModifiers();
// modifiers
@@ -452,8 +480,8 @@
String constructorPrimitiveParamVariablePath = createPath(constructPrimitiveFormalParamRootPath
+ SLASH + JAVA_VARIABLE);
Path constructorParamChildNode = pathFactory.create(constructorPrimitiveParamVariablePath);
+ // variables
for (Variable variable : primitive.getVariables()) {
- // name
output.setProperty(constructorParamChildNode,
nameFactory.create(JAVA_VARIABLE_NAME),
variable.getName());
@@ -461,9 +489,8 @@
// type
Path constructPrimitiveTypeParamChildNode = pathFactory.create(constructPrimitiveFormalParamRootPath);
output.setProperty(constructPrimitiveTypeParamChildNode,
- nameFactory.create(JAVA_TYPE),
+ nameFactory.create(JAVA_PRIMITIVE_TYPE_NAME),
primitive.getType());
-
}
// TODO parameter reference types
@@ -520,8 +547,8 @@
+ SLASH + JAVA_VARIABLE);
Path methodParamChildNode = pathFactory.create(methodPrimitiveParamVariablePath);
+ // variables
for (Variable variable : primitive.getVariables()) {
- // name
output.setProperty(methodParamChildNode,
nameFactory.create(JAVA_VARIABLE_NAME),
variable.getName());
@@ -529,7 +556,7 @@
// type
Path methodPrimitiveTypeParamChildNode = pathFactory.create(methodPrimitiveFormalParamRootPath);
output.setProperty(methodPrimitiveTypeParamChildNode,
- nameFactory.create(JAVA_TYPE),
+ nameFactory.create(JAVA_PRIMITIVE_TYPE_NAME),
primitive.getType());
}
@@ -549,7 +576,7 @@
+ JAVA_PRIMITIVE_TYPE_CHILD_NODE);
Path methodReturnPrimitiveTypeChildNode = pathFactory.create(methodReturnPrimitiveTypePath);
output.setProperty(methodReturnPrimitiveTypeChildNode,
- nameFactory.create(JAVA_TYPE),
+ nameFactory.create(JAVA_PRIMITIVE_TYPE_NAME),
methodReturnPrimitiveType.getType());
}
15 years, 9 months
DNA SVN: r461 - in trunk: dna-spi/src/main/java/org/jboss/dna/spi and 4 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-08-22 15:32:12 -0400 (Fri, 22 Aug 2008)
New Revision: 461
Modified:
trunk/dna-common/src/main/java/org/jboss/dna/common/util/StringUtil.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/SpiI18n.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/Binary.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueComparators.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/InMemoryBinary.java
trunk/dna-spi/src/main/resources/org/jboss/dna/spi/SpiI18n.properties
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/InMemoryBinaryTest.java
Log:
Added to the Binary interface the ability to obtain the SHA-1 hash of the content. This can be used to determine whether two Binary instances contain the same content, as the SHA-1 digests will be the same given the same content.
Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/util/StringUtil.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/util/StringUtil.java 2008-08-20 19:16:50 UTC (rev 460)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/util/StringUtil.java 2008-08-22 19:32:12 UTC (rev 461)
@@ -336,8 +336,8 @@
}
/**
- * Read and return the entire contents of the supplied {@link InputStream}. This method always closes the stream when
- * finished reading.
+ * Read and return the entire contents of the supplied {@link InputStream}. This method always closes the stream when finished
+ * reading.
*
* @param stream the streamed contents; may be null
* @return the contents, or an empty string if the supplied stream is null
@@ -383,8 +383,8 @@
* <li>A string is written wrapped by double quotes.</li>
* <li>A boolean is written using {@link Boolean#toString()}.</li>
* <li>A {@link Number number} is written using the standard {@link Number#toString() toString()} method.</li>
- * <li>A {@link java.util.Date date} is written using the the {@link DateUtil#getDateAsStandardString(java.util.Date)}
- * utility method.</li>
+ * <li>A {@link java.util.Date date} is written using the the {@link DateUtil#getDateAsStandardString(java.util.Date)} utility
+ * method.</li>
* <li>A {@link java.sql.Date SQL date} is written using the the {@link DateUtil#getDateAsStandardString(java.util.Date)}
* utility method.</li>
* <li>A {@link Calendar Calendar instance} is written using the the {@link DateUtil#getDateAsStandardString(Calendar)}
@@ -392,10 +392,10 @@
* <li>An array of bytes is written with a leading "[ " and trailing " ]" surrounding the bytes written as UTF-8.
* <li>An array of objects is written with a leading "[ " and trailing " ]", and with all objects sent through
* {@link #readableString(Object)} and separated by ", ".</li>
- * <li>A collection of objects (e.g, <code>Collection<?></code>) is written with a leading "[ " and trailing " ]", and
- * with all objects sent through {@link #readableString(Object)} and separated by ", ".</li>
- * <li>A map of objects (e.g, <code>Map<?></code>) is written with a leading "{ " and trailing " }", and with all map
- * entries written in the form "key => value" and separated by ", ". All key and value objects are sent through the
+ * <li>A collection of objects (e.g, <code>Collection<?></code>) is written with a leading "[ " and trailing " ]", and with
+ * all objects sent through {@link #readableString(Object)} and separated by ", ".</li>
+ * <li>A map of objects (e.g, <code>Map<?></code>) is written with a leading "{ " and trailing " }", and with all map entries
+ * written in the form "key => value" and separated by ", ". All key and value objects are sent through the
* {@link #readableString(Object)} method.</li>
* <li>Any other object is written using the object's {@link Object#toString() toString()} method.</li>
* </ul>
@@ -649,6 +649,28 @@
return NORMALIZE_PATTERN.matcher(text).replaceAll(" ").trim();
}
+ private static final byte[] HEX_CHAR_TABLE = {(byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4', (byte)'5', (byte)'6',
+ (byte)'7', (byte)'8', (byte)'9', (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', (byte)'f'};
+
+ /**
+ * Get the hexadecimal string representation of the supplied byte array.
+ *
+ * @param bytes the byte array
+ * @return the hex string representation of the byte array; never null
+ * @throws UnsupportedEncodingException
+ */
+ public static String getHexString( byte[] bytes ) throws UnsupportedEncodingException {
+ byte[] hex = new byte[2 * bytes.length];
+ int index = 0;
+
+ for (byte b : bytes) {
+ int v = b & 0xFF;
+ hex[index++] = HEX_CHAR_TABLE[v >>> 4];
+ hex[index++] = HEX_CHAR_TABLE[v & 0xF];
+ }
+ return new String(hex, "ASCII");
+ }
+
private StringUtil() {
// Prevent construction
}
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/SpiI18n.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/SpiI18n.java 2008-08-20 19:16:50 UTC (rev 460)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/SpiI18n.java 2008-08-22 19:32:12 UTC (rev 461)
@@ -58,6 +58,7 @@
public static I18n pathExpressionIsInvalid;
public static I18n pathExpressionHasInvalidSelect;
public static I18n pathExpressionHasInvalidMatch;
+ public static I18n messageDigestNotFound;
public static I18n executingGraphCommand;
public static I18n executedGraphCommand;
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/Binary.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/Binary.java 2008-08-20 19:16:50 UTC (rev 460)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/Binary.java 2008-08-22 19:32:12 UTC (rev 461)
@@ -23,10 +23,12 @@
import java.io.InputStream;
import java.io.Serializable;
+import java.security.MessageDigest;
import net.jcip.annotations.Immutable;
/**
* Value holder for binary data. Binary instances are not mutable.
+ *
* @author Randall Hauch
*/
@Immutable
@@ -34,29 +36,53 @@
/**
* Get the length of this binary data.
+ *
* @return the number of bytes in this binary data
+ * @see #acquire()
*/
public long getSize();
/**
+ * Get the SHA-1 hash of the contents. This hash can be used to determine whether two Binary instances contain the same
+ * content.
+ * <p>
+ * Repeatedly calling this method should generally be efficient, as it most implementations will compute the hash only once.
+ * </p>
+ *
+ * @return the hash of the contents as a byte array, or an empty array if the hash could not be computed.
+ * @see #acquire()
+ * @see MessageDigest#digest(byte[])
+ * @see MessageDigest#getInstance(String)
+ */
+ public byte[] getHash();
+
+ /**
* Get the contents of this data as a stream.
+ *
* @return the stream to this data's contents
+ * @see #acquire()
*/
public InputStream getStream();
/**
* Get the contents of this data as a byte array.
+ *
* @return the data as an array
+ * @see #acquire()
*/
public byte[] getBytes();
/**
* Acquire any resources for this data. This method must be called before any other method on this object.
+ *
+ * @see #release()
*/
public void acquire();
/**
* Release any acquired resources. This method must be called after a client is finished with this value.
+ *
+ * @see #acquire()
*/
public void release();
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueComparators.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueComparators.java 2008-08-20 19:16:50 UTC (rev 460)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueComparators.java 2008-08-22 19:32:12 UTC (rev 461)
@@ -109,6 +109,19 @@
final long len2 = o2.getSize();
if (len1 < len2) return -1;
if (len1 > len2) return 1;
+
+ // Compare using the hashes, if available
+ byte[] hash1 = o1.getHash();
+ byte[] hash2 = o2.getHash();
+ if (hash1.length != 0 || hash2.length != 0) {
+ assert hash1.length == hash2.length;
+ for (int i = 0; i != hash1.length; ++i) {
+ int diff = hash1[i] - hash2[i];
+ if (diff != 0) return diff;
+ }
+ return 0;
+ }
+
// Otherwise they are the same length ...
InputStream stream1 = null;
InputStream stream2 = null;
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/InMemoryBinary.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/InMemoryBinary.java 2008-08-20 19:16:50 UTC (rev 460)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/InMemoryBinary.java 2008-08-22 19:32:12 UTC (rev 461)
@@ -23,18 +23,29 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
import net.jcip.annotations.Immutable;
import org.jboss.dna.common.util.ArgCheck;
+import org.jboss.dna.common.util.Logger;
+import org.jboss.dna.spi.SpiI18n;
import org.jboss.dna.spi.graph.Binary;
import org.jboss.dna.spi.graph.ValueComparators;
/**
* An implementation of {@link Binary} that keeps the binary data in-memory.
+ *
* @author Randall Hauch
*/
@Immutable
public class InMemoryBinary implements Binary {
+ protected static final Set<String> ALGORITHMS_NOT_FOUND_AND_LOGGED = new CopyOnWriteArraySet<String>();
+ private static final String SHA1DIGEST_NAME = "SHA-1";
+ private static final byte[] NO_HASH = new byte[] {};
+
/**
*/
private static final long serialVersionUID = 8792863149767123559L;
@@ -42,6 +53,7 @@
protected static final byte[] EMPTY_CONTENT = new byte[0];
private final byte[] bytes;
+ private byte[] sha1hash;
public InMemoryBinary( byte[] bytes ) {
ArgCheck.isNotNull(bytes, "bytes");
@@ -57,7 +69,40 @@
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.graph.Binary#getHash()
*/
+ public byte[] getHash() {
+ if (sha1hash == null) {
+ // Omnipotent, so doesn't matter if we recompute in concurrent threads ...
+ try {
+ sha1hash = getHash(SHA1DIGEST_NAME);
+ } catch (NoSuchAlgorithmException e) {
+ if (ALGORITHMS_NOT_FOUND_AND_LOGGED.add(SHA1DIGEST_NAME)) {
+ Logger.getLogger(getClass()).error(e, SpiI18n.messageDigestNotFound, SHA1DIGEST_NAME);
+ }
+ sha1hash = NO_HASH;
+ }
+ }
+ return sha1hash;
+ }
+
+ /**
+ * Get the hash of the contents, using the digest identified by the supplied name.
+ *
+ * @param digestName the name of the hashing function (or {@link MessageDigest message digest}) that should be used
+ * @return the hash of the contents as a byte array
+ * @throws NoSuchAlgorithmException if the supplied algorithm could not be found
+ */
+ protected byte[] getHash( String digestName ) throws NoSuchAlgorithmException {
+ MessageDigest digest = MessageDigest.getInstance(digestName);
+ assert digest != null;
+ return digest.digest(bytes);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public byte[] getBytes() {
return this.bytes;
}
Modified: trunk/dna-spi/src/main/resources/org/jboss/dna/spi/SpiI18n.properties
===================================================================
--- trunk/dna-spi/src/main/resources/org/jboss/dna/spi/SpiI18n.properties 2008-08-20 19:16:50 UTC (rev 460)
+++ trunk/dna-spi/src/main/resources/org/jboss/dna/spi/SpiI18n.properties 2008-08-22 19:32:12 UTC (rev 461)
@@ -45,6 +45,7 @@
pathExpressionIsInvalid = The path expression {0} is not valid
pathExpressionHasInvalidSelect = Invalid select expression "{0}" in the path expression "{1}"
pathExpressionHasInvalidMatch = Invalid match expression "{0}" in the path expression "{1}"
+messageDigestNotFound = The "{0}" message digest algorithm could not be found
executingGraphCommand = Executing {0}
executedGraphCommand = Executed {0}
Modified: trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/InMemoryBinaryTest.java
===================================================================
--- trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/InMemoryBinaryTest.java 2008-08-20 19:16:50 UTC (rev 460)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/InMemoryBinaryTest.java 2008-08-22 19:32:12 UTC (rev 461)
@@ -28,6 +28,7 @@
import java.io.IOException;
import java.io.InputStream;
import org.jboss.dna.common.util.IoUtil;
+import org.jboss.dna.common.util.StringUtil;
import org.jboss.dna.spi.graph.Binary;
import org.junit.Before;
import org.junit.Test;
@@ -109,4 +110,24 @@
assertThat(another, hasContent(shorterContent));
}
+ @Test
+ public void shouldComputeSha1HashOfEmptyContent() throws Exception {
+ validByteArrayContent = new byte[0];
+ binary = new InMemoryBinary(validByteArrayContent);
+ assertThat(binary.getSize(), is(0l));
+ assertThat(binary, hasNoContent());
+ byte[] hash = binary.getHash();
+ assertThat(hash.length, is(20));
+ assertThat(StringUtil.getHexString(hash), is("da39a3ee5e6b4b0d3255bfef95601890afd80709"));
+ }
+
+ @Test
+ public void shouldComputeSha1HashOfNonEmptyContent() throws Exception {
+ binary = new InMemoryBinary(validByteArrayContent);
+ assertThat(binary.getSize(), is((long)validByteArrayContent.length));
+ byte[] hash = binary.getHash();
+ assertThat(hash.length, is(20));
+ assertThat(StringUtil.getHexString(hash), is("14abe696257e85ba18b7c784d6c7855f46ce50ea"));
+ }
+
}
15 years, 9 months
DNA SVN: r460 - in trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation: merge and 1 other directory.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-08-20 15:16:50 -0400 (Wed, 20 Aug 2008)
New Revision: 460
Modified:
trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/FederatingCommandExecutor.java
trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/StandardMergeStrategy.java
Log:
DNA-188 - Complete the federating command executor
http://jira.jboss.com/jira/browse/DNA-188
Removed the identity property passed into the StandardMergeStrategy constructor.
Modified: trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/FederatingCommandExecutor.java
===================================================================
--- trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/FederatingCommandExecutor.java 2008-08-20 19:15:52 UTC (rev 459)
+++ trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/FederatingCommandExecutor.java 2008-08-20 19:16:50 UTC (rev 460)
@@ -155,7 +155,7 @@
if (this.sourceProjections.size() == 1 && this.sourceProjections.get(0).isSimple()) {
this.mergingStrategy = new OneContributionMergeStrategy();
} else {
- this.mergingStrategy = new StandardMergeStrategy(DnaLexicon.UUID);
+ this.mergingStrategy = new StandardMergeStrategy();
}
}
assert this.mergingStrategy != null;
Modified: trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/StandardMergeStrategy.java
===================================================================
--- trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/StandardMergeStrategy.java 2008-08-20 19:15:52 UTC (rev 459)
+++ trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/StandardMergeStrategy.java 2008-08-20 19:16:50 UTC (rev 460)
@@ -24,20 +24,12 @@
import java.util.List;
import org.jboss.dna.connector.federation.contribution.Contribution;
import org.jboss.dna.spi.ExecutionContext;
-import org.jboss.dna.spi.graph.Name;
/**
* @author Randall Hauch
*/
public class StandardMergeStrategy implements MergeStrategy {
- private final Name identityPropertyName;
-
- public StandardMergeStrategy( Name identityPropertyName ) {
- assert identityPropertyName != null;
- this.identityPropertyName = identityPropertyName;
- }
-
/**
* {@inheritDoc}
*
@@ -49,7 +41,11 @@
ExecutionContext context ) {
// Children whose identity properties are the same will be considered to be the same node ...
- assert identityPropertyName != null;
+
+ // Assemble the children ...
+
+ // Assemble the properties (and look for UUID property) ...
+
// Create a merge plan with the contributions ...
MergePlan plan = MergePlan.create(contributions);
federatedNode.setMergePlan(plan);
15 years, 9 months
DNA SVN: r459 - trunk/dna-repository/src/test/java/org/jboss/dna/repository.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-08-20 15:15:52 -0400 (Wed, 20 Aug 2008)
New Revision: 459
Modified:
trunk/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryServiceTest.java
Log:
DNA-210 - Change repository connectors to use the new ExecutionContext logger
http://jira.jboss.com/jira/browse/DNA-210
Fixed the tests that stubbed out the ExecutionContext but did not stub out the "getLogger(...)" method that were now called during normal execution.
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryServiceTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryServiceTest.java 2008-08-20 18:07:43 UTC (rev 458)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryServiceTest.java 2008-08-20 19:15:52 UTC (rev 459)
@@ -41,17 +41,13 @@
import org.jboss.dna.repository.services.ServiceAdministrator;
import org.jboss.dna.spi.DnaLexicon;
import org.jboss.dna.spi.ExecutionContext;
+import org.jboss.dna.spi.connector.BasicExecutionContext;
import org.jboss.dna.spi.connector.RepositoryConnection;
import org.jboss.dna.spi.connector.RepositorySource;
import org.jboss.dna.spi.connector.SimpleRepository;
import org.jboss.dna.spi.connector.SimpleRepositorySource;
-import org.jboss.dna.spi.graph.NamespaceRegistry;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PathFactory;
-import org.jboss.dna.spi.graph.PropertyFactory;
-import org.jboss.dna.spi.graph.impl.BasicNamespaceRegistry;
-import org.jboss.dna.spi.graph.impl.BasicPropertyFactory;
-import org.jboss.dna.spi.graph.impl.StandardValueFactories;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -71,14 +67,11 @@
private RepositoryService service;
private Projection configProjection;
- private StandardValueFactories valueFactories;
- private PropertyFactory propertyFactory;
private PathFactory pathFactory;
private String configSourceName;
private SimpleRepository configRepository;
private SimpleRepositorySource configRepositorySource;
private RepositoryConnection configRepositoryConnection;
- @Mock
private ExecutionContext context;
@Mock
private RepositorySourceManager sources;
@@ -86,11 +79,9 @@
@Before
public void beforeEach() throws Exception {
MockitoAnnotations.initMocks(this);
- NamespaceRegistry registry = new BasicNamespaceRegistry();
- registry.register(DnaLexicon.Namespace.PREFIX, DnaLexicon.Namespace.URI);
- valueFactories = new StandardValueFactories(registry);
- pathFactory = valueFactories.getPathFactory();
- propertyFactory = new BasicPropertyFactory(valueFactories);
+ context = new BasicExecutionContext();
+ context.getNamespaceRegistry().register(DnaLexicon.Namespace.PREFIX, DnaLexicon.Namespace.URI);
+ pathFactory = context.getValueFactories().getPathFactory();
Path pathInRepository = pathFactory.create("/");
Path pathInSource = pathFactory.create("/reposX");
configSourceName = "configSource";
@@ -102,9 +93,6 @@
configRepositorySource.setName(configSourceName);
configRepositoryConnection = configRepositorySource.getConnection();
stub(sources.createConnection(configSourceName)).toReturn(configRepositoryConnection);
- stub(context.getValueFactories()).toReturn(valueFactories);
- stub(context.getPropertyFactory()).toReturn(propertyFactory);
- stub(context.getNamespaceRegistry()).toReturn(registry);
service = new RepositoryService(sources, configProjection, context, null);
}
15 years, 9 months