Author: rhauch
Date: 2009-10-28 10:43:17 -0400 (Wed, 28 Oct 2009)
New Revision: 1313
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/Changes.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/NetChangeObserver.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java
Log:
DNA-456 Changed the NetChangeObserver functionality so that there is a NetChanges object
that corresponds to the Changes object, where the NetChanges contains all of the
individual NetChange objects corresponding to the ChangeRequest objects in the Changes
object. This means that we still keep the notion of atomic set of changes.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/Changes.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/Changes.java 2009-10-28
00:41:28 UTC (rev 1312)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/Changes.java 2009-10-28
14:43:17 UTC (rev 1313)
@@ -24,7 +24,7 @@
package org.jboss.dna.graph.observe;
import java.io.Serializable;
-import java.util.Iterator;
+import java.util.Collections;
import java.util.List;
import net.jcip.annotations.Immutable;
import org.jboss.dna.graph.SecurityContext;
@@ -35,15 +35,15 @@
* A set of changes that were made atomically. Each change is in the form of a frozen
{@link ChangeRequest}.
*/
@Immutable
-public final class Changes implements Iterable<ChangeRequest>,
Comparable<Changes>, Serializable {
+public class Changes implements Comparable<Changes>, Serializable {
private static final long serialVersionUID = 1L;
- private final String processId;
- private final String userName;
- private final String sourceName;
- private final DateTime timestamp;
- private final List<ChangeRequest> changeRequests;
+ protected final String processId;
+ protected final String userName;
+ protected final String sourceName;
+ protected final DateTime timestamp;
+ protected final List<ChangeRequest> changeRequests;
public Changes( String userName,
String sourceName,
@@ -57,13 +57,33 @@
String sourceName,
DateTime timestamp,
List<ChangeRequest> requests ) {
+ assert requests != null;
+ assert !requests.isEmpty();
this.userName = userName;
this.sourceName = sourceName;
this.timestamp = timestamp;
- this.changeRequests = requests;
+ this.changeRequests = Collections.unmodifiableList(requests);
this.processId = processId != null ? processId : "";
+ assert this.userName != null;
+ assert this.sourceName != null;
+ assert this.timestamp != null;
+ assert this.changeRequests != null;
+ assert this.processId != null;
}
+ protected Changes( Changes changes ) {
+ this.userName = changes.userName;
+ this.sourceName = changes.sourceName;
+ this.timestamp = changes.timestamp;
+ this.changeRequests = changes.changeRequests;
+ this.processId = changes.processId;
+ assert this.userName != null;
+ assert this.sourceName != null;
+ assert this.timestamp != null;
+ assert this.changeRequests != null;
+ assert this.processId != null;
+ }
+
/**
* Get the user that made these changes.
*
@@ -102,12 +122,12 @@
}
/**
- * {@inheritDoc}
+ * Get the list of changes.
*
- * @see java.lang.Iterable#iterator()
+ * @return the immutable list of change requests; never null and never empty
*/
- public Iterator<ChangeRequest> iterator() {
- return this.changeRequests.iterator();
+ public List<ChangeRequest> getChangeRequests() {
+ return changeRequests;
}
/**
@@ -148,4 +168,18 @@
}
return false;
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ if (processId.length() != 0) {
+ return getTimestamp() + " @" + getUserName() + " [" +
getSourceName() + "] - " + changeRequests.size() + " events";
+ }
+ return getTimestamp() + " @" + getUserName() + " #" +
getProcessId() + " [" + getSourceName() + "] - "
+ + changeRequests.size() + " events";
+ }
}
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/NetChangeObserver.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/NetChangeObserver.java 2009-10-28
00:41:28 UTC (rev 1312)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/NetChangeObserver.java 2009-10-28
14:43:17 UTC (rev 1313)
@@ -27,6 +27,8 @@
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
@@ -42,8 +44,10 @@
import org.jboss.dna.graph.request.CreateNodeRequest;
import org.jboss.dna.graph.request.DeleteBranchRequest;
import org.jboss.dna.graph.request.DeleteChildrenRequest;
+import org.jboss.dna.graph.request.LockBranchRequest;
import org.jboss.dna.graph.request.RemovePropertyRequest;
import org.jboss.dna.graph.request.SetPropertyRequest;
+import org.jboss.dna.graph.request.UnlockBranchRequest;
import org.jboss.dna.graph.request.UpdatePropertiesRequest;
/**
@@ -74,7 +78,7 @@
public void notify( Changes changes ) {
Map<String, Map<Location, NetChangeDetails>>
detailsByLocationByWorkspace = new HashMap<String, Map<Location,
NetChangeDetails>>();
// Process each of the events, extracting the node path and property details for
each ...
- for (ChangeRequest change : changes) {
+ for (ChangeRequest change : changes.getChangeRequests()) {
Location location = change.changedLocation();
String workspace = change.changedWorkspace();
@@ -129,37 +133,84 @@
}
childDetails.addEventType(ChangeType.NODE_REMOVED);
}
+ } else if (change instanceof LockBranchRequest) {
+ details.setLockAction(LockAction.LOCKED);
+ } else if (change instanceof UnlockBranchRequest) {
+ details.setLockAction(LockAction.UNLOCKED);
}
}
// Walk through the net changes ...
- String sourceName = changes.getSourceName();
+ List<NetChange> netChanges = new LinkedList<NetChange>();
for (Map.Entry<String, Map<Location, NetChangeDetails>>
byWorkspaceEntry : detailsByLocationByWorkspace.entrySet()) {
String workspaceName = byWorkspaceEntry.getKey();
// Iterate over the entries. Since we've used a TreeSet, we'll get
these with the lower paths first ...
for (Map.Entry<Location, NetChangeDetails> entry :
byWorkspaceEntry.getValue().entrySet()) {
Location location = entry.getKey();
NetChangeDetails details = entry.getValue();
- notify(new NetChange(sourceName, workspaceName, location,
details.getEventTypes(),
- details.getModifiedProperties(),
details.getRemovedProperties()));
+ netChanges.add(new NetChange(workspaceName, location,
details.getEventTypes(), details.getModifiedProperties(),
+ details.getRemovedProperties()));
}
}
+ // Now notify of all of the changes ...
+ notify(new NetChanges(changes, netChanges));
}
/**
- * Method that is called for each net change.
+ * Method that is called for the set of net changes.
*
- * @param change the net change; never null
+ * @param netChanges the net changes; never null
*/
- protected abstract void notify( NetChange change );
+ protected abstract void notify( NetChanges netChanges );
/**
+ * A set of net changes that were made atomically. Each change is in the form of a
frozen {@link ChangeRequest}, and the net
+ * change is in the form.
+ */
+ @Immutable
+ public static final class NetChanges extends Changes {
+ private static final long serialVersionUID = 1L;
+
+ private final List<NetChange> netChanges;
+
+ public NetChanges( Changes changes,
+ List<NetChange> netChanges ) {
+ super(changes);
+ assert netChanges != null;
+ assert !netChanges.isEmpty();
+ this.netChanges = Collections.unmodifiableList(netChanges);
+ }
+
+ /**
+ * Get the list of net changes.
+ *
+ * @return the immutable list of net changes; never null and never empty
+ */
+ public List<NetChange> getNetChanges() {
+ return this.netChanges;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ if (processId.length() != 0) {
+ return getTimestamp() + " @" + getUserName() + " [" +
getSourceName() + "] - " + netChanges.size() + " changes";
+ }
+ return getTimestamp() + " @" + getUserName() + " #" +
getProcessId() + " [" + getSourceName() + "] - "
+ + netChanges.size() + " changes";
+ }
+ }
+
+ /**
* A notification of changes to a node.
*/
@Immutable
- public static class NetChange {
+ public static final class NetChange {
- private final String sourceName;
private final String workspaceName;
private final Location location;
private final EnumSet<ChangeType> eventTypes;
@@ -167,16 +218,13 @@
private final Set<Name> removedProperties;
private final int hc;
- public NetChange( String sourceName,
- String workspaceName,
+ public NetChange( String workspaceName,
Location location,
EnumSet<ChangeType> eventTypes,
Set<Property> modifiedProperties,
Set<Name> removedProperties ) {
- assert sourceName != null;
assert workspaceName != null;
assert location != null;
- this.sourceName = sourceName;
this.workspaceName = workspaceName;
this.location = location;
this.hc = HashCode.compute(this.workspaceName, this.location);
@@ -195,13 +243,6 @@
}
/**
- * @return repositorySourceName
- */
- public String getRepositorySourceName() {
- return this.sourceName;
- }
-
- /**
* @return repositoryWorkspaceName
*/
public String getRepositoryWorkspaceName() {
@@ -308,6 +349,12 @@
}
}
+ private enum LockAction {
+ NO_CHANGE,
+ LOCKED,
+ UNLOCKED;
+ }
+
/**
* Internal utility class used in the computation of the net changes.
*/
@@ -317,10 +364,26 @@
private final Set<Property> modifiedProperties = new
HashSet<Property>();
private final Set<Name> removedProperties = new HashSet<Name>();
private EnumSet<ChangeType> eventTypes = EnumSet.noneOf(ChangeType.class);
+ private LockAction lockAction = LockAction.NO_CHANGE;
protected NetChangeDetails() {
}
+ public void setLockAction( LockAction lockAction ) {
+ switch (lockAction) {
+ case LOCKED:
+ // always mark as locked
+ this.lockAction = lockAction;
+ break;
+ case UNLOCKED:
+ // mark as unlock or unchanged if previously locked ...
+ this.lockAction = this.lockAction == LockAction.LOCKED ?
LockAction.UNLOCKED : lockAction;
+ break;
+ case NO_CHANGE:
+ break;
+ }
+ }
+
public void addEventType( ChangeType eventType ) {
this.eventTypes.add(eventType);
}
@@ -341,6 +404,13 @@
}
/**
+ * @return lockAction
+ */
+ public LockAction getLockAction() {
+ return lockAction;
+ }
+
+ /**
* @return nodeAction
*/
public EnumSet<ChangeType> getEventTypes() {
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java 2009-10-28
00:41:28 UTC (rev 1312)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java 2009-10-28
14:43:17 UTC (rev 1313)
@@ -847,6 +847,7 @@
// Publish any changes ...
if (observer != null && !this.changes.isEmpty()) {
String userName = context.getSecurityContext() != null ?
context.getSecurityContext().getUserName() : null;
+ if (userName == null) userName = "";
Changes changes = new Changes(userName, getSourceName(), getNowInUtc(),
this.changes);
observer.notify(changes);
}
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java 2009-10-28
00:41:28 UTC (rev 1312)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java 2009-10-28
14:43:17 UTC (rev 1313)
@@ -446,44 +446,47 @@
}
protected class ConfigurationChangeObserver extends NetChangeObserver {
+
/**
* {@inheritDoc}
*
- * @see
org.jboss.dna.graph.observe.NetChangeObserver#notify(org.jboss.dna.graph.observe.NetChangeObserver.NetChange)
+ * @see
org.jboss.dna.graph.observe.NetChangeObserver#notify(org.jboss.dna.graph.observe.NetChangeObserver.NetChanges)
*/
@Override
- protected void notify( NetChange change ) {
- if (!getConfigurationSourceName().equals(change.getRepositorySourceName()))
return;
- if
(!getConfigurationWorkspaceName().equals(change.getRepositoryWorkspaceName())) return;
- Path changedPath = change.getPath();
- Path configPath = getPathToConfigurationRoot();
- if (!changedPath.isAtOrBelow(getPathToConfigurationRoot())) return;
- boolean changedNodeIsPotentiallySource = configPath.size() + 1 ==
changedPath.size();
+ protected void notify( NetChanges netChanges ) {
+ if (!getConfigurationSourceName().equals(netChanges.getSourceName()))
return;
+ for (NetChange change : netChanges.getNetChanges()) {
+ if
(!getConfigurationWorkspaceName().equals(change.getRepositoryWorkspaceName())) return;
+ Path changedPath = change.getPath();
+ Path configPath = getPathToConfigurationRoot();
+ if (!changedPath.isAtOrBelow(getPathToConfigurationRoot())) return;
+ boolean changedNodeIsPotentiallySource = configPath.size() + 1 ==
changedPath.size();
- // At this point, we know that something inside the configuration changed, so
figure out what happened ...
- if (changedNodeIsPotentiallySource &&
change.includes(ChangeType.NODE_REMOVED)) {
- // Then potentially a source with the supplied name has been removed ...
- String sourceName =
changedPath.getLastSegment().getName().getLocalName();
- getRepositoryLibrary().removeSource(sourceName);
- } else {
- // The add/change/remove is either at or below a source, so try to create
a new source for it ...
- Path sourcePath = changedNodeIsPotentiallySource ? changedPath :
changedPath.subpath(0, configPath.size() + 1);
- Problems problems = new SimpleProblems();
- // Now read the node and create the source ...
- Graph graph = Graph.create(getConfigurationSourceName(),
getRepositoryLibrary(), getExecutionEnvironment());
- try {
- String workspaceName = getConfigurationWorkspaceName();
- if (workspaceName != null) graph.useWorkspace(workspaceName);
- Map<Name, Property> properties =
graph.getPropertiesByName().on(sourcePath);
- RepositorySource source = createRepositorySource(sourcePath,
properties, problems);
- if (source != null) {
- // It was the config for a source, so try to add or replace an
existing source ...
- getRepositoryLibrary().addSource(source, true);
- }
- } catch (PathNotFoundException e) {
- // No source was found, and this is okay (since it may just been
deleted)...
+ // At this point, we know that something inside the configuration
changed, so figure out what happened ...
+ if (changedNodeIsPotentiallySource &&
change.includes(ChangeType.NODE_REMOVED)) {
+ // Then potentially a source with the supplied name has been removed
...
String sourceName =
changedPath.getLastSegment().getName().getLocalName();
getRepositoryLibrary().removeSource(sourceName);
+ } else {
+ // The add/change/remove is either at or below a source, so try to
create a new source for it ...
+ Path sourcePath = changedNodeIsPotentiallySource ? changedPath :
changedPath.subpath(0, configPath.size() + 1);
+ Problems problems = new SimpleProblems();
+ // Now read the node and create the source ...
+ Graph graph = Graph.create(getConfigurationSourceName(),
getRepositoryLibrary(), getExecutionEnvironment());
+ try {
+ String workspaceName = getConfigurationWorkspaceName();
+ if (workspaceName != null) graph.useWorkspace(workspaceName);
+ Map<Name, Property> properties =
graph.getPropertiesByName().on(sourcePath);
+ RepositorySource source = createRepositorySource(sourcePath,
properties, problems);
+ if (source != null) {
+ // It was the config for a source, so try to add or replace
an existing source ...
+ getRepositoryLibrary().addSource(source, true);
+ }
+ } catch (PathNotFoundException e) {
+ // No source was found, and this is okay (since it may just been
deleted)...
+ String sourceName =
changedPath.getLastSegment().getName().getLocalName();
+ getRepositoryLibrary().removeSource(sourceName);
+ }
}
}
}
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java 2009-10-28
00:41:28 UTC (rev 1312)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java 2009-10-28
14:43:17 UTC (rev 1313)
@@ -23,9 +23,9 @@
*/
package org.jboss.dna.repository.sequencer;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -49,7 +49,9 @@
import org.jboss.dna.graph.connector.RepositorySource;
import org.jboss.dna.graph.observe.ChangeObserver;
import org.jboss.dna.graph.observe.NetChangeObserver;
+import org.jboss.dna.graph.observe.NetChangeObserver.ChangeType;
import org.jboss.dna.graph.observe.NetChangeObserver.NetChange;
+import org.jboss.dna.graph.observe.NetChangeObserver.NetChanges;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.Property;
@@ -388,95 +390,103 @@
* Do the work of processing by sequencing the node. This method is called by the
{@link #executorService executor service}
* when it performs it's work on the enqueued {@link NetChange NetChange runnable
objects}.
*
- * @param change the change describing the node to be processed.
+ * @param changes the change describing the node to be processed.
*/
- protected void processChange( NetChange change ) {
+ protected void processChange( NetChanges changes ) {
final ExecutionContext context = this.getExecutionContext();
final Logger logger = context.getLogger(getClass());
assert logger != null;
try {
- final String repositorySourceName = change.getRepositorySourceName();
- final String repositoryWorkspaceName = change.getRepositoryWorkspaceName();
+ List<Sequencer> allSequencers = null;
+ final String repositorySourceName = changes.getSourceName();
+ for (NetChange change : changes.getNetChanges()) {
+ // Go through each net change, and only process node/property adds and
property changes ...
+ if (change.includes(ChangeType.NODE_ADDED, ChangeType.PROPERTY_ADDED,
ChangeType.PROPERTY_CHANGED)) {
+ final String repositoryWorkspaceName =
change.getRepositoryWorkspaceName();
- // Figure out which sequencers accept this path,
- // and track which output nodes should be passed to each sequencer...
- final Path nodePath = change.getPath();
- final String nodePathStr =
context.getValueFactories().getStringFactory().create(nodePath);
- Map<SequencerCall, Set<RepositoryNodePath>> sequencerCalls = new
HashMap<SequencerCall, Set<RepositoryNodePath>>();
- List<Sequencer> allSequencers = this.sequencerLibrary.getInstances();
- List<Sequencer> sequencers = new
ArrayList<Sequencer>(allSequencers.size());
- for (Sequencer sequencer : allSequencers) {
- final SequencerConfig config = sequencer.getConfiguration();
- for (SequencerPathExpression pathExpression :
config.getPathExpressions()) {
- for (Property property : change.getModifiedProperties()) {
- Name propertyName = property.getName();
- String propertyNameStr =
context.getValueFactories().getStringFactory().create(propertyName);
- String path = nodePathStr + "/@" + propertyNameStr;
- SequencerPathExpression.Matcher matcher =
pathExpression.matcher(path);
- if (matcher.matches()) {
- // String selectedPath = matcher.getSelectedPath();
- RepositoryNodePath outputPath =
RepositoryNodePath.parse(matcher.getOutputPath(),
-
repositorySourceName,
-
repositoryWorkspaceName);
- SequencerCall call = new SequencerCall(sequencer,
propertyNameStr);
- // Record the output path ...
- Set<RepositoryNodePath> outputPaths =
sequencerCalls.get(call);
- if (outputPaths == null) {
- outputPaths = new HashSet<RepositoryNodePath>();
- sequencerCalls.put(call, outputPaths);
+ // Figure out which sequencers accept this path,
+ // and track which output nodes should be passed to each
sequencer...
+ final Path nodePath = change.getPath();
+ final String nodePathStr =
context.getValueFactories().getStringFactory().create(nodePath);
+ Map<SequencerCall, Set<RepositoryNodePath>>
sequencerCalls = new HashMap<SequencerCall, Set<RepositoryNodePath>>();
+ if (allSequencers == null) {
+ allSequencers = this.sequencerLibrary.getInstances();
+ }
+ List<Sequencer> sequencers = new
LinkedList<Sequencer>();
+ for (Sequencer sequencer : allSequencers) {
+ final SequencerConfig config = sequencer.getConfiguration();
+ for (SequencerPathExpression pathExpression :
config.getPathExpressions()) {
+ for (Property property : change.getModifiedProperties()) {
+ Name propertyName = property.getName();
+ String propertyNameStr =
context.getValueFactories().getStringFactory().create(propertyName);
+ String path = nodePathStr + "/@" +
propertyNameStr;
+ SequencerPathExpression.Matcher matcher =
pathExpression.matcher(path);
+ if (matcher.matches()) {
+ // String selectedPath = matcher.getSelectedPath();
+ RepositoryNodePath outputPath =
RepositoryNodePath.parse(matcher.getOutputPath(),
+
repositorySourceName,
+
repositoryWorkspaceName);
+ SequencerCall call = new SequencerCall(sequencer,
propertyNameStr);
+ // Record the output path ...
+ Set<RepositoryNodePath> outputPaths =
sequencerCalls.get(call);
+ if (outputPaths == null) {
+ outputPaths = new
HashSet<RepositoryNodePath>();
+ sequencerCalls.put(call, outputPaths);
+ }
+ outputPaths.add(outputPath);
+ sequencers.add(sequencer);
+ break;
+ }
}
- outputPaths.add(outputPath);
- sequencers.add(sequencer);
- break;
}
}
- }
- }
- RepositorySource source = repositoryLibrary.getSource(repositorySourceName);
- Graph graph = Graph.create(source, context);
- Node node = null;
- if (!sequencers.isEmpty()) {
+ RepositorySource source =
repositoryLibrary.getSource(repositorySourceName);
+ Graph graph = Graph.create(source, context);
+ Node node = null;
+ if (!sequencers.isEmpty()) {
- // Find the changed node ...
- node = graph.getNodeAt(nodePath);
+ // Find the changed node ...
+ node = graph.getNodeAt(nodePath);
- // Figure out which sequencers should run ...
- sequencers = this.sequencerSelector.selectSequencers(sequencers, node,
change);
- }
- if (sequencers.isEmpty()) {
- this.statistics.recordNodeSkipped();
- if (logger.isDebugEnabled()) {
- logger.trace("Skipping '{0}': no sequencers matched this
condition", change);
- }
- } else {
- // Run each of those sequencers ...
- for (Map.Entry<SequencerCall, Set<RepositoryNodePath>> entry
: sequencerCalls.entrySet()) {
+ // Figure out which sequencers should run ...
+ sequencers = this.sequencerSelector.selectSequencers(sequencers,
node, change);
+ }
+ if (sequencers.isEmpty()) {
+ this.statistics.recordNodeSkipped();
+ if (logger.isDebugEnabled()) {
+ logger.trace("Skipping '{0}': no sequencers
matched this condition", change);
+ }
+ } else {
+ // Run each of those sequencers ...
+ for (Map.Entry<SequencerCall,
Set<RepositoryNodePath>> entry : sequencerCalls.entrySet()) {
- final SequencerCall sequencerCall = entry.getKey();
- final Set<RepositoryNodePath> outputPaths = entry.getValue();
- final Sequencer sequencer = sequencerCall.getSequencer();
- final String sequencerName = sequencer.getConfiguration().getName();
- final String propertyName =
sequencerCall.getSequencedPropertyName();
+ final SequencerCall sequencerCall = entry.getKey();
+ final Set<RepositoryNodePath> outputPaths =
entry.getValue();
+ final Sequencer sequencer = sequencerCall.getSequencer();
+ final String sequencerName =
sequencer.getConfiguration().getName();
+ final String propertyName =
sequencerCall.getSequencedPropertyName();
- // Get the paths to the nodes where the sequencer should write
it's output ...
- assert outputPaths != null && outputPaths.size() != 0;
+ // Get the paths to the nodes where the sequencer should
write it's output ...
+ assert outputPaths != null && outputPaths.size() !=
0;
- // Create a new execution context for each sequencer
- final SimpleProblems problems = new SimpleProblems();
- SequencerContext sequencerContext = new SequencerContext(context,
graph);
- try {
- sequencer.execute(node, propertyName, change, outputPaths,
sequencerContext, problems);
- sequencerContext.getDestination().submit();
- } catch (SequencerException e) {
- logger.error(e, RepositoryI18n.errorWhileSequencingNode,
sequencerName, change);
+ // Create a new execution context for each sequencer
+ final SimpleProblems problems = new SimpleProblems();
+ SequencerContext sequencerContext = new
SequencerContext(context, graph);
+ try {
+ sequencer.execute(node, propertyName, change,
outputPaths, sequencerContext, problems);
+ sequencerContext.getDestination().submit();
+ } catch (SequencerException e) {
+ logger.error(e, RepositoryI18n.errorWhileSequencingNode,
sequencerName, change);
+ }
+ }
+ this.statistics.recordNodeSequenced();
}
}
- this.statistics.recordNodeSequenced();
}
} catch (Throwable e) {
- logger.error(e, RepositoryI18n.errorFindingSequencersToRunAgainstNode,
change);
+ logger.error(e, RepositoryI18n.errorFindingSequencersToRunAgainstNode,
changes);
}
}
@@ -594,22 +604,19 @@
/**
* {@inheritDoc}
*
- * @see
org.jboss.dna.graph.observe.NetChangeObserver#notify(org.jboss.dna.graph.observe.NetChangeObserver.NetChange)
+ * @see
org.jboss.dna.graph.observe.NetChangeObserver#notify(org.jboss.dna.graph.observe.NetChangeObserver.NetChanges)
*/
@Override
- protected void notify( final NetChange change ) {
- // Only care about new nodes or nodes that have new/changed properies ...
- if (change.includes(ChangeType.NODE_ADDED, ChangeType.PROPERTY_ADDED,
ChangeType.PROPERTY_CHANGED)) {
- try {
- getExecutorService().execute(new Runnable() {
+ protected void notify( final NetChanges netChanges ) {
+ try {
+ getExecutorService().execute(new Runnable() {
- public void run() {
- processChange(change);
- }
- });
- } catch (RejectedExecutionException e) {
- // The executor service has been shut down, so do nothing with this
set of changes
- }
+ public void run() {
+ processChange(netChanges);
+ }
+ });
+ } catch (RejectedExecutionException e) {
+ // The executor service has been shut down, so do nothing with this set
of changes
}
}
}
Modified:
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java
===================================================================
---
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java 2009-10-28
00:41:28 UTC (rev 1312)
+++
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java 2009-10-28
14:43:17 UTC (rev 1313)
@@ -131,9 +131,8 @@
Location location =
Location.create(context.getValueFactories().getPathFactory().create("/a/b/c"));
Property sequencedProperty =
inputNode.getProperty("sequencedProperty");
- NetChange nodeChange = new NetChange(repositorySourceName,
repositoryWorkspaceName, location,
- EnumSet.of(ChangeType.PROPERTY_CHANGED),
Collections.singleton(sequencedProperty),
- null);
+ NetChange nodeChange = new NetChange(repositoryWorkspaceName, location,
EnumSet.of(ChangeType.PROPERTY_CHANGED),
+ Collections.singleton(sequencedProperty),
null);
Set<RepositoryNodePath> outputPaths = new
HashSet<RepositoryNodePath>();
outputPaths.add(new RepositoryNodePath(repositorySourceName,
repositoryWorkspaceName, "/d/e"));
sequencerOutput.setProperty("alpha/beta", "isSomething",
true);
@@ -190,9 +189,8 @@
// Set up the node changes ...
Location location =
Location.create(context.getValueFactories().getPathFactory().create("/a/b/c"));
Property sequencedProperty = nodeC.getProperty("sequencedProperty");
- NetChange nodeChange = new NetChange(repositorySourceName,
repositoryWorkspaceName, location,
- EnumSet.of(ChangeType.PROPERTY_CHANGED),
Collections.singleton(sequencedProperty),
- null);
+ NetChange nodeChange = new NetChange(repositoryWorkspaceName, location,
EnumSet.of(ChangeType.PROPERTY_CHANGED),
+ Collections.singleton(sequencedProperty),
null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new
HashSet<RepositoryNodePath>();
@@ -226,9 +224,8 @@
// Set up the node changes ...
Location location =
Location.create(context.getValueFactories().getPathFactory().create("/a/b/c"));
Property sequencedProperty = nodeC.getProperty("sequencedProperty");
- NetChange nodeChange = new NetChange(repositorySourceName,
repositoryWorkspaceName, location,
- EnumSet.of(ChangeType.PROPERTY_CHANGED),
Collections.singleton(sequencedProperty),
- null);
+ NetChange nodeChange = new NetChange(repositoryWorkspaceName, location,
EnumSet.of(ChangeType.PROPERTY_CHANGED),
+ Collections.singleton(sequencedProperty),
null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new
HashSet<RepositoryNodePath>();
@@ -262,9 +259,8 @@
// Set up the node changes ...
Location location =
Location.create(context.getValueFactories().getPathFactory().create("/a/b/c"));
Property sequencedProperty = nodeC.getProperty("sequencedProperty");
- NetChange nodeChange = new NetChange(repositorySourceName,
repositoryWorkspaceName, location,
- EnumSet.of(ChangeType.PROPERTY_CHANGED),
Collections.singleton(sequencedProperty),
- null);
+ NetChange nodeChange = new NetChange(repositoryWorkspaceName, location,
EnumSet.of(ChangeType.PROPERTY_CHANGED),
+ Collections.singleton(sequencedProperty),
null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new
HashSet<RepositoryNodePath>();
@@ -303,9 +299,8 @@
// Set up the node changes ...
Location location =
Location.create(context.getValueFactories().getPathFactory().create("/a/b/c"));
Property sequencedProperty = nodeC.getProperty("sequencedProperty");
- NetChange nodeChange = new NetChange(repositorySourceName,
repositoryWorkspaceName, location,
- EnumSet.of(ChangeType.PROPERTY_CHANGED),
Collections.singleton(sequencedProperty),
- null);
+ NetChange nodeChange = new NetChange(repositoryWorkspaceName, location,
EnumSet.of(ChangeType.PROPERTY_CHANGED),
+ Collections.singleton(sequencedProperty),
null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new
HashSet<RepositoryNodePath>();
@@ -348,9 +343,8 @@
// Set up the node changes ...
Location location =
Location.create(context.getValueFactories().getPathFactory().create("/a/b/c"));
Property sequencedProperty = nodeC.getProperty("sequencedProperty");
- NetChange nodeChange = new NetChange(repositorySourceName,
repositoryWorkspaceName, location,
- EnumSet.of(ChangeType.PROPERTY_CHANGED),
Collections.singleton(sequencedProperty),
- null);
+ NetChange nodeChange = new NetChange(repositoryWorkspaceName, location,
EnumSet.of(ChangeType.PROPERTY_CHANGED),
+ Collections.singleton(sequencedProperty),
null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new
HashSet<RepositoryNodePath>();