Author: rhauch
Date: 2008-07-25 16:39:42 -0400 (Fri, 25 Jul 2008)
New Revision: 371
Added:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/BasicJcrExecutionContext.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/JcrExecutionContext.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/util/MockJcrExecutionContext.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/ExecutionContext.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/ExecutionContexts.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/BasicExecutionContext.java
Removed:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/ExecutionContext.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/SimpleExecutionContext.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/util/MockExecutionContext.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/BasicExecutionEnvironment.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/ExecutionEnvironment.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/ExecutionEnvironments.java
Modified:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepository.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepositoryConnection.java
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/ProjectionParser.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/SingleProjectionCommandExecutor.java
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatedRepositoryConnectionTest.java
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatedRepositorySourceTest.java
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatedRepositoryTest.java
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/ProjectionPathRuleTest.java
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/ProjectionTest.java
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/InMemoryRepositoryConnection.java
trunk/connectors/dna-connector-inmemory/src/main/java/org/jboss/dna/connector/inmemory/Node.java
trunk/connectors/dna-connector-inmemory/src/test/java/org/jboss/dna/connector/inmemory/InMemoryRepositoryTest.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-repository/src/main/java/org/jboss/dna/repository/rules/RuleSetRepositoryMonitor.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/Sequencer.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerNodeContext.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencingService.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapter.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryServiceTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/MockSequencerA.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/MockSequencerB.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencerNodeContextTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencingServiceTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/ExecutionContextFactory.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/executor/NoOpCommandExecutor.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryConnection.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryConnectionPool.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryOperation.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryOperations.java
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/connection/RepositoryConnectionPoolTest.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositorySourceLoadHarness.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/SimpleRepository.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/SimpleRepositorySource.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java
Log:
DNA-182 - Rename ExecutionEnvironment to ExecutionContext
http://jira.jboss.com/jira/browse/DNA-182
DNA-183 - Add "getSubject()" method to org.jboss.dna.spi.ExecutionContext
http://jira.jboss.com/jira/browse/DNA-183
Renamed the org.jboss.dna.repository.util.ExecutionContext to JcrExecutionContext. This
extended org.jboss.dna.spi.graph.connection.ExecutionEnvironment, which was renamed and
moved to org.jboss.dna.spi.ExecutionContext. All of the changes involved changing the
parameter names, variable names, and JavaDocs.
Also added Subject to ExecutionContext interface and the appropriate implementations.
Modified:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepository.java
===================================================================
---
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepository.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepository.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -30,8 +30,8 @@
import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.common.util.ArgCheck;
import org.jboss.dna.connector.federation.executor.FederatingCommandExecutor;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.graph.commands.executor.CommandExecutor;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
import org.jboss.dna.spi.graph.connection.RepositoryConnection;
import org.jboss.dna.spi.graph.connection.RepositoryConnectionFactories;
import org.jboss.dna.spi.graph.connection.RepositorySource;
@@ -47,7 +47,7 @@
@ThreadSafe
public class FederatedRepository {
- private final ExecutionEnvironment env;
+ private final ExecutionContext context;
private final RepositoryConnectionFactories connectionFactories;
private FederatedRepositoryConfig config;
private final AtomicInteger openExecutors = new AtomicInteger(0);
@@ -58,18 +58,18 @@
/**
* Create a federated repository instance.
*
- * @param env the execution environment
+ * @param context the execution context
* @param connectionFactories the set of connection factories that should be used
* @param config the configuration for this repository
* @throws IllegalArgumentException if any of the parameters are null, or if the name
is blank
*/
- public FederatedRepository( ExecutionEnvironment env,
+ public FederatedRepository( ExecutionContext context,
RepositoryConnectionFactories connectionFactories,
FederatedRepositoryConfig config ) {
ArgCheck.isNotNull(connectionFactories, "connectionFactories");
- ArgCheck.isNotNull(env, "env");
+ ArgCheck.isNotNull(context, "context");
ArgCheck.isNotNull(config, "config");
- this.env = env;
+ this.context = context;
this.connectionFactories = connectionFactories;
this.config = config;
}
@@ -84,10 +84,10 @@
}
/**
- * @return the execution environment
+ * @return the execution context
*/
- public ExecutionEnvironment getExecutionEnvironment() {
- return env;
+ public ExecutionContext getExecutionContext() {
+ return context;
}
/**
@@ -221,17 +221,17 @@
}
/**
- * Called by
- * {@link FederatedRepositoryConnection#execute(ExecutionEnvironment,
org.jboss.dna.spi.graph.commands.GraphCommand...)}.
+ * Called by {@link FederatedRepositoryConnection#execute(ExecutionContext,
org.jboss.dna.spi.graph.commands.GraphCommand...)}
+ * .
*
- * @param env the execution environment in which the executor will be run; may not be
null
+ * @param context the execution context in which the executor will be run; may not be
null
* @param sourceName the name of the {@link RepositorySource} that is making use of
this executor; may not be null or empty
* @return the executor
*/
- protected CommandExecutor getExecutor( ExecutionEnvironment env,
+ protected CommandExecutor getExecutor( ExecutionContext context,
String sourceName ) {
FederatedRepositoryConfig config = this.getConfiguration();
- return new FederatingCommandExecutor(env, sourceName,
config.getCacheProjection(), config.getSourceProjections(),
+ return new FederatingCommandExecutor(context, sourceName,
config.getCacheProjection(), config.getSourceProjections(),
getConnectionFactories());
}
Modified:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepositoryConnection.java
===================================================================
---
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepositoryConnection.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepositoryConnection.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -25,10 +25,10 @@
import java.util.concurrent.atomic.AtomicReference;
import javax.transaction.xa.XAResource;
import net.jcip.annotations.ThreadSafe;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.cache.CachePolicy;
import org.jboss.dna.spi.graph.commands.GraphCommand;
import org.jboss.dna.spi.graph.commands.executor.CommandExecutor;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
import org.jboss.dna.spi.graph.connection.RepositoryConnection;
import org.jboss.dna.spi.graph.connection.RepositorySourceException;
import org.jboss.dna.spi.graph.connection.RepositorySourceListener;
@@ -111,14 +111,14 @@
/**
* {@inheritDoc}
*/
- public void execute( ExecutionEnvironment env,
+ public void execute( ExecutionContext context,
GraphCommand... commands ) throws RepositorySourceException,
InterruptedException {
if (!this.repository.isRunning()) {
throw new
RepositorySourceException(FederationI18n.repositoryHasBeenShutDown.text(this.repository.getName()));
}
if (commands == null || commands.length == 0) return;
- CommandExecutor executor = this.repository.getExecutor(env, sourceName);
+ CommandExecutor executor = this.repository.getExecutor(context, sourceName);
assert executor != null;
for (GraphCommand command : commands) {
executor.execute(command);
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-07-25
19:37:40 UTC (rev 370)
+++
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepositorySource.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -48,6 +48,7 @@
import org.jboss.dna.common.util.StringUtil;
import org.jboss.dna.connector.federation.executor.FederatingCommandExecutor;
import org.jboss.dna.connector.federation.executor.SingleProjectionCommandExecutor;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.ExecutionContextFactory;
import org.jboss.dna.spi.cache.BasicCachePolicy;
import org.jboss.dna.spi.cache.CachePolicy;
@@ -67,7 +68,6 @@
import org.jboss.dna.spi.graph.commands.impl.BasicGetChildrenCommand;
import org.jboss.dna.spi.graph.commands.impl.BasicGetNodeCommand;
import org.jboss.dna.spi.graph.connection.AbstractRepositorySource;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
import org.jboss.dna.spi.graph.connection.RepositoryConnection;
import org.jboss.dna.spi.graph.connection.RepositoryConnectionFactories;
import org.jboss.dna.spi.graph.connection.RepositorySource;
@@ -291,7 +291,7 @@
/**
* Get the name in JNDI of a {@link ExecutionContextFactory} instance that should be
used to obtain the
- * {@link ExecutionEnvironment execution context} used by the {@link
FederatedRepository federated repository}.
+ * {@link ExecutionContext execution context} used by the {@link FederatedRepository
federated repository}.
* <p>
* This is a required property (unless the {@link #getRepositoryJndiName() federated
repository is to be found in JDNI}).
* </p>
@@ -306,7 +306,7 @@
/**
* Set the name in JNDI of a {@link ExecutionContextFactory} instance that should be
used to obtain the
- * {@link ExecutionEnvironment execution context} used by the {@link
FederatedRepository federated repository}.
+ * {@link ExecutionContext execution context} used by the {@link FederatedRepository
federated repository}.
* <p>
* This is a required property (unless the {@link #getRepositoryJndiName() federated
repository is to be found in JDNI}).
* </p>
@@ -503,16 +503,16 @@
/**
* This method is called to signal that some aspect of the configuration has changed.
If a {@link #getRepository() repository}
* instance has been created, it's configuration is
- * {@link #getRepositoryConfiguration(ExecutionEnvironment,
RepositoryConnectionFactories) rebuilt} and updated. Nothing is
- * done, however, if there is currently no {@link #getRepository() repository}.
+ * {@link #getRepositoryConfiguration(ExecutionContext,
RepositoryConnectionFactories) rebuilt} and updated. Nothing is done,
+ * however, if there is currently no {@link #getRepository() repository}.
*/
protected synchronized void changeRepositoryConfig() {
if (this.repository != null) {
// Find in JNDI the repository connection factories and the environment ...
- ExecutionEnvironment env = getExecutionEnvironment();
+ ExecutionContext context = getExecutionContext();
RepositoryConnectionFactories factories =
getRepositoryConnectionFactories();
// Compute a new repository config and set it on the repository ...
- FederatedRepositoryConfig newConfig = getRepositoryConfiguration(env,
factories);
+ FederatedRepositoryConfig newConfig = getRepositoryConfiguration(context,
factories);
this.repository.setConfiguration(newConfig);
}
}
@@ -555,7 +555,7 @@
* <ol>
* <li>If a {@link FederatedRepository} already was obtained from a prior call,
the same instance is returned.</li>
* <li>A {@link FederatedRepository} is created using a {@link
FederatedRepositoryConfig} is created from this instance's
- * properties and {@link ExecutionEnvironment} and {@link
RepositoryConnectionFactories} instances obtained from JNDI.</li>
+ * properties and {@link ExecutionContext} and {@link RepositoryConnectionFactories}
instances obtained from JNDI.</li>
* <li></li>
* <li></li>
* </ol>
@@ -566,12 +566,12 @@
protected synchronized FederatedRepository getRepository() throws
RepositorySourceException {
if (repository == null) {
String jndiName = this.getRepositoryJndiName();
- Context context = getContext();
+ Context jndiContext = getContext();
if (jndiName != null && jndiName.trim().length() != 0) {
// Look for an existing repository in JNDI ...
try {
- if (context == null) context = new InitialContext();
- repository = (FederatedRepository)context.lookup(jndiName);
+ if (jndiContext == null) jndiContext = new InitialContext();
+ repository = (FederatedRepository)jndiContext.lookup(jndiName);
} catch (Throwable err) {
I18n msg = FederationI18n.unableToFindFederatedRepositoryInJndi;
throw new RepositorySourceException(msg.text(this.sourceName,
jndiName), err);
@@ -580,17 +580,17 @@
if (repository == null) {
// Find in JNDI the repository connection factories and the environment
...
- ExecutionEnvironment env = getExecutionEnvironment();
+ ExecutionContext context = getExecutionContext();
RepositoryConnectionFactories factories =
getRepositoryConnectionFactories();
// And create the configuration and the repository ...
- FederatedRepositoryConfig config = getRepositoryConfiguration(env,
factories);
- repository = new FederatedRepository(env, factories, config);
+ FederatedRepositoryConfig config = getRepositoryConfiguration(context,
factories);
+ repository = new FederatedRepository(context, factories, config);
}
}
return repository;
}
- protected ExecutionEnvironment getExecutionEnvironment() {
+ protected ExecutionContext getExecutionContext() {
ExecutionContextFactory factory = null;
Context context = getContext();
String jndiName = getExecutionContextFactoryJndiName();
@@ -666,22 +666,22 @@
* Create a {@link FederatedRepositoryConfig} instance from the current properties of
this instance. This method does
* <i>not</i> modify the state of this instance.
*
- * @param env the execution environment that should be used to read the
configuration; may not be null
+ * @param context the execution context that should be used to read the
configuration; may not be null
* @param factories the factories from which can be obtained the
RepositoryConnectionFactory instances for each name source;
* may not be null
* @return a configuration reflecting the current state of this instance
*/
- protected synchronized FederatedRepositoryConfig getRepositoryConfiguration(
ExecutionEnvironment env,
+ protected synchronized FederatedRepositoryConfig getRepositoryConfiguration(
ExecutionContext context,
RepositoryConnectionFactories factories ) {
Problems problems = new SimpleProblems();
- ValueFactories valueFactories = env.getValueFactories();
+ ValueFactories valueFactories = context.getValueFactories();
PathFactory pathFactory = valueFactories.getPathFactory();
NameFactory nameFactory = valueFactories.getNameFactory();
ValueFactory<Long> longFactory = valueFactories.getLongFactory();
// Create the configuration projection ...
ProjectionParser projectionParser = ProjectionParser.getInstance();
- Projection.Rule[] rules = projectionParser.rulesFromStrings(env,
this.getConfigurationSourceProjectionRules());
+ Projection.Rule[] rules = projectionParser.rulesFromStrings(context,
this.getConfigurationSourceProjectionRules());
Projection configurationProjection = new
Projection(this.getConfigurationSourceName(), rules);
// Create a federating command executor to execute the commands and merge the
results into a single set of
@@ -692,13 +692,13 @@
if (configurationProjection.getRules().size() == 1) {
// 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(env, configurationSourceName,
configurationProjection, factories);
+ 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(env, configurationSourceName);
+ executor = new NoOpCommandExecutor(context, configurationSourceName);
} else {
// The configuration repository has more than one projection, so we need to
merge the results
- executor = new FederatingCommandExecutor(env, configurationSourceName, null,
projections, factories);
+ executor = new FederatingCommandExecutor(context, configurationSourceName,
null, projections, factories);
}
// Wrap the executor with a logging executor ...
executor = new LoggingCommandExecutor(executor, Logger.getLogger(getClass()),
Logger.Level.INFO);
@@ -719,7 +719,7 @@
Path pathToCacheRegion = pathFactory.create(configNode,
nameFactory.create("dna:cache"));
BasicGetNodeCommand getCacheRegion = new
BasicGetNodeCommand(pathToCacheRegion);
executor.execute(getCacheRegion);
- Projection cacheProjection = createProjection(env,
+ Projection cacheProjection = createProjection(context,
projectionParser,
getCacheRegion.getPath(),
getCacheRegion.getProperties(),
@@ -755,7 +755,7 @@
for (GraphCommand command : commands) {
BasicGetNodeCommand getProjectionCommand =
(BasicGetNodeCommand)command;
if (getProjectionCommand.hasNoError()) {
- Projection projection = createProjection(env,
+ Projection projection = createProjection(context,
projectionParser,
getProjectionCommand.getPath(),
getProjectionCommand.getProperties(),
@@ -790,19 +790,19 @@
/**
* Instantiate the {@link Projection} described by the supplied properties.
*
- * @param env the execution environment that should be used to read the
configuration; may not be null
+ * @param context the execution context that should be used to read the
configuration; may not be null
* @param projectionParser the projection rule parser that should be used; may not be
null
* @param path the path to the node where these properties were found; never null
* @param properties the properties; never null
* @param problems the problems container in which any problems should be reported;
never null
* @return the region instance, or null if it could not be created
*/
- protected Projection createProjection( ExecutionEnvironment env,
+ protected Projection createProjection( ExecutionContext context,
ProjectionParser projectionParser,
Path path,
Map<Name, Property> properties,
Problems problems ) {
- ValueFactories valueFactories = env.getValueFactories();
+ ValueFactories valueFactories = context.getValueFactories();
NameFactory nameFactory = valueFactories.getNameFactory();
ValueFactory<String> stringFactory = valueFactories.getStringFactory();
@@ -814,7 +814,7 @@
if (projectionRulesProperty != null &&
!projectionRulesProperty.isEmpty()) {
String[] projectionRuleStrs =
stringFactory.create(projectionRulesProperty.getValuesAsArray());
if (projectionRuleStrs != null && projectionRuleStrs.length != 0) {
- projectionRules = projectionParser.rulesFromStrings(env,
projectionRuleStrs);
+ projectionRules = projectionParser.rulesFromStrings(context,
projectionRuleStrs);
}
}
if (problems.hasErrors()) return null;
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-07-25
19:37:40 UTC (rev 370)
+++
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/Projection.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -38,10 +38,10 @@
import org.jboss.dna.common.util.ArgCheck;
import org.jboss.dna.common.util.HashCode;
import org.jboss.dna.common.util.Logger;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.graph.NamespaceRegistry;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PathFactory;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
import org.jboss.dna.spi.graph.connection.RepositorySource;
/**
@@ -64,7 +64,7 @@
static {
parserMethods = new CopyOnWriteArrayList<Method>();
try {
-
parserMethods.add(Projection.class.getDeclaredMethod("parsePathRule",
String.class, ExecutionEnvironment.class));
+
parserMethods.add(Projection.class.getDeclaredMethod("parsePathRule",
String.class, ExecutionContext.class));
} catch (Throwable err) {
Logger.getLogger(Projection.class).error(err,
FederationI18n.errorAddingProjectionRuleParseMethod);
}
@@ -73,8 +73,8 @@
/**
* Add a static method that can be used to parse {@link
Rule#getString(NamespaceRegistry, TextEncoder) rule definition
* strings}. These methods must be static, must accept a {@link String} definition as
the first parameter and an
- * {@link ExecutionEnvironment} environment reference as the second parameter, and
should return the resulting {@link Rule}
- * (or null if the definition format could not be understood by the method. Any
exceptions during
+ * {@link ExecutionContext} environment reference as the second parameter, and should
return the resulting {@link Rule} (or
+ * null if the definition format could not be understood by the method. Any
exceptions during
* {@link Method#invoke(Object, Object...) invocation} will be logged at the
* {@link Logger#trace(Throwable, String, Object...) trace} level.
*
@@ -88,8 +88,8 @@
/**
* Add a static method that can be used to parse {@link
Rule#getString(NamespaceRegistry, TextEncoder) rule definition
* strings}. These methods must be static, must accept a {@link String} definition as
the first parameter and an
- * {@link ExecutionEnvironment} environment reference as the second parameter, and
should return the resulting {@link Rule}
- * (or null if the definition format could not be understood by the method. Any
exceptions during
+ * {@link ExecutionContext} environment reference as the second parameter, and should
return the resulting {@link Rule} (or
+ * null if the definition format could not be understood by the method. Any
exceptions during
* {@link Method#invoke(Object, Object...) invocation} will be logged at the
* {@link Logger#trace(Throwable, String, Object...) trace} level.
*
@@ -110,7 +110,7 @@
ArgCheck.isNotEmpty(className, "className");
ArgCheck.isNotEmpty(methodName, "methodName");
Class<?> clazz = Class.forName(className, true, classLoader);
- parserMethods.add(clazz.getMethod(className, String.class,
ExecutionEnvironment.class));
+ parserMethods.add(clazz.getMethod(className, String.class,
ExecutionContext.class));
}
/**
@@ -148,17 +148,17 @@
* Parse the string form of a rule definition and return the rule
*
* @param definition the definition of the rule that is to be parsed
- * @param env the environment in which this method is being executed; may not be
null
+ * @param context the environment in which this method is being executed; may not be
null
* @return the rule, or null if the definition could not be parsed
*/
public static Rule fromString( String definition,
- ExecutionEnvironment env ) {
- ArgCheck.isNotNull(env, "env");
+ ExecutionContext context ) {
+ ArgCheck.isNotNull(context, "env");
definition = definition != null ? definition.trim() : "";
if (definition.length() == 0) return null;
for (Method method : parserMethods) {
try {
- Rule rule = (Rule)method.invoke(null, definition, env);
+ Rule rule = (Rule)method.invoke(null, definition, context);
if (rule != null) return rule;
} catch (Throwable err) {
String msg = "Error while parsing project rule definition
\"{0}\" using {1}";
@@ -201,18 +201,18 @@
* parser methods} by the static initializer of {@link Projection}.
*
* @param definition the definition
- * @param env the environment
+ * @param context the environment
* @return the path rule, or null if the definition is not in the right form
*/
public static PathRule parsePathRule( String definition,
- ExecutionEnvironment env ) {
+ ExecutionContext context ) {
definition = definition != null ? definition.trim() : "";
if (definition.length() == 0) return null;
Matcher matcher = PATH_RULE_PATTERN.matcher(definition);
if (!matcher.find()) return null;
String reposPathStr = matcher.group(1);
String sourcePathStr = matcher.group(2);
- PathFactory pathFactory = env.getValueFactories().getPathFactory();
+ PathFactory pathFactory = context.getValueFactories().getPathFactory();
Path repositoryPath = pathFactory.create(reposPathStr);
Path sourcePath = pathFactory.create(sourcePathStr);
Modified:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/ProjectionParser.java
===================================================================
---
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/ProjectionParser.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/ProjectionParser.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -31,8 +31,8 @@
import org.jboss.dna.common.util.Logger;
import org.jboss.dna.common.util.StringUtil;
import org.jboss.dna.connector.federation.Projection.Rule;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.graph.NamespaceRegistry;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
/**
* A parser library for {@link Projection projections} and {@link Projection.Rule
projection rules}.
@@ -71,8 +71,8 @@
/**
* Add a static method that can be used to parse {@link
Rule#getString(NamespaceRegistry, TextEncoder) rule definition
* strings}. These methods must be static, must accept a {@link String} definition as
the first parameter and an
- * {@link ExecutionEnvironment} environment reference as the second parameter, and
should return the resulting {@link Rule}
- * (or null if the definition format could not be understood by the method. Any
exceptions during
+ * {@link ExecutionContext} environment reference as the second parameter, and should
return the resulting {@link Rule} (or
+ * null if the definition format could not be understood by the method. Any
exceptions during
* {@link Method#invoke(Object, Object...) invocation} will be logged at the
* {@link Logger#trace(Throwable, String, Object...) trace} level.
*
@@ -86,8 +86,8 @@
/**
* Add a static method that can be used to parse {@link
Rule#getString(NamespaceRegistry, TextEncoder) rule definition
* strings}. These methods must be static, must accept a {@link String} definition as
the first parameter and an
- * {@link ExecutionEnvironment} environment reference as the second parameter, and
should return the resulting {@link Rule}
- * (or null if the definition format could not be understood by the method. Any
exceptions during
+ * {@link ExecutionContext} environment reference as the second parameter, and should
return the resulting {@link Rule} (or
+ * null if the definition format could not be understood by the method. Any
exceptions during
* {@link Method#invoke(Object, Object...) invocation} will be logged at the
* {@link Logger#trace(Throwable, String, Object...) trace} level.
*
@@ -103,14 +103,14 @@
String methodName ) throws SecurityException,
NoSuchMethodException {
ArgCheck.isNotNull(clazz, "clazz");
ArgCheck.isNotEmpty(methodName, "methodName");
- parserMethods.add(clazz.getMethod(methodName, String.class,
ExecutionEnvironment.class));
+ parserMethods.add(clazz.getMethod(methodName, String.class,
ExecutionContext.class));
}
/**
* Add a static method that can be used to parse {@link
Rule#getString(NamespaceRegistry, TextEncoder) rule definition
* strings}. These methods must be static, must accept a {@link String} definition as
the first parameter and an
- * {@link ExecutionEnvironment} environment reference as the second parameter, and
should return the resulting {@link Rule}
- * (or null if the definition format could not be understood by the method. Any
exceptions during
+ * {@link ExecutionContext} environment reference as the second parameter, and should
return the resulting {@link Rule} (or
+ * null if the definition format could not be understood by the method. Any
exceptions during
* {@link Method#invoke(Object, Object...) invocation} will be logged at the
* {@link Logger#trace(Throwable, String, Object...) trace} level.
*
@@ -131,7 +131,7 @@
ArgCheck.isNotEmpty(className, "className");
ArgCheck.isNotEmpty(methodName, "methodName");
Class<?> clazz = Class.forName(className, true, classLoader);
- parserMethods.add(clazz.getMethod(methodName, String.class,
ExecutionEnvironment.class));
+ parserMethods.add(clazz.getMethod(methodName, String.class,
ExecutionContext.class));
}
/**
@@ -176,17 +176,17 @@
* Parse the string form of a rule definition and return the rule
*
* @param definition the definition of the rule that is to be parsed
- * @param env the environment in which this method is being executed; may not be
null
+ * @param context the environment in which this method is being executed; may not be
null
* @return the rule, or null if the definition could not be parsed
*/
public Rule ruleFromString( String definition,
- ExecutionEnvironment env ) {
- ArgCheck.isNotNull(env, "env");
+ ExecutionContext context ) {
+ ArgCheck.isNotNull(context, "env");
definition = definition != null ? definition.trim() : "";
if (definition.length() == 0) return null;
for (Method method : parserMethods) {
try {
- Rule rule = (Rule)method.invoke(null, definition, env);
+ Rule rule = (Rule)method.invoke(null, definition, context);
if (rule != null) {
if (logger.isTraceEnabled()) {
String msg = "Success parsing project rule definition
\"{0}\" using {1}";
@@ -208,15 +208,15 @@
/**
* Parse string forms of an arry of rule definitions and return the rules
*
- * @param env the environment in which this method is being executed; may not be
null
+ * @param context the environment in which this method is being executed; may not be
null
* @param definitions the definition of the rules that are to be parsed
* @return the rule, or null if the definition could not be parsed
*/
- public Rule[] rulesFromStrings( ExecutionEnvironment env,
+ public Rule[] rulesFromStrings( ExecutionContext context,
String... definitions ) {
List<Rule> rules = new LinkedList<Rule>();
for (String definition : definitions) {
- Rule rule = ruleFromString(definition, env);
+ Rule rule = ruleFromString(definition, context);
if (rule != null) rules.add(rule);
}
return rules.toArray(new Rule[rules.size()]);
@@ -226,16 +226,16 @@
* Parse a single string containing one or more string forms of rule definitions, and
return the rules. The string contains
* each rule on a separate line.
*
- * @param env the environment in which this method is being executed; may not be
null
+ * @param context the environment in which this method is being executed; may not be
null
* @param definitions the definitions of the rules that are to be parsed, each
definition separated by a newline character.
* @return the rule, or null if the definition could not be parsed
*/
- public Rule[] rulesFromString( ExecutionEnvironment env,
+ public Rule[] rulesFromString( ExecutionContext context,
String definitions ) {
List<String> lines = StringUtil.splitLines(definitions);
List<Rule> rules = new LinkedList<Rule>();
for (String definition : lines) {
- Rule rule = ruleFromString(definition, env);
+ Rule rule = ruleFromString(definition, context);
if (rule != null) rules.add(rule);
}
return rules.toArray(new Rule[rules.size()]);
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-07-25
19:37:40 UTC (rev 370)
+++
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/FederatingCommandExecutor.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -34,6 +34,7 @@
import org.jboss.dna.connector.federation.Projection;
import org.jboss.dna.connector.federation.contribution.Contribution;
import org.jboss.dna.connector.federation.merge.BasicMergePlan;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.graph.Binary;
import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.Name;
@@ -46,7 +47,6 @@
import org.jboss.dna.spi.graph.commands.executor.AbstractCommandExecutor;
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.ExecutionEnvironment;
import org.jboss.dna.spi.graph.connection.RepositoryConnection;
import org.jboss.dna.spi.graph.connection.RepositoryConnectionFactories;
import org.jboss.dna.spi.graph.connection.RepositoryConnectionFactory;
@@ -72,20 +72,19 @@
/**
* Create a command executor that federates (merges) the information from multiple
sources described by the source
* projections. The resulting command executor does not first consult a cache for the
merged information; if a cache is
- * desired, see
- * {@link #FederatingCommandExecutor(ExecutionEnvironment, String, Projection, List,
RepositoryConnectionFactories)
+ * desired, see {@link #FederatingCommandExecutor(ExecutionContext, String,
Projection, List, RepositoryConnectionFactories)
* constructor} that takes a {@link Projection cache projection}.
*
- * @param env the execution environment in which the executor will be run; may not be
null
+ * @param context the execution context in which the executor will be run; may not be
null
* @param sourceName the name of the {@link RepositorySource} that is making use of
this executor; may not be null or empty
* @param sourceProjections the source projections; may not be null
* @param connectionFactories the factory for connection factory instances
*/
- public FederatingCommandExecutor( ExecutionEnvironment env,
+ public FederatingCommandExecutor( ExecutionContext context,
String sourceName,
List<Projection> sourceProjections,
RepositoryConnectionFactories connectionFactories )
{
- this(env, sourceName, null, sourceProjections, connectionFactories);
+ this(context, sourceName, null, sourceProjections, connectionFactories);
}
/**
@@ -95,25 +94,25 @@
* how the paths are mapped in the cache. This cache will be consulted first for the
requested information, and will be kept
* up to date as changes are made to the federated information.
*
- * @param env the execution environment in which the executor will be run; may not be
null
+ * @param context the execution context in which the executor will be run; may not be
null
* @param sourceName the name of the {@link RepositorySource} that is making use of
this executor; may not be null or empty
* @param cacheProjection the projection used for the cached information; may be null
if there is no cache
* @param sourceProjections the source projections; may not be null
* @param connectionFactories the factory for connection factory instances
*/
- public FederatingCommandExecutor( ExecutionEnvironment env,
+ public FederatingCommandExecutor( ExecutionContext context,
String sourceName,
Projection cacheProjection,
List<Projection> sourceProjections,
RepositoryConnectionFactories connectionFactories )
{
- super(env, sourceName);
+ super(context, sourceName);
assert sourceProjections != null;
assert connectionFactories != null;
this.cacheProjection = cacheProjection;
this.sourceProjections = sourceProjections;
this.connectionFactories = connectionFactories;
this.connectionsBySourceName = new HashMap<String,
RepositoryConnection>();
- this.mergePlanPropertyName =
env.getValueFactories().getNameFactory().create("dna:mergePlan");
+ this.mergePlanPropertyName =
context.getValueFactories().getNameFactory().create("dna:mergePlan");
this.sourceNames = new HashSet<String>();
}
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-07-25
19:37:40 UTC (rev 370)
+++
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/SingleProjectionCommandExecutor.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -24,6 +24,7 @@
import java.util.Set;
import net.jcip.annotations.NotThreadSafe;
import org.jboss.dna.connector.federation.Projection;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PathFactory;
@@ -38,7 +39,6 @@
import org.jboss.dna.spi.graph.commands.RecordBranchCommand;
import org.jboss.dna.spi.graph.commands.SetPropertiesCommand;
import org.jboss.dna.spi.graph.commands.executor.AbstractCommandExecutor;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
import org.jboss.dna.spi.graph.connection.RepositoryConnection;
import org.jboss.dna.spi.graph.connection.RepositoryConnectionFactories;
import org.jboss.dna.spi.graph.connection.RepositoryConnectionFactory;
@@ -57,39 +57,39 @@
private RepositoryConnection connection;
/**
- * @param env the execution environment in which the executor will be run; may not be
null
+ * @param context the execution context in which the executor will be run; may not be
null
* @param sourceName the name of the {@link RepositorySource} that is making use of
this executor; may not be null or empty
* @param projection the projection used for the cached information; may not be null
and must have exactly one
* {@link Projection#getRules() rule}
* @param connectionFactories the factory for connection factory instances
*/
- public SingleProjectionCommandExecutor( ExecutionEnvironment env,
+ public SingleProjectionCommandExecutor( ExecutionContext context,
String sourceName,
Projection projection,
RepositoryConnectionFactories
connectionFactories ) {
- this(env, sourceName, null, projection, connectionFactories);
+ this(context, sourceName, null, projection, connectionFactories);
}
/**
- * @param env the execution environment in which the executor will be run; may not be
null
+ * @param context the execution context in which the executor will be run; may not be
null
* @param sourceName the name of the {@link RepositorySource} that is making use of
this executor; may not be null or empty
* @param now the current time; may be null if the system time is to be used
* @param projection the projection used for the cached information; may not be null
and must have exactly one
* {@link Projection#getRules() rule}
* @param connectionFactories the factory for connection factory instances
*/
- public SingleProjectionCommandExecutor( ExecutionEnvironment env,
+ public SingleProjectionCommandExecutor( ExecutionContext context,
String sourceName,
DateTime now,
Projection projection,
RepositoryConnectionFactories
connectionFactories ) {
- super(env, sourceName, now);
+ super(context, sourceName, now);
assert connectionFactories != null;
assert projection != null;
assert projection.getRules().size() == 1;
this.projection = projection;
this.factories = connectionFactories;
- this.pathFactory = env.getValueFactories().getPathFactory();
+ this.pathFactory = context.getValueFactories().getPathFactory();
assert this.pathFactory != null;
}
Modified:
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatedRepositoryConnectionTest.java
===================================================================
---
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatedRepositoryConnectionTest.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatedRepositoryConnectionTest.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -29,9 +29,9 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.util.concurrent.TimeUnit;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.graph.commands.GraphCommand;
import org.jboss.dna.spi.graph.commands.executor.CommandExecutor;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
import org.jboss.dna.spi.graph.connection.RepositorySourceException;
import org.jboss.dna.spi.graph.connection.RepositorySourceListener;
import org.junit.Before;
@@ -79,28 +79,28 @@
@Test( expected = RepositorySourceException.class )
public void shouldFailExecutionIfRepositoryAdminsIsNotStarted() throws Exception {
stub(repository.isRunning()).toReturn(false);
- ExecutionEnvironment env = mock(ExecutionEnvironment.class);
+ ExecutionContext context = mock(ExecutionContext.class);
GraphCommand command = mock(GraphCommand.class);
- connection.execute(env, command);
+ connection.execute(context, command);
}
@Test
public void shouldReturnImmediatelyWhenExecutingNullOrEmptyCommandArray() throws
Exception {
stub(repository.isRunning()).toReturn(true);
- ExecutionEnvironment env = mock(ExecutionEnvironment.class);
- connection.execute(env, (GraphCommand[])null);
+ ExecutionContext context = mock(ExecutionContext.class);
+ connection.execute(context, (GraphCommand[])null);
verify(repository, times(1)).isRunning();
- connection.execute(env, new GraphCommand[0]);
+ connection.execute(context, new GraphCommand[0]);
verify(repository, times(2)).isRunning();
}
@Test
public void shouldSkipNullCommandReferencesWhenExecuting() throws Exception {
stub(repository.isRunning()).toReturn(true);
- ExecutionEnvironment env = mock(ExecutionEnvironment.class);
+ ExecutionContext context = mock(ExecutionContext.class);
CommandExecutor executor = mock(CommandExecutor.class);
- stub(repository.getExecutor(env, sourceName)).toReturn(executor);
- connection.execute(env, new GraphCommand[] {null, null, null});
+ stub(repository.getExecutor(context, sourceName)).toReturn(executor);
+ connection.execute(context, new GraphCommand[] {null, null, null});
verify(repository, times(1)).isRunning();
}
Modified:
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatedRepositorySourceTest.java
===================================================================
---
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatedRepositorySourceTest.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatedRepositorySourceTest.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -39,9 +39,9 @@
import javax.naming.Reference;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.login.LoginException;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.ExecutionContextFactory;
-import org.jboss.dna.spi.graph.connection.BasicExecutionEnvironment;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
+import org.jboss.dna.spi.graph.connection.BasicExecutionContext;
import org.jboss.dna.spi.graph.connection.RepositoryConnection;
import org.jboss.dna.spi.graph.connection.RepositoryConnectionFactories;
import org.jboss.dna.spi.graph.connection.RepositorySourceException;
@@ -70,7 +70,7 @@
private String securityDomain;
private SimpleRepository configRepository;
private SimpleRepositorySource configRepositorySource;
- private ExecutionEnvironment env;
+ private ExecutionContext context;
@Mock
private RepositoryConnection connection;
@Mock
@@ -86,8 +86,8 @@
@Before
public void beforeEach() throws Exception {
MockitoAnnotations.initMocks(this);
- env = new BasicExecutionEnvironment();
- env.getNamespaceRegistry().register("dna",
"http://www.jboss.org/dna");
+ context = new BasicExecutionContext();
+ context.getNamespaceRegistry().register("dna",
"http://www.jboss.org/dna");
executionContextFactoryJndiName = "context factory jndi name";
connectionFactoriesJndiName = "connection factories jndi name";
configurationSourceName = "configuration source name";
@@ -107,14 +107,14 @@
source.setContext(jndiContext);
source.setSecurityDomain(securityDomain);
configRepository = new SimpleRepository("Configuration Repository");
- configRepository.setProperty(env, "/dna:repositories/Test Repository",
"dna:timeToExpire", "100000");
- configRepository.setProperty(env, "/dna:repositories/Test Repository",
"dna:timeToCache", "100000");
- configRepository.setProperty(env, "/dna:repositories/Test
Repository/dna:cache", "dna:projectionRules", "/ => /");
- configRepository.setProperty(env,
+ configRepository.setProperty(context, "/dna:repositories/Test
Repository", "dna:timeToExpire", "100000");
+ configRepository.setProperty(context, "/dna:repositories/Test
Repository", "dna:timeToCache", "100000");
+ configRepository.setProperty(context, "/dna:repositories/Test
Repository/dna:cache", "dna:projectionRules", "/ => /");
+ configRepository.setProperty(context,
"/dna:repositories/Test
Repository/dna:projections/source 1/",
"dna:projectionRules",
"/ => /s1");
- configRepository.setProperty(env,
+ configRepository.setProperty(context,
"/dna:repositories/Test
Repository/dna:projections/source 2/",
"dna:projectionRules",
"/ => /s1");
@@ -124,7 +124,7 @@
stub(connectionFactories.getConnectionFactory(configurationSourceName)).toReturn(configRepositorySource);
stub(jndiContext.lookup(executionContextFactoryJndiName)).toReturn(executionContextFactory);
stub(jndiContext.lookup(connectionFactoriesJndiName)).toReturn(connectionFactories);
- stub(executionContextFactory.create(eq(securityDomain),
anyCallbackHandler())).toReturn(env);
+ stub(executionContextFactory.create(eq(securityDomain),
anyCallbackHandler())).toReturn(context);
}
protected static CallbackHandler anyCallbackHandler() {
Modified:
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatedRepositoryTest.java
===================================================================
---
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatedRepositoryTest.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatedRepositoryTest.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -27,8 +27,8 @@
import static org.hamcrest.core.IsSame.sameInstance;
import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.hasItems;
-import org.jboss.dna.spi.graph.connection.BasicExecutionEnvironment;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
+import org.jboss.dna.spi.ExecutionContext;
+import org.jboss.dna.spi.graph.connection.BasicExecutionContext;
import org.jboss.dna.spi.graph.connection.RepositoryConnectionFactories;
import org.jboss.dna.spi.graph.connection.RepositorySourceListener;
import org.junit.Before;
@@ -41,7 +41,7 @@
*/
public class FederatedRepositoryTest {
- private ExecutionEnvironment env;
+ private ExecutionContext context;
private FederatedRepository repository;
@Mock
private FederatedRepositoryConfig config;
@@ -57,8 +57,8 @@
@Before
public void beforeEach() {
MockitoAnnotations.initMocks(this);
- env = new BasicExecutionEnvironment();
- repository = new FederatedRepository(env, connectionFactories, config);
+ context = new BasicExecutionContext();
+ repository = new FederatedRepository(context, connectionFactories, config);
}
@Test
Modified:
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/ProjectionPathRuleTest.java
===================================================================
---
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/ProjectionPathRuleTest.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/ProjectionPathRuleTest.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -28,11 +28,11 @@
import static org.junit.matchers.JUnitMatchers.hasItems;
import org.jboss.dna.common.text.TextEncoder;
import org.jboss.dna.common.text.UrlEncoder;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.graph.NamespaceRegistry;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PathFactory;
-import org.jboss.dna.spi.graph.connection.BasicExecutionEnvironment;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
+import org.jboss.dna.spi.graph.connection.BasicExecutionContext;
import org.junit.Before;
import org.junit.Test;
@@ -41,7 +41,7 @@
*/
public class ProjectionPathRuleTest {
- private ExecutionEnvironment env;
+ private ExecutionContext context;
private Projection.PathRule rule;
private PathFactory pathFactory;
private Path repositoryPath;
@@ -52,9 +52,9 @@
@Before
public void beforeEach() {
- env = new BasicExecutionEnvironment();
- pathFactory = env.getValueFactories().getPathFactory();
- registry = env.getNamespaceRegistry();
+ context = new BasicExecutionContext();
+ pathFactory = context.getValueFactories().getPathFactory();
+ registry = context.getNamespaceRegistry();
encoder = new UrlEncoder();
repositoryPath = pathFactory.create("/a/b/c");
sourcePath = pathFactory.create("/x/y");
Modified:
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/ProjectionTest.java
===================================================================
---
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/ProjectionTest.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/ProjectionTest.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -26,11 +26,10 @@
import static org.junit.matchers.JUnitMatchers.hasItems;
import static org.mockito.Mockito.stub;
import java.util.Set;
-import org.jboss.dna.connector.federation.Projection;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PathFactory;
-import org.jboss.dna.spi.graph.connection.BasicExecutionEnvironment;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
+import org.jboss.dna.spi.graph.connection.BasicExecutionContext;
import org.junit.Before;
import org.junit.Test;
import org.mockito.MockitoAnnotations;
@@ -41,7 +40,7 @@
*/
public class ProjectionTest {
- private ExecutionEnvironment env;
+ private ExecutionContext context;
private String sourceName;
private Projection.Rule[] rules;
private Projection projection;
@@ -56,8 +55,8 @@
@Before
public void beforeEach() {
MockitoAnnotations.initMocks(this);
- env = new BasicExecutionEnvironment();
- pathFactory = env.getValueFactories().getPathFactory();
+ context = new BasicExecutionContext();
+ pathFactory = context.getValueFactories().getPathFactory();
sourceName = "Valid name";
rules = new Projection.Rule[] {mockRule1, mockRule2, mockRule3};
projection = new Projection(sourceName, rules);
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-07-25
19:37:40 UTC (rev 370)
+++
trunk/connectors/dna-connector-inmemory/src/main/java/org/jboss/dna/connector/inmemory/InMemoryRepository.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -31,6 +31,7 @@
import java.util.concurrent.locks.ReentrantReadWriteLock;
import net.jcip.annotations.NotThreadSafe;
import org.jboss.dna.common.util.ArgCheck;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PathNotFoundException;
@@ -48,7 +49,6 @@
import org.jboss.dna.spi.graph.commands.SetPropertiesCommand;
import org.jboss.dna.spi.graph.commands.executor.AbstractCommandExecutor;
import org.jboss.dna.spi.graph.commands.executor.CommandExecutor;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
/**
* @author Randall Hauch
@@ -99,11 +99,11 @@
return nodesByUuid;
}
- public Node getNode( ExecutionEnvironment env,
+ public Node getNode( ExecutionContext context,
String path ) {
- assert env != null;
+ assert context != null;
assert path != null;
- return getNode(env.getValueFactories().getPathFactory().create(path));
+ return getNode(context.getValueFactories().getPathFactory().create(path));
}
/**
@@ -139,15 +139,15 @@
return UUID.randomUUID();
}
- public void removeNode( ExecutionEnvironment env,
+ public void removeNode( ExecutionContext context,
Node node ) {
- assert env != null;
+ assert context != null;
assert node != null;
assert getRoot().equals(node) != true;
Node parent = node.getParent();
assert parent != null;
parent.getChildren().remove(node);
- correctSameNameSiblingIndexes(env, parent, node.getName().getName());
+ correctSameNameSiblingIndexes(context, parent, node.getName().getName());
removeUuidReference(node);
}
@@ -161,47 +161,47 @@
/**
* Create a node at the supplied path. The parent of the new node must already
exist.
*
- * @param env the environment; may not be null
+ * @param context the environment; may not be null
* @param pathToNewNode the path to the new node; may not be null
* @return the new node (or root if the path specified the root)
*/
- public Node createNode( ExecutionEnvironment env,
+ public Node createNode( ExecutionContext context,
String pathToNewNode ) {
- assert env != null;
+ assert context != null;
assert pathToNewNode != null;
- Path path = env.getValueFactories().getPathFactory().create(pathToNewNode);
+ Path path = context.getValueFactories().getPathFactory().create(pathToNewNode);
if (path.isRoot()) return getRoot();
Path parentPath = path.getAncestor();
Node parentNode = getNode(parentPath);
Name name = path.getLastSegment().getName();
- return createNode(env, parentNode, name);
+ return createNode(context, parentNode, name);
}
/**
* Create a new node with the supplied name, as a child of the supplied parent.
*
- * @param env the execution environment
+ * @param context the execution context
* @param parentNode the parent node; may not be null
* @param name the name; may not be null
* @return the new node
*/
- public Node createNode( ExecutionEnvironment env,
+ public Node createNode( ExecutionContext context,
Node parentNode,
Name name ) {
- assert env != null;
+ assert context != null;
assert name != null;
if (parentNode == null) parentNode = getRoot();
Node node = new Node(generateUuid());
nodesByUuid.put(node.getUuid(), node);
node.setParent(parentNode);
- Path.Segment newName =
env.getValueFactories().getPathFactory().createSegment(name);
+ Path.Segment newName =
context.getValueFactories().getPathFactory().createSegment(name);
node.setName(newName);
parentNode.getChildren().add(node);
- correctSameNameSiblingIndexes(env, parentNode, name);
+ correctSameNameSiblingIndexes(context, parentNode, name);
return node;
}
- protected void correctSameNameSiblingIndexes( ExecutionEnvironment env,
+ protected void correctSameNameSiblingIndexes( ExecutionContext context,
Node parentNode,
Name name ) {
if (parentNode == null) return;
@@ -213,7 +213,7 @@
if (childrenWithSameNames.size() == 0) return;
if (childrenWithSameNames.size() == 1) {
Node childWithSameName = childrenWithSameNames.get(0);
- Path.Segment newName =
env.getValueFactories().getPathFactory().createSegment(name, Path.NO_INDEX);
+ Path.Segment newName =
context.getValueFactories().getPathFactory().createSegment(name, Path.NO_INDEX);
childWithSameName.setName(newName);
return;
}
@@ -221,7 +221,7 @@
for (Node childWithSameName : childrenWithSameNames) {
Path.Segment segment = childWithSameName.getName();
if (segment.getIndex() != index) {
- Path.Segment newName =
env.getValueFactories().getPathFactory().createSegment(name, index);
+ Path.Segment newName =
context.getValueFactories().getPathFactory().createSegment(name, index);
childWithSameName.setName(newName);
}
++index;
@@ -232,14 +232,14 @@
* Move the supplied node to the new parent. This method automatically removes the
node from its existing parent, and also
* correctly adjusts the {@link Path.Segment#getIndex() index} to be correct in the
new parent.
*
- * @param env
+ * @param context
* @param node the node to be moved; may not be the {@link #getRoot() root}
* @param newParent the new parent; may not be the {@link #getRoot() root}
*/
- public void moveNode( ExecutionEnvironment env,
+ public void moveNode( ExecutionContext context,
Node node,
Node newParent ) {
- assert env != null;
+ assert context != null;
assert newParent != null;
assert node != null;
assert getRoot().equals(newParent) != true;
@@ -250,22 +250,22 @@
boolean removed = oldParent.getChildren().remove(node);
assert removed == true;
node.setParent(null);
- correctSameNameSiblingIndexes(env, oldParent, node.getName().getName());
+ correctSameNameSiblingIndexes(context, oldParent, node.getName().getName());
}
node.setParent(newParent);
newParent.getChildren().add(node);
- correctSameNameSiblingIndexes(env, newParent, node.getName().getName());
+ correctSameNameSiblingIndexes(context, newParent, node.getName().getName());
}
- public int copyNode( ExecutionEnvironment env,
+ public int copyNode( ExecutionContext context,
Node original,
Node newParent,
boolean recursive ) {
- assert env != null;
+ assert context != null;
assert original != null;
assert newParent != null;
// Get or create the new node ...
- Node copy = createNode(env, newParent, original.getName().getName());
+ Node copy = createNode(context, newParent, original.getName().getName());
// Copy the properties ...
copy.getProperties().clear();
@@ -274,7 +274,7 @@
if (recursive) {
// Loop over each child and call this method ...
for (Node child : original.getChildren()) {
- numNodesCopied += copyNode(env, child, copy, true);
+ numNodesCopied += copyNode(context, child, copy, true);
}
}
return numNodesCopied;
@@ -283,20 +283,20 @@
/**
* Get a command executor given the supplied environment and source name.
*
- * @param env the environment in which the commands are to be executed
+ * @param context the environment in which the commands are to be executed
* @param sourceName the name of the repository source
* @return the executor; never null
*/
- public CommandExecutor getCommandExecutor( ExecutionEnvironment env,
+ public CommandExecutor getCommandExecutor( ExecutionContext context,
String sourceName ) {
- return new Executor(env, sourceName);
+ return new Executor(context, sourceName);
}
protected class Executor extends AbstractCommandExecutor {
- protected Executor( ExecutionEnvironment env,
+ protected Executor( ExecutionContext context,
String sourceName ) {
- super(env, sourceName);
+ super(context, sourceName);
}
@Override
Modified:
trunk/connectors/dna-connector-inmemory/src/main/java/org/jboss/dna/connector/inmemory/InMemoryRepositoryConnection.java
===================================================================
---
trunk/connectors/dna-connector-inmemory/src/main/java/org/jboss/dna/connector/inmemory/InMemoryRepositoryConnection.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/connectors/dna-connector-inmemory/src/main/java/org/jboss/dna/connector/inmemory/InMemoryRepositoryConnection.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -24,11 +24,11 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import javax.transaction.xa.XAResource;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.cache.CachePolicy;
import org.jboss.dna.spi.graph.commands.ActsAsUpdate;
import org.jboss.dna.spi.graph.commands.GraphCommand;
import org.jboss.dna.spi.graph.commands.executor.CommandExecutor;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
import org.jboss.dna.spi.graph.connection.RepositoryConnection;
import org.jboss.dna.spi.graph.connection.RepositorySourceException;
import org.jboss.dna.spi.graph.connection.RepositorySourceListener;
@@ -111,7 +111,7 @@
* @throws InterruptedException
* @throws RepositorySourceException
*/
- public void execute( ExecutionEnvironment env,
+ public void execute( ExecutionContext context,
GraphCommand... commands ) throws RepositorySourceException,
InterruptedException {
// Do any commands update/write?
Lock lock = this.content.getLock().readLock();
@@ -124,7 +124,7 @@
try {
// Obtain the lock and execute the commands ...
- CommandExecutor executor = this.content.getCommandExecutor(env,
this.getSourceName());
+ CommandExecutor executor = this.content.getCommandExecutor(context,
this.getSourceName());
lock.lock();
for (GraphCommand command : commands) {
executor.execute(command);
Modified:
trunk/connectors/dna-connector-inmemory/src/main/java/org/jboss/dna/connector/inmemory/Node.java
===================================================================
---
trunk/connectors/dna-connector-inmemory/src/main/java/org/jboss/dna/connector/inmemory/Node.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/connectors/dna-connector-inmemory/src/main/java/org/jboss/dna/connector/inmemory/Node.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -27,11 +27,11 @@
import java.util.Map;
import java.util.UUID;
import net.jcip.annotations.NotThreadSafe;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Property;
import org.jboss.dna.spi.graph.PropertyFactory;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
/**
* @author Randall Hauch
@@ -106,17 +106,17 @@
return this;
}
- public Node setProperty( ExecutionEnvironment env,
+ public Node setProperty( ExecutionContext context,
String name,
Object... values ) {
- PropertyFactory propertyFactory = env.getPropertyFactory();
- Name propertyName = env.getValueFactories().getNameFactory().create(name);
+ PropertyFactory propertyFactory = context.getPropertyFactory();
+ Name propertyName = context.getValueFactories().getNameFactory().create(name);
return setProperty(propertyFactory.create(propertyName, values));
}
- public Property getProperty( ExecutionEnvironment env,
+ public Property getProperty( ExecutionContext context,
String name ) {
- Name propertyName = env.getValueFactories().getNameFactory().create(name);
+ Name propertyName = context.getValueFactories().getNameFactory().create(name);
return getProperty(propertyName);
}
Modified:
trunk/connectors/dna-connector-inmemory/src/test/java/org/jboss/dna/connector/inmemory/InMemoryRepositoryTest.java
===================================================================
---
trunk/connectors/dna-connector-inmemory/src/test/java/org/jboss/dna/connector/inmemory/InMemoryRepositoryTest.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/connectors/dna-connector-inmemory/src/test/java/org/jboss/dna/connector/inmemory/InMemoryRepositoryTest.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -32,6 +32,7 @@
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.NameFactory;
import org.jboss.dna.spi.graph.PathFactory;
@@ -39,7 +40,6 @@
import org.jboss.dna.spi.graph.PropertyFactory;
import org.jboss.dna.spi.graph.ValueFactories;
import org.jboss.dna.spi.graph.ValueFactory;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
import org.jboss.dna.spi.graph.impl.BasicNamespaceRegistry;
import org.jboss.dna.spi.graph.impl.BasicPropertyFactory;
import org.jboss.dna.spi.graph.impl.StandardValueFactories;
@@ -61,7 +61,7 @@
private NameFactory nameFactory;
private PropertyFactory propertyFactory;
@Mock
- private ExecutionEnvironment env;
+ private ExecutionContext context;
@Before
public void beforeEach() throws Exception {
@@ -73,8 +73,8 @@
name = "Test repository";
rootUuid = UUID.randomUUID();
repository = new InMemoryRepository(name, rootUuid);
- stub(env.getValueFactories()).toReturn(valueFactories);
- stub(env.getPropertyFactory()).toReturn(propertyFactory);
+ stub(context.getValueFactories()).toReturn(valueFactories);
+ stub(context.getPropertyFactory()).toReturn(propertyFactory);
}
@Test( expected = IllegalArgumentException.class )
@@ -117,13 +117,13 @@
@Test( expected = AssertionError.class )
public void shouldNotAllowRootToBeRemoved() {
- repository.removeNode(env, repository.getRoot());
+ repository.removeNode(context, repository.getRoot());
}
@Test( expected = AssertionError.class )
public void shouldNotAllowRootToBeMoved() {
Node node = mock(Node.class);
- repository.moveNode(env, repository.getRoot(), node);
+ repository.moveNode(context, repository.getRoot(), node);
}
@Test( expected = AssertionError.class )
@@ -136,7 +136,7 @@
@Test( expected = AssertionError.class )
public void shouldNotAllowNullNodeToBeMoved() {
Node newParent = mock(Node.class);
- repository.moveNode(env, null, newParent);
+ repository.moveNode(context, null, newParent);
}
@Test( expected = AssertionError.class )
@@ -147,27 +147,27 @@
@Test( expected = AssertionError.class )
public void shouldNotAllowNullNodeToBeRemoved() {
- repository.removeNode(env, null);
+ repository.removeNode(context, null);
}
@Test
public void shouldCreateNodesByPath() {
Name name_a = nameFactory.create("a");
- Node node_a = repository.createNode(env, repository.getRoot(), name_a);
+ Node node_a = repository.createNode(context, repository.getRoot(), name_a);
assertThat(node_a, is(notNullValue()));
assertThat(node_a.getParent(), is(repository.getRoot()));
assertThat(node_a.getName().getName(), is(name_a));
assertThat(node_a.getName().hasIndex(), is(false));
Name name_b = nameFactory.create("b");
- Node node_b = repository.createNode(env, node_a, name_b);
+ Node node_b = repository.createNode(context, node_a, name_b);
assertThat(node_b, is(notNullValue()));
assertThat(node_b.getParent(), is(node_a));
assertThat(node_b.getName().getName(), is(name_b));
assertThat(node_b.getName().hasIndex(), is(false));
Name name_c = nameFactory.create("c");
- Node node_c = repository.createNode(env, node_b, name_c);
+ Node node_c = repository.createNode(context, node_b, name_c);
assertThat(node_c, is(notNullValue()));
assertThat(node_c.getParent(), is(node_b));
assertThat(node_c.getName().getName(), is(name_c));
@@ -182,9 +182,9 @@
@Test
public void shouldNotFindNodesThatDoNotExist() {
- Node node_a = repository.createNode(env, repository.getRoot(),
nameFactory.create("a"));
- Node node_b = repository.createNode(env, node_a,
nameFactory.create("b"));
- /*Node node_c =*/repository.createNode(env, node_b,
nameFactory.create("c"));
+ Node node_a = repository.createNode(context, repository.getRoot(),
nameFactory.create("a"));
+ Node node_b = repository.createNode(context, node_a,
nameFactory.create("b"));
+ /*Node node_c =*/repository.createNode(context, node_b,
nameFactory.create("c"));
assertThat(repository.getNodesByUuid().size(), is(4));
assertThat(repository.getNode(pathFactory.create("/a[1]")),
is(nullValue()));
@@ -194,14 +194,14 @@
@Test
public void shouldCorrectlyManageIndexesOfSiblingsWithSameNames() {
Name name_a1 = nameFactory.create("a");
- Node node_a1 = repository.createNode(env, repository.getRoot(), name_a1);
+ Node node_a1 = repository.createNode(context, repository.getRoot(), name_a1);
assertThat(node_a1, is(notNullValue()));
assertThat(node_a1.getParent(), is(repository.getRoot()));
assertThat(node_a1.getName().getName(), is(name_a1));
assertThat(node_a1.getName().hasIndex(), is(false));
Name name_a2 = nameFactory.create("a");
- Node node_a2 = repository.createNode(env, repository.getRoot(), name_a2);
+ Node node_a2 = repository.createNode(context, repository.getRoot(), name_a2);
assertThat(node_a2, is(notNullValue()));
assertThat(node_a2.getParent(), is(repository.getRoot()));
assertThat(node_a2.getName().getName(), is(name_a2));
@@ -213,7 +213,7 @@
// Add another node without the same name ...
Name name_b = nameFactory.create("b");
- Node node_b = repository.createNode(env, repository.getRoot(), name_b);
+ Node node_b = repository.createNode(context, repository.getRoot(), name_b);
assertThat(node_b, is(notNullValue()));
assertThat(node_b.getParent(), is(repository.getRoot()));
assertThat(node_b.getName().getName(), is(name_b));
@@ -221,7 +221,7 @@
// Add a third node with the same name ...
Name name_a3 = nameFactory.create("a");
- Node node_a3 = repository.createNode(env, repository.getRoot(), name_a3);
+ Node node_a3 = repository.createNode(context, repository.getRoot(), name_a3);
assertThat(node_a3, is(notNullValue()));
assertThat(node_a3.getParent(), is(repository.getRoot()));
assertThat(node_a3.getName().getName(), is(name_a3));
@@ -238,7 +238,7 @@
assertThat(repository.getNode(pathFactory.create("/b")),
is(sameInstance(node_b)));
// Removing a node with the same name will reduce the index ...
- repository.removeNode(env, node_a2);
+ repository.removeNode(context, node_a2);
assertThat(repository.getRoot().getChildren().size(), is(3));
assertThat(repository.getRoot().getChildren(), hasItems(node_a1, node_b,
node_a3));
assertThat(node_a1.getName().getIndex(), is(1));
@@ -246,7 +246,7 @@
assertThat(node_a3.getName().getIndex(), is(2));
// Removing a node with the same name will reduce the index ...
- repository.removeNode(env, node_a1);
+ repository.removeNode(context, node_a1);
assertThat(repository.getRoot().getChildren().size(), is(2));
assertThat(repository.getRoot().getChildren(), hasItems(node_b, node_a3));
assertThat(node_b.getName().hasIndex(), is(false));
@@ -257,12 +257,12 @@
@Test
public void shouldMoveNodes() {
Node root = repository.getRoot();
- Node node_a = repository.createNode(env, root,
nameFactory.create("a"));
- Node node_b = repository.createNode(env, node_a,
nameFactory.create("b"));
- Node node_c = repository.createNode(env, node_b,
nameFactory.create("c"));
- Node node_d = repository.createNode(env, root,
nameFactory.create("d"));
- Node node_e = repository.createNode(env, node_d,
nameFactory.create("e"));
- Node node_b2 = repository.createNode(env, node_d,
nameFactory.create("b"));
+ Node node_a = repository.createNode(context, root,
nameFactory.create("a"));
+ Node node_b = repository.createNode(context, node_a,
nameFactory.create("b"));
+ Node node_c = repository.createNode(context, node_b,
nameFactory.create("c"));
+ Node node_d = repository.createNode(context, root,
nameFactory.create("d"));
+ Node node_e = repository.createNode(context, node_d,
nameFactory.create("e"));
+ Node node_b2 = repository.createNode(context, node_d,
nameFactory.create("b"));
assertThat(repository.getNodesByUuid().size(), is(7));
assertThat(repository.getNode(pathFactory.create("/")),
is(sameInstance(repository.getRoot())));
@@ -273,7 +273,7 @@
assertThat(repository.getNode(pathFactory.create("/d/e")),
is(sameInstance(node_e)));
assertThat(repository.getNode(pathFactory.create("/d/b")),
is(sameInstance(node_b2)));
- repository.moveNode(env, node_b, node_d);
+ repository.moveNode(context, node_b, node_d);
assertThat(repository.getNode(pathFactory.create("/")),
is(sameInstance(repository.getRoot())));
assertThat(repository.getNode(pathFactory.create("/a")),
is(sameInstance(node_a)));
@@ -283,7 +283,7 @@
assertThat(repository.getNode(pathFactory.create("/d/b[2]")),
is(sameInstance(node_b)));
assertThat(repository.getNode(pathFactory.create("/d/b[2]/c")),
is(sameInstance(node_c)));
- repository.moveNode(env, node_b, node_e);
+ repository.moveNode(context, node_b, node_e);
assertThat(repository.getNode(pathFactory.create("/")),
is(sameInstance(repository.getRoot())));
assertThat(repository.getNode(pathFactory.create("/a")),
is(sameInstance(node_a)));
@@ -297,12 +297,12 @@
@Test
public void shouldCopyNodes() {
Node root = repository.getRoot();
- Node node_a = repository.createNode(env, root,
nameFactory.create("a"));
- Node node_b = repository.createNode(env, node_a,
nameFactory.create("b"));
- Node node_c = repository.createNode(env, node_b,
nameFactory.create("c"));
- Node node_d = repository.createNode(env, root,
nameFactory.create("d"));
- Node node_e = repository.createNode(env, node_d,
nameFactory.create("e"));
- Node node_b2 = repository.createNode(env, node_d,
nameFactory.create("b"));
+ Node node_a = repository.createNode(context, root,
nameFactory.create("a"));
+ Node node_b = repository.createNode(context, node_a,
nameFactory.create("b"));
+ Node node_c = repository.createNode(context, node_b,
nameFactory.create("c"));
+ Node node_d = repository.createNode(context, root,
nameFactory.create("d"));
+ Node node_e = repository.createNode(context, node_d,
nameFactory.create("e"));
+ Node node_b2 = repository.createNode(context, node_d,
nameFactory.create("b"));
ValueFactory<String> stringFactory = valueFactories.getStringFactory();
Name propertyName = nameFactory.create("something");
@@ -320,7 +320,7 @@
assertThat(repository.getNode(pathFactory.create("/a/b")).getProperties().get(propertyName),
is(property));
- repository.copyNode(env, node_b, node_d, true);
+ repository.copyNode(context, node_b, node_d, true);
assertThat(repository.getNodesByUuid().size(), is(9));
assertThat(repository.getNode(pathFactory.create("/")),
is(sameInstance(repository.getRoot())));
@@ -339,13 +339,18 @@
@Test
public void shouldCreateRepositoryStructure() {
- repository.createNode(env, "/a").setProperty(env, "name",
"value").setProperty(env, "desc", "Some description");
- repository.createNode(env, "/a/b").setProperty(env, "name",
"value2").setProperty(env, "desc", "Some description 2");
- assertThat(repository.getNode(env, "/a").getProperty(env,
"name").getValuesAsArray(), is(new Object[] {"value"}));
- assertThat(repository.getNode(env, "/a").getProperty(env,
"desc").getValuesAsArray(),
+ repository.createNode(context, "/a").setProperty(context,
"name", "value").setProperty(context,
+
"desc",
+
"Some description");
+ repository.createNode(context, "/a/b").setProperty(context,
"name", "value2").setProperty(context,
+
"desc",
+
"Some description 2");
+ assertThat(repository.getNode(context, "/a").getProperty(context,
"name").getValuesAsArray(), is(new Object[] {"value"}));
+ assertThat(repository.getNode(context, "/a").getProperty(context,
"desc").getValuesAsArray(),
is(new Object[] {"Some description"}));
- assertThat(repository.getNode(env, "/a/b").getProperty(env,
"name").getValuesAsArray(), is(new Object[] {"value2"}));
- assertThat(repository.getNode(env, "/a/b").getProperty(env,
"desc").getValuesAsArray(),
+ assertThat(repository.getNode(context, "/a/b").getProperty(context,
"name").getValuesAsArray(),
+ is(new Object[] {"value2"}));
+ assertThat(repository.getNode(context, "/a/b").getProperty(context,
"desc").getValuesAsArray(),
is(new Object[] {"Some description 2"}));
}
}
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-07-25
19:37:40 UTC (rev 370)
+++
trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -31,6 +31,7 @@
import org.jboss.cache.Cache;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.cache.CachePolicy;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
@@ -50,7 +51,6 @@
import org.jboss.dna.spi.graph.commands.SetPropertiesCommand;
import org.jboss.dna.spi.graph.commands.executor.AbstractCommandExecutor;
import org.jboss.dna.spi.graph.commands.executor.CommandExecutor;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
import org.jboss.dna.spi.graph.connection.RepositoryConnection;
import org.jboss.dna.spi.graph.connection.RepositorySourceException;
import org.jboss.dna.spi.graph.connection.RepositorySourceListener;
@@ -139,10 +139,10 @@
/**
* {@inheritDoc}
*/
- public void execute( ExecutionEnvironment env,
+ public void execute( ExecutionContext context,
GraphCommand... commands ) throws RepositorySourceException,
InterruptedException {
// Now execute the commands ...
- CommandExecutor executor = new Executor(env, this.getSourceName());
+ CommandExecutor executor = new Executor(context, this.getSourceName());
for (GraphCommand command : commands) {
executor.execute(command);
}
@@ -160,12 +160,12 @@
* This method may be called without regard to synchronization, since it should
return the same value if it happens to be
* called concurrently while not yet initialized.
*
- * @param env the environment
+ * @param context the execution context
* @return the name, or null if the UUID should not be stored
*/
- protected Name getUuidProperty( ExecutionEnvironment env ) {
+ protected Name getUuidProperty( ExecutionContext context ) {
if (!initializedUuidPropertyName) {
- this.uuidPropertyName =
this.source.getUuidPropertyName(env.getValueFactories().getNameFactory());
+ this.uuidPropertyName =
this.source.getUuidPropertyName(context.getValueFactories().getNameFactory());
initializedUuidPropertyName = true;
}
return this.uuidPropertyName;
@@ -185,13 +185,13 @@
return Fqn.fromElements(pathSegment);
}
- protected Node<Name, Object> getNode( ExecutionEnvironment env,
+ protected Node<Name, Object> getNode( ExecutionContext context,
Path path ) {
// Look up the node with the supplied path ...
Fqn<Segment> fqn = getFullyQualifiedName(path);
Node<Name, Object> node = cache.getNode(fqn);
if (node == null) {
- String nodePath = path.getString(env.getNamespaceRegistry());
+ String nodePath = path.getString(context.getNamespaceRegistry());
throw new PathNotFoundException(path,
JBossCacheConnectorI18n.nodeDoesNotExist.text(nodePath));
}
return node;
@@ -230,10 +230,10 @@
private final PropertyFactory propertyFactory;
- protected Executor( ExecutionEnvironment env,
+ protected Executor( ExecutionContext context,
String sourceName ) {
- super(env, sourceName);
- this.propertyFactory = env.getPropertyFactory();
+ super(context, sourceName);
+ this.propertyFactory = context.getPropertyFactory();
}
@Override
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-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -44,6 +44,7 @@
import org.jboss.dna.repository.services.AbstractServiceAdministrator;
import org.jboss.dna.repository.services.AdministeredService;
import org.jboss.dna.repository.services.ServiceAdministrator;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.NameFactory;
import org.jboss.dna.spi.graph.Path;
@@ -57,7 +58,6 @@
import org.jboss.dna.spi.graph.commands.impl.BasicCompositeCommand;
import org.jboss.dna.spi.graph.commands.impl.BasicGetChildrenCommand;
import org.jboss.dna.spi.graph.commands.impl.BasicGetNodeCommand;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
import org.jboss.dna.spi.graph.connection.RepositoryConnectionFactory;
import org.jboss.dna.spi.graph.connection.RepositorySource;
@@ -113,7 +113,7 @@
}
private final ClassLoaderFactory classLoaderFactory;
- private final ExecutionEnvironment env;
+ private final ExecutionContext context;
private final RepositorySourceManager sources;
private final Projection configurationProjection;
private final Administrator administrator = new Administrator();
@@ -125,7 +125,7 @@
* @param sources the source manager
* @param configurationProjection the projection defining where the service can find
configuration information for the
* different repositories that it is to manage
- * @param env the execution environment in which this service should run
+ * @param context the execution context in which this service should run
* @param classLoaderFactory the class loader factory used to instantiate {@link
RepositorySource} instances; may be null if
* this instance should use a default factory that attempts to load classes
first from the
* {@link Thread#getContextClassLoader() thread's current context class
loader} and then from the class loader that
@@ -134,14 +134,14 @@
*/
public RepositoryService( RepositorySourceManager sources,
Projection configurationProjection,
- ExecutionEnvironment env,
+ ExecutionContext context,
ClassLoaderFactory classLoaderFactory ) {
ArgCheck.isNotNull(configurationProjection,
"configurationProjection");
ArgCheck.isNotNull(sources, "sources");
- ArgCheck.isNotNull(env, "env");
+ ArgCheck.isNotNull(context, "context");
this.sources = sources;
this.configurationProjection = configurationProjection;
- this.env = env;
+ this.context = context;
this.classLoaderFactory = classLoaderFactory != null ? classLoaderFactory : new
StandardClassLoaderFactory();
}
@@ -169,8 +169,8 @@
/**
* @return env
*/
- public ExecutionEnvironment getExecutionEnvironment() {
- return env;
+ public ExecutionContext getExecutionEnvironment() {
+ return context;
}
/**
@@ -192,7 +192,7 @@
//
------------------------------------------------------------------------------------
// Read the configuration ...
//
------------------------------------------------------------------------------------
- ValueFactories valueFactories = env.getValueFactories();
+ ValueFactories valueFactories = context.getValueFactories();
PathFactory pathFactory = valueFactories.getPathFactory();
NameFactory nameFactory = valueFactories.getNameFactory();
@@ -209,13 +209,13 @@
if (configurationProjection.getRules().size() == 1) {
// 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(env,
configurationSourceName, configurationProjection, sources);
+ 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(env, configurationSourceName);
+ executor = new NoOpCommandExecutor(context, configurationSourceName);
} else {
// The configuration repository has more than one projection, so we need
to merge the results
- executor = new FederatingCommandExecutor(env, configurationSourceName,
null, projections, sources);
+ executor = new FederatingCommandExecutor(context,
configurationSourceName, null, projections, sources);
}
// Read the configuration and the repository sources, located as child
nodes/branches under "/dna:sources",
@@ -268,7 +268,7 @@
protected RepositorySource createRepositorySource( Path path,
Map<Name, Property>
properties,
Problems problems ) {
- ValueFactories valueFactories = env.getValueFactories();
+ ValueFactories valueFactories = context.getValueFactories();
NameFactory nameFactory = valueFactories.getNameFactory();
ValueFactory<String> stringFactory = valueFactories.getStringFactory();
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSetRepositoryMonitor.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSetRepositoryMonitor.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSetRepositoryMonitor.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -42,7 +42,7 @@
import org.jboss.dna.repository.observation.NodeChangeListener;
import org.jboss.dna.repository.observation.NodeChanges;
import org.jboss.dna.repository.observation.ObservationService;
-import org.jboss.dna.repository.util.ExecutionContext;
+import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.repository.util.JcrTools;
/**
@@ -64,7 +64,7 @@
protected static final String JCR_PATH_DELIM = "/";
- private final ExecutionContext executionContext;
+ private final JcrExecutionContext executionContext;
private final RuleService ruleService;
private final String jcrAbsolutePath;
private final Pattern ruleSetNamePattern;
@@ -84,7 +84,7 @@
*/
public RuleSetRepositoryMonitor( RuleService ruleService,
String jcrAbsolutePath,
- ExecutionContext executionContext ) {
+ JcrExecutionContext executionContext ) {
ArgCheck.isNotNull(ruleService, "rule service");
ArgCheck.isNotNull(executionContext, "execution context");
this.ruleService = ruleService;
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/Sequencer.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/Sequencer.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/Sequencer.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -32,7 +32,7 @@
import org.jboss.dna.repository.observation.NodeChangeListener;
import org.jboss.dna.repository.observation.NodeChanges;
import org.jboss.dna.repository.observation.ObservationService;
-import org.jboss.dna.repository.util.ExecutionContext;
+import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.repository.util.RepositoryNodePath;
/**
@@ -48,7 +48,7 @@
/**
* Execute the sequencing operation on the supplied node, which has recently been
created or changed. The implementation of
- * this method is responsible for {@link ExecutionContext#getSessionFactory() getting
sessions}, modifying the appropriate
+ * this method is responsible for {@link JcrExecutionContext#getSessionFactory()
getting sessions}, modifying the appropriate
* nodes, {@link Session#save() saving} any changes made by this sequencer, and
{@link Session#logout() closing} all sessions
* (and any other acquired resources), even in the case of {@link
ProgressMonitor#isCancelled() cancellation} or exceptions.
* <p>
@@ -94,7 +94,7 @@
* @throws RepositoryException if there is a problem while working with the
repository
* @throws SequencerException if there is an error in this sequencer
*/
- void execute( Node input, String sequencedPropertyName, NodeChange changes,
Set<RepositoryNodePath> outputPaths, ExecutionContext context, ProgressMonitor
progress )
+ void execute( Node input, String sequencedPropertyName, NodeChange changes,
Set<RepositoryNodePath> outputPaths, JcrExecutionContext context, ProgressMonitor
progress )
throws RepositoryException, SequencerException;
}
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerNodeContext.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerNodeContext.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerNodeContext.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -35,7 +35,7 @@
import org.jboss.dna.common.util.ArgCheck;
import org.jboss.dna.repository.RepositoryI18n;
import org.jboss.dna.repository.mimetype.MimeType;
-import org.jboss.dna.repository.util.ExecutionContext;
+import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.NamespaceRegistry;
import org.jboss.dna.spi.graph.Path;
@@ -60,7 +60,7 @@
SequencerNodeContext( Node input,
javax.jcr.Property sequencedProperty,
- ExecutionContext context ) throws RepositoryException {
+ JcrExecutionContext context ) throws RepositoryException {
assert input != null;
assert sequencedProperty != null;
assert context != null;
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencingService.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencingService.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencingService.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -38,6 +38,7 @@
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.observation.Event;
+import javax.security.auth.Subject;
import net.jcip.annotations.Immutable;
import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.common.component.ClassLoaderFactory;
@@ -56,7 +57,7 @@
import org.jboss.dna.repository.services.AbstractServiceAdministrator;
import org.jboss.dna.repository.services.AdministeredService;
import org.jboss.dna.repository.services.ServiceAdministrator;
-import org.jboss.dna.repository.util.ExecutionContext;
+import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.repository.util.JcrTools;
import org.jboss.dna.repository.util.RepositoryNodePath;
import org.jboss.dna.repository.util.SessionFactory;
@@ -150,9 +151,8 @@
public static final NodeFilter DEFAULT_NODE_FILTER = new DefaultNodeFilter();
/**
- * Class loader factory instance that always returns the
- * {@link Thread#getContextClassLoader() current thread's context class loader}
(if not null) or component library's class
- * loader.
+ * Class loader factory instance that always returns the {@link
Thread#getContextClassLoader() current thread's context class
+ * loader} (if not null) or component library's class loader.
*/
protected static final ClassLoaderFactory DEFAULT_CLASSLOADER_FACTORY = new
StandardClassLoaderFactory(
SequencingService.class.getClassLoader());
@@ -204,7 +204,7 @@
}
- private ExecutionContext executionContext;
+ private JcrExecutionContext executionContext;
private SequencerLibrary sequencerLibrary = new SequencerLibrary();
private Selector sequencerSelector = DEFAULT_SEQUENCER_SELECTOR;
private NodeFilter nodeFilter = DEFAULT_NODE_FILTER;
@@ -287,8 +287,8 @@
}
/**
- * Update the configuration for a sequencer, or add it if there is no
- * {@link SequencerConfig#equals(Object) matching configuration}.
+ * Update the configuration for a sequencer, or add it if there is no {@link
SequencerConfig#equals(Object) matching
+ * configuration}.
*
* @param config the updated (or new) configuration
* @return true if the sequencer was updated, or false if there already was an
existing and
@@ -335,14 +335,14 @@
/**
* @return executionContext
*/
- public ExecutionContext getExecutionContext() {
+ public JcrExecutionContext getExecutionContext() {
return this.executionContext;
}
/**
* @param executionContext Sets executionContext to the specified value.
*/
- public void setExecutionContext( ExecutionContext executionContext ) {
+ public void setExecutionContext( JcrExecutionContext executionContext ) {
ArgCheck.isNotNull(executionContext, "execution context");
if (this.getAdministrator().isStarted()) {
throw new
IllegalStateException(RepositoryI18n.unableToChangeExecutionContextWhileRunning.text());
@@ -615,9 +615,9 @@
}
}
- protected class Context implements ExecutionContext {
+ protected class Context implements JcrExecutionContext {
- protected final ExecutionContext delegate;
+ protected final JcrExecutionContext delegate;
protected final SessionFactory factory;
private final Set<Session> sessions = new HashSet<Session>();
protected final AtomicBoolean closed = new AtomicBoolean(false);
@@ -675,6 +675,15 @@
return SequencingService.this.getExecutionContext().getTools();
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.ExecutionContext#getSubject()
+ */
+ public Subject getSubject() {
+ return this.delegate.getSubject();
+ }
+
public synchronized void close() {
if (this.closed.get()) return;
this.closed.set(true);
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapter.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapter.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapter.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -35,7 +35,7 @@
import org.jboss.dna.common.util.Logger;
import org.jboss.dna.repository.RepositoryI18n;
import org.jboss.dna.repository.observation.NodeChange;
-import org.jboss.dna.repository.util.ExecutionContext;
+import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.repository.util.RepositoryNodePath;
import org.jboss.dna.spi.graph.Binary;
import org.jboss.dna.spi.graph.DateTime;
@@ -80,7 +80,7 @@
String sequencedPropertyName,
NodeChange changes,
Set<RepositoryNodePath> outputPaths,
- ExecutionContext execContext,
+ JcrExecutionContext execContext,
ProgressMonitor progressMonitor ) throws RepositoryException,
SequencerException {
// 'sequencedPropertyName' contains the name of the modified property on
'input' that resulted in the call to this
// sequencer.
@@ -178,7 +178,7 @@
*/
protected boolean saveOutput( Node outputNode,
SequencerOutputMap output,
- ExecutionContext context ) throws RepositoryException
{
+ JcrExecutionContext context ) throws
RepositoryException {
if (output.isEmpty()) return false;
final PathFactory pathFactory = context.getValueFactories().getPathFactory();
final NamespaceRegistry namespaceRegistry = context.getNamespaceRegistry();
Copied:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/BasicJcrExecutionContext.java
(from rev 368,
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/SimpleExecutionContext.java)
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/BasicJcrExecutionContext.java
(rev 0)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/BasicJcrExecutionContext.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -0,0 +1,71 @@
+/*
+ * 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.repository.util;
+
+import org.jboss.dna.common.util.ArgCheck;
+import org.jboss.dna.spi.graph.NamespaceRegistry;
+import org.jboss.dna.spi.graph.PropertyFactory;
+import org.jboss.dna.spi.graph.ValueFactories;
+import org.jboss.dna.spi.graph.connection.BasicExecutionContext;
+
+/**
+ * @author Randall Hauch
+ */
+public class BasicJcrExecutionContext extends BasicExecutionContext implements
JcrExecutionContext {
+
+ private final JcrTools tools = new JcrTools();
+ private final SessionFactory sessionFactory;
+
+ public BasicJcrExecutionContext( SessionFactory sessionFactory,
+ String repositoryWorkspaceForNamespaceRegistry ) {
+ this(sessionFactory, new JcrNamespaceRegistry(sessionFactory,
repositoryWorkspaceForNamespaceRegistry), null, null);
+ }
+
+ public BasicJcrExecutionContext( SessionFactory sessionFactory,
+ NamespaceRegistry namespaceRegistry ) {
+ this(sessionFactory, namespaceRegistry, null, null);
+ }
+
+ public BasicJcrExecutionContext( SessionFactory sessionFactory,
+ NamespaceRegistry namespaceRegistry,
+ ValueFactories valueFactories,
+ PropertyFactory propertyFactory ) {
+ super(namespaceRegistry, valueFactories, propertyFactory);
+ ArgCheck.isNotNull(sessionFactory, "session factory");
+ this.sessionFactory = sessionFactory;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public SessionFactory getSessionFactory() {
+ return this.sessionFactory;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public JcrTools getTools() {
+ return this.tools;
+ }
+
+}
Deleted:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/ExecutionContext.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/ExecutionContext.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/ExecutionContext.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -1,49 +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.repository.util;
-
-import javax.jcr.Session;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
-
-/**
- * The context of an execution.
- *
- * @author Randall Hauch
- */
-public interface ExecutionContext extends ExecutionEnvironment {
-
- /**
- * Get the session factory, which can be used to obtain sessions temporarily for this
context. Any session obtained from this
- * factory should be {@link Session#logout() closed} before the execution finishes.
- *
- * @return the session factory
- */
- SessionFactory getSessionFactory();
-
- /**
- * Get a set of utilities for working with JCR.
- *
- * @return the tools
- */
- JcrTools getTools();
-
-}
Copied:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/JcrExecutionContext.java
(from rev 368,
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/ExecutionContext.java)
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/JcrExecutionContext.java
(rev 0)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/JcrExecutionContext.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -0,0 +1,49 @@
+/*
+ * 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.repository.util;
+
+import javax.jcr.Session;
+import org.jboss.dna.spi.ExecutionContext;
+
+/**
+ * The context of an execution within a JCR environment.
+ *
+ * @author Randall Hauch
+ */
+public interface JcrExecutionContext extends ExecutionContext {
+
+ /**
+ * Get the session factory, which can be used to obtain sessions temporarily for this
context. Any session obtained from this
+ * factory should be {@link Session#logout() closed} before the execution finishes.
+ *
+ * @return the session factory
+ */
+ SessionFactory getSessionFactory();
+
+ /**
+ * Get a set of utilities for working with JCR.
+ *
+ * @return the tools
+ */
+ JcrTools getTools();
+
+}
Property changes on:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/JcrExecutionContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/SimpleExecutionContext.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/SimpleExecutionContext.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/SimpleExecutionContext.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -1,71 +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.repository.util;
-
-import org.jboss.dna.common.util.ArgCheck;
-import org.jboss.dna.spi.graph.NamespaceRegistry;
-import org.jboss.dna.spi.graph.PropertyFactory;
-import org.jboss.dna.spi.graph.ValueFactories;
-import org.jboss.dna.spi.graph.connection.BasicExecutionEnvironment;
-
-/**
- * @author Randall Hauch
- */
-public class SimpleExecutionContext extends BasicExecutionEnvironment implements
ExecutionContext {
-
- private final JcrTools tools = new JcrTools();
- private final SessionFactory sessionFactory;
-
- public SimpleExecutionContext( SessionFactory sessionFactory,
- String repositoryWorkspaceForNamespaceRegistry ) {
- this(sessionFactory, new JcrNamespaceRegistry(sessionFactory,
repositoryWorkspaceForNamespaceRegistry), null, null);
- }
-
- public SimpleExecutionContext( SessionFactory sessionFactory,
- NamespaceRegistry namespaceRegistry ) {
- this(sessionFactory, namespaceRegistry, null, null);
- }
-
- public SimpleExecutionContext( SessionFactory sessionFactory,
- NamespaceRegistry namespaceRegistry,
- ValueFactories valueFactories,
- PropertyFactory propertyFactory ) {
- super(namespaceRegistry, valueFactories, propertyFactory);
- ArgCheck.isNotNull(sessionFactory, "session factory");
- this.sessionFactory = sessionFactory;
- }
-
- /**
- * {@inheritDoc}
- */
- public SessionFactory getSessionFactory() {
- return this.sessionFactory;
- }
-
- /**
- * {@inheritDoc}
- */
- public JcrTools getTools() {
- return this.tools;
- }
-
-}
Modified:
trunk/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryServiceTest.java
===================================================================
---
trunk/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryServiceTest.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryServiceTest.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -39,11 +39,11 @@
import org.jboss.dna.connector.federation.FederationException;
import org.jboss.dna.connector.federation.Projection;
import org.jboss.dna.repository.services.ServiceAdministrator;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.graph.NamespaceRegistry;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PathFactory;
import org.jboss.dna.spi.graph.PropertyFactory;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
import org.jboss.dna.spi.graph.connection.RepositorySource;
import org.jboss.dna.spi.graph.connection.SimpleRepository;
import org.jboss.dna.spi.graph.connection.SimpleRepositorySource;
@@ -76,7 +76,7 @@
private SimpleRepository configRepository;
private SimpleRepositorySource configRepositorySource;
@Mock
- private ExecutionEnvironment env;
+ private ExecutionContext context;
@Mock
private RepositorySourceManager sources;
@@ -98,10 +98,10 @@
configRepositorySource.setRepositoryName(configRepository.getRepositoryName());
configRepositorySource.setName(configSourceName);
stub(sources.getConnectionFactory(configSourceName)).toReturn(configRepositorySource);
- stub(env.getValueFactories()).toReturn(valueFactories);
- stub(env.getPropertyFactory()).toReturn(propertyFactory);
- stub(env.getNamespaceRegistry()).toReturn(registry);
- service = new RepositoryService(sources, configProjection, env, null);
+ stub(context.getValueFactories()).toReturn(valueFactories);
+ stub(context.getPropertyFactory()).toReturn(propertyFactory);
+ stub(context.getNamespaceRegistry()).toReturn(registry);
+ service = new RepositoryService(sources, configProjection, context, null);
}
@After
@@ -126,7 +126,7 @@
@Test
public void shouldHaveAnExecutionEnvironmentAfterInstantiation() {
assertThat(service.getExecutionEnvironment(), is(notNullValue()));
- assertThat(service.getExecutionEnvironment(), is(sameInstance(env)));
+ assertThat(service.getExecutionEnvironment(), is(sameInstance(context)));
}
@Test
@@ -137,7 +137,7 @@
@Test
public void
shouldHaveNonNullClassLoaderFactoryAfterInstantiatingWithClassLoaderFactoryReference() {
ClassLoaderFactory classLoaderFactory = mock(ClassLoaderFactory.class);
- service = new RepositoryService(sources, configProjection, env,
classLoaderFactory);
+ service = new RepositoryService(sources, configProjection, context,
classLoaderFactory);
assertThat(service.getClassLoaderFactory(), is(notNullValue()));
assertThat(service.getClassLoaderFactory(),
is(sameInstance(classLoaderFactory)));
}
@@ -184,22 +184,22 @@
sources.addSource(configRepositorySource, true);
assertThat(sources.getSources(),
hasItems((RepositorySource)configRepositorySource));
assertThat(sources.getSources().size(), is(1));
- service = new RepositoryService(sources, configProjection, env, null);
+ service = new RepositoryService(sources, configProjection, context, null);
// Set up the configuration repository to contain 3 sources ...
- configRepository.create(env, "/reposX/dna:sources");
- configRepository.setProperty(env, "/reposX/dna:sources/source A",
CLASSNAME, SimpleRepositorySource.class.getName());
- configRepository.setProperty(env, "/reposX/dna:sources/source A",
CLASSPATH, "");
- configRepository.setProperty(env, "/reposX/dna:sources/source A",
"repositoryName", "sourceReposA");
- configRepository.setProperty(env, "/reposX/dna:sources/source A",
"retryLimit", 3);
+ configRepository.create(context, "/reposX/dna:sources");
+ configRepository.setProperty(context, "/reposX/dna:sources/source A",
CLASSNAME, SimpleRepositorySource.class.getName());
+ configRepository.setProperty(context, "/reposX/dna:sources/source A",
CLASSPATH, "");
+ configRepository.setProperty(context, "/reposX/dna:sources/source A",
"repositoryName", "sourceReposA");
+ configRepository.setProperty(context, "/reposX/dna:sources/source A",
"retryLimit", 3);
- configRepository.setProperty(env, "/reposX/dna:sources/source B",
CLASSNAME, SimpleRepositorySource.class.getName());
- configRepository.setProperty(env, "/reposX/dna:sources/source B",
CLASSPATH, "");
- configRepository.setProperty(env, "/reposX/dna:sources/source B",
"repositoryName", "sourceReposB");
+ configRepository.setProperty(context, "/reposX/dna:sources/source B",
CLASSNAME, SimpleRepositorySource.class.getName());
+ configRepository.setProperty(context, "/reposX/dna:sources/source B",
CLASSPATH, "");
+ configRepository.setProperty(context, "/reposX/dna:sources/source B",
"repositoryName", "sourceReposB");
- configRepository.setProperty(env, "/reposX/dna:sources/source C",
CLASSNAME, SimpleRepositorySource.class.getName());
- configRepository.setProperty(env, "/reposX/dna:sources/source C",
CLASSPATH, "");
- configRepository.setProperty(env, "/reposX/dna:sources/source C",
"repositoryName", "sourceReposC");
+ configRepository.setProperty(context, "/reposX/dna:sources/source C",
CLASSNAME, SimpleRepositorySource.class.getName());
+ configRepository.setProperty(context, "/reposX/dna:sources/source C",
CLASSPATH, "");
+ configRepository.setProperty(context, "/reposX/dna:sources/source C",
"repositoryName", "sourceReposC");
// Now, start up the service ...
service.getAdministrator().start();
@@ -229,7 +229,7 @@
@Test
public void shouldStartUpUsingConfigurationRepositoryThatContainsNoSources() {
// Set up the configuration repository to contain NO sources ...
- configRepository.create(env, "/reposX/dna:sources");
+ configRepository.create(context, "/reposX/dna:sources");
// Now, start up the service ...
service.getAdministrator().start();
@@ -244,19 +244,19 @@
@Test
public void
shouldStartUpAndCreateRepositoryUsingConfigurationRepositoryThatContainsNoSources() {
// Set up the configuration repository ...
- configRepository.create(env, "/reposX/dna:sources");
- configRepository.setProperty(env, "/reposX/dna:sources/source A",
CLASSNAME, SimpleRepositorySource.class.getName());
- configRepository.setProperty(env, "/reposX/dna:sources/source A",
CLASSPATH, "");
- configRepository.setProperty(env, "/reposX/dna:sources/source A",
"repositoryName", "sourceReposA");
- configRepository.setProperty(env, "/reposX/dna:sources/source A",
"retryLimit", 3);
+ configRepository.create(context, "/reposX/dna:sources");
+ configRepository.setProperty(context, "/reposX/dna:sources/source A",
CLASSNAME, SimpleRepositorySource.class.getName());
+ configRepository.setProperty(context, "/reposX/dna:sources/source A",
CLASSPATH, "");
+ configRepository.setProperty(context, "/reposX/dna:sources/source A",
"repositoryName", "sourceReposA");
+ configRepository.setProperty(context, "/reposX/dna:sources/source A",
"retryLimit", 3);
String fedReposPath = "/reposX/dna:repositories/fed repos/";
- configRepository.setProperty(env, fedReposPath, TIME_TO_CACHE,
"10000");
- configRepository.setProperty(env, fedReposPath, TIME_TO_EXPIRE,
"20000");
- configRepository.setProperty(env, fedReposPath + "dna:regions/source
A", PROJECTION_RULES, "/a/b/c => /sx/sy");
- configRepository.setProperty(env, fedReposPath + "dna:regions/source
B", PROJECTION_RULES, "/ => /");
- configRepository.setProperty(env, fedReposPath + "dna:regions/source
C", PROJECTION_RULES, "/d/e/f => /");
- configRepository.setProperty(env, fedReposPath + "dna:regions/source
D", PROJECTION_RULES, "/ => /x/y/z");
+ configRepository.setProperty(context, fedReposPath, TIME_TO_CACHE,
"10000");
+ configRepository.setProperty(context, fedReposPath, TIME_TO_EXPIRE,
"20000");
+ configRepository.setProperty(context, fedReposPath + "dna:regions/source
A", PROJECTION_RULES, "/a/b/c => /sx/sy");
+ configRepository.setProperty(context, fedReposPath + "dna:regions/source
B", PROJECTION_RULES, "/ => /");
+ configRepository.setProperty(context, fedReposPath + "dna:regions/source
C", PROJECTION_RULES, "/d/e/f => /");
+ configRepository.setProperty(context, fedReposPath + "dna:regions/source
D", PROJECTION_RULES, "/ => /x/y/z");
// Now, start up the service ...
service.getAdministrator().start();
Modified:
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/MockSequencerA.java
===================================================================
---
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/MockSequencerA.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/MockSequencerA.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -31,7 +31,7 @@
import org.jboss.dna.common.i18n.MockI18n;
import org.jboss.dna.common.monitor.ProgressMonitor;
import org.jboss.dna.repository.observation.NodeChange;
-import org.jboss.dna.repository.util.ExecutionContext;
+import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.repository.util.RepositoryNodePath;
/**
@@ -63,7 +63,7 @@
/**
* {@inheritDoc}
*/
- public void execute( Node input, String sequencedPropertyName, NodeChange changes,
Set<RepositoryNodePath> outputPaths, ExecutionContext context, ProgressMonitor
progress ) {
+ public void execute( Node input, String sequencedPropertyName, NodeChange changes,
Set<RepositoryNodePath> outputPaths, JcrExecutionContext context, ProgressMonitor
progress ) {
try {
progress.beginTask(1, MockI18n.passthrough, "Incrementing
counter");
// increment the counter and record the progress ...
Modified:
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/MockSequencerB.java
===================================================================
---
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/MockSequencerB.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/MockSequencerB.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -31,7 +31,7 @@
import org.jboss.dna.common.i18n.MockI18n;
import org.jboss.dna.common.monitor.ProgressMonitor;
import org.jboss.dna.repository.observation.NodeChange;
-import org.jboss.dna.repository.util.ExecutionContext;
+import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.repository.util.RepositoryNodePath;
/**
@@ -63,7 +63,7 @@
/**
* {@inheritDoc}
*/
- public void execute( Node input, String sequencedPropertyName, NodeChange changes,
Set<RepositoryNodePath> outputPaths, ExecutionContext context, ProgressMonitor
progress ) {
+ public void execute( Node input, String sequencedPropertyName, NodeChange changes,
Set<RepositoryNodePath> outputPaths, JcrExecutionContext context, ProgressMonitor
progress ) {
try {
progress.beginTask(1, MockI18n.passthrough, "Incrementing
counter");
// increment the counter and record the progress ...
Modified:
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencerNodeContextTest.java
===================================================================
---
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencerNodeContextTest.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencerNodeContextTest.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -30,11 +30,11 @@
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import org.jboss.dna.common.jcr.AbstractJcrRepositoryTest;
-import org.jboss.dna.repository.util.ExecutionContext;
+import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.repository.util.JcrNamespaceRegistry;
import org.jboss.dna.repository.util.JcrTools;
import org.jboss.dna.repository.util.SessionFactory;
-import org.jboss.dna.repository.util.SimpleExecutionContext;
+import org.jboss.dna.repository.util.BasicJcrExecutionContext;
import org.jboss.dna.spi.graph.NameFactory;
import org.jboss.dna.spi.graph.NamespaceRegistry;
import org.jboss.dna.spi.graph.Property;
@@ -50,7 +50,7 @@
*/
public class SequencerNodeContextTest extends AbstractJcrRepositoryTest {
- private ExecutionContext execContext;
+ private JcrExecutionContext execContext;
private Session session;
private JcrTools tools;
@Mock
@@ -70,7 +70,7 @@
}
};
NamespaceRegistry registry = new JcrNamespaceRegistry(sessionFactory,
"doesn't matter");
- execContext = new SimpleExecutionContext(sessionFactory, registry, null, null);
+ execContext = new BasicJcrExecutionContext(sessionFactory, registry, null,
null);
startRepository();
session = getRepository().login(getTestCredentials());
tools = new JcrTools();
Modified:
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencingServiceTest.java
===================================================================
---
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencingServiceTest.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencingServiceTest.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -35,8 +35,8 @@
import org.jboss.dna.common.jcr.AbstractJcrRepositoryTest;
import org.jboss.dna.repository.observation.ObservationService;
import org.jboss.dna.repository.services.ServiceAdministrator;
-import org.jboss.dna.repository.util.ExecutionContext;
-import org.jboss.dna.repository.util.MockExecutionContext;
+import org.jboss.dna.repository.util.JcrExecutionContext;
+import org.jboss.dna.repository.util.MockJcrExecutionContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -52,11 +52,11 @@
private ObservationService observationService;
private SequencingService sequencingService;
- private ExecutionContext executionContext;
+ private JcrExecutionContext executionContext;
@Before
public void beforeEach() {
- this.executionContext = new MockExecutionContext(this,
REPOSITORY_WORKSPACE_NAME);
+ this.executionContext = new MockJcrExecutionContext(this,
REPOSITORY_WORKSPACE_NAME);
this.sequencingService = new SequencingService();
this.sequencingService.setExecutionContext(this.executionContext);
this.observationService = new
ObservationService(this.executionContext.getSessionFactory());
Modified:
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java
===================================================================
---
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -40,12 +40,12 @@
import org.jboss.dna.common.monitor.ProgressMonitor;
import org.jboss.dna.common.monitor.RecordingProgressMonitor;
import org.jboss.dna.repository.observation.NodeChange;
-import org.jboss.dna.repository.util.ExecutionContext;
+import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.repository.util.JcrNamespaceRegistry;
import org.jboss.dna.repository.util.JcrTools;
import org.jboss.dna.repository.util.RepositoryNodePath;
import org.jboss.dna.repository.util.SessionFactory;
-import org.jboss.dna.repository.util.SimpleExecutionContext;
+import org.jboss.dna.repository.util.BasicJcrExecutionContext;
import org.jboss.dna.spi.graph.NamespaceRegistry;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.sequencers.SequencerContext;
@@ -68,7 +68,7 @@
private Session session;
private SequencerOutputMap sequencerOutput;
private String sampleData = "The little brown fox didn't something
bad.";
- private ExecutionContext context;
+ private JcrExecutionContext context;
private RecordingProgressMonitor progressMonitor;
private String repositoryWorkspaceName = "something";
@@ -83,7 +83,7 @@
}
};
NamespaceRegistry registry = new JcrNamespaceRegistry(sessionFactory,
"doesn't matter");
- this.context = new SimpleExecutionContext(sessionFactory, registry, null, null);
+ this.context = new BasicJcrExecutionContext(sessionFactory, registry, null,
null);
this.sequencerOutput = new SequencerOutputMap(this.context.getValueFactories());
this.progressMonitor = new
RecordingProgressMonitor(StreamSequencerAdapterTest.class.getName());
final SequencerOutputMap finalOutput = sequencerOutput;
Deleted:
trunk/dna-repository/src/test/java/org/jboss/dna/repository/util/MockExecutionContext.java
===================================================================
---
trunk/dna-repository/src/test/java/org/jboss/dna/repository/util/MockExecutionContext.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-repository/src/test/java/org/jboss/dna/repository/util/MockExecutionContext.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -1,51 +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.repository.util;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-import java.io.IOException;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import org.jboss.dna.common.SystemFailureException;
-import org.jboss.dna.common.jcr.AbstractJcrRepositoryTest;
-
-/**
- * @author Randall Hauch
- */
-public class MockExecutionContext extends SimpleExecutionContext {
-
- public MockExecutionContext( final AbstractJcrRepositoryTest test, final String
repositoryName ) {
- super(new SessionFactory() {
-
- public Session createSession( String name ) throws RepositoryException {
- assertThat(name, is(repositoryName));
- try {
- return test.getRepository().login(test.getTestCredentials());
- } catch (IOException e) {
- throw new SystemFailureException(e);
- }
- }
- }, repositoryName);
- }
-
-}
Copied:
trunk/dna-repository/src/test/java/org/jboss/dna/repository/util/MockJcrExecutionContext.java
(from rev 368,
trunk/dna-repository/src/test/java/org/jboss/dna/repository/util/MockExecutionContext.java)
===================================================================
---
trunk/dna-repository/src/test/java/org/jboss/dna/repository/util/MockJcrExecutionContext.java
(rev 0)
+++
trunk/dna-repository/src/test/java/org/jboss/dna/repository/util/MockJcrExecutionContext.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -0,0 +1,51 @@
+/*
+ * 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.repository.util;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+import java.io.IOException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import org.jboss.dna.common.SystemFailureException;
+import org.jboss.dna.common.jcr.AbstractJcrRepositoryTest;
+
+/**
+ * @author Randall Hauch
+ */
+public class MockJcrExecutionContext extends BasicJcrExecutionContext {
+
+ public MockJcrExecutionContext( final AbstractJcrRepositoryTest test, final String
repositoryName ) {
+ super(new SessionFactory() {
+
+ public Session createSession( String name ) throws RepositoryException {
+ assertThat(name, is(repositoryName));
+ try {
+ return test.getRepository().login(test.getTestCredentials());
+ } catch (IOException e) {
+ throw new SystemFailureException(e);
+ }
+ }
+ }, repositoryName);
+ }
+
+}
Property changes on:
trunk/dna-repository/src/test/java/org/jboss/dna/repository/util/MockJcrExecutionContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/dna-spi/src/main/java/org/jboss/dna/spi/ExecutionContext.java (from rev 368,
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/ExecutionEnvironment.java)
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/ExecutionContext.java
(rev 0)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/ExecutionContext.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -0,0 +1,63 @@
+/*
+ * 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.spi;
+
+import javax.security.auth.Subject;
+import org.jboss.dna.spi.graph.NamespaceRegistry;
+import org.jboss.dna.spi.graph.Property;
+import org.jboss.dna.spi.graph.PropertyFactory;
+import org.jboss.dna.spi.graph.ValueFactories;
+
+/**
+ * @author Randall Hauch
+ */
+public interface ExecutionContext {
+
+ /**
+ * Get the factories that should be used to create values for {@link Property
properties}.
+ *
+ * @return the property value factory; never null
+ */
+ ValueFactories getValueFactories();
+
+ /**
+ * Get the namespace registry for this context.
+ *
+ * @return the namespace registry; never null
+ */
+ NamespaceRegistry getNamespaceRegistry();
+
+ /**
+ * Get the factory for creating {@link Property} objects.
+ *
+ * @return the property factory; never null
+ */
+ PropertyFactory getPropertyFactory();
+
+ /**
+ * Get the JAAS subject for which this context was created.
+ *
+ * @return the subject; never null
+ */
+ Subject getSubject();
+
+}
Property changes on: trunk/dna-spi/src/main/java/org/jboss/dna/spi/ExecutionContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/ExecutionContextFactory.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/ExecutionContextFactory.java 2008-07-25
19:37:40 UTC (rev 370)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/ExecutionContextFactory.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -26,10 +26,9 @@
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
import javax.security.auth.spi.LoginModule;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
/**
- * A factory for creating {@link ExecutionEnvironment} instances. Each execution
environment is affiliated with a JAAS
+ * A factory for creating {@link ExecutionContext} instances. Each execution context is
affiliated with a JAAS
* {@link Subject}, and thus the factory methods take the same parameters that the JAAS
{@link LoginContext} take.
*
* @author Randall Hauch
@@ -37,13 +36,13 @@
public interface ExecutionContextFactory {
/**
- * Create an {@link ExecutionEnvironment} for the supplied {@link LoginContext}.
+ * Create an {@link ExecutionContext} for the supplied {@link LoginContext}.
*
* @param loginContext the JAAS login context
* @return the execution context
* @throws IllegalArgumentException if the <code>loginContext</code> is
null
*/
- ExecutionEnvironment create( LoginContext loginContext );
+ ExecutionContext create( LoginContext loginContext );
/**
* @param name the name of the JAAS login context
@@ -52,7 +51,7 @@
* @throws LoginException if there <code>name</code> is invalid (or there
is no login context named "other"), or if the
* default callback handler JAAS property was not set or could not be loaded
*/
- ExecutionEnvironment create( String name ) throws LoginException;
+ ExecutionContext create( String name ) throws LoginException;
/**
* @param name the name of the JAAS login context
@@ -62,7 +61,7 @@
* callback handler JAAS property was not set or could not be loaded, or if
the <code>subject</code> is null or
* unknown
*/
- ExecutionEnvironment create( String name,
+ ExecutionContext create( String name,
Subject subject ) throws LoginException;
/**
@@ -72,7 +71,7 @@
* @throws LoginException if there <code>name</code> is invalid (or there
is no login context named "other"), or if the
* <code>callbackHandler</code> is null
*/
- ExecutionEnvironment create( String name,
+ ExecutionContext create( String name,
CallbackHandler callbackHandler ) throws
LoginException;
/**
@@ -84,7 +83,7 @@
* callback handler JAAS property was not set or could not be loaded, if the
<code>subject</code> is null or unknown,
* or if the <code>callbackHandler</code> is null
*/
- ExecutionEnvironment create( String name,
+ ExecutionContext create( String name,
Subject subject,
CallbackHandler callbackHandler ) throws
LoginException;
Copied: trunk/dna-spi/src/main/java/org/jboss/dna/spi/ExecutionContexts.java (from rev
368,
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/ExecutionEnvironments.java)
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/ExecutionContexts.java
(rev 0)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/ExecutionContexts.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -0,0 +1,193 @@
+/*
+ * 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.spi;
+
+import javax.security.auth.Subject;
+import org.jboss.dna.common.util.ArgCheck;
+import org.jboss.dna.spi.graph.NameFactory;
+import org.jboss.dna.spi.graph.NamespaceRegistry;
+import org.jboss.dna.spi.graph.PathFactory;
+import org.jboss.dna.spi.graph.PropertyFactory;
+import org.jboss.dna.spi.graph.ValueFactories;
+import org.jboss.dna.spi.graph.impl.DelegatingValueFactories;
+
+/**
+ * Utility methods for creating various execution contexts with replacement factories or
components.
+ *
+ * @author Randall Hauch
+ */
+public class ExecutionContexts {
+
+ /**
+ * Create an context that can be used to replace the supplied context but that uses
the supplied path factory.
+ *
+ * @param context the base context
+ * @param pathFactory the new path factory
+ * @return the new execution context
+ * @throws IllegalArgumentException if the context or factory references are null
+ */
+ public static ExecutionContext replace( ExecutionContext context,
+ PathFactory pathFactory ) {
+ ArgCheck.isNotNull(context, "context");
+ ArgCheck.isNotNull(pathFactory, "pathFactory");
+ return new DelegatingExecutionEnvironment(context, null, null, null,
pathFactory);
+ }
+
+ /**
+ * Create an context that can be used to replace the supplied context but that uses
the supplied name factory.
+ *
+ * @param context the base context
+ * @param nameFactory the new name factory
+ * @return the new execution context
+ * @throws IllegalArgumentException if the context or factory references are null
+ */
+ public static ExecutionContext replace( ExecutionContext context,
+ NameFactory nameFactory ) {
+ ArgCheck.isNotNull(context, "context");
+ ArgCheck.isNotNull(nameFactory, "nameFactory");
+ return new DelegatingExecutionEnvironment(context, null, null, nameFactory,
null);
+ }
+
+ /**
+ * Create an context that can be used to replace the supplied context but that uses
the supplied name and path factories.
+ *
+ * @param context the base context
+ * @param nameFactory the new name factory
+ * @param pathFactory the new path factory
+ * @return the new execution context
+ * @throws IllegalArgumentException if the context or factory references are null
+ */
+ public static ExecutionContext replace( ExecutionContext context,
+ NameFactory nameFactory,
+ PathFactory pathFactory ) {
+ ArgCheck.isNotNull(context, "context");
+ ArgCheck.isNotNull(nameFactory, "nameFactory");
+ ArgCheck.isNotNull(pathFactory, "pathFactory");
+ return new DelegatingExecutionEnvironment(context, null, null, nameFactory,
pathFactory);
+ }
+
+ /**
+ * Create an context that can be used to replace the supplied context but that uses
the supplied namespace registry.
+ *
+ * @param context the base context
+ * @param namespaceRegistry the new namespace registry
+ * @return the new execution context
+ * @throws IllegalArgumentException if the context or registry references are null
+ */
+ public static ExecutionContext replace( ExecutionContext context,
+ NamespaceRegistry namespaceRegistry ) {
+ ArgCheck.isNotNull(context, "context");
+ ArgCheck.isNotNull(namespaceRegistry, "namespaceRegistry");
+ return new DelegatingExecutionEnvironment(context, namespaceRegistry, null, null,
null);
+ }
+
+ protected static class DelegatingExecutionEnvironment implements ExecutionContext {
+
+ private final ExecutionContext delegate;
+ private final NamespaceRegistry newNamespaceRegistry;
+ private final PropertyFactory newPropertyFactory;
+ private final ValueFactories newValueFactories;
+
+ public DelegatingExecutionEnvironment( ExecutionContext delegate,
+ NamespaceRegistry newRegistry,
+ PropertyFactory newPropertyFactory,
+ ValueFactories newValueFactories ) {
+ assert delegate != null;
+ this.delegate = delegate;
+ this.newNamespaceRegistry = newRegistry;
+ this.newPropertyFactory = newPropertyFactory;
+ this.newValueFactories = newValueFactories;
+ }
+
+ public DelegatingExecutionEnvironment( ExecutionContext delegate,
+ NamespaceRegistry newRegistry,
+ PropertyFactory newPropertyFactory,
+ final NameFactory newNameFactory,
+ final PathFactory newPathFactory ) {
+ assert delegate != null;
+ this.delegate = delegate;
+ this.newNamespaceRegistry = newRegistry;
+ this.newPropertyFactory = newPropertyFactory;
+ final PathFactory pathFactory = newPathFactory != null ? newPathFactory :
delegate.getValueFactories().getPathFactory();
+ final NameFactory nameFactory = newNameFactory != null ? newNameFactory :
delegate.getValueFactories().getNameFactory();
+ this.newValueFactories = newPathFactory == null ? null : new
DelegatingValueFactories(delegate.getValueFactories()) {
+
+ @Override
+ public PathFactory getPathFactory() {
+ return pathFactory;
+ }
+
+ @Override
+ public NameFactory getNameFactory() {
+ return nameFactory;
+ }
+ };
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.ExecutionContext#getNamespaceRegistry()
+ */
+ public NamespaceRegistry getNamespaceRegistry() {
+ if (newNamespaceRegistry != null) return newNamespaceRegistry;
+ return delegate.getNamespaceRegistry();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.ExecutionContext#getPropertyFactory()
+ */
+ public PropertyFactory getPropertyFactory() {
+ if (newPropertyFactory != null) return newPropertyFactory;
+ return delegate.getPropertyFactory();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.ExecutionContext#getValueFactories()
+ */
+ public ValueFactories getValueFactories() {
+ if (newValueFactories != null) return newValueFactories;
+ return delegate.getValueFactories();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.ExecutionContext#getSubject()
+ */
+ public Subject getSubject() {
+ return delegate.getSubject();
+ }
+
+ /**
+ * @return delegate
+ */
+ protected ExecutionContext getDelegate() {
+ return delegate;
+ }
+
+ }
+}
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-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/executor/AbstractCommandExecutor.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -21,6 +21,7 @@
*/
package org.jboss.dna.spi.graph.commands.executor;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.commands.CompositeCommand;
import org.jboss.dna.spi.graph.commands.CopyBranchCommand;
@@ -34,7 +35,6 @@
import org.jboss.dna.spi.graph.commands.MoveBranchCommand;
import org.jboss.dna.spi.graph.commands.RecordBranchCommand;
import org.jboss.dna.spi.graph.commands.SetPropertiesCommand;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
import org.jboss.dna.spi.graph.connection.RepositoryConnection;
import org.jboss.dna.spi.graph.connection.RepositorySourceException;
@@ -47,42 +47,42 @@
* {@link DeleteBranchCommand}), the methods do nothing and should be overridden if the
command is to be processed.
* <p>
* The implementation is also designed to be instantated as needed. This may be once per
call to
- * {@link RepositoryConnection#execute(ExecutionEnvironment, GraphCommand...)}, or may be
once per transaction. Either way, this
- * class is designed to allow subclasses to store additional state that may otherwise be
expensive or undesirable to obtain
- * repeatedly. However, this state should be independent of the commands that are
processed, meaning that implementations should
- * generally not change state as a result of processing specific commands.
+ * {@link RepositoryConnection#execute(ExecutionContext, GraphCommand...)}, or may be
once per transaction. Either way, this class
+ * is designed to allow subclasses to store additional state that may otherwise be
expensive or undesirable to obtain repeatedly.
+ * However, this state should be independent of the commands that are processed, meaning
that implementations should generally not
+ * change state as a result of processing specific commands.
* </p>
*
* @author Randall Hauch
*/
public abstract class AbstractCommandExecutor implements CommandExecutor {
- private final ExecutionEnvironment env;
+ private final ExecutionContext context;
private final String sourceName;
private final DateTime nowInUtc;
- protected AbstractCommandExecutor( ExecutionEnvironment env,
+ protected AbstractCommandExecutor( ExecutionContext context,
String sourceName ) {
- this(env, sourceName, null);
+ this(context, sourceName, null);
}
- protected AbstractCommandExecutor( ExecutionEnvironment env,
+ protected AbstractCommandExecutor( ExecutionContext context,
String sourceName,
DateTime now ) {
- assert env != null;
+ assert context != null;
assert sourceName != null && sourceName.trim().length() != 0;
- this.env = env;
+ this.context = context;
this.sourceName = sourceName;
- this.nowInUtc = now != null ? now.toUtcTimeZone() :
env.getValueFactories().getDateFactory().createUtc();
+ this.nowInUtc = now != null ? now.toUtcTimeZone() :
context.getValueFactories().getDateFactory().createUtc();
}
/**
* Get the environment in which these commands are being executed.
*
- * @return the execution environment; never null
+ * @return the execution context; never null
*/
- public ExecutionEnvironment getEnvironment() {
- return env;
+ public ExecutionContext getEnvironment() {
+ return context;
}
/**
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/executor/NoOpCommandExecutor.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/executor/NoOpCommandExecutor.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/executor/NoOpCommandExecutor.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -21,6 +21,7 @@
*/
package org.jboss.dna.spi.graph.commands.executor;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.commands.CompositeCommand;
import org.jboss.dna.spi.graph.commands.CopyBranchCommand;
@@ -34,7 +35,6 @@
import org.jboss.dna.spi.graph.commands.MoveBranchCommand;
import org.jboss.dna.spi.graph.commands.RecordBranchCommand;
import org.jboss.dna.spi.graph.commands.SetPropertiesCommand;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
import org.jboss.dna.spi.graph.connection.RepositorySource;
import org.jboss.dna.spi.graph.connection.RepositorySourceException;
@@ -46,25 +46,25 @@
/**
* Create a command executor that does nothing.
*
- * @param env the execution environment in which the executor will be run; may not be
null
+ * @param context the execution context in which the executor will be run; may not be
null
* @param sourceName the name of the {@link RepositorySource} that is making use of
this executor; may not be null or empty
*/
- public NoOpCommandExecutor( ExecutionEnvironment env,
+ public NoOpCommandExecutor( ExecutionContext context,
String sourceName ) {
- super(env, sourceName);
+ super(context, sourceName);
}
/**
* Create a command executor that does nothing.
*
- * @param env the execution environment in which the executor will be run; may not be
null
+ * @param context the execution context in which the executor will be run; may not be
null
* @param sourceName the name of the {@link RepositorySource} that is making use of
this executor; may not be null or empty
* @param now the current time; may be null if the system time is to be used
*/
- public NoOpCommandExecutor( ExecutionEnvironment env,
+ public NoOpCommandExecutor( ExecutionContext context,
String sourceName,
DateTime now ) {
- super(env, sourceName, now);
+ super(context, sourceName, now);
}
/**
Copied:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/BasicExecutionContext.java
(from rev 368,
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/BasicExecutionEnvironment.java)
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/BasicExecutionContext.java
(rev 0)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/BasicExecutionContext.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -0,0 +1,108 @@
+/*
+ * 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.spi.graph.connection;
+
+import javax.security.auth.Subject;
+import org.jboss.dna.common.util.ArgCheck;
+import org.jboss.dna.spi.ExecutionContext;
+import org.jboss.dna.spi.graph.NamespaceRegistry;
+import org.jboss.dna.spi.graph.PropertyFactory;
+import org.jboss.dna.spi.graph.ValueFactories;
+import org.jboss.dna.spi.graph.impl.BasicNamespaceRegistry;
+import org.jboss.dna.spi.graph.impl.BasicPropertyFactory;
+import org.jboss.dna.spi.graph.impl.StandardValueFactories;
+
+/**
+ * @author Randall Hauch
+ */
+public class BasicExecutionContext implements ExecutionContext {
+
+ private final Subject subject;
+ private final PropertyFactory propertyFactory;
+ private final ValueFactories valueFactories;
+ private final NamespaceRegistry namespaceRegistry;
+
+ public BasicExecutionContext() {
+ this(new Subject(), new BasicNamespaceRegistry());
+ }
+
+ public BasicExecutionContext( NamespaceRegistry namespaceRegistry ) {
+ this(new Subject(), namespaceRegistry, null, null);
+ }
+
+ public BasicExecutionContext( NamespaceRegistry namespaceRegistry,
+ ValueFactories valueFactories,
+ PropertyFactory propertyFactory ) {
+ this(new Subject(), namespaceRegistry, valueFactories, propertyFactory);
+ }
+
+ public BasicExecutionContext( Subject subject ) {
+ this(subject, new BasicNamespaceRegistry());
+ }
+
+ public BasicExecutionContext( Subject subject,
+ NamespaceRegistry namespaceRegistry ) {
+ this(subject, namespaceRegistry, null, null);
+ }
+
+ public BasicExecutionContext( Subject subject,
+ NamespaceRegistry namespaceRegistry,
+ ValueFactories valueFactories,
+ PropertyFactory propertyFactory ) {
+ ArgCheck.isNotNull(subject, "subject");
+ ArgCheck.isNotNull(namespaceRegistry, "namespace registry");
+ this.subject = subject;
+ this.namespaceRegistry = namespaceRegistry;
+ this.valueFactories = valueFactories != null ? valueFactories : new
StandardValueFactories(this.namespaceRegistry);
+ this.propertyFactory = propertyFactory != null ? propertyFactory : new
BasicPropertyFactory(this.valueFactories);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public NamespaceRegistry getNamespaceRegistry() {
+ return this.namespaceRegistry;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ValueFactories getValueFactories() {
+ return this.valueFactories;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public PropertyFactory getPropertyFactory() {
+ return this.propertyFactory;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.ExecutionContext#getSubject()
+ */
+ public Subject getSubject() {
+ return this.subject;
+ }
+}
Deleted:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/BasicExecutionEnvironment.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/BasicExecutionEnvironment.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/BasicExecutionEnvironment.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -1,78 +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.spi.graph.connection;
-
-import org.jboss.dna.common.util.ArgCheck;
-import org.jboss.dna.spi.graph.NamespaceRegistry;
-import org.jboss.dna.spi.graph.PropertyFactory;
-import org.jboss.dna.spi.graph.ValueFactories;
-import org.jboss.dna.spi.graph.impl.BasicNamespaceRegistry;
-import org.jboss.dna.spi.graph.impl.BasicPropertyFactory;
-import org.jboss.dna.spi.graph.impl.StandardValueFactories;
-
-/**
- * @author Randall Hauch
- */
-public class BasicExecutionEnvironment implements ExecutionEnvironment {
-
- private final PropertyFactory propertyFactory;
- private final ValueFactories valueFactories;
- private final NamespaceRegistry namespaceRegistry;
-
- public BasicExecutionEnvironment() {
- this(new BasicNamespaceRegistry());
- }
-
- public BasicExecutionEnvironment( NamespaceRegistry namespaceRegistry ) {
- this(namespaceRegistry, null, null);
- }
-
- public BasicExecutionEnvironment( NamespaceRegistry namespaceRegistry,
- ValueFactories valueFactories,
- PropertyFactory propertyFactory ) {
- ArgCheck.isNotNull(namespaceRegistry, "namespace registry");
- this.namespaceRegistry = namespaceRegistry;
- this.valueFactories = valueFactories != null ? valueFactories : new
StandardValueFactories(this.namespaceRegistry);
- this.propertyFactory = propertyFactory != null ? propertyFactory : new
BasicPropertyFactory(this.valueFactories);
- }
-
- /**
- * {@inheritDoc}
- */
- public NamespaceRegistry getNamespaceRegistry() {
- return this.namespaceRegistry;
- }
-
- /**
- * {@inheritDoc}
- */
- public ValueFactories getValueFactories() {
- return this.valueFactories;
- }
-
- /**
- * {@inheritDoc}
- */
- public PropertyFactory getPropertyFactory() {
- return this.propertyFactory;
- }
-}
Deleted:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/ExecutionEnvironment.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/ExecutionEnvironment.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/ExecutionEnvironment.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -1,55 +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.spi.graph.connection;
-
-import org.jboss.dna.spi.graph.NamespaceRegistry;
-import org.jboss.dna.spi.graph.Property;
-import org.jboss.dna.spi.graph.PropertyFactory;
-import org.jboss.dna.spi.graph.ValueFactories;
-
-/**
- * @author Randall Hauch
- */
-public interface ExecutionEnvironment {
-
- /**
- * Get the factories that should be used to create values for {@link Property
properties}.
- *
- * @return the property value factory; never null
- */
- ValueFactories getValueFactories();
-
- /**
- * Get the namespace registry for this environment.
- *
- * @return the namespace registry; never null
- */
- NamespaceRegistry getNamespaceRegistry();
-
- /**
- * Get the factory for creating {@link Property} objects.
- *
- * @return the property factory; never null
- */
- PropertyFactory getPropertyFactory();
-
-}
Deleted:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/ExecutionEnvironments.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/ExecutionEnvironments.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/ExecutionEnvironments.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -1,184 +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.spi.graph.connection;
-
-import org.jboss.dna.common.util.ArgCheck;
-import org.jboss.dna.spi.graph.NameFactory;
-import org.jboss.dna.spi.graph.NamespaceRegistry;
-import org.jboss.dna.spi.graph.PathFactory;
-import org.jboss.dna.spi.graph.PropertyFactory;
-import org.jboss.dna.spi.graph.ValueFactories;
-import org.jboss.dna.spi.graph.impl.DelegatingValueFactories;
-
-/**
- * Utility methods for creating various execution environments with replacement factories
or components.
- *
- * @author Randall Hauch
- */
-public class ExecutionEnvironments {
-
- /**
- * Create an environment that can be used to replace the supplied environment but
that uses the supplied path factory.
- *
- * @param env the base environment
- * @param pathFactory the new path factory
- * @return the new execution environment
- * @throws IllegalArgumentException if the environment or factory references are
null
- */
- public static ExecutionEnvironment replace( ExecutionEnvironment env,
- PathFactory pathFactory ) {
- ArgCheck.isNotNull(env, "env");
- ArgCheck.isNotNull(pathFactory, "pathFactory");
- return new DelegatingExecutionEnvironment(env, null, null, null, pathFactory);
- }
-
- /**
- * Create an environment that can be used to replace the supplied environment but
that uses the supplied name factory.
- *
- * @param env the base environment
- * @param nameFactory the new name factory
- * @return the new execution environment
- * @throws IllegalArgumentException if the environment or factory references are
null
- */
- public static ExecutionEnvironment replace( ExecutionEnvironment env,
- NameFactory nameFactory ) {
- ArgCheck.isNotNull(env, "env");
- ArgCheck.isNotNull(nameFactory, "nameFactory");
- return new DelegatingExecutionEnvironment(env, null, null, nameFactory, null);
- }
-
- /**
- * Create an environment that can be used to replace the supplied environment but
that uses the supplied name and path
- * factories.
- *
- * @param env the base environment
- * @param nameFactory the new name factory
- * @param pathFactory the new path factory
- * @return the new execution environment
- * @throws IllegalArgumentException if the environment or factory references are
null
- */
- public static ExecutionEnvironment replace( ExecutionEnvironment env,
- NameFactory nameFactory,
- PathFactory pathFactory ) {
- ArgCheck.isNotNull(env, "env");
- ArgCheck.isNotNull(nameFactory, "nameFactory");
- ArgCheck.isNotNull(pathFactory, "pathFactory");
- return new DelegatingExecutionEnvironment(env, null, null, nameFactory,
pathFactory);
- }
-
- /**
- * Create an environment that can be used to replace the supplied environment but
that uses the supplied namespace registry.
- *
- * @param env the base environment
- * @param namespaceRegistry the new namespace registry
- * @return the new execution environment
- * @throws IllegalArgumentException if the environment or registry references are
null
- */
- public static ExecutionEnvironment replace( ExecutionEnvironment env,
- NamespaceRegistry namespaceRegistry ) {
- ArgCheck.isNotNull(env, "env");
- ArgCheck.isNotNull(namespaceRegistry, "namespaceRegistry");
- return new DelegatingExecutionEnvironment(env, namespaceRegistry, null, null,
null);
- }
-
- protected static class DelegatingExecutionEnvironment implements ExecutionEnvironment
{
-
- private final ExecutionEnvironment delegate;
- private final NamespaceRegistry newNamespaceRegistry;
- private final PropertyFactory newPropertyFactory;
- private final ValueFactories newValueFactories;
-
- public DelegatingExecutionEnvironment( ExecutionEnvironment delegate,
- NamespaceRegistry newRegistry,
- PropertyFactory newPropertyFactory,
- ValueFactories newValueFactories ) {
- assert delegate != null;
- this.delegate = delegate;
- this.newNamespaceRegistry = newRegistry;
- this.newPropertyFactory = newPropertyFactory;
- this.newValueFactories = newValueFactories;
- }
-
- public DelegatingExecutionEnvironment( ExecutionEnvironment delegate,
- NamespaceRegistry newRegistry,
- PropertyFactory newPropertyFactory,
- final NameFactory newNameFactory,
- final PathFactory newPathFactory ) {
- assert delegate != null;
- this.delegate = delegate;
- this.newNamespaceRegistry = newRegistry;
- this.newPropertyFactory = newPropertyFactory;
- final PathFactory pathFactory = newPathFactory != null ? newPathFactory :
delegate.getValueFactories().getPathFactory();
- final NameFactory nameFactory = newNameFactory != null ? newNameFactory :
delegate.getValueFactories().getNameFactory();
- this.newValueFactories = newPathFactory == null ? null : new
DelegatingValueFactories(delegate.getValueFactories()) {
-
- @Override
- public PathFactory getPathFactory() {
- return pathFactory;
- }
-
- @Override
- public NameFactory getNameFactory() {
- return nameFactory;
- }
- };
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.dna.spi.graph.connection.ExecutionEnvironment#getNamespaceRegistry()
- */
- public NamespaceRegistry getNamespaceRegistry() {
- if (newNamespaceRegistry != null) return newNamespaceRegistry;
- return delegate.getNamespaceRegistry();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.dna.spi.graph.connection.ExecutionEnvironment#getPropertyFactory()
- */
- public PropertyFactory getPropertyFactory() {
- if (newPropertyFactory != null) return newPropertyFactory;
- return delegate.getPropertyFactory();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.dna.spi.graph.connection.ExecutionEnvironment#getValueFactories()
- */
- public ValueFactories getValueFactories() {
- if (newValueFactories != null) return newValueFactories;
- return delegate.getValueFactories();
- }
-
- /**
- * @return delegate
- */
- protected ExecutionEnvironment getDelegate() {
- return delegate;
- }
-
- }
-}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryConnection.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryConnection.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryConnection.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -23,6 +23,7 @@
import java.util.concurrent.TimeUnit;
import javax.transaction.xa.XAResource;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.cache.CachePolicy;
import org.jboss.dna.spi.graph.commands.GraphCommand;
@@ -61,7 +62,8 @@
* @return true if this connection is still valid and can still be used, or false
otherwise
* @throws InterruptedException if the thread has been interrupted during the
operation
*/
- boolean ping( long time, TimeUnit unit ) throws InterruptedException;
+ boolean ping( long time,
+ TimeUnit unit ) throws InterruptedException;
/**
* Set the listener that is to receive notifications to changes to content within
this source.
@@ -80,12 +82,13 @@
/**
* Execute the supplied commands against this repository source.
*
- * @param env the environment in which the commands are being executed; never null
+ * @param context the environment in which the commands are being executed; never
null
* @param commands the commands to be executed; never null
* @throws RepositorySourceException if there is a problem loading the node data
* @throws InterruptedException if the thread has been interrupted during the
operation
*/
- void execute( ExecutionEnvironment env, GraphCommand... commands ) throws
RepositorySourceException, InterruptedException;
+ void execute( ExecutionContext context,
+ GraphCommand... commands ) throws RepositorySourceException,
InterruptedException;
/**
* Close this connection to signal that it is no longer needed and that any
accumulated resources are to be released.
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryConnectionPool.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryConnectionPool.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryConnectionPool.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -38,6 +38,7 @@
import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.common.util.ArgCheck;
import org.jboss.dna.common.util.Logger;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.SpiI18n;
import org.jboss.dna.spi.cache.CachePolicy;
import org.jboss.dna.spi.graph.commands.GraphCommand;
@@ -182,10 +183,10 @@
* @throws IllegalArgumentException if the connection factory is null or any of the
supplied arguments are invalid
*/
public RepositoryConnectionPool( RepositoryConnectionFactory connectionFactory,
- int corePoolSize,
- int maximumPoolSize,
- long keepAliveTime,
- TimeUnit unit ) {
+ int corePoolSize,
+ int maximumPoolSize,
+ long keepAliveTime,
+ TimeUnit unit ) {
ArgCheck.isNonNegative(corePoolSize, "corePoolSize");
ArgCheck.isPositive(maximumPoolSize, "maximumPoolSize");
ArgCheck.isNonNegative(keepAliveTime, "keepAliveTime");
@@ -596,7 +597,8 @@
/**
* {@inheritDoc}
*
- * @see
org.jboss.dna.spi.graph.connection.ManagedRepositoryConnectionFactory#awaitTermination(long,
java.util.concurrent.TimeUnit)
+ * @see
org.jboss.dna.spi.graph.connection.ManagedRepositoryConnectionFactory#awaitTermination(long,
+ * java.util.concurrent.TimeUnit)
*/
public boolean awaitTermination( long timeout,
TimeUnit unit ) throws InterruptedException {
@@ -928,10 +930,10 @@
/**
* {@inheritDoc}
*/
- public void execute( ExecutionEnvironment env,
+ public void execute( ExecutionContext context,
GraphCommand... commands ) throws RepositorySourceException,
InterruptedException {
if (closed) throw new
IllegalStateException(SpiI18n.closedConnectionMayNotBeUsed.text());
- this.original.execute(env, commands);
+ this.original.execute(context, commands);
}
/**
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryOperation.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryOperation.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryOperation.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -21,6 +21,8 @@
*/
package org.jboss.dna.spi.graph.connection;
+import org.jboss.dna.spi.ExecutionContext;
+
/**
* An operation that runs against a repository connection.
*
@@ -39,13 +41,13 @@
/**
* Run the operation using the supplied connection.
*
- * @param env the environment in which this operation is executing; may not be null
+ * @param context the environment in which this operation is executing; may not be
null
* @param connection the connection; may not be null
* @return the result of the operation
* @throws RepositorySourceException if there is a problem with the connection
* @throws InterruptedException if this thread was interrupted
*/
- T run( ExecutionEnvironment env,
+ T run( ExecutionContext context,
RepositoryConnection connection ) throws RepositorySourceException,
InterruptedException;
/**
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryOperations.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryOperations.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryOperations.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -27,6 +27,7 @@
import java.util.concurrent.Callable;
import org.jboss.dna.common.util.ArgCheck;
import org.jboss.dna.common.util.LogContext;
+import org.jboss.dna.spi.ExecutionContext;
/**
* @author Randall Hauch
@@ -37,18 +38,18 @@
* Call the supplied operation, using a connection from this pool.
*
* @param <T> the return type for the operation
- * @param env the environment in which the operation is to execute; may not be null
+ * @param context the context in which the operation is to execute; may not be null
* @param connectionFactory the factory for the connection to use
* @param operation the operation to be run using a new connection obtained from the
factory
* @return the results from the operation
* @throws RepositorySourceException if there was an error obtaining the new
connection
* @throws InterruptedException if the thread was interrupted during the operation
* @throws IllegalArgumentException if the operation is null
- * @see #createCallable(ExecutionEnvironment, RepositoryConnectionFactory,
RepositoryOperation)
- * @see #createCallables(ExecutionEnvironment, RepositoryConnectionFactory,
Iterable)
- * @see #createCallables(ExecutionEnvironment, RepositoryConnectionFactory,
RepositoryOperation...)
+ * @see #createCallable(ExecutionContext, RepositoryConnectionFactory,
RepositoryOperation)
+ * @see #createCallables(ExecutionContext, RepositoryConnectionFactory, Iterable)
+ * @see #createCallables(ExecutionContext, RepositoryConnectionFactory,
RepositoryOperation...)
*/
- public static <T> T call( ExecutionEnvironment env,
+ public static <T> T call( ExecutionContext context,
RepositoryConnectionFactory connectionFactory,
RepositoryOperation<T> operation ) throws
RepositorySourceException, InterruptedException {
ArgCheck.isNotNull(operation, "repository operation");
@@ -58,7 +59,7 @@
RepositoryConnection conn = connectionFactory.getConnection();
try {
// And run the client with the connection ...
- result = operation.run(env, conn);
+ result = operation.run(context, conn);
} finally {
conn.close();
}
@@ -71,15 +72,15 @@
* supplied factory.
*
* @param <T> the return type for the operation
- * @param env the environment in which the operation is to execute; may not be null
+ * @param context the context in which the operation is to execute; may not be null
* @param connectionFactory the factory for the connection to use
* @param operation the operation to be run using a new connection obtained from the
factory
* @return the callable
- * @see #call(ExecutionEnvironment, RepositoryConnectionFactory,
RepositoryOperation)
- * @see #createCallables(ExecutionEnvironment, RepositoryConnectionFactory,
Iterable)
- * @see #createCallables(ExecutionEnvironment, RepositoryConnectionFactory,
RepositoryOperation...)
+ * @see #call(ExecutionContext, RepositoryConnectionFactory, RepositoryOperation)
+ * @see #createCallables(ExecutionContext, RepositoryConnectionFactory, Iterable)
+ * @see #createCallables(ExecutionContext, RepositoryConnectionFactory,
RepositoryOperation...)
*/
- public static <T> Callable<T> createCallable( final ExecutionEnvironment
env,
+ public static <T> Callable<T> createCallable( final ExecutionContext
context,
final RepositoryConnectionFactory
connectionFactory,
final RepositoryOperation<T>
operation ) {
ArgCheck.isNotNull(operation, "repository operation");
@@ -92,7 +93,7 @@
* @throws Exception
*/
public T call() throws Exception {
- return RepositoryOperations.call(env, connectionFactory, operation);
+ return RepositoryOperations.call(context, connectionFactory, operation);
}
};
}
@@ -102,20 +103,20 @@
* this pool.
*
* @param <T> the return type for the operations
- * @param env the environment in which the operation is to execute; may not be null
+ * @param context the context in which the operation is to execute; may not be null
* @param connectionFactory the factory for the connection to use
* @param operations the operations to be run using connections from the factory
* @return the collection of callables
- * @see #call(ExecutionEnvironment, RepositoryConnectionFactory,
RepositoryOperation)
- * @see #createCallable(ExecutionEnvironment, RepositoryConnectionFactory,
RepositoryOperation)
- * @see #createCallables(ExecutionEnvironment, RepositoryConnectionFactory,
Iterable)
+ * @see #call(ExecutionContext, RepositoryConnectionFactory, RepositoryOperation)
+ * @see #createCallable(ExecutionContext, RepositoryConnectionFactory,
RepositoryOperation)
+ * @see #createCallables(ExecutionContext, RepositoryConnectionFactory, Iterable)
*/
- public static <T> List<Callable<T>> createCallables( final
ExecutionEnvironment env,
+ public static <T> List<Callable<T>> createCallables( final
ExecutionContext context,
final
RepositoryConnectionFactory connectionFactory,
final
RepositoryOperation<T>... operations ) {
List<Callable<T>> callables = new
ArrayList<Callable<T>>();
for (final RepositoryOperation<T> operation : operations) {
- callables.add(createCallable(env, connectionFactory, operation));
+ callables.add(createCallable(context, connectionFactory, operation));
}
return callables;
}
@@ -125,20 +126,20 @@
* this pool.
*
* @param <T> the return type for the operations
- * @param env the environment in which the operation is to execute; may not be null
+ * @param context the context in which the operation is to execute; may not be null
* @param connectionFactory the factory for the connection to use
* @param operations the operations to be run using connections from the factory
* @return the collection of callables
- * @see #call(ExecutionEnvironment, RepositoryConnectionFactory,
RepositoryOperation)
- * @see #createCallable(ExecutionEnvironment, RepositoryConnectionFactory,
RepositoryOperation)
- * @see #createCallables(ExecutionEnvironment, RepositoryConnectionFactory,
RepositoryOperation...)
+ * @see #call(ExecutionContext, RepositoryConnectionFactory, RepositoryOperation)
+ * @see #createCallable(ExecutionContext, RepositoryConnectionFactory,
RepositoryOperation)
+ * @see #createCallables(ExecutionContext, RepositoryConnectionFactory,
RepositoryOperation...)
*/
- public static <T> List<Callable<T>> createCallables( final
ExecutionEnvironment env,
+ public static <T> List<Callable<T>> createCallables( final
ExecutionContext context,
final
RepositoryConnectionFactory connectionFactory,
Iterable<RepositoryOperation<T>> operations ) {
List<Callable<T>> callables = new
ArrayList<Callable<T>>();
for (final RepositoryOperation<T> operation : operations) {
- callables.add(createCallable(env, connectionFactory, operation));
+ callables.add(createCallable(context, connectionFactory, operation));
}
return callables;
}
@@ -148,21 +149,21 @@
* this pool.
*
* @param <T> the return type for the operations
- * @param env the environment in which the operation is to execute; may not be null
+ * @param context the context in which the operation is to execute; may not be null
* @param connectionFactory the factory for the connection to use
* @param operations the operations to be run using connections from the factory
* @return the collection of callables
- * @see #call(ExecutionEnvironment, RepositoryConnectionFactory,
RepositoryOperation)
- * @see #createCallable(ExecutionEnvironment, RepositoryConnectionFactory,
RepositoryOperation)
- * @see #createCallables(ExecutionEnvironment, RepositoryConnectionFactory,
RepositoryOperation...)
+ * @see #call(ExecutionContext, RepositoryConnectionFactory, RepositoryOperation)
+ * @see #createCallable(ExecutionContext, RepositoryConnectionFactory,
RepositoryOperation)
+ * @see #createCallables(ExecutionContext, RepositoryConnectionFactory,
RepositoryOperation...)
*/
- public static <T> List<Callable<T>> createCallables( final
ExecutionEnvironment env,
+ public static <T> List<Callable<T>> createCallables( final
ExecutionContext context,
final
RepositoryConnectionFactory connectionFactory,
Iterator<RepositoryOperation<T>> operations ) {
List<Callable<T>> callables = new
ArrayList<Callable<T>>();
while (operations.hasNext()) {
final RepositoryOperation<T> operation = operations.next();
- callables.add(createCallable(env, connectionFactory, operation));
+ callables.add(createCallable(context, connectionFactory, operation));
}
return callables;
}
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-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/commands/executor/AbstractCommandExecutorTest.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -32,6 +32,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.graph.commands.CompositeCommand;
import org.jboss.dna.spi.graph.commands.CopyBranchCommand;
import org.jboss.dna.spi.graph.commands.CopyNodeCommand;
@@ -44,8 +45,7 @@
import org.jboss.dna.spi.graph.commands.MoveBranchCommand;
import org.jboss.dna.spi.graph.commands.RecordBranchCommand;
import org.jboss.dna.spi.graph.commands.SetPropertiesCommand;
-import org.jboss.dna.spi.graph.connection.BasicExecutionEnvironment;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
+import org.jboss.dna.spi.graph.connection.BasicExecutionContext;
import org.jboss.dna.spi.graph.connection.RepositorySourceException;
import org.junit.Before;
import org.junit.Test;
@@ -62,20 +62,20 @@
private AbstractCommandExecutor executor;
private GraphCommand command;
- private ExecutionEnvironment env;
+ private ExecutionContext context;
@Mock
protected CommandExecutor validator;
@Before
public void beforeEach() throws Exception {
MockitoAnnotations.initMocks(this);
- env = new BasicExecutionEnvironment();
- executor = new ExecutorImpl(env, "Source X", validator);
+ context = new BasicExecutionContext();
+ executor = new ExecutorImpl(context, "Source X", validator);
}
@Test
public void shouldHaveEnvironment() {
- assertThat(executor.getEnvironment(), is(sameInstance(env)));
+ assertThat(executor.getEnvironment(), is(sameInstance(context)));
}
@Test
@@ -214,10 +214,10 @@
private final CommandExecutor validator;
- protected ExecutorImpl( ExecutionEnvironment env,
+ protected ExecutorImpl( ExecutionContext context,
String name,
CommandExecutor validator ) {
- super(env, name);
+ super(context, name);
this.validator = validator;
}
Modified:
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositoryConnectionPoolTest.java
===================================================================
---
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositoryConnectionPoolTest.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositoryConnectionPoolTest.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -28,6 +28,7 @@
import java.util.List;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
+import org.jboss.dna.spi.ExecutionContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
@@ -40,13 +41,13 @@
private RepositoryConnectionPool pool;
private TimeDelayingRepositorySource repositorySource;
- private ExecutionEnvironment env;
+ private ExecutionContext context;
@Before
public void beforeEach() {
this.repositorySource = new TimeDelayingRepositorySource("source 1");
this.pool = new RepositoryConnectionPool(this.repositorySource, 1, 1, 100,
TimeUnit.SECONDS);
- this.env = null;
+ this.context = null;
}
@After
@@ -164,7 +165,7 @@
pool.setCorePoolSize(numConnectionsInPool);
pool.setMaximumPoolSize(numConnectionsInPool);
RepositoryOperation.Factory<Integer> operationFactory =
RepositorySourceLoadHarness.createMultipleLoadOperationFactory(10);
- runLoadTest(env, pool, numClients, 100, TimeUnit.MILLISECONDS,
operationFactory);
+ runLoadTest(context, pool, numClients, 100, TimeUnit.MILLISECONDS,
operationFactory);
pool.shutdown();
pool.awaitTermination(4, TimeUnit.SECONDS);
}
@@ -177,7 +178,7 @@
pool.setCorePoolSize(numConnectionsInPool);
pool.setMaximumPoolSize(numConnectionsInPool);
RepositoryOperation.Factory<Integer> operationFactory =
RepositorySourceLoadHarness.createMultipleLoadOperationFactory(10);
- runLoadTest(env, pool, numClients, 100, TimeUnit.MILLISECONDS,
operationFactory);
+ runLoadTest(context, pool, numClients, 100, TimeUnit.MILLISECONDS,
operationFactory);
pool.shutdown();
pool.awaitTermination(4, TimeUnit.SECONDS);
}
@@ -190,7 +191,7 @@
pool.setCorePoolSize(numConnectionsInPool);
pool.setMaximumPoolSize(numConnectionsInPool);
RepositoryOperation.Factory<Integer> operationFactory =
RepositorySourceLoadHarness.createMultipleLoadOperationFactory(10);
- runLoadTest(env, pool, numClients, 100, TimeUnit.MILLISECONDS,
operationFactory);
+ runLoadTest(context, pool, numClients, 100, TimeUnit.MILLISECONDS,
operationFactory);
pool.shutdown();
pool.awaitTermination(4, TimeUnit.SECONDS);
}
@@ -204,7 +205,7 @@
pool.setCorePoolSize(numConnectionsInPool);
pool.setMaximumPoolSize(numConnectionsInPool);
RepositoryOperation.Factory<Integer> operationFactory =
RepositorySourceLoadHarness.createMultipleLoadOperationFactory(20);
- List<Future<Integer>> results = runLoadTest(env, pool, numClients,
200, TimeUnit.MILLISECONDS, operationFactory);
+ List<Future<Integer>> results = runLoadTest(context, pool,
numClients, 200, TimeUnit.MILLISECONDS, operationFactory);
int total = 0;
for (Future<Integer> result : results) {
assertThat(result.isDone(), is(true));
Modified:
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositorySourceLoadHarness.java
===================================================================
---
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositorySourceLoadHarness.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositorySourceLoadHarness.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -33,6 +33,7 @@
import java.util.concurrent.TimeUnit;
import org.jboss.dna.common.i18n.MockI18n;
import org.jboss.dna.common.util.Logger;
+import org.jboss.dna.spi.ExecutionContext;
/**
* A test harness for using repository connections under load.
@@ -42,17 +43,22 @@
public class RepositorySourceLoadHarness {
public static Future<Integer> execute( RepositoryConnectionFactory
connectionFactory,
- ExecutionEnvironment env,
+ ExecutionContext context,
long maxTime,
TimeUnit maxTimeUnit ) throws
InterruptedException {
int numTimes = 1;
int numClients = 1;
RepositoryOperation.Factory<Integer> operationFactory =
RepositorySourceLoadHarness.createMultipleLoadOperationFactory(numTimes);
- List<Future<Integer>> results = runLoadTest(env, connectionFactory,
numClients, maxTime, maxTimeUnit, operationFactory);
+ List<Future<Integer>> results = runLoadTest(context,
+ connectionFactory,
+ numClients,
+ maxTime,
+ maxTimeUnit,
+ operationFactory);
return results.get(0);
}
- public static <T> List<Future<T>> runLoadTest( ExecutionEnvironment
env,
+ public static <T> List<Future<T>> runLoadTest( ExecutionContext
context,
RepositoryConnectionFactory
connectionFactory,
int numClients,
long maxTime,
@@ -65,10 +71,10 @@
}
// and run the test ...
- return runLoadTest(env, connectionFactory, maxTime, maxTimeUnit, clients);
+ return runLoadTest(context, connectionFactory, maxTime, maxTimeUnit, clients);
}
- public static <T> List<Future<T>> runLoadTest( ExecutionEnvironment
env,
+ public static <T> List<Future<T>> runLoadTest( ExecutionContext
context,
RepositoryConnectionFactory
connectionFactory,
long maxTime,
TimeUnit maxTimeUnit,
@@ -79,10 +85,10 @@
if (client != null) clientCollection.add(client);
}
// and run the test ...
- return runLoadTest(env, connectionFactory, maxTime, maxTimeUnit,
clientCollection);
+ return runLoadTest(context, connectionFactory, maxTime, maxTimeUnit,
clientCollection);
}
- public static <T> List<Future<T>> runLoadTest( ExecutionEnvironment
env,
+ public static <T> List<Future<T>> runLoadTest( ExecutionContext
context,
RepositoryConnectionFactory
connectionFactory,
long maxTime,
TimeUnit maxTimeUnit,
@@ -102,7 +108,7 @@
try {
// Wrap each client by a callable and by another that uses a latch ...
- List<Callable<T>> callables =
RepositoryOperations.createCallables(env, connectionFactory, clients);
+ List<Callable<T>> callables =
RepositoryOperations.createCallables(context, connectionFactory, clients);
// Run the tests ...
List<Future<T>> futures = clientPool.invokeAll(callables,
maxTime, maxTimeUnit);
@@ -164,7 +170,7 @@
/**
* Return an operation factory that produces {@link RepositoryOperation} instances
that each call
- * {@link RepositoryConnection#execute(ExecutionEnvironment,
org.jboss.dna.spi.graph.commands.GraphCommand...)} the supplied
+ * {@link RepositoryConnection#execute(ExecutionContext,
org.jboss.dna.spi.graph.commands.GraphCommand...)} the supplied
* number of times, intermixed with random math operations and {@link Thread#yield()
yielding}.
*
* @param callsPerOperation the number of <code>load</code> calls per
RepositoryOperation
@@ -198,10 +204,10 @@
/**
* {@inheritDoc}
*
- * @see
org.jboss.dna.spi.graph.connection.RepositoryOperation#run(org.jboss.dna.spi.graph.connection.ExecutionEnvironment,
+ * @see
org.jboss.dna.spi.graph.connection.RepositoryOperation#run(org.jboss.dna.spi.ExecutionContext,
* org.jboss.dna.spi.graph.connection.RepositoryConnection)
*/
- public Integer run( ExecutionEnvironment env,
+ public Integer run( ExecutionContext context,
RepositoryConnection connection ) throws
RepositorySourceException, InterruptedException {
Logger.getLogger(RepositorySourceLoadHarness.class).debug("Running {0}
operation", this.getClass().getSimpleName());
int total = count;
@@ -211,7 +217,7 @@
if (i % 2 == 0) {
Thread.yield();
}
- connection.execute(env);
+ connection.execute(context);
int int2 = random(this.hashCode() ^ (int)System.nanoTime() + i);
total += Math.min(Math.abs(Math.max(int1, int2) + int1 * int2 / 3),
count);
}
Modified:
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/SimpleRepository.java
===================================================================
---
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/SimpleRepository.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/SimpleRepository.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -28,21 +28,21 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import net.jcip.annotations.ThreadSafe;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.NameFactory;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PathFactory;
import org.jboss.dna.spi.graph.Property;
import org.jboss.dna.spi.graph.PropertyFactory;
-import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
/**
* A very simple repository that maintains properties for nodes identified by a path, and
computes the children based upon the set
* of paths registered in the {@link #getData() data}.
* <p>
* Note that the repository does not automatically rename same-name siblings when nodes
are
- * {@link #delete(ExecutionEnvironment, String) deleted} or {@link
#create(ExecutionEnvironment, String) explicitly} or
- * {@link #setProperty(ExecutionEnvironment, String, String, Object...) implicitly}
created.
+ * {@link #delete(ExecutionContext, String) deleted} or {@link #create(ExecutionContext,
String) explicitly} or
+ * {@link #setProperty(ExecutionContext, String, String, Object...) implicitly} created.
* </p>
*
* @author Randall Hauch
@@ -93,21 +93,21 @@
* Utility method to help set the property on the node given by the supplied path. If
the node does not exist, it will be
* created.
*
- * @param env the environment; may not be null
+ * @param context the execution context; may not be null
* @param path the path to the node; may not be null
* @param propertyName the property name; may not be null
* @param values the values of the property
* @return this repository, for method chaining
*/
- public SimpleRepository setProperty( ExecutionEnvironment env,
+ public SimpleRepository setProperty( ExecutionContext context,
String path,
String propertyName,
Object... values ) {
- PathFactory pathFactory = env.getValueFactories().getPathFactory();
- NameFactory nameFactory = env.getValueFactories().getNameFactory();
- PropertyFactory propertyFactory = env.getPropertyFactory();
+ PathFactory pathFactory = context.getValueFactories().getPathFactory();
+ NameFactory nameFactory = context.getValueFactories().getNameFactory();
+ PropertyFactory propertyFactory = context.getPropertyFactory();
Path pathObj = pathFactory.create(path);
- create(env, pathObj.getAncestor().getString(env.getNamespaceRegistry()));
+ create(context,
pathObj.getAncestor().getString(context.getNamespaceRegistry()));
Property property = propertyFactory.create(nameFactory.create(propertyName),
values);
Map<Name, Property> properties = new HashMap<Name, Property>();
Map<Name, Property> existingProperties = data.putIfAbsent(pathObj,
properties);
@@ -119,13 +119,13 @@
/**
* Create the node if it does not exist.
*
- * @param env the environment; may not be null
+ * @param context the execution context; may not be null
* @param path the path to the node; may not be null
* @return this repository, for method chaining
*/
- public SimpleRepository create( ExecutionEnvironment env,
+ public SimpleRepository create( ExecutionContext context,
String path ) {
- PathFactory pathFactory = env.getValueFactories().getPathFactory();
+ PathFactory pathFactory = context.getValueFactories().getPathFactory();
Path pathObj = pathFactory.create(path);
Path ancestorPath = pathObj.getAncestor();
while (!ancestorPath.isRoot()) {
@@ -139,13 +139,13 @@
/**
* Delete the branch rooted at the supplied path, if it exists.
*
- * @param env the environment; may not be null
+ * @param context the execution context; may not be null
* @param path the path to the branch's top node; may not be null
* @return this repository, for method chaining
*/
- public SimpleRepository delete( ExecutionEnvironment env,
+ public SimpleRepository delete( ExecutionContext context,
String path ) {
- PathFactory pathFactory = env.getValueFactories().getPathFactory();
+ PathFactory pathFactory = context.getValueFactories().getPathFactory();
Path pathObj = pathFactory.create(path);
List<Path> pathsToRemove = new LinkedList<Path>();
for (Path nodePath : data.keySet()) {
Modified:
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/SimpleRepositorySource.java
===================================================================
---
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/SimpleRepositorySource.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/SimpleRepositorySource.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -29,6 +29,7 @@
import javax.naming.Reference;
import javax.transaction.xa.XAResource;
import net.jcip.annotations.ThreadSafe;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.cache.CachePolicy;
import org.jboss.dna.spi.graph.InvalidPathException;
import org.jboss.dna.spi.graph.Name;
@@ -158,28 +159,28 @@
/**
* {@inheritDoc}
*
- * @see
org.jboss.dna.spi.graph.connection.RepositoryConnection#execute(org.jboss.dna.spi.graph.connection.ExecutionEnvironment,
+ * @see
org.jboss.dna.spi.graph.connection.RepositoryConnection#execute(org.jboss.dna.spi.ExecutionContext,
* org.jboss.dna.spi.graph.commands.GraphCommand[])
*/
- public void execute( ExecutionEnvironment env,
+ public void execute( ExecutionContext context,
GraphCommand... commands ) throws RepositorySourceException
{
- assert env != null;
+ assert context != null;
if (repository.isShutdown()) {
throw new RepositorySourceException(getName(), "The repository
\"" + repository.getRepositoryName()
+ "\" is no
longer available");
}
for (GraphCommand command : commands) {
- executeCommand(env, command);
+ executeCommand(context, command);
}
}
- protected void executeCommand( ExecutionEnvironment env,
+ protected void executeCommand( ExecutionContext context,
GraphCommand command ) {
if (command == null) return;
if (command instanceof CompositeCommand) {
CompositeCommand composite = (CompositeCommand)command;
for (GraphCommand nestedCommand : composite) {
- executeCommand(env, nestedCommand);
+ executeCommand(context, nestedCommand);
}
}
Map<Path, Map<Name, Property>> data = repository.getData();
Modified:
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java
===================================================================
---
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -32,6 +32,7 @@
import javax.naming.Reference;
import javax.transaction.xa.XAResource;
import net.jcip.annotations.ThreadSafe;
+import org.jboss.dna.spi.ExecutionContext;
import org.jboss.dna.spi.cache.CachePolicy;
import org.jboss.dna.spi.graph.commands.GraphCommand;
@@ -252,7 +253,7 @@
/**
* {@inheritDoc}
*/
- public void execute( ExecutionEnvironment env,
+ public void execute( ExecutionContext context,
GraphCommand... commands ) throws InterruptedException {
long delay = this.loadDelay.get();
if (delay > 0l) Thread.sleep(delay);
Modified:
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java
===================================================================
---
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java 2008-07-25
19:37:40 UTC (rev 370)
+++
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java 2008-07-25
20:39:42 UTC (rev 371)
@@ -47,10 +47,10 @@
import org.jboss.dna.repository.observation.ObservationService;
import org.jboss.dna.repository.sequencers.SequencerConfig;
import org.jboss.dna.repository.sequencers.SequencingService;
-import org.jboss.dna.repository.util.ExecutionContext;
+import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.repository.util.JcrTools;
import org.jboss.dna.repository.util.SessionFactory;
-import org.jboss.dna.repository.util.SimpleExecutionContext;
+import org.jboss.dna.repository.util.BasicJcrExecutionContext;
import org.jboss.dna.repository.util.SimpleSessionFactory;
/**
@@ -82,7 +82,7 @@
private SequencingService sequencingService;
private ObservationService observationService;
private UserInterface userInterface;
- private ExecutionContext executionContext;
+ private JcrExecutionContext executionContext;
public SequencingClient() {
setJackrabbitConfigPath(DEFAULT_JACKRABBIT_CONFIG_PATH);
@@ -208,7 +208,7 @@
// Create an execution context for the sequencing service. This execution
context provides an environment
// for the DNA services which knows about the JCR repositories, workspaces,
and credentials used to
- // establish sessions to these workspaces. This example uses the
SimpleExecutionContext, but there is
+ // establish sessions to these workspaces. This example uses the
BasicJcrExecutionContext, but there is
// implementation for use with JCR repositories registered in JNDI.
final String repositoryWorkspaceName = this.repositoryName + "/" +
this.workspaceName;
SimpleSessionFactory sessionFactory = new SimpleSessionFactory();
@@ -217,7 +217,7 @@
Credentials credentials = new SimpleCredentials(this.username,
this.password);
sessionFactory.registerCredentials(repositoryWorkspaceName,
credentials);
}
- this.executionContext = new SimpleExecutionContext(sessionFactory,
repositoryWorkspaceName);
+ this.executionContext = new BasicJcrExecutionContext(sessionFactory,
repositoryWorkspaceName);
// Create the sequencing service, passing in the execution context ...
this.sequencingService = new SequencingService();