Skip to end of metadata
Go to start of metadata

Earlier in the introduction, we briefly described sequencers and how they work. In this section we go into more detail about the framework and describe all the steps for developing your own custom sequencers.

The Sequencer framework

A sequencer is actually just a plain old Java object (POJO). Creating a sequencer is pretty straightforward: create a Java class that extends a single abstract class, called Sequencer:

The abstract class also contains fields and getters (not shown above) for the name, description, and path expressions that are automatically set by ModeShape during repository initialization. The initialize(...) method is run upon repository initialization and can be overridden by an implementation to register (if required) any custom namespaces and node types required by the sequencer's generated output.

The outputNode might belong to a different javax.jcr.Session object than the inputProperty, if the input and output paths of the sequencer configuration specify different workspaces. Therefore, be careful that all changes are made using the output node and its session.

The inputs to the sequencer depend on how it's configured, but often the inputProperty represents the jcr:data BINARY property on the "jcr:content" child of an nt:file node. The outputNode, however, will be one of two things:

  1. If there is no output path in the path expression, then the sequenced output is to be placed directly under the selected node, so therefore the "outputNode" will be the existing node being sequenced. In this case, the sequencer should place all content under the output node. In this case, the sequencers are not allowed to change the primary type.
  2. Otherwise, the sequenced output is to be placed in a different location than the selected node. In this case, ModeShape uses the name of the selected node and creates a new node under the output path. This new node will have a primary type of "nt:unstructured", but sequencers are allowed to change the primary type.

The final parameter to the execute(...) method is the SequencerContext object, which is an interface containing some extra information often useful when sequencing files:

Creating a new sequencer

Create the Maven module

Create a Sequencer subclass

Create unit tests

Package your library

Deploy and configure

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.