DNA SVN: r1512 - in trunk: docs/examples/gettingstarted/sequencers and 32 other directories.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2010-01-01 12:46:39 -0500 (Fri, 01 Jan 2010)
New Revision: 1512
Added:
trunk/docs/reference/src/main/docbook/en-US/content/sequencers/java_class.xml
trunk/extensions/dna-sequencer-classfile/
trunk/extensions/dna-sequencer-classfile/.classpath
trunk/extensions/dna-sequencer-classfile/.project
trunk/extensions/dna-sequencer-classfile/pom.xml
trunk/extensions/dna-sequencer-classfile/src/
trunk/extensions/dna-sequencer-classfile/src/main/
trunk/extensions/dna-sequencer-classfile/src/main/java/
trunk/extensions/dna-sequencer-classfile/src/main/java/org/
trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/
trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/
trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/
trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/
trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileRecorder.java
trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileSequencer.java
trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileSequencerI18n.java
trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileSequencerLexicon.java
trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/DefaultClassFileRecorder.java
trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/
trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/AnnotationMetadata.java
trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/ClassFileMetadataReader.java
trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/ClassMetadata.java
trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/EnumMetadata.java
trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/FieldMetadata.java
trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/MethodMetadata.java
trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/Visibility.java
trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/package-info.java
trunk/extensions/dna-sequencer-classfile/src/main/resources/
trunk/extensions/dna-sequencer-classfile/src/main/resources/org/
trunk/extensions/dna-sequencer-classfile/src/main/resources/org/jboss/
trunk/extensions/dna-sequencer-classfile/src/main/resources/org/jboss/dna/
trunk/extensions/dna-sequencer-classfile/src/main/resources/org/jboss/dna/sequencer/
trunk/extensions/dna-sequencer-classfile/src/main/resources/org/jboss/dna/sequencer/classfile/
trunk/extensions/dna-sequencer-classfile/src/main/resources/org/jboss/dna/sequencer/classfile/ClassFileSequencerI18n.properties
trunk/extensions/dna-sequencer-classfile/src/main/resources/org/jboss/dna/sequencer/classfile/sequencer-classfile.cnd
trunk/extensions/dna-sequencer-classfile/src/test/
trunk/extensions/dna-sequencer-classfile/src/test/java/
trunk/extensions/dna-sequencer-classfile/src/test/java/org/
trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/
trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/
trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/
trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/classfile/
trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/classfile/ClassFileSequencerI18nTest.java
trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/classfile/ClassFileSequencerTest.java
trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/classfile/MockEnum.java
trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/classfile/metadata/
trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/classfile/metadata/ClassFileMetadataReaderTest.java
trunk/extensions/dna-sequencer-classfile/src/test/resources/
trunk/extensions/dna-sequencer-classfile/src/test/resources/NodeEntity.clazz
Modified:
trunk/docs/examples/gettingstarted/sequencers/.project
trunk/docs/examples/gettingstarted/sequencers/pom.xml
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java
trunk/docs/examples/gettingstarted/sequencers/src/main/resources/sequencing.cnd
trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencer/SequencingClientTest.java
trunk/docs/reference/src/main/docbook/en-US/custom.dtd
trunk/docs/reference/src/main/docbook/en-US/master.xml
trunk/pom.xml
trunk/utils/dna-jpa-ddl-gen/
Log:
DNA-62
Committed first (working) version of this sequencer. The sequencer calls a Reader implementation (a la the MS Office sequencer) that parses a class file into a metadata object. The metadata object is then passed to a (customizable) recorder object that creates the relevant graph entries. The patch integrates the sequencer with the getting started sequencers example to help verify that it works.
The current version has extensive testing of the class file reader implementation, but very little testing of the default recorder (the object that converts the metadata into a series of graph nodes and properties).
For the defect to be resolved properly, I think these things would need to happen (in no particular order):
1. Align the default output for the class sequencer and the Java sequencer so that they are as identical as possible. This will be very helpful for future analyzer writers.
2. Align the metadata objects between the class sequencer and the Java source sequencer. Both are parsing into objects with the same name. It seems like they could probably be moved to share a common interface and then reuse recorder implementations (solving issue 1).
3. Move the sequencer into the same package and namespace as the java sequencer. This is a nice to have, but the two sequencers are so tightly related that it makes a lot of sense (to me, anyway)
4. Clean up/add Javadoc and add more testing for the default recorder implementation
Steps 2 and 3 may or may not be appropriate, for all of the good reasons that rhauch noted in his comments on this defect.
Modified: trunk/docs/examples/gettingstarted/sequencers/.project
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/.project 2010-01-01 17:19:43 UTC (rev 1511)
+++ trunk/docs/examples/gettingstarted/sequencers/.project 2010-01-01 17:46:39 UTC (rev 1512)
@@ -1,23 +1,29 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>docs-getting-started-examples-sequencers</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.maven.ide.eclipse.maven2Builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.maven.ide.eclipse.maven2Nature</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>docs-getting-started-examples-sequencers</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ </natures>
+</projectDescription>
Modified: trunk/docs/examples/gettingstarted/sequencers/pom.xml
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/pom.xml 2010-01-01 17:19:43 UTC (rev 1511)
+++ trunk/docs/examples/gettingstarted/sequencers/pom.xml 2010-01-01 17:46:39 UTC (rev 1512)
@@ -30,6 +30,12 @@
</dependency>
<dependency>
<groupId>org.jboss.dna</groupId>
+ <artifactId>dna-sequencer-classfile</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
<artifactId>dna-sequencer-images</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
Modified: trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java 2010-01-01 17:19:43 UTC (rev 1511)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java 2010-01-01 17:46:39 UTC (rev 1512)
@@ -50,6 +50,8 @@
import org.jboss.dna.jcr.SecurityContextCredentials;
import org.jboss.dna.repository.sequencer.SequencingService;
import org.jboss.dna.repository.util.SessionFactory;
+import org.jboss.dna.sequencer.classfile.ClassFileSequencer;
+import org.jboss.dna.sequencer.classfile.ClassFileSequencerLexicon;
/**
* The main application for running the sequencers.
@@ -74,7 +76,11 @@
.setDescription("The repository for our content")
.setProperty("defaultWorkspaceName", workspaceName);
// Set up the JCR repository to use the source ...
- config.repository(repositoryId).addNodeTypes("sequencing.cnd").setSource("store");
+ config.repository(repositoryId)
+ .addNodeTypes("sequencing.cnd")
+ .registerNamespace(ClassFileSequencerLexicon.Namespace.PREFIX,
+ ClassFileSequencerLexicon.Namespace.URI)
+ .setSource("store");
// Set up the image sequencer ...
config.sequencer("Image Sequencer")
.usingClass("org.jboss.dna.sequencer.image.ImageMetadataSequencer")
@@ -89,6 +95,12 @@
.setDescription("Sequences mp3 files to extract the id3 tags of the audio file")
.sequencingFrom("//(*.mp3[*])/jcr:content[@jcr:data]")
.andOutputtingTo("/mp3s/$1");
+ // Set up the Java class file sequencer ...
+ config.sequencer("Java Class Sequencer")
+ .usingClass(ClassFileSequencer.class)
+ .setDescription("Sequences Java class files to extract the structure of the classes")
+ .sequencingFrom("//*.class[*]/jcr:content[@jcr:data]")
+ .andOutputtingTo("/classes");
// Set up the Java source file sequencer ...
config.sequencer("Java Sequencer")
.usingClass("org.jboss.dna.sequencer.java.JavaMetadataSequencer")
@@ -273,7 +285,7 @@
while (!nodesToVisit.isEmpty()) {
Node node = nodesToVisit.remove();
- String nodeType = "nt:file".equals(node.getPrimaryNodeType()) ? "file" : "folder";
+ String nodeType = "nt:folder".equals(node.getPrimaryNodeType().getName()) ? "folder" : "file";
infos.add(new MediaInfo(node.getPath(), node.getName(), nodeType, new Properties()));
for (NodeIterator i = node.getNodes(); i.hasNext();) {
@@ -343,6 +355,32 @@
}
}
+ if (root.hasNode("classes")) {
+ LinkedList<Node> nodesToVisit = new LinkedList<Node>();
+
+ for (NodeIterator i = root.getNode("classes").getNodes(); i.hasNext();) {
+ nodesToVisit.addLast(i.nextNode());
+ }
+
+ while (!nodesToVisit.isEmpty()) {
+ Node node = nodesToVisit.remove();
+
+ if ("class:class".equals(node.getPrimaryNodeType().getName())) {
+ Properties props = new Properties();
+ props.put("constructors", node.getNode("class:constructors").getNodes().getSize());
+ props.put("methods", node.getNode("class:methods").getNodes().getSize());
+ props.put("fields", node.getNode("class:fields").getNodes().getSize());
+
+ infos.add(new MediaInfo(node.getPath(), node.getName(), "class", props));
+
+ } else {
+ for (NodeIterator i = node.getNodes(); i.hasNext();) {
+ nodesToVisit.addLast(i.nextNode());
+ }
+ }
+
+ }
+ }
if (root.hasNode("java")) {
Map<String, List<Properties>> tree = new TreeMap<String, List<Properties>>();
// Find the compilation unit node ...
@@ -545,6 +583,7 @@
if (filename.endsWith(".java")) return "text/x-java-source";
if (filename.endsWith(".csv")) return "text/csv";
if (filename.endsWith(".txt")) return "text/plain";
+ if (filename.endsWith(".clazz")) return "application/x-java-class";
return null;
}
Modified: trunk/docs/examples/gettingstarted/sequencers/src/main/resources/sequencing.cnd
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/resources/sequencing.cnd 2010-01-01 17:19:43 UTC (rev 1511)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/resources/sequencing.cnd 2010-01-01 17:46:39 UTC (rev 1512)
@@ -5,7 +5,9 @@
<mp3='http://www.jboss.org/dna/mp3/1.0'>
<java='http://www.jboss.org/dna/java/1.0'>
<zip='http://www.jboss.org/dna/zip/1.0'>
+<class='http://www.jboss.org/dna/sequencer/javaclass/1.0'>
+
// ----------------------------------------------------------
// JCR Pre-defined Mixin Types that are not loaded by default
// ----------------------------------------------------------
@@ -283,4 +285,74 @@
[zip:content] > nt:unstructured, mix:mimeTyped
+ * (nt:folder)
+ * (nt:file)
+
+// -------------------
+// DNA Java Class Sequencer
+// -------------------
+
+[class:annotationMember]
+- class:name (string) mandatory
+- class:value (string)
+
+[class:annotation]
+- class:name (string) mandatory
++ * (class:annotationMember) = class:annotationMember
+
+[class:annotations]
++ * (class:annotation) = class:annotation
+
+[class:field]
+- class:name (string) mandatory
+- class:typeClassName (string) mandatory
+- class:visibility (string) mandatory < 'public', 'protected', 'package', 'private'
+- class:static (boolean) mandatory
+- class:final (boolean) mandatory
+- class:transient (boolean) mandatory
+- class:volatile (boolean) mandatory
++ class:annotations (class:annotations) = class:annotations
+
+[class:fields]
++ * (class:field) = class:field
+
+[class:interfaces]
+- * (string)
+
+[class:parameters]
+- * (string)
+
+[class:method]
+- class:name (string) mandatory
+- class:returnTypeClassName (string) mandatory
+- class:visibility (string) mandatory < 'public', 'protected', 'package', 'private'
+- class:static (boolean) mandatory
+- class:final (boolean) mandatory
+- class:abstract (boolean) mandatory
+- class:strictFp (boolean) mandatory
+- class:native (boolean) mandatory
+- class:synchronized (boolean) mandatory
+- class:parameters (string) multiple
++ class:annotations (class:annotations) = class:annotations
+
+[class:methods]
++ * (class:method) = class:method
+
+[class:constructors]
++ * (class:method) = class:method
+
+[class:class]
+- class:name (string) mandatory
+- class:superClassName (string)
+- class:visibility (string) mandatory < 'public', 'protected', 'package', 'private'
+- class:abstract (boolean) mandatory
+- class:interface (boolean) mandatory
+- class:final (boolean) mandatory
+- class:strictFp (boolean) mandatory
+- class:interfaces (string) multiple
++ class:annotations (class:annotations) = class:annotations
++ class:constructors (class:constructors) = class:constructors
++ class:methods (class:methods) = class:methods
++ class:fields (class:fields) = class:fields
+
+[class:enum] > class:class
+- class:enumValues (string) mandatory multiple
\ No newline at end of file
Modified: trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencer/SequencingClientTest.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencer/SequencingClientTest.java 2010-01-01 17:19:43 UTC (rev 1511)
+++ trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencer/SequencingClientTest.java 2010-01-01 17:46:39 UTC (rev 1512)
@@ -35,6 +35,8 @@
import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
import org.jboss.dna.jcr.JcrConfiguration;
import org.jboss.dna.jcr.JcrRepository;
+import org.jboss.dna.sequencer.classfile.ClassFileSequencer;
+import org.jboss.dna.sequencer.classfile.ClassFileSequencerLexicon;
import org.jboss.dna.sequencer.java.JavaMetadataSequencer;
import org.jboss.dna.sequencer.mp3.Mp3MetadataSequencer;
import org.jboss.dna.sequencer.zip.ZipSequencer;
@@ -52,6 +54,7 @@
private URL jpegImageUrl;
private URL mp3Url;
private URL jarUrl;
+ private URL classUrl;
private URL javaSourceUrl;
private URL csvUrl;
private URL fixedWidthFileUrl;
@@ -64,6 +67,7 @@
this.jpegImageUrl = Thread.currentThread().getContextClassLoader().getResource("caution.jpg");
this.mp3Url = Thread.currentThread().getContextClassLoader().getResource("sample1.mp3");
this.jarUrl = Thread.currentThread().getContextClassLoader().getResource("test.jar");
+ this.classUrl = Thread.currentThread().getContextClassLoader().getResource("JcrRepository.clazz");
this.csvUrl = Thread.currentThread().getContextClassLoader().getResource("test.csv");
this.fixedWidthFileUrl = Thread.currentThread().getContextClassLoader().getResource("fixedWidthFile.txt");
@@ -78,9 +82,12 @@
.usingClass(InMemoryRepositorySource.class)
.setDescription("The repository for our content")
.setProperty("defaultWorkspaceName", workspaceName);
+
// Set up the JCR repository to use the source ...
config.repository(repositoryId)
.addNodeTypes(getClass().getClassLoader().getResource("sequencing.cnd"))
+ .registerNamespace(ClassFileSequencerLexicon.Namespace.PREFIX,
+ ClassFileSequencerLexicon.Namespace.URI)
.setSource("store")
.setOption(JcrRepository.Option.JAAS_LOGIN_CONFIG_NAME, "dna-jcr");
// Set up the image sequencer ...
@@ -108,6 +115,13 @@
.setDescription("Sequences Java files to extract the AST structure of the Java source code")
.sequencingFrom("//(*.java[*])/jcr:content[@jcr:data]")
.andOutputtingTo("/java/$1");
+ // Set up the Java class file sequencer ...
+ // Only looking for one class to make verification easier
+ config.sequencer("Java Class Sequencer")
+ .usingClass(ClassFileSequencer.class)
+ .setDescription("Sequences Java class files to extract the structure of the classes")
+ .sequencingFrom("//JcrRepository.clazz[*]/jcr:content[@jcr:data]")
+ .andOutputtingTo("/classes");
// Set up the CSV file sequencer ...
config.sequencer("CSV Sequencer")
.usingClass("org.jboss.dna.sequencer.text.DelimitedTextSequencer")
@@ -124,7 +138,7 @@
.setProperty("columnStartPositions", new int[] { 10, 20, 30, 40})
.sequencingFrom("//(*.txt[*])/jcr:content[@jcr:data]")
.andOutputtingTo("/txt/$1");
-
+
// Now start the client and tell it which repository and workspace to use ...
client = new SequencingClient(config, repositoryId, workspaceName);
}
@@ -132,6 +146,9 @@
@After
public void afterEach() throws Exception {
if (client != null) client.shutdownRepository();
+ // while (true) {
+ // Thread.sleep(300000);
+ // }
}
@Test
@@ -202,6 +219,19 @@
}
@Test
+ public void shouldUploadAndSequenceClassFile() throws Exception {
+ client.setUserInterface(new MockUserInterface(this.classUrl, "/a/b/JcrRepository.clazz", 1));
+ client.startRepository();
+ client.uploadFile();
+
+ waitUntilSequencedNodesIs(1);
+
+ // The sequencers should have run, so perform the search.
+ // The mock user interface checks the results.
+ client.search();
+ }
+
+ @Test
public void shouldUploadAndSequenceJavaSourceFile() throws Exception {
client.setUserInterface(new MockUserInterface(this.javaSourceUrl, "/a/b/MySource.java", 1));
client.startRepository();
Added: trunk/docs/reference/src/main/docbook/en-US/content/sequencers/java_class.xml
===================================================================
--- trunk/docs/reference/src/main/docbook/en-US/content/sequencers/java_class.xml (rev 0)
+++ trunk/docs/reference/src/main/docbook/en-US/content/sequencers/java_class.xml 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ JBoss DNA (http://www.jboss.org/dna)
+ ~
+ ~ See the COPYRIGHT.txt file distributed with this work for information
+ ~ regarding copyright ownership. Some portions may be licensed
+ ~ to Red Hat, Inc. under one or more contributor license agreements.
+ ~ See the AUTHORS.txt file in the distribution for a full listing of
+ ~ individual contributors.
+ ~
+ ~ JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ ~ is licensed to you under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ JBoss DNA is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ -->
+<!DOCTYPE preface PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % CustomDTD SYSTEM "../../custom.dtd">
+%CustomDTD;
+]>
+<chapter id="java-class-sequencer">
+ <title>Java Class File Sequencer</title>
+ <para>
+ The Java class file sequencer parses Java class file to extract metadata for the class, its methods, its fields, and its annotations.
+ The output of the sequencer can be customized by using the <code>classFileRecorder</code> or <code>classFileRecorderClassName</code>
+ properties to provide a custom implementation of the &ClassFileRecorder; interface. A default implementation (&DefaultClassFileRecorder;) is
+ provided that records all extracted metadata to the output location.
+ <caution>
+ <para>
+ The Java class file sequencer is being released as a Technology Preview. It is fully functional, but the output format and node types
+ associated with the &DefaultClassFileRecorder; may change in future versions to better align with the output of the
+ &JavaMetadataSequencer;.
+ </para>
+ </caution>
+ </para>
+ <para>
+ As noted previously, the &ClassFileSequencer; class provides a pair of JavaBean properties that can be used to specify a custom &ClassFileRecorder;
+ implementation to use to map the extracted metadata to an output location:
+ </para>
+ <table frame='all'>
+ <title>&ClassFileSequencer; properties</title>
+ <tgroup cols='2' align='left' colsep='1' rowsep='1'>
+ <colspec colname='c1' colwidth="1*"/>
+ <colspec colname='c2' colwidth="1*"/>
+ <thead>
+ <row>
+ <entry>Property</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>classFileRecorder</entry>
+ <entry>
+ Optional property that, if set, provides an instance of the &ClassFileRecorder; interface that will be used for all
+ subsequent sequencing activity for this sequencer. If this property is set to null, a default implementation will be used. The default
+ value of this property is null.
+ </entry>
+ </row>
+ <row>
+ <entry>classFileRecorderClassName</entry>
+ <entry>
+ Optional property that, if set, provides the name of a class that provides a custom implementation of the &ClassFileRecorder; interface.
+ This class must have a no-argument, public constructor. If set, an instance of this class will be created immediately and reused for all
+ subsequent sequencing activity for this sequencer. If this property is set to null, a default implementation will be used. The default
+ value of this property is null.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <para>
+ The default class file recorder creates a subgraph rooted at the output location that takes the following form (with primary types in parentheses):
+ </para>
+ <programlisting>
+<graph root>
+ + <package name 1> (nt:unstructured)
+ .
+ .
+ .
+ + <package name N>(nt:unstructured)
+ + <class name> (class:class)
+ + class:annotations (class:annotations)
+ | + <annotation name> - one per annotation (class:annotation)
+ + class:constructors (class:constructors)
+ | + <constructor parameters> - one per constructor (class:constructor)
+ | + <annotation name> - one per annotation (class:annotation)
+ + class:methods (class:methods)
+ | + <method name (parameters)> - one per method (class:method)
+ | + <annotation name> - one per annotation (class:annotation)
+ + class:fields (class:fields)
+ + <field name> - one per field (class:field)
+ + <annotation name> - one per annotation (class:annotation)
+ </programlisting>
+ <para>
+ The compact node definitions for the class:* types is provided below. <emphasis>Please note that these definitions may change in a future release.</emphasis>
+ </para>
+ <programlisting><![CDATA[
+
+[class:annotationMember]
+- class:name (string) mandatory
+- class:value (string)
+
+[class:annotation]
+- class:name (string) mandatory
++ * (class:annotationMember) = class:annotationMember
+
+[class:annotations]
++ * (class:annotation) = class:annotation
+
+[class:field]
+- class:name (string) mandatory
+- class:typeClassName (string) mandatory
+- class:visibility (string) mandatory < 'public', 'protected', 'package', 'private'
+- class:static (boolean) mandatory
+- class:final (boolean) mandatory
+- class:transient (boolean) mandatory
+- class:volatile (boolean) mandatory
++ class:annotations (class:annotations) = class:annotations
+
+[class:fields]
++ * (class:field) = class:field
+
+[class:interfaces]
+- * (string)
+
+[class:parameters]
+- * (string)
+
+[class:method]
+- class:name (string) mandatory
+- class:returnTypeClassName (string) mandatory
+- class:visibility (string) mandatory < 'public', 'protected', 'package', 'private'
+- class:static (boolean) mandatory
+- class:final (boolean) mandatory
+- class:abstract (boolean) mandatory
+- class:strictFp (boolean) mandatory
+- class:native (boolean) mandatory
+- class:synchronized (boolean) mandatory
+- class:parameters (string) multiple
++ class:annotations (class:annotations) = class:annotations
+
+[class:methods]
++ * (class:method) = class:method
+
+[class:constructors]
++ * (class:method) = class:method
+
+[class:class]
+- class:name (string) mandatory
+- class:superClassName (string)
+- class:visibility (string) mandatory < 'public', 'protected', 'package', 'private'
+- class:abstract (boolean) mandatory
+- class:interface (boolean) mandatory
+- class:final (boolean) mandatory
+- class:strictFp (boolean) mandatory
+- class:interfaces (string) multiple
++ class:annotations (class:annotations) = class:annotations
++ class:constructors (class:constructors) = class:constructors
++ class:methods (class:methods) = class:methods
++ class:fields (class:fields) = class:fields
+
+[class:enum] > class:class
+- class:enumValues (string) mandatory multiple
+ ]]></programlisting>
+ <para>
+ To use this sequencer, simply include the <code>dna-sequencer-classfile</code> JAR
+ in your application and configure the &JcrConfiguration; to use this sequencer using something similar to:
+ </para>
+ <programlisting>
+JcrConfiguration config = ...
+
+config.sequencer("Java Class Sequencer")
+ .usingClass(ClassFileSequencer.class)
+ .setDescription("Sequences Java class files to extract the structure of the classes")
+ .sequencingFrom("//*.class[*]/jcr:content[@jcr:data]")
+ .andOutputtingTo("/classes");
+ </programlisting>
+
+</chapter>
\ No newline at end of file
Property changes on: trunk/docs/reference/src/main/docbook/en-US/content/sequencers/java_class.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/docs/reference/src/main/docbook/en-US/custom.dtd
===================================================================
--- trunk/docs/reference/src/main/docbook/en-US/custom.dtd 2010-01-01 17:19:43 UTC (rev 1511)
+++ trunk/docs/reference/src/main/docbook/en-US/custom.dtd 2010-01-01 17:46:39 UTC (rev 1512)
@@ -155,7 +155,6 @@
<!ENTITY Sequencer "<ulink url='&API;repository/sequencer/Sequencer.html'><interface>Sequencer</interface></ulink>">
<!ENTITY SequencerOutput "<ulink url='&API;graph/sequencer/SequencerOutput.html'><interface>SequencerOutput</interface></ulink>">
<!ENTITY SequencerContext "<ulink url='&API;graph/sequencer/SequencerContext.html'><interface>SequencerContext</interface></ulink>">
-<!ENTITY StreamequencerContext "<ulink url='&API;graph/sequencer/StreamequencerContext.html'><interface>StreamequencerContext</interface></ulink>">
<!ENTITY MimeTypeDetector "<ulink url='&API;graph/mimetype/MimeTypeDetector.html'><interface>MimeTypeDetector</interface></ulink>">
<!ENTITY MockSequencerOutput "<ulink url='&API;graph/sequencer/MockSequencerOutput.html'><interface>MockSequencerOutput</interface></ulink>">
<!ENTITY MockSequencerContext "<ulink url='&API;graph/sequencer/MockSequencerContext.html'><interface>MockSequencerContext</interface></ulink>">
@@ -216,6 +215,11 @@
<!ENTITY DnaJcrDeployer "<ulink url='&API;web/jcr/rest/DnaJcrDeployer.html'><classname>DnaJcrDeployer</classname></ulink>">
<!ENTITY RepositoryProvider "<ulink url='&API;web/jcr/rest/spi/RepositoryProvider.html'><classname>RepositoryProvider</classname></ulink>">
+<!ENTITY JavaMetadataSequencer "<ulink url='&API;sequencer/java/JavaMetadataSequencer.html'><classname>JavaMetadataSequencer</classname></ulink>">
+<!ENTITY ClassFileSequencer "<ulink url='&API;sequencer/classfile/ClassFileSequencer.html'><classname>ClassFileSequencer</classname></ulink>">
+<!ENTITY ClassFileRecorder "<ulink url='&API;sequencer/classfile/ClassFileRecorder.html'><classname>ClassFileRecorder</classname></ulink>">
+<!ENTITY DefaultClassFileRecorder "<ulink url='&API;sequencer/classfile/DefaultClassFileRecorder.html'><classname>DefaultClassFileRecorder</classname></ulink>">
+
<!ENTITY AbstractTextSequencer "<ulink url='&API;sequencer/text/AbstractTextSequencer.html'><classname>AbstractTextSequencer</classname></ulink>">
<!ENTITY DelimitedTextSequencer "<ulink url='&API;sequencer/text/DelimitedTextSequencer'><classname>DelimitedTextSequencer</classname></ulink>">
<!ENTITY FixedWidthTextSequencer "<ulink url='&API;sequencer/text/FixedWidthTextSequencer'><classname>FixedWidthTextSequencer</classname></ulink>">
Modified: trunk/docs/reference/src/main/docbook/en-US/master.xml
===================================================================
--- trunk/docs/reference/src/main/docbook/en-US/master.xml 2010-01-01 17:19:43 UTC (rev 1511)
+++ trunk/docs/reference/src/main/docbook/en-US/master.xml 2010-01-01 17:46:39 UTC (rev 1512)
@@ -132,6 +132,7 @@
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="content/sequencers/zip.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="content/sequencers/microsoft_office.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="content/sequencers/java_source.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="content/sequencers/java_class.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="content/sequencers/image.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="content/sequencers/mp3.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="content/sequencers/ddl.xml"/>
Added: trunk/extensions/dna-sequencer-classfile/.classpath
===================================================================
--- trunk/extensions/dna-sequencer-classfile/.classpath (rev 0)
+++ trunk/extensions/dna-sequencer-classfile/.classpath 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/main/resources"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
\ No newline at end of file
Added: trunk/extensions/dna-sequencer-classfile/.project
===================================================================
--- trunk/extensions/dna-sequencer-classfile/.project (rev 0)
+++ trunk/extensions/dna-sequencer-classfile/.project 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>dna-sequencer-classfile</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
Added: trunk/extensions/dna-sequencer-classfile/pom.xml
===================================================================
--- trunk/extensions/dna-sequencer-classfile/pom.xml (rev 0)
+++ trunk/extensions/dna-sequencer-classfile/pom.xml 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,66 @@
+<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">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>dna</artifactId>
+ <groupId>org.jboss.dna</groupId>
+ <version>0.7-SNAPSHOT</version>
+ <relativePath>../..</relativePath>
+ </parent>
+ <!-- The groupId and version values are inherited from parent -->
+ <artifactId>dna-sequencer-classfile</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss DNA Java Class File Sequencer</name>
+
+ <description>JBoss DNA Sequencer that processes Java class files</description>
+ <url>http://labs.jboss.org/dna</url>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-common</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-graph</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-graph</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <version>3.11.0.GA</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </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>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Property changes on: trunk/extensions/dna-sequencer-classfile/pom.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileRecorder.java
===================================================================
--- trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileRecorder.java (rev 0)
+++ trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileRecorder.java 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,57 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ import net.jcip.annotations.ThreadSafe;
+import org.jboss.dna.graph.sequencer.SequencerOutput;
+import org.jboss.dna.graph.sequencer.StreamSequencer;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
+import org.jboss.dna.sequencer.classfile.metadata.ClassMetadata;
+import org.jboss.dna.sequencer.classfile.metadata.EnumMetadata;
+e. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.classfile;
+
+import net.jcip.annotations.ThreadSafe;
+import org.jboss.dna.graph.sequencer.SequencerOutput;
+import org.jboss.dna.graph.sequencer.StreamSequencer;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
+import org.jboss.dna.sequencer.classfile.metadata.ClassMetadata;
+
+/**
+ * A simple interface that allows an implementer to control how class file metadata mapped to properties (including primary and
+ * mixin types) in the graph.
+ * <p>
+ * Implementations of this class must provide a public, no-argument constructor.
+ * </p>
+ * <p>
+ * To use, supply the implementation class name to a {@link ClassFileSequencer} object. Each instance will be reused created for
+ * over multiple {@link ClassFileSequencer#sequence(java.io.InputStream, SequencerOutput, StreamSequencerContext) sequence calls},
+ * so implementations of this interface <b>must</b> be thread-safe.
+ * </p>
+ */
+@ThreadSafe
+public interface ClassFileRecorder {
+
+ /**
+ * Records a row using the provided {@link SequencerOutput} instance.
+ *
+ * @param context the sequencer context
+ * @param output the {@link StreamSequencer} output
+ * @param classMetadata the metadata for the class file
+ */
+ void recordClass( StreamSequencerContext context,
+ SequencerOutput output,
+ ClassMetadata classMetadata );
+}
Property changes on: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileRecorder.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileSequencer.java
===================================================================
--- trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileSequencer.java (rev 0)
+++ trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileSequencer.java 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,90 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.classfile;
+
+import java.io.InputStream;
+import net.jcip.annotations.Immutable;
+import org.jboss.dna.graph.sequencer.SequencerOutput;
+import org.jboss.dna.graph.sequencer.StreamSequencer;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
+import org.jboss.dna.sequencer.classfile.metadata.ClassFileMetadataReader;
+import org.jboss.dna.sequencer.classfile.metadata.ClassMetadata;
+
+@Immutable
+public class ClassFileSequencer implements StreamSequencer {
+
+ private static final ClassFileRecorder DEFAULT_CLASS_FILE_RECORDER = new DefaultClassFileRecorder();
+
+ private ClassFileRecorder classFileRecorder = DEFAULT_CLASS_FILE_RECORDER;
+
+ @Override
+ public void sequence( InputStream stream,
+ SequencerOutput output,
+ StreamSequencerContext context ) {
+
+ try {
+ ClassMetadata classMetadata = ClassFileMetadataReader.instance(stream);
+
+ classFileRecorder.recordClass(context, output, classMetadata);
+ } catch (Exception ex) {
+ context.getLogger(getClass()).error(ex, ClassFileSequencerI18n.errorSequencingClass, context.getInputPath());
+ }
+ }
+
+ /**
+ * Sets the custom {@link ClassFileRecorder} by specifying a class name. This method attempts to instantiate an instance of
+ * the custom {@link ClassFileRecorder} class prior to ensure that the new value represents a valid implementation.
+ *
+ * @param classFileRecorderClassName the fully-qualified class name of the new custom class file recorder implementation; null
+ * indicates that {@link DefaultClassFileRecorder the default class file recorder} should be used.
+ * @throws ClassNotFoundException if the the class for the {@code ClassFileRecorder} implementation cannot be located
+ * @throws IllegalAccessException if the row factory class or its nullary constructor is not accessible.
+ * @throws InstantiationException if the row factory represents an abstract class, an interface, an array class, a primitive
+ * type, or void; or if the class has no nullary constructor; or if the instantiation fails for some other reason.
+ * @throws ClassCastException if the instantiated class file recorder does not implement the {@link ClassFileRecorder}
+ * interface
+ */
+ public void setClassFileRecorderClassName( String classFileRecorderClassName )
+ throws ClassNotFoundException, IllegalAccessException, InstantiationException {
+
+ if (classFileRecorderClassName == null) {
+ this.classFileRecorder = DEFAULT_CLASS_FILE_RECORDER;
+ return;
+ }
+
+ Class<?> classFileRecorderClass = Class.forName(classFileRecorderClassName);
+ this.classFileRecorder = (ClassFileRecorder)classFileRecorderClass.newInstance();
+ }
+
+ /**
+ * Sets a custom {@link ClassFileRecorder}. If {@code classFileRecorder} is null, then the {@link DefaultClassFileRecorder
+ * default class file recorder} will be used.
+ *
+ * @param classFileRecorder the new custom class file recorder implementation; null indicates that
+ * {@link DefaultClassFileRecorder the default class file recorder} should be used.
+ */
+ public void setClassFileRecorder( ClassFileRecorder classFileRecorder ) {
+ this.classFileRecorder = classFileRecorder == null ? DEFAULT_CLASS_FILE_RECORDER : classFileRecorder;
+ }
+}
Property changes on: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileSequencer.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileSequencerI18n.java
===================================================================
--- trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileSequencerI18n.java (rev 0)
+++ trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileSequencerI18n.java 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,56 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.classfile;
+
+import java.util.Locale;
+import java.util.Set;
+import org.jboss.dna.common.i18n.I18n;
+
+/**
+ * The internationalized string constants for the <code>org.jboss.dna.sequencer.text</code> packages.
+ */
+public final class ClassFileSequencerI18n {
+
+ public static I18n errorSequencingClass;
+
+ static {
+ try {
+ I18n.initialize(ClassFileSequencerI18n.class);
+ } catch (final Exception err) {
+ System.err.println(err);
+ }
+ }
+
+ public static Set<Locale> getLocalizationProblemLocales() {
+ return I18n.getLocalizationProblemLocales(ClassFileSequencerI18n.class);
+ }
+
+ public static Set<String> getLocalizationProblems() {
+ return I18n.getLocalizationProblems(ClassFileSequencerI18n.class);
+ }
+
+ public static Set<String> getLocalizationProblems( Locale locale ) {
+ return I18n.getLocalizationProblems(ClassFileSequencerI18n.class, locale);
+ }
+}
Property changes on: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileSequencerI18n.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileSequencerLexicon.java
===================================================================
--- trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileSequencerLexicon.java (rev 0)
+++ trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileSequencerLexicon.java 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,68 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.classfile;
+
+import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.basic.BasicName;
+
+/**
+ * The namespace and property names used within a {@link ClassFileSequencer} to store internal information.
+ */
+public class ClassFileSequencerLexicon {
+
+ public static class Namespace {
+ public static final String URI = "http://www.jboss.org/dna/sequencer/javaclass/1.0";
+ public static final String PREFIX = "class";
+ }
+
+ public static final Name ABSTRACT = new BasicName(Namespace.URI, "abstract");
+ public static final Name ANNOTATION = new BasicName(Namespace.URI, "annotation");
+ public static final Name ANNOTATIONS = new BasicName(Namespace.URI, "annotations");
+ public static final Name ANNOTATION_MEMBER = new BasicName(Namespace.URI, "annotationMember");
+ public static final Name CLASS = new BasicName(Namespace.URI, "class");
+ public static final Name CONSTRUCTORS = new BasicName(Namespace.URI, "constructors");
+ public static final Name ENUM_VALUES = new BasicName(Namespace.URI, "enumValues");
+ public static final Name ENUM = new BasicName(Namespace.URI, "enum");
+ public static final Name FIELD = new BasicName(Namespace.URI, "field");
+ public static final Name FIELDS = new BasicName(Namespace.URI, "fields");
+ public static final Name FINAL = new BasicName(Namespace.URI, "final");
+ public static final Name INTERFACE = new BasicName(Namespace.URI, "interface");
+ public static final Name INTERFACES = new BasicName(Namespace.URI, "interfaces");
+ public static final Name METHOD = new BasicName(Namespace.URI, "method");
+ public static final Name METHODS = new BasicName(Namespace.URI, "methods");
+ public static final Name NAME = new BasicName(Namespace.URI, "name");
+ public static final Name NATIVE = new BasicName(Namespace.URI, "native");
+ public static final Name PARAMETERS = new BasicName(Namespace.URI, "parameters");
+ public static final Name RETURN_TYPE_CLASS_NAME = new BasicName(Namespace.URI, "returnTypeClassName");
+ public static final Name STATIC = new BasicName(Namespace.URI, "static");
+ public static final Name STRICT_FP = new BasicName(Namespace.URI, "strictFp");
+ public static final Name SUPER_CLASS_NAME = new BasicName(Namespace.URI, "superClassName");
+ public static final Name SYNCHRONIZED = new BasicName(Namespace.URI, "synchronized");
+ public static final Name TRANSIENT = new BasicName(Namespace.URI, "transient");
+ public static final Name TYPE_CLASS_NAME = new BasicName(Namespace.URI, "typeClassName");
+ public static final Name VALUE = new BasicName(Namespace.URI, "value");
+ public static final Name VISIBILITY = new BasicName(Namespace.URI, "visibility");
+ public static final Name VOLATILE = new BasicName(Namespace.URI, "volatile");
+
+}
Property changes on: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileSequencerLexicon.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/DefaultClassFileRecorder.java
===================================================================
--- trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/DefaultClassFileRecorder.java (rev 0)
+++ trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/DefaultClassFileRecorder.java 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,235 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.classfile;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import org.jboss.dna.graph.JcrLexicon;
+import org.jboss.dna.graph.property.Path;
+import org.jboss.dna.graph.property.PathFactory;
+import org.jboss.dna.graph.property.Path.Segment;
+import org.jboss.dna.graph.sequencer.SequencerOutput;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
+import org.jboss.dna.sequencer.classfile.metadata.AnnotationMetadata;
+import org.jboss.dna.sequencer.classfile.metadata.ClassMetadata;
+import org.jboss.dna.sequencer.classfile.metadata.EnumMetadata;
+import org.jboss.dna.sequencer.classfile.metadata.FieldMetadata;
+import org.jboss.dna.sequencer.classfile.metadata.MethodMetadata;
+
+public class DefaultClassFileRecorder implements ClassFileRecorder {
+
+ @Override
+ public void recordClass( StreamSequencerContext context,
+ SequencerOutput output,
+ ClassMetadata classMetadata ) {
+
+ PathFactory pathFactory = pathFactoryFor(context);
+ Path classPath = pathFor(pathFactory, classMetadata);
+
+ writeClassNode(output, pathFactory, classPath, classMetadata);
+ }
+
+ private PathFactory pathFactoryFor( StreamSequencerContext context ) {
+ return context.getValueFactories().getPathFactory();
+ }
+
+ private Path pathFor( PathFactory pathFactory,
+ ClassMetadata cmd ) {
+ List<Segment> segments = new LinkedList<Segment>();
+
+ for (String segment : cmd.getClassName().split("\\.")) {
+ segments.add(pathFactory.createSegment(segment));
+ }
+
+ return pathFactory.createRelativePath(segments);
+ }
+
+ private void writeClassNode( SequencerOutput output,
+ PathFactory pathFactory,
+ Path classPath,
+ ClassMetadata cmd ) {
+
+ /*
+ - class:name (string) mandatory
+ - class:superClassName (string)
+ - class:visibility (string) mandatory < 'public', 'protected', 'package', 'private'
+ - class:abstract (boolean) mandatory
+ - class:interface (boolean) mandatory
+ - class:final (boolean) mandatory
+ - class:strictFp (boolean) mandatory
+ - class:interfaces (string) multiple
+ + class:annotations (class:annotations) = class:annotations
+ + class:constructors (class:constructors) = class:constructors
+ + class:methods (class:methods) = class:methods
+ + class:fields (class:fields) = class:fields
+ */
+
+ output.setProperty(classPath, ClassFileSequencerLexicon.NAME, cmd.getClassName());
+ output.setProperty(classPath, ClassFileSequencerLexicon.SUPER_CLASS_NAME, cmd.getSuperclassName());
+ output.setProperty(classPath, ClassFileSequencerLexicon.VISIBILITY, cmd.getVisibility().getDescription());
+ output.setProperty(classPath, ClassFileSequencerLexicon.ABSTRACT, cmd.isAbstract());
+ output.setProperty(classPath, ClassFileSequencerLexicon.INTERFACE, cmd.isInterface());
+ output.setProperty(classPath, ClassFileSequencerLexicon.FINAL, cmd.isFinal());
+ output.setProperty(classPath, ClassFileSequencerLexicon.STRICT_FP, cmd.isStrictFp());
+ output.setProperty(classPath, ClassFileSequencerLexicon.INTERFACES, (Object[])cmd.getInterfaces());
+
+ Path constructorsPath = pathFactory.create(classPath, ClassFileSequencerLexicon.CONSTRUCTORS);
+ output.setProperty(constructorsPath, JcrLexicon.PRIMARY_TYPE, ClassFileSequencerLexicon.CONSTRUCTORS);
+ writeMethods(output, pathFactory, constructorsPath, cmd.getConstructors());
+
+ Path methodsPath = pathFactory.create(classPath, ClassFileSequencerLexicon.METHODS);
+ output.setProperty(methodsPath, JcrLexicon.PRIMARY_TYPE, ClassFileSequencerLexicon.METHODS);
+ writeMethods(output, pathFactory, methodsPath, cmd.getMethods());
+
+ writeFieldsNode(output, pathFactory, classPath, cmd.getFields());
+ writeAnnotationsNode(output, pathFactory, classPath, cmd.getAnnotations());
+
+ if (cmd instanceof EnumMetadata) {
+ output.setProperty(classPath, JcrLexicon.PRIMARY_TYPE, ClassFileSequencerLexicon.ENUM);
+
+ output.setProperty(classPath, ClassFileSequencerLexicon.ENUM_VALUES, ((EnumMetadata)cmd).getValues().toArray());
+ }
+ else {
+ output.setProperty(classPath, JcrLexicon.PRIMARY_TYPE, ClassFileSequencerLexicon.CLASS);
+ }
+ }
+
+ private void writeFieldsNode( SequencerOutput output,
+ PathFactory pathFactory,
+ Path classPath,
+ List<FieldMetadata> fields ) {
+
+ /*
+ [class:field]
+ - class:name (string) mandatory
+ - class:typeClassName (string) mandatory
+ - class:visibility (string) mandatory < 'public', 'protected', 'package', 'private'
+ - class:static (boolean) mandatory
+ - class:final (boolean) mandatory
+ - class:transient (boolean) mandatory
+ - class:volatile (boolean) mandatory
+ + class:annotations (class:annotations) = class:annotations
+
+ [class:fields]
+ + * (class:field) = class:field
+ */
+
+ Path fieldsPath = pathFactory.create(classPath, ClassFileSequencerLexicon.FIELDS);
+ output.setProperty(fieldsPath, JcrLexicon.PRIMARY_TYPE, ClassFileSequencerLexicon.FIELDS);
+
+ for (FieldMetadata field : fields) {
+ Path fieldPath = pathFactory.create(fieldsPath, field.getName());
+
+ output.setProperty(fieldPath, JcrLexicon.PRIMARY_TYPE, ClassFileSequencerLexicon.FIELD);
+ output.setProperty(fieldPath, ClassFileSequencerLexicon.NAME, field.getName());
+ output.setProperty(fieldPath, ClassFileSequencerLexicon.TYPE_CLASS_NAME, field.getTypeName());
+ output.setProperty(fieldPath, ClassFileSequencerLexicon.VISIBILITY, field.getVisibility().getDescription());
+ output.setProperty(classPath, ClassFileSequencerLexicon.STATIC, field.isStatic());
+ output.setProperty(classPath, ClassFileSequencerLexicon.FINAL, field.isFinal());
+ output.setProperty(classPath, ClassFileSequencerLexicon.TRANSIENT, field.isTransient());
+ output.setProperty(classPath, ClassFileSequencerLexicon.VOLATILE, field.isVolatile());
+
+ writeAnnotationsNode(output, pathFactory, fieldPath, field.getAnnotations());
+
+ }
+ }
+
+ private void writeMethods( SequencerOutput output,
+ PathFactory pathFactory,
+ Path methodsPath,
+ List<MethodMetadata> methods ) {
+
+ /*
+ [class:method]
+ - class:name (string) mandatory
+ - class:returnTypeClassName (string) mandatory
+ - class:visibility (string) mandatory < 'public', 'protected', 'package', 'private'
+ - class:static (boolean) mandatory
+ - class:final (boolean) mandatory
+ - class:abstract (boolean) mandatory
+ - class:strictFp (boolean) mandatory
+ - class:native (boolean) mandatory
+ - class:synchronized (boolean) mandatory
+ - class:parameters (string) multiple
+ + class:annotations (class:annotations) = class:annotations
+ */
+
+ for (MethodMetadata method : methods) {
+ Path methodPath = pathFactory.create(methodsPath, method.getId());
+
+ output.setProperty(methodPath, JcrLexicon.PRIMARY_TYPE, ClassFileSequencerLexicon.METHOD);
+ output.setProperty(methodPath, ClassFileSequencerLexicon.NAME, method.getName());
+ output.setProperty(methodPath, ClassFileSequencerLexicon.RETURN_TYPE_CLASS_NAME, method.getReturnType());
+ output.setProperty(methodPath, ClassFileSequencerLexicon.VISIBILITY, method.getVisibility().getDescription());
+ output.setProperty(methodPath, ClassFileSequencerLexicon.STATIC, method.isStatic());
+ output.setProperty(methodPath, ClassFileSequencerLexicon.FINAL, method.isFinal());
+ output.setProperty(methodPath, ClassFileSequencerLexicon.ABSTRACT, method.isAbstract());
+ output.setProperty(methodPath, ClassFileSequencerLexicon.STRICT_FP, method.isStrictFp());
+ output.setProperty(methodPath, ClassFileSequencerLexicon.NATIVE, method.isNative());
+ output.setProperty(methodPath, ClassFileSequencerLexicon.SYNCHRONIZED, method.isSynchronized());
+ output.setProperty(methodPath, ClassFileSequencerLexicon.PARAMETERS, method.getParameters().toArray());
+
+ writeAnnotationsNode(output, pathFactory, methodPath, method.getAnnotations());
+
+ }
+
+ }
+
+ private void writeAnnotationsNode( SequencerOutput output,
+ PathFactory pathFactory,
+ Path parentPath,
+ List<AnnotationMetadata> annotations ) {
+
+ /*
+ [class:annotationMember]
+ - class:name (string) mandatory
+ - class:value (string)
+
+ [class:annotation]
+ - class:name (string) mandatory
+ + * (class:annotationMember) = class:annotationMember
+
+ [class:annotations]
+ + * (class:annotation) = class:annotation
+ */
+
+ Path annotationsPath = pathFactory.create(parentPath, ClassFileSequencerLexicon.ANNOTATIONS);
+ output.setProperty(annotationsPath, JcrLexicon.PRIMARY_TYPE, ClassFileSequencerLexicon.ANNOTATIONS);
+
+ for (AnnotationMetadata annotation : annotations) {
+ Path annotationPath = pathFactory.create(parentPath, annotation.getAnnotationClassName());
+ output.setProperty(annotationPath, JcrLexicon.PRIMARY_TYPE, ClassFileSequencerLexicon.ANNOTATION);
+
+ for (Map.Entry<String, String> entry : annotation.getMemberValues().entrySet()) {
+ Path annotationMemberPath = pathFactory.create(annotationPath, entry.getKey());
+ output.setProperty(annotationMemberPath, JcrLexicon.PRIMARY_TYPE, ClassFileSequencerLexicon.ANNOTATION_MEMBER);
+ output.setProperty(annotationMemberPath, ClassFileSequencerLexicon.NAME, entry.getKey());
+ output.setProperty(annotationMemberPath, ClassFileSequencerLexicon.VALUE, entry.getValue());
+
+ }
+
+ }
+ }
+}
Property changes on: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/DefaultClassFileRecorder.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/AnnotationMetadata.java
===================================================================
--- trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/AnnotationMetadata.java (rev 0)
+++ trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/AnnotationMetadata.java 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,92 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.classfile.metadata;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import javassist.bytecode.annotation.Annotation;
+import net.jcip.annotations.Immutable;
+
+@Immutable
+public class AnnotationMetadata {
+
+ private final String annotationClassName;
+ private final Map<String, String> memberValues;
+
+ @SuppressWarnings( "unchecked" )
+ AnnotationMetadata( Annotation annotation ) {
+ this.annotationClassName = annotation.getTypeName();
+
+ Set<Object> memberNames = annotation.getMemberNames();
+ if (memberNames != null) {
+ Map<String, String> members = new HashMap<String, String>(memberNames.size());
+
+ for (Object rawMemberName : memberNames) {
+ String memberName = (String)rawMemberName;
+
+ members.put(memberName, annotation.getMemberValue(memberName).toString());
+ }
+
+ this.memberValues = Collections.unmodifiableMap(members);
+ } else {
+ this.memberValues = Collections.emptyMap();
+ }
+ }
+
+ public String getAnnotationClassName() {
+ return annotationClassName;
+ }
+
+ public Map<String, String> getMemberValues() {
+ return memberValues;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder buff = new StringBuilder();
+
+ buff.append('@').append(annotationClassName);
+
+ if (!memberValues.isEmpty()) {
+ buff.append('(');
+
+ boolean first = true;
+ for (Map.Entry<String, String> entry : memberValues.entrySet()) {
+ if (first) {
+ first = false;
+ } else {
+ buff.append(", ");
+ }
+ buff.append(entry.getKey()).append('=').append(entry.getValue());
+ }
+
+ buff.append(')');
+ }
+
+ return buff.toString();
+ }
+
+}
Property changes on: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/AnnotationMetadata.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/ClassFileMetadataReader.java
===================================================================
--- trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/ClassFileMetadataReader.java (rev 0)
+++ trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/ClassFileMetadataReader.java 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,45 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.classfile.metadata;
+
+import java.io.DataInputStream;
+import java.io.InputStream;
+import javassist.bytecode.AccessFlag;
+import javassist.bytecode.ClassFile;
+
+/**
+ * Utility for extracting metadata from Java class files
+ */
+public class ClassFileMetadataReader {
+
+ public static ClassMetadata instance( InputStream stream ) throws Exception {
+ ClassFile clazz = new ClassFile(new DataInputStream(stream));
+
+ if ((AccessFlag.ENUM & clazz.getAccessFlags()) == AccessFlag.ENUM) {
+ return new EnumMetadata(clazz);
+ }
+
+ return new ClassMetadata(clazz);
+ }
+}
Property changes on: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/ClassFileMetadataReader.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/ClassMetadata.java
===================================================================
--- trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/ClassMetadata.java (rev 0)
+++ trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/ClassMetadata.java 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,229 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.classfile.metadata;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import javassist.bytecode.AccessFlag;
+import javassist.bytecode.AnnotationsAttribute;
+import javassist.bytecode.AttributeInfo;
+import javassist.bytecode.ClassFile;
+import javassist.bytecode.FieldInfo;
+import javassist.bytecode.MethodInfo;
+import javassist.bytecode.annotation.Annotation;
+import net.jcip.annotations.Immutable;
+
+@Immutable
+public class ClassMetadata {
+
+ private final ClassFile clazz;
+
+ private final List<AnnotationMetadata> annotations;
+ private final List<FieldMetadata> fields;
+ private final List<MethodMetadata> methods;
+ private final List<MethodMetadata> constructors;
+
+ ClassMetadata( ClassFile clazz ) {
+ this.clazz = clazz;
+ this.annotations = annotationsFor(clazz);
+ this.fields = fieldsFor(clazz);
+ this.methods = methodsFor(clazz);
+ this.constructors = constructorsFor(clazz);
+ }
+
+ private List<AnnotationMetadata> annotationsFor( ClassFile clazz ) {
+ List<AnnotationMetadata> annotations = new LinkedList<AnnotationMetadata>();
+
+ for (Object ob : clazz.getAttributes()) {
+ AttributeInfo att = (AttributeInfo)ob;
+
+ if (att instanceof AnnotationsAttribute) {
+ for (Annotation ann : ((AnnotationsAttribute)att).getAnnotations()) {
+ annotations.add(new AnnotationMetadata(ann));
+ }
+ }
+ }
+
+ return Collections.unmodifiableList(annotations);
+ }
+
+ private List<FieldMetadata> fieldsFor( ClassFile clazz ) {
+ List<FieldMetadata> fields = new LinkedList<FieldMetadata>();
+
+ for (Object field : clazz.getFields()) {
+ fields.add(new FieldMetadata((FieldInfo)field));
+ }
+
+ Collections.sort(fields);
+
+ return Collections.unmodifiableList(fields);
+ }
+
+ private List<MethodMetadata> methodsFor( ClassFile clazz ) {
+ List<MethodMetadata> methods = new LinkedList<MethodMetadata>();
+
+ for (Object ob : clazz.getMethods()) {
+ MethodInfo method = (MethodInfo)ob;
+
+ if (!method.isStaticInitializer() && !method.isConstructor()) {
+ methods.add(new MethodMetadata(clazz, method));
+ }
+ }
+
+ Collections.sort(methods);
+
+ return Collections.unmodifiableList(methods);
+ }
+
+ private List<MethodMetadata> constructorsFor( ClassFile clazz ) {
+ List<MethodMetadata> ctors = new LinkedList<MethodMetadata>();
+
+ for (Object ob : clazz.getMethods()) {
+ MethodInfo method = (MethodInfo)ob;
+ if (!method.isStaticInitializer() && method.isConstructor()) {
+ ctors.add(new MethodMetadata(clazz, method));
+ }
+ }
+
+ Collections.sort(ctors);
+
+ return Collections.unmodifiableList(ctors);
+ }
+
+ public boolean isEnumeration() {
+ return false;
+ }
+
+ public String getClassName() {
+ return clazz.getName();
+ }
+
+ public String getSuperclassName() {
+ return clazz.getSuperclass();
+ }
+
+ public String[] getInterfaces() {
+ return clazz.getInterfaces();
+ }
+
+ public boolean isAbstract() {
+ return clazz.isAbstract();
+ }
+
+ public boolean isInterface() {
+ return clazz.isInterface();
+ }
+
+ public boolean isStrictFp() {
+ return AccessFlag.STRICT == (AccessFlag.STRICT & clazz.getAccessFlags());
+ }
+
+ public boolean isFinal() {
+ return AccessFlag.FINAL == (AccessFlag.FINAL & clazz.getAccessFlags());
+ }
+
+ public Visibility getVisibility() {
+ return Visibility.fromAccessFlags(clazz.getAccessFlags());
+ }
+
+ public List<AnnotationMetadata> getAnnotations() {
+ return annotations;
+ }
+
+ public List<FieldMetadata> getFields() {
+ return fields;
+ }
+
+ public List<MethodMetadata> getMethods() {
+ return methods;
+ }
+
+ public List<MethodMetadata> getConstructors() {
+ return constructors;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder buff = new StringBuilder();
+
+ for (AnnotationMetadata annotation : annotations) {
+ buff.append(annotation).append('\n');
+ }
+
+ buff.append(getVisibility());
+ if (getVisibility() != Visibility.PACKAGE) {
+ buff.append(' ');
+ }
+
+ if (isAbstract()) {
+ if (isInterface()) {
+ buff.append("interface ");
+ } else {
+ buff.append("abstract class ");
+
+ }
+ } else {
+ buff.append("class ");
+ }
+
+ if (getSuperclassName() != null && !Object.class.getName().equals(getSuperclassName())) {
+ buff.append(" extends ").append(getSuperclassName()).append(" ");
+ }
+
+ if (getInterfaces().length > 0) {
+ boolean first = true;
+ buff.append(" implements ");
+
+ for (String interfaceName : getInterfaces()) {
+ if (first) {
+ first = false;
+ } else {
+ buff.append(", ");
+ }
+ buff.append(interfaceName);
+ }
+
+ buff.append(' ');
+ }
+
+ buff.append(getClassName()).append(" {\n");
+
+ for (FieldMetadata field : fields) {
+ buff.append('\t').append(field).append('\n');
+ }
+
+ if (!methods.isEmpty()) {
+ buff.append('\n');
+ }
+
+ for (MethodMetadata method : methods) {
+ buff.append('\t').append(method).append('\n');
+ }
+
+ buff.append("}");
+
+ return buff.toString();
+ }
+}
Property changes on: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/ClassMetadata.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/EnumMetadata.java
===================================================================
--- trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/EnumMetadata.java (rev 0)
+++ trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/EnumMetadata.java 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,75 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.classfile.metadata;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import javassist.bytecode.AccessFlag;
+import javassist.bytecode.ClassFile;
+
+public class EnumMetadata extends ClassMetadata {
+
+ private final List<FieldMetadata> enumFields;
+ private final List<String> values;
+
+ public EnumMetadata( ClassFile clazz ) {
+ super(clazz);
+
+ assert (clazz.getAccessFlags() & AccessFlag.ENUM) == AccessFlag.ENUM;
+ List<FieldMetadata> fieldsFromClass = super.getFields();
+
+ /*
+ * Each enum value is stored as a static field in the class file. Filter those out and treat them separately.
+ */
+ List<FieldMetadata> enumFields = new ArrayList<FieldMetadata>(fieldsFromClass.size());
+ List<String> values = new ArrayList<String>(fieldsFromClass.size());
+ for (FieldMetadata fieldFromClass : fieldsFromClass) {
+ if (fieldFromClass.getTypeName().equals(getClassName())) {
+ values.add(fieldFromClass.getName());
+ } else {
+ enumFields.add(fieldFromClass);
+ }
+ }
+
+ this.enumFields = Collections.unmodifiableList(enumFields);
+ this.values = Collections.unmodifiableList(values);
+
+ }
+
+ public List<String> getValues() {
+ return values;
+ }
+
+ @Override
+ public List<FieldMetadata> getFields() {
+ return enumFields;
+ }
+
+ @Override
+ public boolean isEnumeration() {
+ return true;
+ }
+
+}
Property changes on: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/EnumMetadata.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/FieldMetadata.java
===================================================================
--- trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/FieldMetadata.java (rev 0)
+++ trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/FieldMetadata.java 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,128 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.classfile.metadata;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import javassist.bytecode.AccessFlag;
+import javassist.bytecode.AnnotationsAttribute;
+import javassist.bytecode.AttributeInfo;
+import javassist.bytecode.Descriptor;
+import javassist.bytecode.FieldInfo;
+import javassist.bytecode.annotation.Annotation;
+
+public class FieldMetadata implements Comparable<FieldMetadata> {
+
+ private final FieldInfo field;
+ private final List<AnnotationMetadata> annotations;
+
+ FieldMetadata( FieldInfo field ) {
+ this.field = field;
+ this.annotations = annotationsFor(field);
+ }
+
+ private List<AnnotationMetadata> annotationsFor( FieldInfo field ) {
+ List<AnnotationMetadata> annotations = new LinkedList<AnnotationMetadata>();
+
+ for (Object ob : field.getAttributes()) {
+ AttributeInfo att = (AttributeInfo)ob;
+
+ if (att instanceof AnnotationsAttribute) {
+ for (Annotation ann : ((AnnotationsAttribute)att).getAnnotations()) {
+ annotations.add(new AnnotationMetadata(ann));
+ }
+ }
+ }
+
+ return Collections.unmodifiableList(annotations);
+ }
+
+ public String getName() {
+ return field.getName();
+ }
+
+ public boolean isStatic() {
+ return AccessFlag.STATIC == (AccessFlag.STATIC & field.getAccessFlags());
+ }
+
+ public boolean isFinal() {
+ return AccessFlag.FINAL == (AccessFlag.FINAL & field.getAccessFlags());
+ }
+
+ public boolean isTransient() {
+ return AccessFlag.TRANSIENT == (AccessFlag.TRANSIENT & field.getAccessFlags());
+ }
+
+ public boolean isVolatile() {
+ return AccessFlag.VOLATILE == (AccessFlag.VOLATILE & field.getAccessFlags());
+ }
+
+ public Visibility getVisibility() {
+ return Visibility.fromAccessFlags(field.getAccessFlags());
+ }
+
+ public String getTypeName() {
+ return Descriptor.toClassName(field.getDescriptor());
+ }
+
+ public List<AnnotationMetadata> getAnnotations() {
+ return annotations;
+ }
+
+ @Override
+ public int compareTo( FieldMetadata o ) {
+ if (this.isStatic() && !o.isStatic()) {
+ return 1;
+ }
+ if (!this.isStatic() && o.isStatic()) {
+ return -1;
+ }
+
+ return this.getName().compareTo(o.getName());
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder buff = new StringBuilder();
+
+ if (!annotations.isEmpty()) {
+ for (AnnotationMetadata annotation : annotations) {
+ buff.append(annotation).append("\n\t");
+ }
+ }
+
+ buff.append(getVisibility());
+ if (getVisibility() != Visibility.PACKAGE) buff.append(' ');
+
+ if (isFinal()) buff.append("final ");
+ if (isStatic()) buff.append("static ");
+ if (isTransient()) buff.append("transient ");
+
+ buff.append(Descriptor.toClassName(getTypeName())).append(' ');
+ buff.append(getName()).append(';');
+
+ return buff.toString();
+ }
+}
Property changes on: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/FieldMetadata.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/MethodMetadata.java
===================================================================
--- trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/MethodMetadata.java (rev 0)
+++ trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/MethodMetadata.java 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,240 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.classfile.metadata;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import javassist.bytecode.AccessFlag;
+import javassist.bytecode.AnnotationsAttribute;
+import javassist.bytecode.AttributeInfo;
+import javassist.bytecode.ClassFile;
+import javassist.bytecode.Descriptor;
+import javassist.bytecode.MethodInfo;
+import javassist.bytecode.annotation.Annotation;
+
+public class MethodMetadata implements Comparable<MethodMetadata> {
+
+ private final MethodInfo method;
+ private final String name;
+ private final List<AnnotationMetadata> annotations;
+ private final List<String> parameters;
+
+ MethodMetadata( ClassFile clazz,
+ MethodInfo method ) {
+ this.method = method;
+ this.name = method.isConstructor() ? clazz.getName() : method.getName();
+ this.annotations = annotationsFor(method);
+ this.parameters = parametersFor(method);
+ }
+
+ private List<String> parametersFor( MethodInfo method ) {
+ String descriptor = method.getDescriptor();
+ int lastParenPos = descriptor.lastIndexOf(')');
+ assert lastParenPos >= 0;
+ String parameterString = descriptor.substring(1, lastParenPos);
+
+ if (parameterString.length() == 0) {
+ return Collections.emptyList();
+ }
+
+ List<String> parameters = new ArrayList<String>();
+ Descriptor.Iterator iter = new Descriptor.Iterator(parameterString);
+
+ assert iter.hasNext();
+ int startPos = iter.next();
+
+ while (iter.hasNext()) {
+ int endPos = iter.next();
+ parameters.add(Descriptor.toClassName(parameterString.substring(startPos, endPos)));
+ startPos = endPos;
+ }
+ parameters.add(Descriptor.toClassName(parameterString.substring(startPos)));
+
+ return parameters;
+ }
+
+ private String returnTypeFor( MethodInfo method ) {
+ String descriptor = method.getDescriptor();
+ int lastParenPos = descriptor.lastIndexOf(')');
+ assert lastParenPos >= 0;
+ return Descriptor.toClassName(descriptor.substring(lastParenPos + 1));
+ }
+
+ private List<AnnotationMetadata> annotationsFor( MethodInfo method ) {
+ List<AnnotationMetadata> annotations = new LinkedList<AnnotationMetadata>();
+
+ for (Object ob : method.getAttributes()) {
+ AttributeInfo att = (AttributeInfo)ob;
+
+ if (att instanceof AnnotationsAttribute) {
+ for (Annotation ann : ((AnnotationsAttribute)att).getAnnotations()) {
+ annotations.add(new AnnotationMetadata(ann));
+ }
+ }
+ }
+
+ return annotations;
+ }
+
+ private String shortNameFor( String type ) {
+ int lastDotPos = type.lastIndexOf('.');
+ if (lastDotPos < 0) return type;
+ return type.substring(lastDotPos + 1);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Visibility getVisibility() {
+ return Visibility.fromAccessFlags(method.getAccessFlags());
+ }
+
+ public boolean isConstructor() {
+ return method.isConstructor();
+ }
+
+ public String getReturnType() {
+ return returnTypeFor(method);
+ }
+
+ public List<AnnotationMetadata> getAnnotations() {
+ return annotations;
+ }
+
+ public List<String> getParameters() {
+ return parameters;
+ }
+
+ public boolean isStatic() {
+ return AccessFlag.STATIC == (AccessFlag.STATIC & method.getAccessFlags());
+ }
+
+ public boolean isFinal() {
+ return AccessFlag.FINAL == (AccessFlag.FINAL & method.getAccessFlags());
+ }
+
+ public boolean isAbstract() {
+ return AccessFlag.ABSTRACT == (AccessFlag.ABSTRACT & method.getAccessFlags());
+ }
+
+ public boolean isNative() {
+ return AccessFlag.NATIVE == (AccessFlag.NATIVE & method.getAccessFlags());
+ }
+
+ public boolean isStrictFp() {
+ return AccessFlag.STRICT == (AccessFlag.STRICT & method.getAccessFlags());
+ }
+
+ public boolean isSynchronized() {
+ return AccessFlag.SYNCHRONIZED == (AccessFlag.SYNCHRONIZED & method.getAccessFlags());
+ }
+
+ public int compareTo( MethodMetadata o ) {
+ if (this.isStatic() && !o.isStatic()) {
+ return -1;
+ }
+ if (!this.isStatic() && o.isStatic()) {
+ return 1;
+ }
+
+ if (!this.name.equals(o.name)) {
+ return this.name.compareTo(o.name);
+ }
+
+ if (this.parameters.size() != o.parameters.size()) {
+ return ((Integer)this.parameters.size()).compareTo(o.parameters.size());
+ }
+
+ for (int i = 0; i < parameters.size(); i++) {
+ String p1 = this.parameters.get(i);
+ String p2 = o.parameters.get(i);
+
+ if (!p1.equals(p2)) {
+ return p1.compareTo(p2);
+ }
+ }
+
+ return 0;
+ }
+
+ public String getId() {
+ StringBuilder buff = new StringBuilder();
+ buff.append(method.getName()).append('(');
+
+ boolean first = false;
+ for (String parameter : parameters) {
+ if (first) {
+ first = false;
+ } else {
+ buff.append(", ");
+ }
+ buff.append(shortNameFor(parameter).replace("[]", " array"));
+ }
+
+ buff.append(')');
+
+ return buff.toString();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder buff = new StringBuilder();
+
+ if (!annotations.isEmpty()) {
+ for (AnnotationMetadata annotation : annotations) {
+ buff.append(annotation).append("\n\t");
+ }
+ }
+
+ buff.append(getVisibility());
+ if (getVisibility() != Visibility.PACKAGE) buff.append(' ');
+
+ if (isFinal()) buff.append("final ");
+ if (isStatic()) buff.append("static ");
+
+ buff.append(shortNameFor(getReturnType())).append(' ');
+ buff.append(name).append('(');
+
+ boolean first = true;
+
+ for (String parameter : parameters) {
+ if (first) {
+ first = false;
+ } else {
+ buff.append(", ");
+ }
+ buff.append(shortNameFor(parameter));
+ }
+
+ buff.append(' ');
+
+ buff.append(");");
+
+ return buff.toString();
+ }
+
+}
Property changes on: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/MethodMetadata.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/Visibility.java
===================================================================
--- trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/Visibility.java (rev 0)
+++ trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/Visibility.java 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,65 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.classfile.metadata;
+
+import javassist.bytecode.AccessFlag;
+
+public enum Visibility {
+
+ PUBLIC("public"),
+ PROTECTED("protected"),
+ PACKAGE(""),
+ PRIVATE("private");
+
+ private static final int VISBILITY_MASK = AccessFlag.PUBLIC | AccessFlag.PRIVATE | AccessFlag.PROTECTED;
+
+ private final String description;
+
+ private Visibility( String description ) {
+ this.description = description;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ @Override
+ public String toString() {
+ return description;
+ }
+
+ public static Visibility fromAccessFlags( int accessFlags ) {
+ switch (accessFlags & VISBILITY_MASK) {
+ case AccessFlag.PUBLIC:
+ return Visibility.PUBLIC;
+ case AccessFlag.PROTECTED:
+ return Visibility.PROTECTED;
+ case AccessFlag.PRIVATE:
+ return Visibility.PRIVATE;
+ default:
+ return Visibility.PACKAGE;
+ }
+
+ }
+}
Property changes on: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/Visibility.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/package-info.java
===================================================================
--- trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/package-info.java (rev 0)
+++ trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/package-info.java 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,29 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+/**
+ * The classes that provide the ability to sequence Java class files into metadata and then write that metadata to a graph in a customizable way.
+ */
+
+package org.jboss.dna.sequencer.classfile;
+
Property changes on: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/package-info.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-sequencer-classfile/src/main/resources/org/jboss/dna/sequencer/classfile/ClassFileSequencerI18n.properties
===================================================================
--- trunk/extensions/dna-sequencer-classfile/src/main/resources/org/jboss/dna/sequencer/classfile/ClassFileSequencerI18n.properties (rev 0)
+++ trunk/extensions/dna-sequencer-classfile/src/main/resources/org/jboss/dna/sequencer/classfile/ClassFileSequencerI18n.properties 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,25 @@
+#
+# JBoss DNA (http://www.jboss.org/dna)
+# See the COPYRIGHT.txt file distributed with this work for information
+# regarding copyright ownership. Some portions may be licensed
+# to Red Hat, Inc. under one or more contributor license agreements.
+# See the AUTHORS.txt file in the distribution for a full listing of
+# individual contributors.
+#
+# JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+# is licensed to you under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# JBoss DNA is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this software; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+#
+
+errorSequencingClass = Error sequencing class at path "{0}"
Added: trunk/extensions/dna-sequencer-classfile/src/main/resources/org/jboss/dna/sequencer/classfile/sequencer-classfile.cnd
===================================================================
--- trunk/extensions/dna-sequencer-classfile/src/main/resources/org/jboss/dna/sequencer/classfile/sequencer-classfile.cnd (rev 0)
+++ trunk/extensions/dna-sequencer-classfile/src/main/resources/org/jboss/dna/sequencer/classfile/sequencer-classfile.cnd 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,91 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+<class='http://www.jboss.org/dna/sequencer/javaclass/1.0'>
+
+[class:annotationMember]
+- class:name (string) mandatory
+- class:value (string)
+
+[class:annotation]
+- class:name (string) mandatory
++ * (class:annotationMember) = class:annotationMember
+
+[class:annotations]
++ * (class:annotation) = class:annotation
+
+[class:field]
+- class:name (string) mandatory
+- class:typeClassName (string) mandatory
+- class:visibility (string) mandatory < 'public', 'protected', 'package', 'private'
+- class:static (boolean) mandatory
+- class:final (boolean) mandatory
+- class:transient (boolean) mandatory
+- class:volatile (boolean) mandatory
++ class:annotations (class:annotations) = class:annotations
+
+[class:fields]
++ * (class:field) = class:field
+
+[class:interfaces]
+- * (string)
+
+[class:parameters]
+- * (string)
+
+[class:method]
+- class:name (string) mandatory
+- class:returnTypeClassName (string) mandatory
+- class:visibility (string) mandatory < 'public', 'protected', 'package', 'private'
+- class:static (boolean) mandatory
+- class:final (boolean) mandatory
+- class:abstract (boolean) mandatory
+- class:strictFp (boolean) mandatory
+- class:native (boolean) mandatory
+- class:synchronized (boolean) mandatory
+- class:parameters (string) multiple
++ class:annotations (class:annotations) = class:annotations
+
+[class:methods]
++ * (class:method) = class:method
+
+[class:constructors]
++ * (class:method) = class:method
+
+[class:class]
+- class:name (string) mandatory
+- class:superClassName (string)
+- class:visibility (string) mandatory < 'public', 'protected', 'package', 'private'
+- class:abstract (boolean) mandatory
+- class:interface (boolean) mandatory
+- class:final (boolean) mandatory
+- class:strictFp (boolean) mandatory
+- class:interfaces (string) multiple
++ class:annotations (class:annotations) = class:annotations
++ class:constructors (class:constructors) = class:constructors
++ class:methods (class:methods) = class:methods
++ class:fields (class:fields) = class:fields
+
+[class:enum] > class:class
+- class:enumValues (string) mandatory multiple
Added: trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/classfile/ClassFileSequencerI18nTest.java
===================================================================
--- trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/classfile/ClassFileSequencerI18nTest.java (rev 0)
+++ trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/classfile/ClassFileSequencerI18nTest.java 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,36 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.classfile;
+
+import org.jboss.dna.common.AbstractI18nTest;
+
+/**
+ * @author Randall Hauch
+ */
+public class ClassFileSequencerI18nTest extends AbstractI18nTest {
+
+ public ClassFileSequencerI18nTest() {
+ super(ClassFileSequencerI18n.class);
+ }
+}
Property changes on: trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/classfile/ClassFileSequencerI18nTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/classfile/ClassFileSequencerTest.java
===================================================================
--- trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/classfile/ClassFileSequencerTest.java (rev 0)
+++ trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/classfile/ClassFileSequencerTest.java 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,129 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.classfile;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+import java.io.InputStream;
+import org.jboss.dna.graph.sequencer.MockSequencerContext;
+import org.jboss.dna.graph.sequencer.MockSequencerOutput;
+import org.jboss.dna.graph.sequencer.SequencerOutput;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
+import org.jboss.dna.sequencer.classfile.metadata.ClassMetadata;
+import org.jboss.dna.sequencer.classfile.metadata.EnumMetadata;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ClassFileSequencerTest {
+ private ClassFileSequencer sequencer;
+ private InputStream input;
+ private MockSequencerOutput output;
+ private StreamSequencerContext context;
+
+ @Before
+ public void beforeEach() throws Exception {
+ sequencer = new ClassFileSequencer();
+ context = new MockSequencerContext();
+ context.getNamespaceRegistry().register("class", "http://www.jboss.org/dna/sequencer/classfile/1.0");
+ context.getNamespaceRegistry().register("nt", "http://www.jcp.org/jcr/nt/1.0");
+ output = new MockSequencerOutput(context);
+ input = this.getClass().getResourceAsStream("/NodeEntity.clazz");
+ }
+
+ @After
+ public void afterEach() throws Exception {
+ if (input != null) {
+ try {
+ input.close();
+ } finally {
+ input = null;
+ }
+ }
+ }
+
+ @Test
+ public void shouldAllowSettingClassFileRecorder() throws Exception {
+ MockClassFileRecorder recorder = new MockClassFileRecorder();
+ MockClassFileRecorder.called = false;
+
+ sequencer.setClassFileRecorder(recorder);
+ sequencer.sequence(input, output, context);
+
+ assertThat(MockClassFileRecorder.called, is(true));
+ }
+
+ @Test
+ public void shouldAllowSettingClassFileRecorderByName() throws Exception {
+ MockClassFileRecorder.called = false;
+
+ sequencer.setClassFileRecorderClassName(MockClassFileRecorder.class.getName());
+ sequencer.sequence(input, output, context);
+
+ assertThat(MockClassFileRecorder.called, is(true));
+ }
+
+ @Test
+ public void shouldAllowSettingClassFileRecorderToDefaultByName() throws Exception {
+ MockClassFileRecorder.called = false;
+
+ sequencer.setClassFileRecorderClassName(MockClassFileRecorder.class.getName());
+ sequencer.setClassFileRecorderClassName(null);
+ sequencer.sequence(input, output, context);
+
+ assertThat(MockClassFileRecorder.called, is(false));
+ }
+
+ @Test
+ public void shouldAllowSettingClassFileRecorderToDefault() throws Exception {
+ MockClassFileRecorder.called = false;
+
+ sequencer.setClassFileRecorder(new MockClassFileRecorder());
+ sequencer.setClassFileRecorder(null);
+ sequencer.sequence(input, output, context);
+
+ assertThat(MockClassFileRecorder.called, is(false));
+ }
+
+ @Test( expected = ClassCastException.class )
+ public void shouldNotAllowSettingClassFileRecorderToInvalidClass() throws Exception {
+ sequencer.setClassFileRecorderClassName(Object.class.getName());
+ }
+
+
+ public static class MockClassFileRecorder implements ClassFileRecorder {
+ static boolean called = false;
+
+ public void recordClass( StreamSequencerContext context,
+ SequencerOutput output,
+ ClassMetadata classMetadata ) {
+ called = true;
+ }
+
+ public void recordEnum( StreamSequencerContext context,
+ SequencerOutput output,
+ EnumMetadata enumMetadata ) {
+ }
+ }
+}
Property changes on: trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/classfile/ClassFileSequencerTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/classfile/MockEnum.java
===================================================================
--- trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/classfile/MockEnum.java (rev 0)
+++ trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/classfile/MockEnum.java 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,31 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.classfile;
+
+public enum MockEnum {
+
+ VALUE_A,
+ VALUE_B,
+ VALUE_C;
+}
Property changes on: trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/classfile/MockEnum.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/classfile/metadata/ClassFileMetadataReaderTest.java
===================================================================
--- trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/classfile/metadata/ClassFileMetadataReaderTest.java (rev 0)
+++ trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/classfile/metadata/ClassFileMetadataReaderTest.java 2010-01-01 17:46:39 UTC (rev 1512)
@@ -0,0 +1,355 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.classfile.metadata;
+
+import static org.hamcrest.core.AnyOf.anyOf;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
+import static org.hamcrest.core.IsNot.not;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.hamcrest.core.IsNull.nullValue;
+import static org.junit.Assert.assertThat;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.jboss.dna.common.util.HashCode;
+import org.jboss.dna.graph.Graph;
+import org.jboss.dna.sequencer.classfile.ClassFileSequencer;
+import org.jboss.dna.sequencer.classfile.MockEnum;
+import org.junit.After;
+import org.junit.Test;
+
+public class ClassFileMetadataReaderTest {
+
+ private InputStream input;
+
+ @After
+ public void afterEach() throws Exception {
+ if (input != null) {
+ try {
+ input.close();
+ } finally {
+ input = null;
+ }
+ }
+ }
+
+ @Test
+ public void shouldReadJavaLangObject() throws Exception {
+ compareMetadataToClass(Object.class);
+ }
+
+ @Test
+ public void shouldReadJavaLangString() throws Exception {
+ compareMetadataToClass(String.class);
+ }
+
+ @Test
+ public void shouldReadOrgJbossDnaGraph() throws Exception {
+ compareMetadataToClass(Graph.class);
+ }
+
+ @Test
+ public void shouldReadOrgJbossDnaSequencerClassfileClassFileSequencer() throws Exception {
+ compareMetadataToClass(ClassFileSequencer.class);
+ }
+
+ @SuppressWarnings( "unchecked" )
+ @Test
+ public void shouldReadEnum() throws Exception {
+ String resourceName = "/" + MockEnum.class.getName().replace('.', '/') + ".class";
+ input = getClass().getResourceAsStream(resourceName);
+
+ ClassMetadata cmd = ClassFileMetadataReader.instance(input);
+
+ assertThat(cmd, instanceOf(EnumMetadata.class));
+ EnumMetadata emd = (EnumMetadata) cmd;
+
+ List<String> enumValues = Arrays.asList(new String[] {"VALUE_A", "VALUE_B", "VALUE_C"});
+ assertThat(emd.getValues(), is(enumValues));
+
+ for (FieldMetadata fmd : emd.getFields()) {
+ assertThat(fmd.getName(), not(anyOf(is("VALUE_A"), is("VALUE_B"), is("VALUE_C"))));
+ }
+
+ }
+
+ @SuppressWarnings( "unchecked" )
+ private void compareMetadataToClass( Class<?> clazz ) throws Exception {
+ String resourceName = "/" + clazz.getName().replace('.', '/') + ".class";
+ input = getClass().getResourceAsStream(resourceName);
+
+ ClassMetadata cmd = ClassFileMetadataReader.instance(input);
+
+ assertThat(cmd.getClassName(), is(clazz.getName()));
+
+ if (clazz.getSuperclass() == null) {
+ assertThat(cmd.getSuperclassName(), is(nullValue()));
+ } else {
+ assertThat(cmd.getSuperclassName(), is(clazz.getSuperclass().getName()));
+ }
+
+ String[] clazzInterfaces = new String[clazz.getInterfaces().length];
+ for (int i = 0; i < clazz.getInterfaces().length; i++) {
+ clazzInterfaces[i] = clazz.getInterfaces()[i].getName();
+ }
+
+ assertThat(cmd.getInterfaces(), is(clazzInterfaces));
+ assertThat(cmd.isEnumeration(), is(clazz.isEnum()));
+ assertThat(cmd.getVisibility(), is(visibilityFor(clazz.getModifiers())));
+ assertThat(cmd.isInterface(), is(Modifier.isInterface(clazz.getModifiers())));
+ assertThat(cmd.isAbstract(), is(Modifier.isAbstract(clazz.getModifiers())));
+
+ assertThat(cmd.getAnnotations().size(), is(clazz.getDeclaredAnnotations().length));
+ for (AnnotationMetadata amd : cmd.getAnnotations()) {
+ Class<Annotation> annotationClass = (Class<Annotation>)Class.forName(amd.getAnnotationClassName());
+ Annotation annotation = clazz.getAnnotation(annotationClass);
+ assertThat(annotation, is(notNullValue()));
+ }
+
+ checkFields(cmd, clazz);
+ checkMethods(cmd, clazz);
+ checkConstructors(cmd, clazz);
+ }
+
+ @SuppressWarnings( "unchecked" )
+ private void checkFields( ClassMetadata cmd,
+ Class<?> clazz ) throws Exception {
+ Map<FieldKey, Field> clazzFields = new HashMap<FieldKey, Field>();
+ Map<FieldKey, FieldMetadata> metaFields = new HashMap<FieldKey, FieldMetadata>();
+
+ for (Field field : clazz.getDeclaredFields()) {
+ clazzFields.put(new FieldKey(field), field);
+ }
+
+ for (FieldMetadata field : cmd.getFields()) {
+ metaFields.put(new FieldKey(field), field);
+ }
+
+ assertThat(metaFields.size(), is(clazzFields.size()));
+ assertThat(metaFields.keySet(), is(clazzFields.keySet()));
+
+ for (Map.Entry<FieldKey, FieldMetadata> entry : metaFields.entrySet()) {
+ Field clazzField = clazzFields.get(entry.getKey());
+ FieldMetadata metaField = entry.getValue();
+ assert clazzField != null;
+
+ // getCanonicalName converts the $ to .
+ String metaName = metaField.getTypeName().replace('$', '.');
+ String clazzName = clazzField.getType().getCanonicalName();
+ assertThat(metaName, is(clazzName));
+
+ assertThat(metaField.getVisibility(), is(visibilityFor(clazzField.getModifiers())));
+ assertThat(metaField.isFinal(), is(Modifier.isFinal(clazzField.getModifiers())));
+ assertThat(metaField.isStatic(), is(Modifier.isStatic(clazzField.getModifiers())));
+
+ assertThat(metaField.getAnnotations().size(), is(clazzField.getDeclaredAnnotations().length));
+ for (AnnotationMetadata amd : metaField.getAnnotations()) {
+ Class<Annotation> annotationClass = (Class<Annotation>)Class.forName(amd.getAnnotationClassName());
+ Annotation annotation = clazz.getAnnotation(annotationClass);
+ assertThat(annotation, is(notNullValue()));
+ }
+ }
+ }
+
+ private void checkMethods( ClassMetadata cmd,
+ Class<?> clazz ) throws Exception {
+ Map<MethodKey, Method> clazzMethods = new HashMap<MethodKey, Method>();
+ Map<MethodKey, MethodMetadata> metaMethods = new HashMap<MethodKey, MethodMetadata>();
+
+ for (Method field : clazz.getDeclaredMethods()) {
+ clazzMethods.put(new MethodKey(field), field);
+ }
+
+ for (MethodMetadata field : cmd.getMethods()) {
+ metaMethods.put(new MethodKey(field), field);
+ }
+
+ assertThat(metaMethods.size(), is(clazzMethods.size()));
+ assertThat(metaMethods.keySet(), is(clazzMethods.keySet()));
+
+ for (Map.Entry<MethodKey, MethodMetadata> entry : metaMethods.entrySet()) {
+
+ /*
+ * We already know that the parameter types and name are equal, otherwise this would fail
+ */
+
+ Method clazzMethod = clazzMethods.get(entry.getKey());
+ MethodMetadata metaMethod = entry.getValue();
+ assert clazzMethod != null;
+
+ // getCanonicalName converts the $ to .
+ String metaName = metaMethod.getReturnType().replace('$', '.');
+ String clazzName = clazzMethod.getReturnType().getCanonicalName();
+ assertThat(metaName, is(clazzName));
+
+ assertThat(metaMethod.getVisibility(), is(visibilityFor(clazzMethod.getModifiers())));
+ assertThat(metaMethod.isFinal(), is(Modifier.isFinal(clazzMethod.getModifiers())));
+ assertThat(metaMethod.isStatic(), is(Modifier.isStatic(clazzMethod.getModifiers())));
+
+ assertThat(metaMethod.getAnnotations().size(), is(clazzMethod.getDeclaredAnnotations().length));
+
+
+ // Can't really check this since some annotations are not runtime annotations
+ // for (AnnotationMetadata amd : metaMethod.getAnnotations()) {
+ // Class<Annotation> annotationClass = (Class<Annotation>)Class.forName(amd.getAnnotationClassName());
+ // Annotation annotation = clazz.getAnnotation(annotationClass);
+ //
+ // assertThat(annotation, is(notNullValue()));
+ // }
+ }
+ }
+
+ @SuppressWarnings( "unchecked" )
+ private void checkConstructors( ClassMetadata cmd,
+ Class<?> clazz ) throws Exception {
+ Map<MethodKey, Constructor> clazzCtors = new HashMap<MethodKey, Constructor>();
+ Map<MethodKey, MethodMetadata> metaCtors = new HashMap<MethodKey, MethodMetadata>();
+
+ for (Constructor field : clazz.getDeclaredConstructors()) {
+ clazzCtors.put(new MethodKey(field), field);
+ }
+
+ for (MethodMetadata field : cmd.getConstructors()) {
+ metaCtors.put(new MethodKey(field), field);
+ }
+
+ assertThat(metaCtors.size(), is(clazzCtors.size()));
+ assertThat(metaCtors.keySet(), is(clazzCtors.keySet()));
+
+ for (Map.Entry<MethodKey, MethodMetadata> entry : metaCtors.entrySet()) {
+
+ /*
+ * We already know that the parameter types and name are equal, otherwise this would fail
+ */
+
+ Constructor clazzCtor = clazzCtors.get(entry.getKey());
+ MethodMetadata metaCtor = entry.getValue();
+ assert clazzCtor != null;
+
+ assertThat(metaCtor.getVisibility(), is(visibilityFor(clazzCtor.getModifiers())));
+ assertThat(metaCtor.isFinal(), is(Modifier.isFinal(clazzCtor.getModifiers())));
+ assertThat(metaCtor.isStatic(), is(Modifier.isStatic(clazzCtor.getModifiers())));
+
+ assertThat(metaCtor.getAnnotations().size(), is(clazzCtor.getDeclaredAnnotations().length));
+
+ // Can't really check this since some annotations are not runtime annotations
+ // for (AnnotationMetadata amd : metaMethod.getAnnotations()) {
+ // Class<Annotation> annotationClass = (Class<Annotation>)Class.forName(amd.getAnnotationClassName());
+ // Annotation annotation = clazz.getAnnotation(annotationClass);
+ //
+ // assertThat(annotation, is(notNullValue()));
+ // }
+ }
+ }
+
+ private Visibility visibilityFor( int modifier ) {
+ if (Modifier.isPublic(modifier)) return Visibility.PUBLIC;
+ if (Modifier.isProtected(modifier)) return Visibility.PROTECTED;
+ if (Modifier.isPrivate(modifier)) return Visibility.PRIVATE;
+ return Visibility.PACKAGE;
+ }
+
+ private class FieldKey {
+ private final String name;
+
+ private FieldKey( Field field ) {
+ this.name = field.getName();
+ }
+
+ private FieldKey( FieldMetadata field ) {
+ this.name = field.getName();
+ }
+
+ @Override
+ public boolean equals( Object obj ) {
+ if (!(obj instanceof FieldKey)) return false;
+ return name.equals(((FieldKey)obj).name);
+ }
+
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+ }
+
+ private class MethodKey {
+ private final String name;
+ private final List<String> parameters;
+
+ private MethodKey( Method method ) {
+ this.name = method.getName();
+ this.parameters = new ArrayList<String>();
+ for (Class<?> parameter : method.getParameterTypes()) {
+ parameters.add(parameter.getCanonicalName());
+ }
+ }
+
+ @SuppressWarnings( "unchecked" )
+ private MethodKey( Constructor ctor ) {
+ this.name = ctor.getName();
+ this.parameters = new ArrayList<String>();
+ for (Class<?> parameter : ctor.getParameterTypes()) {
+ parameters.add(parameter.getCanonicalName());
+ }
+ }
+
+ private MethodKey( MethodMetadata method ) {
+ this.name = method.getName();
+ this.parameters = method.getParameters();
+ }
+
+ @Override
+ public boolean equals( Object obj ) {
+ if (!(obj instanceof MethodKey)) return false;
+
+ MethodKey other = (MethodKey)obj;
+ return name.equals(other.name) && parameters.equals(other.parameters);
+ }
+
+ @Override
+ public int hashCode() {
+ return HashCode.compute(name, parameters);
+ }
+
+ @Override
+ public String toString() {
+ return name + "(" + parameters + ")";
+ }
+
+ }
+}
Property changes on: trunk/extensions/dna-sequencer-classfile/src/test/java/org/jboss/dna/sequencer/classfile/metadata/ClassFileMetadataReaderTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-sequencer-classfile/src/test/resources/NodeEntity.clazz
===================================================================
(Binary files differ)
Property changes on: trunk/extensions/dna-sequencer-classfile/src/test/resources/NodeEntity.clazz
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-01-01 17:19:43 UTC (rev 1511)
+++ trunk/pom.xml 2010-01-01 17:46:39 UTC (rev 1512)
@@ -130,6 +130,7 @@
<!--module>extensions/dna-sequencer-esbMessage</module-->
<module>extensions/dna-sequencer-cnd</module>
<module>extensions/dna-sequencer-java</module>
+ <module>extensions/dna-sequencer-classfile</module>
<module>extensions/dna-sequencer-msoffice</module>
<module>extensions/dna-sequencer-text</module>
<module>extensions/dna-sequencer-xml</module>
Property changes on: trunk/utils/dna-jpa-ddl-gen
___________________________________________________________________
Name: svn:ignore
+ target
14 years, 4 months
DNA SVN: r1511 - in trunk: extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem and 1 other directory.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2010-01-01 12:19:43 -0500 (Fri, 01 Jan 2010)
New Revision: 1511
Removed:
trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemTransaction.java
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/DefaultPathNode.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepository.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepositoryConnection.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRequestProcessor.java
trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRepository.java
Log:
DNA-519 SVN Connector integration test runs in a very long time
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/DefaultPathNode.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/DefaultPathNode.java 2010-01-01 13:28:22 UTC (rev 1510)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/DefaultPathNode.java 2010-01-01 17:19:43 UTC (rev 1511)
@@ -1,6 +1,7 @@
package org.jboss.dna.graph.connector.path;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -37,6 +38,21 @@
this.childSegments = childSegments;
}
+ public DefaultPathNode( Path path,
+ UUID uuid,
+ Iterable<Property> properties,
+ List<Segment> childSegments ) {
+ super();
+ this.path = path;
+ this.uuid = uuid;
+ this.childSegments = childSegments;
+ this.properties = new HashMap<Name, Property>();
+
+ for (Property property : properties) {
+ this.properties.put(property.getName(), property);
+ }
+ }
+
public List<Segment> getChildSegments() {
return this.childSegments;
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepository.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepository.java 2010-01-01 13:28:22 UTC (rev 1510)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepository.java 2010-01-01 17:19:43 UTC (rev 1511)
@@ -6,6 +6,9 @@
import java.util.concurrent.ConcurrentMap;
import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.connector.RepositoryContext;
+import org.jboss.dna.graph.observe.Observer;
@ThreadSafe
public abstract class PathRepository {
@@ -106,21 +109,21 @@
*/
protected abstract void initialize();
- /**
- * Begin a transaction, hinting whether the transaction will be used only to read the content. If this is called, then the
- * transaction must be either {@link PathRepositoryTransaction#commit() committed} or
- * {@link PathRepositoryTransaction#rollback() rolled back}.
- *
- * @param readonly true if the transaction will not modify any content, or false if changes are to be made
- * @return the transaction; never null
- * @see PathRepositoryTransaction#commit()
- * @see PathRepositoryTransaction#rollback()
- */
- public PathRepositoryTransaction startTransaction( boolean readonly ) {
+ public boolean isWritable() {
+ return false;
+ }
- // Read-only repositories can return a default NOP implementation
- return new PathRepositoryTransaction() {
+ PathRequestProcessor createRequestProcessor( ExecutionContext context,
+ PathRepositorySource source ) {
+ RepositoryContext repositoryContext = source.getRepositoryContext();
+ Observer observer = repositoryContext != null ? repositoryContext.getObserver() : null;
+ boolean updatesAllowed = source.areUpdatesAllowed();
+ /**
+ * Read-only implementations can use a NOP transaction.
+ */
+ PathRepositoryTransaction txn = new PathRepositoryTransaction() {
+
public void commit() {
}
@@ -128,9 +131,7 @@
}
};
- }
- public boolean isWritable() {
- return false;
+ return new PathRequestProcessor(context, this, observer, updatesAllowed, txn);
}
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepositoryConnection.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepositoryConnection.java 2010-01-01 13:28:22 UTC (rev 1510)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepositoryConnection.java 2010-01-01 17:19:43 UTC (rev 1511)
@@ -7,11 +7,8 @@
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.cache.CachePolicy;
import org.jboss.dna.graph.connector.RepositoryConnection;
-import org.jboss.dna.graph.connector.RepositoryContext;
import org.jboss.dna.graph.connector.RepositorySourceException;
-import org.jboss.dna.graph.observe.Observer;
import org.jboss.dna.graph.request.Request;
-import org.jboss.dna.graph.request.processor.RequestProcessor;
public class PathRepositoryConnection implements RepositoryConnection {
@@ -78,10 +75,8 @@
}
// Do any commands update/write?
- PathRepositoryTransaction txn = repository.startTransaction(request.isReadOnly());
- RepositoryContext repositoryContext = this.source.getRepositoryContext();
- Observer observer = repositoryContext != null ? repositoryContext.getObserver() : null;
- RequestProcessor processor = new PathRequestProcessor(context, this.repository, observer, source.areUpdatesAllowed());
+ PathRequestProcessor processor = repository.createRequestProcessor(context, source);
+ PathRepositoryTransaction txn = processor.getTransaction();
boolean commit = true;
try {
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRequestProcessor.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRequestProcessor.java 2010-01-01 13:28:22 UTC (rev 1510)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRequestProcessor.java 2010-01-01 17:19:43 UTC (rev 1511)
@@ -51,15 +51,18 @@
private final PathFactory pathFactory;
private final PathRepository repository;
private final boolean updatesAllowed;
+ private final PathRepositoryTransaction txn;
public PathRequestProcessor( ExecutionContext context,
PathRepository repository,
Observer observer,
- boolean updatesAllowed ) {
+ boolean updatesAllowed,
+ PathRepositoryTransaction txn ) {
super(repository.getSourceName(), context, observer);
this.repository = repository;
pathFactory = context.getValueFactories().getPathFactory();
this.updatesAllowed = updatesAllowed;
+ this.txn = txn;
}
protected boolean updatesAllowed( Request request ) {
@@ -575,4 +578,15 @@
return node;
}
+ /**
+ * Returns the transaction associated with this request processor. This transaction must eventually either be
+ * {@link PathRepositoryTransaction#commit() committed} or {@link PathRepositoryTransaction#rollback() rolled back}.
+ *
+ * @return the transaction associated with this request processor; never null
+ * @see PathRepositoryTransaction#commit()
+ * @see PathRepositoryTransaction#rollback()
+ */
+ public PathRepositoryTransaction getTransaction() {
+ return this.txn;
+ }
}
Modified: trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRepository.java
===================================================================
--- trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRepository.java 2010-01-01 13:28:22 UTC (rev 1510)
+++ trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRepository.java 2010-01-01 17:19:43 UTC (rev 1511)
@@ -49,7 +49,6 @@
import org.jboss.dna.graph.connector.path.AbstractWritablePathWorkspace;
import org.jboss.dna.graph.connector.path.DefaultPathNode;
import org.jboss.dna.graph.connector.path.PathNode;
-import org.jboss.dna.graph.connector.path.PathRepositoryTransaction;
import org.jboss.dna.graph.connector.path.WritablePathRepository;
import org.jboss.dna.graph.connector.path.WritablePathWorkspace;
import org.jboss.dna.graph.mimetype.MimeTypeDetector;
@@ -171,11 +170,6 @@
return null;
}
- @Override
- public PathRepositoryTransaction startTransaction( boolean readonly ) {
- return new FileSystemTransaction();
- }
-
/**
* Writable workspace implementation for file system-backed workspaces
*/
Deleted: trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemTransaction.java
===================================================================
--- trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemTransaction.java 2010-01-01 13:28:22 UTC (rev 1510)
+++ trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemTransaction.java 2010-01-01 17:19:43 UTC (rev 1511)
@@ -1,53 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.connector.filesystem;
-
-import org.jboss.dna.graph.connector.path.PathRepositoryTransaction;
-
-/**
- * A transaction returned by the {@link FileSystemRepository#startTransaction(boolean)}.
- */
-public class FileSystemTransaction implements PathRepositoryTransaction {
-
- /**
- * Commit any changes that have been made to the repository. This method may throw runtime exceptions if there are failures
- * committing the changes, but the transaction is still expected to be closed.
- *
- * @see #rollback()
- * @see FileSystemRepository#startTransaction(boolean)
- */
- public void commit() {
- }
-
- /**
- * Rollback any changes that have been made to this repository. This method may throw runtime exceptions if there are failures
- * rolling back the changes, but the transaction is still expected to be closed.
- *
- * @see #commit()
- * @see FileSystemRepository#startTransaction(boolean)
- */
- public void rollback() {
- }
-
-}
14 years, 4 months
DNA SVN: r1510 - trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2010-01-01 08:28:22 -0500 (Fri, 01 Jan 2010)
New Revision: 1510
Modified:
trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemSource.java
Log:
Corrected Javadoc
Modified: trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemSource.java
===================================================================
--- trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemSource.java 2009-12-31 22:41:01 UTC (rev 1509)
+++ trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemSource.java 2010-01-01 13:28:22 UTC (rev 1510)
@@ -274,9 +274,9 @@
}
/**
- * Get the UUID that is used for the root node of each workspace
+ * Get the maximum path length (in characters) allowed by the underlying file system
*
- * @return the UUID that is used for the root node of each workspace
+ * @return the maximum path length (in characters) allowed by the underlying file system
*/
public int getMaxPathLength() {
return maxPathLength;
14 years, 4 months