org.modeshape.repository.sequencer
Class StreamSequencerAdapter

java.lang.Object
  extended by org.modeshape.repository.sequencer.StreamSequencerAdapter
All Implemented Interfaces:
Component<SequencerConfig>, Sequencer

public class StreamSequencerAdapter
extends Object
implements Sequencer

An adapter class that wraps a StreamSequencer instance to be a Sequencer.


Nested Class Summary
protected  class StreamSequencerAdapter.NextSnsPathStrategy
           
protected  class StreamSequencerAdapter.PassThroughStrategy
           
protected static interface StreamSequencerAdapter.PathStrategy
           
 
Field Summary
static boolean DEFAULT_ADD_DEFAULT_MIXIN
           
 
Constructor Summary
StreamSequencerAdapter(StreamSequencer streamSequencer)
           
StreamSequencerAdapter(StreamSequencer streamSequencer, boolean addDerivedMixin)
           
 
Method Summary
protected  Collection<Property> addDerivedProperties(Collection<Property> properties, SequencerContext context, Path derivedPath)
           
protected  StreamSequencerContext createStreamSequencerContext(Node input, Property sequencedProperty, SequencerContext context, Problems problems)
           
protected  Path derivedFromPath(Path inputPath)
          Compute the path that will be used in the "mode:derivedFrom" property on the "mode:derived" node(s) output by the sequencing operation.
 void execute(Node input, String sequencedPropertyName, NetChangeObserver.NetChange changes, Set<RepositoryNodePath> outputPaths, SequencerContext context, Problems problems)
          Execute the sequencing operation on the supplied node, which has recently been created or changed.
protected  String[] extractMixinTypes(Object value)
           
 SequencerConfig getConfiguration()
          Return the configuration for this component, as supplied to the last Component.setConfiguration(ComponentConfig) invocation.
protected  String getMimeType(SequencerContext context, Property sequencedProperty, String name)
           
protected  void saveOutput(Path inputPath, String outputPath, SequencerOutputMap output, SequencerContext context, Set<Path> builtPaths, boolean replacePreviouslyDerivedContent)
          Save the sequencing output to the supplied node.
 void setConfiguration(SequencerConfig configuration)
          This method allows the implementation to initialize and configure itself using the supplied ComponentConfig information, and is called prior to any other class to this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ADD_DEFAULT_MIXIN

public static final boolean DEFAULT_ADD_DEFAULT_MIXIN
See Also:
Constant Field Values
Constructor Detail

StreamSequencerAdapter

public StreamSequencerAdapter(StreamSequencer streamSequencer)

StreamSequencerAdapter

public StreamSequencerAdapter(StreamSequencer streamSequencer,
                              boolean addDerivedMixin)
Method Detail

getConfiguration

public SequencerConfig getConfiguration()
Return the configuration for this component, as supplied to the last Component.setConfiguration(ComponentConfig) invocation.

Specified by:
getConfiguration in interface Component<SequencerConfig>
Returns:
the configuration, or null if not yet configured

setConfiguration

public void setConfiguration(SequencerConfig configuration)
This method allows the implementation to initialize and configure itself using the supplied ComponentConfig information, and is called prior to any other class to this object. When this method is called, the implementation must maintain a reference to the supplied configuration (which should then be returned in Component.getConfiguration().

Specified by:
setConfiguration in interface Component<SequencerConfig>
Parameters:
configuration - the configuration for the component

execute

public void execute(Node input,
                    String sequencedPropertyName,
                    NetChangeObserver.NetChange changes,
                    Set<RepositoryNodePath> outputPaths,
                    SequencerContext context,
                    Problems problems)
             throws SequencerException
Execute the sequencing operation on the supplied node, which has recently been created or changed. The implementation of this method is responsible for modifying the appropriate nodes and saving any changes made by this sequencer, and closing any other acquired resources, even in the case of exceptions.

The SequencingService determines the sequencers that should be executed by monitoring the changes to one or more workspaces (it registers an Observer with the RepositoryLibrary). Changes in those workspaces are aggregated for each transaction, and organized into changes for each node. The SequencingService then determines for each set of changes to a node the set of full paths to the properties that have changed and whether those paths match the sequencer's path expressions. Each path expression produces the path to the output node, and these output paths are accumulated and (with the original node that changed, the node change summary, and other information) supplied to the sequencer via this method.

It is possible that a sequencer is configured to apply to multiple properties on a node. So, in cases where multiple properties are changed on a single node (within a single repository transaction), the sequencer will only be executed once. Also, in such cases the sequencer's configuration may imply multiple output nodes, so it is left to the sequencer to define the behavior in such cases.

Specified by:
execute in interface Sequencer
Parameters:
input - the node that has recently been created or changed; never null
sequencedPropertyName - the name of the property that caused this sequencer to be executed; never null and never empty
changes - the immutable summary of changes that occurred on the input node within the transaction; never null
outputPaths - the paths to the nodes where the sequencing content should be placed; never null and never empty, but the set may contain paths for non-existent nodes or may reference the input node
context - the context in which this sequencer is executing; never null
problems - the interface used for recording problems; never null
Throws:
SequencerException - if there is an error in this sequencer

saveOutput

protected void saveOutput(Path inputPath,
                          String outputPath,
                          SequencerOutputMap output,
                          SequencerContext context,
                          Set<Path> builtPaths,
                          boolean replacePreviouslyDerivedContent)
Save the sequencing output to the supplied node. This method does not need to save the output, as that is done by the caller of this method.

Parameters:
inputPath - the existing node that was sequenced; never null
outputPath - the existing node onto (or below) which the output is to be written; never null
output - the (immutable) sequencing output; never null
context - the execution context for this sequencing operation; never null
builtPaths - a set of the paths that have already been created but not submitted in this batch
replacePreviouslyDerivedContent - true if any existing content that was previously derived from the same input path should first be removed before saving the output, or false otherwise

addDerivedProperties

protected Collection<Property> addDerivedProperties(Collection<Property> properties,
                                                    SequencerContext context,
                                                    Path derivedPath)

derivedFromPath

protected Path derivedFromPath(Path inputPath)
Compute the path that will be used in the "mode:derivedFrom" property on the "mode:derived" node(s) output by the sequencing operation. If the supplied input path of the node being sequenced ends with "jcr:content", then the derived path is the parent path; otherwise, this method simply returns the supplied input path.

Parameters:
inputPath - the path of the node being sequenced; may not be null
Returns:
the derived path; never null

extractMixinTypes

protected String[] extractMixinTypes(Object value)

createStreamSequencerContext

protected StreamSequencerContext createStreamSequencerContext(Node input,
                                                              Property sequencedProperty,
                                                              SequencerContext context,
                                                              Problems problems)

getMimeType

protected String getMimeType(SequencerContext context,
                             Property sequencedProperty,
                             String name)


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