# Package org.modeshape.jcr.api.sequencer

Many repositories are used (at least in part) to manage files and other artifacts, including service definitions, policy files, images, media, documents, presentations, application components, reusable libraries, configuration files, application installations, databases schemas, management scripts, and so on.

See: Description

- Interface Summary
  Interface | Description
  --- | ---
  Sequencer.Context | The sequencer context represents the complete context of a sequencer invocation.

- Class Summary
  Class | Description
  --- | ---
  Sequencer | A component that reads recently-changed content (often uploaded files) and extracts additional information from the content.

## Package org.modeshape.jcr.api.sequencer Description

Many repositories are used (at least in part) to manage files and other artifacts, including service definitions, policy files, images, media, documents, presentations, application components, reusable libraries, configuration files, application installations, databases schemas, management scripts, and so on. Most JCR repository implementations will store those files and maybe index them for searching.

But ModeShape does more. ModeShape sequencers can automatically unlock the structured information buried within all of those files, and this useful content derived from your files is then stored back in the repository where your client applications can search, access, and analyze it using the JCR API.

A repository can be configured to have any number of sequencers, and each one is configured to apply to content in the repository matching specific patterns. When content in the repository changes, ModeShape automatically looks to see which (if any) sequencers might be able to run on the changed content. If any of the sequencers do match, ModeShape automatically calls them by supplying the changed content. At that point, the sequencer's job is to process the supplied input, extract meaningful information, and write that derived information back into the repository where it can be accessed, searched and used by your client applications.

Implementing a sequencer is pretty straightforward:

1. Create a class that subclasses the `Sequencer` abstract base class.
2. Implement the `execute(...)` method by processing the supplied input property and creating a node (or subgraph) that represents the structured output of the input property.
3. If the output structure uses custom node types, overwrite the `initialize(...)` method to register any custom node types and namespaces. Be sure your method only registers them if they don't exist.
4. Configure a repository to use your new sequencer. Be sure your class (and any third-party libraries it uses) are available on the classpath.

The output structure can take almost any form, and it is almost always specific to each kind of file being sequenced. For example, ModeShape comes with an image sequencer that extracts the simple metadata from different kinds of image files (e.g., JPEG, GIF, PNG, etc.). Another example is the Compact Node Definition (CND) sequencer that processes the CND files to extract and produce a structured representation of the node type definitions, property definitions, and child node definitions contained within the file.

There may be multiple sequencers that all output the same type of information. For example, ModeShape's Java class file sequencer and Java source file sequencer both generate an output structure that represents the Java AST. In this case, both types of files contain semantically similar information.

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.