DNA SVN: r154 - in trunk: dna-maven-classloader and 3 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-05-13 15:30:28 -0400 (Tue, 13 May 2008)
New Revision: 154
Modified:
trunk/dna-integration-tests/pom.xml
trunk/dna-maven-classloader/pom.xml
trunk/dna-repository/pom.xml
trunk/dna-spi/pom.xml
trunk/sequencers/dna-sequencer-images/pom.xml
Log:
Updated the POM files with the correct version of test JARs
Modified: trunk/dna-integration-tests/pom.xml
===================================================================
--- trunk/dna-integration-tests/pom.xml 2008-05-13 18:56:30 UTC (rev 153)
+++ trunk/dna-integration-tests/pom.xml 2008-05-13 19:30:28 UTC (rev 154)
@@ -22,22 +22,22 @@
<dependency>
<groupId>org.jboss.dna</groupId>
<artifactId>dna-common</artifactId>
- <version>0.1-SNAPSHOT</version>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.dna</groupId>
<artifactId>dna-maven-classloader</artifactId>
- <version>0.1-SNAPSHOT</version>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.dna</groupId>
<artifactId>dna-repository</artifactId>
- <version>0.1-SNAPSHOT</version>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.dna</groupId>
<artifactId>dna-common</artifactId>
- <version>0.1-SNAPSHOT</version>
+ <version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
Modified: trunk/dna-maven-classloader/pom.xml
===================================================================
--- trunk/dna-maven-classloader/pom.xml 2008-05-13 18:56:30 UTC (rev 153)
+++ trunk/dna-maven-classloader/pom.xml 2008-05-13 19:30:28 UTC (rev 154)
@@ -22,12 +22,12 @@
<dependency>
<groupId>org.jboss.dna</groupId>
<artifactId>dna-common</artifactId>
- <version>0.1-SNAPSHOT</version>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.dna</groupId>
<artifactId>dna-common</artifactId>
- <version>0.1-SNAPSHOT</version>
+ <version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
Modified: trunk/dna-repository/pom.xml
===================================================================
--- trunk/dna-repository/pom.xml 2008-05-13 18:56:30 UTC (rev 153)
+++ trunk/dna-repository/pom.xml 2008-05-13 19:30:28 UTC (rev 154)
@@ -22,19 +22,19 @@
<dependency>
<groupId>org.jboss.dna</groupId>
<artifactId>dna-common</artifactId>
- <version>0.1-SNAPSHOT</version>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.dna</groupId>
<artifactId>dna-common</artifactId>
- <version>0.1-SNAPSHOT</version>
+ <version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.dna</groupId>
<artifactId>dna-spi</artifactId>
- <version>0.1-SNAPSHOT</version>
+ <version>${project.version}</version>
</dependency>
<!--
Rules
Modified: trunk/dna-spi/pom.xml
===================================================================
--- trunk/dna-spi/pom.xml 2008-05-13 18:56:30 UTC (rev 153)
+++ trunk/dna-spi/pom.xml 2008-05-13 19:30:28 UTC (rev 154)
@@ -22,12 +22,12 @@
<dependency>
<groupId>org.jboss.dna</groupId>
<artifactId>dna-common</artifactId>
- <version>0.1-SNAPSHOT</version>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.dna</groupId>
<artifactId>dna-common</artifactId>
- <version>0.1-SNAPSHOT</version>
+ <version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
Modified: trunk/sequencers/dna-sequencer-images/pom.xml
===================================================================
--- trunk/sequencers/dna-sequencer-images/pom.xml 2008-05-13 18:56:30 UTC (rev 153)
+++ trunk/sequencers/dna-sequencer-images/pom.xml 2008-05-13 19:30:28 UTC (rev 154)
@@ -31,6 +31,20 @@
<groupId>org.jboss.dna</groupId>
<artifactId>dna-spi</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-spi</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
<!--
Testing (note the scope)
-->
15 years, 12 months
DNA SVN: r153 - trunk/docs/gettingstarted/en.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-05-13 14:56:30 -0400 (Tue, 13 May 2008)
New Revision: 153
Modified:
trunk/docs/gettingstarted/en/master.xml
Log:
Completed the remaining sections/chapters of the document, and made numerous small edits.
Modified: trunk/docs/gettingstarted/en/master.xml
===================================================================
--- trunk/docs/gettingstarted/en/master.xml 2008-05-13 18:30:33 UTC (rev 152)
+++ trunk/docs/gettingstarted/en/master.xml 2008-05-13 18:56:30 UTC (rev 153)
@@ -82,9 +82,9 @@
<chapter id="introduction">
<title>Introduction</title>
<para>There are a lot of choices for how applications can store information persistently so that it can be accessed at a
- later time and by other processes. The challenge developers face is how to use an approach that most closely matches the needs
- of their application. This choice becomes more important as developers choose to focus their efforts on application-specific
- logic, delegating much of the responsibilities for persistence to libraries and frameworks.</para>
+ later time and by other processes. The challenge developers face is how to use an approach that most closely matches the
+ needs of their application. This choice becomes more important as developers choose to focus their efforts on
+ application-specific logic, delegating much of the responsibilities for persistence to libraries and frameworks.</para>
<para>
Perhaps one of the easiest techniques is to simply store information in
<emphasis>files</emphasis>
@@ -114,8 +114,8 @@
</para>
<para>
<emphasis>Object-relational mapping</emphasis>
- libraries automate the creation of this mapping layer and result in far less code that is much more maintainable with performance
- that is often as good as (if not better than) handwritten JDBC code. The new
+ libraries automate the creation of this mapping layer and result in far less code that is much more maintainable with
+ performance that is often as good as (if not better than) handwritten JDBC code. The new
<ulink url="http://java.sun.com/developer/technicalArticles/J2EE/jpa/">Java Persistence API (JPA)</ulink>
provide a standard mechanism for defining the mappings (through annotations) and working with these entity objects. Several
commercial and open-source libraries implement JPA, and some even offer additional capabilities and features that go beyond
@@ -126,8 +126,9 @@
</para>
<para>
While relational databases and JPA are solutions that work for many applications, they become more limited in cases when the
- information structure is highly flexible, is not known <emphasis>a priori</emphasis>, or is subject to frequent change and
- customization. In these situations,
+ information structure is highly flexible, is not known
+ <emphasis>a priori</emphasis>
+ , or is subject to frequent change and customization. In these situations,
<emphasis>content repositories</emphasis>
may offer a better choice for persistence. Content repositories are almost a hybrid between relational databases and file
systems, and typically provide other capabilities as well, including versioning, indexing, search, access control,
@@ -149,8 +150,8 @@
below the JCR API and involve automated processing of the information in the repository. Thus, JBoss DNA can add value to
existing repository implementations. For example, JCR repositories offer the ability to upload files into the repository and
have the file content indexed for search purposes. JBoss DNA also defines a library for "sequencing" content - to extract
- meaningful information from that content and store it in the repository, where it can then be searched, accessed, and analyzed
- using the JCR API.
+ meaningful information from that content and store it in the repository, where it can then be searched, accessed, and
+ analyzed using the JCR API.
</para>
<para> JBoss DNA is building other features as well. One goal of JBoss DNA is to create federated repositories that
dynamically merge the information from multiple databases, services, applications, and other JCR repositories. Another is to
@@ -230,8 +231,8 @@
is used by end users and domain experts to visualize, search, edit, change and tag the repository content. The web
application uses views to define how different types of information are to be presented and edited in
domain-specific ways. The goal is that this web application is easily customized and branded for inclusion into
- other solutions and application systems. The DNA Web Application operates upon any JCR-compliant repository, although
- it does rely upon the DNA analysis and templating services.
+ other solutions and application systems. The DNA Web Application operates upon any JCR-compliant repository,
+ although it does rely upon the DNA analysis and templating services.
</para>
</listitem>
<listitem>
@@ -263,9 +264,9 @@
<listitem>
<para>
<emphasis role="strong">DNA Analyses</emphasis>
- are pluggable components that analyze content and the relationships between content to generate reports or
- to answer queries. DNA will include some standard analyzers, like dependency analysis and similarity analysis, that
- are commonly needed by many different solutions. DNA analyzers operate upon any JCR-compliant repository.
+ are pluggable components that analyze content and the relationships between content to generate reports or to answer
+ queries. DNA will include some standard analyzers, like dependency analysis and similarity analysis, that are
+ commonly needed by many different solutions. DNA analyzers operate upon any JCR-compliant repository.
</para>
</listitem>
<listitem>
@@ -325,9 +326,9 @@
those files to extract meaningful structured information. For example, load DDL files into the repository, and let
sequencers extract the structure and metadata for the database schema. Load Hibernate configuration files into the
repository, and let sequencers extract the schema and mapping information. Load Java source into the repository, and let
- sequencers extract the class structure, JavaDoc, and annotations. Load a PNG, JPEG, or other image into the repository, and
- let sequencers extract the metadata from the image and save it in the repository. The same with XSDs, WSDL, WS policies,
- UML, MetaMatrix models, etc.</para>
+ sequencers extract the class structure, JavaDoc, and annotations. Load a PNG, JPEG, or other image into the repository,
+ and let sequencers extract the metadata from the image and save it in the repository. The same with XSDs, WSDL, WS
+ policies, UML, MetaMatrix models, etc.</para>
<para>
JBoss DNA sequencers sit on top of existing JCR repositories (including federated repositories) - it basically extracts
more useful information from what's already stored in the repository. And it uses the existing JCR versioning system. Each
@@ -337,9 +338,10 @@
<para>
<emphasis role="strong">Image sequencer</emphasis>
- A sequencer that processes the binary content of an image file, extracts the metadata for the image, and then
- writes that image metadata to the repository. It gets the file format, image resolution, number of bits per pixel (and
- optionally number of images), comments and physical resolution from JPEG, GIF, BMP, PCX, PNG, IFF, RAS, PBM, PGM, PPM,
- and PSD files. (This sequencer may be improved in the future to also extract EXIF metadata from JPEG files; see
+ writes that image metadata to the repository. It gets the file format, image resolution, number of bits per pixel
+ (and optionally number of images), comments and physical resolution from JPEG, GIF, BMP, PCX, PNG, IFF, RAS, PBM,
+ PGM, PPM, and PSD files. (This sequencer may be improved in the future to also extract EXIF metadata from JPEG
+ files; see
<ulink url="http://jira.jboss.org/jira/browse/DNA-26">DNA-26</ulink>
.)
</para>
@@ -353,8 +355,9 @@
<listitem>
<para>
<emphasis role="strong">XML Schema Document (XSD) Sequencer</emphasis>
- - Process XSD files and extract the various elements, attributes, complex types, simple types, groups, and other information.
- (See <ulink url="http://jira.jboss.org/jira/browse/DNA-32">DNA-32</ulink>
+ - Process XSD files and extract the various elements, attributes, complex types, simple types, groups, and other
+ information. (See
+ <ulink url="http://jira.jboss.org/jira/browse/DNA-32">DNA-32</ulink>
)
</para>
</listitem>
@@ -564,12 +567,12 @@
provide an implementation.
</para>
<para>
- Also, connectors talk to <emphasis>sources</emphasis> of information, and it's quite likely that the same
- connector is used to talk to different sources. Each source contains the configuration details
- (e.g., connection information, location, properties, options, etc.) for
- working with that particular source, as well as a reference to the connector that should be used to establish
- connections to the source. And of course, sources can be added or removed without having to stop and restart the
- federated repository.
+ Also, connectors talk to
+ <emphasis>sources</emphasis>
+ of information, and it's quite likely that the same connector is used to talk to different sources. Each source contains
+ the configuration details (e.g., connection information, location, properties, options, etc.) for working with that
+ particular source, as well as a reference to the connector that should be used to establish connections to the source.
+ And of course, sources can be added or removed without having to stop and restart the federated repository.
</para>
</sect2>
<sect2 id="federation_graph">
@@ -609,18 +612,17 @@
be consulted prior to returning the query results, as the results from one source might have contributions from another
source.</para>
<note>
- <para> It is hoped that the MetaMatrix query engine can be used for this purpose, after it is open sourced. This engine
- implements sophisticated query planning and optimization techniques for working efficiently with multiple sources.
- </para>
+ <para> It is hoped that the MetaMatrix query engine can be used for this purpose, after it is open sourced. This engine
+ implements sophisticated query planning and optimization techniques for working efficiently with multiple sources.
+ </para>
</note>
- <para>Searching the whole federated repository is also important. This allows users to simply supply a handful of search
- terms, and to get results that are ranked based upon how close each result is to the search terms. (Searching is very
- different from querying, which involves specifying the exact semantics of what is to be searched and how the information
- is to be compared.) JBoss DNA will incorporate a search
- engine (e.g., likely to be Lucene) and will populate the engine's indexes using the federated content and the cached
- information. Notifications of changing information will be reflected in the indexes, but some sources may want to explicitly
- allow or disallow periodic crawling of their content.
- </para>
+ <para>Searching the whole federated repository is also important. This allows users to simply supply a handful of
+ search terms, and to get results that are ranked based upon how close each result is to the search terms. (Searching is
+ very different from querying, which involves specifying the exact semantics of what is to be searched and how the
+ information is to be compared.) JBoss DNA will incorporate a search engine (e.g., likely to be Lucene) and will populate
+ the engine's indexes using the federated content and the cached information. Notifications of changing information will
+ be reflected in the indexes, but some sources may want to explicitly allow or disallow periodic crawling of their
+ content.</para>
</sect2>
<sect2 id="federation_updates">
<title>Updating content</title>
@@ -1431,17 +1433,49 @@
==================================================================================================== -->
<chapter id="custom_sequencers">
<title>Creating custom sequencers</title>
- <para>The current release of JBoss DNA comes with a single sequencer that extracts metadata from image files.
- If you create your own sequencer implementation,
+ <para>The current release of JBoss DNA comes with two sequencers: one that extracts metadata from a variety of image file formats,
+ and another that extracts some of the ID3 metadata from MP3 audio files. However, it's very easy to create your own
+ sequencers and to then configure JBoss DNA to use them in your own application.
</para>
+ <para>
+ Creating a custom sequencer involves the following steps:
+ <itemizedlist>
+ <listitem>
+ <para>Create a Maven 2 project for your sequencer;</para>
+ </listitem>
+ <listitem>
+ <para>Implement the <code>org.jboss.dna.spi.sequencers.StreamSequencer</code> interface with your own implementation, and create unit tests to verify
+ the functionality and expected behavior;</para>
+ </listitem>
+ <listitem>
+ <para>Add the sequencer configuration to the JBoss DNA <code>SequencingService</code> in your application,
+ as described in the <link linkend="using_dna">previous chapter</link>; and</para>
+ </listitem>
+ <listitem>
+ <para>Deploy the JAR file with your implementation (as well as any dependencies) and make them available to JBoss DNA
+ in your application.</para>
+ </listitem>
+ </itemizedlist>
+ It's that simple.
+ </para>
+ <sect1 id="custom_sequencer_project">
+ <title>Creating the Maven 2 project</title>
+ <para>The first step is to create the Maven 2 project that you can use to compile your code and build the JARs.
+ Maven 2 automates a lot of the work, and since you're already <link linkend="downloading_and_running">set up to use Maven</link>,
+ using Maven for your project will save you a lot of time and effort. Of course, you don't have to use Maven 2, but then you'll
+ have to get the required libraries and manage the compiling and building process yourself.</para>
+ <note>
+ <para>JBoss DNA may provide in the future a Maven archetype for creating sequencer projects. If you'd find this useful
+ and would like to help create it, please <link linkend="preface">join the community</link>.</para>
+ </note>
<note>
<para>The <code>dna-sequencer-images</code> project is a small, self-contained sequencer implementation that
- has only the minimal dependencies. Starting with the source can modifying it may be the easiest way to get started.
+ has only the minimal dependencies. Starting with this project's source and modifying it to suit your needs may be the easiest way to get started.
See the subversion repository: <ulink url="http://anonsvn.jboss.org/repos/dna/trunk/sequencers/dna-sequencer-images/">http://anonsvn.jboss.org/repos/dna/trunk/sequencers/dna-sequencer-images/</ulink>
</para>
</note>
- <para>The first step is to <ulink url="http://maven.apache.org/guides/getting-started/index.html#How_do_I_make_m...">create a new Maven 2 project</ulink>
- for your sequencer, and specify the following in your project's <code>pom.xml</code> dependencies section:
+ <para>You can create your Maven project any way you'd like. For examples, see the <ulink url="http://maven.apache.org/guides/getting-started/index.html#How_do_I_make_m...">Maven 2 documentation</ulink>.
+ Once you've done that, just add the dependencies in your project's <code>pom.xml</code> dependencies section:
<programlisting>
<dependency>
<groupId>org.jboss.dna</groupId>
@@ -1460,8 +1494,7 @@
</programlisting>
These are minimum dependencies required for compiling a sequencer. Of course, you'll have to add
other dependencies that your sequencer needs.</para>
- <para>As for testing, you probably will want to add more dependencies. Here are some dependencies you may need,
- depending upon how you want to test:
+ <para>As for testing, you probably will want to add more dependencies, such as those listed here:
<programlisting>
<dependency>
<groupId>junit</groupId>
@@ -1489,9 +1522,9 @@
<scope>test</scope>
</dependency>
</programlisting>
- If you want to test with JCR and with JBoss DNA, you'll need additional dependencies for these libraries.
- Strictly speaking, the sequencers do not actually use JCR. Instead, they use interfaces defined in the <code>dna-spi</code> project.
- This not only simplifies the sequencer implementation, it also dramatically simplifies testing.
+ Testing JBoss DNA sequencers does not require a JCR repository or the JBoss DNA services. (For more detail,
+ see the <link linkend="testing_custom_sequencers">testing section</link>.) However, if you want to do
+ integration testing with a JCR repository and the JBoss DNA services, you'll need additional dependencies for these libraries.
<programlisting>
<dependency>
<groupId>org.jboss.dna</groupId>
@@ -1543,23 +1576,240 @@
</dependency>
</programlisting>
</para>
+ <para>At this point, your project should be set up correctly, and you're ready to move on to
+ <link linkend="custom_sequencer_implementation">writing the Java implementation</link> for your sequencer.
+ </para>
+ </sect1>
<sect1 id="custom_sequencer_implementation">
<title>Implementing the StreamSequencer interface</title>
- <para></para>
+ <para>After creating the project and setting up the dependencies, the next step is to create a Java class that implements
+ the <code>org.jboss.dna.spi.sequencers.StreamSequencer</code> interface. This interface is very straightforward,
+ and involves a single method:
+ <programlisting>
+public interface StreamSequencer {
+
+ /**
+ * Sequence the data found in the supplied stream, placing the output
+ * information into the supplied map.
+ *
+ * @param stream the stream with the data to be sequenced; never null
+ * @param output the output from the sequencing operation; never null
+ * @param progressMonitor the progress monitor that should be kept
+ * updated with the sequencer's progress and that should be
+ * frequently consulted as to whether this operation has been cancelled.
+ */
+ void sequence( InputStream stream, SequencerOutput output,
+ ProgressMonitor progressMonitor );</programlisting>
+ </para>
+ <para>The job of a stream sequencer is to process the data in the supplied stream, and place into the <code>SequencerOutput</code>
+ any information that is to go into the JCR repository. JBoss DNA figures out when your sequencer should be called
+ (of course using the sequencing configuration you'll add in a bit), and then makes sure the generated information
+ is saved in the correct place in the repository.
+ </para>
+ <para>The <code>SequencerOutput</code> class is fairly easy to use. There are basically two methods you need to call.
+ One method sets the property values, while the other sets references to other nodes in the repository. Use these
+ methods to describe the properties of the nodes you want to create, using relative paths for the nodes and
+ valid JCR property names for properties and references. JBoss DNA will ensure that nodes are created or updated
+ whenever they're needed.
+ <programlisting>
+public interface SequencerOutput {
+
+ /**
+ * Set the supplied property on the supplied node. The allowable
+ * values are any of the following:
+ * - primitives (which will be autoboxed)
+ * - String instances
+ * - String arrays
+ * - byte arrays
+ * - InputStream instances
+ * - Calendar instances
+ *
+ * @param nodePath the path to the node containing the property;
+ * may not be null
+ * @param property the name of the property to be set
+ * @param values the value(s) for the property; may be empty if
+ * any existing property is to be removed
+ */
+ void setProperty( String nodePath, String property,
+ Object... values );
+
+ /**
+ * Set the supplied reference on the supplied node.
+ *
+ * @param nodePath the path to the node containing the property;
+ * may not be null
+ * @param property the name of the property to be set
+ * @param paths the paths to the referenced property, which may be
+ * absolute paths or relative to the sequencer output node;
+ * may be empty if any existing property is to be removed
+ */
+ void setReference( String nodePath, String property,
+ String... paths );
+}</programlisting>
+ </para>
+ <para>JBoss DNA will create nodes of type <code>nt:unstructured</code> unless you specify the value for the
+ <code>jcr:primaryType</code> property. You can also specify the values for the <code>jcr:mixinTypes</code> property
+ if you want to add mixins to any node.
+ </para>
+ <para>For a complete example of a sequencer, let's look at the <code>org.jboss.dna.sequencers.image.ImageMetadataSequencer</code> implementation:
+ <programlisting>
+public class ImageMetadataSequencer implements StreamSequencer {
+
+ public static final String METADATA_NODE = "image:metadata";
+ public static final String IMAGE_PRIMARY_TYPE = "jcr:primaryType";
+ public static final String IMAGE_MIXINS = "jcr:mixinTypes";
+ public static final String IMAGE_MIME_TYPE = "jcr:mimeType";
+ public static final String IMAGE_ENCODING = "jcr:encoding";
+ public static final String IMAGE_FORMAT_NAME = "image:formatName";
+ public static final String IMAGE_WIDTH = "image:width";
+ public static final String IMAGE_HEIGHT = "image:height";
+ public static final String IMAGE_BITS_PER_PIXEL = "image:bitsPerPixel";
+ public static final String IMAGE_PROGRESSIVE = "image:progressive";
+ public static final String IMAGE_NUMBER_OF_IMAGES = "image:numberOfImages";
+ public static final String IMAGE_PHYSICAL_WIDTH_DPI = "image:physicalWidthDpi";
+ public static final String IMAGE_PHYSICAL_HEIGHT_DPI = "image:physicalHeightDpi";
+ public static final String IMAGE_PHYSICAL_WIDTH_INCHES = "image:physicalWidthInches";
+ public static final String IMAGE_PHYSICAL_HEIGHT_INCHES = "image:physicalHeightInches";
+
+ /**
+ * {@inheritDoc}
+ */
+ public void sequence( InputStream stream, SequencerOutput output,
+ ProgressMonitor progressMonitor ) {
+ progressMonitor.beginTask(10, ImageSequencerI18n.sequencerTaskName);
+
+ ImageMetadata metadata = new ImageMetadata();
+ metadata.setInput(stream);
+ metadata.setDetermineImageNumber(true);
+ metadata.setCollectComments(true);
+
+ // Process the image stream and extract the metadata ...
+ if (!metadata.check()) {
+ metadata = null;
+ }
+ progressMonitor.worked(5);
+ if (progressMonitor.isCancelled()) return;
+
+ // Generate the output graph if we found useful metadata ...
+ if (metadata != null) {
+ // Place the image metadata into the output map ...
+ output.setProperty(METADATA_NODE, IMAGE_PRIMARY_TYPE, "image:metadata");
+ // output.psetProperty(METADATA_NODE, IMAGE_MIXINS, "");
+ output.setProperty(METADATA_NODE, IMAGE_MIME_TYPE, metadata.getMimeType());
+ // output.setProperty(METADATA_NODE, IMAGE_ENCODING, "");
+ output.setProperty(METADATA_NODE, IMAGE_FORMAT_NAME, metadata.getFormatName());
+ output.setProperty(METADATA_NODE, IMAGE_WIDTH, metadata.getWidth());
+ output.setProperty(METADATA_NODE, IMAGE_HEIGHT, metadata.getHeight());
+ output.setProperty(METADATA_NODE, IMAGE_BITS_PER_PIXEL, metadata.getBitsPerPixel());
+ output.setProperty(METADATA_NODE, IMAGE_PROGRESSIVE, metadata.isProgressive());
+ output.setProperty(METADATA_NODE, IMAGE_NUMBER_OF_IMAGES, metadata.getNumberOfImages());
+ output.setProperty(METADATA_NODE, IMAGE_PHYSICAL_WIDTH_DPI, metadata.getPhysicalWidthDpi());
+ output.setProperty(METADATA_NODE, IMAGE_PHYSICAL_HEIGHT_DPI, metadata.getPhysicalHeightDpi());
+ output.setProperty(METADATA_NODE, IMAGE_PHYSICAL_WIDTH_INCHES, metadata.getPhysicalWidthInch());
+ output.setProperty(METADATA_NODE, IMAGE_PHYSICAL_HEIGHT_INCHES, metadata.getPhysicalHeightInch());
+ }
+
+ progressMonitor.done();
+ }
+}</programlisting>
+ </para>
+ <para>
+ Notice how the image metadata is extracted, and the output graph is generated. A single node is created with the name <code>image:metadata</code>
+ and with the <code>image:metadata</code> node type. No mixins are defined for the node, but several properties are set on the node
+ using the values obtained from the image metadata. After this method returns, the constructed graph will be saved to the repository
+ in all of the places defined by its configuration. (This is why only relative paths are used in the sequencer.)
+ </para>
+ <para>Also note how the progress monitor is used. Reporting progress through the supplied <code>ProgressMonitor</code> is very easy, and it ensures that JBoss DNA
+ can accurately monitor and report the status of sequencing activities to the users. At the beginning of the operation, call
+ <code>beginTask(...)</code> with a meaningful message describing
+ the operation and a total for the amount of work that will be done by this sequencer. Then perform the sequencing work,
+ periodically reporting work by specifying the incremental amount of work with the <code>worked(double)</code> method, or
+ by creating a subtask with the <code>createSubtask(double)</code> method and reporting work against that subtask
+ monitor.
+ </para>
+ <para>Your method should periodically use the ProgressMonitor's <code>isCancelled()</code> method to check whether the operation has been
+ cancelled.. If this method returns true, the implementation should abort all work as
+ soon as possible and close any resources that were acquired or opened.
+ </para>
+ <para>
+ Finally, when your sequencing operation is completed, it should call <code>done()</code> on the progress monitor.
+ </para>
</sect1>
<sect1 id="testing_custom_sequencers">
<title>Testing custom sequencers</title>
- <para></para>
+ <para>The sequencing framework was designed to make testing sequencers much easier. In particular, the
+ <code>StreamSequencer</code> interface does not make use of the JCR API. So instead of requiring a fully-configured
+ JCR repository and JBoss DNA system, unit tests for a sequencer can focus on testing that the content is
+ processed correctly and the desired output graph is generated.</para>
+ <note>
+ <para>For a complete example of a sequencer unit test, see the <code>ImageMetadataSequencerTest</code> unit test
+ in the <code>org.jboss.dna.sequencer.images</code> package of the <code>dna-sequencers-image</code> project.
+ </para>
+ </note>
+ <para>The following code fragment shows one way of testing a sequencer, using JUnit 4.4 assertions and
+ some of the classes made available by JBoss DNA. Of course,
+ this example code does not do any error handling and does not make all the assertions a real test would.
+ <programlisting>
+Sequencer sequencer = new ImageMetadataSequencer();
+MockSequencerOutput output = new MockSequencerOutput();
+ProgressMonitor progress = new SimpleProgressMonitor("Test activity");
+InputStream stream = null;
+try {
+ stream = this.getClass().getClassLoader().getResource("caution.gif").openStream();
+ sequencer.sequence(stream,output,progress); // writes to 'output'
+ assertThat(output.getPropertyValues("image:metadata", "jcr:primaryType"),
+ is(new Object[] {"image:metadata"}));
+ assertThat(output.getPropertyValues("image:metadata", "jcr:mimeType"),
+ is(new Object[] {"image/gif"}));
+ // ... make more assertions here
+ assertThat(output.hasReferences(), is(false));
+} finally {
+ stream.close();
+}</programlisting>
+ </para>
+ <para>It's also useful to test that a sequencer produces no output for something it should not understand:
+ <programlisting>
+Sequencer sequencer = new ImageMetadataSequencer();
+MockSequencerOutput output = new MockSequencerOutput();
+ProgressMonitor progress = new SimpleProgressMonitor("Test activity");
+InputStream stream = null;
+try {
+ stream = this.getClass().getClassLoader().getResource("caution.pict").openStream();
+ sequencer.sequence(stream,output,progress); // writes to 'output'
+ assertThat(output.hasProperties(), is(false));
+ assertThat(output.hasReferences(), is(false));
+} finally {
+ stream.close();
+}</programlisting>
+ </para>
+ <para>These are just two simple tests that show ways of testing a sequencer. Some tests may get quite involved,
+ especially if a lot of output data are produced.
+ </para>
+ <para>It may also be useful to create some integration tests
+ that <link linkend="using_dna">configures JBoss DNA</link> to use the custom sequencer, and to then upload
+ content using the JCR API, verifying that the custom sequencer did run. However, remember that JBoss DNA
+ runs sequencers asynchronously in the background, and you must sychronize your tests to ensure that the
+ sequencers have a chance to run before checking the results. (One way of doing this is to wait for a second
+ after uploading your content, shutdown the <code>SequencingService</code> and await its termination,
+ and then check that the sequencer output has been saved to the JCR repository. For an example of this technique,
+ see the <code>SequencingClientTest</code> unit test in the example application.)
+ </para>
</sect1>
<sect1 id="deploying_custom_sequencers">
<title>Deploying custom sequencers</title>
- <para>At this time, the JAR containing your new sequencer, as well as any JARs that your sequencer depends on, should be placed
- on your application classpath.</para>
+ <para>The first step of deploying a sequencer consists of adding/changing the sequencer configuration (e.g., <code>SequencerConfig</code>)
+ in the <code>SequencingService</code>. This was covered in the <link linkend="sequencing_service">previous chapter</link>.
+ </para>
+ <para>
+ The second step is to make the sequencer implementation available to JBoss DNA. At this time, the JAR containing
+ your new sequencer, as well as any JARs that your sequencer depends on, should be placed on your application classpath.</para>
<note>
<para>A future goal of JBoss DNA is to allow sequencers, connectors and other extensions to be easily deployed into
- a runtime repository. JBoss DNA will then create and use the appropriate class loaders for each extension.
- This will prevent the pollution of the common classpath, allow for easy upgrades, enable separation of
- the extensions in their own environment, and may even allow for hot redeployment of newer versions of extensions.
+ a runtime repository. This process will not only be much simpler, but it will also provide JBoss DNA
+ with the information necessary to update configurations and create the appropriate class loaders for each extension.
+ Having separate class loaders for each extension helps prevent the pollution of the common classpath,
+ facilitates an isolated runtime environment to eliminate any dependency conflicts, and may potentially
+ enable hot redeployment of newer extension versions.
</para>
</note>
</sect1>
@@ -1578,13 +1828,15 @@
for the list of sequencers we've thought of. If you think of one that's not there, please add it to JIRA!
</para>
<para>
+ The next release will focus on creating the <link linkend="federation">federation engine</link> and connectors
+ for several popular and ubiquitous systems. The 0.2 release will likely only federate information in a read-only manner,
+ but updates will soon follow. Also, during the early part of the next release, the JBoss DNA project will switch to use JDK 6.
+ Java 5 is being end-of-lifed, so we want to move to a supported JDK. However, a number of JBoss projects and products continue to
+ require Java 5, so our next release will most likely use JDK 6 with Java 5 compatibility.</para>
+ <para>
Other components on our roadmap include a web user interface, a REST-ful server, and a view system that allows domain-specific
- views of information in the repository. These components are farter out on our roadmap, and at this time have not been
- targeted to a particular release. If any of these are of interest to you, please get involved in the community.
+ views of information in the repository. These components are farther out on our roadmap, and at this time have not been
+ targeted to a particular release. If any of these are of interest to you, please <link linkend="preface">get involved</link> in the community.
</para>
- <para>
- Finally, during the early part of the next release, the JBoss DNA project will switch to use JDK 6. Java 5 is being
- end-of-lifed, so we want to move to a supported JDK. However, a number of JBoss projects and products continue to
- require Java 5, so our next release will most likely use JDK 6 with Java 5 compatibility.</para>
</chapter>
</book>
\ No newline at end of file
15 years, 12 months
DNA SVN: r152 - in trunk: sequencers/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images and 2 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-05-13 14:30:33 -0400 (Tue, 13 May 2008)
New Revision: 152
Added:
trunk/dna-spi/src/test/java/org/jboss/dna/spi/sequencers/MockSequencerOutput.java
trunk/sequencers/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageSequencerI18n.java
trunk/sequencers/dna-sequencer-images/src/main/resources/org/jboss/dna/sequencer/images/ImageSequencerI18n.properties
trunk/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java
trunk/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageSequencerI18nTest.java
Modified:
trunk/sequencers/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageMetadataSequencer.java
Log:
Enhanced the image sequencer implementation by adding calls to the progress monitor and adding unit tests. Also added an I18n class.
Added: trunk/dna-spi/src/test/java/org/jboss/dna/spi/sequencers/MockSequencerOutput.java
===================================================================
--- trunk/dna-spi/src/test/java/org/jboss/dna/spi/sequencers/MockSequencerOutput.java (rev 0)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/sequencers/MockSequencerOutput.java 2008-05-13 18:30:33 UTC (rev 152)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.spi.sequencers;
+
+import java.util.HashMap;
+import java.util.Map;
+import net.jcip.annotations.NotThreadSafe;
+
+/**
+ * @author Randall Hauch
+ */
+@NotThreadSafe
+public class MockSequencerOutput implements SequencerOutput {
+
+ private final Map<String, Object[]> properties;
+ private final Map<String, String[]> references;
+
+ /**
+ *
+ */
+ public MockSequencerOutput() {
+ this.properties = new HashMap<String, Object[]>();
+ this.references = new HashMap<String, String[]>();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setProperty( String nodePath, String property, Object... values ) {
+ String key = getKey(nodePath, property);
+ if (values == null || values.length == 0) {
+ this.properties.remove(key);
+ } else {
+ this.properties.put(key, values);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setReference( String nodePath, String property, String... paths ) {
+ String key = getKey(nodePath, property);
+ if (paths == null || paths.length == 0) {
+ this.references.remove(key);
+ } else {
+ this.references.put(key, paths);
+ }
+ }
+
+ public Object[] getPropertyValues( String nodePath, String property ) {
+ String key = getKey(nodePath, property);
+ return this.properties.get(key);
+ }
+
+ public String[] getReferenceValues( String nodePath, String property ) {
+ String key = getKey(nodePath, property);
+ return this.references.get(key);
+ }
+
+ public boolean hasProperty( String nodePath, String property ) {
+ String key = nodePath + "@" + property;
+ return this.properties.containsKey(key);
+ }
+
+ public boolean hasReference( String nodePath, String property ) {
+ String key = nodePath + "@" + property;
+ return this.references.containsKey(key);
+ }
+
+ public boolean hasProperties() {
+ return this.properties.size() > 0;
+ }
+
+ public boolean hasReferences() {
+ return this.references.size() > 0;
+ }
+
+ protected String getKey( String nodePath, String property ) {
+ return nodePath + "@" + property;
+ }
+
+}
Property changes on: trunk/dna-spi/src/test/java/org/jboss/dna/spi/sequencers/MockSequencerOutput.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/sequencers/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageMetadataSequencer.java
===================================================================
--- trunk/sequencers/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageMetadataSequencer.java 2008-05-13 16:00:15 UTC (rev 151)
+++ trunk/sequencers/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageMetadataSequencer.java 2008-05-13 18:30:33 UTC (rev 152)
@@ -83,16 +83,21 @@
* {@inheritDoc}
*/
public void sequence( InputStream stream, SequencerOutput output, ProgressMonitor progressMonitor ) {
+ progressMonitor.beginTask(10, ImageSequencerI18n.sequencerTaskName);
+
ImageMetadata metadata = new ImageMetadata();
metadata.setInput(stream);
metadata.setDetermineImageNumber(true);
metadata.setCollectComments(true);
- // Process the image ...
+ // Process the image stream and extract the metadata ...
if (!metadata.check()) {
metadata = null;
}
+ progressMonitor.worked(5);
+ if (progressMonitor.isCancelled()) return;
+ // Generate the output graph if we found useful metadata ...
if (metadata != null) {
// Place the image metadata into the output map ...
output.setProperty(METADATA_NODE, IMAGE_PRIMARY_TYPE, "image:metadata");
@@ -110,5 +115,7 @@
output.setProperty(METADATA_NODE, IMAGE_PHYSICAL_WIDTH_INCHES, metadata.getPhysicalWidthInch());
output.setProperty(METADATA_NODE, IMAGE_PHYSICAL_HEIGHT_INCHES, metadata.getPhysicalHeightInch());
}
+
+ progressMonitor.done();
}
}
Added: trunk/sequencers/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageSequencerI18n.java
===================================================================
--- trunk/sequencers/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageSequencerI18n.java (rev 0)
+++ trunk/sequencers/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageSequencerI18n.java 2008-05-13 18:30:33 UTC (rev 152)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.images;
+
+import java.util.Locale;
+import java.util.Set;
+import org.jboss.dna.common.i18n.I18n;
+
+/**
+ * @author Randall Hauch
+ */
+public final class ImageSequencerI18n {
+
+ public static I18n sequencerTaskName;
+
+ static {
+ try {
+ I18n.initialize(ImageSequencerI18n.class);
+ } catch (final Exception err) {
+ System.err.println(err);
+ }
+ }
+
+ public static Set<Locale> getLocalizationProblemLocales() {
+ return I18n.getLocalizationProblemLocales(ImageSequencerI18n.class);
+ }
+
+ public static Set<String> getLocalizationProblems() {
+ return I18n.getLocalizationProblems(ImageSequencerI18n.class);
+ }
+
+ public static Set<String> getLocalizationProblems( Locale locale ) {
+ return I18n.getLocalizationProblems(ImageSequencerI18n.class, locale);
+ }
+}
Property changes on: trunk/sequencers/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageSequencerI18n.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/sequencers/dna-sequencer-images/src/main/resources/org/jboss/dna/sequencer/images/ImageSequencerI18n.properties
===================================================================
--- trunk/sequencers/dna-sequencer-images/src/main/resources/org/jboss/dna/sequencer/images/ImageSequencerI18n.properties (rev 0)
+++ trunk/sequencers/dna-sequencer-images/src/main/resources/org/jboss/dna/sequencer/images/ImageSequencerI18n.properties 2008-05-13 18:30:33 UTC (rev 152)
@@ -0,0 +1 @@
+sequencerTaskName = Processing image contents
Property changes on: trunk/sequencers/dna-sequencer-images/src/main/resources/org/jboss/dna/sequencer/images/ImageSequencerI18n.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java
===================================================================
--- trunk/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java (rev 0)
+++ trunk/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java 2008-05-13 18:30:33 UTC (rev 152)
@@ -0,0 +1,150 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.images;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.hamcrest.number.IsCloseTo.closeTo;
+import static org.junit.Assert.assertThat;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import org.jboss.dna.common.monitor.ProgressMonitor;
+import org.jboss.dna.common.monitor.SimpleProgressMonitor;
+import org.jboss.dna.spi.sequencers.MockSequencerOutput;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Randall Hauch
+ */
+public class ImageMetadataSequencerTest {
+
+ private ImageMetadataSequencer sequencer;
+ private InputStream content;
+ private MockSequencerOutput output;
+ private ProgressMonitor progress;
+ private URL cautionGif;
+ private URL cautionJpg;
+ private URL cautionPict;
+ private URL cautionPng;
+
+ @Before
+ public void beforeEach() throws Exception {
+ this.sequencer = new ImageMetadataSequencer();
+ this.output = new MockSequencerOutput();
+ this.progress = new SimpleProgressMonitor("Test activity");
+ this.cautionGif = this.getClass().getClassLoader().getResource("caution.gif");
+ this.cautionJpg = this.getClass().getClassLoader().getResource("caution.jpg");
+ this.cautionPict = this.getClass().getClassLoader().getResource("caution.pict");
+ this.cautionPng = this.getClass().getClassLoader().getResource("caution.png");
+ }
+
+ @After
+ public void afterEach() throws Exception {
+ if (content != null) {
+ try {
+ content.close();
+ } finally {
+ content = null;
+ }
+ }
+ }
+
+ @Test
+ public void shouldGenerateMetadataForJpegImageFiles() throws IOException {
+ URL url = this.cautionJpg;
+ assertThat(url, is(notNullValue()));
+ content = url.openStream();
+ assertThat(content, is(notNullValue()));
+ sequencer.sequence(content, output, progress);
+ assertThat(output.getPropertyValues("image:metadata", "jcr:primaryType"), is(new Object[] {"image:metadata"}));
+ assertThat(output.getPropertyValues("image:metadata", "jcr:mimeType"), is(new Object[] {"image/jpeg"}));
+ assertThat(output.getPropertyValues("image:metadata", "image:formatName"), is(new Object[] {"JPEG"}));
+ assertThat(output.getPropertyValues("image:metadata", "image:width"), is(new Object[] {48}));
+ assertThat(output.getPropertyValues("image:metadata", "image:height"), is(new Object[] {48}));
+ assertThat(output.getPropertyValues("image:metadata", "image:bitsPerPixel"), is(new Object[] {24}));
+ assertThat(output.getPropertyValues("image:metadata", "image:progressive"), is(new Object[] {false}));
+ assertThat(output.getPropertyValues("image:metadata", "image:numberOfImages"), is(new Object[] {1}));
+ assertThat(output.getPropertyValues("image:metadata", "image:physicalWidthDpi"), is(new Object[] {72}));
+ assertThat(output.getPropertyValues("image:metadata", "image:physicalHeightDpi"), is(new Object[] {72}));
+ assertThat(((Float)(output.getPropertyValues("image:metadata", "image:physicalWidthInches")[0])).doubleValue(), is(closeTo(0.666667d, 0.0001d)));
+ assertThat(((Float)(output.getPropertyValues("image:metadata", "image:physicalHeightInches")[0])).doubleValue(), is(closeTo(0.666667d, 0.0001d)));
+ assertThat(output.hasReferences(), is(false));
+ }
+
+ @Test
+ public void shouldGenerateMetadataForPngImageFiles() throws IOException {
+ URL url = this.cautionPng;
+ assertThat(url, is(notNullValue()));
+ content = url.openStream();
+ assertThat(content, is(notNullValue()));
+ sequencer.sequence(content, output, progress);
+ assertThat(output.getPropertyValues("image:metadata", "jcr:primaryType"), is(new Object[] {"image:metadata"}));
+ assertThat(output.getPropertyValues("image:metadata", "jcr:mimeType"), is(new Object[] {"image/png"}));
+ assertThat(output.getPropertyValues("image:metadata", "image:formatName"), is(new Object[] {"PNG"}));
+ assertThat(output.getPropertyValues("image:metadata", "image:width"), is(new Object[] {48}));
+ assertThat(output.getPropertyValues("image:metadata", "image:height"), is(new Object[] {48}));
+ assertThat(output.getPropertyValues("image:metadata", "image:bitsPerPixel"), is(new Object[] {24}));
+ assertThat(output.getPropertyValues("image:metadata", "image:progressive"), is(new Object[] {false}));
+ assertThat(output.getPropertyValues("image:metadata", "image:numberOfImages"), is(new Object[] {1}));
+ assertThat(output.getPropertyValues("image:metadata", "image:physicalWidthDpi"), is(new Object[] {-1}));
+ assertThat(output.getPropertyValues("image:metadata", "image:physicalHeightDpi"), is(new Object[] {-1}));
+ assertThat(((Float)(output.getPropertyValues("image:metadata", "image:physicalWidthInches")[0])), is(-1f));
+ assertThat(((Float)(output.getPropertyValues("image:metadata", "image:physicalHeightInches")[0])), is(-1f));
+ assertThat(output.hasReferences(), is(false));
+ }
+
+ @Test
+ public void shouldGenerateMetadataForGifImageFiles() throws IOException {
+ URL url = this.cautionGif;
+ assertThat(url, is(notNullValue()));
+ content = url.openStream();
+ assertThat(content, is(notNullValue()));
+ sequencer.sequence(content, output, progress);
+ assertThat(output.getPropertyValues("image:metadata", "jcr:mimeType"), is(new Object[] {"image/gif"}));
+ assertThat(output.getPropertyValues("image:metadata", "image:formatName"), is(new Object[] {"GIF"}));
+ assertThat(output.getPropertyValues("image:metadata", "image:width"), is(new Object[] {48}));
+ assertThat(output.getPropertyValues("image:metadata", "image:height"), is(new Object[] {48}));
+ assertThat(output.getPropertyValues("image:metadata", "image:bitsPerPixel"), is(new Object[] {8}));
+ assertThat(output.getPropertyValues("image:metadata", "image:progressive"), is(new Object[] {false}));
+ assertThat(output.getPropertyValues("image:metadata", "image:numberOfImages"), is(new Object[] {1}));
+ assertThat(output.getPropertyValues("image:metadata", "image:physicalWidthDpi"), is(new Object[] {-1}));
+ assertThat(output.getPropertyValues("image:metadata", "image:physicalHeightDpi"), is(new Object[] {-1}));
+ assertThat(((Float)(output.getPropertyValues("image:metadata", "image:physicalWidthInches")[0])), is(-1f));
+ assertThat(((Float)(output.getPropertyValues("image:metadata", "image:physicalHeightInches")[0])), is(-1f));
+ assertThat(output.hasReferences(), is(false));
+ }
+
+ @Test
+ public void shouldGenerateNoMetadataforPictImageFiles() throws IOException {
+ URL url = this.cautionPict;
+ assertThat(url, is(notNullValue()));
+ content = url.openStream();
+ assertThat(content, is(notNullValue()));
+ sequencer.sequence(content, output, progress);
+ assertThat(output.hasProperties(), is(false));
+ assertThat(output.hasReferences(), is(false));
+
+ }
+}
Property changes on: trunk/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageSequencerI18nTest.java
===================================================================
--- trunk/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageSequencerI18nTest.java (rev 0)
+++ trunk/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageSequencerI18nTest.java 2008-05-13 18:30:33 UTC (rev 152)
@@ -0,0 +1,13 @@
+package org.jboss.dna.sequencer.images;
+
+import org.jboss.dna.common.AbstractI18nTest;
+
+/**
+ * @author John Verhaeg
+ */
+public class ImageSequencerI18nTest extends AbstractI18nTest {
+
+ public ImageSequencerI18nTest() {
+ super(ImageSequencerI18n.class);
+ }
+}
Property changes on: trunk/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageSequencerI18nTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 12 months
DNA SVN: r151 - trunk/docs/gettingstarted/en.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-05-13 12:00:15 -0400 (Tue, 13 May 2008)
New Revision: 151
Modified:
trunk/docs/gettingstarted/en/master.xml
Log:
Minor edits and word-smithing. Also added a few stubbed sections to the "Creating custom sequencer" chapter.
Modified: trunk/docs/gettingstarted/en/master.xml
===================================================================
--- trunk/docs/gettingstarted/en/master.xml 2008-05-13 15:56:28 UTC (rev 150)
+++ trunk/docs/gettingstarted/en/master.xml 2008-05-13 16:00:15 UTC (rev 151)
@@ -173,7 +173,7 @@
</para>
</chapter>
<chapter id="jboss_dna">
- <title>JBoss DNA</title>
+ <title>Understanding JBoss DNA</title>
<sect1 id="jboss_dna_overview">
<title>Overview</title>
<para>JBoss DNA is a repository and set of tools that make it easy to capture, version, analyze, and understand the
@@ -646,7 +646,7 @@
</para>
</sect2>
<sect2 id="federation_events">
- <title>Observing for changes</title>
+ <title>Observing changes</title>
<para> The JCR API supports observing a repository to receive notifications of additions, changes and deletions of nodes
and properties. The JBoss DNA federated repository will support this API through two primary means.</para>
<para> When the changes are made through the federated repository, the JBoss DNA federation engine is well aware of the
@@ -1547,13 +1547,29 @@
<title>Implementing the StreamSequencer interface</title>
<para></para>
</sect1>
+ <sect1 id="testing_custom_sequencers">
+ <title>Testing custom sequencers</title>
+ <para></para>
+ </sect1>
+ <sect1 id="deploying_custom_sequencers">
+ <title>Deploying custom sequencers</title>
+ <para>At this time, the JAR containing your new sequencer, as well as any JARs that your sequencer depends on, should be placed
+ on your application classpath.</para>
+ <note>
+ <para>A future goal of JBoss DNA is to allow sequencers, connectors and other extensions to be easily deployed into
+ a runtime repository. JBoss DNA will then create and use the appropriate class loaders for each extension.
+ This will prevent the pollution of the common classpath, allow for easy upgrades, enable separation of
+ the extensions in their own environment, and may even allow for hot redeployment of newer versions of extensions.
+ </para>
+ </note>
+ </sect1>
</chapter>
<!-- ====================================================================================================
Chapter
==================================================================================================== -->
<chapter id="future_directions">
- <title>Future Directions</title>
+ <title>Looking to the future</title>
<para>What's next for JBoss DNA? Well, the sequencing system is just the beginning. With this release, the sequencing system
is stable enough so that more <link linkend="sequencers">sequencers</link> can be developed and used within your own applications.
If you're interested in getting involved with the JBoss DNA project, consider picking up one of the sequencers on our
15 years, 12 months
DNA SVN: r150 - trunk/docs/gettingstarted/en.
by dna-commits@lists.jboss.org
Author: jverhaeg(a)redhat.com
Date: 2008-05-13 11:56:28 -0400 (Tue, 13 May 2008)
New Revision: 150
Modified:
trunk/docs/gettingstarted/en/master.xml
Log:
Corrected some grammatical errors and did a little word-smithing.
Modified: trunk/docs/gettingstarted/en/master.xml
===================================================================
--- trunk/docs/gettingstarted/en/master.xml 2008-05-13 15:41:11 UTC (rev 149)
+++ trunk/docs/gettingstarted/en/master.xml 2008-05-13 15:56:28 UTC (rev 150)
@@ -325,7 +325,7 @@
those files to extract meaningful structured information. For example, load DDL files into the repository, and let
sequencers extract the structure and metadata for the database schema. Load Hibernate configuration files into the
repository, and let sequencers extract the schema and mapping information. Load Java source into the repository, and let
- sequencers extract the class structure, JavaDoc, annotations. Load a PNG, JPEG, or other image into the repository, and
+ sequencers extract the class structure, JavaDoc, and annotations. Load a PNG, JPEG, or other image into the repository, and
let sequencers extract the metadata from the image and save it in the repository. The same with XSDs, WSDL, WS policies,
UML, MetaMatrix models, etc.</para>
<para>
@@ -337,8 +337,8 @@
<para>
<emphasis role="strong">Image sequencer</emphasis>
- A sequencer that processes the binary content of an image file, extracts the metadata for the image, and then
- writes that image metadata to the repository. Gets the file format, image resolution, number of bits per pixel and
- optionally number of images, comments and physical resolution from JPEG, GIF, BMP, PCX, PNG, IFF, RAS, PBM, PGM, PPM
+ writes that image metadata to the repository. It gets the file format, image resolution, number of bits per pixel (and
+ optionally number of images), comments and physical resolution from JPEG, GIF, BMP, PCX, PNG, IFF, RAS, PBM, PGM, PPM,
and PSD files. (This sequencer may be improved in the future to also extract EXIF metadata from JPEG files; see
<ulink url="http://jira.jboss.org/jira/browse/DNA-26">DNA-26</ulink>
.)
@@ -353,8 +353,8 @@
<listitem>
<para>
<emphasis role="strong">XML Schema Document (XSD) Sequencer</emphasis>
- - Process XSD files and extract the various elements, attributes, complex types, simple types, and groups. (See
- <ulink url="http://jira.jboss.org/jira/browse/DNA-32">DNA-32</ulink>
+ - Process XSD files and extract the various elements, attributes, complex types, simple types, groups, and other information.
+ (See <ulink url="http://jira.jboss.org/jira/browse/DNA-32">DNA-32</ulink>
)
</para>
</listitem>
@@ -603,7 +603,7 @@
</sect2>
<sect2 id="federation_queries">
<title>Searching and querying</title>
- <para>The JBoss DNA federated repository will also support queries against the integrated and unified graph. In some
+ <para> The JBoss DNA federated repository will also support queries against the integrated and unified graph. In some
situations the query can be determined to apply to a single source, but in most situations the query must be planned
(and possibly rewritten) such that it can be pushed down to all the appropriate sources. Also, the cached results must
be consulted prior to returning the query results, as the results from one source might have contributions from another
15 years, 12 months
DNA SVN: r149 - trunk/docs/gettingstarted/en.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-05-13 11:41:11 -0400 (Tue, 13 May 2008)
New Revision: 149
Modified:
trunk/docs/gettingstarted/en/master.xml
Log:
Reworded the "Querying..." section to include both search and query functionality.
Modified: trunk/docs/gettingstarted/en/master.xml
===================================================================
--- trunk/docs/gettingstarted/en/master.xml 2008-05-13 15:33:43 UTC (rev 148)
+++ trunk/docs/gettingstarted/en/master.xml 2008-05-13 15:41:11 UTC (rev 149)
@@ -105,8 +105,8 @@
<para>
One of the more popular persistence technologies is the
<emphasis>relational database</emphasis>
- . Relational DataBase Management Systems (RDBMS) have been around for decades and are very capable. The Java Database
- Connectivity (JDBC) API provides a standard interface for connecting to and interacting with relational databases. However, it is a
+ . Relational database management systems have been around for decades and are very capable. The Java Database Connectivity
+ (JDBC) API provides a standard interface for connecting to and interacting with relational databases. However, it is a
low-level API that requires a lot of code to use correctly, and it still doesn't abstract away the DBMS-specific SQL
grammar. Also, working with relational data in an object-oriented language can feel somewhat unnatural, so many developers
map this data to classes that fit much more cleanly into their application. The problem is that manually creating this
@@ -602,15 +602,25 @@
</para>
</sect2>
<sect2 id="federation_queries">
- <title>Querying the unified graph</title>
- <para> The JBoss DNA federated repository will also support queries against the integrated and unified graph. In some
+ <title>Searching and querying</title>
+ <para>The JBoss DNA federated repository will also support queries against the integrated and unified graph. In some
situations the query can be determined to apply to a single source, but in most situations the query must be planned
(and possibly rewritten) such that it can be pushed down to all the appropriate sources. Also, the cached results must
be consulted prior to returning the query results, as the results from one source might have contributions from another
source.</para>
+ <note>
<para> It is hoped that the MetaMatrix query engine can be used for this purpose, after it is open sourced. This engine
implements sophisticated query planning and optimization techniques for working efficiently with multiple sources.
</para>
+ </note>
+ <para>Searching the whole federated repository is also important. This allows users to simply supply a handful of search
+ terms, and to get results that are ranked based upon how close each result is to the search terms. (Searching is very
+ different from querying, which involves specifying the exact semantics of what is to be searched and how the information
+ is to be compared.) JBoss DNA will incorporate a search
+ engine (e.g., likely to be Lucene) and will populate the engine's indexes using the federated content and the cached
+ information. Notifications of changing information will be reflected in the indexes, but some sources may want to explicitly
+ allow or disallow periodic crawling of their content.
+ </para>
</sect2>
<sect2 id="federation_updates">
<title>Updating content</title>
15 years, 12 months
DNA SVN: r148 - trunk/docs/gettingstarted/en.
by dna-commits@lists.jboss.org
Author: jverhaeg(a)redhat.com
Date: 2008-05-13 11:33:43 -0400 (Tue, 13 May 2008)
New Revision: 148
Modified:
trunk/docs/gettingstarted/en/master.xml
Log:
Corrected some grammatical errors and did a little word-smithing.
Modified: trunk/docs/gettingstarted/en/master.xml
===================================================================
--- trunk/docs/gettingstarted/en/master.xml 2008-05-13 15:21:46 UTC (rev 147)
+++ trunk/docs/gettingstarted/en/master.xml 2008-05-13 15:33:43 UTC (rev 148)
@@ -105,8 +105,8 @@
<para>
One of the more popular persistence technologies is the
<emphasis>relational database</emphasis>
- . Relational database management systems (RDBMS) have been around for decades and are very capable. The Java Database Connectivity
- (JDBC) API provides a standard interface for connecting to and interacting with relational databases. However, it is a
+ . Relational DataBase Management Systems (RDBMS) have been around for decades and are very capable. The Java Database
+ Connectivity (JDBC) API provides a standard interface for connecting to and interacting with relational databases. However, it is a
low-level API that requires a lot of code to use correctly, and it still doesn't abstract away the DBMS-specific SQL
grammar. Also, working with relational data in an object-oriented language can feel somewhat unnatural, so many developers
map this data to classes that fit much more cleanly into their application. The problem is that manually creating this
@@ -148,9 +148,9 @@
is building the tools and services that surround content repositories. Nearly all of these capabilities are to be hidden
below the JCR API and involve automated processing of the information in the repository. Thus, JBoss DNA can add value to
existing repository implementations. For example, JCR repositories offer the ability to upload files into the repository and
- have the file content index for search purposes. JBoss DNA defines a library for also sequencing that content to extract
- meaningful information and store it in the repository, where it can then be searched, accessed and analyzed using the JCR
- API.
+ have the file content indexed for search purposes. JBoss DNA also defines a library for "sequencing" content - to extract
+ meaningful information from that content and store it in the repository, where it can then be searched, accessed, and analyzed
+ using the JCR API.
</para>
<para> JBoss DNA is building other features as well. One goal of JBoss DNA is to create federated repositories that
dynamically merge the information from multiple databases, services, applications, and other JCR repositories. Another is to
@@ -169,7 +169,7 @@
<link linkend="custom_sequencers">Chapter 5</link>
goes over how to create custom sequencers. Finally,
<link linkend="future_directions">Chapter 6</link>
- wraps things up.
+ wraps things up with a discussion about the future of JBoss DNA.
</para>
</chapter>
<chapter id="jboss_dna">
@@ -194,7 +194,7 @@
<title>Architecture</title>
<para>The architecture for JBoss DNA consists of several major components that will be built on top of standard APIs,
including JCR, JDBC, JNDI and HTTP. The goal is to allow these components to be assembled as needed and add value on top
- of other DNA components or third-party systems that support the standard APIs.</para>
+ of other DNA components or third-party systems that support these standard APIs.</para>
<mediaobject>
<imageobject role="fo">
<imagedata align="center" fileref="images/dna-architecture.png" />
@@ -230,23 +230,23 @@
is used by end users and domain experts to visualize, search, edit, change and tag the repository content. The web
application uses views to define how different types of information are to be presented and edited in
domain-specific ways. The goal is that this web application is easily customized and branded for inclusion into
- other solutions and application systems. The DNA Web Application operate upon any JCR-compliant repository, although
+ other solutions and application systems. The DNA Web Application operates upon any JCR-compliant repository, although
it does rely upon the DNA analysis and templating services.
</para>
</listitem>
<listitem>
<para>
<emphasis role="strong">DNA Publishing Server</emphasis>
- allows content to be downloaded, uploaded and edited using the Atom Publishing Protocol. With the DNA Publishing
- Server, the content of the repository can easily be created, read, edited and deleted using the standard HTTP
- operations of POST, GET, PUT and DELETE (respectively). More and more tools are being created that support working
+ allows content to be downloaded, uploaded, and edited using the Atom Publishing Protocol. With the DNA Publishing
+ Server, the content of the repository can easily be created, read, edited, and deleted using the standard HTTP
+ operations of POST, GET, PUT, and DELETE (respectively). More and more tools are being created that support working
with Atom Publishing servers. The DNA Publishing Server operates upon any JCR-compliant repository.
</para>
</listitem>
<listitem>
<para>
<emphasis role="strong">DNA WebDAV Server</emphasis>
- allows clients such as Microsoft Windows and Apple OS X to connect to, read and edit the content in the repository
+ allows clients such as Microsoft Windows and Apple OS X to connect to, read, and edit the content in the repository
using the WebDAV standard. Since WebDAV is an extension of HTTP, web browsers are able to read (but not modify) the
content served by a WebDAV compliant server. The DNA WebDAV Server operates upon any JCR-compliant repository.
</para>
@@ -263,7 +263,7 @@
<listitem>
<para>
<emphasis role="strong">DNA Analyses</emphasis>
- are pluggable components that analyze the content and the relationships between the content to generate reports or
+ are pluggable components that analyze content and the relationships between content to generate reports or
to answer queries. DNA will include some standard analyzers, like dependency analysis and similarity analysis, that
are commonly needed by many different solutions. DNA analyzers operate upon any JCR-compliant repository.
</para>
@@ -280,7 +280,7 @@
<para>
<emphasis role="strong">DNA Federation</emphasis>
is an implementation of the JCR API that builds the content within the repository by accessing and integrating
- information from multiple sources. DNA Federation allows the integration of external system, like other JCR
+ information from multiple sources. DNA Federation allows the integration of external systems, like other JCR
repositories, databases, applications, and services.
</para>
</listitem>
15 years, 12 months
DNA SVN: r147 - trunk/docs/gettingstarted/en.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-05-13 11:21:46 -0400 (Tue, 13 May 2008)
New Revision: 147
Modified:
trunk/docs/gettingstarted/en/master.xml
Log:
Changed the chapter and section titles to be consistently action-oriented.
Modified: trunk/docs/gettingstarted/en/master.xml
===================================================================
--- trunk/docs/gettingstarted/en/master.xml 2008-05-13 15:14:22 UTC (rev 146)
+++ trunk/docs/gettingstarted/en/master.xml 2008-05-13 15:21:46 UTC (rev 147)
@@ -105,8 +105,8 @@
<para>
One of the more popular persistence technologies is the
<emphasis>relational database</emphasis>
- . Relational DataBase Management Systems (RDBMS) have been around for decades and are very capable. The Java Database
- Connectivity (JDBC) API provides a standard interface for connecting to and interacting with relational databases. However, it is a
+ . Relational database management systems (RDBMS) have been around for decades and are very capable. The Java Database Connectivity
+ (JDBC) API provides a standard interface for connecting to and interacting with relational databases. However, it is a
low-level API that requires a lot of code to use correctly, and it still doesn't abstract away the DBMS-specific SQL
grammar. Also, working with relational data in an object-oriented language can feel somewhat unnatural, so many developers
map this data to classes that fit much more cleanly into their application. The problem is that manually creating this
@@ -317,7 +317,7 @@
</para>
</sect1>
<sect1 id="sequencers">
- <title>Sequencers</title>
+ <title>Sequencing content</title>
<para> The current JBoss DNA release contains a sequencing framework that is designed to sequence data (typically files)
stored in a JCR repository to automatically extract meaningful and useful information. This additional information is then
saved back into the repository, where it can be accessed and used.</para>
@@ -463,7 +463,7 @@
</para>
</sect1>
<sect1 id="federation">
- <title>Federation</title>
+ <title>Federating content</title>
<para>There is a lot of information stored in many of different places: databases, repositories, SCM systems,
registries, file systems, services, etc. The purpose of the federation engine is to allow applications to use the JCR API
to access that information as if it were all stored in a single JCR repository, but to really leave the information where
@@ -486,7 +486,7 @@
configured to allow updates, client applications can change the information in the repository and JBoss DNA will propagate
those changes down to the original source.</para>
<sect2 id="federation_connectors">
- <title>Connectors</title>
+ <title>Connecting to information sources</title>
<para>
The JBoss DNA federation engine will use connectors to interact with different information sources to get at the content
in those systems. Some ideas for connectors include:
@@ -563,13 +563,10 @@
implementation that can be used with a Java Transaction Service. Connectors that provide read-only access need not
provide an implementation.
</para>
- </sect2>
- <sect2 id="federation_sources">
- <title>Sources</title>
<para>
- Each JBoss DNA federated repository is configured to federate and integrate information from one or more
- <emphasis>sources</emphasis>
- . Each source contains the configuration details (e.g., connection information, location, properties, options, etc.) for
+ Also, connectors talk to <emphasis>sources</emphasis> of information, and it's quite likely that the same
+ connector is used to talk to different sources. Each source contains the configuration details
+ (e.g., connection information, location, properties, options, etc.) for
working with that particular source, as well as a reference to the connector that should be used to establish
connections to the source. And of course, sources can be added or removed without having to stop and restart the
federated repository.
@@ -605,7 +602,7 @@
</para>
</sect2>
<sect2 id="federation_queries">
- <title>Queries</title>
+ <title>Querying the unified graph</title>
<para> The JBoss DNA federated repository will also support queries against the integrated and unified graph. In some
situations the query can be determined to apply to a single source, but in most situations the query must be planned
(and possibly rewritten) such that it can be pushed down to all the appropriate sources. Also, the cached results must
@@ -616,7 +613,7 @@
</para>
</sect2>
<sect2 id="federation_updates">
- <title>Updates</title>
+ <title>Updating content</title>
<para>
The JBoss DNA federated repositories also make it possible for client applications to make changes to the unified graph
within the context of distributed transactions. According to the JCR API, client applications use the Java Transaction
@@ -639,7 +636,7 @@
</para>
</sect2>
<sect2 id="federation_events">
- <title>Events</title>
+ <title>Observing for changes</title>
<para> The JCR API supports observing a repository to receive notifications of additions, changes and deletions of nodes
and properties. The JBoss DNA federated repository will support this API through two primary means.</para>
<para> When the changes are made through the federated repository, the JBoss DNA federation engine is well aware of the
@@ -657,7 +654,7 @@
Chapter
==================================================================================================== -->
<chapter id="downloading_and_running">
- <title>Example application</title>
+ <title>Running the example application</title>
<para>
This chapter provides instructions for downloading and running a sample application that demonstrates how JBoss DNA works
with a JCR repository to automatically sequence changing content to extract useful information. So read on to get the simple
@@ -973,7 +970,7 @@
that we'll describe later) will not be sequenced.</para>
</sect1>
<sect1 id="downloading_and_running_review">
- <title>Review</title>
+ <title>Summarizing what we just did</title>
<para>In this chapter you downloaded and installed the example application and used it to upload files into a
JCR repository. JBoss DNA automatically sequenced the image files you uploaded, extracted the metadata from the
files, and stored that metadata inside the repository. The application allowed you to see this metadata
@@ -1000,7 +997,7 @@
JCR implementation.</para>
</note>
<sect1 id="sequencing_service">
- <title>Sequencing Service</title>
+ <title>Configuring the Sequencing Service</title>
<para>
The JBoss DNA <emphasis>sequencing service</emphasis> is the component that manages the <emphasis>sequencers</emphasis>
and that reacts to changes in JCR repositories and then running the appropriate sequencers.
@@ -1117,7 +1114,7 @@
described in the <link linkend="observation_service">next section</link>.</para>
</sect1>
<sect1 id="observation_service">
- <title>Observation Service</title>
+ <title>Configuring the Observation Service</title>
<para>The JBoss DNA <code>ObservationService</code> is responsible for listening to one or more JCR repositories
and multiplexing the events to its listeners. Unlike JCR events, this framework embeds in the events the
name of the repository and workspace that can be passed to a <code>SessionFactory</code> to obtain a session
@@ -1169,7 +1166,7 @@
The next chapter goes back to the <link linkend="downloading_and_running">sample application</link> to show how all these pieces fit together.</para>
</sect1>
<sect1 id="example_application_review">
- <title>Example Application</title>
+ <title>Reviewing the example application</title>
<para>Recall that the example application consists of a client application that sets up an in-memory JCR repository and
that allows a user to upload files into that repository. The client also sets up the DNA services with an image sequencer so
that if any of the uploaded files are PNG, JPEG, GIF, BMP or other images, DNA will automatically extract the image's
@@ -1410,7 +1407,7 @@
</para>
</sect1>
<sect1 id="using_dna_review">
- <title>Review</title>
+ <title>Summarizing what we just did</title>
<para>In this chapter we covered the different JBoss DNA components and how they can be used in your application.
Specifically, we described how the <code>SequencingService</code> and <code>ObservationService</code> can
be configured and used. And we ended the chapter by reviewing the example application, which not only uses
@@ -1423,7 +1420,7 @@
Chapter
==================================================================================================== -->
<chapter id="custom_sequencers">
- <title>Custom sequencers</title>
+ <title>Creating custom sequencers</title>
<para>The current release of JBoss DNA comes with a single sequencer that extracts metadata from image files.
If you create your own sequencer implementation,
</para>
@@ -1546,7 +1543,7 @@
Chapter
==================================================================================================== -->
<chapter id="future_directions">
- <title>Future directions</title>
+ <title>Future Directions</title>
<para>What's next for JBoss DNA? Well, the sequencing system is just the beginning. With this release, the sequencing system
is stable enough so that more <link linkend="sequencers">sequencers</link> can be developed and used within your own applications.
If you're interested in getting involved with the JBoss DNA project, consider picking up one of the sequencers on our
15 years, 12 months
DNA SVN: r146 - trunk/docs/gettingstarted/en.
by dna-commits@lists.jboss.org
Author: jverhaeg(a)redhat.com
Date: 2008-05-13 11:14:22 -0400 (Tue, 13 May 2008)
New Revision: 146
Modified:
trunk/docs/gettingstarted/en/Legal_Notice.xml
trunk/docs/gettingstarted/en/master.xml
Log:
Corrected some grammatical errors and did a little word-smithing.
Modified: trunk/docs/gettingstarted/en/Legal_Notice.xml
===================================================================
--- trunk/docs/gettingstarted/en/Legal_Notice.xml 2008-05-12 20:12:29 UTC (rev 145)
+++ trunk/docs/gettingstarted/en/Legal_Notice.xml 2008-05-13 15:14:22 UTC (rev 146)
@@ -36,7 +36,7 @@
</address>
</para>
<para>
- Copyright <trademark class="copyright"/> 2007 by Red Hat, Inc. This copyrighted material is made available to
+ Copyright <trademark class="copyright"/> 2008 by Red Hat, Inc. This copyrighted material is made available to
anyone wishing to use, modify, copy, or redistribute it subject to the terms and conditions of the
GNU <ulink url="http://www.gnu.org/licenses/lgpl-2.1.html">Lesser General Public License</ulink>, as published
by the Free Software Foundation.
Modified: trunk/docs/gettingstarted/en/master.xml
===================================================================
--- trunk/docs/gettingstarted/en/master.xml 2008-05-12 20:12:29 UTC (rev 145)
+++ trunk/docs/gettingstarted/en/master.xml 2008-05-13 15:14:22 UTC (rev 146)
@@ -60,7 +60,7 @@
<para>The goal of this book is to help you learn about JBoss DNA and how you can use it in your own applications to get the
most out of your JCR repositories.</para>
<para>The first part of the book starts out with an introduction to content repositories and an overview of the JCR API,
- both of which are an important aspect of JBoss DNA. This is followed by an overview of the JBoss DNA project, it's
+ both of which are important aspects of JBoss DNA. This is followed by an overview of the JBoss DNA project, its
architecture, and a basic roadmap for what's coming next.</para>
<para>The next part of the book covers how to download and build the examples, how to use JBoss DNA with existing
repositories, and how to build and use custom sequencers.</para>
@@ -82,8 +82,8 @@
<chapter id="introduction">
<title>Introduction</title>
<para>There are a lot of choices for how applications can store information persistently so that it can be accessed at a
- later time and by other processes. The challenge developers face is to use an approach that most closely matches the needs
- of their application. This choice is more important as developers choose to focus their efforts on the application-specific
+ later time and by other processes. The challenge developers face is how to use an approach that most closely matches the needs
+ of their application. This choice becomes more important as developers choose to focus their efforts on application-specific
logic, delegating much of the responsibilities for persistence to libraries and frameworks.</para>
<para>
Perhaps one of the easiest techniques is to simply store information in
@@ -92,21 +92,21 @@
using files is an easy choice when the information is either not complicated (for example property files), or when users may
need to read or change the information outside of the application (for example log files or configuration files). But using
files to persist information becomes more difficult as the information becomes more complex, as the volume of it increases,
- or if it needs to be accessed by multiple processes. For these situations, other techniques are often a better choice.
+ or if it needs to be accessed by multiple processes. For these situations, other techniques often offer better choices.
</para>
<para>
Another technique built into the Java language is
<emphasis>Java serialization</emphasis>
, which is capable of persisting the state of an object graph so that it can be read back in at a later time. However, Java
- serialization can quickly become tricky if the classes are changed, and so its beneficial usually when the information is
+ serialization can quickly become tricky if the classes are changed, and so it's beneficial usually when the information is
persisted for a very short period of time. For example, serialization is sometimes used to send an object graph from one
process to another.
</para>
<para>
One of the more popular persistence technologies is the
<emphasis>relational database</emphasis>
- . Relational database management systems have been around for decades and are very capable. The Java Database Connectivity
- (JDBC) API provides a standard interface for connecting to and interacting with relational databases. However, it is a
+ . Relational DataBase Management Systems (RDBMS) have been around for decades and are very capable. The Java Database
+ Connectivity (JDBC) API provides a standard interface for connecting to and interacting with relational databases. However, it is a
low-level API that requires a lot of code to use correctly, and it still doesn't abstract away the DBMS-specific SQL
grammar. Also, working with relational data in an object-oriented language can feel somewhat unnatural, so many developers
map this data to classes that fit much more cleanly into their application. The problem is that manually creating this
@@ -114,8 +114,8 @@
</para>
<para>
<emphasis>Object-relational mapping</emphasis>
- libraries automate the creation of this mapping layer and result in far less code that is much more maintainable with often
- as good (if not better) performance than handwritten JDBC code. The new
+ libraries automate the creation of this mapping layer and result in far less code that is much more maintainable with performance
+ that is often as good as (if not better than) handwritten JDBC code. The new
<ulink url="http://java.sun.com/developer/technicalArticles/J2EE/jpa/">Java Persistence API (JPA)</ulink>
provide a standard mechanism for defining the mappings (through annotations) and working with these entity objects. Several
commercial and open-source libraries implement JPA, and some even offer additional capabilities and features that go beyond
@@ -126,11 +126,11 @@
</para>
<para>
While relational databases and JPA are solutions that work for many applications, they become more limited in cases when the
- information structure is highly flexible, is not known a priori, or is subject to frequent change and customization. In
- these situations,
+ information structure is highly flexible, is not known <emphasis>a priori</emphasis>, or is subject to frequent change and
+ customization. In these situations,
<emphasis>content repositories</emphasis>
may offer a better choice for persistence. Content repositories are almost a hybrid between relational databases and file
- systems, and typically provide other capabilies as well, including versioning, indexing, search, access control,
+ systems, and typically provide other capabilities as well, including versioning, indexing, search, access control,
transactions, and observation. Because of this, content repositories are used by content management systems (CMS), document
management systems (DMS), and other applications that manage electronic files (e.g., documents, images, multi-media, web
content, etc.) and metadata associated with them (e.g., author, date, status, security information, etc.). The
@@ -145,7 +145,7 @@
<para>
The
<emphasis>JBoss DNA project</emphasis>
- is building the tooles and services that surround content repositories. Nearly all of these capabilities are to be hidden
+ is building the tools and services that surround content repositories. Nearly all of these capabilities are to be hidden
below the JCR API and involve automated processing of the information in the repository. Thus, JBoss DNA can add value to
existing repository implementations. For example, JCR repositories offer the ability to upload files into the repository and
have the file content index for search purposes. JBoss DNA defines a library for also sequencing that content to extract
15 years, 12 months
DNA SVN: r145 - in trunk: dna-common and 36 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-05-12 16:12:29 -0400 (Mon, 12 May 2008)
New Revision: 145
Added:
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/MediaInfo.java
trunk/docs/examples/gettingstarted/sequencers/src/test/resources/sample1.mp3
trunk/sequencers/dna-sequencer-mp3/
trunk/sequencers/dna-sequencer-mp3/.classpath
trunk/sequencers/dna-sequencer-mp3/.project
trunk/sequencers/dna-sequencer-mp3/pom.xml
trunk/sequencers/dna-sequencer-mp3/src/
trunk/sequencers/dna-sequencer-mp3/src/main/
trunk/sequencers/dna-sequencer-mp3/src/main/java/
trunk/sequencers/dna-sequencer-mp3/src/main/java/org/
trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/
trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/
trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/
trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/
trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3Metadata.java
trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3MetadataSequencer.java
trunk/sequencers/dna-sequencer-mp3/src/main/resources/
trunk/sequencers/dna-sequencer-mp3/src/main/resources/org/
trunk/sequencers/dna-sequencer-mp3/src/main/resources/org/jboss/
trunk/sequencers/dna-sequencer-mp3/src/main/resources/org/jboss/dna/
trunk/sequencers/dna-sequencer-mp3/src/main/resources/org/jboss/dna/sequencer/
trunk/sequencers/dna-sequencer-mp3/src/main/resources/org/jboss/dna/sequencer/mp3/
trunk/sequencers/dna-sequencer-mp3/src/main/resources/org/jboss/dna/sequencer/mp3/mp3.cnd
trunk/sequencers/dna-sequencer-mp3/src/test/
trunk/sequencers/dna-sequencer-mp3/src/test/java/
trunk/sequencers/dna-sequencer-mp3/src/test/java/org/
trunk/sequencers/dna-sequencer-mp3/src/test/java/org/jboss/
trunk/sequencers/dna-sequencer-mp3/src/test/java/org/jboss/dna/
trunk/sequencers/dna-sequencer-mp3/src/test/java/org/jboss/dna/sequencer/
trunk/sequencers/dna-sequencer-mp3/src/test/java/org/jboss/dna/sequencer/mp3/
trunk/sequencers/dna-sequencer-mp3/src/test/java/org/jboss/dna/sequencer/mp3/Mp3MetadataTest.java
trunk/sequencers/dna-sequencer-mp3/src/test/resources/
trunk/sequencers/dna-sequencer-mp3/src/test/resources/sample1.mp3
Removed:
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/ImageInfo.java
trunk/docs/examples/gettingstarted/sequencers/src/test/resources/log4j.properties
Modified:
trunk/dna-common/
trunk/dna-common/pom.xml
trunk/dna-integration-tests/
trunk/dna-maven-classloader/
trunk/dna-maven-classloader/pom.xml
trunk/dna-repository/
trunk/dna-repository/pom.xml
trunk/dna-spi/
trunk/dna-spi/pom.xml
trunk/docs/examples/gettingstarted/sequencers/pom.xml
trunk/docs/examples/gettingstarted/sequencers/src/main/assembly/basic.xml
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/ConsoleInput.java
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/UserInterface.java
trunk/docs/examples/gettingstarted/sequencers/src/main/resources/jackrabbitNodeTypes.cnd
trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/MockUserInterface.java
trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/SequencingClientTest.java
trunk/pom.xml
trunk/sequencers/dna-sequencer-images/
trunk/sequencers/dna-sequencer-images/pom.xml
trunk/sequencers/dna-sequencer-images/src/main/resources/org/jboss/dna/sequencer/images/images.cnd
Log:
Added dna-sequencer-mp3
Property changes on: trunk/dna-common
___________________________________________________________________
Name: svn:ignore
- target
+ .settings
target
Modified: trunk/dna-common/pom.xml
===================================================================
--- trunk/dna-common/pom.xml 2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/dna-common/pom.xml 2008-05-12 20:12:29 UTC (rev 145)
@@ -1,4 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?><project>
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
<groupId>org.jboss.dna</groupId>
Property changes on: trunk/dna-integration-tests
___________________________________________________________________
Name: svn:ignore
- target
+ .settings
target
Property changes on: trunk/dna-maven-classloader
___________________________________________________________________
Name: svn:ignore
- target
+ .settings
target
Modified: trunk/dna-maven-classloader/pom.xml
===================================================================
--- trunk/dna-maven-classloader/pom.xml 2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/dna-maven-classloader/pom.xml 2008-05-12 20:12:29 UTC (rev 145)
@@ -1,4 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?><project>
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
<groupId>org.jboss.dna</groupId>
Property changes on: trunk/dna-repository
___________________________________________________________________
Name: svn:ignore
- target
+ .settings
target
Modified: trunk/dna-repository/pom.xml
===================================================================
--- trunk/dna-repository/pom.xml 2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/dna-repository/pom.xml 2008-05-12 20:12:29 UTC (rev 145)
@@ -1,4 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?><project>
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
<groupId>org.jboss.dna</groupId>
Property changes on: trunk/dna-spi
___________________________________________________________________
Name: svn:ignore
- target
+ .settings
target
Modified: trunk/dna-spi/pom.xml
===================================================================
--- trunk/dna-spi/pom.xml 2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/dna-spi/pom.xml 2008-05-12 20:12:29 UTC (rev 145)
@@ -1,4 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?><project>
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
<groupId>org.jboss.dna</groupId>
Modified: trunk/docs/examples/gettingstarted/sequencers/pom.xml
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/pom.xml 2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/docs/examples/gettingstarted/sequencers/pom.xml 2008-05-12 20:12:29 UTC (rev 145)
@@ -1,5 +1,5 @@
-<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">
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<parent>
<groupId>org.jboss.dna.examples</groupId>
@@ -73,6 +73,11 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-sequencer-mp3</artifactId>
+ <version>0.1-SNAPSHOT</version>
+ </dependency>
</dependencies>
<build>
Modified: trunk/docs/examples/gettingstarted/sequencers/src/main/assembly/basic.xml
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/assembly/basic.xml 2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/assembly/basic.xml 2008-05-12 20:12:29 UTC (rev 145)
@@ -20,6 +20,7 @@
<include>*.gif</include>
<include>*.jpg</include>
<include>*.pict</include>
+ <include>*.mp3</include>
</includes>
</fileSet>
</fileSets>
Modified: trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/ConsoleInput.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/ConsoleInput.java 2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/ConsoleInput.java 2008-05-12 20:12:29 UTC (rev 145)
@@ -171,24 +171,25 @@
return path;
}
- public void displaySearchResults( List<ImageInfo> images ) {
+ public void displaySearchResults( List<MediaInfo> medias ) {
System.out.println();
- if (images.isEmpty()) {
+ if (medias.isEmpty()) {
System.out.println("No results were found.");
System.out.println();
return;
}
- if (images.size() == 1) {
+ if (medias.size() == 1) {
System.out.println("1 image was found:");
} else {
- System.out.println("" + images.size() + " images were found:");
+ System.out.println("" + medias.size() + " images were found:");
}
int counter = 1;
- for (ImageInfo image : images) {
- System.out.println(" Image " + counter++);
- System.out.println(" Name: " + image.getName());
- System.out.println(" Path: " + image.getPath());
- for (Map.Entry<Object, Object> entry : image.getProperties().entrySet()) {
+ for (MediaInfo media : medias) {
+ System.out.println(" Media " + counter++);
+ System.out.println(" Name: " + media.getName());
+ System.out.println(" Path: " + media.getPath());
+ System.out.println(" Type: " + media.getMediaType());
+ for (Map.Entry<Object, Object> entry : media.getProperties().entrySet()) {
System.out.println(" " + entry.getKey() + ": " + entry.getValue());
}
}
Deleted: trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/ImageInfo.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/ImageInfo.java 2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/ImageInfo.java 2008-05-12 20:12:29 UTC (rev 145)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.example.dna.sequencers;
-
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * @author Randall Hauch
- */
-public class ImageInfo {
-
- private final Properties properties = new Properties();
- private final String name;
- private final String path;
-
- protected ImageInfo( String path, String name, Properties props ) {
- this.name = name;
- this.path = path;
- if (props != null) this.properties.putAll(props);
- }
-
- public String getName() {
- return this.name;
- }
-
- public String getPath() {
- return this.path;
- }
-
- public Properties getProperties() {
- return this.properties;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- boolean first = true;
- for (Map.Entry<Object, Object> entry : this.properties.entrySet()) {
- sb.append(entry.getKey()).append("=>").append(entry.getValue());
- if (first) {
- first = false;
- } else {
- sb.append(", ");
- }
- }
- return this.name + " (at " + this.path + ") with properties {" + sb.toString() + "}";
- }
-
-}
Added: trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/MediaInfo.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/MediaInfo.java (rev 0)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/MediaInfo.java 2008-05-12 20:12:29 UTC (rev 145)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.example.dna.sequencers;
+
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * @author Randall Hauch
+ */
+public class MediaInfo {
+
+ private final Properties properties = new Properties();
+ private final String name;
+ private final String path;
+ private final String mediaType;
+
+ protected MediaInfo( String path, String name, String mediaType, Properties props ) {
+ this.name = name;
+ this.path = path;
+ this.mediaType = mediaType;
+ if (props != null) this.properties.putAll(props);
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public String getPath() {
+ return this.path;
+ }
+
+ public String getMediaType() {
+ return this.mediaType;
+ }
+
+ public Properties getProperties() {
+ return this.properties;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ boolean first = true;
+ for (Map.Entry<Object, Object> entry : this.properties.entrySet()) {
+ sb.append(entry.getKey()).append("=>").append(entry.getValue());
+ if (first) {
+ first = false;
+ } else {
+ sb.append(", ");
+ }
+ }
+ return this.name + " (at " + this.path + ") of type \"" + this.mediaType + "\" with properties {" + sb.toString() + "}";
+ }
+
+}
Modified: trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java 2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java 2008-05-12 20:12:29 UTC (rev 145)
@@ -31,6 +31,7 @@
import javax.jcr.Credentials;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
+import javax.jcr.PathNotFoundException;
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
import javax.jcr.Repository;
@@ -38,6 +39,7 @@
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
import javax.jcr.observation.Event;
import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
import org.apache.jackrabbit.core.TransientRepository;
@@ -210,8 +212,9 @@
this.sequencingService = new SequencingService();
this.sequencingService.setExecutionContext(executionContext);
- // Configure the sequencers. In this example, we only use a single sequencer that processes image files.
- // So create a configuration. Note that the sequencing service expects the class to be on the thread's current context
+ // Configure the sequencers. In this example, we only two sequencers that processes image and mp3 files.
+ // So create a configurations. Note that the sequencing service expects the class to be on the thread's current
+ // context
// classloader, or if that's null the classloader that loaded the SequencingService class.
//
// Part of the configuration includes telling DNA which JCR paths should be processed by the sequencer.
@@ -231,6 +234,13 @@
SequencerConfig imageSequencerConfig = new SequencerConfig(name, desc, classname, classpath, pathExpressions);
this.sequencingService.addSequencer(imageSequencerConfig);
+ name = "Mp3 Sequencer";
+ desc = "Sequences mp3 files to extract the id3 tags of the audio file";
+ classname = "org.jboss.dna.sequencer.mp3.Mp3MetadataSequencer";
+ String[] mp3PathExpressions = {"//(*.(mp3))[*]/jcr:content[@jcr:data] => /mp3s/$1"};
+ SequencerConfig mp3SequencerConfig = new SequencerConfig(name, desc, classname, classpath, mp3PathExpressions);
+ this.sequencingService.addSequencer(mp3SequencerConfig);
+
// Use the DNA observation service to listen to the JCR repository (or multiple ones), and
// then register the sequencing service as a listener to this observation service...
this.observationService = new ObservationService(this.executionContext.getSessionFactory());
@@ -303,59 +313,84 @@
*/
public void search() throws Exception {
// Use JCR to search the repository for image metadata ...
- List<ImageInfo> images = new ArrayList<ImageInfo>();
+ List<MediaInfo> medias = new ArrayList<MediaInfo>();
Session session = createSession();
try {
// Find the image node ...
Node root = session.getRootNode();
- if (root.hasNode("images")) {
- Node imagesNode = root.getNode("images");
- // Iterate over each child ...
- for (NodeIterator iter = imagesNode.getNodes(); iter.hasNext();) {
- Node imageNode = iter.nextNode();
- String nodePath = imageNode.getPath();
- String nodeName = imageNode.getName();
- if (imageNode.hasNode("image:metadata")) {
- imageNode = imageNode.getNode("image:metadata");
+ if (root.hasNode("images") || root.hasNode("mp3s")) {
+ Node mediasNode;
+ if (root.hasNode("images")) {
+ mediasNode = root.getNode("images");
- // Create a Properties object containing the properties for this node; ignore any children ...
- Properties props = new Properties();
- for (PropertyIterator propertyIter = imageNode.getProperties(); propertyIter.hasNext();) {
- Property property = propertyIter.nextProperty();
- String name = property.getName();
- String stringValue = null;
- if (property.getDefinition().isMultiple()) {
- StringBuilder sb = new StringBuilder();
- boolean first = true;
- for (Value value : property.getValues()) {
- if (!first) {
- sb.append(", ");
- first = false;
- }
- sb.append(value.getString());
- }
- stringValue = sb.toString();
- } else {
- stringValue = property.getValue().getString();
- }
- props.put(name, stringValue);
+ for (NodeIterator iter = mediasNode.getNodes(); iter.hasNext();) {
+ Node mediaNode = iter.nextNode();
+ if (mediaNode.hasNode("image:metadata")) {
+ medias.add(extractMediaInfo("image:metadata", "image", mediaNode));
}
- // Create the image information object, and add it to the collection ...
- ImageInfo info = new ImageInfo(nodePath, nodeName, props);
- images.add(info);
}
}
+ if (root.hasNode("mp3s")) {
+ mediasNode = root.getNode("mp3s");
+
+ for (NodeIterator iter = mediasNode.getNodes(); iter.hasNext();) {
+ Node mediaNode = iter.nextNode();
+ if (mediaNode.hasNode("mp3:metadata")) {
+ medias.add(extractMediaInfo("mp3:metadata", "mp3", mediaNode));
+ }
+ }
+ }
+
}
} finally {
session.logout();
}
// Display the search results ...
- this.userInterface.displaySearchResults(images);
+ this.userInterface.displaySearchResults(medias);
}
/**
+ * @param metadataNodeName
+ * @param mediaType
+ * @param mediaNode media node
+ * @throws RepositoryException
+ * @throws PathNotFoundException
+ * @throws ValueFormatException
+ */
+ private MediaInfo extractMediaInfo( String metadataNodeName, String mediaType, Node mediaNode ) throws RepositoryException, PathNotFoundException, ValueFormatException {
+ String nodePath = mediaNode.getPath();
+ String nodeName = mediaNode.getName();
+ mediaNode = mediaNode.getNode(metadataNodeName);
+
+ // Create a Properties object containing the properties for this node; ignore any children ...
+ Properties props = new Properties();
+ for (PropertyIterator propertyIter = mediaNode.getProperties(); propertyIter.hasNext();) {
+ Property property = propertyIter.nextProperty();
+ String name = property.getName();
+ String stringValue = null;
+ if (property.getDefinition().isMultiple()) {
+ StringBuilder sb = new StringBuilder();
+ boolean first = true;
+ for (Value value : property.getValues()) {
+ if (!first) {
+ sb.append(", ");
+ first = false;
+ }
+ sb.append(value.getString());
+ }
+ stringValue = sb.toString();
+ } else {
+ stringValue = property.getValue().getString();
+ }
+ props.put(name, stringValue);
+ }
+ // Create the image information object, and add it to the collection ...
+ return new MediaInfo(nodePath, nodeName, mediaType, props);
+ }
+
+ /**
* Utility method to create a new JCR session from the execution context's {@link SessionFactory}.
* @return the session
* @throws RepositoryException
@@ -374,6 +409,7 @@
if (filename.endsWith(".jpe")) return "image/jpeg";
if (filename.endsWith(".jpeg")) return "image/jpeg";
if (filename.endsWith(".ras")) return "image/x-cmu-raster";
+ if (filename.endsWith(".mp3")) return "audio/mpeg";
throw new SystemFailureException("Unknown mime type for " + file);
}
Modified: trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/UserInterface.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/UserInterface.java 2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/UserInterface.java 2008-05-12 20:12:29 UTC (rev 145)
@@ -34,5 +34,5 @@
public String getRepositoryPath( String defaultPath ) throws IllegalArgumentException, IOException;
- public void displaySearchResults( List<ImageInfo> images ) throws IOException;
+ public void displaySearchResults( List<MediaInfo> images ) throws IOException;
}
Modified: trunk/docs/examples/gettingstarted/sequencers/src/main/resources/jackrabbitNodeTypes.cnd
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/resources/jackrabbitNodeTypes.cnd 2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/resources/jackrabbitNodeTypes.cnd 2008-05-12 20:12:29 UTC (rev 145)
@@ -2,12 +2,12 @@
<nt='http://www.jcp.org/jcr/nt/1.0'>
<mix='http://www.jcp.org/jcr/mix/1.0'>
<image='http://jboss.org/dna/images/1.0'>
-
+<mp3='http://jboss.org/dna/mp3/1.0'>
// ----------------------------------------------------------
// JCR Pre-defined Mixin Types that are not loaded by default
// ----------------------------------------------------------
-[mix:mimeType] mixin
+[mix:mimeTyped] mixin
- jcr:mimeType (string)
- jcr:encoding (string)
@@ -17,12 +17,11 @@
// -------------------
/**
- * Marker mixin that defines the root of a Maven 2 repository.
+ * Node type that defines the metadata for an image
*/
-[image:metadata] > nt:unstructured
- - image:mimeType (string)
- - image:encoding (string)
+[image:metadata] > nt:unstructured, mix:mimeTyped
- image:formatName (string) mandatory
+ < 'JPEG', 'GIF', 'PNG', 'BMP', 'PCX', 'IFF', 'RAS', 'PBM', 'PGM', 'PPM', 'PSD'
- image:width (long)
- image:height (long)
- image:bitsPerPixel (long)
@@ -33,5 +32,14 @@
- image:physicalWidthInches (long)
- image:physicalHeightInches (long)
+/**
+ * Node type that defines the metadata for an MP3 audio file
+ */
+[mp3:metadata] > nt:unstructured, mix:mimeTyped
+ - mp3:title (string)
+ - mp3:author (string)
+ - mp3:album (string)
+ - mp3:year (long)
+ - mp3:comment (string)
Modified: trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/MockUserInterface.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/MockUserInterface.java 2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/MockUserInterface.java 2008-05-12 20:12:29 UTC (rev 145)
@@ -44,9 +44,9 @@
/**
* {@inheritDoc}
*/
- public void displaySearchResults( List<ImageInfo> images ) {
+ public void displaySearchResults( List<MediaInfo> images ) {
assertThat(images.size(), is(this.numberOfSearchResults));
- for (ImageInfo image : images) {
+ for (MediaInfo image : images) {
System.out.println("Image: " + image);
}
}
Modified: trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/SequencingClientTest.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/SequencingClientTest.java 2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/SequencingClientTest.java 2008-05-12 20:12:29 UTC (rev 145)
@@ -38,6 +38,7 @@
private URL pngImageUrl;
private URL pictImageUrl;
private URL jpegImageUrl;
+ private URL mp3Url;
private SequencingClient client;
@Before
@@ -45,6 +46,7 @@
this.pngImageUrl = Thread.currentThread().getContextClassLoader().getResource("caution.png");
this.pictImageUrl = Thread.currentThread().getContextClassLoader().getResource("caution.pict");
this.jpegImageUrl = Thread.currentThread().getContextClassLoader().getResource("caution.jpg");
+ this.mp3Url = Thread.currentThread().getContextClassLoader().getResource("sample1.mp3");
client = new SequencingClient();
client.setWorkingDirectory("target/repositoryData");
client.setJackrabbitConfigPath("src/main/resources/jackrabbitConfig.xml");
@@ -59,10 +61,11 @@
}
@Test
- public void shouldFindImages() {
+ public void shouldFindMedias() {
assertThat(this.pictImageUrl, is(notNullValue()));
assertThat(this.pngImageUrl, is(notNullValue()));
assertThat(this.jpegImageUrl, is(notNullValue()));
+ assertThat(this.mp3Url, is(notNullValue()));
}
@Test
@@ -137,4 +140,23 @@
assertThat(client.getStatistics().getNumberOfNodesSequenced(), is(0l));
}
+ @Test
+ public void shouldUploadAndSequenceMp3File() throws Exception {
+ client.setUserInterface(new MockUserInterface(this.mp3Url, "/a/b/test.mp3", 1));
+ client.startRepository();
+ client.startDnaServices();
+ client.uploadFile();
+
+ // Use a trick to wait until the sequencing has been done by sleeping (to give the sequencing time to start)
+ // and to then shut down the DNA services (which will block until all sequencing has been completed) ...
+ Thread.sleep(1000);
+ client.shutdownDnaServices();
+
+ // The sequencers should have run, so perform the search.
+ // The mock user interface checks the results.
+ client.search();
+
+ assertThat(client.getStatistics().getNumberOfNodesSequenced(), is(1l));
+ }
+
}
Deleted: trunk/docs/examples/gettingstarted/sequencers/src/test/resources/log4j.properties
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/test/resources/log4j.properties 2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/docs/examples/gettingstarted/sequencers/src/test/resources/log4j.properties 2008-05-12 20:12:29 UTC (rev 145)
@@ -1,16 +0,0 @@
-# Direct log messages to stdout
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Target=System.out
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %m%n
-
-# Root logger option
-log4j.rootLogger=INFO, stdout
-
-# Set up the default logging to be INFO level, then override specific units
-log4j.logger.org.jboss.dna=INFO
-
-# Jackrabbit logging
-log4j.logger.org.apache.jackrabbit=WARN, stdout
-log4j.logger.org.apache.derby=INFO, stdout
-
Added: trunk/docs/examples/gettingstarted/sequencers/src/test/resources/sample1.mp3
===================================================================
(Binary files differ)
Property changes on: trunk/docs/examples/gettingstarted/sequencers/src/test/resources/sample1.mp3
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/pom.xml 2008-05-12 20:12:29 UTC (rev 145)
@@ -1,5 +1,7 @@
-<?xml version="1.0"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<?xml version="1.0" encoding="UTF-8"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.dna</groupId>
<artifactId>dna</artifactId>
@@ -7,18 +9,24 @@
<packaging>pom</packaging>
<name>JBoss DNA</name>
<url>http://www.jboss.org/dna</url>
- <description>JBoss DNA provides tools for working with JCR repositories.</description>
+ <description>
+ JBoss DNA provides tools for working with JCR repositories.
+ </description>
<scm>
- <connection>scm:svn:https://svn.jboss.org/repos/dna/trunk</connection>
+ <connection>
+ scm:svn:https://svn.jboss.org/repos/dna/trunk
+ </connection>
</scm>
<modules>
<module>dna-common</module>
<module>dna-spi</module>
<module>dna-repository</module>
+ <module>dna-maven-classloader</module>
<module>sequencers/dna-sequencer-images</module>
- <module>dna-maven-classloader</module>
+ <module>sequencers/dna-sequencer-mp3</module>
<module>dna-integration-tests</module>
</modules>
+
<properties>
<dna-version>${project.version}</dna-version>
</properties>
@@ -71,12 +79,22 @@
</execution>
</executions>
<configuration>
- <finalName>jboss-dna-${project.version}</finalName>
+ <finalName>
+ jboss-dna-${project.version}
+ </finalName>
<descriptors>
- <descriptor>build/assembly/examples.xml</descriptor>
- <descriptor>build/assembly/javadoc.xml</descriptor>
- <descriptor>build/assembly/dist.xml</descriptor>
- <descriptor>build/assembly/src.xml</descriptor>
+ <descriptor>
+ build/assembly/examples.xml
+ </descriptor>
+ <descriptor>
+ build/assembly/javadoc.xml
+ </descriptor>
+ <descriptor>
+ build/assembly/dist.xml
+ </descriptor>
+ <descriptor>
+ build/assembly/src.xml
+ </descriptor>
</descriptors>
</configuration>
</plugin>
@@ -166,11 +184,17 @@
<configuration>
<archive>
<manifest>
- <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
- <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+ <addDefaultSpecificationEntries>
+ true
+ </addDefaultSpecificationEntries>
+ <addDefaultImplementationEntries>
+ true
+ </addDefaultImplementationEntries>
</manifest>
<manifestEntries>
- <Implementation-URL>${pom.url}</Implementation-URL>
+ <Implementation-URL>
+ ${pom.url}
+ </Implementation-URL>
</manifestEntries>
</archive>
</configuration>
@@ -340,4 +364,4 @@
</plugin>
</plugins>
</reporting>
-</project>
+</project>
\ No newline at end of file
Property changes on: trunk/sequencers/dna-sequencer-images
___________________________________________________________________
Name: svn:ignore
- target
+ .settings
target
Modified: trunk/sequencers/dna-sequencer-images/pom.xml
===================================================================
--- trunk/sequencers/dna-sequencer-images/pom.xml 2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/sequencers/dna-sequencer-images/pom.xml 2008-05-12 20:12:29 UTC (rev 145)
@@ -1,4 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?><project>
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
<groupId>org.jboss.dna</groupId>
Modified: trunk/sequencers/dna-sequencer-images/src/main/resources/org/jboss/dna/sequencer/images/images.cnd
===================================================================
--- trunk/sequencers/dna-sequencer-images/src/main/resources/org/jboss/dna/sequencer/images/images.cnd 2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/sequencers/dna-sequencer-images/src/main/resources/org/jboss/dna/sequencer/images/images.cnd 2008-05-12 20:12:29 UTC (rev 145)
@@ -23,30 +23,39 @@
//------------------------------------------------------------------------------
// N A M E S P A C E S
//------------------------------------------------------------------------------
-<dna = 'http://www.jboss.org/dna-repository/1.0'>
-<image = 'http://www.jboss.org/dna-repository/images/1.0'>
+<jcr='http://www.jcp.org/jcr/1.0'>
<nt='http://www.jcp.org/jcr/nt/1.0'>
<mix='http://www.jcp.org/jcr/mix/1.0'>
+<image='http://jboss.org/dna/images/1.0'>
+// ----------------------------------------------------------
+// JCR Pre-defined Mixin Types that are not loaded by default
+// ----------------------------------------------------------
+
+[mix:mimeType] mixin
+ - jcr:mimeType (string)
+ - jcr:encoding (string)
+
+
//------------------------------------------------------------------------------
// N O D E T Y P E S
//------------------------------------------------------------------------------
-[image:metadata] > nt:unstructured, mix:mimeTyped
- //Inherited from 'mix:mimeTyped'
- //- jcr:mimeType (string)
- //- jcr:encoding (string)
+/**
+ * Mixin that defines the metadata for an image
+ */
+[image:metadata] > nt:unstructured, mix:mimeType
- image:formatName (string) mandatory
< 'JPEG', 'GIF', 'PNG', 'BMP', 'PCX', 'IFF', 'RAS', 'PBM', 'PGM', 'PPM', 'PSD'
- - image:width (int)
- - image:height (int)
- - image:bitsPerPixel (int)
+ - image:width (long)
+ - image:height (long)
+ - image:bitsPerPixel (long)
- image:progressive (boolean)
- - image:imageCount (int)
- - image:physicalWidthDpi (int)
- - image:physicalHeightDpi (int)
- - image:physicalWidthInches (double)
- - image:physicalHeightInches (double)
- - image:comments (string) multiple
-
+ - image:numberOfImages (long)
+ - image:physicalWidthDpi (long)
+ - image:physicalHeightDpi (long)
+ - image:physicalWidthInches (long)
+ - image:physicalHeightInches (long)
+
+
\ No newline at end of file
Property changes on: trunk/sequencers/dna-sequencer-mp3
___________________________________________________________________
Name: svn:ignore
+ .settings
target
Added: trunk/sequencers/dna-sequencer-mp3/.classpath
===================================================================
--- trunk/sequencers/dna-sequencer-mp3/.classpath (rev 0)
+++ trunk/sequencers/dna-sequencer-mp3/.classpath 2008-05-12 20:12:29 UTC (rev 145)
@@ -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>
Added: trunk/sequencers/dna-sequencer-mp3/.project
===================================================================
--- trunk/sequencers/dna-sequencer-mp3/.project (rev 0)
+++ trunk/sequencers/dna-sequencer-mp3/.project 2008-05-12 20:12:29 UTC (rev 145)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>dna-sequencer-mp3</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/sequencers/dna-sequencer-mp3/pom.xml
===================================================================
--- trunk/sequencers/dna-sequencer-mp3/pom.xml (rev 0)
+++ trunk/sequencers/dna-sequencer-mp3/pom.xml 2008-05-12 20:12:29 UTC (rev 145)
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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.1-SNAPSHOT</version>
+ <relativePath>../..</relativePath>
+ </parent>
+ <!-- The groupId and version values are inherited from parent -->
+ <artifactId>dna-sequencer-mp3</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss DNA MP3 Sequencer</name>
+ <description>JBoss DNA Sequencer that processes MP3 audio files</description>
+ <url>http://labs.jboss.org/dna</url>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-common</artifactId>
+ <version>0.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-spi</artifactId>
+ <version>0.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jaudiotagger</groupId>
+ <artifactId>jaudiotagger</artifactId>
+ <version>1.0.8</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit-dep</artifactId>
+ <version>4.4</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Added: trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3Metadata.java
===================================================================
--- trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3Metadata.java (rev 0)
+++ trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3Metadata.java 2008-05-12 20:12:29 UTC (rev 145)
@@ -0,0 +1,82 @@
+package org.jboss.dna.sequencer.mp3;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.util.logging.Level;
+import org.jaudiotagger.audio.AudioFile;
+import org.jaudiotagger.audio.AudioFileIO;
+import org.jaudiotagger.tag.Tag;
+
+/**
+ * Utility for extracting metadata from MP3 files.
+ * @author Stefano Maestri
+ */
+public class Mp3Metadata {
+
+ private String title;
+ private String author;
+ private String album;
+ private String year;
+ private String comment;
+
+ private Mp3Metadata() {
+
+ }
+
+ public static Mp3Metadata instance( InputStream stream ) {
+
+ Mp3Metadata me = null;
+ File tmpFile = null;
+ try {
+ tmpFile = File.createTempFile("dna-sequencer-mp3", ".mp3");
+ FileOutputStream writer = new FileOutputStream(tmpFile);
+ byte[] b = new byte[128];
+ while (stream.read(b) != -1) {
+ writer.write(b);
+ }
+ writer.close();
+ AudioFileIO.logger.getParent().setLevel(Level.OFF);
+ AudioFile f = AudioFileIO.read(tmpFile);
+ Tag tag = f.getTag();
+
+ me = new Mp3Metadata();
+
+ me.author = tag.getFirstArtist();
+ me.album = tag.getFirstAlbum();
+ me.title = tag.getFirstTitle();
+ me.comment = tag.getFirstComment();
+ me.year = tag.getFirstYear();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (tmpFile != null) {
+ tmpFile.delete();
+ }
+ }
+ return me;
+
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public String getAuthor() {
+ return author;
+ }
+
+ public String getAlbum() {
+ return album;
+ }
+
+ public String getYear() {
+ return year;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+}
Added: trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3MetadataSequencer.java
===================================================================
--- trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3MetadataSequencer.java (rev 0)
+++ trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3MetadataSequencer.java 2008-05-12 20:12:29 UTC (rev 145)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.mp3;
+
+import java.io.InputStream;
+import org.jboss.dna.common.monitor.ProgressMonitor;
+import org.jboss.dna.spi.sequencers.SequencerOutput;
+import org.jboss.dna.spi.sequencers.StreamSequencer;
+
+/**
+ * A sequencer that processes the binary content of an MP3 audio file, extracts the metadata for the file, and then writes that
+ * audio metadata to the repository.
+ * <p>
+ * This sequencer produces data that corresponds to the following structure:
+ * <ul>
+ * <li><strong>mp3:metadata</strong> node of type <code>mp3:metadata</code>
+ * <ul>
+ * <li><strong>jcr:mimeType</strong> - optional string property for the mime type of the image</li>
+ * <li><strong>jcr:encoding</strong> - optional string property for the encoding of the image</li>
+ * <li><strong>mp3:title</strong> - optional string property for the name of the audio file or recording</li>
+ * <li><strong>mp3:author</strong> - optional string property for the author of the recording</li>
+ * <li><strong>mp3:album</strong> - optional string property for the name of the album</li>
+ * <li><strong>mp3:year</strong> - optional integer property for the year the recording as created</li>
+ * <li><strong>mp3:comment</strong> - optional string property specifying a comment</li>
+ * </ul>
+ * </li>
+ * </ul>
+ * </p>
+ * @author Stefano Maestri
+ * @author Randall Hauch
+ */
+public class Mp3MetadataSequencer implements StreamSequencer {
+
+ public static final String METADATA_NODE = "mp3:metadata";
+ public static final String MP3_PRIMARY_TYPE = "jcr:primaryType";
+ public static final String MP3_TITLE = "mp3:title";
+ public static final String MP3_AUTHOR = "mp3:author";
+ public static final String MP3_ALBUM = "mp3:album";
+ public static final String MP3_YEAR = "mp3:year";
+ public static final String MP3_COMMENT = "mp3:comment";
+
+ /**
+ * {@inheritDoc}
+ */
+ public void sequence( InputStream stream, SequencerOutput output, ProgressMonitor progressMonitor ) {
+ Mp3Metadata metadata = Mp3Metadata.instance(stream);
+
+ if (metadata != null) {
+ // Place the image metadata into the output map ...
+ output.setProperty(METADATA_NODE, MP3_PRIMARY_TYPE, "mp3:metadata");
+ // output.psetProperty(METADATA_NODE, IMAGE_MIXINS, "");
+ output.setProperty(METADATA_NODE, MP3_TITLE, metadata.getTitle());
+ // output.setProperty(METADATA_NODE, IMAGE_ENCODING, "");
+ output.setProperty(METADATA_NODE, MP3_AUTHOR, metadata.getAuthor());
+ output.setProperty(METADATA_NODE, MP3_ALBUM, metadata.getAlbum());
+ output.setProperty(METADATA_NODE, MP3_YEAR, metadata.getYear());
+ output.setProperty(METADATA_NODE, MP3_COMMENT, metadata.getComment());
+ }
+ }
+}
Added: trunk/sequencers/dna-sequencer-mp3/src/main/resources/org/jboss/dna/sequencer/mp3/mp3.cnd
===================================================================
--- trunk/sequencers/dna-sequencer-mp3/src/main/resources/org/jboss/dna/sequencer/mp3/mp3.cnd (rev 0)
+++ trunk/sequencers/dna-sequencer-mp3/src/main/resources/org/jboss/dna/sequencer/mp3/mp3.cnd 2008-05-12 20:12:29 UTC (rev 145)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+//------------------------------------------------------------------------------
+// N A M E S P A C E S
+//------------------------------------------------------------------------------
+<jcr='http://www.jcp.org/jcr/1.0'>
+<nt='http://www.jcp.org/jcr/nt/1.0'>
+<mix='http://www.jcp.org/jcr/mix/1.0'>
+<mp3='http://jboss.org/dna/mp3/1.0'>
+
+// ----------------------------------------------------------
+// JCR Pre-defined Mixin Types that are not loaded by default
+// ----------------------------------------------------------
+
+[mix:mimeType] mixin
+ - jcr:mimeType (string)
+ - jcr:encoding (string)
+
+
+//------------------------------------------------------------------------------
+// N O D E T Y P E S
+//------------------------------------------------------------------------------
+
+[mp3:metadata] > nt:unstructured, mix:mimeTyped
+ - mp3:title (string)
+ - mp3:author (string)
+ - mp3:album (string)
+ - mp3:year (long)
+ - mp3:comment (string)
+
+
\ No newline at end of file
Added: trunk/sequencers/dna-sequencer-mp3/src/test/java/org/jboss/dna/sequencer/mp3/Mp3MetadataTest.java
===================================================================
--- trunk/sequencers/dna-sequencer-mp3/src/test/java/org/jboss/dna/sequencer/mp3/Mp3MetadataTest.java (rev 0)
+++ trunk/sequencers/dna-sequencer-mp3/src/test/java/org/jboss/dna/sequencer/mp3/Mp3MetadataTest.java 2008-05-12 20:12:29 UTC (rev 145)
@@ -0,0 +1,39 @@
+package org.jboss.dna.sequencer.mp3;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+import java.io.InputStream;
+import org.junit.After;
+import org.junit.Test;
+
+public class Mp3MetadataTest {
+
+ private Mp3Metadata metadata;
+ private InputStream imageStream;
+
+ @After
+ public void afterEach() throws Exception {
+ if (imageStream != null) {
+ try {
+ imageStream.close();
+ } finally {
+ imageStream = null;
+ }
+ }
+ }
+
+ protected InputStream getTestMp3( String resourcePath ) {
+ return this.getClass().getResourceAsStream("/" + resourcePath);
+ }
+
+ @Test
+ public void shouldBeAbleToCreateMetadataForSample1() {
+ metadata = Mp3Metadata.instance(this.getTestMp3("sample1.mp3"));
+ assertThat(metadata.getAlbum(), is("Badwater Slim Performs Live"));
+ assertThat(metadata.getAuthor(), is("Badwater Slim"));
+ assertThat(metadata.getComment(), is("This is a test audio file."));
+ assertThat(metadata.getTitle(), is("Sample MP3"));
+ assertThat(metadata.getYear(), is("2008"));
+ }
+
+}
Added: trunk/sequencers/dna-sequencer-mp3/src/test/resources/sample1.mp3
===================================================================
(Binary files differ)
Property changes on: trunk/sequencers/dna-sequencer-mp3/src/test/resources/sample1.mp3
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
15 years, 12 months