Author: rhauch
Date: 2008-08-05 17:05:45 -0400 (Tue, 05 Aug 2008)
New Revision: 379
Added:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/FederatedNode.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/MergeStrategy.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/OneContributionMergeStrategy.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/StandardMergeStrategy.java
Removed:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/BasicFederatedNode.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/FederatedNode.java
Modified:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepositorySource.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/Projection.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/FederatingCommandExecutor.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/ProjectedCreateNodeCommand.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/ProjectedGetChildrenCommand.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/ProjectedGetPropertiesCommand.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/ProjectedSetPropertiesCommand.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/SingleProjectionCommandExecutor.java
trunk/connectors/dna-connector-inmemory/src/main/java/org/jboss/dna/connector/inmemory/InMemoryRepository.java
trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/Cacheable.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/ActsOnProperties.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/CreateNodeCommand.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/GetChildrenCommand.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/executor/AbstractCommandExecutor.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicCreateNodeCommand.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetChildrenCommand.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetNodeCommand.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetPropertiesCommand.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicSetPropertiesCommand.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/commands/executor/AbstractCommandExecutorTest.java
Log:
DNA-115 - Create federation service
http://jira.jboss.com/jira/browse/DNA-115
Renamed the "getEnvironment()" methods to "getExecutionContext()" to
reflect the previous change in name of the ExecutionContext (was ExecutionEnvironment).
Also renamed the "getProperties()" method of some of the SPI graph commands that
returned an Iterator<Property> to now be "getPropertyIterator()", which is
now consistent with the other graph commands. Made FederatedNode a concrete class (not an
interface), moved it, and implemented additional interfaces so that it can be treated as a
GetNodeCommand. Finally, made more changes to the FederationCommandExecutor
implementation.
Modified:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepositorySource.java
===================================================================
---
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepositorySource.java 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepositorySource.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -688,13 +688,13 @@
final String configurationSourceName = configurationProjection.getSourceName();
List<Projection> projections =
Collections.singletonList(configurationProjection);
CommandExecutor executor = null;
- if (configurationProjection.getRules().size() == 1) {
+ if (configurationProjection.getRules().size() == 0) {
+ // There is no projection for the configuration repository, so just use a
no-op executor
+ executor = new NoOpCommandExecutor(context, configurationSourceName);
+ } else if (configurationProjection.isSimple()) {
// There is just a single projection for the configuration repository, so
just use an executor that
// translates the paths using the projection
executor = new SingleProjectionCommandExecutor(context,
configurationSourceName, configurationProjection, factories);
- } else if (configurationProjection.getRules().size() == 0) {
- // There is no projection for the configuration repository, so just use a
no-op executor
- executor = new NoOpCommandExecutor(context, configurationSourceName);
} else {
// The configuration repository has more than one projection, so we need to
merge the results
executor = new FederatingCommandExecutor(context, configurationSourceName,
projections, factories);
Modified:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/Projection.java
===================================================================
---
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/Projection.java 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/Projection.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -228,6 +228,7 @@
private final String sourceName;
private final List<Rule> rules;
+ private final boolean simple;
/**
* Create a new federated projection for the supplied source, using the supplied
rules.
@@ -247,6 +248,7 @@
}
this.rules = Collections.unmodifiableList(rulesList);
ArgCheck.isNotEmpty(this.rules, "rules");
+ this.simple = computeSimpleProjection(this.rules);
}
/**
@@ -313,6 +315,39 @@
}
/**
+ * Determine whether this project is a simple projection that only involves for any
one repository path no more than a single
+ * source path.
+ *
+ * @return true if this projection is a simple projection, or false if the projection
is not simple (or it cannot be
+ * determined if it is simple)
+ */
+ public boolean isSimple() {
+ return simple;
+ }
+
+ protected boolean computeSimpleProjection( List<Rule> rules ) {
+ // Get the set of repository paths for the rules, and see if they overlap ...
+ Set<Path> repositoryPaths = new HashSet<Path>();
+ for (Rule rule : rules) {
+ if (rule instanceof PathRule) {
+ PathRule pathRule = (PathRule)rule;
+ Path repoPath = pathRule.getPathInRepository();
+ if (!repositoryPaths.isEmpty()) {
+ if (repositoryPaths.contains(repoPath)) return false;
+ for (Path path : repositoryPaths) {
+ if (path.isAtOrAbove(repoPath)) return false;
+ if (repoPath.isAtOrAbove(path)) return false;
+ }
+ }
+ repositoryPaths.add(repoPath);
+ } else {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
* {@inheritDoc}
*
* @see java.lang.Object#hashCode()
Modified:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/FederatingCommandExecutor.java
===================================================================
---
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/FederatingCommandExecutor.java 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/FederatingCommandExecutor.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -29,11 +29,16 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.UUID;
import net.jcip.annotations.NotThreadSafe;
import org.jboss.dna.common.util.Logger;
import org.jboss.dna.connector.federation.Projection;
import org.jboss.dna.connector.federation.contribution.Contribution;
+import org.jboss.dna.connector.federation.merge.FederatedNode;
import org.jboss.dna.connector.federation.merge.MergePlan;
+import org.jboss.dna.connector.federation.merge.MergeStrategy;
+import org.jboss.dna.connector.federation.merge.OneContributionMergeStrategy;
+import org.jboss.dna.connector.federation.merge.StandardMergeStrategy;
import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.cache.CachePolicy;
import org.jboss.dna.spi.graph.DateTime;
@@ -51,6 +56,7 @@
import org.jboss.dna.spi.graph.commands.NodeConflictBehavior;
import org.jboss.dna.spi.graph.commands.executor.AbstractCommandExecutor;
import org.jboss.dna.spi.graph.commands.impl.BasicCreateNodeCommand;
+import org.jboss.dna.spi.graph.commands.impl.BasicGetChildrenCommand;
import org.jboss.dna.spi.graph.commands.impl.BasicGetNodeCommand;
import org.jboss.dna.spi.graph.commands.impl.BasicGetPropertiesCommand;
import org.jboss.dna.spi.graph.connection.RepositoryConnection;
@@ -58,6 +64,7 @@
import org.jboss.dna.spi.graph.connection.RepositoryConnectionFactory;
import org.jboss.dna.spi.graph.connection.RepositorySource;
import org.jboss.dna.spi.graph.connection.RepositorySourceException;
+import org.jboss.dna.spi.graph.impl.BasicSingleValueProperty;
/**
* @author Randall Hauch
@@ -65,12 +72,14 @@
@NotThreadSafe
public class FederatingCommandExecutor extends AbstractCommandExecutor {
+ private final Name uuidPropertyName;
private final Name mergePlanPropertyName;
private final CachePolicy defaultCachePolicy;
private final Projection cacheProjection;
private final List<Projection> sourceProjections;
private final Set<String> sourceNames;
private final RepositoryConnectionFactories connectionFactories;
+ private final MergeStrategy mergingStrategy;
/** The set of all connections, including the cache connection */
private final Map<String, RepositoryConnection> connectionsBySourceName;
/** A direct reference to the cache connection */
@@ -125,11 +134,17 @@
this.sourceProjections = sourceProjections;
this.connectionFactories = connectionFactories;
this.connectionsBySourceName = new HashMap<String,
RepositoryConnection>();
+ this.uuidPropertyName =
context.getValueFactories().getNameFactory().create("dna:uuid");
this.mergePlanPropertyName =
context.getValueFactories().getNameFactory().create("dna:mergePlan");
this.sourceNames = new HashSet<String>();
for (Projection projection : this.sourceProjections) {
this.sourceNames.add(projection.getSourceName());
}
+ if (this.sourceProjections.size() == 1 &&
this.sourceProjections.get(0).isSimple()) {
+ this.mergingStrategy = new OneContributionMergeStrategy();
+ } else {
+ this.mergingStrategy = new StandardMergeStrategy();
+ }
}
/**
@@ -228,22 +243,52 @@
*/
protected BasicGetNodeCommand getNode( Path path ) throws RepositorySourceException,
InterruptedException {
// Check the cache first ...
- final ExecutionContext context = getEnvironment();
+ final ExecutionContext context = getExecutionContext();
RepositoryConnection cacheConnection = getConnectionToCache();
BasicGetNodeCommand fromCache = new BasicGetNodeCommand(path);
cacheConnection.execute(context, fromCache);
if (fromCache.hasError()) {
if (fromCache.getError() instanceof PathNotFoundException) {
- // Start at the root and populate the cache down to this node ...
+ // The path was not found in the cache, so since we don't know
whether the ancestors are federated
+ // from multiple source nodes, we need to populate the cache starting
with the lowest ancestor
+ // that already exists in the cache.
+ PathNotFoundException notFound =
(PathNotFoundException)fromCache.getError();
+ Path lowestExistingAncestor = notFound.getLowestAncestorThatDoesExist();
+ Path ancestor = path.getAncestor();
+
+ if (!ancestor.equals(lowestExistingAncestor)) {
+ // Create the commands that load the children (not properties) of the
existing ancestor,
+ // then the children (not properties) of the child next on the
desired path, etc.,
+ // down to (but excluding) the desired path.
+ LinkedList<BasicGetChildrenCommand> loadChildrenCommands = new
LinkedList<BasicGetChildrenCommand>();
+ Path pathToLoad = path.getAncestor();
+ while (!pathToLoad.equals(lowestExistingAncestor)) {
+ BasicGetChildrenCommand command = new
BasicGetChildrenCommand(pathToLoad);
+ loadChildrenCommands.addFirst(command);
+ pathToLoad = pathToLoad.getAncestor();
+ }
+ // Now execute these commands (one-by-one is fine, since this is an
executor) ...
+ for (BasicGetChildrenCommand command : loadChildrenCommands) {
+ execute(command);
+ }
+ }
+
+ // Load the node from the sources ...
+ FederatedNode mergedNode = loadFromSources(path);
+
+ // Place the results into the cache ...
+ updateCache(mergedNode);
+
+ // Return the results ...
+ return mergedNode;
}
+ return fromCache; // with an error
}
- if (fromCache.hasError()) return fromCache;
-
- // Look up the merge plan ...
+ // The cache had the node information, so look for the merge plan ...
MergePlan mergePlan = getMergePlan(fromCache);
- if (mergePlan != null) {
- if (isCurrent(path, mergePlan)) return fromCache;
+ assert mergePlan != null;
+ if (!isCurrent(path, mergePlan)) {
// Some of the merge plan is out of date, so we need to read the information
from those regions that are expired ...
// MergePlan newMergePlan = new BasicMergePlan();
// for (Projection projection : sourceProjections) {
@@ -267,97 +312,89 @@
// }
// What about other (new) regions?
- } else {
- // At this point, there is no merge plan, so read information from the
sources ...
- PathFactory pathFactory = context.getValueFactories().getPathFactory();
- DateTimeFactory timeFactory = context.getValueFactories().getDateFactory();
- List<Contribution> contributions = new
LinkedList<Contribution>();
- for (Projection projection : this.sourceProjections) {
- final String source = projection.getSourceName();
- final RepositoryConnection sourceConnection = getConnection(projection);
- try {
- // Get the cached information ...
- CachePolicy cachePolicy = sourceConnection.getDefaultCachePolicy();
- if (cachePolicy == null) cachePolicy = this.defaultCachePolicy;
- DateTime expirationTime = null;
- if (cachePolicy != null) {
- expirationTime = timeFactory.create(getCurrentTimeInUtc(),
cachePolicy.getTimeToLive());
- }
- // Get the paths-in-source where we should fetch node contributions
...
- Set<Path> pathsInSource = projection.getPathsInSource(path,
pathFactory);
- if (pathsInSource.isEmpty()) {
- // The source has no contributions ...
- contributions.add(Contribution.create(source, expirationTime));
- } else {
- // There is at least one contribution ...
+ }
- // Get the contributions ...
- final int numPaths = pathsInSource.size();
- if (numPaths == 1) {
- Path pathInSource = pathsInSource.iterator().next();
- BasicGetNodeCommand fromSource = new
BasicGetNodeCommand(pathInSource);
- sourceConnection.execute(getEnvironment(), fromSource);
- if (!fromSource.hasError()) {
- Collection<Property> properties =
fromSource.getProperties().values();
- Collection<Segment> children =
fromSource.getChildren();
- DateTime expTime = fromSource.getCachePolicy() == null ?
expirationTime : timeFactory.create(getCurrentTimeInUtc(),
-
fromSource.getCachePolicy().getTimeToLive());
- Contribution contribution = Contribution.create(source,
-
pathInSource,
- expTime,
-
properties,
-
children);
- contributions.add(contribution);
- }
- } else {
- BasicGetNodeCommand[] fromSourceCommands = new
BasicGetNodeCommand[numPaths];
- int i = 0;
- for (Path pathInSource : pathsInSource) {
- fromSourceCommands[i++] = new
BasicGetNodeCommand(pathInSource);
- }
- sourceConnection.execute(getEnvironment(),
fromSourceCommands);
- for (BasicGetNodeCommand fromSource : fromSourceCommands) {
- if (fromSource.hasError()) continue;
- Collection<Property> properties =
fromSource.getProperties().values();
- Collection<Segment> children =
fromSource.getChildren();
- DateTime expTime = fromSource.getCachePolicy() == null ?
expirationTime : timeFactory.create(getCurrentTimeInUtc(),
-
fromSource.getCachePolicy().getTimeToLive());
- Contribution contribution = Contribution.create(source,
-
fromSource.getPath(),
- expTime,
-
properties,
-
children);
- contributions.add(contribution);
- }
+ return fromCache;
+ }
+
+ /**
+ * @param path the path of the node that is to be loaded
+ * @return the federated node containing information loaded from the sources
+ * @throws InterruptedException
+ * @throws RepositorySourceException
+ */
+ protected FederatedNode loadFromSources( Path path ) throws
RepositorySourceException, InterruptedException {
+ // At this point, there is no merge plan, so read information from the sources
...
+ ExecutionContext context = getExecutionContext();
+ PathFactory pathFactory = context.getValueFactories().getPathFactory();
+ DateTimeFactory timeFactory = context.getValueFactories().getDateFactory();
+ List<Contribution> contributions = new LinkedList<Contribution>();
+ for (Projection projection : this.sourceProjections) {
+ final String source = projection.getSourceName();
+ final RepositoryConnection sourceConnection = getConnection(projection);
+ try {
+ // Get the cached information ...
+ CachePolicy cachePolicy = sourceConnection.getDefaultCachePolicy();
+ if (cachePolicy == null) cachePolicy = this.defaultCachePolicy;
+ DateTime expirationTime = null;
+ if (cachePolicy != null) {
+ expirationTime = timeFactory.create(getCurrentTimeInUtc(),
cachePolicy.getTimeToLive());
+ }
+ // Get the paths-in-source where we should fetch node contributions ...
+ Set<Path> pathsInSource = projection.getPathsInSource(path,
pathFactory);
+ if (pathsInSource.isEmpty()) {
+ // The source has no contributions ...
+ contributions.add(Contribution.create(source, expirationTime));
+ } else {
+ // There is at least one contribution ...
+
+ // Get the contributions ...
+ final int numPaths = pathsInSource.size();
+ if (numPaths == 1) {
+ Path pathInSource = pathsInSource.iterator().next();
+ BasicGetNodeCommand fromSource = new
BasicGetNodeCommand(pathInSource);
+ sourceConnection.execute(getExecutionContext(), fromSource);
+ if (!fromSource.hasError()) {
+ Collection<Property> properties =
fromSource.getProperties().values();
+ Collection<Segment> children =
fromSource.getChildren();
+ DateTime expTime = fromSource.getCachePolicy() == null ?
expirationTime : timeFactory.create(getCurrentTimeInUtc(),
+
fromSource.getCachePolicy().getTimeToLive());
+ Contribution contribution = Contribution.create(source,
pathInSource, expTime, properties, children);
+ contributions.add(contribution);
}
+ } else {
+ BasicGetNodeCommand[] fromSourceCommands = new
BasicGetNodeCommand[numPaths];
+ int i = 0;
+ for (Path pathInSource : pathsInSource) {
+ fromSourceCommands[i++] = new
BasicGetNodeCommand(pathInSource);
+ }
+ sourceConnection.execute(context, fromSourceCommands);
+ for (BasicGetNodeCommand fromSource : fromSourceCommands) {
+ if (fromSource.hasError()) continue;
+ Collection<Property> properties =
fromSource.getProperties().values();
+ Collection<Segment> children =
fromSource.getChildren();
+ DateTime expTime = fromSource.getCachePolicy() == null ?
expirationTime : timeFactory.create(getCurrentTimeInUtc(),
+
fromSource.getCachePolicy().getTimeToLive());
+ Contribution contribution = Contribution.create(source,
+
fromSource.getPath(),
+ expTime,
+ properties,
+ children);
+ contributions.add(contribution);
+ }
}
- } finally {
- sourceConnection.close();
}
+ } finally {
+ sourceConnection.close();
}
- // Merge the results into a single set of results ...
- mergePlan = MergePlan.create(contributions);
- BasicGetNodeCommand mergedNode = new BasicGetNodeCommand(null);
-
- // Place the results into the cache ...
- NodeConflictBehavior conflictBehavior = NodeConflictBehavior.UPDATE;
- BasicCreateNodeCommand newNode = new BasicCreateNodeCommand(path,
mergedNode.getProperties().values(),
-
conflictBehavior);
- List<Segment> children = mergedNode.getChildren();
- GraphCommand[] intoCache = new GraphCommand[1 + children.size()];
- int i = 0;
- intoCache[i++] = newNode;
- List<Property> noProperties = Collections.emptyList();
- for (Segment child : mergedNode.getChildren()) {
- intoCache[i++] = new BasicCreateNodeCommand(pathFactory.create(path,
child), noProperties, conflictBehavior);
- }
- cacheConnection.execute(getEnvironment(), mergedNode);
-
- // Return the results ...
- return mergedNode;
}
-
- return null;
+ // Merge the results into a single set of results ...
+ FederatedNode mergedNode = new FederatedNode(path, UUID.randomUUID());
+ mergingStrategy.merge(mergedNode, contributions, context);
+ if (mergedNode.getCachePolicy() == null) {
+ mergedNode.setCachePolicy(defaultCachePolicy);
+ }
+ return mergedNode;
}
protected MergePlan getMergePlan( BasicGetPropertiesCommand command ) {
@@ -369,6 +406,28 @@
return value instanceof MergePlan ? (MergePlan)value : null;
}
+ protected void updateCache( FederatedNode mergedNode ) throws
RepositorySourceException, InterruptedException {
+ final ExecutionContext context = getExecutionContext();
+ final RepositoryConnection cacheConnection = getConnectionToCache();
+ final Path path = mergedNode.getPath();
+
+ NodeConflictBehavior conflictBehavior = NodeConflictBehavior.UPDATE;
+ BasicCreateNodeCommand newNode = new BasicCreateNodeCommand(path,
mergedNode.getProperties().values(), conflictBehavior);
+ newNode.setProperty(new BasicSingleValueProperty(this.uuidPropertyName,
mergedNode.getUuid()));
+ List<Segment> children = mergedNode.getChildren();
+ GraphCommand[] intoCache = new GraphCommand[1 + children.size()];
+ int i = 0;
+ intoCache[i++] = newNode;
+ List<Property> noProperties = Collections.emptyList();
+ PathFactory pathFactory = context.getValueFactories().getPathFactory();
+ for (Segment child : mergedNode.getChildren()) {
+ newNode = new BasicCreateNodeCommand(pathFactory.create(path, child),
noProperties, conflictBehavior);
+ // newNode.setProperty(new BasicSingleValueProperty(this.uuidPropertyName,
mergedNode.getUuid()));
+ intoCache[i++] = newNode;
+ }
+ cacheConnection.execute(context, intoCache);
+ }
+
/**
* Determine if the supplied plan is considered current
*
Modified:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/ProjectedCreateNodeCommand.java
===================================================================
---
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/ProjectedCreateNodeCommand.java 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/ProjectedCreateNodeCommand.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -48,10 +48,10 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.spi.graph.commands.CreateNodeCommand#getProperties()
+ * @see org.jboss.dna.spi.graph.commands.CreateNodeCommand#getPropertyIterator()
*/
- public Iterable<Property> getProperties() {
- return getOriginalCommand().getProperties();
+ public Iterable<Property> getPropertyIterator() {
+ return getOriginalCommand().getPropertyIterator();
}
/**
Modified:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/ProjectedGetChildrenCommand.java
===================================================================
---
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/ProjectedGetChildrenCommand.java 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/ProjectedGetChildrenCommand.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -23,6 +23,7 @@
import java.util.Iterator;
import org.jboss.dna.spi.cache.CachePolicy;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Path.Segment;
@@ -81,6 +82,24 @@
/**
* {@inheritDoc}
*
+ * @see
org.jboss.dna.spi.graph.commands.GetChildrenCommand#addChild(org.jboss.dna.spi.graph.Path.Segment)
+ */
+ public void addChild( Segment nameOfChild ) {
+ getOriginalCommand().addChild(nameOfChild);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.spi.graph.commands.GetChildrenCommand#addChildren(org.jboss.dna.spi.graph.Path.Segment[])
+ */
+ public void addChildren( Segment... namesOfChildren ) {
+ getOriginalCommand().addChildren(namesOfChildren);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.jboss.dna.spi.graph.commands.GetChildrenCommand#setNoChildren()
*/
public void setNoChildren() {
@@ -101,7 +120,7 @@
*
* @see org.jboss.dna.spi.cache.Cacheable#getTimeLoaded()
*/
- public long getTimeLoaded() {
+ public DateTime getTimeLoaded() {
return getOriginalCommand().getTimeLoaded();
}
Modified:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/ProjectedGetPropertiesCommand.java
===================================================================
---
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/ProjectedGetPropertiesCommand.java 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/ProjectedGetPropertiesCommand.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -22,6 +22,7 @@
package org.jboss.dna.connector.federation.executor;
import org.jboss.dna.spi.cache.CachePolicy;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Property;
import org.jboss.dna.spi.graph.commands.GetPropertiesCommand;
@@ -55,7 +56,7 @@
*
* @see org.jboss.dna.spi.cache.Cacheable#getTimeLoaded()
*/
- public long getTimeLoaded() {
+ public DateTime getTimeLoaded() {
return getOriginalCommand().getTimeLoaded();
}
Modified:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/ProjectedSetPropertiesCommand.java
===================================================================
---
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/ProjectedSetPropertiesCommand.java 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/ProjectedSetPropertiesCommand.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -39,10 +39,10 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.spi.graph.commands.ActsOnProperties#getProperties()
+ * @see org.jboss.dna.spi.graph.commands.ActsOnProperties#getPropertyIterator()
*/
- public Iterable<Property> getProperties() {
- return getOriginalCommand().getProperties();
+ public Iterable<Property> getPropertyIterator() {
+ return getOriginalCommand().getPropertyIterator();
}
}
Modified:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/SingleProjectionCommandExecutor.java
===================================================================
---
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/SingleProjectionCommandExecutor.java 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/SingleProjectionCommandExecutor.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -127,7 +127,7 @@
@Override
public void execute( GetChildrenCommand command ) throws RepositorySourceException,
InterruptedException {
Path pathInSource = getPathInSource(command.getPath());
- getConnection().execute(this.getEnvironment(), new
ProjectedGetChildrenCommand(command, pathInSource));
+ getConnection().execute(this.getExecutionContext(), new
ProjectedGetChildrenCommand(command, pathInSource));
}
/**
@@ -138,7 +138,7 @@
@Override
public void execute( GetPropertiesCommand command ) throws RepositorySourceException,
InterruptedException {
Path pathInSource = getPathInSource(command.getPath());
- getConnection().execute(this.getEnvironment(), new
ProjectedGetPropertiesCommand(command, pathInSource));
+ getConnection().execute(this.getExecutionContext(), new
ProjectedGetPropertiesCommand(command, pathInSource));
}
/**
@@ -149,7 +149,7 @@
@Override
public void execute( GetNodeCommand command ) throws RepositorySourceException,
InterruptedException {
Path pathInSource = getPathInSource(command.getPath());
- getConnection().execute(this.getEnvironment(), new
ProjectedGetNodeCommand(command, pathInSource));
+ getConnection().execute(this.getExecutionContext(), new
ProjectedGetNodeCommand(command, pathInSource));
}
/**
@@ -160,7 +160,7 @@
@Override
public void execute( CreateNodeCommand command ) throws RepositorySourceException,
InterruptedException {
Path pathInSource = getPathInSource(command.getPath());
- getConnection().execute(this.getEnvironment(), new
ProjectedCreateNodeCommand(command, pathInSource));
+ getConnection().execute(this.getExecutionContext(), new
ProjectedCreateNodeCommand(command, pathInSource));
}
/**
@@ -171,7 +171,7 @@
@Override
public void execute( SetPropertiesCommand command ) throws RepositorySourceException,
InterruptedException {
Path pathInSource = getPathInSource(command.getPath());
- getConnection().execute(this.getEnvironment(), new
ProjectedSetPropertiesCommand(command, pathInSource));
+ getConnection().execute(this.getExecutionContext(), new
ProjectedSetPropertiesCommand(command, pathInSource));
}
/**
@@ -182,7 +182,7 @@
@Override
public void execute( DeleteBranchCommand command ) throws RepositorySourceException,
InterruptedException {
Path pathInSource = getPathInSource(command.getPath());
- getConnection().execute(this.getEnvironment(), new
ProjectedDeleteBranchCommand(command, pathInSource));
+ getConnection().execute(this.getExecutionContext(), new
ProjectedDeleteBranchCommand(command, pathInSource));
}
/**
@@ -194,7 +194,7 @@
public void execute( MoveBranchCommand command ) throws RepositorySourceException,
InterruptedException {
Path pathInSource = getPathInSource(command.getPath());
Path newPathInSource = getPathInSource(command.getNewPath());
- getConnection().execute(this.getEnvironment(), new
ProjectedMoveBranchCommand(command, pathInSource, newPathInSource));
+ getConnection().execute(this.getExecutionContext(), new
ProjectedMoveBranchCommand(command, pathInSource, newPathInSource));
}
/**
@@ -205,7 +205,7 @@
@Override
public void execute( RecordBranchCommand command ) throws RepositorySourceException,
InterruptedException {
Path pathInSource = getPathInSource(command.getPath());
- getConnection().execute(this.getEnvironment(), new
ProjectedRecordBranchCommand(command, pathInSource));
+ getConnection().execute(this.getExecutionContext(), new
ProjectedRecordBranchCommand(command, pathInSource));
}
/**
@@ -217,7 +217,7 @@
public void execute( CopyBranchCommand command ) throws RepositorySourceException,
InterruptedException {
Path pathInSource = getPathInSource(command.getPath());
Path newPathInSource = getPathInSource(command.getNewPath());
- getConnection().execute(this.getEnvironment(), new
ProjectedCopyBranchCommand(command, pathInSource, newPathInSource));
+ getConnection().execute(this.getExecutionContext(), new
ProjectedCopyBranchCommand(command, pathInSource, newPathInSource));
}
/**
@@ -229,7 +229,7 @@
public void execute( CopyNodeCommand command ) throws RepositorySourceException,
InterruptedException {
Path pathInSource = getPathInSource(command.getPath());
Path newPathInSource = getPathInSource(command.getNewPath());
- getConnection().execute(this.getEnvironment(), new
ProjectedCopyNodeCommand(command, pathInSource, newPathInSource));
+ getConnection().execute(this.getExecutionContext(), new
ProjectedCopyNodeCommand(command, pathInSource, newPathInSource));
}
protected Path getPathInSource( Path pathInRepository ) {
Deleted:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/BasicFederatedNode.java
===================================================================
---
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/BasicFederatedNode.java 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/BasicFederatedNode.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -1,148 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.dna.connector.federation.merge;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.UUID;
-import net.jcip.annotations.ThreadSafe;
-import org.jboss.dna.spi.graph.Name;
-import org.jboss.dna.spi.graph.Property;
-
-/**
- * @author Randall Hauch
- */
-@ThreadSafe
-public class BasicFederatedNode implements FederatedNode {
-
- private final UUID uuid;
-
- // private Name name;
-
- /**
- * Create a new federated node instance.
- *
- * @param uuid the UUID; may not be null
- */
- public BasicFederatedNode( UUID uuid ) {
- assert uuid != null;
- this.uuid = uuid;
- }
-
- /**
- * {@inheritDoc}
- */
- public UUID getUuid() {
- return uuid;
- }
-
- /**
- * {@inheritDoc}
- */
- public Name getName() {
- return null;
- }
-
- /**
- * @param name Sets name to the specified value; may not be null
- */
- public void setName( Name name ) {
- assert name != null;
- // this.name = name;
- }
-
- /**
- * {@inheritDoc}
- */
- public Set<String> getContributingSources() {
- Set<String> names = new HashSet<String>();
- return names;
- }
-
- /**
- * {@inheritDoc}
- */
- public Iterator<Property> getProperties() {
- // Compute merged properties ...
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public Property getProperty( Name propertyName ) {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getPropertyCount() {
- return 0;
- }
-
- /**
- * {@inheritDoc}
- */
- public Iterator<Name> getPropertyNames() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public void removeAllProperties() {
- }
-
- /**
- * {@inheritDoc}
- */
- public void setAllProperties( Property... properties ) {
- }
-
- /**
- * {@inheritDoc}
- */
- public void setAllProperties( Iterable<Property> properties ) {
- }
-
- /**
- * {@inheritDoc}
- */
- public void setProperties( Property... properties ) {
- }
-
- /**
- * {@inheritDoc}
- */
- public void setProperties( Iterable<Property> properties ) {
- }
-
- /**
- * {@inheritDoc}
- */
- public Property setPropertyIfAbsent( Property property ) {
- return null;
- }
-
-}
Deleted:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/FederatedNode.java
===================================================================
---
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/FederatedNode.java 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/FederatedNode.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -1,140 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.dna.connector.federation.merge;
-
-import java.util.Iterator;
-import java.util.Set;
-import java.util.UUID;
-import net.jcip.annotations.ThreadSafe;
-import org.jboss.dna.spi.graph.Name;
-import org.jboss.dna.spi.graph.Property;
-
-/**
- * @author Randall Hauch
- */
-@ThreadSafe
-public interface FederatedNode {
- /**
- * Get the unique identifier for this federated node.
- *
- * @return the UUID; never null
- */
- UUID getUuid();
-
- /**
- * Get the name of this node.
- *
- * @return the node name; never null
- */
- Name getName();
-
- /**
- * Get the property with the given name.
- *
- * @param propertyName the property name
- * @return the property, or null if the property does not exist
- * @throws IllegalArgumentException if the name is null
- */
- Property getProperty( Name propertyName );
-
- /**
- * Get the number of properties on this node. This value is technically an estimate,
as it may not exactly match the number of
- * properties returned by {@link #getProperties()} or {@link #getPropertyNames()}.
- *
- * @return the approximate number of properties.
- */
- int getPropertyCount();
-
- /**
- * Get the properties. This method returns a consistent set of properties at the
moment this method is called, and is not
- * affected by additions or change to the properties. In other words, it is safe for
concurrent operations and is not a
- * fail-fast iterator.
- *
- * @return the properties on this node via an immutable iterator
- */
- Iterator<Property> getProperties();
-
- /**
- * Get the names of the properties for this node. This method returns a consistent
set of names at the moment this method is
- * called, and is not affected by additions or change to the properties. In other
words, it is safe for concurrent operations
- * and is not a fail-fast iterator.
- *
- * @return the property names via an immutable iterator
- */
- Iterator<Name> getPropertyNames();
-
- /**
- * Set the property if it is not already set.
- *
- * @param property the property
- * @return the existing property, or null if there was no property and the supplied
property was set
- * @throws IllegalArgumentException if the property is null
- */
- Property setPropertyIfAbsent( Property property );
-
- /**
- * Set the supplied properties. This method will overwrite any existing properties
with the new properties if they have the
- * same {@link Property#getName() property name}. This method ignores any null
property references, and does nothing if there
- * are no properties supplied.
- *
- * @param properties the properties that should be set
- */
- void setProperties( Property... properties );
-
- /**
- * Set the supplied properties. This method will overwrite any existing properties
with the new properties if they have the
- * same {@link Property#getName() property name}. This method ignores any null
property references, and does nothing if there
- * are no properties supplied.
- *
- * @param properties the properties that should be set
- */
- void setProperties( Iterable<Property> properties );
-
- /**
- * Replace all existing properties with the supplied properties. This method ignores
any null property references, and does
- * nothing if there are no properties supplied.
- *
- * @param properties the properties that should be set
- */
- void setAllProperties( Property... properties );
-
- /**
- * Replace all existing properties with the supplied properties. This method ignores
any null property references, and does
- * nothing if there are no properties supplied.
- *
- * @param properties the properties that should replace the existing properties
- */
- void setAllProperties( Iterable<Property> properties );
-
- /**
- * Remove all properties, except for the {@link #getName() name} and {@link
#getUuid() identifier}.
- */
- void removeAllProperties();
-
- /**
- * Get the sources that have contributed information to this node.
- *
- * @return the names of the sources that have contributed content to this node.
- */
- Set<String> getContributingSources();
-
-}
Added:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/FederatedNode.java
===================================================================
---
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/FederatedNode.java
(rev 0)
+++
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/FederatedNode.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -0,0 +1,145 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.connector.federation.merge;
+
+import java.util.UUID;
+import org.jboss.dna.spi.graph.Path;
+import org.jboss.dna.spi.graph.commands.CreateNodeCommand;
+import org.jboss.dna.spi.graph.commands.NodeConflictBehavior;
+import org.jboss.dna.spi.graph.commands.impl.BasicGetNodeCommand;
+
+/**
+ * An in-memory (and temporary) representation of a federated node and it's merged
properties and children.
+ *
+ * @author Randall Hauch
+ */
+public class FederatedNode extends BasicGetNodeCommand implements CreateNodeCommand {
+
+ private static final long serialVersionUID = 1L;
+
+ private final UUID uuid;
+ private MergePlan mergePlan;
+ private NodeConflictBehavior nodeConflictBehavior = NodeConflictBehavior.UPDATE;
+
+ /**
+ * Create a federated node given the path and UUID.
+ *
+ * @param path the path of the federated node; may not be null
+ * @param uuid the UUID of the federated node; may not be null
+ */
+ public FederatedNode( Path path,
+ UUID uuid ) {
+ super(path);
+ assert uuid != null;
+ this.uuid = uuid;
+ }
+
+ /**
+ * Get the UUID for this federated node.
+ *
+ * @return the UUID; never null
+ */
+ public UUID getUuid() {
+ return uuid;
+ }
+
+ /**
+ * Get the merge plan for this federated node
+ *
+ * @return the merge plan, or null if there is no merge plan
+ */
+ public MergePlan getMergePlan() {
+ return mergePlan;
+ }
+
+ /**
+ * Set the merge plan for this federated node
+ *
+ * @param mergePlan the new merge plan for this federated node; may be null
+ */
+ public void setMergePlan( MergePlan mergePlan ) {
+ this.mergePlan = mergePlan;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( CreateNodeCommand that ) {
+ if (this == that) return 0;
+ return this.getPath().compareTo(that.getPath());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return this.uuid.hashCode();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals( Object obj ) {
+ if (obj == this) return true;
+ if (obj instanceof FederatedNode) {
+ FederatedNode that = (FederatedNode)obj;
+ if (this.getPath().equals(that.getPath())) return true;
+ if (this.getUuid().equals(that.getUuid())) return true;
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return getPath().toString() + " (" + this.getUuid() + ")";
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.graph.commands.CreateNodeCommand#getConflictBehavior()
+ */
+ public NodeConflictBehavior getConflictBehavior() {
+ return this.nodeConflictBehavior;
+ }
+
+ /**
+ * @param nodeConflictBehavior Sets nodeConflictBehavior to the specified value.
+ */
+ public void setNodeConflictBehavior( NodeConflictBehavior nodeConflictBehavior ) {
+ this.nodeConflictBehavior = nodeConflictBehavior;
+ }
+
+}
Property changes on:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/FederatedNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/MergeStrategy.java
===================================================================
---
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/MergeStrategy.java
(rev 0)
+++
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/MergeStrategy.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.connector.federation.merge;
+
+import java.util.List;
+import org.jboss.dna.connector.federation.contribution.Contribution;
+import org.jboss.dna.spi.ExecutionContext;
+
+/**
+ * @author Randall Hauch
+ */
+public interface MergeStrategy {
+
+ /**
+ * Merge the contributions into a single
+ *
+ * @param federatedNode the federated node into which the contributions are to be
merged; never null
+ * @param contributions the contributions to the node; never null
+ * @param context the context in which this operation is to be performed; never null
+ */
+ public void merge( FederatedNode federatedNode,
+ List<Contribution> contributions,
+ ExecutionContext context );
+
+}
Property changes on:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/MergeStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/OneContributionMergeStrategy.java
===================================================================
---
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/OneContributionMergeStrategy.java
(rev 0)
+++
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/OneContributionMergeStrategy.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.connector.federation.merge;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import org.jboss.dna.connector.federation.contribution.Contribution;
+import org.jboss.dna.spi.ExecutionContext;
+import org.jboss.dna.spi.graph.Name;
+import org.jboss.dna.spi.graph.Property;
+import org.jboss.dna.spi.graph.Path.Segment;
+
+/**
+ * @author Randall Hauch
+ */
+public class OneContributionMergeStrategy implements MergeStrategy {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.connector.federation.merge.MergeStrategy#merge(org.jboss.dna.connector.federation.merge.FederatedNode,
+ * java.util.List, org.jboss.dna.spi.ExecutionContext)
+ */
+ public void merge( FederatedNode federatedNode,
+ List<Contribution> contributions,
+ ExecutionContext context ) {
+ assert federatedNode != null;
+ assert contributions != null;
+ assert contributions.size() == 1;
+ Contribution contribution = contributions.get(0);
+ // Copy the children ...
+ List<Segment> children = federatedNode.getChildren();
+ children.clear();
+ Iterator<Segment> childIterator = contribution.getChildren();
+ while (childIterator.hasNext()) {
+ Segment child = childIterator.next();
+ children.add(child);
+ }
+ // Copy the properties ...
+ Map<Name, Property> properties = federatedNode.getProperties();
+ properties.clear();
+ Iterator<Property> propertyIterator = contribution.getProperties();
+ while (propertyIterator.hasNext()) {
+ Property property = propertyIterator.next();
+ properties.put(property.getName(), property);
+ }
+ // Assign the merge plan ...
+ MergePlan mergePlan = MergePlan.create(contributions);
+ federatedNode.setMergePlan(mergePlan);
+ }
+
+}
Property changes on:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/OneContributionMergeStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/StandardMergeStrategy.java
===================================================================
---
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/StandardMergeStrategy.java
(rev 0)
+++
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/StandardMergeStrategy.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.connector.federation.merge;
+
+import java.util.List;
+import org.jboss.dna.connector.federation.contribution.Contribution;
+import org.jboss.dna.spi.ExecutionContext;
+
+/**
+ * @author Randall Hauch
+ */
+public class StandardMergeStrategy implements MergeStrategy {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.connector.federation.merge.MergeStrategy#merge(org.jboss.dna.connector.federation.merge.FederatedNode,
+ * java.util.List, org.jboss.dna.spi.ExecutionContext)
+ */
+ public void merge( FederatedNode federatedNode,
+ List<Contribution> contributions,
+ ExecutionContext context ) {
+ }
+}
Property changes on:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/merge/StandardMergeStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/connectors/dna-connector-inmemory/src/main/java/org/jboss/dna/connector/inmemory/InMemoryRepository.java
===================================================================
---
trunk/connectors/dna-connector-inmemory/src/main/java/org/jboss/dna/connector/inmemory/InMemoryRepository.java 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/connectors/dna-connector-inmemory/src/main/java/org/jboss/dna/connector/inmemory/InMemoryRepository.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -341,9 +341,9 @@
Path lowestExisting = getLowestExistingPath(parent);
throw new PathNotFoundException(path, lowestExisting,
InMemoryConnectorI18n.nodeDoesNotExist.text(parent));
}
- Node node = createNode(getEnvironment(), parentNode,
path.getLastSegment().getName());
+ Node node = createNode(getExecutionContext(), parentNode,
path.getLastSegment().getName());
// Now add the properties to the supplied node ...
- for (Property property : command.getProperties()) {
+ for (Property property : command.getPropertyIterator()) {
Name propName = property.getName();
if (property.size() == 0) {
node.getProperties().remove(propName);
@@ -378,7 +378,7 @@
public void execute( SetPropertiesCommand command ) {
Node node = getTargetNode(command);
// Now set (or remove) the properties to the supplied node ...
- for (Property property : command.getProperties()) {
+ for (Property property : command.getPropertyIterator()) {
Name propName = property.getName();
if (property.size() == 0) {
node.getProperties().remove(propName);
@@ -391,7 +391,7 @@
@Override
public void execute( DeleteBranchCommand command ) {
Node node = getTargetNode(command);
- removeNode(getEnvironment(), node);
+ removeNode(getExecutionContext(), node);
}
@Override
@@ -400,7 +400,7 @@
// Look up the new parent, which must exist ...
Path newPath = command.getNewPath();
Node newParent = getNode(newPath.getAncestor());
- copyNode(getEnvironment(), node, newParent, false);
+ copyNode(getExecutionContext(), node, newParent, false);
}
@Override
@@ -409,7 +409,7 @@
// Look up the new parent, which must exist ...
Path newPath = command.getNewPath();
Node newParent = getNode(newPath.getAncestor());
- copyNode(getEnvironment(), node, newParent, true);
+ copyNode(getExecutionContext(), node, newParent, true);
}
@Override
Modified:
trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java
===================================================================
---
trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -264,12 +264,12 @@
Node<Name, Object> parentNode = getNode(parent);
Node<Name, Object> node = parentNode.addChild(childFqn);
// Add the UUID property (if required), which may be overwritten by a
supplied property ...
- Name uuidPropertyName = getUuidProperty(getEnvironment());
+ Name uuidPropertyName = getUuidProperty(getExecutionContext());
if (uuidPropertyName != null) {
node.put(uuidPropertyName, generateUuid());
}
// Now add the properties to the supplied node ...
- for (Property property : command.getProperties()) {
+ for (Property property : command.getPropertyIterator()) {
if (property.size() == 0) continue;
Name propName = property.getName();
Object value = null;
@@ -309,7 +309,7 @@
public void execute( SetPropertiesCommand command ) {
Node<Name, Object> node = getNode(command.getPath());
// Now set (or remove) the properties to the supplied node ...
- for (Property property : command.getProperties()) {
+ for (Property property : command.getPropertyIterator()) {
Name propName = property.getName();
if (property.size() == 0) {
node.remove(propName);
@@ -353,7 +353,7 @@
public void execute( MoveBranchCommand command ) {
Node<Name, Object> node = getNode(command.getPath());
boolean recursive = true;
- Name uuidProperty = getUuidProperty(getEnvironment());
+ Name uuidProperty = getUuidProperty(getExecutionContext());
// Look up the new parent, which must exist ...
Path newPath = command.getNewPath();
Node<Name, Object> newParent = getNode(newPath.getAncestor());
@@ -389,7 +389,7 @@
}
protected Node<Name, Object> getNode( Path path ) {
- return JBossCacheConnection.this.getNode(getEnvironment(), path);
+ return JBossCacheConnection.this.getNode(getExecutionContext(), path);
}
}
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 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -206,13 +206,13 @@
// commands.
List<Projection> projections =
Collections.singletonList(configurationProjection);
CommandExecutor executor = null;
- if (configurationProjection.getRules().size() == 1) {
+ if (configurationProjection.getRules().size() == 0) {
+ // There is no projection for the configuration repository, so just use a
no-op executor
+ executor = new NoOpCommandExecutor(context, configurationSourceName);
+ } else if (configurationProjection.isSimple()) {
// There is just a single projection for the configuration repository, so
just use an executor that
// translates the paths using the projection
executor = new SingleProjectionCommandExecutor(context,
configurationSourceName, configurationProjection, sources);
- } else if (configurationProjection.getRules().size() == 0) {
- // There is no projection for the configuration repository, so just use a
no-op executor
- executor = new NoOpCommandExecutor(context, configurationSourceName);
} else {
// The configuration repository has more than one projection, so we need
to merge the results
executor = new FederatingCommandExecutor(context,
configurationSourceName, projections, sources);
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/Cacheable.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/Cacheable.java 2008-08-05 18:09:39
UTC (rev 378)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/Cacheable.java 2008-08-05 21:05:45
UTC (rev 379)
@@ -22,18 +22,21 @@
package org.jboss.dna.spi.cache;
import java.io.Serializable;
+import org.jboss.dna.spi.graph.DateTime;
/**
* Interface defining an object that can be cached according to a {@link CachePolicy}.
+ *
* @author Randall Hauch
*/
public interface Cacheable extends Serializable {
/**
* Get the time that this node data was originally loaded.
+ *
* @return the system time (in milliseconds) that the node data was loaded
*/
- long getTimeLoaded();
+ DateTime getTimeLoaded();
/**
* Get the caching policy to be used for this object.
@@ -41,12 +44,14 @@
* Note that the values of the policy are relative to the {@link #getTimeLoaded()
time the node was loaded}, so the same
* instance can be used for many nodes.
* </p>
+ *
* @return cachePolicy the caching policy, which may not be null
*/
public CachePolicy getCachePolicy();
/**
* Set the caching policy for this object.
+ *
* @param cachePolicy the caching policy to use for this object
* @throws IllegalArgumentException if the cachePolicy is null
*/
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/ActsOnProperties.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/ActsOnProperties.java 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/ActsOnProperties.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -38,6 +38,6 @@
*
* @return the properties
*/
- Iterable<Property> getProperties();
+ Iterable<Property> getPropertyIterator();
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/CreateNodeCommand.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/CreateNodeCommand.java 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/CreateNodeCommand.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -38,7 +38,7 @@
*
* @return the property iterator; never null, but possibly empty
*/
- Iterable<Property> getProperties();
+ Iterable<Property> getPropertyIterator();
/**
* Get the desired behavior when a node at the target {@link ActsOnPath#getPath()
path} already exists.
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/GetChildrenCommand.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/GetChildrenCommand.java 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/GetChildrenCommand.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -81,11 +81,27 @@
* replaced by those supplied to this method. Note that a {@link Path.Segment
segment} is not required in this case because
* there is only one child and (by definition) no index.
*
- * @param nameOfChild
+ * @param nameOfChild the name of the only child
*/
void setChild( Name nameOfChild );
/**
+ * Add the child to this node. This method does not affect existing children, so
callers of this method should not add a child
+ * with the same segment as an existing child (this is not checked by this method).
+ *
+ * @param nameOfChild the name of the child; should not be the same as an existing
child (not checked)
+ */
+ void addChild( Path.Segment nameOfChild );
+
+ /**
+ * Adds the children to this node. This method does not affect existing children, so
callers of this method should not add
+ * children with the same segment as existing children (this is not checked by this
method).
+ *
+ * @param namesOfChildren the names of the new children; these should not be the same
as any other children
+ */
+ void addChildren( Path.Segment... namesOfChildren );
+
+ /**
* Set that this node has no children. Any existing child references already set on
this command will be removed.
*/
void setNoChildren();
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/executor/AbstractCommandExecutor.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/executor/AbstractCommandExecutor.java 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/executor/AbstractCommandExecutor.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -81,7 +81,7 @@
*
* @return the execution context; never null
*/
- public ExecutionContext getEnvironment() {
+ public ExecutionContext getExecutionContext() {
return context;
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicCreateNodeCommand.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicCreateNodeCommand.java 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicCreateNodeCommand.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -69,7 +69,7 @@
/**
* {@inheritDoc}
*/
- public Iterable<Property> getProperties() {
+ public Iterable<Property> getPropertyIterator() {
return properties;
}
@@ -80,6 +80,18 @@
return this.conflictBehavior;
}
+ public void setProperty( Property property ) {
+ if (!properties.isEmpty()) {
+ for (Property existing : this.properties) {
+ if (existing.getName().equals(property.getName())) {
+ this.properties.remove(existing);
+ break;
+ }
+ }
+ }
+ this.properties.add(property);
+ }
+
/**
* {@inheritDoc}
*/
@@ -121,7 +133,7 @@
sb.append(" at ");
sb.append(this.getPath());
boolean firstProperty = true;
- for (Property property : this.getProperties()) {
+ for (Property property : this.getPropertyIterator()) {
if (property.isEmpty()) continue;
if (firstProperty) {
sb.append(" { ");
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetChildrenCommand.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetChildrenCommand.java 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetChildrenCommand.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -27,6 +27,7 @@
import net.jcip.annotations.NotThreadSafe;
import org.jboss.dna.common.util.StringUtil;
import org.jboss.dna.spi.cache.CachePolicy;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Path.Segment;
@@ -44,7 +45,7 @@
private List<Segment> children;
private final Path path;
private CachePolicy cachePolicy;
- private long timeLoaded;
+ private DateTime timeLoaded;
/**
* @param path the path to the node; may not be null
@@ -91,6 +92,26 @@
}
/**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.spi.graph.commands.GetChildrenCommand#addChild(org.jboss.dna.spi.graph.Path.Segment)
+ */
+ public void addChild( Segment nameOfChild ) {
+ if (nameOfChild != null) this.children.add(nameOfChild);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.spi.graph.commands.GetChildrenCommand#addChildren(org.jboss.dna.spi.graph.Path.Segment[])
+ */
+ public void addChildren( Segment... namesOfChildren ) {
+ for (Segment nameOfChild : namesOfChildren) {
+ if (nameOfChild != null) this.children.add(nameOfChild);
+ }
+ }
+
+ /**
* @return children
*/
public List<Segment> getChildren() {
@@ -114,14 +135,14 @@
/**
* {@inheritDoc}
*/
- public long getTimeLoaded() {
+ public DateTime getTimeLoaded() {
return timeLoaded;
}
/**
* @param timeLoaded Sets timeLoaded to the specified value.
*/
- public void setTimeLoaded( long timeLoaded ) {
+ public void setTimeLoaded( DateTime timeLoaded ) {
this.timeLoaded = timeLoaded;
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetNodeCommand.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetNodeCommand.java 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetNodeCommand.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -80,7 +80,8 @@
} else {
children = new ArrayList<Segment>();
while (namesOfChildren.hasNext()) {
- children.add(namesOfChildren.next());
+ Segment childSegment = namesOfChildren.next();
+ if (childSegment != null) children.add(childSegment);
}
}
}
@@ -94,7 +95,7 @@
} else {
children = new ArrayList<Segment>();
for (Segment childSegment : namesOfChildren) {
- children.add(childSegment);
+ if (childSegment != null) children.add(childSegment);
}
}
}
@@ -108,14 +109,34 @@
} else {
children = new ArrayList<Segment>();
for (Segment childSegment : namesOfChildren) {
- children.add(childSegment);
+ if (childSegment != null) children.add(childSegment);
}
}
}
/**
* {@inheritDoc}
+ *
+ * @see
org.jboss.dna.spi.graph.commands.GetChildrenCommand#addChild(org.jboss.dna.spi.graph.Path.Segment)
*/
+ public void addChild( Segment nameOfChild ) {
+ if (nameOfChild != null) this.children.add(nameOfChild);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.spi.graph.commands.GetChildrenCommand#addChildren(org.jboss.dna.spi.graph.Path.Segment[])
+ */
+ public void addChildren( Segment... namesOfChildren ) {
+ for (Segment nameOfChild : namesOfChildren) {
+ if (nameOfChild != null) this.children.add(nameOfChild);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public void setNoChildren() {
children = Collections.emptyList();
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetPropertiesCommand.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetPropertiesCommand.java 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetPropertiesCommand.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -26,6 +26,7 @@
import net.jcip.annotations.NotThreadSafe;
import org.jboss.dna.common.util.StringUtil;
import org.jboss.dna.spi.cache.CachePolicy;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Property;
@@ -43,7 +44,7 @@
private final Map<Name, Property> properties = new HashMap<Name,
Property>();
private final Path path;
private CachePolicy cachePolicy;
- private long timeLoaded;
+ private DateTime timeLoaded;
/**
* @param path the path to the node; may not be null
@@ -63,6 +64,11 @@
}
}
+ public void setProperties( Map<Name, Property> properties ) {
+ this.properties.clear();
+ if (properties != null) this.properties.putAll(properties);
+ }
+
/**
* Get the property values that were added to the command
*
@@ -93,14 +99,14 @@
/**
* {@inheritDoc}
*/
- public long getTimeLoaded() {
+ public DateTime getTimeLoaded() {
return timeLoaded;
}
/**
* @param timeLoaded Sets timeLoaded to the specified value.
*/
- public void setTimeLoaded( long timeLoaded ) {
+ public void setTimeLoaded( DateTime timeLoaded ) {
this.timeLoaded = timeLoaded;
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicSetPropertiesCommand.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicSetPropertiesCommand.java 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicSetPropertiesCommand.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -63,7 +63,7 @@
/**
* {@inheritDoc}
*/
- public Iterable<Property> getProperties() {
+ public Iterable<Property> getPropertyIterator() {
return properties;
}
@@ -79,7 +79,7 @@
sb.append(" at ");
sb.append(this.getPath());
boolean firstProperty = true;
- for (Property property : this.getProperties()) {
+ for (Property property : this.getPropertyIterator()) {
if (property.isEmpty()) continue;
if (firstProperty) {
sb.append(" { ");
Modified:
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/commands/executor/AbstractCommandExecutorTest.java
===================================================================
---
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/commands/executor/AbstractCommandExecutorTest.java 2008-08-05
18:09:39 UTC (rev 378)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/commands/executor/AbstractCommandExecutorTest.java 2008-08-05
21:05:45 UTC (rev 379)
@@ -75,7 +75,7 @@
@Test
public void shouldHaveEnvironment() {
- assertThat(executor.getEnvironment(), is(sameInstance(context)));
+ assertThat(executor.getExecutionContext(), is(sameInstance(context)));
}
@Test