|
ModeShape Distribution 3.0.0.Beta4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.jcr.api.sequencer.Sequencer
public abstract class Sequencer
A component that reads recently-changed content (often uploaded files) and extracts additional information from the content.
Each ModeShape repository can be configured with zero or more sequencers. Each sequencer is configured with a set of match conditions that define the acceptable patterns for the paths of changed nodes, as well as a path specification that defines where the derived (or generated) output should be placed. Then when clients change nodes with paths that satisfy the match conditions, the repository will create a new Session and invoke the sequencer, which is then expected to process the changed content and generate the derived information under the supplied parent node. The session will be saved automatically or, if an exception is thrown, discard the changes and close the session.
Nested Class Summary | |
---|---|
static interface |
Sequencer.Context
The sequencer context represents the complete context of a sequencer invocation. |
Constructor Summary | |
---|---|
Sequencer()
|
Method Summary | |
---|---|
abstract boolean |
execute(Property inputProperty,
Node outputNode,
Sequencer.Context context)
Execute the sequencing operation on the specified property, which has recently been created or changed. |
protected Set<String> |
getAcceptedMimeTypes()
Utility method to obtain the set of accepted MIME types. |
protected Logger |
getLogger()
|
String |
getName()
Get the name for this sequencer. |
String[] |
getPathExpressions()
Obtain the path expressions as configured on the sequencer. |
String |
getRepositoryName()
Get the name of the repository. |
UUID |
getUniqueId()
Return the unique identifier for this sequencer. |
boolean |
hasAcceptedMimeTypes()
Determine if this sequencer requires the content to have a specific MIME type |
void |
initialize(NamespaceRegistry registry,
NodeTypeManager nodeTypeManager)
Initialize the sequencer. |
boolean |
isAccepted(String mimeType)
Determine if this sequencer has been configured to accept and process content with the supplied MIME type. |
protected void |
registerDefaultMimeTypes(String... mimeTypes)
Set the MIME types that are accepted by default, if there are any. |
protected boolean |
registerNamespace(String namespacePrefix,
String namespaceUri,
NamespaceRegistry namespaceRegistry)
Registers a namespace using the given NamespaceRegistry , if the namespace has not been previously registered. |
protected void |
registerNodeTypes(InputStream cndStream,
NodeTypeManager nodeTypeManager,
boolean allowUpdate)
See registerNodeTypes(String, org.modeshape.jcr.api.nodetype.NodeTypeManager, boolean) |
protected void |
registerNodeTypes(String cndFile,
NodeTypeManager nodeTypeManager,
boolean allowUpdate)
Registers node types from a CND file, using the given NodeTypeManager . |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Sequencer()
Method Detail |
---|
public final UUID getUniqueId()
public final String getName()
public final String getRepositoryName()
public final String[] getPathExpressions()
public void initialize(NamespaceRegistry registry, NodeTypeManager nodeTypeManager) throws RepositoryException, IOException
By default this method does nothing, so it should be overridden by implementations to do a one-time initialization of any
internal components. For example, sequencers can use the supplied registry
and nodeTypeManager
objects to register custom namesapces and node types required by the generated content.
registry
- the namespace registry that can be used to register custom namespaces; never nullnodeTypeManager
- the node type manager that can be used to register custom node types; never null
RepositoryException
- if operations on the NamespaceRegistry
or NodeTypeManager
fail
IOException
- if any stream based operations fail (like importing cnd files)public abstract boolean execute(Property inputProperty, Node outputNode, Sequencer.Context context) throws Exception
Each sequencer is expected to process the value of the property, extract information from the value, and write a structured representation (in the form of a node or a subgraph of nodes) using the supplied output node. Note that the output node will either be:
Node.setPrimaryType(String)
)The implementation is expected to always clean up all resources that it acquired, even in the case of exceptions.
Note: This method must be threadsafe: ModeShape will likely invoke this method concurrently in separate threads,
and the method should never modify the state or fields of the Sequencer implementation class. All initialization should be
performed in initialize(NamespaceRegistry, NodeTypeManager)
.
inputProperty
- the property that was changed and that should be used as the input; never nulloutputNode
- the node that represents the output for the derived information; never null, and will either be
new
if the output is being placed outside of the selected node, or will not be new when the
output is to be placed on the selected input nodecontext
- the context in which this sequencer is executing, and which may contain additional parameters useful when
generating the output structure; never null
Exception
- if there was a problem with the sequencer that could not be handled. All exceptions will be logged
automatically as errors by ModeShape.public String toString()
toString
in class Object
protected boolean registerNamespace(String namespacePrefix, String namespaceUri, NamespaceRegistry namespaceRegistry) throws RepositoryException
NamespaceRegistry
, if the namespace has not been previously registered.
namespacePrefix
- a non-null String
namespaceUri
- a non-null String
namespaceRegistry
- a NamespaceRegistry
instance.
RepositoryException
- if anything fails during the registration processprotected void registerNodeTypes(String cndFile, NodeTypeManager nodeTypeManager, boolean allowUpdate) throws RepositoryException, IOException
NodeTypeManager
. Any namespaces defined in the CND file will
be automatically registered as well.
cndFile
- the relative path to the cnd file, which is loaded using via Class.getResourceAsStream(String)
nodeTypeManager
- the node type manager with which the cnd will be registeredallowUpdate
- a boolean which indicates whether updates on existing node types are allowed or no. See
NodeTypeManager.registerNodeType(javax.jcr.nodetype.NodeTypeDefinition, boolean)
RepositoryException
- if anything fails
IOException
- if any stream related operations failprotected void registerNodeTypes(InputStream cndStream, NodeTypeManager nodeTypeManager, boolean allowUpdate) throws RepositoryException, IOException
registerNodeTypes(String, org.modeshape.jcr.api.nodetype.NodeTypeManager, boolean)
cndStream
- the input stream containing the CND file; may not be nullnodeTypeManager
- the node type manager with which the node types in the CND file should be registered; may not be
nullallowUpdate
- a boolean which indicates whether updates on existing node types are allowed or no. See
NodeTypeManager.registerNodeType(javax.jcr.nodetype.NodeTypeDefinition, boolean)
RepositoryException
- if anything fails
IOException
- if any stream related operations failprotected final Logger getLogger()
protected final void registerDefaultMimeTypes(String... mimeTypes)
initialize(NamespaceRegistry, NodeTypeManager)
method in the subclass.
This method can be called more than once to add additional mime types.
mimeTypes
- the array of MIME types that are accepted by this sequencerisAccepted(String)
protected final Set<String> getAcceptedMimeTypes()
initialize(NamespaceRegistry, NodeTypeManager)
method or the MIME types explicitly set in the
sequencers configuration.
public final boolean hasAcceptedMimeTypes()
public final boolean isAccepted(String mimeType)
mimeType
- the MIME type
mimeType
is null and
therefore not known), or false otherwisehasAcceptedMimeTypes()
|
ModeShape Distribution 3.0.0.Beta4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |