You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by re...@apache.org on 2015/03/23 17:37:45 UTC

[01/51] [partial] incubator-taverna-engine git commit:

Repository: incubator-taverna-engine
Updated Branches:
  refs/heads/master a36853983 -> 5f1ddb715


http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/DataflowImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/DataflowImpl.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/DataflowImpl.java
new file mode 100644
index 0000000..2ce7709
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/DataflowImpl.java
@@ -0,0 +1,796 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.impl;
+
+import static java.util.Collections.unmodifiableList;
+import static org.apache.taverna.workflowmodel.utils.Tools.addDataflowIdentification;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import org.apache.taverna.annotation.AbstractAnnotatedThing;
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.monitor.MonitorManager;
+import org.apache.taverna.workflowmodel.Dataflow;
+import org.apache.taverna.workflowmodel.DataflowInputPort;
+import org.apache.taverna.workflowmodel.DataflowOutputPort;
+import org.apache.taverna.workflowmodel.DataflowValidationReport;
+import org.apache.taverna.workflowmodel.Datalink;
+import org.apache.taverna.workflowmodel.EditException;
+import org.apache.taverna.workflowmodel.EventHandlingInputPort;
+import org.apache.taverna.workflowmodel.FailureTransmitter;
+import org.apache.taverna.workflowmodel.InvalidDataflowException;
+import org.apache.taverna.workflowmodel.Merge;
+import org.apache.taverna.workflowmodel.NamedWorkflowEntity;
+import org.apache.taverna.workflowmodel.NamingException;
+import org.apache.taverna.workflowmodel.Processor;
+import org.apache.taverna.workflowmodel.TokenProcessingEntity;
+import org.apache.taverna.workflowmodel.processor.iteration.IterationTypeMismatchException;
+
+/**
+ * Implementation of Dataflow including implementation of the dataflow level
+ * type checker. Other than this the implementation is fairly simple as it's
+ * effectively just a container for other things especially the dataflow input
+ * and output port implementations.
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public class DataflowImpl extends AbstractAnnotatedThing<Dataflow> implements
+		Dataflow {
+	List<ProcessorImpl> processors;
+	List<MergeImpl> merges;
+	private String name;
+	private static int nameIndex = 1;
+	private List<DataflowInputPortImpl> inputs;
+	private List<DataflowOutputPortImpl> outputs;
+	protected String internalIdentifier;
+	private DataflowValidationReport validationReport;
+
+    /**
+	 * Protected constructor, assigns a default name. To build an instance of
+	 * DataflowImpl you should use the appropriate Edit object from the Edits
+	 * interface
+	 */
+	protected DataflowImpl() {
+		this.name = "Workflow" + (nameIndex++);
+		this.processors = new ArrayList<ProcessorImpl>();
+		this.merges = new ArrayList<MergeImpl>();
+		this.inputs = new ArrayList<DataflowInputPortImpl>();
+		this.outputs = new ArrayList<DataflowOutputPortImpl>();
+		refreshInternalIdentifier();
+	}
+
+	/**
+	 * Adds a processor on the DataFlow.
+	 * 
+	 * @param processor
+	 *            the ProcessorImpl to be added to the Dataflow
+	 * @return
+	 * @throws NamingException
+	 *             if a processor already exists with the same local name
+	 */
+	protected synchronized void addProcessor(ProcessorImpl processor)
+			throws NamingException {
+		for (Processor existingProcessor : new ArrayList<>(processors))
+			if (existingProcessor.getLocalName().equals(
+					processor.getLocalName()))
+				throw new NamingException("There already is a processor named:"
+						+ processor.getLocalName());
+		processors.add(processor);
+	}
+
+	protected synchronized void removeProcessor(Processor processor) {
+		processors.remove(processor);
+	}
+
+	/**
+	 * Adds a processor on the DataFlow.
+	 * 
+	 * @param processor
+	 *            the ProcessorImpl to be added to the Dataflow
+	 * @return
+	 * @throws NamingException
+	 *             if a processor already exists with the same local name
+	 */
+	protected synchronized void addMerge(MergeImpl merge)
+			throws NamingException {
+		for (Merge existingMerge : new ArrayList<>(merges))
+			if (existingMerge.getLocalName().equals(merge.getLocalName()))
+				throw new NamingException(
+						"There already is a merge operation named:"
+								+ merge.getLocalName());
+		merges.add(merge);
+	}
+
+	protected synchronized void removeMerge(Merge merge) {
+		merges.remove(merge);
+	}
+
+	/**
+	 * Build a new dataflow input port, the granular depth is set for the input
+	 * port so it can be copied onto the internal output port
+	 * 
+	 * @param name
+	 *            name of the dataflow input port to build
+	 * @param depth
+	 *            input depth
+	 * @param granularDepth
+	 *            granular depth to copy to the internal output port
+	 * @throws NamingException
+	 *             in the event of a duplicate or invalid name
+	 * @return the newly created input port
+	 */
+	protected synchronized DataflowInputPort createInputPort(String name,
+			int depth, int granularDepth) throws NamingException {
+		for (DataflowInputPort dip : inputs)
+			if (dip.getName().equals(name))
+				throw new NamingException(
+						"Duplicate workflow input port name '" + name
+								+ "' in workflow already.");
+		DataflowInputPortImpl dipi = new DataflowInputPortImpl(name, depth,
+				granularDepth, this);
+		inputs.add(dipi);
+		return dipi;
+	}
+
+	/**
+	 * Adds an input port to the DataFlow.
+	 * 
+	 * @param inputPort
+	 *            the DataflowInputPortImpl to be added to the Dataflow
+	 * @throws EditException
+	 */
+	protected synchronized void addInputPort(DataflowInputPortImpl inputPort)
+			throws EditException {
+		for (DataflowInputPort existingInputPort : new ArrayList<>(inputs))
+			if (existingInputPort.getName().equals(inputPort.getName()))
+				throw new NamingException(
+						"There already is a workflow input port named:"
+								+ inputPort.getName());
+		if (inputPort.getDataflow() != this)
+			throw new EditException("Port specifies a different workflow");
+		inputs.add(inputPort);
+	}
+
+	/**
+	 * Remove the named dataflow input port
+	 * 
+	 * @param name
+	 *            name of the dataflow input port to remove
+	 * @throws EditException
+	 *             if the specified port doesn't exist within this dataflow
+	 */
+	protected synchronized void removeDataflowInputPort(String name)
+			throws EditException {
+		for (DataflowInputPort dip : inputs)
+			if (dip.getName().equals(name)) {
+				removeDataflowInputPort(dip);
+				return;
+			}
+		throw new EditException("No such input port '" + name
+				+ "' in workflow.");
+	}
+
+	/**
+	 * Remove the specified input port from this dataflow
+	 * 
+	 * @param dip
+	 *            dataflow input port to remove
+	 * @throws EditException
+	 *             if the input port isn't in the list of inputs - should never
+	 *             happen but you never know.
+	 */
+	protected synchronized void removeDataflowInputPort(DataflowInputPort dip)
+			throws EditException {
+		if (!inputs.contains(dip))
+			throw new EditException(
+					"Can't locate the specified input port in workflow. Input port has name '"
+							+ dip.getName() + "'.");
+		inputs.remove(dip);
+	}
+
+	/**
+	 * Create and return a new DataflowOutputPort in this dataflow
+	 * 
+	 * @param name
+	 *            name of the port to create, must be unique within the set of
+	 *            output ports for this dataflow
+	 * @return the newly created DataflowOutputPort
+	 * @throws NamingException
+	 *             if the name is invalid or already exists as a name for a
+	 *             dataflow output
+	 */
+	protected synchronized DataflowOutputPort createOutputPort(String name)
+			throws NamingException {
+		for (DataflowOutputPort dop : outputs)
+			if (dop.getName().equals(name))
+				throw new NamingException(
+						"Duplicate workflow output port name '" + name
+								+ "' in workflow already.");
+		DataflowOutputPortImpl dopi = new DataflowOutputPortImpl(name, this);
+		outputs.add(dopi);
+		return dopi;
+	}
+
+	/**
+	 * Adds an output port to the DataFlow.
+	 * 
+	 * @param outputPort
+	 *            the DataflowOutputPortImpl to be added to the Dataflow
+	 * @throws EditException
+	 */
+	protected synchronized void addOutputPort(DataflowOutputPortImpl outputPort)
+			throws EditException {
+		for (DataflowOutputPort existingOutputPort : new ArrayList<>(outputs))
+			if (existingOutputPort.getName().equals(outputPort.getName()))
+				throw new NamingException(
+						"There already is a workflow output port named:"
+								+ outputPort.getName());
+		if (outputPort.getDataflow() != this)
+			throw new EditException("Port specifies a different workflow");
+		outputs.add(outputPort);
+	}
+
+	/**
+	 * Remove the named dataflow output port
+	 * 
+	 * @param name
+	 *            name of the dataflow output port to remove
+	 * @throws EditException
+	 *             if the specified port doesn't exist within this dataflow
+	 */
+	protected synchronized void removeDataflowOutputPort(String name)
+			throws EditException {
+		for (DataflowOutputPort dop : outputs)
+			if (dop.getName().equals(name)) {
+				removeDataflowOutputPort(dop);
+				return;
+			}
+		throw new EditException("No such output port '" + name
+				+ "' in workflow.");
+	}
+
+	/**
+	 * Remove the specified output port from this dataflow
+	 * 
+	 * @param dop
+	 *            dataflow output port to remove
+	 * @throws EditException
+	 *             if the output port isn't in the list of outputs for this
+	 *             dataflow
+	 */
+	protected synchronized void removeDataflowOutputPort(DataflowOutputPort dop)
+			throws EditException {
+		if (!outputs.contains(dop))
+			throw new EditException(
+					"Can't locate the specified output port in workflow, output port has name '"
+							+ dop.getName() + "'.");
+		outputs.remove(dop);
+	}
+
+	/**
+	 * Create a new datalink between two entities within the workflow
+	 * 
+	 * @param sourceName
+	 *            interpreted either as the literal name of a dataflow input
+	 *            port or the colon seperated name of a
+	 *            [processorName|mergeName]:[outputPort]
+	 * @param sinkName
+	 *            as with sourceName but for processor or merge input ports and
+	 *            dataflow output ports
+	 * @return the created Datalink
+	 * @throws EditException
+	 *             if either source or sink isn't found within this dataflow or
+	 *             if the link would violate workflow structural constraints in
+	 *             an immediate way. This won't catch cycles (see the validation
+	 *             methods for that) but will prevent you from having more than
+	 *             one link going to an input port.
+	 */
+	protected synchronized Datalink link(String sourceName, String sinkName)
+			throws EditException {
+		BasicEventForwardingOutputPort source = findSourcePort(sourceName);
+		EventHandlingInputPort sink = findSinkPort(sinkName);
+
+		// Check whether the sink is already linked
+		if (sink.getIncomingLink() != null)
+			throw new EditException("Cannot link to sink port '" + sinkName
+					+ "' as it is already linked");
+
+		/*
+		 * Got here so we have both source and sink and the sink isn't already
+		 * linked from somewhere. If the sink isn't linked we can't have a
+		 * duplicate link here which would have been the other condition to
+		 * check for.
+		 */
+
+		DatalinkImpl link = new DatalinkImpl(source, sink);
+		source.addOutgoingLink(link);
+		((AbstractEventHandlingInputPort) sink).setIncomingLink(link);
+
+		return link;
+	}
+
+	/* @nonnull */
+	private BasicEventForwardingOutputPort findSourcePort(String sourceName)
+			throws EditException {
+		BasicEventForwardingOutputPort source = null;
+		String[] split = sourceName.split(":");
+		if (split.length == 2) {
+			/* source is a processor */
+			// TODO - update to include Merge when it's added
+			for (ProcessorImpl pi : processors)
+				if (pi.getLocalName().equals(split[0])) {
+					source = pi.getOutputPortWithName(split[1]);
+					break;
+				}
+		} else if (split.length == 1) {
+			/*
+			 * source is a workflow input port, or at least the internal output
+			 * port within it
+			 */
+			for (DataflowInputPortImpl dipi : inputs)
+				if (dipi.getName().equals(split[0])) {
+					source = dipi.internalOutput;
+					break;
+				}
+		} else
+			throw new EditException("Invalid source link name '" + sourceName
+					+ "'.");
+		if (source == null)
+			throw new EditException("Unable to find source port named '"
+					+ sourceName + "' in link creation.");
+		return source;
+	}
+
+	/* @nonnull */
+	private EventHandlingInputPort findSinkPort(String sinkName)
+			throws EditException {
+		EventHandlingInputPort sink = null;
+		String[] split;
+		split = sinkName.split(":");
+		if (split.length == 2) {
+			/* sink is a processor */
+			// TODO - update to include Merge when it's added
+			for (ProcessorImpl pi : processors)
+				if (pi.getLocalName().equals(split[0])) {
+					sink = pi.getInputPortWithName(split[1]);
+					break;
+				}
+		} else if (split.length == 1) {
+			/*
+			 * source is a workflow input port, or at least the internal output
+			 * port within it
+			 */
+			for (DataflowOutputPortImpl dopi : outputs)
+				if (dopi.getName().equals(split[0])) {
+					sink = dopi.getInternalInputPort();
+					break;
+				}
+		} else
+			throw new EditException("Invalid link sink name '" + sinkName
+					+ "'.");
+		if (sink == null)
+			throw new EditException("Unable to find sink port named '"
+					+ sinkName + "' in link creation");
+		return sink;
+	}
+	
+	/**
+	 * Return a copy of the list of dataflow input ports for this dataflow
+	 */
+	@Override
+	public synchronized List<? extends DataflowInputPort> getInputPorts() {
+		return unmodifiableList(inputs);
+	}
+
+	/**
+	 * For each processor input, merge input and workflow output get the
+	 * incoming link and, if non null, add to a list and return the entire list.
+	 */
+	@Override
+	public synchronized List<? extends Datalink> getLinks() {
+		List<Datalink> result = new ArrayList<>();
+		/*
+		 * All processors have a set of input ports each of which has at most
+		 * one incoming data link
+		 */
+		for (TokenProcessingEntity p : getEntities(TokenProcessingEntity.class))
+			for (EventHandlingInputPort pip : p.getInputPorts()) {
+				Datalink dl = pip.getIncomingLink();
+				if (dl != null)
+					result.add(dl);
+			}
+		/*
+		 * Workflow outputs have zero or one incoming data link to their
+		 * internal input port
+		 */
+		for (DataflowOutputPort dop : getOutputPorts()) {
+			Datalink dl = dop.getInternalInputPort().getIncomingLink();
+			if (dl != null)
+				result.add(dl);
+		}
+
+		return result;
+	}
+
+	/**
+	 * Return the list of all processors within the dataflow
+	 */
+	@Override
+	public synchronized List<? extends Processor> getProcessors() {
+		return getEntities(Processor.class);
+	}
+
+	/**
+	 * Return the list of all merge operations within the dataflow
+	 */
+	@Override
+	public synchronized List<? extends Merge> getMerges() {
+		return getEntities(Merge.class);
+	}
+
+	/**
+	 * Return all dataflow output ports
+	 */
+	@Override
+	public synchronized List<? extends DataflowOutputPort> getOutputPorts() {
+		return unmodifiableList(outputs);
+	}
+
+	/**
+	 * Return the local name of this workflow
+	 */
+	@Override
+	public String getLocalName() {
+		return this.name;
+	}
+
+	/**
+	 * Run the type check algorithm and return a report on any problems found.
+	 * This method must be called prior to actually pushing data through the
+	 * dataflow as it sets various properties as a side effect.
+	 * 
+	 * If the workflow has been set immutable with {@link #setImmutable()},
+	 * subsequent calls to this method will return the cached
+	 * DataflowValidationReport.
+	 * 
+	 */
+	@Override
+	public DataflowValidationReport checkValidity() {
+		if (!immutable)
+			// Don't store it!
+			return checkValidityImpl();
+		if (validationReport == null)
+			validationReport = checkValidityImpl();
+		return validationReport;
+	}
+
+	/**
+	 * Works out whether a dataflow is valid. <strong>This includes working out
+	 * the real depths of output ports.</strong>
+	 */
+	public synchronized DataflowValidationReport checkValidityImpl() {
+		// First things first - nullify the resolved depths in all datalinks
+		for (Datalink dl : getLinks())
+			if (dl instanceof DatalinkImpl)
+				((DatalinkImpl) dl).setResolvedDepth(-1);
+		// Now copy type information from workflow inputs
+		for (DataflowInputPort dip : getInputPorts())
+			for (Datalink dl : dip.getInternalOutputPort().getOutgoingLinks())
+				if (dl instanceof DatalinkImpl)
+					((DatalinkImpl) dl).setResolvedDepth(dip.getDepth());
+
+		/*
+		 * ==================================================================
+		 * Now iteratively attempt to resolve everything else.
+		 * ==================================================================
+		 */
+
+		/*
+		 * Firstly take a copy of the processor list, we'll processors from this
+		 * list as they become either failed or resolved
+		 */
+		List<TokenProcessingEntity> unresolved = new ArrayList<>(
+				getEntities(TokenProcessingEntity.class));
+
+		// Keep a list of processors that have failed, initially empty
+		List<TokenProcessingEntity> failed = new ArrayList<>();
+
+		/**
+		 * Is the dataflow valid? The flow is valid if and only if both
+		 * unresolved and failed lists are empty at the end. This doesn't
+		 * guarantee that the workflow will run, in particular it doesn't
+		 * actually check for issues such as unresolved output edges.
+		 */
+
+		// Flag to indicate whether we've finished yet, set to true if no
+		// changes are made in an iteration
+		boolean finished = false;
+
+		Map<TokenProcessingEntity, DataflowValidationReport> invalidDataflows = new HashMap<>();
+		while (!finished) {
+			// We're finished unless something happens later
+			finished = true;
+			// Keep a list of processors to remove from the unresolved list
+			// because they've been resolved properly
+			List<TokenProcessingEntity> removeValidated = new ArrayList<>();
+			// Keep another list of those that have failed
+			List<TokenProcessingEntity> removeFailed = new ArrayList<>();
+
+			for (TokenProcessingEntity p : unresolved)
+				try {
+					/*
+					 * true = checked and valid, false = can't check, the
+					 * exception means the processor was checked but was invalid
+					 * for some reason
+					 */
+
+					if (p.doTypeCheck()) {
+						removeValidated.add(p);
+						/*
+						 * At least one thing validated; we will need to run the
+						 * check loop at least once more.
+						 */
+						finished = false;
+					}
+				} catch (IterationTypeMismatchException e) {
+					removeFailed.add(p);
+				} catch (InvalidDataflowException e) {
+					invalidDataflows.put(p, e.getDataflowValidationReport());
+					removeFailed.add(p);
+				}
+
+			/*
+			 * Remove validated and failed items from the pending lists.
+			 */
+			unresolved.removeAll(removeValidated);
+			unresolved.removeAll(removeFailed);
+			failed.addAll(removeFailed);
+		}
+
+		/*
+		 * At this point we know whether the processors within the workflow
+		 * validated. If all the processors validated then we're probably okay,
+		 * but there are a few other problems to check for. Firstly we need to
+		 * check whether all the dataflow outputs are connected; any unconnected
+		 * output is by definition a validation failure.
+		 */
+		List<DataflowOutputPort> unresolvedOutputs = new ArrayList<>();
+		for (DataflowOutputPortImpl dopi : outputs) {
+			Datalink dl = dopi.getInternalInputPort().getIncomingLink();
+			/*
+			 * Unset any type information on the output port, we'll set it again
+			 * later if there's a suitably populated link going into it
+			 */
+			dopi.setDepths(-1, -1);
+			if (dl == null)
+				// not linked, this is by definition an unsatisfied link!
+				unresolvedOutputs.add(dopi);
+			else if (dl.getResolvedDepth() == -1)
+				/*
+				 * linked but the edge hasn't had its depth resolved, i.e. it
+				 * links from an unresolved entity
+				 */
+				unresolvedOutputs.add(dopi);
+			else {
+				/*
+				 * linked and edge depth is defined, we can therefore populate
+				 * the granular and real depth of the dataflow output port. Note
+				 * that this is the only way these values can be populated, you
+				 * don't define them when creating the ports as they are
+				 * entirely based on the type check stage.
+				 */
+
+				int granularDepth = dl.getSource().getGranularDepth();
+				int resolvedDepth = dl.getResolvedDepth();
+				dopi.setDepths(resolvedDepth, granularDepth);
+			}
+		}
+
+		/*
+		 * Check if workflow is 'incomplete' - i.e. if it contains no processors
+		 * and no output ports. This is to prevent empty workflows or ones that
+		 * contain input ports from being run.
+		 */
+
+		boolean dataflowIsIncomplete = getProcessors().isEmpty()
+				&& getOutputPorts().isEmpty();
+
+		/*
+		 * For a workflow to be valid - workflow must not be 'empty' and lists
+		 * of problems must all be empty
+		 */
+
+		boolean dataflowValid = (!dataflowIsIncomplete)
+				&& unresolvedOutputs.isEmpty() && failed.isEmpty()
+				&& unresolved.isEmpty();
+
+		/*
+		 * Build and return a new validation report containing the overall state
+		 * along with lists of failed and unsatisfied processors and unsatisfied
+		 * output ports
+		 */
+
+		return new DataflowValidationReportImpl(dataflowValid,
+				dataflowIsIncomplete, failed, unresolved, unresolvedOutputs,
+				invalidDataflows);
+	}
+
+	/**
+	 * Gets all workflow entities of the specified type and returns as an
+	 * unmodifiable list of that type
+	 */
+	@Override
+	public <T extends NamedWorkflowEntity> List<? extends T> getEntities(
+			Class<T> entityType) {
+		List<T> result = new ArrayList<T>();
+		filterAndAdd(processors, result, entityType);
+		filterAndAdd(merges, result, entityType);
+		return unmodifiableList(result);
+	}
+
+	private <T extends NamedWorkflowEntity> void filterAndAdd(
+			Iterable<?> source, List<T> target, Class<T> type) {
+		for (Object o : source)
+			if (type.isAssignableFrom(o.getClass()))
+				target.add(type.cast(o));
+	}
+
+	/**
+	 * The active process identifiers correspond to current strands of data
+	 * running through this dataflow.
+	 */
+	private Set<String> activeProcessIdentifiers = new HashSet<>();
+	private volatile boolean immutable;
+
+	/**
+	 * Called when a token is received or the dataflow is fired, checks to see
+	 * whether the process identifier is already known (in which case we assume
+	 * it's been registered and can ignore it) or registers it with the monitor
+	 * along with all child entities. The method is called with the ID of the
+	 * new process, that is to say the ID of the token with ':'getLocalName()
+	 * appended.
+	 * 
+	 * @param owningProcess
+	 * 
+	 * @return true if the owning process specified was already in the active
+	 *         process identifier set, false otherwise
+	 */
+	protected boolean tokenReceived(String owningProcess,
+			InvocationContext context) {
+		synchronized (activeProcessIdentifiers) {
+			if (activeProcessIdentifiers.contains(owningProcess))
+				return true;
+			MonitorManager.getInstance().registerNode(this, owningProcess);
+
+			/*
+			 * Message each processor within the dataflow and instruct it to
+			 * register any properties with the monitor including any processor
+			 * level properties it can aggregate from its dispatch stack.
+			 */
+
+			for (ProcessorImpl p : getEntities(ProcessorImpl.class)) {
+				p.registerWithMonitor(owningProcess);
+				if (p.getInputPorts().isEmpty())
+					p.fire(owningProcess, context);
+			}
+			activeProcessIdentifiers.add(owningProcess);
+			return false;
+		}
+	}
+
+	/**
+	 * Sets the local name for the dataflow
+	 * 
+	 * @param localName
+	 */
+	public void setLocalName(String localName) {
+		if (immutable)
+			throw new UnsupportedOperationException("Dataflow is immutable");
+		name = localName;
+	}
+
+	@Override
+	public String toString() {
+		return "Dataflow " + getLocalName() + "[" + getIdentifier() + "]";
+	}
+
+	@Override
+	public void fire(String owningProcess, InvocationContext context) {
+		String newOwningProcess = owningProcess + ":" + getLocalName();
+		if (tokenReceived(newOwningProcess, context)) {
+			/*
+			 * This is not good - should ideally handle it as it means the
+			 * workflow has been fired when in a state where this wasn't
+			 * sensible, i.e. already having been fired on this process
+			 * identifier. For now we'll ignore it (ho hum, release deadline
+			 * etc!)
+			 */
+		}
+		/*
+		 * The code below now happens in the tokenReceived method, we need to
+		 * fire any processors which don't have dependencies when a new token
+		 * arrives and we weren't doing that anywhere.
+		 */
+		/**
+		 * for (Processor p : getEntities(Processor.class)) { if
+		 * (p.getInputPorts().isEmpty()) { p.fire(newOwningProcess, context); }
+		 * }
+		 */
+	}
+
+	@Override
+	public FailureTransmitter getFailureTransmitter() {
+		throw new UnsupportedOperationException(
+				"Not implemented for DataflowImpl yet");
+	}
+
+	@Override
+	public boolean doTypeCheck() throws IterationTypeMismatchException {
+		throw new UnsupportedOperationException(
+				"Not implemented for DataflowImpl yet");
+	}
+
+	public void refreshInternalIdentifier() {
+		setIdentifier(UUID.randomUUID().toString());
+	}
+
+	@Override
+	public String getIdentifier() {
+		return internalIdentifier;
+	}
+
+	@Override
+	public String recordIdentifier() {
+		addDataflowIdentification(this, internalIdentifier, new EditsImpl());
+		return internalIdentifier;
+	}
+
+	void setIdentifier(String id) {
+		if (immutable)
+			throw new UnsupportedOperationException("Dataflow is immutable");
+		this.internalIdentifier = id;
+	}
+
+	@Override
+	public boolean isInputPortConnected(DataflowInputPort inputPort) {
+		for (Datalink link : getLinks())
+			if (link.getSource().equals(inputPort.getInternalOutputPort()))
+				return true;
+		return false;
+	}
+
+	@Override
+	public synchronized void setImmutable() {
+		if (immutable)
+			return;
+		processors = unmodifiableList(processors);
+		merges = unmodifiableList(merges);
+		outputs = unmodifiableList(outputs);
+		inputs = unmodifiableList(inputs);
+		immutable = true;
+	}
+}


[07/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Invoke.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Invoke.java b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Invoke.java
new file mode 100644
index 0000000..ce6bf35
--- /dev/null
+++ b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Invoke.java
@@ -0,0 +1,368 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.layers;
+
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchMessageType.ERROR;
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchMessageType.RESULT;
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchMessageType.RESULT_COMPLETION;
+
+import java.lang.Thread.UncaughtExceptionHandler;
+import java.sql.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.monitor.MonitorManager;
+import org.apache.taverna.monitor.MonitorableProperty;
+import org.apache.taverna.provenance.item.InvocationStartedProvenanceItem;
+import org.apache.taverna.provenance.item.IterationProvenanceItem;
+import org.apache.taverna.provenance.reporter.ProvenanceReporter;
+import org.apache.taverna.reference.ReferenceService;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.workflowmodel.ControlBoundary;
+import org.apache.taverna.workflowmodel.OutputPort;
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+import org.apache.taverna.workflowmodel.processor.activity.AsynchronousActivity;
+import org.apache.taverna.workflowmodel.processor.activity.AsynchronousActivityCallback;
+import org.apache.taverna.workflowmodel.processor.activity.MonitorableAsynchronousActivity;
+import org.apache.taverna.workflowmodel.processor.dispatch.AbstractDispatchLayer;
+import org.apache.taverna.workflowmodel.processor.dispatch.DispatchLayer;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerJobReaction;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchCompletionEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchErrorEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchErrorType;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchJobEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchResultEvent;
+
+import org.apache.log4j.Logger;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * Context free invoker layer, does not pass index arrays of jobs into activity
+ * instances.
+ * <p>
+ * This layer will invoke the first invokable activity in the activity list, so
+ * any sane dispatch stack will have narrowed this down to a single item list by
+ * this point, i.e. by the insertion of a failover layer.
+ * <p>
+ * Currently only handles activities implementing {@link AsynchronousActivity}.
+ *
+ * @author Tom Oinn
+ * @author Stian Soiland-Reyes
+ *
+ */
+@DispatchLayerJobReaction(emits = { ERROR, RESULT_COMPLETION, RESULT }, relaysUnmodified = false, stateEffects = {})
+@ControlBoundary
+public class Invoke extends AbstractDispatchLayer<JsonNode> {
+	public static final String URI = "http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/Invoke";
+	private static Logger logger = Logger.getLogger(Invoke.class);
+	private static Long invocationCount = 0L;
+
+	private MonitorManager monMan;
+
+	private static String getNextProcessID() {
+		long count;
+		synchronized (invocationCount) {
+			count = ++invocationCount;
+		}
+		return "invocation" + count;
+	}
+
+	public Invoke() {
+		super();
+		monMan = MonitorManager.getInstance();
+	}
+
+	@Override
+	public void configure(JsonNode config) {
+		// No configuration, do nothing
+	}
+
+	@Override
+	public JsonNode getConfiguration() {
+		return null;
+	}
+
+	/**
+	 * Receive a job from the layer above and pick the first concrete activity
+	 * from the list to invoke. Invoke this activity, creating a callback which
+	 * will wrap up the result messages in the appropriate collection depth
+	 * before sending them on (in general activities are not aware of their
+	 * invocation context and should not be responsible for providing correct
+	 * index arrays for results)
+	 * <p>
+	 * This layer will invoke the first invokable activity in the activity list,
+	 * so any sane dispatch stack will have narrowed this down to a single item
+	 * list by this point, i.e. by the insertion of a failover layer.
+	 */
+	@Override
+	public void receiveJob(final DispatchJobEvent jobEvent) {
+		for (Activity<?> activity : jobEvent.getActivities())
+			if (activity instanceof AsynchronousActivity) {
+				invoke(jobEvent, (AsynchronousActivity<?>) activity);
+				break;
+			}
+	}
+
+	protected void invoke(final DispatchJobEvent jobEvent, final AsynchronousActivity<?> activity) {
+		// Register with the monitor
+		final String invocationProcessIdentifier = jobEvent.pushOwningProcess(
+				getNextProcessID()).getOwningProcess();
+		monMan.registerNode(activity, invocationProcessIdentifier,
+				new HashSet<MonitorableProperty<?>>());
+		monMan.registerNode(jobEvent, invocationProcessIdentifier,
+				new HashSet<MonitorableProperty<?>>());
+
+		/*
+		 * The activity is an AsynchronousActivity so we invoke it with an
+		 * AsynchronousActivityCallback object containing appropriate callback
+		 * methods to push results, completions and failures back to the
+		 * invocation layer.
+		 * 
+		 * Get the registered DataManager for this process. In most cases this
+		 * will just be a single DataManager for the entire workflow system but
+		 * it never hurts to generalize
+		 */
+
+		InvocationContext context = jobEvent.getContext();
+		final ReferenceService refService = context.getReferenceService();
+
+		InvocationStartedProvenanceItem invocationItem = null;
+		ProvenanceReporter provenanceReporter = context.getProvenanceReporter();
+		if (provenanceReporter != null) {
+			IntermediateProvenance intermediateProvenance = findIntermediateProvenance();
+			if (intermediateProvenance != null) {
+				invocationItem = new InvocationStartedProvenanceItem();
+				IterationProvenanceItem parentItem = intermediateProvenance.getIterationProvItem(jobEvent);
+				invocationItem.setIdentifier(UUID.randomUUID().toString());
+				invocationItem.setActivity(activity);
+				invocationItem.setProcessId(jobEvent.getOwningProcess());
+				invocationItem.setInvocationProcessId(invocationProcessIdentifier);
+				invocationItem.setParentId(parentItem.getIdentifier());
+				invocationItem.setWorkflowId(parentItem.getWorkflowId());
+				invocationItem.setInvocationStarted(new Date(System.currentTimeMillis()));
+				provenanceReporter.addProvenanceItem(invocationItem);
+			}
+		}
+
+		/*
+		 * Create a Map of EntityIdentifiers named appropriately given the
+		 * activity mapping
+		 */
+		Map<String, T2Reference> inputData = new HashMap<>();
+		for (String inputName : jobEvent.getData().keySet()) {
+			String activityInputName = activity
+					.getInputPortMapping().get(inputName);
+			if (activityInputName != null)
+				inputData.put(activityInputName, jobEvent.getData()
+						.get(inputName));
+		}
+
+		/*
+		 * Create a callback object to receive events, completions and failure
+		 * notifications from the activity
+		 */
+		AsynchronousActivityCallback callback = new InvokeCallBack(
+				jobEvent, refService, invocationProcessIdentifier,
+				activity);
+
+		if (activity instanceof MonitorableAsynchronousActivity<?>) {
+			/*
+			 * Monitorable activity so get the monitorable properties and push
+			 * them into the state tree after launching the job
+			 */
+			MonitorableAsynchronousActivity<?> maa = (MonitorableAsynchronousActivity<?>) activity;
+			Set<MonitorableProperty<?>> props = maa
+					.executeAsynchWithMonitoring(inputData, callback);
+			monMan.addPropertiesToNode(invocationProcessIdentifier.split(":"), props);
+		} else {
+			/*
+			 * Run the job, passing in the callback we've just created along
+			 * with the (possibly renamed) input data map
+			 */
+			activity.executeAsynch(inputData, callback);
+		}
+	}
+
+	protected IntermediateProvenance findIntermediateProvenance() {
+		for (DispatchLayer<?> layer : getProcessor().getDispatchStack()
+				.getLayers())
+			if (layer instanceof IntermediateProvenance)
+				return (IntermediateProvenance) layer;
+		return null;
+	}
+
+	protected class InvokeCallBack implements AsynchronousActivityCallback {
+		protected final AsynchronousActivity<?> activity;
+		protected final String invocationProcessIdentifier;
+		protected final DispatchJobEvent jobEvent;
+		protected final ReferenceService refService;
+		protected boolean sentJob = false;
+
+		protected InvokeCallBack(DispatchJobEvent jobEvent,
+				ReferenceService refService,
+				String invocationProcessIdentifier,
+				AsynchronousActivity<?> asyncActivity) {
+			this.jobEvent = jobEvent;
+			this.refService = refService;
+			this.invocationProcessIdentifier = invocationProcessIdentifier;
+			this.activity = asyncActivity;
+		}
+
+		@Override
+		public void fail(String message) {
+			fail(message, null);
+		}
+
+		@Override
+		public void fail(String message, Throwable t) {
+			fail(message, t, DispatchErrorType.INVOCATION);
+		}
+
+		@Override
+		public void fail(String message, Throwable t,
+				DispatchErrorType errorType) {
+			logger.warn("Failed (" + errorType + ") invoking " + activity
+					+ " for job " + jobEvent + ": " + message, t);
+			monMan.deregisterNode(
+					invocationProcessIdentifier);
+			getAbove().receiveError(
+					new DispatchErrorEvent(jobEvent.getOwningProcess(),
+							jobEvent.getIndex(), jobEvent.getContext(),
+							message, t, errorType, activity));
+		}
+
+		@Override
+		public InvocationContext getContext() {
+			return jobEvent.getContext();
+		}
+
+		@Override
+		public String getParentProcessIdentifier() {
+			return invocationProcessIdentifier;
+		}
+
+		@Override
+		public void receiveCompletion(int[] completionIndex) {
+			if (completionIndex.length == 0)
+				// Final result, clean up monitor state
+				monMan.deregisterNode(invocationProcessIdentifier);
+			if (sentJob) {
+				int[] newIndex;
+				if (completionIndex.length == 0)
+					newIndex = jobEvent.getIndex();
+				else {
+					newIndex = new int[jobEvent.getIndex().length
+							+ completionIndex.length];
+					int i = 0;
+					for (int indexValue : jobEvent.getIndex())
+						newIndex[i++] = indexValue;
+					for (int indexValue : completionIndex)
+						newIndex[i++] = indexValue;
+				}
+				DispatchCompletionEvent c = new DispatchCompletionEvent(
+						jobEvent.getOwningProcess(), newIndex, jobEvent
+								.getContext());
+				getAbove().receiveResultCompletion(c);
+			} else {
+				/*
+				 * We haven't sent any 'real' data prior to completing a stream.
+				 * This in effect means we're sending an empty top level
+				 * collection so we need to register empty collections for each
+				 * output port with appropriate depth (by definition if we're
+				 * streaming all outputs are collection types of some kind)
+				 */
+				Map<String, T2Reference> emptyListMap = new HashMap<>();
+				for (OutputPort op : activity.getOutputPorts()) {
+					String portName = op.getName();
+					int portDepth = op.getDepth();
+					emptyListMap.put(portName, refService.getListService()
+							.registerEmptyList(portDepth, jobEvent.getContext()).getId());
+				}
+				receiveResult(emptyListMap, new int[0]);
+			}
+		}
+
+		@Override
+		public void receiveResult(Map<String, T2Reference> data, int[] index) {
+			/*
+			 * Construct a new result map using the activity mapping (activity
+			 * output name to processor output name)
+			 */
+			Map<String, T2Reference> resultMap = new HashMap<>();
+			for (String outputName : data.keySet()) {
+				String processorOutputName = activity
+						.getOutputPortMapping().get(outputName);
+				if (processorOutputName != null)
+					resultMap.put(processorOutputName, data.get(outputName));
+			}
+			/*
+			 * Construct a new index array if the specified index is non zero
+			 * length, otherwise just use the original job's index array (means
+			 * we're not streaming)
+			 */
+			int[] newIndex;
+			boolean streaming = false;
+			if (index.length == 0)
+				newIndex = jobEvent.getIndex();
+			else {
+				streaming = true;
+				newIndex = new int[jobEvent.getIndex().length + index.length];
+				int i = 0;
+				for (int indexValue : jobEvent.getIndex())
+					newIndex[i++] = indexValue;
+				for (int indexValue : index)
+					newIndex[i++] = indexValue;
+			}
+			DispatchResultEvent resultEvent = new DispatchResultEvent(jobEvent
+					.getOwningProcess(), newIndex, jobEvent.getContext(),
+					resultMap, streaming);
+			if (!streaming) {
+				monMan.registerNode(resultEvent, invocationProcessIdentifier,
+						new HashSet<MonitorableProperty<?>>());
+				// Final result, clean up monitor state
+				monMan.deregisterNode(invocationProcessIdentifier);
+			}
+			// Push the modified data to the layer above in the dispatch stack
+			getAbove().receiveResult(resultEvent);
+
+			sentJob = true;
+		}
+
+		@Override
+		public void requestRun(Runnable runMe) {
+			String newThreadName = jobEvent.toString();
+			Thread thread = new Thread(runMe, newThreadName);
+			thread.setContextClassLoader(activity.getClass()
+					.getClassLoader());
+			thread.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
+				@Override
+				public void uncaughtException(Thread t, Throwable e) {
+					fail("Uncaught exception while invoking " + activity, e);
+				}
+			});
+			thread.start();
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Loop.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Loop.java b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Loop.java
new file mode 100644
index 0000000..bd85fab
--- /dev/null
+++ b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Loop.java
@@ -0,0 +1,423 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.layers;
+
+import java.lang.Thread.UncaughtExceptionHandler;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.reference.ReferenceService;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.workflowmodel.Processor;
+import org.apache.taverna.workflowmodel.processor.activity.AbstractAsynchronousActivity;
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+import org.apache.taverna.workflowmodel.processor.activity.ActivityInputPort;
+import org.apache.taverna.workflowmodel.processor.activity.AsynchronousActivityCallback;
+import org.apache.taverna.workflowmodel.processor.dispatch.AbstractDispatchLayer;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.AbstractDispatchEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchCompletionEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchErrorEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchErrorType;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchJobEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchJobQueueEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchResultEvent;
+
+import org.apache.log4j.Logger;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+
+/**
+ * A layer that allows while-style loops.
+ * <p>
+ * The layer is configured with a {@link LoopConfiguration}, where an activity
+ * has been set as the
+ * {@link LoopConfiguration#setCondition(org.apache.taverna.workflowmodel.processor.activity.Activity)
+ * condition}.
+ * <p>
+ * After a job has been successful further down the dispatch stack, the loop
+ * layer will invoke the conditional activity to determine if the job will be
+ * invoked again. If {@link LoopConfiguration#isRunFirst()} is false, this test
+ * will be performed even before the first invocation. (The default
+ * runFirst=true is equivalent to a do..while construct, while runFirst=false is
+ * equivalent to a while.. construct.)
+ * <p>
+ * A job will be resent down the dispatch stack only if the conditional activity
+ * returns a reference to a string equal to "true" on its output port "loop".
+ * <p>
+ * If a job or the conditional activity fails, the while-loop is interrupted and
+ * the error is sent further up.
+ * <p>
+ * Note that the LoopLayer will be invoked for each item in an iteration, if you
+ * want to do the loop for the whole collection (ie. re-iterating if the
+ * loop-condition fails after processing the full list) - create a nested
+ * workflow with the desired depths on it's input ports and insert this
+ * LoopLayer in the stack of the nested workflow's processor in parent workflow.
+ * <p>
+ * It is recommended that the LoopLayer is to be inserted after the
+ * {@link ErrorBounce} layer, as this layer is needed for registering errors
+ * produced by the LoopLayer. If the user requires {@link Retry retries} and
+ * {@link Failover failovers} before checking the while condition, such layers
+ * should be below LoopLayer.
+ *
+ * @author Stian Soiland-Reyes
+ */
+// FIXME Doesn't work
+@SuppressWarnings({"unchecked","rawtypes"})
+public class Loop extends AbstractDispatchLayer<JsonNode> {
+	public static final String URI = "http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/Loop";
+	private static Logger logger = Logger.getLogger(Loop.class);
+
+	private JsonNode config = JsonNodeFactory.instance.objectNode();
+
+	protected Map<String, AbstractDispatchEvent> incomingJobs = new HashMap<>();
+	protected Map<String, AbstractDispatchEvent> outgoingJobs = new HashMap<>();
+
+	@Override
+	public void configure(JsonNode config) {
+		this.config = config;
+	}
+
+	@Override
+	public void finishedWith(String owningProcess) {
+		String prefix = owningProcess + "[";
+		synchronized (outgoingJobs) {
+			for (String key : new ArrayList<>(outgoingJobs.keySet()))
+				if (key.startsWith(prefix))
+					outgoingJobs.remove(key);
+		}
+		synchronized (incomingJobs) {
+			for (String key : new ArrayList<>(incomingJobs.keySet()))
+				if (key.startsWith(prefix))
+					incomingJobs.remove(key);
+		}
+	}
+
+	@Override
+	public JsonNode getConfiguration() {
+		return config;
+	}
+
+	@Override
+	public void receiveJob(DispatchJobEvent jobEvent) {
+		synchronized (incomingJobs) {
+			incomingJobs.put(jobIdentifier(jobEvent), jobEvent);
+		}
+		if (config.get("runFirst").asBoolean()) {
+			// We'll do the conditional in receiveResult instead
+			super.receiveJob(jobEvent);
+			return;
+		}
+		checkCondition(jobEvent);
+	}
+
+	@Override
+	public void receiveJobQueue(DispatchJobQueueEvent jobQueueEvent) {
+		synchronized (incomingJobs) {
+			incomingJobs.put(jobIdentifier(jobQueueEvent), jobQueueEvent);
+		}
+		if (config.get("runFirst").asBoolean()) {
+			// We'll do the conditional in receiveResult instead
+			super.receiveJobQueue(jobQueueEvent);
+			return;
+		}
+		checkCondition(jobQueueEvent);
+	}
+	
+	private Activity<?> getCondition() {
+		//return config.getCondition();
+		return null;
+	}
+
+	@Override
+	public void receiveResult(DispatchResultEvent resultEvent) {
+		Activity<?> condition = getCondition();
+		if (condition == null) {
+			super.receiveResult(resultEvent);
+			return;
+		}
+		synchronized (outgoingJobs) {
+			outgoingJobs.put(jobIdentifier(resultEvent), resultEvent);
+		}
+		checkCondition(resultEvent);
+	}
+
+	@Override
+	public void receiveResultCompletion(DispatchCompletionEvent completionEvent) {
+		Activity<?> condition = getCondition();
+		if (condition == null) {
+			super.receiveResultCompletion(completionEvent);
+			return;
+		}
+		synchronized (outgoingJobs) {
+			outgoingJobs.put(jobIdentifier(completionEvent), completionEvent);
+		}
+		checkCondition(completionEvent);
+	}
+
+	private void checkCondition(AbstractDispatchEvent event) {
+		Activity<?> condition = getCondition();
+		if (condition == null) {
+			super.receiveError(new DispatchErrorEvent(event.getOwningProcess(),
+					event.getIndex(), event.getContext(),
+					"Can't invoke condition service: null", null,
+					DispatchErrorType.INVOCATION, condition));
+			return;
+		}
+		if (!(condition instanceof AbstractAsynchronousActivity)) {
+			DispatchErrorEvent errorEvent = new DispatchErrorEvent(
+					event.getOwningProcess(),
+					event.getIndex(),
+					event.getContext(),
+					"Can't invoke condition service "
+							+ condition
+							+ " is not an instance of AbstractAsynchronousActivity",
+					null, DispatchErrorType.INVOCATION, condition);
+			super.receiveError(errorEvent);
+			return;
+		}
+		AbstractAsynchronousActivity asyncCondition = (AbstractAsynchronousActivity) condition;
+		String jobIdentifier = jobIdentifier(event);
+		Map<String, T2Reference> inputs = prepareInputs(asyncCondition,
+				jobIdentifier);
+		AsynchronousActivityCallback callback = new ConditionCallBack(
+				jobIdentifier);
+		asyncCondition.executeAsynch(inputs, callback);
+	}
+
+	private Map<String, T2Reference> prepareInputs(
+			AbstractAsynchronousActivity asyncCondition, String jobIdentifier) {
+		Map<String, T2Reference> inputs = new HashMap<>();
+		Map<String, T2Reference> inData = getInData(jobIdentifier);
+		Map<String, T2Reference> outData = getOutData(jobIdentifier);
+
+		Set<ActivityInputPort> inputPorts = asyncCondition.getInputPorts();
+		for (ActivityInputPort conditionIn : inputPorts) {
+			String conditionPort = conditionIn.getName();
+			if (outData.containsKey(conditionPort))
+				// Copy from previous output
+				inputs.put(conditionPort, outData.get(conditionPort));
+			else if (inData.containsKey(conditionPort))
+				// Copy from original input
+				inputs.put(conditionPort, inData.get(conditionPort));
+		}
+		return inputs;
+	}
+
+	private Map<String, T2Reference> getInData(String jobIdentifier) {
+		AbstractDispatchEvent inEvent;
+		synchronized (incomingJobs) {
+			inEvent = incomingJobs.get(jobIdentifier);
+		}
+		Map<String, T2Reference> inData = new HashMap<>();
+		if (inEvent instanceof DispatchJobEvent)
+			inData = ((DispatchJobEvent) inEvent).getData();
+		return inData;
+	}
+
+	private Map<String, T2Reference> getOutData(String jobIdentifier) {
+		AbstractDispatchEvent outEvent;
+		synchronized (outgoingJobs) {
+			outEvent = outgoingJobs.get(jobIdentifier);
+		}
+		Map<String, T2Reference> outData = new HashMap<>();
+		if (outEvent instanceof DispatchResultEvent)
+			outData = ((DispatchResultEvent) outEvent).getData();
+		return outData;
+	}
+
+	private String jobIdentifier(AbstractDispatchEvent event) {
+		String jobId = event.getOwningProcess()
+				+ Arrays.toString(event.getIndex());
+		return jobId;
+	}
+
+	public static final String LOOP_PORT = "loop";
+
+	public class ConditionCallBack implements AsynchronousActivityCallback {
+		private InvocationContext context;
+		private final String jobIdentifier;
+		private String processId;
+
+		public ConditionCallBack(String jobIdentifier) {
+			this.jobIdentifier = jobIdentifier;
+			AbstractDispatchEvent originalEvent;
+			synchronized (incomingJobs) {
+				originalEvent = incomingJobs.get(jobIdentifier);
+			}
+			context = originalEvent.getContext();
+			processId = originalEvent.getOwningProcess() + ":condition";
+		}
+
+		@Override
+		public void fail(String message) {
+			fail(message, null, DispatchErrorType.INVOCATION);
+		}
+
+		@Override
+		public void fail(String message, Throwable t) {
+			fail(message, t, DispatchErrorType.INVOCATION);
+		}
+
+		@Override
+		public void fail(String message, Throwable t,
+				DispatchErrorType errorType) {
+			logger.warn("Failed (" + errorType + ") invoking condition service "
+					+ jobIdentifier + ":" + message, t);
+
+			AbstractDispatchEvent originalEvent;
+			synchronized (incomingJobs) {
+				originalEvent = incomingJobs.get(jobIdentifier);
+			}
+			receiveError(new DispatchErrorEvent(originalEvent
+					.getOwningProcess(), originalEvent.getIndex(),
+					originalEvent.getContext(),
+					"Can't invoke condition service ", t,
+					DispatchErrorType.INVOCATION, null));
+		}
+
+		@Override
+		public InvocationContext getContext() {
+			return context;
+		}
+
+		@Override
+		public String getParentProcessIdentifier() {
+			return processId;
+		}
+
+		@Override
+		public void receiveCompletion(int[] completionIndex) {
+			// Ignore streaming
+		}
+
+		@Override
+		public void receiveResult(Map<String, T2Reference> data, int[] index) {
+			if (index.length > 0) {
+				// Ignore streaming
+				return;
+			}
+			T2Reference loopRef = data.get(LOOP_PORT);
+			if (loopRef == null) {
+				fail("Condition service didn't contain output port " + LOOP_PORT);
+				return;
+			}
+			if (loopRef.containsErrors()) {
+				fail("Condition service failed: " + loopRef);
+				return;
+			}
+			if (loopRef.getDepth() != 0) {
+				fail("Condition service output " + LOOP_PORT
+						+ " depth is not 0, but " + loopRef.getDepth());
+			}
+			ReferenceService referenceService = context.getReferenceService();
+			String loop = (String) referenceService.renderIdentifier(loopRef,
+					String.class, context);
+
+			if (Boolean.parseBoolean(loop)) {
+				// Push it down again
+				AbstractDispatchEvent dispatchEvent;
+				synchronized (incomingJobs) {
+					dispatchEvent = incomingJobs.get(jobIdentifier);
+				}
+				if (dispatchEvent == null) {
+					fail("Unknown job identifier " + jobIdentifier);
+				}
+				if (dispatchEvent instanceof DispatchJobEvent) {
+					DispatchJobEvent newJobEvent = prepareNewJobEvent(data,
+							dispatchEvent);
+					getBelow().receiveJob(newJobEvent);
+				} else if (dispatchEvent instanceof DispatchJobQueueEvent) {
+					getBelow().receiveJobQueue(
+							(DispatchJobQueueEvent) dispatchEvent);
+				} else {
+					fail("Unknown type of incoming event " + dispatchEvent);
+				}
+				return;
+
+			} else {
+				// We'll push it up, end of loop for now
+
+				AbstractDispatchEvent outgoingEvent;
+				synchronized (outgoingJobs) {
+					outgoingEvent = outgoingJobs.get(jobIdentifier);
+				}
+				if (outgoingEvent == null && !config.get("runFirst").asBoolean()) {
+					fail("Initial loop condition failed");
+				}
+				if (outgoingEvent instanceof DispatchCompletionEvent) {
+					getAbove().receiveResultCompletion(
+							(DispatchCompletionEvent) outgoingEvent);
+				} else if (outgoingEvent instanceof DispatchResultEvent) {
+					getAbove().receiveResult(
+							(DispatchResultEvent) outgoingEvent);
+				} else {
+					fail("Unknown type of outgoing event " + outgoingEvent);
+				}
+			}
+
+		}
+
+		private DispatchJobEvent prepareNewJobEvent(
+				Map<String, T2Reference> data,
+				AbstractDispatchEvent dispatchEvent) {
+			DispatchJobEvent dispatchJobEvent = (DispatchJobEvent) dispatchEvent;
+			Map<String, T2Reference> newInputs = new HashMap<String, T2Reference>(
+					dispatchJobEvent.getData());
+			newInputs.putAll(data);
+			DispatchJobEvent newJobEvent = new DispatchJobEvent(dispatchEvent
+					.getOwningProcess(), dispatchEvent.getIndex(),
+					dispatchEvent.getContext(), newInputs,
+					((DispatchJobEvent) dispatchEvent).getActivities());
+			/*
+			 * TODO: Should this be registered as an incomingJobs? If so the
+			 * conditional could even feed to itself, and we should also keep a
+			 * list of originalJobs.
+			 */
+			return newJobEvent;
+		}
+
+		@Override
+		public void requestRun(Runnable runMe) {
+			String newThreadName = "Condition service "
+					+ getParentProcessIdentifier();
+			Thread thread = new Thread(runMe, newThreadName);
+			thread.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
+				@Override
+				public void uncaughtException(Thread t, Throwable e) {
+					fail("Uncaught exception while invoking " + jobIdentifier,
+							e);
+				}
+			});
+			thread.start();
+		}
+	}
+
+	@Override
+	public Processor getProcessor() {
+		if (dispatchStack == null)
+			return null;
+		return dispatchStack.getProcessor();
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/LoopConfiguration.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/LoopConfiguration.java b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/LoopConfiguration.java
new file mode 100644
index 0000000..b98c551
--- /dev/null
+++ b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/LoopConfiguration.java
@@ -0,0 +1,94 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.layers;
+
+import java.util.Properties;
+
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+import org.apache.taverna.workflowmodel.processor.config.ConfigurationBean;
+import org.apache.taverna.workflowmodel.processor.config.ConfigurationProperty;
+
+/**
+ * Configuration bean for the {@link Loop}.
+ * <p>
+ * Set the {@link #setCondition(Activity)} for an activity with an output port
+ * called "loop". The LoopLayer will re-send a job only if this port exist and
+ * it's output can be dereferenced to a string equal to "true".
+ * </p>
+ * <p>
+ * If {@link #isRunFirst()} is false, the loop layer will check the condition
+ * before invoking the job for the first time, otherwise the condition will be
+ * invoked after the job has come back with successful results.
+ * </p>
+ * 
+ * @author Stian Soiland-Reyes
+ * 
+ */
+@ConfigurationBean(uri = Loop.URI + "#Config")
+public class LoopConfiguration implements Cloneable {
+	private Activity<?> condition = null;
+	private Boolean runFirst;
+	private Properties properties;
+
+	public Properties getProperties() {
+		synchronized (this) {
+			if (properties == null)
+				properties = new Properties();
+		}
+		return properties;
+	}
+
+	public void setProperties(Properties properties) {
+		this.properties = properties;
+	}
+
+	@Override
+	public LoopConfiguration clone() {
+		LoopConfiguration clone;
+		try {
+			clone = (LoopConfiguration) super.clone();
+			clone.condition = null;
+		} catch (CloneNotSupportedException e) {
+			throw new RuntimeException("Unexpected CloneNotSupportedException",
+					e);
+		}
+		return clone;
+	}
+
+	public Activity<?> getCondition() {
+		return condition;
+	}
+
+	public boolean isRunFirst() {
+		if (runFirst == null)
+			return true;
+		return runFirst;
+	}
+
+	@ConfigurationProperty(name = "condition", label = "Condition Activity", description = "The condition activity with an output port called \"loop\"", required = false)
+	public void setCondition(Activity<?> activity) {
+		this.condition = activity;
+	}
+
+	@ConfigurationProperty(name = "runFirst", label = "Check Condition On Run First", description = "Whether to check the condition before invoking the job for the first time", required = false)
+	public void setRunFirst(boolean runFirst) {
+		this.runFirst = runFirst;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Parallelize.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Parallelize.java b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Parallelize.java
new file mode 100644
index 0000000..428dc5f
--- /dev/null
+++ b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Parallelize.java
@@ -0,0 +1,462 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.layers;
+
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.CREATE_PROCESS_STATE;
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.NO_EFFECT;
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.REMOVE_PROCESS_STATE;
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchMessageType.JOB;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.TimerTask;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import org.apache.taverna.invocation.Completion;
+import org.apache.taverna.invocation.IterationInternalEvent;
+import org.apache.taverna.monitor.MonitorManager;
+import org.apache.taverna.monitor.MonitorableProperty;
+import org.apache.taverna.monitor.NoSuchPropertyException;
+import org.apache.taverna.workflowmodel.WorkflowStructureException;
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+import org.apache.taverna.workflowmodel.processor.activity.Job;
+import org.apache.taverna.workflowmodel.processor.dispatch.AbstractDispatchLayer;
+import org.apache.taverna.workflowmodel.processor.dispatch.NotifiableLayer;
+import org.apache.taverna.workflowmodel.processor.dispatch.PropertyContributingDispatchLayer;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerErrorReaction;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerJobQueueReaction;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerResultCompletionReaction;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerResultReaction;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.SupportsStreamedResult;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchCompletionEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchErrorEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchJobEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchJobQueueEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchResultEvent;
+
+import org.apache.log4j.Logger;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * Dispatch layer which consumes a queue of events and fires off a fixed number
+ * of simultaneous jobs to the layer below. It observes failure, data and
+ * completion events coming up and uses these to determine when to push more
+ * jobs downwards into the stack as well as when it can safely emit completion
+ * events from the queue.
+ *
+ * @author Tom Oinn
+ *
+ */
+@DispatchLayerErrorReaction(emits = {}, relaysUnmodified = true, stateEffects = {
+		REMOVE_PROCESS_STATE, NO_EFFECT })
+@DispatchLayerJobQueueReaction(emits = { JOB }, relaysUnmodified = false, stateEffects = { CREATE_PROCESS_STATE })
+@DispatchLayerResultReaction(emits = {}, relaysUnmodified = true, stateEffects = {
+		REMOVE_PROCESS_STATE, NO_EFFECT })
+@DispatchLayerResultCompletionReaction(emits = {}, relaysUnmodified = true, stateEffects = {
+		REMOVE_PROCESS_STATE, NO_EFFECT })
+@SupportsStreamedResult
+public class Parallelize extends AbstractDispatchLayer<JsonNode>
+		implements NotifiableLayer,
+		PropertyContributingDispatchLayer<JsonNode> {
+	public static final String URI = "http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/Parallelize";
+	private static Logger logger = Logger.getLogger(Parallelize.class);
+
+	private Map<String, StateModel> stateMap = new HashMap<>();
+	private JsonNode config = JsonNodeFactory.instance.objectNode();
+	int sentJobsCount = 0;
+	int completedJobsCount = 0;
+
+	public Parallelize() {
+		super();
+	}
+
+	/**
+	 * Test constructor, only used by unit tests, should probably not be public
+	 * access here?
+	 *
+	 * @param maxJobs
+	 */
+	public Parallelize(int maxJobs) {
+		super();
+		((ObjectNode)config).put("maxJobs", maxJobs);
+	}
+
+	@Override
+	public void eventAdded(String owningProcess) {
+		StateModel stateModel;
+		synchronized (stateMap) {
+			stateModel = stateMap.get(owningProcess);
+		}
+		if (stateModel == null)
+			/*
+			 * Should never see this here, it means we've had duplicate
+			 * completion events from upstream
+			 */
+			throw new WorkflowStructureException(
+					"Unknown owning process " + owningProcess);
+		synchronized (stateModel) {
+			stateModel.fillFromQueue();
+		}
+	}
+
+	@Override
+	public void receiveJobQueue(DispatchJobQueueEvent queueEvent) {
+		StateModel model = new StateModel(queueEvent,
+				config.has("maxJobs") ? config.get("maxJobs").intValue() : 1);
+		synchronized (stateMap) {
+			stateMap.put(queueEvent.getOwningProcess(), model);
+		}
+		model.fillFromQueue();
+	}
+
+	public void receiveJob(Job job, List<? extends Activity<?>> activities) {
+		throw new WorkflowStructureException(
+				"Parallelize layer cannot handle job events");
+	}
+
+	@Override
+	public void receiveError(DispatchErrorEvent errorEvent) {
+		StateModel model;
+		String owningProcess = errorEvent.getOwningProcess();
+		synchronized(stateMap) {
+			model = stateMap.get(owningProcess);
+		}
+		if (model == null) {
+			logger.warn("Error received for unknown owning process: " + owningProcess);
+			return;
+		}
+		model.finishWith(errorEvent.getIndex());
+		getAbove().receiveError(errorEvent);
+	}
+
+	@Override
+	public void receiveResult(DispatchResultEvent resultEvent) {
+		StateModel model;
+		String owningProcess = resultEvent.getOwningProcess();
+		synchronized(stateMap) {
+			model = stateMap.get(owningProcess);
+		}
+		if (model == null) {
+			logger.warn("Error received for unknown owning process: " + owningProcess);
+			return;
+		}
+		if (!resultEvent.isStreamingEvent()) {
+			MonitorManager.getInstance().registerNode(resultEvent,
+					owningProcess,
+					new HashSet<MonitorableProperty<?>>());
+		}
+		model.finishWith(resultEvent.getIndex());
+		getAbove().receiveResult(resultEvent);
+	}
+
+	/**
+	 * Only going to receive this if the activity invocation was streaming, in
+	 * which case we need to handle all completion events and pass them up the
+	 * stack.
+	 */
+	@Override
+	public void receiveResultCompletion(DispatchCompletionEvent completionEvent) {
+		StateModel model;
+		String owningProcess = completionEvent.getOwningProcess();
+		synchronized(stateMap) {
+			model = stateMap.get(owningProcess);
+		}
+		if (model == null) {
+			logger.warn("Error received for unknown owning process: " + owningProcess);
+			return;
+		}
+		model.finishWith(completionEvent.getIndex());
+		getAbove().receiveResultCompletion(completionEvent);
+	}
+
+	@Override
+	public void finishedWith(final String owningProcess) {
+		// Delay the removal of the state to give the monitor a chance to poll
+		cleanupTimer.schedule(new TimerTask() {
+			@Override
+			public void run() {
+				synchronized(stateMap) {
+					stateMap.remove(owningProcess);
+				}
+			}
+		}, CLEANUP_DELAY_MS);
+	}
+
+	@Override
+	public void configure(JsonNode config) {
+		this.config = config;
+	}
+
+	@Override
+	public JsonNode getConfiguration() {
+		return this.config;
+	}
+
+	/**
+	 * Injects the following properties into its parent processor's property set:
+	 * <ul>
+	 * <li><code>dispatch.parallelize.queuesize [Integer]</code><br/>The current
+	 * size of the incomming job queue, or -1 if the state isn't defined for the
+	 * registered process identifier (which will be the case if the process
+	 * hasn't started or has had its state purged after a final completion of
+	 * some kind.</li>
+	 * </ul>
+	 */
+	@Override
+	public void injectPropertiesFor(final String owningProcess) {
+		/**
+		 * Property for the queue depth, will evaluate to -1 if there isn't a
+		 * queue in the state model for this identifier (which will be the case
+		 * if we haven't created the state yet or the queue has been collected)
+		 */
+		MonitorableProperty<Integer> queueSizeProperty = new MonitorableProperty<Integer>() {
+			@Override
+			public Date getLastModified() {
+				return new Date();
+			}
+
+			@Override
+			public String[] getName() {
+				return new String[] { "dispatch", "parallelize", "queuesize" };
+			}
+
+			@Override
+			public Integer getValue() throws NoSuchPropertyException {
+				StateModel model;
+				synchronized(stateMap) {
+					model = stateMap.get(owningProcess);
+				}
+				if (model == null)
+					return -1;
+				return model.queueSize();
+			}
+		};
+		dispatchStack.receiveMonitorableProperty(queueSizeProperty,
+				owningProcess);
+
+		MonitorableProperty<Integer> sentJobsProperty = new MonitorableProperty<Integer>() {
+			@Override
+			public Date getLastModified() {
+				return new Date();
+			}
+
+			@Override
+			public String[] getName() {
+				return new String[] { "dispatch", "parallelize", "sentjobs" };
+			}
+
+			@Override
+			public Integer getValue() throws NoSuchPropertyException {
+				return sentJobsCount;
+			}
+		};
+		dispatchStack.receiveMonitorableProperty(sentJobsProperty,
+				owningProcess);
+
+		MonitorableProperty<Integer> completedJobsProperty = new MonitorableProperty<Integer>() {
+			@Override
+			public Date getLastModified() {
+				return new Date();
+			}
+
+			@Override
+			public String[] getName() {
+				return new String[] { "dispatch", "parallelize",
+						"completedjobs" };
+			}
+
+			@Override
+			public Integer getValue() throws NoSuchPropertyException {
+				return completedJobsCount;
+			}
+		};
+		dispatchStack.receiveMonitorableProperty(completedJobsProperty,
+				owningProcess);
+	}
+
+	/**
+	 * Holds the state for a given owning process
+	 *
+	 * @author Tom Oinn
+	 *
+	 */
+	// suppressed to avoid jdk1.5 error messages caused by the declaration
+	// IterationInternalEvent<? extends IterationInternalEvent<?>> e
+	@SuppressWarnings("rawtypes")
+	class StateModel {
+		private DispatchJobQueueEvent queueEvent;
+		private BlockingQueue<IterationInternalEvent> pendingEvents = new LinkedBlockingQueue<>();
+		private int activeJobs = 0;
+		private int maximumJobs;
+
+		/**
+		 * Construct state model for a particular owning process
+		 *
+		 * @param owningProcess
+		 *            Process to track parallel execution
+		 * @param queue
+		 *            reference to the queue into which jobs are inserted by the
+		 *            iteration strategy
+		 * @param activities
+		 *            activities to pass along with job events down into the
+		 *            stack below
+		 * @param maxJobs
+		 *            maximum number of concurrent jobs to keep 'hot' at any
+		 *            given point
+		 */
+		protected StateModel(DispatchJobQueueEvent queueEvent, int maxJobs) {
+			this.queueEvent = queueEvent;
+			this.maximumJobs = maxJobs;
+		}
+
+		Integer queueSize() {
+			return queueEvent.getQueue().size();
+		}
+
+		/**
+		 * Poll the queue repeatedly until either the queue is empty or we have
+		 * enough jobs pulled from it. The semantics for this are:
+		 * <ul>
+		 * <li>If the head of the queue is a Job and activeJobs < maximumJobs
+		 * then increment activeJobs, add the Job to the pending events list at
+		 * the end and send the message down the stack
+		 * <li>If the head of the queue is a Completion and the pending jobs
+		 * list is empty then send it to the layer above
+		 * <li>If the head of the queue is a Completion and the pending jobs
+		 * list is not empty then add the Completion to the end of the pending
+		 * jobs list and return
+		 * </ul>
+		 */
+		protected void fillFromQueue() {
+			synchronized (this) {
+				while (queueEvent.getQueue().peek() != null
+						&& activeJobs < maximumJobs) {
+					final IterationInternalEvent e = queueEvent.getQueue()
+							.remove();
+
+					if (e instanceof Completion && pendingEvents.peek() == null) {
+						new Thread(new Runnable() {
+							@Override
+							public void run() {
+								getAbove().receiveResultCompletion(
+										new DispatchCompletionEvent(e
+												.getOwningProcess(), e
+												.getIndex(), e.getContext()));
+							}
+						}, "Parallelize " + e.getOwningProcess()).start();
+						// getAbove().receiveResultCompletion((Completion) e);
+					} else {
+						pendingEvents.add(e);
+					}
+					if (e instanceof Job) {
+						synchronized (this) {
+							activeJobs++;
+						}
+						sentJobsCount++;
+
+						DispatchJobEvent dispatchJobEvent = new DispatchJobEvent(e
+								.getOwningProcess(), e
+								.getIndex(), e.getContext(),
+								((Job) e).getData(), queueEvent
+										.getActivities());
+						// Register with the monitor
+						MonitorManager.getInstance().registerNode(dispatchJobEvent,
+								e.getOwningProcess(),
+								new HashSet<MonitorableProperty<?>>());
+
+						getBelow().receiveJob(dispatchJobEvent);
+					}
+				}
+			}
+		}
+
+		/**
+		 * Returns true if the index matched an existing Job exactly, if this
+		 * method returns false then you have a partial completion event which
+		 * should be sent up the stack without modification.
+		 *
+		 * @param index
+		 * @return
+		 */
+		protected boolean finishWith(int[] index) {
+			synchronized (this) {
+				for (IterationInternalEvent e : new ArrayList<>(pendingEvents)) {
+					if (!(e instanceof Job))
+						continue;
+					Job j = (Job) e;
+					if (!arrayEquals(j.getIndex(), index))
+						continue;
+
+					/*
+					 * Found a job in the pending events list which has the
+					 * same index, remove it and decrement the current count
+					 * of active jobs
+					 */
+					pendingEvents.remove(e);
+					activeJobs--;
+					completedJobsCount++;
+					/*
+					 * Now pull any completion events that have reached the head
+					 * of the queue - this indicates that all the job events
+					 * which came in before them have been processed and we can
+					 * emit the completions
+					 */
+					while (pendingEvents.peek() != null
+							&& pendingEvents.peek() instanceof Completion) {
+						Completion c = (Completion) pendingEvents.remove();
+						getAbove().receiveResultCompletion(
+								new DispatchCompletionEvent(c
+										.getOwningProcess(), c.getIndex(), c
+										.getContext()));
+					}
+					/*
+					 * Refresh from the queue; as we've just decremented the
+					 * active job count there should be a worker available
+					 */
+					fillFromQueue();
+					/*
+					 * Return true to indicate that we removed a job event from
+					 * the queue, that is to say that the index wasn't that of a
+					 * partial completion.
+					 */
+					return true;
+				}
+			}
+			return false;
+		}
+
+		private boolean arrayEquals(int[] a, int[] b) {
+			if (a.length != b.length)
+				return false;
+			for (int i = 0; i < a.length; i++)
+				if (a[i] != b[i])
+					return false;
+			return true;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/ParallelizeConfig.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/ParallelizeConfig.java b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/ParallelizeConfig.java
new file mode 100644
index 0000000..03418b1
--- /dev/null
+++ b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/ParallelizeConfig.java
@@ -0,0 +1,49 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.layers;
+
+import org.apache.taverna.workflowmodel.processor.config.ConfigurationBean;
+import org.apache.taverna.workflowmodel.processor.config.ConfigurationProperty;
+
+/**
+ * Bean to hold the configuration for the parallelize layer, specifically a
+ * single int property defining the number of concurrent jobs in that processor
+ * instance per owning process ID.
+ * 
+ * @author Tom Oinn
+ */
+@ConfigurationBean(uri = Parallelize.URI + "#Config")
+public class ParallelizeConfig {
+	private int maxJobs;
+
+	public ParallelizeConfig() {
+		super();
+		this.maxJobs = 1;
+	}
+
+	@ConfigurationProperty(name = "maxJobs", label = "Maximum Parallel Jobs", description = "The maximum number of jobs that can run in parallel", required = false)
+	public void setMaximumJobs(int maxJobs) {
+		this.maxJobs = maxJobs;
+	}
+
+	public int getMaximumJobs() {
+		return this.maxJobs;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Retry.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Retry.java b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Retry.java
new file mode 100644
index 0000000..c10209c
--- /dev/null
+++ b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Retry.java
@@ -0,0 +1,179 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.layers;
+
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.CREATE_LOCAL_STATE;
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.REMOVE_LOCAL_STATE;
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.UPDATE_LOCAL_STATE;
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchMessageType.JOB;
+
+import java.util.Iterator;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+import org.apache.taverna.workflowmodel.processor.dispatch.AbstractErrorHandlerLayer;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerErrorReaction;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerJobReaction;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerResultReaction;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchJobEvent;
+
+/**
+ * Implements retry policy with delay between retries and exponential backoff
+ * <p>
+ * Default properties are as follows :
+ * <ul>
+ * <li>maxRetries = 0 (int)</li>
+ * <li>initialDelay = 1000 (milliseconds)</li>
+ * <li>maxDelay = 2000 (milliseconds)</li>
+ * <li>backoffFactor = 1.0 (double)</li>
+ * </ul>
+ *
+ * @author Tom Oinn
+ * @author David Withers
+ * @author Stian Soiland-Reyes
+ */
+@DispatchLayerErrorReaction(emits = { JOB }, relaysUnmodified = true, stateEffects = {
+		UPDATE_LOCAL_STATE, REMOVE_LOCAL_STATE })
+@DispatchLayerJobReaction(emits = {}, relaysUnmodified = true, stateEffects = { CREATE_LOCAL_STATE })
+@DispatchLayerResultReaction(emits = {}, relaysUnmodified = true, stateEffects = { REMOVE_LOCAL_STATE })
+public class Retry extends AbstractErrorHandlerLayer<JsonNode> {
+	private static final String BACKOFF_FACTOR = "backoffFactor";
+    private static final String MAX_DELAY = "maxDelay";
+    private static final String MAX_RETRIES = "maxRetries";
+    private static final String INITIAL_DELAY = "initialDelay";
+    public static final String URI = "http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/Retry";
+
+	private ObjectNode config;
+    private int maxRetries;
+    private int initialDelay;
+    private int maxDelay;
+    private double backoffFactor;
+
+	private static Timer retryTimer = new Timer("Retry timer", true);
+
+	public Retry() {
+		super();
+		configure(JsonNodeFactory.instance.objectNode());
+	}
+
+	public Retry(int maxRetries, int initialDelay, int maxDelay,
+			double backoffFactor) {
+		super();
+		ObjectNode conf = JsonNodeFactory.instance.objectNode();
+		conf.put(MAX_RETRIES, maxRetries);
+		conf.put(INITIAL_DELAY, initialDelay);
+		conf.put(MAX_DELAY, maxDelay);
+		conf.put(BACKOFF_FACTOR, backoffFactor);
+		configure(conf);
+	}
+
+	class RetryState extends JobState {
+		int currentRetryCount = 0;
+
+		public RetryState(DispatchJobEvent jobEvent) {
+			super(jobEvent);
+		}
+
+		/**
+		 * Try to schedule a retry, returns true if a retry is scheduled, false
+		 * if the retry count has already been reached (in which case no retry
+		 * is scheduled
+		 *
+		 * @return
+		 */
+		@Override
+		public boolean handleError() {
+			if (currentRetryCount >= maxRetries)
+				return false;
+			int delay = (int) (initialDelay * Math.pow(backoffFactor, currentRetryCount));
+			delay = Math.min(delay, maxDelay);
+			TimerTask task = new TimerTask() {
+				@Override
+				public void run() {
+					currentRetryCount++;
+					getBelow().receiveJob(jobEvent);
+				}
+			};
+			retryTimer.schedule(task, delay);
+			return true;
+		}
+	}
+
+	@Override
+	protected JobState getStateObject(DispatchJobEvent jobEvent) {
+		return new RetryState(jobEvent);
+	}
+
+	@Override
+	public void configure(JsonNode config) {
+	    ObjectNode defaultConfig = defaultConfig();
+        setAllMissingFields((ObjectNode) config, defaultConfig);
+        checkConfig((ObjectNode)config);
+        this.config = (ObjectNode) config;
+        maxRetries = config.get(MAX_RETRIES).intValue();
+        initialDelay = config.get(INITIAL_DELAY).intValue();
+        maxDelay = config.get(MAX_DELAY).intValue();
+        backoffFactor = config.get(BACKOFF_FACTOR).doubleValue();       
+	}
+
+    private void setAllMissingFields(ObjectNode config, ObjectNode defaults) {
+        for (String fieldName : forEach(defaults.fieldNames()))
+	        if (! config.has(fieldName) || config.get(fieldName).isNull())
+	            config.put(fieldName, defaults.get(fieldName));
+    }
+
+	private <T> Iterable<T> forEach(final Iterator<T> iterator) {
+	    return new Iterable<T>() {
+            @Override
+            public Iterator<T> iterator() {
+                return iterator;
+            }
+        };
+    }
+
+    private void checkConfig(ObjectNode conf) {
+        if (conf.get(MAX_RETRIES).intValue() < 0)
+            throw new IllegalArgumentException("maxRetries < 0");
+        if (conf.get(INITIAL_DELAY).intValue() < 0)
+            throw new IllegalArgumentException("initialDelay < 0");
+        if (conf.get(MAX_DELAY).intValue() < conf.get(INITIAL_DELAY).intValue())
+            throw new IllegalArgumentException("maxDelay < initialDelay");
+        if (conf.get(BACKOFF_FACTOR).doubleValue() < 0.0)
+            throw new IllegalArgumentException("backoffFactor < 0.0");
+    }
+
+    public static ObjectNode defaultConfig() {
+	    ObjectNode conf = JsonNodeFactory.instance.objectNode();
+	    conf.put(MAX_RETRIES, 0);
+	    conf.put(INITIAL_DELAY, 1000);
+	    conf.put(MAX_DELAY, 5000);
+	    conf.put(BACKOFF_FACTOR, 1.0);
+	    return conf;
+    }
+
+    @Override
+	public JsonNode getConfiguration() {
+		return this.config;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/RetryConfig.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/RetryConfig.java b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/RetryConfig.java
new file mode 100644
index 0000000..7a3780b
--- /dev/null
+++ b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/RetryConfig.java
@@ -0,0 +1,96 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.layers;
+
+import org.apache.taverna.workflowmodel.processor.config.ConfigurationBean;
+import org.apache.taverna.workflowmodel.processor.config.ConfigurationProperty;
+
+@ConfigurationBean(uri = Retry.URI + "#Config")
+public class RetryConfig {
+	private static final float BACKOFF_FACTOR = 1.0f;
+	private static final int MAX_DELAY = 5000;
+	private static final int INITIAL_DELAY = 1000;
+	private static final int MAX_RETRIES = 0;
+
+	private float backoffFactor = BACKOFF_FACTOR;
+	private int initialDelay = INITIAL_DELAY;
+	private int maxDelay = MAX_DELAY;
+	private int maxRetries = MAX_RETRIES;
+
+	/**
+	 * Factor by which the initial delay is multiplied for each retry after the
+	 * first, this allows for exponential backoff of retry times up to a certain
+	 * ceiling
+	 *
+	 * @return
+	 */
+	public float getBackoffFactor() {
+		return this.backoffFactor;
+	}
+
+	/**
+	 * Delay in milliseconds between the initial failure message and the first
+	 * attempt to retry the failed job
+	 *
+	 * @return
+	 */
+	public int getInitialDelay() {
+		return this.initialDelay;
+	}
+
+	/**
+	 * Maximum delay in milliseconds between failure reception and retry. This
+	 * acts as a ceiling for the exponential backoff factor allowing the retry
+	 * delay to initially increase to a certain value then remain constant after
+	 * that point rather than exploding to unreasonable levels.
+	 */
+	public int getMaxDelay() {
+		return this.maxDelay;
+	}
+
+	/**
+	 * Maximum number of retries for a failing process
+	 *
+	 * @return
+	 */
+	public int getMaxRetries() {
+		return this.maxRetries;
+	}
+
+	@ConfigurationProperty(name = "backoffFactor", label = "Backoff Factor", description = "Factor by which the initial delay is multiplied for each retry after the first retry", required=false)
+	public void setBackoffFactor(float factor) {
+		this.backoffFactor = factor;
+	}
+
+	@ConfigurationProperty(name = "initialDelay", label = "Initial Delay", description = "Delay in milliseconds between the initial failure message and the first attempt to retry the failed job", required=false)
+	public void setInitialDelay(int delay) {
+		this.initialDelay = delay;
+	}
+
+	@ConfigurationProperty(name = "maxDelay", label = "Maximum Delay", description = "Maximum delay in milliseconds between failure reception and retry", required=false)
+	public void setMaxDelay(int delay) {
+		this.maxDelay = delay;
+	}
+
+	@ConfigurationProperty(name = "maxRetries", label = "Maximum Retries", description = "Maximum number of retries for a failing process", required=false)
+	public void setMaxRetries(int max) {
+		this.maxRetries = max;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Stop.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Stop.java b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Stop.java
new file mode 100644
index 0000000..d4b2d98
--- /dev/null
+++ b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Stop.java
@@ -0,0 +1,179 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.layers;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.taverna.reference.WorkflowRunIdEntity;
+import org.apache.taverna.workflowmodel.ConfigurationException;
+import org.apache.taverna.workflowmodel.processor.dispatch.AbstractDispatchLayer;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchJobEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchJobQueueEvent;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * This layer allows for the cancellation, pausing and resuming of workflow
+ * runs. It does so by intercepting jobs sent to the layer.
+ *
+ * @author alanrw
+ */
+public class Stop extends AbstractDispatchLayer<JsonNode> {
+	public static final String URI = "http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/Stop";
+	/**
+	 * The set of ids of workflow runs that have been cancelled.
+	 */
+	private static Set<String> cancelledWorkflowRuns = new HashSet<>();
+	/**
+	 * A map from workflow run ids to the set of Stop layers where jobs have
+	 * been intercepted for that run.
+	 */
+	private static Map<String, Set<Stop>> pausedLayerMap = new HashMap<>();
+	/**
+	 * A map for a given Stop from ids of suspended workflow runs to the jobs
+	 * that have been intercepted.
+	 */
+	private Map<String, Set<DispatchJobEvent>> suspendedJobEventMap = new HashMap<>();
+
+	@Override
+	public void configure(JsonNode conf) throws ConfigurationException {
+		// nothing
+	}
+
+	@Override
+	public JsonNode getConfiguration() {
+		return null;
+	}
+
+	@Override
+	public void receiveJob(final DispatchJobEvent jobEvent) {
+		List<WorkflowRunIdEntity> entities = jobEvent.getContext().getEntities(
+				WorkflowRunIdEntity.class);
+		if (entities != null && !entities.isEmpty()) {
+			final String wfRunId = entities.get(0).getWorkflowRunId();
+			// If the workflow run is cancelled then simply "eat" the jobEvent.
+			// This does a hard-cancel.
+			if (cancelledWorkflowRuns.contains(wfRunId))
+				return;
+			// If the workflow run is paused
+			if (pausedLayerMap.containsKey(wfRunId))
+				synchronized (Stop.class) {
+					// double check as pausedLayerMap may have been changed
+					// waiting for the lock
+					if (pausedLayerMap.containsKey(wfRunId)) {
+						// Remember that this Stop layer was affected by the
+						// workflow pause
+						pausedLayerMap.get(wfRunId).add(this);
+						if (!suspendedJobEventMap.containsKey(wfRunId))
+							suspendedJobEventMap.put(wfRunId,
+									new HashSet<DispatchJobEvent>());
+						// Remember the suspended jobEvent
+						suspendedJobEventMap.get(wfRunId).add(jobEvent);
+						return;
+					}
+				}
+		}
+		// By default pass the jobEvent down to the next layer
+		super.receiveJob(jobEvent);
+	}
+
+	@Override
+	public void receiveJobQueue(DispatchJobQueueEvent jobQueueEvent) {
+		super.receiveJobQueue(jobQueueEvent);
+	}
+
+	/**
+	 * Cancel the workflow run with the specified id
+	 *
+	 * @param workflowRunId
+	 *            The id of the workflow run to cancel
+	 * @return If the workflow run was cancelled then true. If it was already
+	 *         cancelled then false.
+	 */
+	public static synchronized boolean cancelWorkflow(String workflowRunId) {
+		if (cancelledWorkflowRuns.contains(workflowRunId))
+			return false;
+		Set<String> cancelledWorkflowRunsCopy = new HashSet<>(
+				cancelledWorkflowRuns);
+		cancelledWorkflowRunsCopy.add(workflowRunId);
+		cancelledWorkflowRuns = cancelledWorkflowRunsCopy;
+		return true;
+	}
+
+	/**
+	 * Pause the workflow run with the specified id
+	 *
+	 * @param workflowRunId
+	 *            The id of the workflow run to pause
+	 * @return If the workflow run was paused then true. If it was already
+	 *         paused or cancelled then false.
+	 */
+	public static synchronized boolean pauseWorkflow(String workflowRunId) {
+		if (cancelledWorkflowRuns.contains(workflowRunId))
+			return false;
+		if (pausedLayerMap.containsKey(workflowRunId))
+			return false;
+		Map<String, Set<Stop>> pausedLayerMapCopy = new HashMap<>(pausedLayerMap);
+		pausedLayerMapCopy.put(workflowRunId, new HashSet<Stop>());
+		pausedLayerMap = pausedLayerMapCopy;
+		return true;
+	}
+
+	/**
+	 * Resume the workflow run with the specified id
+	 *
+	 * @param workflowRunId
+	 *            The id of the workflow run to resume
+	 * @return If the workflow run was resumed then true. If the workflow run
+	 *         was not paused or it was cancelled, then false.
+	 */
+	public static synchronized boolean resumeWorkflow(String workflowRunId) {
+		if (cancelledWorkflowRuns.contains(workflowRunId))
+			return false;
+		if (!pausedLayerMap.containsKey(workflowRunId))
+			return false;
+		Map<String, Set<Stop>> pausedLayerMapCopy = new HashMap<>();
+		pausedLayerMapCopy.putAll(pausedLayerMap);
+		Set<Stop> stops = pausedLayerMapCopy.remove(workflowRunId);
+		pausedLayerMap = pausedLayerMapCopy;
+		for (Stop s : stops)
+			s.resumeLayerWorkflow(workflowRunId);
+		return true;
+	}
+
+	/**
+	 * Resume the workflow run with the specified id on this Stop layer. This
+	 * method processes any suspended job events.
+	 *
+	 * @param workflowRunId
+	 *            The id of the workflow run to resume.
+	 */
+	private void resumeLayerWorkflow(String workflowRunId) {
+		synchronized (Stop.class) {
+			for (DispatchJobEvent dje : suspendedJobEventMap
+					.remove(workflowRunId))
+				receiveJob(dje);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/package.html b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/package.html
new file mode 100644
index 0000000..fe6e73f
--- /dev/null
+++ b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/package.html
@@ -0,0 +1,4 @@
+<body>
+Contains implementations of DispatchLayer defined by the core Taverna 2
+specification.
+</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/resources/META-INF/spring/workflowmodel-core-extensions-context-osgi.xml
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/resources/META-INF/spring/workflowmodel-core-extensions-context-osgi.xml b/taverna-workflowmodel-extensions/src/main/resources/META-INF/spring/workflowmodel-core-extensions-context-osgi.xml
index dc55fc7..8880144 100644
--- a/taverna-workflowmodel-extensions/src/main/resources/META-INF/spring/workflowmodel-core-extensions-context-osgi.xml
+++ b/taverna-workflowmodel-extensions/src/main/resources/META-INF/spring/workflowmodel-core-extensions-context-osgi.xml
@@ -6,6 +6,6 @@
                                  http://www.springframework.org/schema/osgi 
                                  http://www.springframework.org/schema/osgi/spring-osgi.xsd" >
 
-	<service ref="coreDispatchLayerFactory" interface="net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchLayerFactory" />
+	<service ref="coreDispatchLayerFactory" interface="org.apache.taverna.workflowmodel.processor.dispatch.DispatchLayerFactory" />
 
 </beans:beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/resources/META-INF/spring/workflowmodel-core-extensions-context.xml
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/resources/META-INF/spring/workflowmodel-core-extensions-context.xml b/taverna-workflowmodel-extensions/src/main/resources/META-INF/spring/workflowmodel-core-extensions-context.xml
index 90ed75f..0f9183e 100644
--- a/taverna-workflowmodel-extensions/src/main/resources/META-INF/spring/workflowmodel-core-extensions-context.xml
+++ b/taverna-workflowmodel-extensions/src/main/resources/META-INF/spring/workflowmodel-core-extensions-context.xml
@@ -4,6 +4,6 @@
 	xsi:schemaLocation="http://www.springframework.org/schema/beans 
                            http://www.springframework.org/schema/beans/spring-beans.xsd">
                            
-	<bean id="coreDispatchLayerFactory" class="net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.CoreDispatchLayerFactory" />
+	<bean id="coreDispatchLayerFactory" class="org.apache.taverna.workflowmodel.processor.dispatch.layers.CoreDispatchLayerFactory" />
 
 </beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/test/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/TestRetry.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/test/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/TestRetry.java b/taverna-workflowmodel-extensions/src/test/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/TestRetry.java
deleted file mode 100644
index e202df1..0000000
--- a/taverna-workflowmodel-extensions/src/test/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/TestRetry.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.layers;
-
-import org.junit.Test;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-import static org.junit.Assert.*;
-
-public class TestRetry {
-    
-    @Test
-    public void defaultConfig() throws Exception {
-        Retry retry = new Retry();
-        JsonNode configuration = retry.getConfiguration();
-        assertEquals(0, configuration.get("maxRetries").intValue());
-        assertEquals(1000, configuration.get("initialDelay").intValue());
-        assertEquals(5000, configuration.get("maxDelay").intValue());
-        assertEquals(1.0, configuration.get("backoffFactor").doubleValue(), 0.001);
-    }
-
-    @Test
-    public void customConfig() throws Exception {
-        Retry retry = new Retry(15, 150, 1200, 1.2);
-        JsonNode configuration = retry.getConfiguration();
-        assertEquals(15, configuration.get("maxRetries").intValue());
-        assertEquals(150, configuration.get("initialDelay").intValue());
-        assertEquals(1200, configuration.get("maxDelay").intValue());
-        assertEquals(1.2, configuration.get("backoffFactor").doubleValue(), 0.001);
-    }
-    
-    @Test
-    public void configureEmpty() throws Exception {
-        Retry retry = new Retry(15, 150, 1200, 1.2);
-        JsonNode empty = JsonNodeFactory.instance.objectNode();
-        retry.configure(empty);
-        // We would expect missing values to be replaced with the
-        // DEFAULT values rather than the previous values
-        JsonNode configuration = retry.getConfiguration();
-        assertEquals(0, configuration.get("maxRetries").intValue());
-        assertEquals(1000, configuration.get("initialDelay").intValue());
-        assertEquals(5000, configuration.get("maxDelay").intValue());
-        assertEquals(1.0, configuration.get("backoffFactor").doubleValue(), 0.001);
-    }
-
-    @Test
-    public void configurePartly() throws Exception {
-        Retry retry = new Retry(15, 150, 1200, 1.2);
-        ObjectNode conf = JsonNodeFactory.instance.objectNode();
-        conf.put("maxRetries", 15);
-        conf.put("backoffFactor", 1.2);
-        retry.configure(conf);
-        // We would expect to see the new values
-        JsonNode configuration = retry.getConfiguration();
-        assertEquals(15, configuration.get("maxRetries").intValue());
-        assertEquals(1.2, configuration.get("backoffFactor").doubleValue(), 0.001);
-        // And the default values (not the previous values!)
-        assertEquals(1000, configuration.get("initialDelay").intValue());
-        assertEquals(5000, configuration.get("maxDelay").intValue());
-    }    
-    
-    @Test(expected=IllegalArgumentException.class)
-    public void invalidMaxRetries() throws Exception {
-        Retry retry = new Retry();
-        ObjectNode conf = JsonNodeFactory.instance.objectNode();
-        conf.put("maxRetries", -15);
-        retry.configure(conf);
-    }
-
-    @Test(expected=IllegalArgumentException.class)
-    public void invalidInitialDelay() throws Exception {
-        Retry retry = new Retry();
-        ObjectNode conf = JsonNodeFactory.instance.objectNode();
-        conf.put("initialDelay", -15);
-        retry.configure(conf);
-    }
-    
-    @Test(expected=IllegalArgumentException.class)
-    public void invalidMaxDelay() throws Exception {
-        Retry retry = new Retry();
-        ObjectNode conf = JsonNodeFactory.instance.objectNode();
-        conf.put("maxDelay", 150);
-        // Valid on its own, but less than the default initialDelay of 1000!
-        retry.configure(conf);
-    }
-
-    
-    @Test
-    public void invalidConfigureRecovers() throws Exception {
-        Retry retry = new Retry(15, 150, 1200, 1.2);
-        ObjectNode conf = JsonNodeFactory.instance.objectNode();
-        conf.put("maxRetries", -15);
-        try { 
-            retry.configure(conf);
-        } catch (IllegalArgumentException ex) {
-            // As expected
-        }
-        // We would expect the earlier values to persist
-        JsonNode configuration = retry.getConfiguration();
-        assertEquals(15, configuration.get("maxRetries").intValue());
-        assertEquals(150, configuration.get("initialDelay").intValue());
-        assertEquals(1200, configuration.get("maxDelay").intValue());
-        assertEquals(1.2, configuration.get("backoffFactor").doubleValue(), 0.001);
-    }
-    
-    // TODO: Testing the Retry layer without making a big dispatch stack and job context
-    
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/test/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/TestRetry.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/test/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/TestRetry.java b/taverna-workflowmodel-extensions/src/test/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/TestRetry.java
new file mode 100644
index 0000000..48b4c20
--- /dev/null
+++ b/taverna-workflowmodel-extensions/src/test/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/TestRetry.java
@@ -0,0 +1,129 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.layers;
+
+import org.junit.Test;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+import static org.junit.Assert.*;
+
+public class TestRetry {
+    
+    @Test
+    public void defaultConfig() throws Exception {
+        Retry retry = new Retry();
+        JsonNode configuration = retry.getConfiguration();
+        assertEquals(0, configuration.get("maxRetries").intValue());
+        assertEquals(1000, configuration.get("initialDelay").intValue());
+        assertEquals(5000, configuration.get("maxDelay").intValue());
+        assertEquals(1.0, configuration.get("backoffFactor").doubleValue(), 0.001);
+    }
+
+    @Test
+    public void customConfig() throws Exception {
+        Retry retry = new Retry(15, 150, 1200, 1.2);
+        JsonNode configuration = retry.getConfiguration();
+        assertEquals(15, configuration.get("maxRetries").intValue());
+        assertEquals(150, configuration.get("initialDelay").intValue());
+        assertEquals(1200, configuration.get("maxDelay").intValue());
+        assertEquals(1.2, configuration.get("backoffFactor").doubleValue(), 0.001);
+    }
+    
+    @Test
+    public void configureEmpty() throws Exception {
+        Retry retry = new Retry(15, 150, 1200, 1.2);
+        JsonNode empty = JsonNodeFactory.instance.objectNode();
+        retry.configure(empty);
+        // We would expect missing values to be replaced with the
+        // DEFAULT values rather than the previous values
+        JsonNode configuration = retry.getConfiguration();
+        assertEquals(0, configuration.get("maxRetries").intValue());
+        assertEquals(1000, configuration.get("initialDelay").intValue());
+        assertEquals(5000, configuration.get("maxDelay").intValue());
+        assertEquals(1.0, configuration.get("backoffFactor").doubleValue(), 0.001);
+    }
+
+    @Test
+    public void configurePartly() throws Exception {
+        Retry retry = new Retry(15, 150, 1200, 1.2);
+        ObjectNode conf = JsonNodeFactory.instance.objectNode();
+        conf.put("maxRetries", 15);
+        conf.put("backoffFactor", 1.2);
+        retry.configure(conf);
+        // We would expect to see the new values
+        JsonNode configuration = retry.getConfiguration();
+        assertEquals(15, configuration.get("maxRetries").intValue());
+        assertEquals(1.2, configuration.get("backoffFactor").doubleValue(), 0.001);
+        // And the default values (not the previous values!)
+        assertEquals(1000, configuration.get("initialDelay").intValue());
+        assertEquals(5000, configuration.get("maxDelay").intValue());
+    }    
+    
+    @Test(expected=IllegalArgumentException.class)
+    public void invalidMaxRetries() throws Exception {
+        Retry retry = new Retry();
+        ObjectNode conf = JsonNodeFactory.instance.objectNode();
+        conf.put("maxRetries", -15);
+        retry.configure(conf);
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void invalidInitialDelay() throws Exception {
+        Retry retry = new Retry();
+        ObjectNode conf = JsonNodeFactory.instance.objectNode();
+        conf.put("initialDelay", -15);
+        retry.configure(conf);
+    }
+    
+    @Test(expected=IllegalArgumentException.class)
+    public void invalidMaxDelay() throws Exception {
+        Retry retry = new Retry();
+        ObjectNode conf = JsonNodeFactory.instance.objectNode();
+        conf.put("maxDelay", 150);
+        // Valid on its own, but less than the default initialDelay of 1000!
+        retry.configure(conf);
+    }
+
+    
+    @Test
+    public void invalidConfigureRecovers() throws Exception {
+        Retry retry = new Retry(15, 150, 1200, 1.2);
+        ObjectNode conf = JsonNodeFactory.instance.objectNode();
+        conf.put("maxRetries", -15);
+        try { 
+            retry.configure(conf);
+        } catch (IllegalArgumentException ex) {
+            // As expected
+        }
+        // We would expect the earlier values to persist
+        JsonNode configuration = retry.getConfiguration();
+        assertEquals(15, configuration.get("maxRetries").intValue());
+        assertEquals(150, configuration.get("initialDelay").intValue());
+        assertEquals(1200, configuration.get("maxDelay").intValue());
+        assertEquals(1.2, configuration.get("backoffFactor").doubleValue(), 0.001);
+    }
+    
+    // TODO: Testing the Retry layer without making a big dispatch stack and job context
+    
+    
+}


[15/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/utility/TypedTreeModelListener.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/utility/TypedTreeModelListener.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/utility/TypedTreeModelListener.java
new file mode 100644
index 0000000..204676e
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/utility/TypedTreeModelListener.java
@@ -0,0 +1,81 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.utility;
+
+/**
+ * Equivalent to TreeModelListener for use with the TypedTreeModel
+ * 
+ * @author Tom Oinn
+ * 
+ * @see javax.swing.tree.TreeModelListener
+ * 
+ * @param <NodeType>
+ *            Type of the node within the TypedTreeModel and used to
+ *            parameterize the typed version of the tree model event.
+ */
+public interface TypedTreeModelListener<NodeType> {
+	/**
+	 * Invoked after a node (or a set of siblings) has changed in some way. The
+	 * node(s) have not changed locations in the tree or altered their children
+	 * arrays, but other attributes have changed and may affect presentation.
+	 * Example: the name of a file has changed, but it is in the same location
+	 * in the file system.
+	 * <p>
+	 * To indicate the root has changed, childIndices and children will be null.
+	 * <p>
+	 * Use <code>e.getPath()</code> to get the parent of the changed node(s).
+	 * <code>e.getChildIndices()</code> returns the index(es) of the changed
+	 * node(s).
+	 */
+	void treeNodesChanged(TypedTreeModelEvent<NodeType> e);
+
+	/**
+	 * Invoked after nodes have been inserted into the tree.
+	 * <p>
+	 * Use <code>e.getPath()</code> to get the parent of the new node(s).
+	 * <code>e.getChildIndices()</code> returns the index(es) of the new node(s)
+	 * in ascending order.
+	 */
+	void treeNodesInserted(TypedTreeModelEvent<NodeType> e);
+
+	/**
+	 * Invoked after nodes have been removed from the tree. Note that if a
+	 * subtree is removed from the tree, this method may only be invoked once
+	 * for the root of the removed subtree, not once for each individual set of
+	 * siblings removed.
+	 * <p>
+	 * Use <code>e.getPath()</code> to get the former parent of the deleted
+	 * node(s). <code>e.getChildIndices()</code> returns, in ascending order,
+	 * the index(es) the node(s) had before being deleted.
+	 */
+	void treeNodesRemoved(TypedTreeModelEvent<NodeType> e);
+
+	/**
+	 * Invoked after the tree has drastically changed structure from a given
+	 * node down. If the path returned by <code>e.getPath()</code> is of length
+	 * one and the first element does not identify the current root node the
+	 * first element should become the new root of the tree.
+	 * <p>
+	 * Use
+	 * <code>e.getPath()<code> to get the path to the node. <code>e.getChildIndices()</code>
+	 * returns <code>null</code>.
+	 */
+	void treeStructureChanged(TypedTreeModelEvent<NodeType> e);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/utility/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/utility/package.html b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/utility/package.html
new file mode 100644
index 0000000..03fc4c0
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/utility/package.html
@@ -0,0 +1,5 @@
+<body>
+Utility classes, currently consists of a generic type safe alternative
+to TreeModel along with an adapter class to allow it to be used where a
+TreeModel is required (i.e. JTree)
+</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/visit/DataflowCollation.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/visit/DataflowCollation.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/visit/DataflowCollation.java
new file mode 100644
index 0000000..48a4c68
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/visit/DataflowCollation.java
@@ -0,0 +1,51 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.visit;
+
+/**
+ * This visit kind is a dummy for collecting together the information associated
+ * with a nested workflow.
+ * 
+ * @author alanrw
+ */
+public class DataflowCollation extends VisitKind {
+	public static final int NESTED_ISSUES = 1;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * There are no visitors that can perform a DataflowCollation visit. This
+	 * is, instead done within the HierarchyTraverser code iteself.
+	 * 
+	 * @see org.apache.taverna.visit.VisitKind#getVisitorClass()
+	 */
+	@Override
+	public Class<? extends Visitor<?>> getVisitorClass() {
+		return null;
+	}
+
+	private static class Singleton {
+		private static DataflowCollation instance = new DataflowCollation();
+	}
+
+	public static DataflowCollation getInstance() {
+		return Singleton.instance;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/visit/HierarchyTraverser.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/visit/HierarchyTraverser.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/visit/HierarchyTraverser.java
new file mode 100644
index 0000000..1d78183
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/visit/HierarchyTraverser.java
@@ -0,0 +1,362 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.visit;
+
+import static java.lang.System.currentTimeMillis;
+import static java.util.Collections.synchronizedMap;
+import static org.apache.taverna.visit.VisitReport.findAncestor;
+import static org.apache.taverna.visit.VisitReport.getWorstStatus;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
+
+import org.apache.taverna.annotation.HierarchyRole;
+import org.apache.taverna.annotation.HierarchyTraversal;
+import org.apache.taverna.visit.VisitReport.Status;
+import org.apache.taverna.workflowmodel.Dataflow;
+import org.apache.taverna.workflowmodel.Processor;
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+import org.apache.taverna.workflowmodel.processor.activity.NestedDataflow;
+
+import org.apache.log4j.Logger;
+
+/**
+ * A HierarchyTraverser allows the traversal of the parent -> child hierarchy
+ * (as indicated by annotations) and performs visits conforming to the set of
+ * VisitKinds.
+ * 
+ * @author alanrw
+ */
+public class HierarchyTraverser {
+	private static Logger logger = Logger.getLogger(HierarchyTraverser.class);
+
+	/**
+	 * A mapping from the class of an object to the set of names of methods that
+	 * will return children of instances of the object. Note that this has to be
+	 * done by String because of problems with annotations on overridden
+	 * methods.
+	 */
+	private static Map<Class<?>, Set<String>> childrenMethods = synchronizedMap(new WeakHashMap<Class<?>, Set<String>>());
+
+	/**
+	 * The set of visitors that can perform visits of one or more of a set of
+	 * VisitKind.
+	 */
+	protected Set<Visitor<?>> visitors;
+
+	/**
+	 * Create a HierarchyTraverser that can perform visits of the specified set
+	 * of VisitKind.
+	 * 
+	 * @param descriptions
+	 */
+	public HierarchyTraverser(Set<Visitor<?>> visitors) {
+		this.visitors = visitors;
+	}
+
+	/**
+	 * Add a new VisitReport to a set of VisitReport. If the VisitReport has
+	 * sub-reports then, unless the report is about a Dataflow, then the
+	 * VisitReport itself is ignored and the sub-reports added instead. If the
+	 * VisiReport has no sub-reports, or it is a report about a Dataflow, then
+	 * the VisitReport is added to the set.
+	 * 
+	 * @param reports
+	 *            The set of reports to which to add the useful VisitReports
+	 *            corresponding to the new VisitReport.
+	 * @param newReport
+	 *            The VisitReport to be added (or whose sub-reports are to be
+	 *            added) to the set of reports.
+	 */
+	private void addReport(Set<VisitReport> reports, VisitReport newReport) {
+		if (newReport == null)
+			return;
+		Collection<VisitReport> subReports = newReport.getSubReports();
+		if ((subReports == null) || subReports.size() == 0)
+			reports.add(newReport);
+		else if (!(newReport.getSubject() instanceof Dataflow))
+			for (VisitReport r : subReports)
+				addReport(reports, r);
+	}
+
+	/**
+	 * Change the subject of a VisitReport. This is currently done to change a
+	 * VisitReport about an Activity to be about its containing Processor. If
+	 * the VisitReport has sub-reports then their subject is also patched. It is
+	 * not obvious that this should be done here.
+	 * 
+	 * @param vr
+	 *            The VisitReport for which to change the subject
+	 * @param newSubject
+	 *            The new subject of the VisitReport and its sub-reports
+	 */
+	private void patchSubject(VisitReport vr, Object newSubject) {
+		vr.setSubject(newSubject);
+		Collection<VisitReport> subReports = vr.getSubReports();
+		if (subReports != null)
+			for (VisitReport child : subReports)
+				patchSubject(child, newSubject);
+	}
+
+	private void patchCheckTime(VisitReport vr, long time) {
+		vr.setCheckTime(time);
+		Collection<VisitReport> subReports = vr.getSubReports();
+		if (subReports != null)
+			for (VisitReport child : subReports)
+				patchCheckTime(child, time);
+	}
+
+	/**
+	 * Change a VisitReport and its sub-reports (if any) to indicate that the
+	 * visit was time-consuming. This is done to ensure that the time-consuming
+	 * indication of the Visitor is used on the VisitReport.
+	 * 
+	 * @param vr
+	 *            The VisitReport for which to set the time-consuming flag.
+	 */
+	private void patchTimeConsuming(VisitReport vr) {
+		vr.setWasTimeConsuming(true);
+		Collection<VisitReport> subReports = vr.getSubReports();
+		if (subReports != null)
+			for (VisitReport child : subReports)
+				patchTimeConsuming(child);
+	}
+
+	/**
+	 * Carry out the appropriate visits on an object and then traverse down the
+	 * hierarchy of its children.
+	 * 
+	 * @param o
+	 *            The object to visit
+	 * @param ancestry
+	 *            The, possibly empty, list of the ancestors (ordered parents)
+	 *            of the object with the most recent ancestor being the first in
+	 *            the list.
+	 * @param reports
+	 *            The set to which to add reports generated about the object and
+	 *            its descendents
+	 * @param includeTimeConsuming
+	 *            Whether to include visits that are time-consuming.
+	 */
+	@SuppressWarnings({ "rawtypes", "unchecked" })
+	public void traverse(Object o, List ancestry, Set<VisitReport> reports,
+			boolean includeTimeConsuming) {
+		/*
+		 * For each visitor that is able to do visits for the set of VisitKind
+		 * specified for the HierarchyTraverser
+		 */
+		for (Visitor v : visitors)
+			/*
+			 * If time consuming visits are allowed or the visitor is not time
+			 * consuming, and the visitor can visit the specified object
+			 */
+
+			if ((includeTimeConsuming || !v.isTimeConsuming()) && v.canVisit(o)) {
+				// Make the visitor visit the object
+				VisitReport report = null;
+				try {
+					report = v.visit(o, ancestry);
+				} catch (NullPointerException|ClassCastException e) {
+					logger.error("Visit threw exception", e);
+				}
+
+				if (report == null)
+					continue;
+
+				patchCheckTime(report, currentTimeMillis());
+
+				/*
+				 * If the current object is an Activity then change the report
+				 * so that its subject is the Processor containing the Activity
+				 */
+				if (o instanceof Activity) {
+					Processor p = (Processor) findAncestor(ancestry,
+							Processor.class);
+					if (p != null)
+						patchSubject(report, p);
+				}
+				/*
+				 * Note in the VisitReport if it was caused by a time-consuming
+				 * visitor
+				 */
+				if (v.isTimeConsuming() && (report != null))
+					patchTimeConsuming(report);
+				/*
+				 * Add the VisitReport and its sub-reports, if any, to the set
+				 * of VisitReports
+				 */
+				addReport(reports, report);
+			}
+
+		/*
+		 * If the object is a nested dataflow activity then traverse the
+		 * dataflow that is nested. Take the reports about the sub-dataflow and,
+		 * if there are problems with it, create a DataflowCollation report
+		 * about the nested dataflow activity (or to be more precise the
+		 * Procesor containing it.)
+		 */
+		if (o instanceof NestedDataflow) {
+			NestedDataflow nestedDataflow = (NestedDataflow) o;
+			Dataflow subFlow = nestedDataflow.getNestedDataflow();
+			Set<VisitReport> subReports = new HashSet<>();
+			traverse(subFlow, new ArrayList<Object>(), subReports,
+					includeTimeConsuming);
+			Processor p = (Processor) findAncestor(ancestry, Processor.class);
+			if (p != null) {
+				Status worstStatus = getWorstStatus(subReports);
+				if (!worstStatus.equals(Status.OK)) {
+					VisitReport report = new VisitReport(
+							DataflowCollation.getInstance(),
+							p,
+							(worstStatus.equals(Status.WARNING) ? "Warnings in nested workflow"
+									: "Errors in nested workflow"),
+							DataflowCollation.NESTED_ISSUES, worstStatus,
+							subReports);
+					report.setProperty("dataflowIdentifier",
+							subFlow.getIdentifier());
+					report.setWasTimeConsuming(includeTimeConsuming);
+					reports.add(report);
+				}
+			}
+		}
+
+		// Now move on to traversing the descendents
+
+		/*
+		 * For every child-getting method for this object, try to get the
+		 * children and add them into a set.
+		 */
+		Set<String> methodNames = getMethods(o);
+		Set<Object> children = new HashSet<>();
+		for (Method m : o.getClass().getMethods())
+			if (methodNames.contains(m.getName())) {
+				Object methodResult = null;
+				try {
+					methodResult = m.invoke(o);
+				} catch (IllegalArgumentException | IllegalAccessException
+						| InvocationTargetException e) {
+					logger.error(e);
+				}
+				/*
+				 * If the method did not produce a singleton but instead a List
+				 * or similar then add the members of the list.
+				 */
+				children.addAll(getLeafs(methodResult));
+			}
+
+		/*
+		 * For every child of the current object, traverse that object and get
+		 * reports about it and its descendents.
+		 */
+		ArrayList<Object> newAncestry = new ArrayList<>();
+		newAncestry.add(o);
+		newAncestry.addAll(ancestry);
+		for (Object c : children)
+			traverse(c, newAncestry, reports, includeTimeConsuming);
+	}
+
+	/**
+	 * Determine the set of singletons corresponding to an object. If the object
+	 * is a singleton then a set containing just the object is returned. If the
+	 * object is iterable then the singletons of the elements of the iteration
+	 * are returned.
+	 * 
+	 * @param o
+	 *            The object.
+	 * @return The set of singletons
+	 */
+	@SuppressWarnings("unchecked")
+	private static Set<Object> getLeafs(Object o) {
+		Set<Object> result = new HashSet<>();
+		if (o instanceof Iterable)
+			for (Object element : (Iterable<Object>) o)
+				result.addAll(getLeafs(element));
+		else
+			result.add(o);
+		return result;
+	}
+
+	/**
+	 * Determine the set of names of child-getting methods for a given object
+	 * 
+	 * @param o
+	 *            The object to consider.
+	 * @return The set of names of child-getting methods
+	 */
+	private static Set<String> getMethods(Object o) {
+		Class<?> c = o.getClass();
+		return getMethodsForClass(c);
+	}
+
+	/**
+	 * Determine the set of names of child-getting methods for a given Class.
+	 * This includes the names of methods from interfaces and super-classes.
+	 * 
+	 * @param c
+	 *            The class to consider
+	 * @return The set of names of child-getting methods for the class
+	 */
+	private static synchronized Set<String> getMethodsForClass(Class<?> c) {
+		if (!childrenMethods.containsKey(c)) {
+			Set<String> result = new HashSet<>();
+			result.addAll(getExplicitMethodsForClass(c));
+			for (Class<?> i : c.getInterfaces())
+				result.addAll(getMethodsForClass(i));
+			Class<?> s = c.getSuperclass();
+			if (s != null)
+				result.addAll(getMethodsForClass(s));
+			childrenMethods.put(c, result);
+		}
+		return childrenMethods.get(c);
+	}
+
+	/**
+	 * Determine the set of names of child-getting methods explicitly identified
+	 * for an Interface or a Class.
+	 * 
+	 * @param c
+	 *            The Interface or Class to consider
+	 * @return The set of names of child-getting methods.
+	 */
+	private static Collection<? extends String> getExplicitMethodsForClass(
+			Class<?> c) {
+		Method[] methods = c.getDeclaredMethods();
+		Set<String> result = new HashSet<>();
+
+		for (Method m : methods)
+			if (m.getParameterTypes().length == 0) {
+				HierarchyTraversal ht = m
+						.getAnnotation(HierarchyTraversal.class);
+				if (ht != null
+						&& Arrays.asList(ht.role()).contains(
+								HierarchyRole.CHILD))
+					result.add(m.getName());
+			}
+		return result;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/visit/VisitKind.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/visit/VisitKind.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/visit/VisitKind.java
new file mode 100644
index 0000000..f7dbd72
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/visit/VisitKind.java
@@ -0,0 +1,35 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.visit;
+
+/**
+ * A type of visit that can be made e.g. a health check.
+ * 
+ * @author alanrw
+ */
+public abstract class VisitKind {
+	/**
+	 * The class that all visitors that extend/implement if they make this type
+	 * of visit.
+	 * 
+	 * @return
+	 */
+	public abstract Class<? extends Visitor<?>> getVisitorClass();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/visit/VisitReport.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/visit/VisitReport.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/visit/VisitReport.java
new file mode 100644
index 0000000..c993e2a
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/visit/VisitReport.java
@@ -0,0 +1,362 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.visit;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author alanrw
+ */
+public class VisitReport {
+	private static final String INDENTION = "    ";
+
+	/**
+	 * Enumeration of the possible status's in increasing severity: OK,
+	 * WARNING,SEVERE
+	 */
+	public enum Status {
+		OK, WARNING, SEVERE
+	};
+
+	/**
+	 * A short message describing the state of the report
+	 */
+	private String message;
+	/**
+	 * An integer indicating the outcome of a visit relative to the VisitKind
+	 */
+	private int resultId;
+	/**
+	 * 
+	 */
+	private Status status;
+	/**
+	 * The object about which the report is made
+	 */
+	private Object subject;
+	/**
+	 * The sub-reports of the VisitReport
+	 */
+	private Collection<VisitReport> subReports = new ArrayList<>();
+	/**
+	 * The kind of visit that was made e.g. to check the health of a service or
+	 * examine its up-stream error fragility
+	 */
+	private VisitKind kind;
+	/**
+	 * An indication of whether the visit report was generated by a time
+	 * consuming visitor. This is used to check whether the VisitReport can be
+	 * automatically junked.
+	 */
+	private boolean wasTimeConsuming;
+	private Map<String, Object> propertyMap = new HashMap<>();
+	private long checkTime;
+
+	/**
+	 * @return whether the VisitReport was generated by a time consuming visitor
+	 */
+	public boolean wasTimeConsuming() {
+		return wasTimeConsuming;
+	}
+
+	/**
+	 * @param wasTimeConsuming whether the VisitReport was generated by a time consuming visitot
+	 */
+	public void setWasTimeConsuming(boolean wasTimeConsuming) {
+		this.wasTimeConsuming = wasTimeConsuming;
+	}
+
+	/**
+	 * Constructs the Visit Report. The sub reports default to an empty list.
+	 * 
+	 * @param kind
+	 *            - the type of visit performed
+	 * @param subject
+	 *            - the thing being tested.
+	 * @param message
+	 *            - a summary of the result of the test.
+	 * @param resultId
+	 *            - an identification of the type of result relative to the
+	 *            VisitKind
+	 * @param status
+	 *            - the overall Status.
+	 */
+	public VisitReport(VisitKind kind, Object subject, String message,
+			int resultId, Status status) {
+		this(kind, subject, message, resultId, status,
+				new ArrayList<VisitReport>());
+	}
+	
+	/**
+	 * Used internally by {@link #clone()}.
+	 */
+	protected VisitReport() {}
+
+	/**
+	 * Constructs the Visit Report
+	 * 
+	 * @param kind
+	 *            - the type of visit performed
+	 * @param subject
+	 *            - the thing being tested.
+	 * @param message
+	 *            - a summary of the result of the test.
+	 * @param resultId
+	 *            - an identification of the type of result relative to the
+	 *            VisitKind
+	 * @param status - the overall Status.
+	 * @param subReports
+	 *            - a List of sub reports.
+	 */
+	public VisitReport(VisitKind kind, Object subject, String message,
+			int resultId, Status status, Collection<VisitReport> subReports) {
+		this.kind = kind;
+		this.subject = subject;
+		this.status = status;
+		this.message = message;
+		this.resultId = resultId;
+		this.subReports = subReports;
+		this.wasTimeConsuming = false;
+		this.checkTime = 0;
+	}
+
+	/**
+	 * @param kind The type of visit performed
+	 * @param subject The thing that was visited
+	 * @param message A summary of the result of the test
+	 * @param resultId An indication of the type of the result relative to the kind of visit
+	 * @param subReports A list of sub-reports
+	 */
+	public VisitReport(VisitKind kind, Object subject, String message,
+			int resultId, Collection<VisitReport> subReports) {
+		this(kind, subject, message, resultId, getWorstStatus(subReports),
+				subReports);
+	}
+
+	/**
+	 * @return An indication of the type of the result relative to the kind of visit
+	 */
+	public int getResultId() {
+		return resultId;
+	}
+
+	/**
+	 * @param resultId The type of the result of the visit relative to the kind of visit
+	 */
+	public void setResultId(int resultId) {
+		this.resultId = resultId;
+	}
+
+	/**
+	 * @return a message summarizing the report
+	 */
+	public String getMessage() {
+		return message;
+	}
+
+	/**
+	 * Sets the message
+	 * 
+	 * @param message
+	 *            a message summarizing the report
+	 */
+	public void setMessage(String message) {
+		this.message = message;
+	}
+
+	/**
+	 * Determines the overall Status. This is the most severe status of this
+	 * report and all its sub reports.
+	 * 
+	 * @return the overall status
+	 */
+	public Status getStatus() {
+		Status result = status;
+		for (VisitReport report : subReports)
+			if (report.getStatus().compareTo(result) > 0)
+				result = report.getStatus();
+		return result;
+	}
+
+	/**
+	 * Sets the status of this report. Be aware that the overall status of this
+	 * report may also be affected by its sub reports if they have a more severe
+	 * Status.
+	 * 
+	 * @param status
+	 * @see #getStatus
+	 */
+	public void setStatus(Status status) {
+		this.status = status;
+	}
+
+	/**
+	 * @return an Object representing the subject of this visit report
+	 */
+	public Object getSubject() {
+		return subject;
+	}
+
+	/**
+	 * @param subject
+	 *            an Object representing the subject of this visit report
+	 */
+	public void setSubject(Object subject) {
+		this.subject = subject;
+	}
+
+	/**
+	 * Provides a list of sub reports. This list defaults an empty list, so it
+	 * is safe to add new reports through this method.
+	 * 
+	 * @return a list of sub reports associated with this Visit Report
+	 */
+	public Collection<VisitReport> getSubReports() {
+		return subReports;
+	}
+
+	/**
+	 * Replaces the List of sub reports with those provided.
+	 * 
+	 * @param subReports
+	 *            a list of sub reports
+	 */
+	public void setSubReports(Collection<VisitReport> subReports) {
+		this.subReports = subReports;
+	}
+
+	/**
+	 * 
+	 * @return the kind of visit that was made.
+	 */
+	public VisitKind getKind() {
+		return kind;
+	}
+
+	/**
+	 * @param kind Specify the kind of visit that was made
+	 */
+	public void setKind(VisitKind kind) {
+		this.kind = kind;
+	}
+	
+	public void setProperty(String key, Object value) {
+		propertyMap.put(key, value);
+	}
+	
+	public Object getProperty(String key) {
+		return propertyMap.get(key);
+	}
+
+	public Map<String, Object> getProperties() {
+		return propertyMap;
+	}
+	
+	/**
+	 * Find the most recent ancestor (earliest in the list) of a given class from the list of ancestors
+	 * 
+	 * @param ancestors The list of ancestors to examine
+	 * @param ancestorClass The class to search for
+	 * @return The most recent ancestor, or null if no suitable ancestor
+	 */
+	public static Object findAncestor(List<Object> ancestors,
+			Class<?> ancestorClass) {
+		Object result = null;
+		for (Object o : ancestors)
+			if (ancestorClass.isInstance(o))
+				return o;
+		return result;
+	}
+
+	public void setCheckTime(long time) {
+		this.checkTime = time;
+	}
+
+	public long getCheckTime() {
+		return this.checkTime;
+	}
+
+	/**
+	 * Determine the worst status from a collection of reports
+	 * 
+	 * @param reports
+	 *            The collection of reports to examine
+	 * @return The worst status
+	 */
+	public static Status getWorstStatus(Collection<VisitReport> reports) {
+		Status currentStatus = Status.OK;
+		for (VisitReport report : reports)
+			if (currentStatus.compareTo(report.getStatus()) < 0)
+				currentStatus = report.getStatus();
+		return currentStatus;
+	}
+
+	@Override
+	public String toString() {
+		// TODO Use StringBuilder instead
+		StringBuffer sb = new StringBuffer();
+		visitReportToStringBuffer(sb, "");
+		return sb.toString();
+	}
+
+	protected void visitReportToStringBuffer(
+			StringBuffer sb, String indent) {	
+		sb.append(indent);
+		sb.append(getStatus());
+		sb.append(' ');
+		sb.append(getMessage());
+		if (! propertyMap.isEmpty()) {
+			sb.append(' ');
+			sb.append(propertyMap);
+		}
+		sb.append('\n');
+		indent = indent + INDENTION;
+		for (VisitReport subReport : getSubReports())
+			subReport.visitReportToStringBuffer(sb, indent);
+	}
+	
+	@Override
+	public VisitReport clone() throws CloneNotSupportedException {
+		if (!getClass().equals(VisitReport.class))
+			throw new CloneNotSupportedException("Can't clone subclass "
+					+ getClass()
+					+ ", reimplement clone() and use internalClone()");
+		return internalClone(new VisitReport());
+	}
+
+	protected VisitReport internalClone(VisitReport newReport)
+			throws CloneNotSupportedException {
+		newReport.checkTime = this.checkTime;
+		newReport.kind = this.kind;
+		newReport.message = this.message;
+		newReport.propertyMap.putAll(this.propertyMap);
+		newReport.resultId = this.resultId;
+		newReport.status = this.status;
+		newReport.subject = this.subject;
+		newReport.wasTimeConsuming = this.wasTimeConsuming;
+		for (VisitReport childReport : this.subReports)
+			newReport.subReports.add(childReport.clone());
+		return newReport;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/visit/Visitor.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/visit/Visitor.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/visit/Visitor.java
new file mode 100644
index 0000000..d9f20fc
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/visit/Visitor.java
@@ -0,0 +1,63 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.visit;
+
+import java.util.List;
+
+/**
+ * A Visitor can perform a visit of a VisitKind on a object. It can return a
+ * VisitReport giving details of the result of the visit, A Visitor may be time
+ * consuming, in which case it is only performed upon user request.
+ * 
+ * @author alanrw
+ * 
+ * @param <T> The type of the objects being visited.
+ */
+public interface Visitor<T> {
+	/**
+	 * Returns true if the visitor can visit the specified object.
+	 * 
+	 * @param o
+	 *            The object that might be visited
+	 * @return true is a visit is possible from this Visitor.
+	 */
+	boolean canVisit(Object o);
+
+	/**
+	 * Visit an object which has the specified ancestry (list of parents) and
+	 * possibly return a VisitReport detailing the result of the visit.
+	 * 
+	 * @param o
+	 *            The object to visit
+	 * @param ancestry
+	 *            A list of the ancestors of the object with the immediate
+	 *            parent at the start of the list.
+	 * @return A VisitReport detailing the result of the visit.
+	 */
+	VisitReport visit(T o, List<Object> ancestry);
+
+	/**
+	 * An indication if the visit would take sufficient time that it should only
+	 * be run upon user request
+	 * 
+	 * @return
+	 */
+	boolean isTimeConsuming();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/AbstractOutputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/AbstractOutputPort.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/AbstractOutputPort.java
new file mode 100644
index 0000000..d236d52
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/AbstractOutputPort.java
@@ -0,0 +1,42 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+/**
+ * Simple implementation of OutputPort, extends AbstractPort and adds the
+ * granular depth bean getter.
+ * 
+ * @author Tom Oinn
+ */
+public abstract class AbstractOutputPort extends AbstractPort implements
+		OutputPort {
+	protected int granularDepth;
+
+	protected AbstractOutputPort(String portName, int portDepth,
+			int granularDepth) {
+		super(portName, portDepth);
+		this.granularDepth = granularDepth;
+	}
+
+	@Override
+	public int getGranularDepth() {
+		return granularDepth;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/AbstractPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/AbstractPort.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/AbstractPort.java
new file mode 100644
index 0000000..3ffcd7a
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/AbstractPort.java
@@ -0,0 +1,53 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+import org.apache.taverna.annotation.AbstractAnnotatedThing;
+
+/**
+ * Port definition with depth and name
+ * 
+ * @author Tom Oinn
+ */
+public abstract class AbstractPort extends AbstractAnnotatedThing<Port>
+		implements Port {
+	protected String name;
+	protected int depth;
+
+	protected AbstractPort(String name, int depth) {
+		this.name = name;
+		this.depth = depth;
+	}
+
+	@Override
+	public int getDepth() {
+		return this.depth;
+	}
+
+	@Override
+	public final String getName() {
+		return this.name;
+	}
+
+	@Override
+	public String toString() {
+		return getClass().getSimpleName() + " " + getName() + " (" + getDepth() + ")";
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/CompoundEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/CompoundEdit.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/CompoundEdit.java
new file mode 100644
index 0000000..810fd8c
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/CompoundEdit.java
@@ -0,0 +1,114 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Implementation of Edit which contains an ordered list of child edits. Child
+ * edits are applied collectively and in order, any failure in any child edit
+ * causes an undo of previously applied children and a propogation of the edit
+ * exception.
+ * 
+ * @author Tom Oinn
+ */
+public class CompoundEdit implements Edit<Object> {
+	private final transient List<Edit<?>> childEdits;
+	private transient boolean applied = false;
+
+	/**
+	 * Create a new compound edit with no existing Edit objects.
+	 * 
+	 */
+	public CompoundEdit() {
+		this.childEdits = new ArrayList<>();
+	}
+
+	/**
+	 * Create a new compound edit with the specified edits as children.
+	 */
+	public CompoundEdit(List<Edit<?>> edits) {
+		this.childEdits = edits;
+	}
+
+	public List<Edit<?>> getChildEdits() {
+		return childEdits;
+	}
+
+	/**
+	 * Attempts to call the doEdit method of all child edits. If any of those
+	 * children throws an EditException any successful edits are rolled back and
+	 * the exception is rethrown as the cause of a new EditException from the
+	 * CompoundEdit
+	 */
+	@Override
+	@SuppressWarnings("deprecation")
+	public synchronized Object doEdit() throws EditException {
+		if (isApplied())
+			throw new EditException("Cannot apply an edit more than once!");
+		List<Edit<?>> doneEdits = new ArrayList<>();
+		try {
+			for (Edit<?> edit : childEdits) {
+				edit.doEdit();
+				/*
+				 * Insert the done edit at position 0 in the list so we can
+				 * iterate over the list in the normal order if we need to
+				 * rollback, this ensures that the most recent edit is first.
+				 */
+				doneEdits.add(0, edit);
+			}
+			applied = true;
+			return null;
+		} catch (EditException ee) {
+			// TODO Remove undo; we can't do that any more
+			for (Edit<?> undoMe : doneEdits)
+				undoMe.undo();
+			applied = false;
+			throw new EditException("Failed child of compound edit", ee);
+		}
+	}
+
+	/**
+	 * There is no explicit subject for a compound edit, so this method always
+	 * returns null.
+	 */
+	@Override
+	public Object getSubject() {
+		return null;
+	}
+
+	/**
+	 * Rolls back all child edits in reverse order
+	 */
+	@Override
+	@SuppressWarnings("deprecation")
+	public synchronized void undo() {
+		for (int i = (childEdits.size() - 1); i >= 0; i--)
+			// Undo child edits in reverse order
+			childEdits.get(i).undo();
+		applied = false;
+	}
+
+	@Override
+	public boolean isApplied() {
+		return applied;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Condition.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Condition.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Condition.java
new file mode 100644
index 0000000..a7b3b8e
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Condition.java
@@ -0,0 +1,51 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+import org.apache.taverna.annotation.Annotated;
+
+/**
+ * Defines the base interface for a condition which must be satisfied before a
+ * processor can commence invocation. Conditions are expressed in terms of a
+ * relationship between a controlling and a target processor where the target
+ * processor may not commence invocation until all conditions for which it is a
+ * target are satisfied in the context of a particular owning process
+ * identifier.
+ * 
+ * @author Tom Oinn
+ */
+public interface Condition extends Annotated<Condition>, WorkflowItem {
+	/**
+	 * @return the Processor constrained by this condition
+	 */
+	Processor getControl();
+
+	/**
+	 * @return the Processor acting as the controller for this condition
+	 */
+	Processor getTarget();
+
+	/**
+	 * @param owningProcess
+	 *            the context in which the condition is to be evaluated
+	 * @return whether the condition is satisfied
+	 */
+	boolean isSatisfied(String owningProcess);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Configurable.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Configurable.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Configurable.java
new file mode 100644
index 0000000..7b0f072
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Configurable.java
@@ -0,0 +1,54 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+import org.apache.taverna.workflowmodel.processor.activity.ActivityConfigurationException;
+
+/**
+ * Interface for workflow items that can be configured from a bean.
+ * 
+ * @param <ConfigurationType>
+ *            the ConfigurationType associated with the workflow item. This is
+ *            an arbitrary java class that provides details on how the item is
+ *            configured. To allow successful serialisation it's recommended to
+ *            keep this configuration as a simple Java bean.
+ * 
+ * @author Tom Oinn
+ * @author Stian Soiland-Reyes
+ * @see ActivityConfigurationException
+ */
+public interface Configurable<ConfigurationType> extends WorkflowItem {
+	/**
+	 * Each item stores configuration within a bean of type ConfigurationType,
+	 * this method returns the configuration. This is used by the automatic
+	 * serialisation framework to store the item definition in the workflow XML.
+	 */
+	ConfigurationType getConfiguration();
+
+	/**
+	 * When the item is built from the workflow definition XML the object is
+	 * first constructed with a default constructor then this method is called,
+	 * passing in the configuration bean returned by getConfiguration().
+	 * 
+	 * @throws ConfigurationException
+	 *             if a problem occurs when configuring the item
+	 */
+	void configure(ConfigurationType conf) throws ConfigurationException;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ConfigurationException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ConfigurationException.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ConfigurationException.java
new file mode 100644
index 0000000..aa48541
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ConfigurationException.java
@@ -0,0 +1,61 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+/**
+ * Thrown when attempting to configure a
+ * {@link org.apache.taverna.workflowmodel.Configurable} with an invalid
+ * configuration. Causes may include actual configuration errors, unavailable
+ * implementations etc.
+ * 
+ * @author Stian Soiland-Reyes
+ * @author Tom Oinn
+ */
+public class ConfigurationException extends Exception {
+	private static final long serialVersionUID = -2841928064598107156L;
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public ConfigurationException() {
+		super();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public ConfigurationException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public ConfigurationException(String message) {
+		super(message);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public ConfigurationException(Throwable cause) {
+		super(cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ControlBoundary.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ControlBoundary.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ControlBoundary.java
new file mode 100644
index 0000000..7ccef85
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ControlBoundary.java
@@ -0,0 +1,46 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Denotes that the associated type creates a boundary of control within the
+ * dataflow. Types marked with this annotation are those which can modify the
+ * owning process of data tokens they consume and generally correspond to cases
+ * where the control flow bifurcates in some fashion.
+ * <p>
+ * This annotation doesn't currently define this behaviour but serves as an easy
+ * way for us to track which objects might potentially do this, something we
+ * need to be able to do to guarantee that the monitor works correctly.
+ * 
+ * @author Tom Oinn
+ * 
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@Documented
+public @interface ControlBoundary {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Dataflow.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Dataflow.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Dataflow.java
new file mode 100644
index 0000000..e6cbc7f
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Dataflow.java
@@ -0,0 +1,172 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+import static org.apache.taverna.annotation.HierarchyRole.CHILD;
+
+import java.util.List;
+
+import org.apache.taverna.annotation.Annotated;
+import org.apache.taverna.annotation.HierarchyTraversal;
+import org.apache.taverna.invocation.InvocationContext;
+
+/**
+ * Top level definition object for a dataflow workflow. Currently Taverna only
+ * supports dataflow workflows, this is equivalent to the Taverna 1 ScuflModel
+ * class in role.
+ * 
+ * @author Tom Oinn
+ */
+@ControlBoundary
+public interface Dataflow extends Annotated<Dataflow>, TokenProcessingEntity,
+		WorkflowItem {
+	/**
+	 * A Dataflow consists of a set of named Processor instances. This method
+	 * returns an unmodifiable list of these processors. Equivalent to calling
+	 * getEntities(Processor.class).
+	 * 
+	 * @return list of all processors in the dataflow
+	 */
+	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
+	List<? extends Processor> getProcessors();
+
+	/**
+	 * Dataflows also contain a set of merge operations, this method returns an
+	 * unmodifiable copy of the set. Equivalent to calling
+	 * getEntities(Merge.class)
+	 */
+	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
+	List<? extends Merge> getMerges();
+
+	/**
+	 * Dataflows have a list of input ports. These are the input ports the world
+	 * outside the dataflow sees - each one contains an internal output port
+	 * which is used to forward events on to entities (mostly processors) within
+	 * the dataflow.
+	 * 
+	 * @return list of dataflow input port instances
+	 */
+	@Override
+	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
+	List<? extends DataflowInputPort> getInputPorts();
+
+	/**
+	 * Get all workflow entities with the specified type restriction, this
+	 * allows retrieval of Processor, Merge, a mix of the two or any other
+	 * future entity to be added to the workflow model without a significant
+	 * change in this part of the API.
+	 * 
+	 * @return an unmodifiable list of entities of the specified type
+	 * @param entityType
+	 *            a class of the type specified by the type variable T. All
+	 *            entities returned in the list can be cast to this type
+	 */
+	<T extends NamedWorkflowEntity> List<? extends T> getEntities(
+			Class<T> entityType);
+
+	/**
+	 * Dataflows have a list of output ports. The output port in a dataflow is
+	 * the port visible to the outside world and from which the dataflow emits
+	 * events. Each dataflow output port also contains an instance of event
+	 * receiving input port which is used by entities within the dataflow to
+	 * push events to the corresponding external output port.
+	 * 
+	 * @return list of dataflow output port instances
+	 */
+	@Override
+	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
+	List<? extends DataflowOutputPort> getOutputPorts();
+
+	/**
+	 * The dataflow is largely defined by the links between processors and other
+	 * entities within its scope. This method returns them.
+	 * 
+	 * @return list of Datalink implementations
+	 */
+	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
+	List<? extends Datalink> getLinks();
+
+	/**
+	 * Triggers a check for various basic potential problems with the workflow,
+	 * in particular ones related to type checking. Returns a report object
+	 * containing the state of the workflow and any problems found.
+	 * <p>
+	 * If the workflow has been set immutable with {@link #setImmutable()},
+	 * subsequent calls to this method will return the cached
+	 * DataflowValidationReport.
+	 * 
+	 * @return validation report
+	 */
+	DataflowValidationReport checkValidity();
+
+	/**
+	 * A dataflow with no inputs cannot be driven by the supply of data tokens
+	 * as it has nowhere to receive such tokens. This method allows a dataflow
+	 * to fire on an empty input set, in this case the owning process identifier
+	 * must be passed explicitly to the dataflow. This method then calls the
+	 * fire methods of any Processor instances with no input ports.
+	 */
+	void fire(String owningProcess, InvocationContext context);
+
+	/**
+	 * The failure transmitter contains event listeners to be notified of
+	 * workflow level failures - these occur when an error bubbles up to the top
+	 * of the dispatch stack in a processor and is not handled by conversion to
+	 * an error token within the data stream.
+	 * <p>
+	 * Listeners are messaged after all clean-up has been performed on the
+	 * dataflow's internal state and that of any child operations within it,
+	 * guaranteeing that no tokens will be generated with the id of the failed
+	 * process after the message has been received by the listener
+	 */
+	FailureTransmitter getFailureTransmitter();
+
+	/**
+	 * An identifier that is unique to this dataflow and its current state. The
+	 * identifier will change whenever the dataflow is modified.
+	 * 
+	 * @return a String representing a unique internal identifier.
+	 */
+	String getIdentifier();
+
+	String recordIdentifier();
+
+	/**
+	 * Check if the given input port is connected to anything in the workflow.
+	 * 
+	 * @param inputPort
+	 * @return true if the given workflow input port is connected, false
+	 *         otherwise.
+	 */
+	boolean isInputPortConnected(DataflowInputPort inputPort);
+
+	/**
+	 * Mark this dataflow as immutable.
+	 * 
+	 * Subsequent edits to its ports, links, merges, input and output ports will
+	 * throw a RuntimeException like UnsupportedOperationException.
+	 * 
+	 * This method should be called before executing a Dataflow with
+	 * {@link #fire(String, InvocationContext)}, in order to guarantee that
+	 * datalinks, port depths etc. don't change while the dataflow is running.
+	 * 
+	 */
+	void setImmutable();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/DataflowInputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/DataflowInputPort.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/DataflowInputPort.java
new file mode 100644
index 0000000..92b4fee
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/DataflowInputPort.java
@@ -0,0 +1,51 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+/**
+ * An input port on a Dataflow contains a nested output port within it. This
+ * internal output port is used when connecting an edge from the workflow input
+ * to a processor or workflow output (which in turn has a nested input port).
+ * The workflow ports are therefore effectively pairs of ports with a relay
+ * mechanism between the external and internal in the case of the dataflow
+ * input.
+ * 
+ * @author Tom Oinn
+ */
+public interface DataflowInputPort extends EventHandlingInputPort, DataflowPort {
+	/**
+	 * Return the internal output port. Output ports have a granular depth
+	 * property denoting the finest grained output token they can possibly
+	 * produce, this is used to configure downstream filtering input ports. In
+	 * this case the finest depth item is determined by the input to the
+	 * workflow port and must be explicitly set.
+	 * 
+	 * @return the internal output port
+	 */
+	EventForwardingOutputPort getInternalOutputPort();
+
+	/**
+	 * Define the finest grained item that will be sent to this input port. As
+	 * all data are relayed through to the internal output port this is used to
+	 * denote output port granularity as well as to configure any downstream
+	 * connected filtering input ports.
+	 */
+	int getGranularInputDepth();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/DataflowOutputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/DataflowOutputPort.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/DataflowOutputPort.java
new file mode 100644
index 0000000..839c0f5
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/DataflowOutputPort.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program 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 program 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 program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package org.apache.taverna.workflowmodel;
+
+import org.apache.taverna.facade.ResultListener;
+
+/**
+ * Output port of a DataFlow, exposes an internal EventHandlingInputPort into
+ * which the internal workflow logic pushes data to be exposed outside the
+ * workflow boundary.
+ * 
+ * @author Tom Oinn
+ */
+public interface DataflowOutputPort extends EventForwardingOutputPort,
+		DataflowPort {
+	/**
+	 * Get the internal input port for this workflow output
+	 * 
+	 * @return port into which the workflow can push data for this output
+	 */
+	EventHandlingInputPort getInternalInputPort();
+
+	/**
+	 * Add a ResultListener, capable of listening to results being received by
+	 * the output port
+	 * 
+	 * @param listener
+	 *            the ResultListener
+	 * 
+	 * @see ResultListener
+	 */
+	void addResultListener(ResultListener listener);
+
+	/**
+	 * Remove a ResultListener
+	 * 
+	 * @param listener
+	 *            the ResultListener
+	 * 
+	 * @see ResultListener
+	 */
+	void removeResultListener(ResultListener listener);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/DataflowPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/DataflowPort.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/DataflowPort.java
new file mode 100644
index 0000000..3f4b17b
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/DataflowPort.java
@@ -0,0 +1,33 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+/**
+ * Defines that the implementing port belongs to a Dataflow
+ * 
+ * @author Tom Oinn
+ * @author Stian Soiland-Reyes
+ */
+public interface DataflowPort extends Port {
+	/**
+	 * Get the parent DataFlow to which this port belongs
+	 */
+	public Dataflow getDataflow();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/DataflowValidationReport.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/DataflowValidationReport.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/DataflowValidationReport.java
new file mode 100644
index 0000000..127fde6
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/DataflowValidationReport.java
@@ -0,0 +1,98 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Contains a validation report from a dataflow validation check. Processors are
+ * classified as failed, unsatisfied or valid depending on whether they directly
+ * fail type validation, cannot be checked due to unsatisfied incoming links or
+ * pass respectively.
+ * 
+ * @author Tom Oinn
+ */
+public interface DataflowValidationReport {
+	/**
+	 * Overall validity - if the workflow is valid it can be run, otherwise
+	 * there are problems somewhere and a facade can't be created from it.
+	 * 
+	 * @return whether the workflow is valid (true) or not (false)
+	 */
+	boolean isValid();
+
+	/**
+	 * Whether the workflow is incomplete, i.e. contains no processors and no
+	 * connected output ports. For example, it is empty or contains only input
+	 * ports. Even though one can technically run such a workflow it should be
+	 * prohibited as it does not make any sense. If a workflow is incomplete
+	 * {@link DataflowValidationReport#isValid()} should return
+	 * <code>false</code>.
+	 * 
+	 * @return whether the workflow is incomplete or not
+	 */
+	boolean isWorkflowIncomplete();
+
+	/**
+	 * The workflow will be marked as invalid if there are entities with
+	 * unlinked input ports or where there are cycles causing the type checking
+	 * algorithm to give up. In these cases offending processors or any
+	 * ancestors that are affected as a knock on effect will be returned in this
+	 * list.
+	 * 
+	 * @return list of TokenProcessingEntity instances within the Dataflow for
+	 *         which it is impossible to determine validity due to missing
+	 *         inputs or cyclic dependencies
+	 */
+	List<? extends TokenProcessingEntity> getUnsatisfiedEntities();
+
+	/**
+	 * The workflow will be marked as invalid if any entity fails to type check.
+	 * 
+	 * @return list of TokenProcessingEntity instances within the Dataflow which
+	 *         caused explicit type check failures
+	 */
+	List<? extends TokenProcessingEntity> getFailedEntities();
+
+	/**
+	 * The workflow will be marked as invalid if any of the dataflow output
+	 * ports can't be typed based on incoming links. This happens if the port
+	 * isn't linked (a common enough issue for new users in previous releases of
+	 * Taverna) or if the internal port is linked but the entity it links to
+	 * isn't validated.
+	 * 
+	 * @return a list of DataflowOutputPort implementations which are not typed
+	 *         correctly. These will have output depth of -1 indicating an
+	 *         unknown depth, they may or may not have a granular depth set but
+	 *         if the overall depth is -1 this isn't important as the thing
+	 *         won't run anyway.
+	 */
+	List<? extends DataflowOutputPort> getUnresolvedOutputs();
+
+	/**
+	 * An entity will be marked invalid if it depends on a nested dataflow which
+	 * itself is invalid. If this is the case the entity will be be present both
+	 * in {@link #getFailedEntities()} and can be used as a key with this method
+	 * to get the DataflowValidationReport explaining how the nested dataflow
+	 * failed.
+	 */
+	Map<TokenProcessingEntity, DataflowValidationReport> getInvalidDataflows();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Datalink.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Datalink.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Datalink.java
new file mode 100644
index 0000000..942eb3f
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Datalink.java
@@ -0,0 +1,55 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+import org.apache.taverna.annotation.Annotated;
+
+/**
+ * A single point to point data link from an instance of
+ * EventForwardingOutputPort to an instance of EventHandlingInputPort
+ * 
+ * @author Tom Oinn
+ */
+public interface Datalink extends Annotated<Datalink>, WorkflowItem {
+	/**
+	 * Get the sink for events flowing through this link
+	 * 
+	 * @return input port receiving events
+	 */
+	EventHandlingInputPort getSink();
+
+	/**
+	 * Get the source for events flowing through this link
+	 * 
+	 * @return output port generating events
+	 */
+	EventForwardingOutputPort getSource();
+
+	/**
+	 * Each datalink has a resolved depth, this being the constant sum of index
+	 * array length + item depth for all tokens exchanged along this link. Where
+	 * no iteration or data streaming is occuring this will evaluate to the
+	 * output port depth the link is from (as is always the case with the
+	 * internal output ports in dataflow inputs)
+	 * 
+	 * @return
+	 */
+	int getResolvedDepth();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Edit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Edit.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Edit.java
new file mode 100644
index 0000000..897c8bd
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Edit.java
@@ -0,0 +1,64 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+/**
+ * The workflow object model exposed by this API is read only. Properties of the
+ * model can only be changed through implementations of this interface, this
+ * ensures a consistant approach to grouped edits (transactions) and undo / redo
+ * support within the UI. It also potentially allows for capture of editing
+ * provenance where a workflow is repurposed or created from an aggregate of
+ * several others.
+ * 
+ * @author Tom Oinn
+ */
+public interface Edit<TargetType> {
+	/**
+	 * Perform the edit
+	 * 
+	 * @throws EditException
+	 *             if the edit fails. If an edit throws EditException it should
+	 *             try to ensure the subject is unaltered. Where this is
+	 *             impossible consider breaking edits down into a compound edit.
+	 */
+	TargetType doEdit() throws EditException;
+
+	/**
+	 * Undo the edit, reverting the subject to the state it was in prior to the
+	 * edit
+	 */
+	@Deprecated
+	void undo();
+
+	/**
+	 * Return the object to which this edit applies
+	 * 
+	 * @return
+	 */
+	Object getSubject();
+
+	/**
+	 * Has the edit been applied yet?
+	 * 
+	 * @return true if and only if the edit has been successfully applied to the
+	 *         subject
+	 */
+	boolean isApplied();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/EditException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/EditException.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/EditException.java
new file mode 100644
index 0000000..bdaf50c
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/EditException.java
@@ -0,0 +1,42 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+/**
+ * Superclass of all exceptions thrown when altering the workflow model through
+ * the edit manager.
+ * 
+ * @author Tom Oinn
+ */
+public class EditException extends Exception {
+	public EditException(String string) {
+		super(string);
+	}
+
+	public EditException(String string, Throwable cause) {
+		super(string, cause);
+	}
+	
+	public EditException(Throwable t) {
+		super(t);
+	}
+
+	private static final long serialVersionUID = 1L;
+}


[17/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/HierarchyRole.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/HierarchyRole.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/HierarchyRole.java
new file mode 100644
index 0000000..46ad2d3
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/HierarchyRole.java
@@ -0,0 +1,39 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation;
+
+/**
+ * Possible relationships between entities in a hierarchical context. This is
+ * used as a property of the HierarchyTraversal annotation on members which
+ * traverse a conceptual object hierarchy such as a parent-child containment
+ * relationship. As an example the getProcessors() method in Dataflow is
+ * annotated with <code>&amp;HierarchyRole(role=CHILD)</code> to indicate that
+ * it accesses child members of the workflow model containment hierarchy.
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public enum HierarchyRole {
+
+	CHILD,
+
+	PARENT;
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/HierarchyTraversal.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/HierarchyTraversal.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/HierarchyTraversal.java
new file mode 100644
index 0000000..5ba5e3a
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/HierarchyTraversal.java
@@ -0,0 +1,73 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Applied to getFoo methods to indicate that the returned type is related to
+ * the annotated type by some hierarchical relationship, either parent or child.
+ * This can then be used by annotation tools to determine the structure of an
+ * object under annotation in order to find any child objects without
+ * accidentally traversing outside of the bound of the object to be annotated.
+ * <p>
+ * As annotations are not inherited any annotation tool should traverse up the
+ * type structure of an object under annotation to determine the possible
+ * child-parent relationships from superclasses and implemented interfaces.
+ * <p>
+ * There is no guarantee that the return types from annotated members implement
+ * Annotated, in these cases traversal should still be followed to cover cases
+ * where a grandchild of an object is annotatable even though all children are
+ * not.
+ * <p>
+ * This should only be applied to method with no arguments, if this is not the
+ * case an annotation tool is free to not follow such methods (as it has no way
+ * to determine what should be applied as arguments)
+ * 
+ * @author Tom Oinn
+ * 
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+@Documented
+public @interface HierarchyTraversal {
+
+	/**
+	 * The role the return type of the annotated method plays in the named
+	 * hierarchy relative to the containing type.
+	 * 
+	 * @return role in hierarchy at corresponding index in the Hierarchies
+	 *         property, currently either CHILD or PARENT
+	 */
+	HierarchyRole[] role();
+
+	/**
+	 * It is possible for multiple orthogonal containment hierarchies to exist,
+	 * to allow for this the hierarchies are named using this field.
+	 * 
+	 * @return name of the hierarchy to which this relationship applies
+	 */
+	String[] hierarchies();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/Person.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/Person.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/Person.java
new file mode 100644
index 0000000..8a16062
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/Person.java
@@ -0,0 +1,35 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation;
+
+/**
+ * All metadata assertions and curation assertions have a person who is
+ * ultimately responsible for the assertion (although this may not necessarily
+ * imply that the assertion was created interactively).
+ * 
+ * TODO this needs to have some members! Cross reference with myExperiment user
+ * model I suspect.
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public interface Person {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/AbstractNumericRangeAssertion.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/AbstractNumericRangeAssertion.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/AbstractNumericRangeAssertion.java
new file mode 100644
index 0000000..148ba42
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/AbstractNumericRangeAssertion.java
@@ -0,0 +1,63 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation.annotationbeans;
+
+import org.apache.taverna.annotation.AnnotationBeanSPI;
+import org.apache.taverna.annotation.AppliesTo;
+
+/**
+ * Generic annotation containing a pair of numeric values with precision
+ * determined by the type parameter which form a bound.
+ * 
+ * @author Tom Oinn
+ * 
+ */
+@AppliesTo(targetObjectType = { Object.class }, many = true)
+public abstract class AbstractNumericRangeAssertion<NumericType extends Number>
+		implements AnnotationBeanSPI {
+
+	private NumericType upperNumericValue;
+
+	private NumericType lowerNumericValue;
+	
+	/**
+	 * Default constructor as mandated by java bean specification
+	 */
+	protected AbstractNumericRangeAssertion() {
+		//
+	}
+
+	public NumericType getUpperNumericValue() {
+		return upperNumericValue;
+	}
+
+	public void setUpperNumericValue(NumericType upperNumericValue) {
+		this.upperNumericValue = upperNumericValue;
+	}
+
+	public NumericType getLowerNumericValue() {
+		return lowerNumericValue;
+	}
+
+	public void setLowerNumericValue(NumericType lowerNumericValue) {
+		this.lowerNumericValue = lowerNumericValue;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/AbstractNumericValueAssertion.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/AbstractNumericValueAssertion.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/AbstractNumericValueAssertion.java
new file mode 100644
index 0000000..5f98188
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/AbstractNumericValueAssertion.java
@@ -0,0 +1,53 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation.annotationbeans;
+
+import org.apache.taverna.annotation.AnnotationBeanSPI;
+import org.apache.taverna.annotation.AppliesTo;
+
+/**
+ * Generic annotation containing a single number of precision specified by the
+ * type variable
+ * 
+ * @author Tom Oinn
+ * 
+ */
+@AppliesTo(targetObjectType = { Object.class }, many = true)
+public abstract class AbstractNumericValueAssertion<NumericType extends Number>
+		implements AnnotationBeanSPI {
+
+	private NumericType numericValue;
+
+	/**
+	 * Default constructor as mandated by java bean specification
+	 */
+	protected AbstractNumericValueAssertion() {
+		//
+	}
+
+	public NumericType getNumericValue() {
+		return numericValue;
+	}
+
+	public void setNumericValue(NumericType numericValue) {
+		this.numericValue = numericValue;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/AbstractTextualValueAssertion.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/AbstractTextualValueAssertion.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/AbstractTextualValueAssertion.java
new file mode 100644
index 0000000..e7f0164
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/AbstractTextualValueAssertion.java
@@ -0,0 +1,52 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation.annotationbeans;
+
+import org.apache.taverna.annotation.AnnotationBeanSPI;
+import org.apache.taverna.annotation.AppliesTo;
+
+/**
+ * Generic bit of free text that can be stuck to anything, subclass for more
+ * specific uses
+ * 
+ * @author Tom Oinn
+ * 
+ */
+@AppliesTo(targetObjectType = { Object.class }, many = true)
+public abstract class AbstractTextualValueAssertion implements AnnotationBeanSPI {
+
+	private String text;
+
+	/**
+	 * Default constructor as mandated by java bean specification
+	 */
+	protected AbstractTextualValueAssertion() {
+		//
+	}
+
+	public String getText() {
+		return text;
+	}
+
+	public void setText(String text) {
+		this.text = text;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/Author.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/Author.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/Author.java
new file mode 100644
index 0000000..8d65a64
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/Author.java
@@ -0,0 +1,43 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation.annotationbeans;
+
+import org.apache.taverna.annotation.AppliesTo;
+import org.apache.taverna.workflowmodel.Dataflow;
+
+/**
+ * The name of an author of a dataflow held as a String
+ * 
+ * It should allow many but currently only allows one
+ * 
+ * @author Alan R Williams
+ * 
+ */
+@AppliesTo(targetObjectType = { Dataflow.class }, many = false)
+public class Author extends AbstractTextualValueAssertion {
+
+	/**
+	 * Default constructor as mandated by java bean specification
+	 */
+	public Author() {
+		//
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/DescriptiveTitle.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/DescriptiveTitle.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/DescriptiveTitle.java
new file mode 100644
index 0000000..de6fe01
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/DescriptiveTitle.java
@@ -0,0 +1,41 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation.annotationbeans;
+
+import org.apache.taverna.annotation.AppliesTo;
+import org.apache.taverna.workflowmodel.Dataflow;
+
+/**
+ * The descriptive title of a dataflow held as a String
+ * 
+ * @author Alan R Williams
+ * 
+ */
+@AppliesTo(targetObjectType = { Dataflow.class }, many = false)
+public class DescriptiveTitle extends AbstractTextualValueAssertion {
+
+	/**
+	 * Default constructor as mandated by java bean specification
+	 */
+	public DescriptiveTitle() {
+		//
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/DocumentationUrl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/DocumentationUrl.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/DocumentationUrl.java
new file mode 100644
index 0000000..55c13b0
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/DocumentationUrl.java
@@ -0,0 +1,57 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation.annotationbeans;
+
+import java.net.URL;
+import org.apache.taverna.annotation.AnnotationBeanSPI;
+import org.apache.taverna.annotation.AppliesTo;
+import org.apache.taverna.workflowmodel.Dataflow;
+import org.apache.taverna.workflowmodel.Port;
+import org.apache.taverna.workflowmodel.Processor;
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+
+/**
+ * A link to documentation for the target element contained at a particular
+ * Uniform Resource Locator (URL)
+ * 
+ * @author Tom Oinn
+ * @author Alan Williams
+ */
+@AppliesTo(targetObjectType = { Port.class, Activity.class, Processor.class, Dataflow.class }, many = true)
+public class DocumentationUrl implements AnnotationBeanSPI {
+
+	private URL documentationURL;
+
+	/**
+	 * Default constructor as mandated by java bean specification
+	 */
+	public DocumentationUrl() {
+		//
+	}
+
+	public URL getDocumentationURL() {
+		return documentationURL;
+	}
+
+	public void setDocumentationURL(URL documentationURL) {
+		this.documentationURL = documentationURL;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/ExampleValue.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/ExampleValue.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/ExampleValue.java
new file mode 100644
index 0000000..48d368e
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/ExampleValue.java
@@ -0,0 +1,42 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation.annotationbeans;
+
+import org.apache.taverna.annotation.AppliesTo;
+import org.apache.taverna.workflowmodel.DataflowInputPort;
+import org.apache.taverna.workflowmodel.DataflowOutputPort;
+
+/**
+ * A String containing an example or a description of an example
+ * 
+ * @author Alan R Williams
+ * 
+ */
+@AppliesTo(targetObjectType = { DataflowInputPort.class , DataflowOutputPort.class }, many = false)
+public class ExampleValue extends AbstractTextualValueAssertion {
+
+	/**
+	 * Default constructor as mandated by java bean specification
+	 */
+	public ExampleValue() {
+		//
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/FreeTextDescription.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/FreeTextDescription.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/FreeTextDescription.java
new file mode 100644
index 0000000..9164e86
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/FreeTextDescription.java
@@ -0,0 +1,47 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation.annotationbeans;
+
+import org.apache.taverna.annotation.AppliesTo;
+import org.apache.taverna.workflowmodel.Condition;
+import org.apache.taverna.workflowmodel.Dataflow;
+import org.apache.taverna.workflowmodel.DataflowPort;
+import org.apache.taverna.workflowmodel.Datalink;
+import org.apache.taverna.workflowmodel.Processor;
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+
+/**
+ * An unconstrained textual description held as a String
+ * 
+ * @author Tom Oinn
+ * 
+ */
+@AppliesTo(targetObjectType = { Dataflow.class, Processor.class,
+		Activity.class, DataflowPort.class, Datalink.class, Condition.class }, many = false)
+public class FreeTextDescription extends AbstractTextualValueAssertion {
+
+	/**
+	 * Default constructor as mandated by java bean specification
+	 */
+	public FreeTextDescription() {
+		//
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/HostInstitution.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/HostInstitution.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/HostInstitution.java
new file mode 100644
index 0000000..4a69e55
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/HostInstitution.java
@@ -0,0 +1,41 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation.annotationbeans;
+
+import org.apache.taverna.annotation.AppliesTo;
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+
+/**
+ * The host institution for an activity implementation
+ * 
+ * @author Tom Oinn
+ * @author Alan Williams
+ */
+@AppliesTo(targetObjectType = { Activity.class }, many = false)
+public class HostInstitution extends AbstractTextualValueAssertion {
+
+	/**
+	 * Default constructor as mandated by java bean specification
+	 */
+	public HostInstitution() {
+		super();
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/IdentificationAssertion.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/IdentificationAssertion.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/IdentificationAssertion.java
new file mode 100644
index 0000000..023eb05
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/IdentificationAssertion.java
@@ -0,0 +1,54 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation.annotationbeans;
+
+import org.apache.taverna.annotation.AnnotationBeanSPI;
+import org.apache.taverna.annotation.AppliesTo;
+import org.apache.taverna.workflowmodel.Dataflow;
+
+/**
+ * An IdentificationAssertion is used to hold previous identifications of an
+ * object.
+ * 
+ * @author alanrw
+ * 
+ */
+@AppliesTo(targetObjectType = { Dataflow.class }, many = false, pruned = false)
+public class IdentificationAssertion implements AnnotationBeanSPI {
+
+	private String identification;
+
+	/**
+	 * @return The identification. This will be a previous identifier of the
+	 *         annotated object.
+	 */
+	public String getIdentification() {
+		return identification;
+	}
+
+	/**
+	 * @param identification
+	 *            A previous identified of the annotated object.
+	 */
+	public void setIdentification(String identification) {
+		this.identification = identification;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/MimeType.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/MimeType.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/MimeType.java
new file mode 100644
index 0000000..afa4c4e
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/MimeType.java
@@ -0,0 +1,59 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation.annotationbeans;
+
+import org.apache.taverna.annotation.AppliesTo;
+import org.apache.taverna.workflowmodel.Port;
+
+/**
+ * A single MIME type, intended to be used to annotate an input or output port
+ * within the workflow to denote the type within that system of data produced or
+ * consumed by the port.
+ * 
+ * @author Tom Oinn
+ * 
+ */
+@AppliesTo(targetObjectType = { Port.class })
+public class MimeType extends AbstractTextualValueAssertion {
+
+	/**
+	 * Default constructor as mandated by java bean specification
+	 */
+	public MimeType() {
+		super();
+	}
+
+	/**
+	 * Return the MIME type as a string, mime types look like 'part/part'. We
+	 * may want to consider whether it's possible to make this a genuine
+	 * enumeration driven off a canonical list of MIME types or whether it's
+	 * best kept as the current (free) string. The advantage of an enumerated
+	 * type is that we could attach description to the MIME types which would
+	 * help with the UI construction but maybe this isn't the place to put it
+	 * (should this link be in the UI layer? probably)
+	 * 
+	 * @return the MIME type as a string.
+	 */
+	@Override
+	public String getText() {
+		return super.getText();
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/Optional.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/Optional.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/Optional.java
new file mode 100644
index 0000000..9a39040
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/Optional.java
@@ -0,0 +1,43 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation.annotationbeans;
+
+import org.apache.taverna.annotation.AppliesTo;
+import org.apache.taverna.annotation.AnnotationBeanSPI;
+import org.apache.taverna.workflowmodel.InputPort;
+
+/**
+ * A declaration that the bound input port is optional, if this annotation is
+ * refuted then the interpretation should be that the input port is required.
+ * 
+ * @author Tom Oinn
+ * @author Alan Williams
+ */
+@AppliesTo(targetObjectType = { InputPort.class }, many = false)
+public class Optional implements AnnotationBeanSPI {
+
+	/**
+	 * Default constructor as mandated by java bean specification
+	 */
+	public Optional() {
+		//
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/SemanticAnnotation.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/SemanticAnnotation.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/SemanticAnnotation.java
new file mode 100644
index 0000000..7cd87ec
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/annotationbeans/SemanticAnnotation.java
@@ -0,0 +1,67 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation.annotationbeans;
+
+import org.apache.taverna.annotation.AnnotationBeanSPI;
+import org.apache.taverna.annotation.AppliesTo;
+import org.apache.taverna.workflowmodel.Condition;
+import org.apache.taverna.workflowmodel.Dataflow;
+import org.apache.taverna.workflowmodel.Datalink;
+import org.apache.taverna.workflowmodel.Merge;
+import org.apache.taverna.workflowmodel.Port;
+import org.apache.taverna.workflowmodel.Processor;
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+import org.apache.taverna.workflowmodel.processor.dispatch.DispatchLayer;
+
+/**
+ * A SemanticAssertion holds a String which contains RDF about an Object
+ * @author alanrw
+ *
+ */
+@AppliesTo(targetObjectType = { Dataflow.class, Processor.class, Port.class, Activity.class, Datalink.class, Merge.class, Condition.class, DispatchLayer.class }, many = false)
+public class SemanticAnnotation implements AnnotationBeanSPI {
+	
+	private String mimeType = "text/rdf+n3";
+	
+	private String content = "";
+
+	public String getMimeType() {
+		return mimeType;
+	}
+
+	public void setMimeType(String mimeType) {
+		this.mimeType = mimeType;
+	}
+
+	/**
+	 * @param content the content to set
+	 */
+	public void setContent(String content) {
+		this.content = content;
+	}
+
+	/**
+	 * @return the content
+	 */
+	public String getContent() {
+		return content;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/package.html b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/package.html
new file mode 100644
index 0000000..99a5a4f
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/package.html
@@ -0,0 +1,17 @@
+<body>
+Entities within the workflow object model may be marked as annotated.
+When marked as such they contract to provide one or more of a variety of
+forms of metadata, whether generic or specific to the type of object
+within the model. This description is deliberately kept vague for now
+because we haven't yet enumerated what classes of annotation exist on
+each entity.
+<p>From this point in we will use the term 'metadata' to distinguish
+between annotations in terms of properties of the workflow and
+annotations in terms of the Java 5 language feature. This is
+particularly important we we use Java Annotations to implement the
+workflow annotations. Yay.
+<p>In keeping with the read-only model of the API package all
+metadata interfaces only specify the get methods for their respective
+contents. Modification of metadata instances is performed through Edit
+objects.
+</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/facade/FacadeListener.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/facade/FacadeListener.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/facade/FacadeListener.java
new file mode 100644
index 0000000..01359ce
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/facade/FacadeListener.java
@@ -0,0 +1,48 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.facade;
+
+import org.apache.taverna.facade.WorkflowInstanceFacade.State;
+
+/**
+ * Used to communicate a failure of the overall workflow to interested parties.
+ * 
+ * @author Tom Oinn
+ */
+public interface FacadeListener {
+	/**
+	 * Called if the workflow fails in a critical and fundamental way. Most
+	 * internal failures of individual process instances will not trigger this,
+	 * being handled either by the per processor dispatch stack through retry,
+	 * failover etc or by being converted into error tokens and injected
+	 * directly into the data stream. This therefore denotes a catastrophic and
+	 * unrecoverable problem.
+	 * 
+	 * @param message
+	 *            Description of what happened
+	 * @param t
+	 *            The cause of the failure
+	 */
+	void workflowFailed(WorkflowInstanceFacade facade, String message,
+			Throwable t);
+
+	void stateChange(WorkflowInstanceFacade facade, State oldState,
+			State newState);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/facade/ResultListener.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/facade/ResultListener.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/facade/ResultListener.java
new file mode 100644
index 0000000..0415b40
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/facade/ResultListener.java
@@ -0,0 +1,42 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.facade;
+
+import org.apache.taverna.invocation.WorkflowDataToken;
+
+/**
+ * Implement and use with the WorkflowInstanceFacade to listen for data
+ * production events from the underlying workflow instance
+ * 
+ * @author Tom Oinn
+ */
+public interface ResultListener {
+	/**
+	 * Called when a new result token is produced by the workflow instance.
+	 * 
+	 * @param token
+	 *            the WorkflowDataToken containing the result.
+	 * @param portName
+	 *            The name of the output port on the workflow from which this
+	 *            token is produced, this now folds in the owning process which
+	 *            was part of the signature for this method
+	 */
+	void resultTokenProduced(WorkflowDataToken token, String portName);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/facade/WorkflowInstanceFacade.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/facade/WorkflowInstanceFacade.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/facade/WorkflowInstanceFacade.java
new file mode 100644
index 0000000..a7a02e7
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/facade/WorkflowInstanceFacade.java
@@ -0,0 +1,236 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.facade;
+
+import java.lang.ref.WeakReference;
+import java.util.WeakHashMap;
+
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.invocation.TokenOrderException;
+import org.apache.taverna.invocation.WorkflowDataToken;
+import org.apache.taverna.monitor.MonitorNode;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.utility.TypedTreeModel;
+import org.apache.taverna.workflowmodel.ControlBoundary;
+import org.apache.taverna.workflowmodel.Dataflow;
+
+/**
+ * The interaction point with a workflow instance. Technically there is no such
+ * thing as a workflow instance in Taverna2, at least not in any real sense in
+ * the code itself. The instance is more literally an identifier used as the
+ * root of all data and error objects within this workflow and by which the top
+ * level DataFlow or similar object is identified in the state tree. The
+ * implementation of this interface should hide this though, automatically
+ * prepending the internally stored (and hidden) identifier to all data push
+ * messages and providing a subtree of the state model rooted at the internal
+ * ID.
+ * <p>
+ * TODO - we should probably have callbacks for failure states here, but that
+ * would need a decent definition (and maybe even ontology of) what failure
+ * means. It's less obvious in a data streaming world what a failure is. At the
+ * moment the dispatch stack can potentially treat unhandled error messages as
+ * failing the processor, how do we get this exception information back up to
+ * the workflow level?
+ * 
+ * @author Tom Oinn
+ * @author Alex Nenadic
+ * @author Stian Soiland-Reyes
+ * @author Alan R Williams
+ */
+@ControlBoundary
+public interface WorkflowInstanceFacade {
+	public static enum State {
+		/**
+		 * Workflow has not yet been started using
+		 * {@link WorkflowInstanceFacade#fire()}
+		 */
+		prepared,
+		/**
+		 * Workflow is running (or have been resumed using
+		 * {@link WorkflowInstanceFacade#fire()})
+		 */
+		running,
+		/**
+		 * Workflow has been paused using
+		 * {@link WorkflowInstanceFacade#pauseWorkflowRun()}
+		 */
+		paused,
+		/**
+		 * Workflow has completed, all processors are finished and all data
+		 * delivered to all output ports.
+		 */
+		completed,
+		/**
+		 * Workflow has been cancelled using
+		 * {@link WorkflowInstanceFacade#cancelWorkflowRun()}
+		 */
+		cancelled;
+	}
+
+	/**
+	 * A weak hash map of all workflow run IDs mapped against the corresponding
+	 * WorkflowInstanceFacadeS. This is needed for activities with dependencies
+	 * (such as beanshell and API consumer) to gain access to the current
+	 * workflow via the WorkflowInstanceFacade.
+	 */
+	static final WeakHashMap<String, WeakReference<WorkflowInstanceFacade>> workflowRunFacades = new WeakHashMap<>();
+
+	/**
+	 * Push a data token into the specified port. If the token is part of a
+	 * stream the index contains the index of this particular token. If not the
+	 * index should be the empty integer array.
+	 * 
+	 * @param token
+	 *            A WorkflowDataToken containing the data to be pushed to the
+	 *            workflow along with its current owning process identifier and
+	 *            index
+	 * @param portName
+	 *            Port name to use
+	 * @throws TokenOrderException
+	 *             if ordering constraints on the token stream to each input
+	 *             port are violated
+	 */
+	void pushData(WorkflowDataToken token, String portName)
+			throws TokenOrderException;
+
+	/**
+	 * Where a workflow has no inputs this method will cause it to start
+	 * processing. Any processors within the workflow with no inputs are fired.
+	 * 
+	 * @throws IllegalStateException
+	 *             if the workflow has already been fired or has had data pushed
+	 *             to it.
+	 */
+	void fire() throws IllegalStateException;
+
+	/**
+	 * The result listener is used to handle data tokens produced by the
+	 * workflow.
+	 * <p>
+	 * If the listener is registered after the workflow has already produced
+	 * results it will be immediately called with any results previously
+	 * produced. Where the workflow has completed a stream of results it may
+	 * only message the listener with the highest level one, so for a case where
+	 * a list of results is emited one at a time the listener may either get the
+	 * individual items followed by the list token or if registered after the
+	 * list token has been emited only receive the list token.
+	 * 
+	 * @param listener
+	 */
+	void addResultListener(ResultListener listener);
+
+	/**
+	 * Remove a previously registered result listener
+	 * 
+	 * @param listener
+	 */
+	void removeResultListener(ResultListener listener);
+
+	/**
+	 * A failure listener reports on overall workflow failure. It is not
+	 * triggered by the failure of individual processors unless that processor
+	 * is marked as critical. In fact in T2 all processors are marked as
+	 * critical by default as there are ways of handling errors within the data
+	 * stream, if the processor actually fails something really bad has
+	 * happened.
+	 * <p>
+	 * As with the result listener a failure listener registered after the
+	 * workflow has already failed will be immediately called with the failure
+	 * data.
+	 */
+	void addFacadeListener(FacadeListener listener);
+
+	/**
+	 * Remove a previously registered failure listener
+	 */
+	void removeFacadeListener(FacadeListener listener);
+
+	/**
+	 * Workflow state is available through a sub-tree of the monitor tree. For
+	 * security reasons the full monitor tree is never accessible through this
+	 * interface but the sub-tree rooted at the node representing this workflow
+	 * instance is and can be used for both monitoring and steering functions.
+	 * <p>
+	 * Uses the standard TreeModel-like mechanisms for registering change events
+	 * and can be plugged into a JTree for display purposes through the
+	 * TreeModelAdapter class.
+	 * 
+	 * @return Typed version of TreeModel representing the state of this
+	 *         workflow. Nodes in the tree are instances of MonitorNode
+	 */
+	TypedTreeModel<MonitorNode> getStateModel();
+
+	/**
+	 * Return the dataflow this facade facades
+	 */
+	Dataflow getDataflow();
+
+	/**
+	 * Return the invocation context used by this facade
+	 */
+	InvocationContext getContext();
+
+	/**
+	 * Return a map of the data pushed on the named port
+	 */
+	WeakHashMap<String, T2Reference> getPushedDataMap();
+
+	/**
+	 * Get the unique id of the wf run inside the facede.
+	 */
+	String getWorkflowRunId();
+
+	/**
+	 * Cancel the workflow run corresponding to this facade
+	 * 
+	 * @return true if the workflow run was successfully cancelled. Note that
+	 *         this does not mean that all of the invocations associated with
+	 *         the run have finished.
+	 */
+	boolean cancelWorkflowRun() throws IllegalStateException;
+
+	/**
+	 * Pause the workflow run corresponding to this facade
+	 * 
+	 * @return true if the workflow run was successfully paused.
+	 */
+	boolean pauseWorkflowRun() throws IllegalStateException;
+
+	/**
+	 * Resume the workflow run corresponding to this facade
+	 * 
+	 * @return true if the workflow run was successfully resumed
+	 */
+	boolean resumeWorkflowRun() throws IllegalStateException;
+
+	/**
+	 * Return the current workflow {@link State}.
+	 * 
+	 * @return The workflow state.
+	 */
+	State getState();
+
+	/**
+	 * An identifier that is unique to this facade.
+	 * 
+	 * @return a String representing a unique internal identifier.
+	 */
+	String getIdentifier();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/facade/WorkflowRunCancellation.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/facade/WorkflowRunCancellation.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/facade/WorkflowRunCancellation.java
new file mode 100644
index 0000000..53d8d98
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/facade/WorkflowRunCancellation.java
@@ -0,0 +1,45 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.facade;
+
+/**
+ * A WorkflowRunCancellation is passed to listeners when a workflow run is
+ * cancelled.
+ * 
+ * @author alanrw
+ */
+@SuppressWarnings("serial")
+public class WorkflowRunCancellation extends Throwable {
+	/**
+	 * The id of the workflow run that was cancelled
+	 */
+	private String cancelledWorkflowRunId;
+	
+	public WorkflowRunCancellation (String runId) {
+		cancelledWorkflowRunId = runId;
+	}
+
+	/**
+	 * @return the id of the workflow run that was cancelled.
+	 */
+	public String getCancelledWorkflowRunId() {
+		return cancelledWorkflowRunId;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/facade/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/facade/package.html b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/facade/package.html
new file mode 100644
index 0000000..898ccdf
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/facade/package.html
@@ -0,0 +1,24 @@
+<body>
+Facade interfaces to represent a workflow instance within the enactor.
+<p>Although T2 has no 'real' concept of a workflow instance, using
+identifiers on data instead, it is useful to treat it as if it does. The
+facade classes are the external 'invoke only' interface to the enactment
+system, providing wrappers around the actual single instance model. This
+also hides the shared state tree, exposing only the sub-tree rooted at
+the base ID internal to the facade layer. The state tree acts both as
+monitoring and steering infrastructure, the facade therefore prevents a
+process accessing the state of another workflow either maliciously or
+inadvertently.
+<p>The construction of these facade objects is not defined here, a
+factory method in the implementation package is the most likely
+candidate but there are other options, for example a peer to peer cloud
+may expose services to create new facades and allow access as might a
+web service based interface. The interfaces here are intended to be as
+easy to access remotely as possible.
+<p>For the same reasons there are no methods in the workflow facade
+concerning security or the management of data access - it is assumed
+that the constructor of the facade layer has embedded such concerns
+within it. There is therefore a clear split between initiation of the
+workflow session and manipulation of it with this package only
+addressing the latter of the two.
+</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/Completion.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/Completion.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/Completion.java
new file mode 100644
index 0000000..1eca3a1
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/Completion.java
@@ -0,0 +1,106 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.invocation;
+
+/**
+ * Contains a (possibly partial) completion event. The completion event is a
+ * statement that no further events will occur on this channel with an index
+ * prefixed by the completion index. As with Job events completion events have
+ * an owning process with the same semantics as that of the Job class
+ * <p>
+ * The conceptual depth of a completion is the sum of the length of index array
+ * for any data tokens the completion shares a stream with and the depth of
+ * those tokens. This should be constant for any given token stream.
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public class Completion extends IterationInternalEvent<Completion> {
+
+	/**
+	 * Construct a new optionally partial completion event with the specified
+	 * owner and completion index
+	 * 
+	 * @param owningProcess
+	 * @param completionIndex
+	 */
+	public Completion(String owningProcess, int[] completionIndex,
+			InvocationContext context) {
+		super(owningProcess, completionIndex, context);
+	}
+
+	/**
+	 * Construct a new final completion event, equivalent to calling new
+	 * Completion(owningProcess, new int[0]);
+	 * 
+	 * @param owningProcess
+	 */
+	public Completion(String owningProcess, InvocationContext context) {
+		super(owningProcess, new int[0], context);
+	}
+
+	@Override
+	public String toString() {
+		StringBuffer sb = new StringBuffer();
+		sb.append("Cmp(" + owner + ")[");
+		for (int i = 0; i < index.length; i++) {
+			if (i > 0) {
+				sb.append(",");
+			}
+			sb.append(index[i] + "");
+		}
+		sb.append("]");
+		return sb.toString();
+	}
+
+	/**
+	 * Push the index array onto the owning process name and return the new Job
+	 * object. Does not modify this object, the method creates a new Job with
+	 * the modified index array and owning process
+	 * 
+	 * @return
+	 */
+	@Override
+	public Completion pushIndex() {
+		return new Completion(getPushedOwningProcess(), new int[] {}, context);
+	}
+
+	/**
+	 * Pull the index array previous pushed to the owning process name and
+	 * prepend it to the current index array
+	 */
+	@Override
+	public Completion popIndex() {
+		return new Completion(owner.substring(0, owner.lastIndexOf(':')),
+				getPoppedIndex(), context);
+	}
+
+	@Override
+	public Completion popOwningProcess() throws ProcessIdentifierException {
+		return new Completion(popOwner(), index, context);
+	}
+
+	@Override
+	public Completion pushOwningProcess(String localProcessName)
+			throws ProcessIdentifierException {
+		return new Completion(pushOwner(localProcessName), index, context);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/Event.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/Event.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/Event.java
new file mode 100644
index 0000000..609c0ec
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/Event.java
@@ -0,0 +1,167 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.invocation;
+
+/**
+ * Abstract superclass of all 'event' types within a workflow invocation. These
+ * are the Job and Completion events which are used internally within a
+ * Processor, in particular by the dispatch stack and iteration system, and the
+ * WorkflowDataToken which is the only event class that can exist outside of a
+ * Processor boundary (and is therefore the most significant one for users of
+ * the API)
+ * 
+ * @author Tom Oinn
+ */
+public abstract class Event<EventType extends Event<?>> {
+	protected String owner;
+	protected InvocationContext context;
+	protected int[] index;
+
+	protected Event(String owner, int[] index, InvocationContext context) {
+		this.owner = owner;
+		this.index = index;
+		this.context = context;
+		if (index == null)
+			throw new RuntimeException("Job index cannot be null");
+		if (owner == null)
+			throw new RuntimeException("Owning process cannot be null");
+		if (context == null)
+			throw new RuntimeException("Invocation context cannot be null");
+	}
+
+	/**
+	 * An event is final if its index array is zero length
+	 * 
+	 * @return true if indexarray.length==0
+	 */
+	public final boolean isFinal() {
+		return (index.length == 0);
+	}
+
+	/**
+	 * The event has an owner, this is represented as a String object but the
+	 * ownership is hierarchical in nature. The String is a colon separated list
+	 * of alphanumeric process identifiers, with identifiers being pushed onto
+	 * this list on entry to a process and popped off on exit.
+	 * 
+	 * @return String of colon separated process identifiers owning this Job
+	 */
+	public final String getOwningProcess() {
+		return this.owner;
+	}
+
+	public final InvocationContext getContext() {
+		return this.context;
+	}
+
+	/**
+	 * Return a copy of the event subclass with the last owning process removed
+	 * from the owning process list. For example, if the event had owner
+	 * 'foo:bar' this would return a duplicate event with owner 'foo'. If the
+	 * owning process is the empty string this is invalid and will throw a
+	 * ProcessIdentifierException
+	 * 
+	 * @return a copy of the event with the parent process identifier
+	 */
+	public abstract EventType popOwningProcess()
+			throws ProcessIdentifierException;
+
+	/**
+	 * Return a copy of the event subclass with the specified local process name
+	 * appended to the owning process identifier field. If the original owner
+	 * was 'foo' and this was called with 'bar' you'd end up with a copy of the
+	 * subclass with owner 'foo:bar'
+	 * 
+	 * @param localProcessName
+	 *            name to add
+	 * @return the modified event
+	 * @throws ProcessIdentifierException
+	 *             if the local process name contains the ':' character
+	 */
+	public abstract EventType pushOwningProcess(String localProcessName)
+			throws ProcessIdentifierException;
+
+	/**
+	 * Events have an index placing them in a conceptual tree structure. This
+	 * index is carried along with the event and used at various points to drive
+	 * iteration and ensure that separate jobs are kept that way
+	 */
+	public final int[] getIndex() {
+		return this.index;
+	}
+
+	/**
+	 * Helper method for implementations of popOwningProcess, this constructs
+	 * the appropriate process identifier after the leaf has been removed and
+	 * returns it. If there is no leaf to remove, i.e. the current process
+	 * identifier is the empty string, then ProcessIdentifierException is thrown
+	 * 
+	 * @return
+	 * @throws ProcessIdentifierException
+	 */
+	protected final String popOwner() throws ProcessIdentifierException {
+		// Empty string already, can't pop from here, throw exception
+		if (owner.isEmpty())
+			throw new ProcessIdentifierException(
+					"Attempt to pop a null owning process (empty string)");
+		// A single ID with no colon in, return the empty string
+		if (owner.lastIndexOf(':') < 0)
+			return "";
+		return owner.substring(0, owner.lastIndexOf(':'));
+	}
+
+	/**
+	 * Helper method for implementations of pushOwningProcess, appends the
+	 * specified local name to the current owning process identifier and returns
+	 * the new id. This doesn't change the current process identifier. If there
+	 * is a colon ':' in the specified name this is invalid and will throw
+	 * ProcessIdentifierException at you.
+	 * 
+	 * @param newLocalProcess
+	 * @return
+	 * @throws ProcessIdentifierException
+	 */
+	protected final String pushOwner(String newLocalProcess)
+			throws ProcessIdentifierException {
+		if (newLocalProcess.contains(":"))
+			throw new ProcessIdentifierException("Can't push '"
+					+ newLocalProcess + "' as it contains a ':' character");
+		if (owner.isEmpty())
+			// If the owner was the empty string we don't need to append the
+			// colon
+			return newLocalProcess;
+		return owner + ":" + newLocalProcess;
+	}
+
+	@Override
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		sb.append(getClass().getSimpleName());
+		sb.append(' ');
+		sb.append(owner);
+		sb.append('[');
+		for (int i : index) {
+			sb.append(i);
+			sb.append(" ");
+		}
+		sb.append(']');
+		return sb.toString();
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/InvocationContext.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/InvocationContext.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/InvocationContext.java
new file mode 100644
index 0000000..c4f2535
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/InvocationContext.java
@@ -0,0 +1,43 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.invocation;
+
+import org.apache.taverna.provenance.reporter.ProvenanceReporter;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferenceService;
+
+/**
+ * Carries the context of a workflow invocation, the necessary data manager,
+ * security agents and any other resource shared across the invocation such as
+ * provenance injectors.
+ * 
+ * @author Tom Oinn
+ */
+public interface InvocationContext extends ReferenceContext {
+	/**
+	 * Return the reference service to be used within this invocation context
+	 * 
+	 * @return a configured instance of ReferenceService to be used to resolve
+	 *         and register references to data in the workflow
+	 */
+	ReferenceService getReferenceService();
+
+	ProvenanceReporter getProvenanceReporter();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/IterationInternalEvent.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/IterationInternalEvent.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/IterationInternalEvent.java
new file mode 100644
index 0000000..94a1b92
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/IterationInternalEvent.java
@@ -0,0 +1,102 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.invocation;
+
+/**
+ * Abstract superclass for event types which have to pass through the iteration
+ * system. For this they need the ability to push and pull the iteration index
+ * to and from the process identifier, this is done through the popIndex and
+ * pushIndex methods. Subclasses of this may be used outside the iteration
+ * system but anything which is passed into the iteration system must provide
+ * this functionality.
+ * 
+ * @author Tom Oinn
+ * 
+ * @param <EventType>
+ *            reflexive self type
+ */
+public abstract class IterationInternalEvent<EventType extends IterationInternalEvent<?>>
+		extends Event<EventType> {
+	/**
+	 * Protected constructor for the minimum fields required by all Event
+	 * subclasses
+	 * 
+	 * @param owner
+	 * @param index
+	 * @param context
+	 */
+	protected IterationInternalEvent(String owner, int[] index,
+			InvocationContext context) {
+		super(owner, index, context);
+	}
+
+	/**
+	 * Pop a previously pushed index array off the process name and append the
+	 * current index array to create the new index array. This is applied to a
+	 * new instance of an Event subclass and does not modify the target.
+	 * 
+	 * @return new Event subclass with modified owning process and index
+	 */
+	public abstract IterationInternalEvent<EventType> popIndex();
+
+	/**
+	 * Push the index array onto the owning process name and return the new
+	 * Event subclass object. Does not modify this object, the method creates a
+	 * new Event subclass with the modified index array and owning process.
+	 * 
+	 */
+	public abstract IterationInternalEvent<EventType> pushIndex();
+
+	/**
+	 * Helper method for the pushIndex operation
+	 * 
+	 * @return
+	 */
+	protected final String getPushedOwningProcess() {
+		StringBuilder sb = new StringBuilder(owner).append(":");
+		String sep = "";
+		for (int idx : index) {
+			sb.append(sep).append(idx);
+			sep = ",";
+		}
+		return sb.toString();
+	}
+
+	/**
+	 * Helper method for the popIndex operation, returns the modified index
+	 * array. Subclasses must still implement logic to get the modified owning
+	 * process but that's relatively easy : <code>
+	 * return new &lt;Event subclass&gt;(owner.substring(0, owner.lastIndexOf(':')),getPoppedIndex(), dataMap);
+	 * </code>
+	 * 
+	 * @return
+	 */
+	protected final int[] getPoppedIndex() {
+		int lastLocation = owner.lastIndexOf(':');
+		String indexArrayAsString = owner.substring(lastLocation + 1);
+		String[] parts = indexArrayAsString.split(",");
+		int[] newIndexArray = new int[index.length + parts.length];
+		int pos = 0;
+		for (String part : parts)
+			newIndexArray[pos++] = Integer.parseInt(part);
+		System.arraycopy(index, 0, newIndexArray, pos, index.length);
+		return newIndexArray;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/ProcessIdentifierException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/ProcessIdentifierException.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/ProcessIdentifierException.java
new file mode 100644
index 0000000..3b98282
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/ProcessIdentifierException.java
@@ -0,0 +1,47 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.invocation;
+
+/**
+ * Thrown when attempting to create an invalid process identifier, either by
+ * popping an empty one (this by definition has no parents) or by pushing a
+ * local name including a colon ':' character.
+ * 
+ * @author Tom Oinn
+ */
+public class ProcessIdentifierException extends RuntimeException {
+	private static final long serialVersionUID = -221443591753067425L;
+
+	public ProcessIdentifierException() {
+		super();
+	}
+
+	public ProcessIdentifierException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+	public ProcessIdentifierException(String message) {
+		super(message);
+	}
+
+	public ProcessIdentifierException(Throwable cause) {
+		super(cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/TokenOrderException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/TokenOrderException.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/TokenOrderException.java
new file mode 100644
index 0000000..e49d054
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/TokenOrderException.java
@@ -0,0 +1,48 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.invocation;
+
+/**
+ * Thrown when tokens are supplied in an invalid order. Examples of this are
+ * where duplicate indices are supplied in the same token stream or where list
+ * items are emitted at a point where the individual members haven't been fully
+ * populated.
+ * 
+ * @author Tom Oinn
+ */
+public class TokenOrderException extends Exception {
+	public TokenOrderException() {
+		super();
+	}
+
+	public TokenOrderException(String arg0, Throwable arg1) {
+		super(arg0, arg1);
+	}
+
+	public TokenOrderException(String arg0) {
+		super(arg0);
+	}
+
+	public TokenOrderException(Throwable arg0) {
+		super(arg0);
+	}
+
+	private static final long serialVersionUID = -7870614853928171878L;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/TreeCache.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/TreeCache.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/TreeCache.java
new file mode 100644
index 0000000..48a45bc
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/TreeCache.java
@@ -0,0 +1,199 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.invocation;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.taverna.workflowmodel.processor.activity.Job;
+
+/**
+ * Tree cache for jobs waiting to be combined and dispatched down the iteration
+ * system
+ * 
+ * @author Tom Oinn
+ */
+public class TreeCache {
+	private NamedNode root = null;
+	private int indexDepth = -1;
+
+	/**
+	 * Show the tree structure, printing each node recursively
+	 */
+	@Override
+	public synchronized String toString() {
+		if (root == null)
+			return "No root node defined.";
+		StringBuilder sb = new StringBuilder();
+		printNode(root, sb, "");
+		return sb.toString();
+	}
+	
+	private synchronized void printNode(NamedNode node, StringBuilder sb, String indent) {
+		sb.append(indent).append("Node (").append(node.contents).append(")\n");
+		String newIndent = indent + "  ";
+		for (NamedNode child : node.children)
+			if (child == null)
+				sb.append(newIndent).append("null\n");
+			else
+				printNode(child, sb, newIndent);
+	}
+	
+	public class NamedNode {
+		public Job contents = null;
+		public List<NamedNode> children = new ArrayList<>();
+
+		public void insertJob(Job j) {
+			insertJobAt(j, j.getIndex());
+		}
+
+		private void insertJobAt(Job j, int[] position) {
+			if (position.length == 0) {
+				this.contents = j;
+				return;
+			}
+			int firstIndex = position[0];
+			if (firstIndex >= children.size())
+				// Pad with blank NamedNode objects
+				for (int i = children.size(); i <= firstIndex; i++)
+					children.add(null);
+			NamedNode child = children.get(firstIndex);
+			if (child == null) {
+				child = new NamedNode();
+				children.set(firstIndex, child);
+			}
+
+			int[] newTarget = new int[position.length - 1];
+			for (int i = 1; i < position.length; i++)
+				newTarget[i - 1] = position[i];
+			child.insertJobAt(j, newTarget);
+		}
+
+		public NamedNode childAt(int i) {
+			if (i >= children.size())
+				return null;
+			return children.get(i);
+		}
+	}
+
+	/**
+	 * The length of index arrays of jobs within the TreeCache. This assumes
+	 * that all jobs have the same index array length, this is true when the
+	 * cache is used by the iteration strategy but may not be in other
+	 * scenarios, use with caution!
+	 * <p>
+	 * If no jobs have been submitted this method returns -1
+	 */
+	public int getIndexLength() {
+		return this.indexDepth;
+	}
+
+	/**
+	 * Add a job to the cache, the job is inserted at a position corresponding
+	 * to its index array property
+	 * 
+	 * @param j
+	 */
+	public synchronized void insertJob(Job j) {
+		if (root == null)
+			root = new NamedNode();
+		indexDepth = j.getIndex().length;
+		root.insertJob(j);
+	}
+
+	protected synchronized NamedNode nodeAt(int[] position) {
+		if (root == null)
+			return null;
+		NamedNode result = root;
+		int index = 0;
+		while (index < position.length && result != null)
+			result = result.childAt(position[index++]);
+		return result;
+	}
+
+	/**
+	 * Chop the cache off at the specified index
+	 * 
+	 * @param indexArray
+	 */
+	public synchronized void cut(int[] indexArray) {
+		if (indexArray.length > 0) {
+			int[] newIndex = tail(indexArray);
+			NamedNode node = nodeAt(newIndex);
+			if (node != null
+					&& node.children.size() >= indexArray[indexArray.length - 1])
+				node.children.set(indexArray[indexArray.length - 1], null);
+		}
+	}
+
+	/**
+	 * Recursively fetch contents of all nodes under the specified index array,
+	 * used by the prefix matching iteration strategy
+	 */
+	public synchronized List<Job> jobsWithPrefix(int[] prefix) {
+		List<Job> jobs = new ArrayList<>();
+		NamedNode prefixNode = nodeAt(prefix);
+		if (prefixNode != null)
+			getJobsUnder(prefixNode, jobs);
+		return jobs;
+	}
+
+	private synchronized void getJobsUnder(NamedNode node, List<Job> jobs) {
+		if (node.contents != null)
+			jobs.add(node.contents);
+		else
+			for (NamedNode child : node.children)
+				getJobsUnder(child, jobs);
+	}
+
+	/**
+	 * Does the location exist?
+	 * 
+	 * @param location
+	 * @return whether the contents of the location are non null
+	 */
+	public synchronized boolean containsLocation(int[] location) {
+		return (get(location) != null);
+	}
+
+	/**
+	 * Get the job object at the specified index array
+	 * 
+	 * @param location
+	 * @return Job at the specified location or null if no such job was found
+	 */
+	public synchronized Job get(int[] location) {
+		NamedNode n = nodeAt(location);
+		return (n == null ? null : n.contents);
+	}
+
+	/**
+	 * Chop the last index off an int[]
+	 * 
+	 * @param arg
+	 * @return
+	 */
+	private static int[] tail(int[] arg) {
+		int result[] = new int[arg.length - 1];
+		for (int i = 0; i < arg.length - 1; i++)
+			result[i] = arg[i];
+		return result;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/WorkflowDataToken.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/WorkflowDataToken.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/WorkflowDataToken.java
new file mode 100644
index 0000000..e081567
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/WorkflowDataToken.java
@@ -0,0 +1,90 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.invocation;
+
+import org.apache.taverna.reference.T2Reference;
+
+/**
+ * A single data token passed between processors in a workflow. This is distinct
+ * from the Job in that it contains a single (unnamed) data reference whereas
+ * the Job holds a map of arbitrarily many named data references in a bundle.
+ * 
+ * @author Tom Oinn
+ */
+public class WorkflowDataToken extends Event<WorkflowDataToken> {
+	private T2Reference dataRef;
+
+	/**
+	 * Construct a new data token with the specified owning process, conceptual
+	 * index array and data reference
+	 * 
+	 * @param owningProcess
+	 * @param index
+	 * @param dataRef
+	 */
+	public WorkflowDataToken(String owningProcess, int[] index,
+			T2Reference dataRef, InvocationContext context) {
+		super(owningProcess, index, context);
+		this.dataRef = dataRef;
+	}
+
+	@Override
+	public WorkflowDataToken popOwningProcess()
+			throws ProcessIdentifierException {
+		return new WorkflowDataToken(popOwner(), index, dataRef, context);
+	}
+
+	@Override
+	public WorkflowDataToken pushOwningProcess(String localProcessName)
+			throws ProcessIdentifierException {
+		return new WorkflowDataToken(pushOwner(localProcessName), index,
+				dataRef, context);
+	}
+
+	/**
+	 * Return the ID of the data this event represents
+	 * 
+	 * @return
+	 */
+	public T2Reference getData() {
+		return this.dataRef;
+	}
+
+	/**
+	 * Show the owner, index array and data map in textual form for debugging
+	 * and any other purpose. Jobs appear in the form :
+	 * 
+	 * <pre>
+	 * Job(Process1)[2,0]{Input2=dataID4,Input1=dataID3}
+	 * </pre>
+	 */
+	@Override
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		sb.append("Token(").append(owner).append(")[");
+		String sep = "";
+		for (int idx : index) {
+			sb.append(sep).append(idx);
+			sep = ",";
+		}
+		sb.append("]{").append(dataRef).append("}");
+		return sb.toString();
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/package.html b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/package.html
new file mode 100644
index 0000000..8b3c49a
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/invocation/package.html
@@ -0,0 +1,6 @@
+<body>
+Contains classes supporting workflow invocation. Other packages may have
+dependencies on this one but classes here will only be accessed by
+non-taverna code in an invocation context. Nothing in here should be
+critical to the definition and manipulation of the workflow defintion.
+</body>


[20/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/Job.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/Job.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/Job.java
deleted file mode 100644
index 1ce96a3..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/Job.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.activity;
-
-import java.util.Map;
-
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.invocation.IterationInternalEvent;
-import net.sf.taverna.t2.invocation.ProcessIdentifierException;
-import net.sf.taverna.t2.reference.T2Reference;
-
-/**
- * Contains a (possibly partial) job description. A job is the smallest entity
- * that can be enacted by the invocation layer of the dispatch stack within a
- * processor. Jobs are partial jobs if the set of keys in the data map is not
- * identical to the set of named input ports on the processor within which the
- * job is used. These objects are used internally within the processor to stage
- * data during iteration and within the dispatch stack, they do not appear
- * within the workflow itself.
- * 
- * @author Tom Oinn
- */
-public class Job extends IterationInternalEvent<Job> {
-	private Map<String, T2Reference> dataMap;
-
-	/**
-	 * Push the index array onto the owning process name and return the new Job
-	 * object. Does not modify this object, the method creates a new Job with
-	 * the modified index array and owning process
-	 * 
-	 * @return
-	 */
-	@Override
-	public Job pushIndex() {
-		return new Job(getPushedOwningProcess(), new int[] {}, dataMap, context);
-	}
-
-	/**
-	 * Pull the index array previous pushed to the owning process name and
-	 * prepend it to the current index array
-	 */
-	@Override
-	public Job popIndex() {
-		return new Job(owner.substring(0, owner.lastIndexOf(':')),
-				getPoppedIndex(), dataMap, context);
-	}
-
-	/**
-	 * The actual data carried by this (partial) Job object is in the form of a
-	 * map, where the keys of the map are Strings identifying the named input
-	 * and the values are Strings containing valid data identifiers within the
-	 * context of a visible DataManager object (see CloudOne specification for
-	 * further information on the DataManager system)
-	 * 
-	 * @return Map of name to data reference for this Job
-	 */
-	public Map<String, T2Reference> getData() {
-		return this.dataMap;
-	}
-
-	/**
-	 * Create a new Job object with the specified owning process (colon
-	 * separated 'list' of process identifiers), index array and data map
-	 * 
-	 * @param owner
-	 * @param index
-	 * @param data
-	 */
-	public Job(String owner, int[] index, Map<String, T2Reference> data,
-			InvocationContext context) {
-		super(owner, index, context);
-		this.dataMap = data;
-	}
-
-	/**
-	 * Show the owner, index array and data map in textual form for debugging
-	 * and any other purpose. Jobs appear in the form :
-	 * 
-	 * <pre>
-	 * Job(Process1)[2,0]{Input2=dataID4,Input1=dataID3}
-	 * </pre>
-	 */
-	@Override
-	public String toString() {
-		StringBuilder sb = new StringBuilder();
-		sb.append("Job(").append(owner).append(")[");
-		String sep = "";
-		for (int i : index) {
-			sb.append(sep).append(i);
-			sep = ",";
-		}
-		sb.append("]{");
-		sep = "";
-		for (String key : dataMap.keySet()) {
-			sb.append(sep).append(key).append("=").append(dataMap.get(key));
-			sep = ",";
-		}
-		sb.append("}");
-		return sb.toString();
-	}
-
-	@Override
-	public Job popOwningProcess() throws ProcessIdentifierException {
-		return new Job(popOwner(), index, dataMap, context);
-	}
-
-	@Override
-	public Job pushOwningProcess(String localProcessName)
-			throws ProcessIdentifierException {
-		return new Job(pushOwner(localProcessName), index, dataMap, context);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/LockedNestedDataflow.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/LockedNestedDataflow.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/LockedNestedDataflow.java
deleted file mode 100644
index d215a5b..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/LockedNestedDataflow.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package net.sf.taverna.t2.workflowmodel.processor.activity;
-
-/**
- * A LockedNestedDataflow is intended to be unchangeable. It is normally defined
- * elsewhere to the workflow.
- * 
- * @author alanrw
- */
-public interface LockedNestedDataflow extends NestedDataflow {
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/MonitorableAsynchronousActivity.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/MonitorableAsynchronousActivity.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/MonitorableAsynchronousActivity.java
deleted file mode 100644
index 3b87776..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/MonitorableAsynchronousActivity.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.activity;
-
-import java.util.Map;
-import java.util.Set;
-
-import net.sf.taverna.t2.monitor.MonitorableProperty;
-import net.sf.taverna.t2.reference.T2Reference;
-
-/**
- * An extension of AsynchronousActivity with the additional stipulation that
- * implementing classes must return a set of monitorable properties for the
- * activity invocation instance when invoked. This allows for deep state
- * management, where the monitor state extends out from the workflow engine into
- * the remote resources themselves and is dependant on the resource proxied by
- * the activity implementation providing this information.
- * 
- * @author Tom Oinn
- */
-public interface MonitorableAsynchronousActivity<ConfigType> extends
-		AsynchronousActivity<ConfigType> {
-	/**
-	 * This has the same invocation semantics as
-	 * {@link AsynchronousActivity}<code>.executeAsynch</code> and all
-	 * implementations should also implement that method, with the difference
-	 * that this one returns immediately with a set of monitorable properties
-	 * which represent monitorable or steerable state within the invocation
-	 * itself.
-	 * 
-	 * @param data
-	 * @param callback
-	 * @return a set of monitorable properties representing internal state of
-	 *         the invoked resource
-	 */
-	Set<MonitorableProperty<?>> executeAsynchWithMonitoring(
-			Map<String, T2Reference> data, AsynchronousActivityCallback callback);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/NestedDataflow.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/NestedDataflow.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/NestedDataflow.java
deleted file mode 100644
index c37cb3f..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/NestedDataflow.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.activity;
-
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-
-/**
- * Nested workflows/dataflows can come in many shapes and sizes - in-line, url
- * etc. However, they are all {@link Dataflow}s. Implement this in any
- * implementation of a Nested dataflow
- * 
- * @author Ian Dunlop
- */
-public interface NestedDataflow {
-	Dataflow getNestedDataflow();
-
-	void setNestedDataflow(Dataflow dataflow);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/NestedDataflowSource.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/NestedDataflowSource.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/NestedDataflowSource.java
deleted file mode 100644
index d901af2..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/NestedDataflowSource.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- * 
- */
-package net.sf.taverna.t2.workflowmodel.processor.activity;
-
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-
-/**
- * @author alanrw
- */
-public interface NestedDataflowSource<T extends NestedDataflow> {
-	T getNestedDataflow();
-
-	Dataflow getParentDataflow();
-
-	@Override
-	String toString();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/NonExecutableActivity.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/NonExecutableActivity.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/NonExecutableActivity.java
deleted file mode 100644
index c0ab452..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/NonExecutableActivity.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.workflowmodel.processor.activity;
-
-import java.util.Map;
-
-import net.sf.taverna.t2.reference.T2Reference;
-
-/**
- * A non-executable activity is a wrapper for an Activity that cannot be
- * executed, for example because it is offline or unrecognized.
- * 
- * @author alanrw
- */
-public abstract class NonExecutableActivity<T> extends
-		AbstractAsynchronousActivity<T> {
-	public static final String URI = "http://ns.taverna.org.uk/2010/activity/nonExecutable";
-
-	/**
-	 * It is not possible to create a "naked" NonExecutableActivity.
-	 */
-	protected NonExecutableActivity() {
-		super();
-	}
-
-	/**
-	 * Add an input to the NonExecutableActivity with the specified name.
-	 * 
-	 * @param portName
-	 */
-	public void addProxyInput(String portName) {
-		super.addInput(portName, 0, true, null, null);
-	}
-
-	/**
-	 * Add an input to the NonExecutableActivity with the specified name and
-	 * depth.
-	 * 
-	 * @param portName
-	 * @param depth
-	 */
-	public void addProxyInput(String portName, int depth) {
-		super.addInput(portName, depth, true, null, null);
-	}
-
-	/**
-	 * Add an output to the NonExecutableActivity with the specified name
-	 * 
-	 * @param portName
-	 */
-	public void addProxyOutput(String portName) {
-		super.addOutput(portName, 0);
-	}
-
-	/**
-	 * Add an output to the NonExecutableActivity with the specified name and
-	 * depth
-	 * 
-	 * @param portName
-	 * @param depth
-	 */
-	public void addProxyOutput(String portName, int depth) {
-		super.addOutput(portName, depth);
-	}
-
-	/**
-	 * Attempting to run a NonExecutableActivity will always fail.
-	 */
-	@Override
-	public void executeAsynch(Map<String, T2Reference> data,
-			final AsynchronousActivityCallback callback) {
-		callback.requestRun(new Runnable() {
-			@Override
-			public void run() {
-				callback.fail("The service is not executable");
-			}
-		});
-	}
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/SupersededActivity.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/SupersededActivity.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/SupersededActivity.java
deleted file mode 100644
index 727298b..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/SupersededActivity.java
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * 
- */
-package net.sf.taverna.t2.workflowmodel.processor.activity;
-
-/**
- * 
- * A superseded activity is one which has been replaced be another activity type
- * of similar functionality but different configuration and name
- * 
- * @author alanrw
- */
-public interface SupersededActivity<ConfigurationType> extends
-		Activity<ConfigurationType> {
-	Activity<?> getReplacementActivity() throws ActivityConfigurationException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/UnrecognizedActivity.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/UnrecognizedActivity.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/UnrecognizedActivity.java
deleted file mode 100644
index be2465a..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/UnrecognizedActivity.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.workflowmodel.processor.activity;
-
-import org.jdom.Element;
-
-/**
- * An unrecognized activity is an activity that was not recognized when the
- * workflow was opened.
- * 
- * @author alanrw
- */
-public final class UnrecognizedActivity extends NonExecutableActivity<Element> {
-	public static final String URI = "http://ns.taverna.org.uk/2010/activity/unrecognized";
-
-	private Element conf;
-
-	/**
-	 * It is not possible to create a "naked" UnrecognizedActivity.
-	 */
-	private UnrecognizedActivity() {
-		super();
-	}
-
-	public UnrecognizedActivity(Element config)
-			throws ActivityConfigurationException {
-		this();
-		this.configure(config);
-	}
-
-	@Override
-	public void configure(Element conf) throws ActivityConfigurationException {
-		this.conf = conf;
-	}
-
-	@Override
-	public Element getConfiguration() {
-		return conf;
-	}
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/config/ActivityInputPortDefinitionBean.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/config/ActivityInputPortDefinitionBean.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/config/ActivityInputPortDefinitionBean.java
deleted file mode 100644
index 7dd4c05..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/config/ActivityInputPortDefinitionBean.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.activity.config;
-
-import java.util.Collections;
-import java.util.List;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationBean;
-
-/**
- * A bean that describes properties of an Input port.
- * 
- * @author Stuart Owen
- * @author Stian Soiland-Reyes
- */
-@ConfigurationBean(uri = "http://ns.taverna.org.uk/2010/scufl2#InputPortDefinition")
-public class ActivityInputPortDefinitionBean extends ActivityPortDefinitionBean {
-	private List<Class<? extends ExternalReferenceSPI>> handledReferenceSchemes;
-	private Class<?> translatedElementType;
-	private boolean allowsLiteralValues;
-
-	public List<Class<? extends ExternalReferenceSPI>> getHandledReferenceSchemes() {
-		if (handledReferenceSchemes == null)
-			return Collections.emptyList();
-		return handledReferenceSchemes;
-	}
-
-	public void setHandledReferenceSchemes(
-			List<Class<? extends ExternalReferenceSPI>> handledReferenceSchemes) {
-		this.handledReferenceSchemes = handledReferenceSchemes;
-	}
-
-	public Class<?> getTranslatedElementType() {
-		return translatedElementType;
-	}
-
-	public void setTranslatedElementType(Class<?> translatedElementType) {
-		this.translatedElementType = translatedElementType;
-	}
-
-	public boolean getAllowsLiteralValues() {
-		return allowsLiteralValues;
-	}
-
-	public void setAllowsLiteralValues(boolean allowsLiteralValues) {
-		this.allowsLiteralValues = allowsLiteralValues;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/config/ActivityOutputPortDefinitionBean.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/config/ActivityOutputPortDefinitionBean.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/config/ActivityOutputPortDefinitionBean.java
deleted file mode 100644
index 55bda31..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/config/ActivityOutputPortDefinitionBean.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.activity.config;
-
-import net.sf.taverna.t2.workflowmodel.OutputPort;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationBean;
-
-/**
- * A bean that describes properties of an Output port.
- * 
- * @author Stuart Owen
- */
-@ConfigurationBean(uri = "http://ns.taverna.org.uk/2010/scufl2#OutputPortDefinition")
-public class ActivityOutputPortDefinitionBean extends ActivityPortDefinitionBean {
-	private int granularDepth;
-
-	/**
-	 * @return the granular depth of the port
-	 * @see OutputPort#getGranularDepth()
-	 */
-	public int getGranularDepth() {
-		return granularDepth;
-	}
-
-	/**
-	 * @param granularDepth the granular depth of the port
-	 */
-	public void setGranularDepth(int granularDepth) {
-		this.granularDepth = granularDepth;
-	}	
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/config/ActivityPortDefinitionBean.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/config/ActivityPortDefinitionBean.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/config/ActivityPortDefinitionBean.java
deleted file mode 100644
index 05d991f..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/config/ActivityPortDefinitionBean.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.activity.config;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationBean;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationProperty;
-
-/**
- * A generic bean that describes the shared properties of input and output
- * ports.
- * 
- * @author Stuart Owen
- * 
- */
-@ConfigurationBean(uri = "http://ns.taverna.org.uk/2010/scufl2#PortDefinition")
-public abstract class ActivityPortDefinitionBean {
-	private String name;
-	private int depth;
-	private List<String> mimeTypes;
-
-	/**
-	 * @return the port name
-	 */
-	public String getName() {
-		return name;
-	}
-
-	/**
-	 * @param name
-	 *            the port name
-	 */
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	/**
-	 * @return the depth of the port
-	 */
-	public int getDepth() {
-		return depth;
-	}
-
-	/**
-	 * @param depth
-	 *            the depth of the port
-	 */
-	public void setDepth(int depth) {
-		this.depth = depth;
-	}
-
-	/**
-	 * @return a list a MIME types that describe the port
-	 */
-	public List<String> getMimeTypes() {
-		if (mimeTypes == null)
-			return Collections.emptyList();
-		return mimeTypes;
-	}
-
-	/**
-	 * @param mimeTypes
-	 *            the list of MIME-types that describe the port
-	 */
-	public void setMimeTypes(List<String> mimeTypes) {
-		this.mimeTypes = mimeTypes;
-	}
-
-	/**
-	 * @param mimeTypes
-	 *            the list of MIME-types that describe the port
-	 */
-	@ConfigurationProperty(name = "expectedMimeType", label = "Mime Types", description = "The MIME-types that describe the port", required = false)
-	public void setMimeTypes(Set<URI> mimeTypes) {
-		this.mimeTypes = new ArrayList<>();
-		for (URI uri : mimeTypes)
-			this.mimeTypes.add("'"
-					+ URI.create("http://purl.org/NET/mediatypes/").relativize(
-							uri) + "'");
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/config/ActivityPortsDefinitionBean.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/config/ActivityPortsDefinitionBean.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/config/ActivityPortsDefinitionBean.java
deleted file mode 100644
index 211a759..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/config/ActivityPortsDefinitionBean.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.activity.config;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationBean;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationProperty;
-
-/**
- * <p>
- * Defines a configuration type that relates directly to an {@link Activity} and
- * in particular defines details its input and output ports.<br>
- * An Activity that has its ports implicitly defined may define a ConfigType
- * that extends this class, but this is not enforced.
- * </p>
- * 
- * @author Stuart Owen
- */
-@ConfigurationBean(uri = "http://ns.taverna.org.uk/2010/scufl2#ActivityPortsDefinition")
-public class ActivityPortsDefinitionBean {
-	private List<ActivityInputPortDefinitionBean> inputs = new ArrayList<>();
-	private List<ActivityOutputPortDefinitionBean> outputs = new ArrayList<>();
-
-	/**
-	 * @return a list of {@link ActivityInputPortDefinitionBean} that describes
-	 *         each input port
-	 */
-	public List<ActivityInputPortDefinitionBean> getInputPortDefinitions() {
-		return inputs;
-	}
-
-	/**
-	 * @return a list of {@link ActivityOutputPortDefinitionBean} that describes
-	 *         each output port.
-	 */
-	public List<ActivityOutputPortDefinitionBean> getOutputPortDefinitions() {
-		return outputs;
-	}
-
-	/**
-	 * @param portDefinitions
-	 *            a list of {@link ActivityInputPortDefinitionBean} that
-	 *            describes each input port
-	 */
-	@ConfigurationProperty(name = "inputPortDefinition", label = "Input Ports", description = "", required = false, ordering = ConfigurationProperty.OrderPolicy.NON_ORDERED)
-	public void setInputPortDefinitions(
-			List<ActivityInputPortDefinitionBean> portDefinitions) {
-		inputs = portDefinitions;
-	}
-
-	/**
-	 * @param portDefinitions
-	 *            a list of {@link ActivityOutputPortDefinitionBean} that
-	 *            describes each output port
-	 */
-	@ConfigurationProperty(name = "outputPortDefinition", label = "Output Ports", description = "", required = false, ordering = ConfigurationProperty.OrderPolicy.NON_ORDERED)
-	public void setOutputPortDefinitions(
-			List<ActivityOutputPortDefinitionBean> portDefinitions) {
-		outputs = portDefinitions;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/config/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/config/package.html b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/config/package.html
deleted file mode 100644
index fa104d7..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/config/package.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<body>
-A set of helper classes to aid in defining how Activities are configured.
-An Activity class is associated with a ConfigurationType, which is an arbitrary Java object defining
-how the Activity should be configured.<br>
-This package provides classes and interfaces that help in creating these ConfigurationTypes with details that are common
-across different Activities, but there use is in no way enforced.
-</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/package.html b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/package.html
deleted file mode 100644
index 72a9076..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/package.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<body>
-Provides definitions for a single Activity to be contained within a
-Processor. Activity was previously called 'Service' but this was
-somewhat misleading as there wasn't always a service backing it. The
-Activity may be abstract, it may be synchronous or asynchronous in which
-case it uses a callback mechanism. It doesn't carry around annotation
-itself instead using an activity annotation container to handle this
-(this avoids third parties having to manage annotation containment
-themselves).
-</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/config/ConfigurationBean.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/config/ConfigurationBean.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/config/ConfigurationBean.java
deleted file mode 100644
index ff0e589..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/config/ConfigurationBean.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package net.sf.taverna.t2.workflowmodel.processor.config;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-public @interface ConfigurationBean {
-	String uri();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/config/ConfigurationProperty.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/config/ConfigurationProperty.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/config/ConfigurationProperty.java
deleted file mode 100644
index f952991..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/config/ConfigurationProperty.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package net.sf.taverna.t2.workflowmodel.processor.config;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface ConfigurationProperty {
-	// TODO document this
-	String name();
-
-	String label() default "";
-
-	String description() default "";
-
-	boolean required() default true;
-
-	OrderPolicy ordering() default OrderPolicy.DEFAULT;
-
-	enum OrderPolicy {
-		DEFAULT, NON_ORDERED
-	}
-
-	String uri() default "";
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/AbstractDispatchLayer.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/AbstractDispatchLayer.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/AbstractDispatchLayer.java
deleted file mode 100644
index fc07e75..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/AbstractDispatchLayer.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch;
-
-import java.util.Timer;
-
-import net.sf.taverna.t2.workflowmodel.Processor;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchCompletionEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchErrorEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchJobEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchJobQueueEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchResultEvent;
-
-/**
- * Convenience abstract implementation of DispatchLayer
- * 
- * @author Tom Oinn
- */
-public abstract class AbstractDispatchLayer<ConfigurationType> implements
-		DispatchLayer<ConfigurationType> {
-	protected static Timer cleanupTimer = new Timer(
-			"Dispatch stack state cleanup", true);
-	protected static final int CLEANUP_DELAY_MS = 1000;
-
-	@Override
-	public void setDispatchStack(DispatchStack parentStack) {
-		this.dispatchStack = parentStack;
-	}
-
-	protected DispatchStack dispatchStack;
-
-	protected final DispatchLayer<?> getAbove() {
-		return dispatchStack.layerAbove(this);
-	}
-
-	protected final DispatchLayer<?> getBelow() {
-		return dispatchStack.layerBelow(this);
-	}
-
-	@Override
-	public void receiveError(DispatchErrorEvent errorEvent) {
-		DispatchLayer<?> above = dispatchStack.layerAbove(this);
-		if (above != null)
-			above.receiveError(errorEvent);
-	}
-
-	@Override
-	public void receiveJob(DispatchJobEvent jobEvent) {
-		DispatchLayer<?> below = dispatchStack.layerBelow(this);
-		if (below != null)
-			below.receiveJob(jobEvent);
-	}
-
-	@Override
-	public void receiveJobQueue(DispatchJobQueueEvent jobQueueEvent) {
-		DispatchLayer<?> below = dispatchStack.layerBelow(this);
-		if (below != null)
-			below.receiveJobQueue(jobQueueEvent);
-	}
-
-	@Override
-	public void receiveResult(DispatchResultEvent resultEvent) {
-		DispatchLayer<?> above = dispatchStack.layerAbove(this);
-		if (above != null)
-			above.receiveResult(resultEvent);
-	}
-
-	@Override
-	public void receiveResultCompletion(DispatchCompletionEvent completionEvent) {
-		DispatchLayer<?> above = dispatchStack.layerAbove(this);
-		if (above != null)
-			above.receiveResultCompletion(completionEvent);
-	}
-
-	@Override
-	public void finishedWith(String owningProcess) {
-		// Do nothing by default
-	}
-
-	public Processor getProcessor() {
-		if (dispatchStack == null)
-			return null;
-		return dispatchStack.getProcessor();
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/AbstractErrorHandlerLayer.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/AbstractErrorHandlerLayer.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/AbstractErrorHandlerLayer.java
deleted file mode 100644
index 3f180c1..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/AbstractErrorHandlerLayer.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchCompletionEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchErrorEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchJobEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchResultEvent;
-
-/**
- * Superclass of error handling dispatch layers (for example retry and
- * failover). Provides generic functionality required by this class of layers.
- * 
- * @author Tom Oinn
- * @author Stian Soiland-Reyes
- */
-public abstract class AbstractErrorHandlerLayer<ConfigurationType> extends
-		AbstractDispatchLayer<ConfigurationType> {
-	private static Logger logger = Logger
-			.getLogger(AbstractErrorHandlerLayer.class);
-
-	/**
-	 * Compare two arrays of ints, return true if they are the same length and
-	 * if at every index the two integer values are equal
-	 * 
-	 * @param a
-	 * @param b
-	 * @return
-	 */
-	private static boolean identicalIndex(int[] a, int[] b) {
-		if (a.length != b.length)
-			return false;
-		for (int i = 0; i < a.length; i++)
-			if (a[i] != b[i])
-				return false;
-		return true;
-	}
-
-	/**
-	 * Map of process name -> list of state models. Note that all access to this
-	 * map must be synchronized on the stateMap, and access to the lists inside
-	 * it must be synchronized on the list.
-	 * 
-	 * @see #addJobToStateList(DispatchJobEvent)
-	 * @see #removeJob(String, JobState)
-	 * @see #getJobsDefault(String)
-	 * @see #getJobsCopy(String)
-	 */
-	private Map<String, List<JobState>> stateMap = new HashMap<>();
-
-	protected AbstractErrorHandlerLayer() {
-		super();
-	}
-
-	/**
-	 * Clear cached state for the specified process when notified by the
-	 * dispatch stack
-	 */
-	@Override
-	public void finishedWith(String owningProcess) {
-		synchronized (stateMap) {
-			stateMap.remove(owningProcess);
-		}
-	}
-
-	/**
-	 * If an error occurs we can either handle the error or send it to the layer
-	 * above for further processing.
-	 */
-	@Override
-	public void receiveError(DispatchErrorEvent errorEvent) {
-		String owningProcess = errorEvent.getOwningProcess();
-		for (JobState rs : getJobsCopy(owningProcess))
-			if (identicalIndex(rs.jobEvent.getIndex(), errorEvent.getIndex())) {
-				boolean handled = rs.handleError();
-				if (!handled) {
-					removeJob(owningProcess, rs);
-					getAbove().receiveError(errorEvent);
-					return;
-				}
-			}
-	}
-
-	/**
-	 * Receive a job from the layer above, store it for later retries and pass
-	 * it down to the next layer
-	 */
-	@Override
-	public void receiveJob(DispatchJobEvent jobEvent) {
-		addJobToStateList(jobEvent);
-		getBelow().receiveJob(jobEvent);
-	}
-
-	/**
-	 * If we see a result with an index matching one of those in the current
-	 * retry state we can safely forget that state object
-	 */
-	@Override
-	public void receiveResult(DispatchResultEvent j) {
-		forget(j.getOwningProcess(), j.getIndex());
-		getAbove().receiveResult(j);
-	}
-
-	/**
-	 * If we see a completion event with an index matching one of those in the
-	 * current retry state we can safely forget that state object
-	 */
-	@Override
-	public void receiveResultCompletion(DispatchCompletionEvent c) {
-		forget(c.getOwningProcess(), c.getIndex());
-		getAbove().receiveResultCompletion(c);
-	}
-
-	/**
-	 * Remove the specified pending retry job from the cache
-	 * 
-	 * @param owningProcess
-	 *            Owning process identifier as returned by
-	 *            {@link DispatchJobEvent#getOwningProcess()}
-	 * @param index
-	 *            Index of the job as returned by
-	 *            {@link DispatchJobEvent#getIndex()}
-	 */
-	protected void forget(String owningProcess, int[] index) {
-		for (JobState jobState : getJobsCopy(owningProcess))
-			if (identicalIndex(jobState.jobEvent.getIndex(), index)) {
-				removeJob(owningProcess, jobState);
-				return;
-			}
-		// It could be due to pipelining activities like BioMart 
-		logger.debug("Could not forget " + owningProcess + " " + Arrays.toString(index));
-	}
-
-	protected void addJobToStateList(DispatchJobEvent jobEvent) {
-		List<JobState> stateList = null;
-		stateList = getJobsDefault(jobEvent.getOwningProcess());
-		synchronized (stateList) {
-			stateList.add(getStateObject(jobEvent));
-		}
-	}
-
-	/**
-	 * Get a copy of the list of {@link JobState}s for the owning process, or an
-	 * empty list if the owning process is unknown or have been
-	 * {@link #forget(String, int[]) forgotten}.
-	 * <p>
-	 * This list can safely be iterated over without synchronizing. If you need
-	 * to modify the list, either synchronize over the returned list from
-	 * {@link #getJobsDefault(String)} or use
-	 * {@link #removeJob(String, JobState)}.
-	 * 
-	 * @param owningProcess
-	 *            Owning process identifier as returned by
-	 *            {@link DispatchJobEvent#getOwningProcess()}
-	 * @return A copy of the list of known JobState {@link JobState}s for the
-	 *         owning process,
-	 */
-	protected List<JobState> getJobsCopy(String owningProcess) {
-		List<JobState> activeJobs;
-		synchronized (stateMap) {
-			activeJobs = stateMap.get(owningProcess);
-		}
-		if (activeJobs == null) {
-			logger.warn("Could not find any active jobs for " + owningProcess);
-			return Collections.emptyList();
-		}
-		// Take a copy of the list so we don't modify it while iterating over it
-		List<JobState> activeJobsCopy;
-		synchronized (activeJobs) {
-			activeJobsCopy = new ArrayList<>(activeJobs);
-		}
-		return activeJobsCopy;
-	}
-
-	/**
-	 * Get the list of {@link JobState}s for the owning process, creating and
-	 * adding it to the state map if necessary.
-	 * <p>
-	 * Note that all access to the returned list must be synchronized on the
-	 * list to avoid threading issues.
-	 * <p>
-	 * If you are going to iterate over the list, use
-	 * {@link #getJobsCopy(String)} instead.
-	 * 
-	 * @see #getJobsCopy(String)
-	 * @param owningProcess
-	 *            Owning process identifier as returned by
-	 *            {@link DispatchJobEvent#getOwningProcess()}
-	 * 
-	 * @return List of {@link JobState}s for the owning process
-	 */
-	protected List<JobState> getJobsDefault(String owningProcess) {
-		List<JobState> stateList;
-		synchronized (stateMap) {
-			stateList = stateMap.get(owningProcess);
-			if (stateList == null) {
-				stateList = new ArrayList<>();
-				stateMap.put(owningProcess, stateList);
-			}
-		}
-		return stateList;
-	}
-
-	/**
-	 * Generate an appropriate state object from the specified job event. The
-	 * state object is a concrete subclass of JobState.
-	 * 
-	 * @return
-	 */
-	protected abstract JobState getStateObject(DispatchJobEvent jobEvent);
-
-	protected void removeJob(String owningProcess, JobState jobState) {
-		List<JobState> activeJobs;
-		synchronized (stateMap) {
-			activeJobs = stateMap.get(owningProcess);
-		}
-		if (activeJobs == null) {
-			logger.error("Could not find active jobs for " + owningProcess);
-			return;
-		}
-		synchronized (activeJobs) {
-			activeJobs.remove(jobState);
-		}
-	}
-
-	/**
-	 * Abstract superclass of all state models for pending failure handlers.
-	 * This object is responsible for handling failure messages if they occur
-	 * and represents the current state of the failure handling algorithm on a
-	 * per job basis.
-	 * 
-	 * @author Tom Oinn
-	 */
-	protected abstract class JobState {
-		protected DispatchJobEvent jobEvent;
-
-		protected JobState(DispatchJobEvent jobEvent) {
-			this.jobEvent = jobEvent;
-		}
-
-		/**
-		 * Called when the layer below pushes an error up and where the error
-		 * index and owning process matches that of this state object. The
-		 * implementation must deal with the error, either by handling it and
-		 * pushing a new job down the stack or by rejecting it. If this method
-		 * returns false the error has not been dealt with and MUST be pushed up
-		 * the stack by the active dispatch layer. In this case the layer will
-		 * be a subclass of AbstractErrorHandlerLayer and the logic to do this
-		 * is already included in the receive methods for results, errors and
-		 * completion events.
-		 * 
-		 * @return true if the error was handled.
-		 */
-		public abstract boolean handleError();
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/DispatchLayer.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/DispatchLayer.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/DispatchLayer.java
deleted file mode 100644
index ed21907..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/DispatchLayer.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch;
-
-import net.sf.taverna.t2.workflowmodel.Configurable;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchCompletionEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchErrorEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchJobEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchJobQueueEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchResultEvent;
-
-/**
- * Layers within the dispatch stack define a control flow to handle dispatch of
- * jobs from a queue (generated by the iteration system) to appropriate
- * activities.
- * <p>
- * A dispatch layer can receive a reference to the Queue and a set of
- * Activities, or a single Job and a set of Activities from the layer above it
- * (or from the DispatchStackImpl object itself if this is the top layer). It
- * can receive errors, results and partial or total completion events from the
- * layer immediately below it.
- * <p>
- * To assist in graphical representation of the dispatch configuration each
- * layer declares for each class of message whether it intercepts and alters,
- * intercepts and observes or ignores (forwards) the message onto the next layer
- * (either up or down depending on the message) and whether the layer is capable
- * of instigating the creation of each class of message.
- * 
- * @author Tom Oinn
- */
-public interface DispatchLayer<ConfigurationType> extends
-		Configurable<ConfigurationType> {
-	/**
-	 * Receive a pointer to the job queue along with a set of activities, this
-	 * is received from the layer above in the dispatch stack or from the
-	 * DispatchStackImpl object itself if this is the top layer.
-	 */
-	void receiveJobQueue(DispatchJobQueueEvent queueEvent);
-
-	/**
-	 * Receive a single job and associated set of activities from the layer
-	 * above
-	 */
-	void receiveJob(DispatchJobEvent jobEvent);
-
-	/**
-	 * Receive a single error reference from the layer below
-	 */
-	void receiveError(DispatchErrorEvent errorEvent);
-
-	/**
-	 * Receive a result from the layer below
-	 */
-	void receiveResult(DispatchResultEvent resultEvent);
-
-	/**
-	 * Receive a (possibly partial) completion event from the layer below. This
-	 * is only going to be used when the activities invocation is capable of
-	 * streaming partial data back up through the dispatch stack before the
-	 * activities has completed. Not all dispatch stack layers are compatible
-	 * with this mode of operation, for example retry and recursion do not play
-	 * well here!
-	 */
-	void receiveResultCompletion(DispatchCompletionEvent completionEvent);
-
-	/**
-	 * Called when there will be no more events with the specified process
-	 * identifier, can be used to purge cached state from layers within the
-	 * stack
-	 */
-	void finishedWith(String owningProcess);
-
-	/**
-	 * Set the parent dispatch stack of this layer, this is called when a layer
-	 * is added to the dispatch stack and can be safely ignored by end users of
-	 * this API
-	 */
-	void setDispatchStack(DispatchStack stack);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/DispatchLayerFactory.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/DispatchLayerFactory.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/DispatchLayerFactory.java
deleted file mode 100644
index 8515bb8..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/DispatchLayerFactory.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch;
-
-import java.net.URI;
-import java.util.Set;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * Factory for creating {@link DispatchLayer} instances.
- * 
- * @author David Withers
- */
-public interface DispatchLayerFactory {
-	/**
-	 * Creates a new {@link DispatchLayer} instance.
-	 * 
-	 * @param dispatchLayerType
-	 *            the type of the {@link DispatchLayer}
-	 * @return a new <code>DispatchLayer</code> instance
-	 */
-	DispatchLayer<?> createDispatchLayer(URI dispatchLayerType);
-
-	/**
-	 * Returns the types of the {@link DispatchLayer}s that this factory
-	 * can create.
-	 * 
-	 * @return the types of the {@link DispatchLayer}s that this factory
-	 *         can create
-	 */
-	Set<URI> getDispatchLayerTypes();
-
-	/**
-	 * Returns the JSON Schema for the configuration required by the
-	 * {@link DispatchLayer}.
-	 * 
-	 * @param dispatchLayerType
-	 *            the type of the {@link DispatchLayer}
-	 * @return the JSON Schema for the configuration required by the
-	 *         {@link DispatchLayer}
-	 */
-	JsonNode getDispatchLayerConfigurationSchema(URI dispatchLayerType);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/DispatchStack.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/DispatchStack.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/DispatchStack.java
deleted file mode 100644
index cb933c6..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/DispatchStack.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch;
-
-import static net.sf.taverna.t2.annotation.HierarchyRole.CHILD;
-import static net.sf.taverna.t2.annotation.HierarchyRole.PARENT;
-
-import java.util.List;
-
-import net.sf.taverna.t2.annotation.Annotated;
-import net.sf.taverna.t2.annotation.HierarchyTraversal;
-import net.sf.taverna.t2.monitor.MonitorableProperty;
-import net.sf.taverna.t2.workflowmodel.Processor;
-import net.sf.taverna.t2.workflowmodel.WorkflowItem;
-
-/**
- * The dispatch stack is responsible for consuming a queue of jobs from the
- * iteration strategy and dispatching those jobs through a stack based control
- * flow to an appropriate invocation target. Conceptually the queue and
- * description of activities enter the stack at the top, travel down to an
- * invocation layer at the bottom from which results, errors and completion
- * events rise back up to the top layer. Dispatch stack layers are stored as an
- * ordered list with index 0 being the top of the stack.
- * 
- * @author Tom Oinn
- */
-public interface DispatchStack extends Annotated<DispatchStack>, WorkflowItem {
-	/**
-	 * The DispatchStack consists of an ordered list of DispatchLayer instances
-	 * where the DispatchLayer at index zero is at the bottom of the stack and
-	 * is almost always an invocation layer of some kind (in any working
-	 * dispatch stack configuration)
-	 * 
-	 */
-	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
-	List<DispatchLayer<?>> getLayers();
-
-	/**
-	 * The dispatch stack is contained within a processor, this can be null if
-	 * the stack is being used out of this context but layers may be relying on
-	 * this link to get information about the processor input ports and their
-	 * annotations for various reasons.
-	 */
-	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { PARENT })
-	Processor getProcessor();
-
-	/**
-	 * Return the layer above (lower index!) the specified layer, or a reference
-	 * to the internal top layer dispatch layer if there is no layer above the
-	 * specified one. Remember - input data and activities go down, results,
-	 * errors and completion events bubble back up the dispatch stack.
-	 * <p>
-	 * The top layer within the dispatch stack is always invisible and is held
-	 * within the DispatchStackImpl object itself, being used to route data out
-	 * of the entire stack
-	 * 
-	 * @param layer
-	 * @return
-	 */
-	DispatchLayer<?> layerAbove(DispatchLayer<?> layer);
-
-	/**
-	 * Return the layer below (higher index) the specified layer, or null if
-	 * there is no layer below this one.
-	 * 
-	 * @param layer
-	 * @return
-	 */
-	DispatchLayer<?> layerBelow(DispatchLayer<?> layer);
-
-	/**
-	 * The dispatch stack acts as an aggregator for monitorable properties
-	 * exposed by the dispatch layers. This is distinct from layers which are
-	 * capable of rewriting the process idenfitier of tokens - these require
-	 * their own nodes in the monitor in addition to any contributed properties.
-	 * 
-	 * @param prop
-	 * @param processID
-	 */
-	void receiveMonitorableProperty(MonitorableProperty<?> prop,
-			String processID);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/NotifiableLayer.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/NotifiableLayer.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/NotifiableLayer.java
deleted file mode 100644
index e78dfda..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/NotifiableLayer.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch;
-
-import net.sf.taverna.t2.invocation.Completion;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Job;
-
-/**
- * If a layer requires notification of the arrival of new items to the event
- * queues within the dispatcher it should implement this interface.
- * 
- * @author Tom Oinn
- */
-public interface NotifiableLayer {
-	/**
-	 * Called when a new {@link Job} or {@link Completion} is added to a queue
-	 * within the dispatch stack
-	 * 
-	 * @param owningProcess
-	 */
-	void eventAdded(String owningProcess);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/PropertyContributingDispatchLayer.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/PropertyContributingDispatchLayer.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/PropertyContributingDispatchLayer.java
deleted file mode 100644
index 02f8802..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/PropertyContributingDispatchLayer.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch;
-
-/**
- * Used by dispatch layers which can contribute property information to their
- * parent processor instance. This is distinct from dispatch layers which modify
- * the process identifier and therefore create their own nodes in the monitor
- * tree, although there's no reason a layer can't perform both functions. For
- * example, the fault tolerance layers create their own state subtrees for each
- * failure recovery but could also contribute aggregate fault information to the
- * parent processor's property set.
- * 
- * @author Tom Oinn
- * 
- * @param <ConfigType>
- *            configuration type for the dispatch layer
- */
-public interface PropertyContributingDispatchLayer<ConfigType> extends
-		DispatchLayer<ConfigType> {
-	/**
-	 * Inject properties for the specified owning process into the parent
-	 * dispatch stack. At some point prior to this call being made the
-	 * setDispatchStack will have been called, implementations of this method
-	 * need to use this DispatchStack reference to push properties in with the
-	 * specified key.
-	 * <p>
-	 * Threading - this thread must not fork, do all the work in this method in
-	 * the thread you're given by the caller. This is because implementations
-	 * may assume that they can collect properties from the dispatch stack
-	 * implementation (which will expose them through a private access method to
-	 * prevent arbitrary access to layer properties) once this call has
-	 * returned.
-	 * <p>
-	 * There is no guarantee that the layer will have seen an event with the
-	 * specified process, and in fact it's unlikely to in the general case as
-	 * any layers above it are free to modify the process identifier of tokens
-	 * as they go. Remember that this method is for aggregating properties into
-	 * the top level (processor) view so you may need to implement the property
-	 * getters such that they check prefixes of identifiers rather than
-	 * equality.
-	 * 
-	 * @param owningProcess
-	 */
-	void injectPropertiesFor(String owningProcess);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerErrorReaction.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerErrorReaction.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerErrorReaction.java
deleted file mode 100644
index cfa020b..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerErrorReaction.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.description;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Describes how a dispatch layer reacts to an error message
- * 
- * @author Tom Oinn
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-@Documented
-@ReactionTo(messageType = DispatchMessageType.ERROR)
-public @interface DispatchLayerErrorReaction {
-	public DispatchLayerStateEffect[] stateEffects();
-
-	public DispatchMessageType[] emits();
-
-	public boolean relaysUnmodified();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerJobQueueReaction.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerJobQueueReaction.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerJobQueueReaction.java
deleted file mode 100644
index 19aa9fa..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerJobQueueReaction.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.description;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Describes how a dispatch layer reacts to a Job Queue message
- * 
- * @author Tom Oinn
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-@Documented
-@ReactionTo(messageType = DispatchMessageType.JOB_QUEUE)
-public @interface DispatchLayerJobQueueReaction {
-
-	public DispatchLayerStateEffect[] stateEffects();
-
-	public DispatchMessageType[] emits();
-
-	public boolean relaysUnmodified();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerJobReaction.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerJobReaction.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerJobReaction.java
deleted file mode 100644
index ec550cc..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerJobReaction.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.description;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Describes how a dispatch layer reacts to a Job message
- * 
- * @author Tom Oinn
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-@Documented
-@ReactionTo(messageType = DispatchMessageType.JOB)
-public @interface DispatchLayerJobReaction {
-	public DispatchLayerStateEffect[] stateEffects();
-
-	public DispatchMessageType[] emits();
-	
-	public boolean relaysUnmodified();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerResultCompletionReaction.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerResultCompletionReaction.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerResultCompletionReaction.java
deleted file mode 100644
index edb22cf..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerResultCompletionReaction.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.description;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Describes how a dispatch layer reacts to a result completion message
- * 
- * @author Tom Oinn
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-@Documented
-@ReactionTo(messageType = DispatchMessageType.RESULT_COMPLETION)
-public @interface DispatchLayerResultCompletionReaction {
-	public DispatchLayerStateEffect[] stateEffects();
-
-	public DispatchMessageType[] emits();
-
-	public boolean relaysUnmodified();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerResultReaction.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerResultReaction.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerResultReaction.java
deleted file mode 100644
index a051331..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerResultReaction.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.description;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Describes how a dispatch layer responds to a result message
- * 
- * @author Tom Oinn
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-@Documented
-@ReactionTo(messageType = DispatchMessageType.RESULT)
-public @interface DispatchLayerResultReaction {
-	public DispatchLayerStateEffect[] stateEffects();
-
-	public DispatchMessageType[] emits();
-
-	public boolean relaysUnmodified();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerStateEffect.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerStateEffect.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerStateEffect.java
deleted file mode 100644
index 5a3b7aa..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchLayerStateEffect.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.description;
-
-/**
- * Describes the effect of a message on the state of a dispatch layer, used by
- * DispatchLayerReaction. If no message causes any of these actions the layer
- * can be described as state free.
- * 
- * @author Tom Oinn
- */
-public enum DispatchLayerStateEffect {
-	/**
-	 * The message causes a state object within the dispatch layer to be created
-	 * keyed on the process identifier and index
-	 */
-	CREATE_LOCAL_STATE,
-
-	/**
-	 * The message causes the removal of a state object within the dispatch
-	 * layer, the layer to be removed is keyed on process identifier and index
-	 * of the message
-	 */
-	REMOVE_LOCAL_STATE,
-
-	/**
-	 * The message causes the modification of a previously stored state object
-	 * within the dispatch layer, the state object modified is keyed on process
-	 * identifier and index of the message.
-	 */
-	UPDATE_LOCAL_STATE,
-
-	/**
-	 * The message causes a state object within the dispatch layer to be created
-	 * keyed only on the process identifier and not on the index of the message.
-	 */
-	CREATE_PROCESS_STATE,
-
-	/**
-	 * The message causes a state object to be removed from the dispatch layer,
-	 * the state object is identified only by the process identifier
-	 */
-	REMOVE_PROCESS_STATE,
-
-	/**
-	 * The message causes a state object to be modified, the state object is
-	 * identified by process identifier only
-	 */
-	UPDATE_PROCESS_STATE,
-
-	/**
-	 * The message causes global level state to be modified within the dispatch
-	 * layer
-	 */
-	UPDATE_GLOBAL_STATE,
-
-	/**
-	 * The message has no effect on state. This value is used when specifying
-	 * that a message might cause effect or it might not, the interpretation of
-	 * the various reaction annotations is that exactly one of the state effects
-	 * will take place, so if the state side effect array isn't empty you have
-	 * to insert this one to specify that it's possible that no state change
-	 * will occur
-	 */
-	NO_EFFECT;
-}


[35/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ReferenceServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ReferenceServiceImpl.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ReferenceServiceImpl.java
new file mode 100644
index 0000000..30620bd
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ReferenceServiceImpl.java
@@ -0,0 +1,730 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import static java.lang.Float.MAX_VALUE;
+import static org.apache.taverna.reference.T2ReferenceType.ErrorDocument;
+import static org.apache.taverna.reference.T2ReferenceType.IdentifiedList;
+import static org.apache.taverna.reference.T2ReferenceType.ReferenceSet;
+import static org.apache.taverna.reference.impl.T2ReferenceImpl.getAsImpl;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.taverna.reference.ContextualizedT2Reference;
+import org.apache.taverna.reference.ErrorDocument;
+import org.apache.taverna.reference.ErrorDocumentServiceException;
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.Identified;
+import org.apache.taverna.reference.IdentifiedList;
+import org.apache.taverna.reference.ListServiceException;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferenceService;
+import org.apache.taverna.reference.ReferenceServiceException;
+import org.apache.taverna.reference.ReferenceSet;
+import org.apache.taverna.reference.ReferenceSetServiceException;
+import org.apache.taverna.reference.StreamToValueConverterSPI;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.ValueCarryingExternalReference;
+import org.apache.taverna.reference.ValueToReferenceConversionException;
+import org.apache.taverna.reference.ValueToReferenceConverterSPI;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Implementation of ReferenceService, inject with ReferenceSetService,
+ * ErrorDocumentService and ListService to enable.
+ * 
+ * @author Tom Oinn
+ * @author Alan R Williams
+ * @author Stuart Owen
+ * @author Stian Soiland-Reyes
+ */
+public class ReferenceServiceImpl extends AbstractReferenceServiceImpl
+		implements ReferenceService {
+	private final Logger log = Logger.getLogger(ReferenceServiceImpl.class);
+
+	/**
+	 * The top level registration method is used to register either as yet
+	 * unregistered ErrorDocuments and ReferenceSets (if these are passed in and
+	 * already have an identifier this call does nothing) and arbitrarily nested
+	 * Lists of the same. In addition any ExternalReferenceSPI instances found
+	 * will be wrapped in a single item ReferenceSet and registered, and any
+	 * Throwables will be wrapped in an ErrorDocument and registered. Lists will
+	 * be converted to IdentifiedList&lt;T2Reference&gt; and registered if all
+	 * children can be (or were already) appropriately named.
+	 * <p>
+	 * This method is only valid on parameters of the following type :
+	 * <ol>
+	 * <li>{@link ReferenceSet} - registered if not already registered,
+	 * otherwise returns existing T2Reference</li>
+	 * <li>{@link ErrorDocument} - same behaviour as ReferenceSet</li>
+	 * <li>{@link ExternalReferenceSPI} - wrapped in ReferenceSet, registered
+	 * and ID returned</li>
+	 * <li>Throwable - wrapped in ErrorDocument with no message, registered and
+	 * ID returned</li>
+	 * <li>List - all children are first registered, if this succeeds the list
+	 * is itself registered as an IdentifiedList of T2Reference and its
+	 * reference returned.</li>
+	 * </ol>
+	 * The exception to this is if the useConvertorSPI parameter is set to true
+	 * - in this case any objects which do not match the above allowed list will
+	 * be run through any available ValueToReferenceConvertorSPI instances in
+	 * turn until one succeeds or all fail, which may result in the creation of
+	 * ExternalReferenceSPI instances. As these can be registered such objects
+	 * will not cause an exception to be thrown.
+	 * 
+	 * @param o
+	 *            the object to register with the reference system, must comply
+	 *            with and will be interpreted as shown in the type list above.
+	 * @param targetDepth
+	 *            the depth of the top level object supplied. This is needed
+	 *            when registering empty collections and error documents,
+	 *            whether as top level types or as members of a collection
+	 *            within the top level type. If registering a collection this is
+	 *            the collection depth, so a List of ReferenceSchemeSPI would be
+	 *            depth 1. Failing to specify this correctly will result in
+	 *            serious problems downstream so be careful! We can't catch all
+	 *            potential problems in this method (although some errors will
+	 *            be trapped).
+	 * @param useConverterSPI
+	 *            whether to attempt to use the ValueToReferenceConvertorSPI
+	 *            registry (if defined and available) to map arbitrary objects
+	 *            to ExternalReferenceSPI instances on the fly. The registry of
+	 *            converters is generally injected into the implementation of
+	 *            this service.
+	 * @param context
+	 *            ReferenceContext to use if required by component services,
+	 *            this is most likely to be used by the object to reference
+	 *            converters if engaged.
+	 *            <p>
+	 *            If the context is null a new empty reference context is
+	 *            inserted.
+	 * @return a T2Reference to the registered object
+	 * @throws ReferenceServiceException
+	 *             if the object type (or, for collections, the recursive type
+	 *             of its contents) is not in the allowed list or if a problem
+	 *             occurs during registration. Also thrown if attempting to use
+	 *             the converter SPI without an attached registry.
+	 */
+	@Override
+	public T2Reference register(Object o, int targetDepth,
+			boolean useConverterSPI, ReferenceContext context)
+			throws ReferenceServiceException {
+		checkServices();
+		if (context == null)
+			context = new EmptyReferenceContext();
+		if (useConverterSPI)
+			checkConverterRegistry();
+		return getNameForObject(o, targetDepth, useConverterSPI, context);
+	}
+
+	@SuppressWarnings("unchecked")
+	private T2Reference getNameForObject(Object o, int currentDepth,
+			boolean useConverterSPI, ReferenceContext context)
+			throws ReferenceServiceException {
+		if (currentDepth < 0)
+			throw new ReferenceServiceException("Cannot register at depth "
+					+ currentDepth + ": " + o);
+		/*
+		 * First check whether this is an Identified, and if so whether it
+		 * already has an ID. If this is the case then return it, we assume that
+		 * anything which has an identifier already allocated must have been
+		 * registered (this is implicit in the contract for the various
+		 * sub-services
+		 */
+		if (o instanceof Identified) {
+			Identified i = (Identified) o;
+			if (i.getId() != null)
+				return i.getId();
+		}
+		/*
+		 * Then check whether the item *is* a T2Reference, in which case we can
+		 * just return it (useful for when registering lists of existing
+		 * references)
+		 */
+		if (o instanceof T2Reference)
+			return (T2Reference) o;
+
+		if (o.getClass().isArray()) {
+			Class<?> elementType = o.getClass().getComponentType();
+			if (elementType.getCanonicalName().equals("char")) {
+				char[] cArray = (char[]) o;
+				List<Character> cList = new ArrayList<>();
+				for (char c : cArray)
+					cList.add(new Character(c));
+				o = cList;
+			} else if (elementType.getCanonicalName().equals("short")) {
+				short[] cArray = (short[]) o;
+				List<Short> cList = new ArrayList<>();
+				for (short c : cArray)
+					cList.add(new Short(c));
+				o = cList;
+			} else if (elementType.getCanonicalName().equals("int")) {
+				int[] cArray = (int[]) o;
+				List<Integer> cList = new ArrayList<>();
+				for (int c : cArray)
+					cList.add(new Integer(c));
+				o = cList;
+			} else if (elementType.getCanonicalName().equals("long")) {
+				long[] cArray = (long[]) o;
+				List<Long> cList = new ArrayList<>();
+				for (long c : cArray)
+					cList.add(new Long(c));
+				o = cList;
+			} else if (elementType.getCanonicalName().equals("float")) {
+				float[] cArray = (float[]) o;
+				List<Float> cList = new ArrayList<>();
+				for (float c : cArray)
+					cList.add(new Float(c));
+				o = cList;
+			} else if (elementType.getCanonicalName().equals("double")) {
+				double[] cArray = (double[]) o;
+				List<Double> cList = new ArrayList<>();
+				for (double c : cArray)
+					cList.add(new Double(c));
+				o = cList;
+			} else if (elementType.getCanonicalName().equals("boolean")) {
+				boolean[] cArray = (boolean[]) o;
+				List<Boolean> cList = new ArrayList<>();
+				for (boolean c : cArray)
+					cList.add(new Boolean(c));
+				o = cList;
+			} else if (!elementType.getCanonicalName().equals("byte")) {
+				// Covert arrays of objects
+				Object[] cArray = (Object[]) o;
+				List<Object> cList = new ArrayList<>();
+				for (Object c : cArray)
+					cList.add(c);
+				o = cList;
+			}
+		}
+
+		// If a Collection but not a List
+		if ((o instanceof Collection) && !(o instanceof List)) {
+			List<Object> cList = new ArrayList<>();
+			cList.addAll((Collection<Object>) o);
+			o = cList;
+		}
+		// Next check lists.
+		if (o instanceof List) {
+			if (currentDepth < 1)
+				throw new ReferenceServiceException(
+						"Cannot register list at depth " + currentDepth);
+			List<?> l = (List<?>) o;
+			/*
+			 * If the list is empty then register a new empty list of the
+			 * appropriate depth and return it
+			 */
+			if (l.isEmpty())
+				try {
+					return listService.registerEmptyList(currentDepth, context)
+							.getId();
+				} catch (ListServiceException lse) {
+					throw new ReferenceServiceException(lse);
+				}
+			/*
+			 * Otherwise construct a new list of T2Reference and register it,
+			 * calling the getNameForObject method on all children of the list
+			 * to construct the list of references
+			 */
+			else {
+				List<T2Reference> references = new ArrayList<>();
+				for (Object item : l)
+					/*
+					 * Recursively call this method with a depth one lower than
+					 * the current depth
+					 */
+					references.add(getNameForObject(item, currentDepth - 1,
+							useConverterSPI, context));
+				try {
+					return listService.registerList(references, context)
+							.getId();
+				} catch (ListServiceException lse) {
+					throw new ReferenceServiceException(lse);
+				}
+			}
+		} else {
+			/*
+			 * Neither a list nor an already identified object, first thing is
+			 * to engage the converters if enabled. Only engage if we don't
+			 * already have a Throwable or an ExternalReferenceSPI instance
+			 */
+			if (useConverterSPI && (o instanceof Throwable == false)
+					&& (o instanceof ExternalReferenceSPI == false)) {
+				if (currentDepth != 0)
+					throw new ReferenceServiceException(
+							"Cannot register object " + o + " at depth "
+									+ currentDepth);
+
+				for (ValueToReferenceConverterSPI converter : converters)
+					if (converter.canConvert(o, context))
+						try {
+							o = converter.convert(o, context);
+							break;
+						} catch (ValueToReferenceConversionException vtrce) {
+							/*
+							 * Fail, but that doesn't matter at the moment as
+							 * there may be more converters to try.
+							 * 
+							 * TODO - log this!
+							 */
+						}
+			}
+			/*
+			 * If the object is neither a Throwable nor an ExternalReferenceSPI
+			 * instance at this point we should fail the registration process,
+			 * this means either that the conversion process wasn't enabled or
+			 * that it failed to map the object type correctly.
+			 */
+			if (!(o instanceof Throwable)
+					&& !(o instanceof ExternalReferenceSPI))
+				throw new ReferenceServiceException(
+						"Failed to register object "
+								+ o
+								+ ", found a type '"
+								+ o.getClass().getCanonicalName()
+								+ "' which cannot currently be registered with the reference manager");
+
+			// Have either a Throwable or an ExternalReferenceSPI
+			if (o instanceof Throwable)
+				// Wrap in an ErrorDocument and return the ID
+				try {
+					ErrorDocument doc = errorDocumentService.registerError(
+							(Throwable) o, currentDepth, context);
+					return doc.getId();
+				} catch (ErrorDocumentServiceException edse) {
+					throw new ReferenceServiceException(edse);
+				}
+			if (o instanceof ExternalReferenceSPI) {
+				if (currentDepth != 0)
+					throw new ReferenceServiceException(
+							"Cannot register external references at depth "
+									+ currentDepth);
+				try {
+					Set<ExternalReferenceSPI> references = new HashSet<ExternalReferenceSPI>();
+					references.add((ExternalReferenceSPI) o);
+					ReferenceSet rs = referenceSetService.registerReferenceSet(
+							references, context);
+					return rs.getId();
+				} catch (ReferenceSetServiceException rsse) {
+					throw new ReferenceServiceException(rsse);
+				}
+			}
+		}
+		throw new ReferenceServiceException(
+				"Should never see this, reference registration"
+						+ " logic has fallen off the end of the"
+						+ " world, check the code!");
+	}
+
+	/**
+	 * Perform recursive identifier resolution, building a collection structure
+	 * of Identified objects, any collection elements being IdentifiedLists of
+	 * Identified subclasses. If the id has depth 0 this will just return the
+	 * Identified to which that id refers.
+	 * 
+	 * @param id
+	 *            the T2Reference to resolve
+	 * @param ensureTypes
+	 *            a set of ExternalReferenceSPI classes, this is used to augment
+	 *            any resolved ReferenceSet instances to ensure that each one
+	 *            has at least one of the specified types. If augmentation is
+	 *            not required this can be set to null.
+	 * @param context
+	 *            the ReferenceContext to use to resolve this and any
+	 *            recursively resolved identifiers
+	 *            <p>
+	 *            If the context is null a new EmptyReferenceContext is inserted
+	 *            in its place.
+	 * @return fully resolved Identified subclass - this is either a (recursive)
+	 *         IdentifiedList of Identified, a ReferenceSet or an ErrorDocument
+	 * @throws ReferenceServiceException
+	 *             if any problems occur during resolution
+	 */
+	@Override
+	public Identified resolveIdentifier(T2Reference id,
+			Set<Class<ExternalReferenceSPI>> ensureTypes,
+			ReferenceContext context) throws ReferenceServiceException {
+		checkServices();
+		if (context == null)
+			context = new EmptyReferenceContext();
+		switch (id.getReferenceType()) {
+		case ReferenceSet:
+			try {
+				ReferenceSet rs;
+				if (ensureTypes == null)
+					rs = referenceSetService.getReferenceSet(id);
+				else
+					rs = referenceSetService.getReferenceSetWithAugmentation(
+							id, ensureTypes, context);
+				if (rs == null)
+					throw new ReferenceServiceException(
+							"Could not find ReferenceSet " + id);
+				return rs;
+			} catch (ReferenceSetServiceException rsse) {
+				throw new ReferenceServiceException(rsse);
+			}
+
+		case ErrorDocument:
+			try {
+				ErrorDocument ed = errorDocumentService.getError(id);
+				if (ed == null)
+					throw new ReferenceServiceException(
+							"Could not find ErrorDocument " + id);
+				return ed;
+			} catch (ErrorDocumentServiceException edse) {
+				throw new ReferenceServiceException(edse);
+			}
+
+		case IdentifiedList:
+			try {
+				IdentifiedList<T2Reference> idList = listService.getList(id);
+				if (idList == null)
+					throw new ReferenceServiceException(
+							"Could not find IdentifiedList " + id);
+				/*
+				 * Construct a new list, and populate with the result of
+				 * resolving each ID in turn
+				 */
+				IdentifiedArrayList<Identified> newList = new IdentifiedArrayList<>();
+				for (T2Reference item : idList)
+					newList.add(resolveIdentifier(item, ensureTypes, context));
+				newList.setTypedId(getAsImpl(id));
+				return newList;
+			} catch (ListServiceException lse) {
+				throw new ReferenceServiceException(lse);
+			}
+
+		default:
+			throw new ReferenceServiceException("Unsupported ID type : "
+					+ id.getReferenceType());
+		}
+	}
+
+	@Override
+	public Object renderIdentifier(T2Reference id, Class<?> leafClass,
+			ReferenceContext context) throws ReferenceServiceException {
+		// Check we have the services installed
+		checkServices();
+
+		// Insert an empty context if context was null
+		if (context == null)
+			context = new EmptyReferenceContext();
+		// Reject if the source reference contains errors
+		if (id.containsErrors())
+			throw new ReferenceServiceException(
+					"Can't render an identifier which contains errors to a POJO");
+
+		/*
+		 * Attempt to find an appropriate StreamToValueConverterSPI instance to
+		 * build the specified class
+		 */
+		StreamToValueConverterSPI<?> converter = null;
+		if (valueBuilders != null)
+			for (StreamToValueConverterSPI<?> stvc : valueBuilders) {
+				Class<?> builtClass = stvc.getPojoClass();
+				if (leafClass.isAssignableFrom(builtClass)) {
+					converter = stvc;
+					break;
+				}
+			}
+		if (converter == null)
+			log.warn("No stream->value converters found for type '"
+					+ leafClass.getCanonicalName() + "'");
+
+		// Render the identifier
+		return renderIdentifierInner(id, leafClass, context, converter);
+	}
+
+	private Object renderIdentifierInner(T2Reference id, Class<?> leafClass,
+			ReferenceContext context, StreamToValueConverterSPI<?> converter)
+			throws ReferenceServiceException {
+		checkServices();
+
+		switch (id.getReferenceType()) {
+		case IdentifiedList:
+			try {
+				IdentifiedList<T2Reference> idList = listService.getList(id);
+				if (idList == null)
+					throw new ReferenceServiceException(
+							"Could not find IdentifiedList " + id);
+				List<Object> result = new ArrayList<>();
+				for (T2Reference child : idList)
+					result.add(renderIdentifierInner(child, leafClass, context,
+							converter));
+				return result;
+			} catch (ListServiceException lse) {
+				throw new ReferenceServiceException(lse);
+			}
+
+		case ReferenceSet:
+			try {
+				ReferenceSet rs = referenceSetService.getReferenceSet(id);
+				if (rs == null)
+					throw new ReferenceServiceException(
+							"Could not find ReferenceSet " + id);
+				// Check that there are references in the set
+				if (rs.getExternalReferences().isEmpty())
+					throw new ReferenceServiceException(
+							"Can't render an empty reference set to a POJO");
+				/*
+				 * If we can't directly map to an appropriate value keep track
+				 * of the cheapest reference from which to try to build the pojo
+				 * from a stream
+				 */
+				ExternalReferenceSPI cheapestReference = null;
+				float cheapestReferenceCost = MAX_VALUE;
+				for (ExternalReferenceSPI ers : rs.getExternalReferences()) {
+					if (ers instanceof ValueCarryingExternalReference<?>) {
+						ValueCarryingExternalReference<?> vcer = (ValueCarryingExternalReference<?>) ers;
+						if (leafClass.isAssignableFrom(vcer.getValueType()))
+							return vcer.getValue();
+					}
+					// Got here so this wasn't an appropriate value type
+					if (cheapestReference == null
+							|| ers.getResolutionCost() < cheapestReferenceCost) {
+						cheapestReference = ers;
+						cheapestReferenceCost = ers.getResolutionCost();
+					}
+				}
+				if (converter != null && cheapestReference != null)
+					try (InputStream stream = cheapestReference
+							.openStream(context)) {
+						return converter.renderFrom(stream,
+								cheapestReference.getDataNature(),
+								cheapestReference.getCharset());
+					}
+			} catch (Exception e) {
+				throw new ReferenceServiceException(e);
+			}
+			throw new ReferenceServiceException(
+					"No converter found, and reference set didn't contain"
+							+ " an appropriate value carrying reference, cannot render to POJO");
+
+		default:
+			throw new ReferenceServiceException("Unsupported ID type : "
+					+ id.getReferenceType());
+		}
+	}
+
+	/**
+	 * Initiates a traversal of the specified t2reference, traversing to
+	 * whatever level of depth is required such that all identifiers returned
+	 * within the iterator have the specified depth. The context (i.e. the index
+	 * path from the originally specified reference to each reference within the
+	 * iteration) is included through use of the ContextualizedT2Reference
+	 * wrapper class
+	 * 
+	 * @param source
+	 *            the T2Reference from which to traverse. In general this is the
+	 *            root of a collection structure.
+	 * @param desiredDepth
+	 *            the desired depth of all returned T2References, must be less
+	 *            than or equal to that of the source reference.
+	 * @throws ReferenceServiceException
+	 *             if unable to create the iterator for some reason. Note that
+	 *             implementations are free to lazily perform the iteration so
+	 *             this method may succeed but the iterator produced can fail
+	 *             when used. If the iterator fails it will do so by throwing
+	 *             one of the underlying sub-service exceptions.
+	 */
+	@Override
+	public Iterator<ContextualizedT2Reference> traverseFrom(T2Reference source,
+			int desiredDepth) throws ReferenceServiceException {
+		checkServices();
+		if (desiredDepth < 0)
+			throw new ReferenceServiceException(
+					"Cannot traverse to a negative depth");
+		List<ContextualizedT2Reference> workingSet = new ArrayList<>();
+		workingSet.add(new ContextualizedT2ReferenceImpl(source, new int[0]));
+		int currentDepth = source.getDepth();
+		while (currentDepth > desiredDepth) {
+			List<ContextualizedT2Reference> newSet = new ArrayList<>();
+			for (ContextualizedT2Reference ci : workingSet) {
+				T2ReferenceImpl ref = (T2ReferenceImpl) ci.getReference();
+				switch (ref.getReferenceType()) {
+				case IdentifiedList:
+					try {
+						int position = 0;
+						for (T2Reference child : getListService().getList(ref))
+							newSet.add(new ContextualizedT2ReferenceImpl(child,
+									addIndex(ci.getIndex(), position++)));
+					} catch (ListServiceException lse) {
+						throw new ReferenceServiceException(lse);
+					}
+					break;
+				case ReferenceSet:
+					throw new ReferenceServiceException(
+							"Should never be trying to drill inside a data document identifier");
+				case ErrorDocument:
+					newSet.add(new ContextualizedT2ReferenceImpl(ref
+							.getDeeperErrorReference(), addIndex(ci.getIndex(),
+							0)));
+					break;
+				default:
+					throw new ReferenceServiceException(
+							"Fallen off end of case statement, unknown reference type!");
+				}
+			}
+			currentDepth--;
+			workingSet = newSet;
+		}
+		return workingSet.iterator();
+	}
+
+	/**
+	 * Append to an int[]
+	 * 
+	 * @param current
+	 *            current int[]
+	 * @param head
+	 *            new int item to append to the current array
+	 * @return new array of int with the head added
+	 */
+	private static int[] addIndex(int[] current, int head) {
+		int[] result = new int[current.length + 1];
+		System.arraycopy(current, 0, result, 0, current.length);
+		result[current.length] = head;
+		return result;
+	}
+
+	/**
+	 * Parse the reference contained in the string and return a
+	 * {@link T2Reference} with the correct properties
+	 */
+	@Override
+	public T2Reference referenceFromString(String reference) {
+		T2ReferenceImpl newRef = new T2ReferenceImpl();
+		Map<String, String> parseRef = parseRef(reference);
+		newRef.setNamespacePart(parseRef.get("namespace"));
+		newRef.setLocalPart(parseRef.get("localPart"));
+		String type = parseRef.get("type");
+		if (type.equals("ref")) {
+			newRef.setReferenceType(ReferenceSet);
+		} else if (type.equals("list")) {
+			newRef.setReferenceType(IdentifiedList);
+			newRef.setContainsErrors(Boolean.parseBoolean(parseRef.get("error")));
+			newRef.setDepth(Integer.parseInt(parseRef.get("depth")));
+		} else if (type.equals("error")) {
+			newRef.setContainsErrors(true);
+			newRef.setReferenceType(ErrorDocument);
+			newRef.setDepth(Integer.parseInt(parseRef.get("depth")));
+		} else {
+			return null;
+			// should throw an error
+		}
+
+		return newRef;
+	}
+
+	/**
+	 * Parse the reference and return a map with localPart, namespace, depth,
+	 * contains errors and the type
+	 * 
+	 * @param ref
+	 * @return
+	 */
+	private Map<String, String> parseRef(String ref) {
+		String[] split = ref.split("\\?");
+		/*
+		 * get the bit before and after the final '/' ie. the local part and the
+		 * depth, there might not be a split1[1] since it might not be a list
+		 */
+		String[] split2 = split[1].split("/");
+		// get the t2:abc:// and the namespace
+		String[] split3 = split[0].split("//");
+		// get the t2 bit and the reference type bit
+		String[] split4 = split3[0].split(":");
+
+		Map<String, String> refPartsMap = new HashMap<String, String>();
+		refPartsMap.put("type", split4[1]);
+		refPartsMap.put("namespace", split3[1]);
+		refPartsMap.put("localPart", split2[0]);
+
+		if (refPartsMap.get("type").equals("list")) {
+			refPartsMap.put("error", split2[1]);
+			refPartsMap.put("depth", split2[2]);
+		}
+		if (refPartsMap.get("type").equals("error"))
+			refPartsMap.put("depth", split2[1]);
+
+		return refPartsMap;
+
+	}
+
+	@Override
+	public boolean delete(List<T2Reference> references)
+			throws ReferenceServiceException {
+		for (T2Reference reference : references)
+			delete(reference);
+		return true;
+	}
+
+	@Override
+	public boolean delete(T2Reference reference)
+			throws ReferenceServiceException {
+		switch (reference.getReferenceType()) {
+		case IdentifiedList:
+			return listService.delete(reference);
+		case ReferenceSet:
+			return referenceSetService.delete(reference);
+		case ErrorDocument:
+			return errorDocumentService.delete(reference);
+		default:
+			throw new ReferenceServiceException("Unknown reference type!");
+		}
+	}
+
+	@Override
+	public void deleteReferencesForWorkflowRun(String workflowRunId)
+			throws ReferenceServiceException {
+		String errorString = "";
+		try {
+			listService.deleteIdentifiedListsForWorkflowRun(workflowRunId);
+		} catch (ReferenceServiceException resex) {
+			errorString += "Failed to delete lists for workflow run: "
+					+ workflowRunId + ".";
+		}
+		try {
+			referenceSetService
+					.deleteReferenceSetsForWorkflowRun(workflowRunId);
+		} catch (ReferenceServiceException resex) {
+			errorString += "Failed to delete reference sets for workflow run: "
+					+ workflowRunId + ".";
+		}
+		try {
+			errorDocumentService
+					.deleteErrorDocumentsForWorkflowRun(workflowRunId);
+		} catch (ReferenceServiceException resex) {
+			errorString += "Failed to delete error documents for workflow run: "
+					+ workflowRunId + ".";
+		}
+		if (!errorString.equals(""))
+			throw new ReferenceServiceException(errorString);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ReferenceSetAugmentorImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ReferenceSetAugmentorImpl.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ReferenceSetAugmentorImpl.java
new file mode 100644
index 0000000..994d104
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ReferenceSetAugmentorImpl.java
@@ -0,0 +1,461 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.PriorityQueue;
+import java.util.Set;
+
+import org.apache.taverna.reference.ExternalReferenceBuilderSPI;
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ExternalReferenceTranslatorSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferenceSet;
+import org.apache.taverna.reference.ReferenceSetAugmentationException;
+import org.apache.taverna.reference.ReferenceSetAugmentor;
+import org.apache.taverna.reference.ReferenceSetAugmentorCallback;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Implementation of ReferenceSetAugmentor using Dijkstra's shortest path
+ * algorithm over a type graph built from SPI instance registries of reference
+ * builders and reference translators.
+ * 
+ * @author Tom Oinn
+ */
+public class ReferenceSetAugmentorImpl implements ReferenceSetAugmentor {
+	private final Logger log = Logger
+			.getLogger(ReferenceSetAugmentorImpl.class);
+
+	/**
+	 * A list of ExternalReferenceBuilderSPI instances used to construct
+	 * ExternalReferenceSPI instances from byte streams
+	 */
+	private List<ExternalReferenceBuilderSPI<?>> builders;
+
+	/**
+	 * A list of ExternalReferenceTranslatorSPI instances used to construct
+	 * ExternalReferenceSPI instances from existing ExternalReferenceSPI
+	 * instances.
+	 */
+	private List<ExternalReferenceTranslatorSPI<?, ?>> translators;
+
+	private boolean cacheValid = false;
+
+	private final Set<Class<ExternalReferenceSPI>> knownReferenceTypes = new HashSet<>();
+	@SuppressWarnings("rawtypes")
+	private final Map<Class<ExternalReferenceSPI>, Set<ExternalReferenceTranslatorSPI>> adjacencySets = new HashMap<>();
+	private final Map<Class<ExternalReferenceSPI>, ShortestPathSolver> solvers = new HashMap<>();
+
+	/**
+	 * Default constructor to make life easier when using Spring. To be
+	 * functional this implementation should be injected with InstanceRegistry
+	 * implementations containing lists of known implementations of the
+	 * ExternalReferenceBuilderSPI and ExternalReferenceTranslatorSPI
+	 * interfaces.
+	 */
+	public ReferenceSetAugmentorImpl() {
+		super();
+	}
+
+	public void buildersUpdated(Object service, Map<?, ?> properties) {
+		cacheValid = false;
+	}
+
+	public void translatorsUpdated(Object service, Map<?, ?> properties) {
+		cacheValid = false;
+	}
+
+	/**
+	 * Inject a list containing all known implementations of
+	 * ExternalReferenceBuilderSPI.
+	 * 
+	 * @throws IllegalStateException
+	 *             if this has already been set, the instance registries should
+	 *             only be set on bean construction.
+	 */
+	public synchronized void setBuilders(
+			List<ExternalReferenceBuilderSPI<?>> builders) {
+		if (this.builders != null) {
+			log.error("Builder registry already injected, invalid operation");
+			throw new IllegalStateException(
+					"Can't inject the external reference builder registry "
+							+ "multiple times.");
+		}
+
+		this.builders = builders;
+		if (log.isDebugEnabled()) {
+			log.debug("* Builders injected :");
+			int counter = 0;
+			for (ExternalReferenceBuilderSPI<?> builder : builders)
+				log.debug("*   " + (++counter) + ") "
+						+ builder.getClass().getSimpleName() + ", builds "
+						+ builder.getReferenceType().getSimpleName());
+		}
+		cacheValid = false;
+	}
+
+	/**
+	 * Inject a list containing all known implementations of
+	 * ExternalReferenceTranslatorSPI.
+	 * 
+	 * @throws IllegalStateException
+	 *             if this has already been set, the instance registries should
+	 *             only be set on bean construction.
+	 */
+	public synchronized void setTranslators(
+			List<ExternalReferenceTranslatorSPI<?, ?>> translators) {
+		if (this.translators == null) {
+			this.translators = translators;
+			if (log.isDebugEnabled()) {
+				log.debug("* Translators injected :");
+				int counter = 0;
+				for (ExternalReferenceTranslatorSPI<?, ?> translator : translators)
+					log.debug("*   "
+							+ (++counter)
+							+ ") "
+							+ translator.getClass().getSimpleName()
+							+ ", translates "
+							+ translator.getSourceReferenceType()
+									.getSimpleName()
+							+ " to "
+							+ translator.getTargetReferenceType()
+									.getSimpleName());
+			}
+			cacheValid = false;
+		} else {
+			log.error("Translator registry already injected, invalid operation");
+			throw new IllegalStateException(
+					"Can't inject the translator registry multiple times.");
+		}
+	}
+
+	@SuppressWarnings({ "unchecked", "rawtypes" })
+	protected synchronized final void update() {
+		if (builders == null || translators == null || cacheValid)
+			return;
+		log.debug("# Refreshing shortest path cache");
+		knownReferenceTypes.clear();
+		solvers.clear();
+		adjacencySets.clear();
+		for (ExternalReferenceBuilderSPI erb : builders)
+			knownReferenceTypes.add(erb.getReferenceType());
+		for (ExternalReferenceTranslatorSPI ert : translators) {
+			knownReferenceTypes.add(ert.getSourceReferenceType());
+			knownReferenceTypes.add(ert.getTargetReferenceType());
+			getNeighbours(ert.getTargetReferenceType()).add(ert);
+		}
+		for (Class<ExternalReferenceSPI> type : knownReferenceTypes)
+			try {
+				solvers.put(type, new ShortestPathSolver(type));
+			} catch (Throwable t) {
+				log.error(t);
+				if (t instanceof RuntimeException)
+					throw (RuntimeException) t;
+			}
+		log.debug("# Path cache refresh done");
+		cacheValid = true;
+	}
+
+	@SuppressWarnings("rawtypes")
+	Set<ExternalReferenceTranslatorSPI> getNeighbours(
+			Class<ExternalReferenceSPI> node) {
+		Set<ExternalReferenceTranslatorSPI> adjacentTo = adjacencySets
+				.get(node);
+		if (adjacentTo != null)
+			return adjacentTo;
+
+		HashSet<ExternalReferenceTranslatorSPI> neighbours = new HashSet<>();
+		adjacencySets.put(node, neighbours);
+		return neighbours;
+	}
+
+	@Override
+	public final Set<ExternalReferenceSPI> augmentReferenceSet(
+			ReferenceSet references,
+			Set<Class<ExternalReferenceSPI>> targetReferenceTypes,
+			ReferenceContext context) throws ReferenceSetAugmentationException {
+		synchronized (this) {
+			if (!cacheValid)
+				update();
+		}
+
+		// Synchronize on the reference set itself
+		synchronized (references) {
+			/*
+			 * First check whether we actually need to modify the reference set
+			 * at all - it's perfectly valid to call the augmentor when nothing
+			 * actually needs to be done (ideally you wouldn't do this, but it's
+			 * likely to happen)
+			 */
+			for (ExternalReferenceSPI er : references.getExternalReferences())
+				if (targetReferenceTypes.contains(er.getClass()))
+					return new HashSet<>();
+
+			// Need to perform augmentation if we reach this point
+			List<TranslationPath> candidatePaths = new ArrayList<>();
+			for (Class<ExternalReferenceSPI> target : targetReferenceTypes) {
+				ShortestPathSolver solver = solvers.get(target);
+				if (solver == null) {
+					solver = new ShortestPathSolver(target);
+					solvers.put(target, solver);
+				}
+				if (solver != null)
+					for (TranslationPath path : solver.getTranslationPaths()) {
+						for (ExternalReferenceSPI er : references
+								.getExternalReferences())
+							if (er.getClass().equals(path.getSourceType()))
+								candidatePaths.add(path);
+						for (TranslationPath dereferenceBasedPath : path
+								.getDereferenceBasedPaths(references))
+							candidatePaths.add(dereferenceBasedPath);
+					}
+			}
+			/*
+			 * Now add candidate paths to represent a no-translator 'direct from
+			 * byte stream source' path for each target type compatible
+			 * reference builder
+			 */
+			for (ExternalReferenceBuilderSPI<?> builder : builders)
+				if (targetReferenceTypes.contains(builder.getReferenceType()))
+					/*
+					 * The builder can construct one of the target types, add
+					 * paths for all possible pairs of 'de-reference existing
+					 * reference' and the builder
+					 */
+					for (ExternalReferenceSPI er : references
+							.getExternalReferences()) {
+						TranslationPath newPath = new TranslationPath();
+						newPath.setBuilders(builders);
+						newPath.setInitialBuilder(builder);
+						newPath.setSourceReference(er);
+						candidatePaths.add(newPath);
+					}
+
+			/*
+			 * Got a list of candidate paths sorted by estimated overall path
+			 * cost
+			 */
+			Collections.sort(candidatePaths);
+			if (log.isDebugEnabled()) {
+				log.debug("Found "
+						+ candidatePaths.size()
+						+ " contextual translation path(s) including builder based :");
+				int counter = 0;
+				for (TranslationPath path : candidatePaths)
+					log.debug("  " + (++counter) + ") " + path.toString());
+			}
+
+			if (candidatePaths.isEmpty()) {
+				log.warn("No candidate paths found for augmentation");
+				throw new ReferenceSetAugmentationException(
+						"No candidate translation paths were found");
+			}
+
+			log.debug("Performing augmentation :");
+			int counter = 0;
+			for (TranslationPath path : candidatePaths)
+				try {
+					counter++;
+					Set<ExternalReferenceSPI> newReferences = path
+							.doTranslation(references, context);
+					if (log.isDebugEnabled())
+						log.debug("  Success (" + counter + "), created "
+								+ printRefSet(newReferences));
+					return newReferences;
+				} catch (Exception ex) {
+					log.debug("  Failed (" + counter + ")");
+					log.trace(ex);
+					// Use next path...
+				}
+			log.warn("  No paths succeeded, augmentation failed");
+			throw new ReferenceSetAugmentationException(
+					"All paths threw exceptions, can't perform augmentation");
+		}
+	}
+
+	private String printRefSet(Set<ExternalReferenceSPI> set) {
+		StringBuilder sb = new StringBuilder("[");
+		String sep = "";
+		for (ExternalReferenceSPI ref : set) {
+			sb.append(sep).append(ref.toString());
+			sep = ",";
+		}
+		return sb.append("]").toString();
+	}
+
+	@Override
+	public final void augmentReferenceSetAsynch(final ReferenceSet references,
+			final Set<Class<ExternalReferenceSPI>> targetReferenceTypes,
+			final ReferenceContext context,
+			final ReferenceSetAugmentorCallback callback)
+			throws ReferenceSetAugmentationException {
+		Runnable r = new Runnable() {
+			@Override
+			public void run() {
+				try {
+					callback.augmentationCompleted(augmentReferenceSet(
+							references, targetReferenceTypes, context));
+				} catch (ReferenceSetAugmentationException rsae) {
+					callback.augmentationFailed(rsae);
+				}
+			}
+		};
+		executeRunnable(r);
+	}
+
+	/**
+	 * Schedule a runnable for execution - current naive implementation uses a
+	 * new thread and executes immediately, but this is where any thread pool
+	 * logic would go if we wanted to add that.
+	 * 
+	 * @param r
+	 */
+	private void executeRunnable(Runnable r) {
+		new Thread(r).start();
+	}
+
+	class ShortestPathSolver {
+		private Map<Class<ExternalReferenceSPI>, Class<ExternalReferenceSPI>> predecessors;
+		private Map<Class<ExternalReferenceSPI>, ExternalReferenceTranslatorSPI<?, ?>> translators;
+		private Map<Class<ExternalReferenceSPI>, Float> shortestDistances;
+		private final Comparator<Class<ExternalReferenceSPI>> shortestDistanceComparator = new Comparator<Class<ExternalReferenceSPI>>() {
+			@Override
+			public int compare(Class<ExternalReferenceSPI> left,
+					Class<ExternalReferenceSPI> right) {
+				float shortestDistanceLeft = shortestDistances.get(left);
+				float shortestDistanceRight = shortestDistances.get(right);
+				if (shortestDistanceLeft > shortestDistanceRight)
+					return +1;
+				if (shortestDistanceLeft < shortestDistanceRight)
+					return -1;
+				return left.getCanonicalName().compareTo(
+						right.getCanonicalName());
+			}
+		};
+		private final PriorityQueue<Class<ExternalReferenceSPI>> unsettledNodes = new PriorityQueue<>(
+				10, shortestDistanceComparator);
+		private final Set<Class<ExternalReferenceSPI>> settledNodes = new HashSet<>();
+
+		private final List<TranslationPath> translationPaths = new ArrayList<>();
+
+		public List<TranslationPath> getTranslationPaths() {
+			return this.translationPaths;
+		}
+
+		public ShortestPathSolver(Class<ExternalReferenceSPI> targetType) {
+			log.debug("# Constructing shortest paths to '"
+					+ targetType.getSimpleName() + "'");
+			predecessors = new HashMap<>();
+			translators = new HashMap<>();
+			shortestDistances = new HashMap<>();
+			setShortestDistance(targetType, 0.0f);
+			unsettledNodes.add(targetType);
+			while (!unsettledNodes.isEmpty()) {
+				Class<ExternalReferenceSPI> u = extractMin();
+				settledNodes.add(u);
+				relaxNeighbours(u);
+			}
+			for (Class<ExternalReferenceSPI> c : settledNodes)
+				if (!c.equals(targetType)) {
+					// Don't calculate a path to itself!
+					TranslationPath p = new TranslationPath();
+					p.setBuilders(builders);
+					Class<ExternalReferenceSPI> node = c;
+					while (predecessors.get(node) != null) {
+						p.pathSteps().add(translators.get(node));
+						// Recurse, should terminate at the target type
+						node = predecessors.get(node);
+					}
+					translationPaths.add(p);
+				}
+			Collections.sort(translationPaths);
+			if (translationPaths.isEmpty())
+				log.debug("#   no paths discovered, type not reachable through translation");
+			else if (log.isDebugEnabled()) {
+				log.debug("#   found " + translationPaths.size()
+						+ " distinct path(s) :");
+				int counter = 0;
+				for (TranslationPath path : translationPaths)
+					log.debug("#     " + (++counter) + ") " + path);
+			}
+		}
+
+		@SuppressWarnings({ "unchecked", "rawtypes" })
+		private void relaxNeighbours(Class<ExternalReferenceSPI> u) {
+			log.trace("#     relaxing node " + u.getSimpleName());
+			Set<Class<ExternalReferenceSPI>> alreadySeen = new HashSet<>();
+			for (ExternalReferenceTranslatorSPI ert : getNeighbours(u)) {
+				// all the translators that translate *to* u
+				Class<ExternalReferenceSPI> v = ert.getSourceReferenceType();
+				log.trace("#     translator found from from '" + v + "' : "
+						+ ert.getClass().getSimpleName());
+				if (!alreadySeen.contains(v) && !isSettled(v)) {
+					/*
+					 * Avoid duplicate edges, always take the first one where
+					 * such duplicates exist
+					 */
+					alreadySeen.add(v);
+					if (getShortestDistance(v) > getShortestDistance(u)
+							+ ert.getTranslationCost()) {
+						setShortestDistance(
+								v,
+								getShortestDistance(u)
+										+ ert.getTranslationCost());
+						setPredecessor(v, u, ert);
+						unsettledNodes.add(v);
+					}
+				}
+			}
+		}
+
+		private boolean isSettled(Class<ExternalReferenceSPI> node) {
+			return settledNodes.contains(node);
+		}
+
+		private void setShortestDistance(Class<ExternalReferenceSPI> node,
+				float distance) {
+			shortestDistances.put(node, distance);
+		}
+
+		private float getShortestDistance(Class<ExternalReferenceSPI> node) {
+			Float d = shortestDistances.get(node);
+			return (d == null) ? Float.MAX_VALUE : d;
+		}
+
+		private Class<ExternalReferenceSPI> extractMin() {
+			return unsettledNodes.poll();
+		}
+
+		private void setPredecessor(Class<ExternalReferenceSPI> child,
+				Class<ExternalReferenceSPI> parent,
+				ExternalReferenceTranslatorSPI<?, ?> translator) {
+			predecessors.put(child, parent);
+			translators.put(child, translator);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ReferenceSetImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ReferenceSetImpl.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ReferenceSetImpl.java
new file mode 100644
index 0000000..785a552
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ReferenceSetImpl.java
@@ -0,0 +1,122 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import java.util.Set;
+
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceSet;
+import org.apache.taverna.reference.h3.HibernateMappedEntity;
+
+/**
+ * An implementation of ReferenceSet with the additional methods and metadata
+ * required by Hibernate3 to allow it to be persisted in a relational store. As
+ * with everything else in this package you shouldn't be using this class
+ * directly! Instead of this class you should use the registration methods on
+ * {@link org.apache.taverna.reference.ReferenceSetService}, implementations of
+ * that interface will handle the construction of ReferenceSet implementations
+ * (including this one).
+ * 
+ * @author Tom Oinn
+ */
+public class ReferenceSetImpl extends AbstractEntityImpl implements
+		ReferenceSet, HibernateMappedEntity {
+	private Set<ExternalReferenceSPI> externalReferences;
+	private Long approximateSizeInBytes = new Long(-1);
+	
+	/**
+	 * Construct a new ReferenceSetImpl with the given set of external
+	 * references and identifier.
+	 * 
+	 * @param references
+	 *            the set of ExternalReferenceSPI which this reference set
+	 *            should contain initially
+	 * @param id
+	 *            the T2Reference to use, must be an instance of
+	 *            ReferenceSetT2ReferenceImpl so hibernate can make use of it as
+	 *            a compound primary key component
+	 */
+	public ReferenceSetImpl(Set<ExternalReferenceSPI> references,
+			T2ReferenceImpl id) {
+		setTypedId(id);
+		this.externalReferences = references;
+		
+		//  Should be at least one - otherwise we cannot calculate the data size
+		if (externalReferences != null && externalReferences.size() > 0) {
+			// Just take the first ExternalReferenceSPI returned
+			ExternalReferenceSPI externalReferenceSPI = externalReferences
+					.toArray(new ExternalReferenceSPI[0])[0];
+			approximateSizeInBytes = externalReferenceSPI
+					.getApproximateSizeInBytes();
+		}
+	}
+
+	/**
+	 * Default constructor, used by Hibernate when reconstructing this bean from
+	 * the database. If you call this directly from your code you must then call
+	 * both {@link #setExternalReferences(Set)} and
+	 * {@link #setId(T2ReferenceImpl)} before any use of the reference set. If
+	 * you're not writing the reference manager implementation you shouldn't be
+	 * using this class anyway.
+	 */
+	public ReferenceSetImpl() {
+		//
+	}
+
+	/**
+	 * For debugging purposes, prints a summary of the contents and identifier
+	 * of this reference set.
+	 * 
+	 * @return human readable string representation of this object. This is not
+	 *         regarded as 'stable' and should not be parsed for any reason!
+	 */
+	@Override
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		sb.append(getId()).append(" [").append(externalReferences.size())
+				.append("]\n");
+		for (ExternalReferenceSPI ref : externalReferences)
+			sb.append("  ").append(ref).append("\n");
+		return sb.toString();
+
+	}
+
+	@Override
+	public Set<ExternalReferenceSPI> getExternalReferences() {
+		return externalReferences;
+	}
+
+	/**
+	 * This method is only ever called from within Hibernate, and is used to
+	 * initialize the set of external references.
+	 */
+	public void setExternalReferences(Set<ExternalReferenceSPI> newReferences) {
+		this.externalReferences = newReferences;
+	}
+
+	public void setApproximateSizeInBytes(Long sizeInBytes) {
+		this.approximateSizeInBytes = sizeInBytes;
+	}
+
+	@Override
+	public Long getApproximateSizeInBytes() {
+		return approximateSizeInBytes;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ReferenceSetServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ReferenceSetServiceImpl.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ReferenceSetServiceImpl.java
new file mode 100644
index 0000000..0a50883
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ReferenceSetServiceImpl.java
@@ -0,0 +1,152 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import static org.apache.taverna.reference.impl.T2ReferenceImpl.getAsImpl;
+
+import java.net.URI;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
+
+import org.apache.taverna.reference.DaoException;
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferenceServiceException;
+import org.apache.taverna.reference.ReferenceSet;
+import org.apache.taverna.reference.ReferenceSetAugmentationException;
+import org.apache.taverna.reference.ReferenceSetService;
+import org.apache.taverna.reference.ReferenceSetServiceException;
+import org.apache.taverna.reference.T2Reference;
+
+/**
+ * Implementation of ReferenceSetService, inject with an appropriate
+ * ReferenceSetDao to enable. Implements translation functionality as long as an
+ * appropriate ReferenceSetAugmentor implementation is injected.
+ * 
+ * @author Tom Oinn
+ */
+public class ReferenceSetServiceImpl extends AbstractReferenceSetServiceImpl
+		implements ReferenceSetService {
+	@Override
+	public ReferenceSet getReferenceSet(T2Reference id)
+			throws ReferenceSetServiceException {
+		checkDao();
+		try {
+			return referenceSetDao.get(id);
+		} catch (DaoException de) {
+			throw new ReferenceSetServiceException(de);
+		}
+	}
+
+	private Map<URI,Object> locks = new WeakHashMap<>();
+
+	private Object getLock(T2Reference id) {
+		URI uri = id.toUri();
+		synchronized (locks) {
+			Object lock = locks.get(uri);
+			if (lock == null) {
+				lock = new Object();
+				locks.put(uri, lock);
+			}
+			return lock;
+		}
+	}
+
+	@Override
+	public ReferenceSet getReferenceSetWithAugmentation(T2Reference id,
+			Set<Class<ExternalReferenceSPI>> ensureTypes,
+			ReferenceContext context) throws ReferenceSetServiceException {
+		checkDao();
+		checkAugmentor();
+		if (context == null)
+			context = new EmptyReferenceContext();
+		// Obtain the reference set
+
+		try {
+			/*
+			 * Synchronize on the reference set, should ensure that we don't
+			 * have multiple concurrent translations assuming that Hibernate
+			 * retrieves the same entity each time. Except we have to
+			 * synchronize on the reference, and in fact we have to synchronize
+			 * on the URI form.
+			 */
+			synchronized (getLock(id)) {
+				ReferenceSet rs = getReferenceSet(id);
+				Set<ExternalReferenceSPI> newReferences = referenceSetAugmentor
+						.augmentReferenceSet(rs, ensureTypes, context);
+				if (!newReferences.isEmpty()) {
+					/*
+					 * Write back changes to the store if we got here, this can
+					 * potentially throw an unsupported operation exception in
+					 * which case we have to fail the augmentation.
+					 */
+					try {
+						rs.getExternalReferences().addAll(newReferences);
+					} catch (RuntimeException re) {
+						throw new ReferenceSetAugmentationException(
+								"Can't add new references back into existing reference set instance");
+					}
+					referenceSetDao.update(rs);
+				}
+				return rs;
+			}
+		} catch (ReferenceSetAugmentationException rsae) {
+			throw new ReferenceSetServiceException(rsae);
+		}
+	}
+
+	@Override
+	public ReferenceSet registerReferenceSet(
+			Set<ExternalReferenceSPI> references, ReferenceContext context)
+			throws ReferenceSetServiceException {
+		checkDao();
+		checkGenerator();
+		
+		ReferenceSetImpl rsi = new ReferenceSetImpl(new HashSet<>(references),
+				getAsImpl(t2ReferenceGenerator
+						.nextReferenceSetReference(context)));
+
+		try {
+			referenceSetDao.store(rsi);
+			return rsi;
+		} catch (DaoException de) {
+			throw new ReferenceSetServiceException(de);
+		}
+	}
+
+	@Override
+	public boolean delete(T2Reference reference)
+			throws ReferenceServiceException {
+		checkDao();
+		ReferenceSet set = referenceSetDao.get(reference);
+		if (set == null)
+			return false;
+		return referenceSetDao.delete(set);
+	}
+
+	@Override
+	public void deleteReferenceSetsForWorkflowRun(String workflowRunId)
+			throws ReferenceServiceException {
+		checkDao();
+		referenceSetDao.deleteReferenceSetsForWFRun(workflowRunId);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/SimpleCacheProviderImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/SimpleCacheProviderImpl.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/SimpleCacheProviderImpl.java
new file mode 100644
index 0000000..5ea2e82
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/SimpleCacheProviderImpl.java
@@ -0,0 +1,56 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.taverna.reference.Identified;
+import org.apache.taverna.reference.ReferenceServiceCacheProvider;
+import org.apache.taverna.reference.T2Reference;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Completely naive cache provider that just stores everything in a map. This
+ * <em>will</em> run out of memory as it makes no attempt to evict old items,
+ * it's really just here as a test!
+ * 
+ * @author Tom Oinn
+ */
+public class SimpleCacheProviderImpl implements ReferenceServiceCacheProvider {
+	private final Logger log = Logger.getLogger(SimpleCacheProviderImpl.class);
+	private Map<T2Reference, Identified> cache = new HashMap<>();
+
+	@Override
+	public Identified get(T2Reference id) {
+		if (log.isDebugEnabled())
+			log.debug("Get " + id.toString() + " (" + cache.containsKey(id)
+					+ ")");
+		return cache.get(id);
+	}
+
+	@Override
+	public void put(Identified i) {
+		if (log.isDebugEnabled())
+			log.debug("Put " + i.getId().toString());
+		cache.put(i.getId(), i);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/SimpleT2ReferenceGenerator.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/SimpleT2ReferenceGenerator.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/SimpleT2ReferenceGenerator.java
new file mode 100644
index 0000000..4be90b5
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/SimpleT2ReferenceGenerator.java
@@ -0,0 +1,62 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import org.apache.taverna.reference.T2ReferenceGenerator;
+
+/**
+ * Simple implementation of T2ReferenceGenerator intended to be injected into
+ * the service layers for integration testing. Exposes a namespace property
+ * which can be configured through spring and allocates local parts based on an
+ * integer counter - this is only guaranteed to be unique within a single
+ * instance of this object so isn't suitable for real production use. For proper
+ * usage use an implementation tied to the backing store you're putting t2
+ * reference objects into.
+ * 
+ * @author Tom Oinn
+ */
+public class SimpleT2ReferenceGenerator extends AbstractT2ReferenceGenerator implements T2ReferenceGenerator {
+	private String namespace = "testNS";
+	private String localPrefix = "test";
+	private int counter = 0;
+
+	/**
+	 * Set the namespace for identifiers generated by this class as a string
+	 * 
+	 * @param newNamespace
+	 *            the namespace to use
+	 */
+	public void setNamespace(String newNamespace) {
+		this.namespace = newNamespace;
+	}
+
+	/**
+	 * Get the namespace for identifiers generated by this class
+	 */
+	@Override
+	public String getNamespace() {
+		return namespace;
+	}
+
+	@Override
+	protected synchronized String getNextLocalPart() {
+		return localPrefix + (counter++);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/StackTraceElementBeanImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/StackTraceElementBeanImpl.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/StackTraceElementBeanImpl.java
new file mode 100644
index 0000000..12158f5
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/StackTraceElementBeanImpl.java
@@ -0,0 +1,76 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import org.apache.taverna.reference.StackTraceElementBean;
+import org.apache.taverna.reference.h3.HibernateComponentClass;
+
+/**
+ * Simple bean implementation of StackTraceElement for Hibernate
+ * 
+ * @author Tom Oinn
+ */
+public class StackTraceElementBeanImpl implements StackTraceElementBean,
+		HibernateComponentClass {
+	private String className;
+	private String fileName;
+	private String methodName;
+	private int lineNumber;
+
+	public StackTraceElementBeanImpl() {
+		//
+	}
+
+	@Override
+	public String getClassName() {
+		return this.className;
+	}
+
+	public void setClassName(String className) {
+		this.className = className;
+	}
+
+	@Override
+	public String getFileName() {
+		return this.fileName;
+	}
+
+	public void setFileName(String fileName) {
+		this.fileName = fileName;
+	}
+
+	@Override
+	public int getLineNumber() {
+		return lineNumber;
+	}
+
+	public void setLineNumber(int lineNumber) {
+		this.lineNumber = lineNumber;
+	}
+
+	@Override
+	public String getMethodName() {
+		return this.methodName;
+	}
+
+	public void setMethodName(String methodName) {
+		this.methodName = methodName;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/T2ReferenceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/T2ReferenceImpl.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/T2ReferenceImpl.java
new file mode 100644
index 0000000..2f0b385
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/T2ReferenceImpl.java
@@ -0,0 +1,287 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import static org.apache.taverna.reference.T2ReferenceType.ErrorDocument;
+
+import java.io.Serializable;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.UUID;
+
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.T2ReferenceType;
+import org.apache.taverna.reference.h3.HibernateComponentClass;
+
+import org.apache.log4j.Logger;
+
+/**
+ * An implementation of T2Reference specific to the ReferenceSetImpl. This is
+ * needed because ReferenceSetImpl uses a component based primary key driven
+ * from the namespace and local parts of T2Reference. This in turn means we can
+ * query hibernate directly with a T2Reference instance in the data access
+ * object. Because this is only used as a component (i.e. a value type) we don't
+ * need to define a hibernate mapping file for it.
+ * 
+ * @author Tom Oinn
+ * @author David Withers
+ */
+public class T2ReferenceImpl implements T2Reference, Serializable, HibernateComponentClass {
+	private static Logger logger = Logger.getLogger(T2ReferenceImpl.class);
+
+	private static final long serialVersionUID = 8363330461158750319L;
+	private String localPart;
+	private String namespacePart;
+	private long localMostSigBits, localLeastSigBits;
+	private boolean containsErrors = false;
+	private T2ReferenceType referenceType = T2ReferenceType.ReferenceSet;
+	private int depth = 0;
+	private transient URI cachedURI;
+
+	public T2ReferenceImpl() {
+		// Default constructor for Hibernate et al
+	}
+
+	/**
+	 * Construct a deep copy of the given T2Reference
+	 * 
+	 * @param source
+	 *            T2Reference to copy
+	 */
+	private T2ReferenceImpl(T2Reference source) {
+		super();
+		setNamespacePart(source.getNamespacePart());
+		setLocalPart(source.getLocalPart());
+		setContainsErrors(source.containsErrors());
+		setReferenceType(source.getReferenceType());
+		setDepth(source.getDepth());
+	}
+
+	public static T2ReferenceImpl getAsImpl(T2Reference source) {
+		if (source instanceof T2ReferenceImpl)
+			return (T2ReferenceImpl) source;
+		return new T2ReferenceImpl(source);
+	}
+
+	/**
+	 * Return whether the identified entity either is or contains errors
+	 */
+	@Override
+	public boolean containsErrors() {
+		return this.containsErrors;
+	}
+
+	/**
+	 * Property accessor for Hibernate, complies with java bean spec
+	 */
+	public boolean getContainsErrors() {
+		return this.containsErrors;
+	}
+
+	/**
+	 * Get the depth of the entity referred to by this reference
+	 */
+	@Override
+	public int getDepth() {
+		return this.depth;
+	}
+
+	/**
+	 * Get the local part of the URI for this reference
+	 */
+	@Override
+	public String getLocalPart() {
+		if (localPart == null) {
+			UUID localPartUUID = new UUID(localMostSigBits, localLeastSigBits);
+			return localPartUUID.toString();
+		}
+		return localPart;
+	}
+
+	/**
+	 * Get the namespace part of the URI for this reference
+	 */
+	@Override
+	public String getNamespacePart() {
+		return namespacePart;
+	}
+
+	/**
+	 * Get the type of the entity to which this reference refers
+	 */
+	@Override
+	public T2ReferenceType getReferenceType() {
+		return referenceType;
+	}
+
+	/**
+	 * This method is only ever called from within Hibernate when
+	 * re-constructing the identifier component to set the namespace part of the
+	 * identifier.
+	 */
+	public synchronized void setNamespacePart(String namespacePart) {
+		this.namespacePart = namespacePart;
+	}
+
+	/**
+	 * This method is only ever called from within Hibernate when
+	 * re-constructing the identifier component to set the local part of the
+	 * identifier.
+	 */
+	public synchronized void setLocalPart(String localPart) {
+		try {
+			UUID namespacePartUUID = UUID.fromString(localPart);
+			localMostSigBits = namespacePartUUID.getMostSignificantBits();
+			localLeastSigBits = namespacePartUUID.getLeastSignificantBits();
+			this.localPart = null;
+		} catch (IllegalArgumentException e) {
+			this.localPart = localPart;
+		}
+	}
+
+	/**
+	 * This method is only ever called from within Hibernate when
+	 * re-constructing the identifier component to set the depth of the
+	 * identifier.
+	 */
+	public synchronized void setDepth(int depth) {
+		this.depth = depth;
+	}
+
+	/**
+	 * This method is only ever called from within Hibernate when
+	 * re-constructing the identifier component to set the error property of the
+	 * identifier.
+	 */
+	public synchronized void setContainsErrors(boolean containsErrors) {
+		this.containsErrors = containsErrors;
+	}
+
+	/**
+	 * This method is only ever called from within Hibernate when
+	 * re-constructing the identifier component to set the reference type
+	 * property of the identifier.
+	 */
+	public synchronized void setReferenceType(T2ReferenceType type) {
+		this.referenceType = type;
+	}
+
+	/**
+	 * By default when printing an identifier we use {@link #toUri()}.
+	 * {@link java.net.URI#toASCIIString() toASCIIString()}
+	 */
+	@Override
+	public String toString() {
+		return toUri().toASCIIString();
+	}
+
+	/**
+	 * Drill inside an error document reference to get the error one deeper than
+	 * this as long as it is at least depth 1.
+	 */
+	T2ReferenceImpl getDeeperErrorReference() {
+		if (!getReferenceType().equals(ErrorDocument))
+			throw new AssertionError(
+					"Attempt to get a deeper reference on something that isn't an error ref");
+		if (getDepth() == 0)
+			throw new AssertionError(
+					"Error identifier already has depth 0, cannot decrease");
+
+		T2ReferenceImpl result = new T2ReferenceImpl();
+		result.setContainsErrors(true);
+		result.setDepth(getDepth() - 1);
+		result.setLocalPart(getLocalPart());
+		result.setNamespacePart(getNamespacePart());
+		result.setReferenceType(ErrorDocument);
+		return result;
+	}
+
+	/**
+	 * Returns the identifier expressed as a {@link java.net.URI URI},
+	 * constructed based on the reference type. For references to ReferenceSet
+	 * this is
+	 * <code>new URI("t2:ref//" + namespacePart + "?" + localPart)</code>
+	 * leading to URIs of the form <code>t2:ref//namespace?local</code>
+	 */
+	@Override
+	public synchronized URI toUri() {
+		try {
+			if (cachedURI == null)
+				switch (referenceType) {
+				case ReferenceSet:
+					cachedURI = new URI("t2:ref//" + getNamespacePart() + "?"
+							+ getLocalPart());
+				case IdentifiedList:
+					cachedURI = new URI("t2:list//" + getNamespacePart() + "?"
+							+ getLocalPart() + "/" + containsErrors + "/"
+							+ depth);
+				case ErrorDocument:
+					cachedURI = new URI("t2:error//" + getNamespacePart() + "?"
+							+ getLocalPart() + "/" + depth);
+				}
+		} catch (URISyntaxException e) {
+			logger.error("Unable to create URI", e);
+		}
+		return cachedURI;
+	}
+
+	@Override
+	public int hashCode() {
+		int result = 1;
+		result = 31 * result + depth;
+		result = 31 * result + (int) (localLeastSigBits ^ (localLeastSigBits >>> 32));
+		result = 31 * result + (int) (localMostSigBits ^ (localMostSigBits >>> 32));
+		result = 31 * result + ((localPart == null) ? 0 : localPart.hashCode());
+		result = 31 * result + ((namespacePart == null) ? 0 : namespacePart.hashCode());
+		return result;
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (obj == null)
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		T2ReferenceImpl other = (T2ReferenceImpl) obj;
+		if (depth != other.depth)
+			return false;
+		if (localLeastSigBits != other.localLeastSigBits)
+			return false;
+		if (localMostSigBits != other.localMostSigBits)
+			return false;
+		if (localPart == null) {
+			if (other.localPart != null)
+				return false;
+		} else if (!localPart.equals(other.localPart))
+			return false;
+		if (namespacePart == null) {
+			if (other.namespacePart != null)
+				return false;
+		} else if (!namespacePart.equals(other.namespacePart))
+			return false;
+		return true;
+	}
+
+	public synchronized String getCompactForm() {
+		return getNamespacePart() + ":" + getLocalPart() + ":" + getDepth();
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/T2ReferenceListImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/T2ReferenceListImpl.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/T2ReferenceListImpl.java
new file mode 100644
index 0000000..2b0a449
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/T2ReferenceListImpl.java
@@ -0,0 +1,74 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import java.util.List;
+
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.h3.HibernateMappedEntity;
+
+/**
+ * Simple extension of
+ * <code>{@link IdentifiedArrayList IdentifiedArrayList&lt;T2Reference&gt;}</code>
+ * exposing get and set methods for the list contents so we can map it in
+ * hibernate.
+ * 
+ * @author Tom Oinn
+ */
+public class T2ReferenceListImpl extends IdentifiedArrayList<T2Reference>
+		implements HibernateMappedEntity {
+	public T2ReferenceListImpl() {
+		super();
+	}
+
+	/**
+	 * This is only called from Hibernate, outside of test code, so is
+	 * relatively safe to leave unchecked.
+	 */
+	@SuppressWarnings("rawtypes")
+	public List getListContents() {
+		return this.listDelegate;
+	}
+
+	/**
+	 * This is only called from Hibernate, outside of test code, so is
+	 * relatively safe to leave unchecked.
+	 */
+	@SuppressWarnings({ "unchecked", "rawtypes" })
+	public void setListContents(List newList) {
+		this.listDelegate = newList;
+	}
+
+	/**
+	 * Print the contents of this list for vaguely human readable debug
+	 * purposes.
+	 */
+	@Override
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		sb.append(getId()).append("\n");
+		int counter = 0;
+		for (T2Reference ref : listDelegate)
+			sb.append("  ").append(++counter).append(") ").append(ref)
+					.append("\n");
+		return sb.toString();
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateErrorDocumentDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateErrorDocumentDao.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateErrorDocumentDao.java
new file mode 100644
index 0000000..38a6988
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateErrorDocumentDao.java
@@ -0,0 +1,154 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import static org.apache.taverna.reference.T2ReferenceType.ErrorDocument;
+
+import java.util.List;
+
+import org.apache.taverna.reference.DaoException;
+import org.apache.taverna.reference.ErrorDocument;
+import org.apache.taverna.reference.ErrorDocumentDao;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.annotations.DeleteIdentifiedOperation;
+import org.apache.taverna.reference.annotations.GetIdentifiedOperation;
+import org.apache.taverna.reference.annotations.PutIdentifiedOperation;
+
+import org.hibernate.Query;
+import org.hibernate.SessionFactory;
+
+/**
+ * An implementation of ErrorDocumentDao based on raw hibernate session factory
+ * injection and running within a spring managed context through auto-proxy
+ * generation. To use this in spring inject a property 'sessionFactory' with
+ * either a {@link org.springframework.orm.hibernate3.LocalSessionFactoryBean
+ * LocalSessionFactoryBean} or the equivalent class from the T2Platform module
+ * to add SPI based implementation discovery and mapping. To use outside of
+ * Spring ensure you call the setSessionFactory(..) method before using this
+ * (but really, use it from Spring, so much easier).
+ * <p>
+ * Methods in this Dao require transactional support
+ * 
+ * @author Tom Oinn
+ */
+public class TransactionalHibernateErrorDocumentDao implements ErrorDocumentDao {
+	private static final String GET_ERRORS_FOR_RUN = "FROM ErrorDocumentImpl WHERE namespacePart = :workflow_run_id";
+	private SessionFactory sessionFactory;
+
+	public void setSessionFactory(SessionFactory sessionFactory) {
+		this.sessionFactory = sessionFactory;
+	}
+
+	/**
+	 * Fetch an ErrorDocument list by id
+	 * 
+	 * @param ref
+	 *            the T2Reference to fetch
+	 * @return a retrieved identified list of T2 references
+	 * @throws DaoException
+	 *             if the supplied reference is of the wrong type or if
+	 *             something goes wrong fetching the data or connecting to the
+	 *             database
+	 */
+	@Override
+	@GetIdentifiedOperation
+	public ErrorDocument get(T2Reference ref) throws DaoException {
+		if (ref == null)
+			throw new DaoException(
+					"Supplied reference is null, can't retrieve.");
+		if (!ref.getReferenceType().equals(ErrorDocument))
+			throw new DaoException(
+					"This dao can only retrieve reference of type T2Reference.ErrorDocument");
+		if (!(ref instanceof T2ReferenceImpl))
+			throw new DaoException(
+					"Reference must be an instance of T2ReferenceImpl");
+
+		try {
+			return (ErrorDocumentImpl) sessionFactory.getCurrentSession().get(
+					ErrorDocumentImpl.class,
+					((T2ReferenceImpl) ref).getCompactForm());
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+
+	@Override
+	@PutIdentifiedOperation
+	public void store(ErrorDocument theDocument) throws DaoException {
+		if (theDocument.getId() == null)
+			throw new DaoException(
+					"Supplied error document set has a null ID, allocate "
+							+ "an ID before calling the store method in the dao.");
+		if (!theDocument.getId().getReferenceType().equals(ErrorDocument))
+			throw new DaoException("Strangely the list ID doesn't have type "
+					+ "T2ReferenceType.ErrorDocument, something has probably "
+					+ "gone badly wrong somewhere earlier!");
+		if (!(theDocument instanceof ErrorDocumentImpl))
+			throw new DaoException(
+					"Supplied ErrorDocument not an instance of ErrorDocumentImpl");
+
+		try {
+			sessionFactory.getCurrentSession().save(theDocument);
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+
+	@Override
+	@DeleteIdentifiedOperation
+	public boolean delete(ErrorDocument theDocument) throws DaoException {
+		if (theDocument.getId() == null)
+			throw new DaoException(
+					"Supplied error document set has a null ID, allocate "
+							+ "an ID before calling the store method in the dao.");
+		if (!theDocument.getId().getReferenceType().equals(ErrorDocument))
+			throw new DaoException("Strangely the list ID doesn't have type "
+					+ "T2ReferenceType.ErrorDocument, something has probably "
+					+ "gone badly wrong somewhere earlier!");
+		if (!(theDocument instanceof ErrorDocumentImpl))
+			throw new DaoException(
+					"Supplied ErrorDocument not an instance of ErrorDocumentImpl");
+
+		try {
+			sessionFactory.getCurrentSession().delete(theDocument);
+			return true;
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+
+	@Override
+	@SuppressWarnings("unchecked")
+	@DeleteIdentifiedOperation
+	public synchronized void deleteErrorDocumentsForWFRun(String workflowRunId)
+			throws DaoException {
+		try {
+			// Select all ErrorDocuments for this wf run
+			Query selectQuery = sessionFactory.getCurrentSession().createQuery(
+					GET_ERRORS_FOR_RUN);
+			selectQuery.setString("workflow_run_id", workflowRunId);
+			List<ErrorDocument> errorDocuments = selectQuery.list();
+			for (ErrorDocument errorDocument : errorDocuments)
+				delete(errorDocument);
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateListDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateListDao.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateListDao.java
new file mode 100644
index 0000000..3cc6561
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateListDao.java
@@ -0,0 +1,153 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import static org.apache.taverna.reference.T2ReferenceType.IdentifiedList;
+
+import java.util.List;
+
+import org.apache.taverna.reference.DaoException;
+import org.apache.taverna.reference.IdentifiedList;
+import org.apache.taverna.reference.ListDao;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.annotations.DeleteIdentifiedOperation;
+import org.apache.taverna.reference.annotations.GetIdentifiedOperation;
+import org.apache.taverna.reference.annotations.PutIdentifiedOperation;
+
+import org.hibernate.Query;
+import org.hibernate.SessionFactory;
+
+/**
+ * An implementation of ListDao based on based on raw hibernate session factory
+ * injection and running within a spring managed context through auto-proxy
+ * generation. To use this in spring inject a property 'sessionFactory' with
+ * either a {@link org.springframework.orm.hibernate3.LocalSessionFactoryBean
+ * LocalSessionFactoryBean} or the equivalent class from the T2Platform module
+ * to add SPI based implementation discovery and mapping. To use outside of
+ * Spring ensure you call the setSessionFactory(..) method before using this
+ * (but really, use it from Spring, so much easier).
+ * <p>
+ * Methods in this Dao require transactional support
+ * 
+ * @author Tom Oinn
+ */
+public class TransactionalHibernateListDao implements ListDao {
+	private static final String GET_REFLISTS_FOR_RUN = "FROM T2ReferenceListImpl WHERE namespacePart = :workflow_run_id";
+	private SessionFactory sessionFactory;
+
+	public void setSessionFactory(SessionFactory sessionFactory) {
+		this.sessionFactory = sessionFactory;
+	}
+
+	/**
+	 * Fetch a t2reference list by id
+	 * 
+	 * @param ref
+	 *            the T2Reference to fetch
+	 * @return a retrieved identified list of T2 references
+	 * @throws DaoException
+	 *             if the supplied reference is of the wrong type or if
+	 *             something goes wrong fetching the data or connecting to the
+	 *             database
+	 */
+	@Override
+	@GetIdentifiedOperation
+	public IdentifiedList<T2Reference> get(T2Reference ref) throws DaoException {
+		if (ref == null)
+			throw new DaoException(
+					"Supplied reference is null, can't retrieve.");
+		if (!ref.getReferenceType().equals(IdentifiedList))
+			throw new DaoException(
+					"This dao can only retrieve reference of type T2Reference.IdentifiedList");
+		if (!(ref instanceof T2ReferenceImpl))
+			throw new DaoException(
+					"Reference must be an instance of T2ReferenceImpl");
+
+		try {
+			return (T2ReferenceListImpl) sessionFactory.getCurrentSession()
+					.get(T2ReferenceListImpl.class,
+							((T2ReferenceImpl) ref).getCompactForm());
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+
+	@Override
+	@PutIdentifiedOperation
+	public void store(IdentifiedList<T2Reference> theList) throws DaoException {
+		if (theList.getId() == null)
+			throw new DaoException("Supplied list set has a null ID, allocate "
+					+ "an ID before calling the store method in the dao.");
+		if (!theList.getId().getReferenceType().equals(IdentifiedList))
+			throw new DaoException("Strangely the list ID doesn't have type "
+					+ "T2ReferenceType.IdentifiedList, something has probably "
+					+ "gone badly wrong somewhere earlier!");
+		if (!(theList instanceof T2ReferenceListImpl))
+			throw new DaoException(
+					"Supplied identifier list not an instance of T2ReferenceList");
+
+		try {
+			sessionFactory.getCurrentSession().save(theList);
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+
+	@Override
+	public boolean delete(IdentifiedList<T2Reference> theList)
+			throws DaoException {
+		if (theList.getId() == null)
+			throw new DaoException("Supplied list set has a null ID, allocate "
+					+ "an ID before calling the store method in the dao.");
+		if (!theList.getId().getReferenceType().equals(IdentifiedList))
+			throw new DaoException("Strangely the list ID doesn't have type "
+					+ "T2ReferenceType.IdentifiedList, something has probably "
+					+ "gone badly wrong somewhere earlier!");
+		if (!(theList instanceof T2ReferenceListImpl))
+			throw new DaoException(
+					"Supplied identifier list not an instance of T2ReferenceList");
+
+		try {
+			sessionFactory.getCurrentSession().delete(theList);
+			return true;
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+
+	@Override
+	@SuppressWarnings("unchecked")
+	@DeleteIdentifiedOperation
+	public synchronized void deleteIdentifiedListsForWFRun(String workflowRunId)
+			throws DaoException {
+		try {
+			// Select all T2Reference lists for this wf run
+			Query selectQuery = sessionFactory.getCurrentSession().createQuery(
+					GET_REFLISTS_FOR_RUN);
+			selectQuery.setString("workflow_run_id", workflowRunId);
+			List<IdentifiedList<T2Reference>> referenceLists = selectQuery
+					.list();
+			for (IdentifiedList<T2Reference> referenceList : referenceLists)
+				delete(referenceList);
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+}


[29/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/main/java/org/apache/taverna/platform/report/WorkflowReport.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/main/java/org/apache/taverna/platform/report/WorkflowReport.java b/taverna-report-api/src/main/java/org/apache/taverna/platform/report/WorkflowReport.java
new file mode 100644
index 0000000..20807ae
--- /dev/null
+++ b/taverna-report-api/src/main/java/org/apache/taverna/platform/report/WorkflowReport.java
@@ -0,0 +1,168 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.report;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import org.apache.taverna.robundle.Bundle;
+import org.apache.taverna.scufl2.api.core.Workflow;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+/**
+ * Report about the {@link State} of a {@link Workflow} run.
+ *
+ * @author David Withers
+ */
+public class WorkflowReport extends StatusReport<Workflow, ActivityReport> {
+	@SuppressWarnings("unused")
+	private static final Logger logger = Logger.getLogger(WorkflowReport.class.getName());
+	private static final String dateFormatString = "yyyy-MM-dd HH:mm:ss";
+
+	private Set<ProcessorReport> processorReports = new LinkedHashSet<>();
+	private Bundle dataBundle;
+
+	public WorkflowReport(Workflow workflow) {
+		super(workflow);
+	}
+
+	public Set<ProcessorReport> getProcessorReports() {
+		return processorReports;
+	}
+
+	public void addProcessorReport(ProcessorReport processorReport) {
+		processorReports.add(processorReport);
+	}
+
+	@JsonIgnore
+	public Bundle getDataBundle() {
+		return dataBundle;
+	}
+
+	public void setDataBundle(Bundle dataBundle) {
+		this.dataBundle = dataBundle;
+	}
+
+	@Override
+	public String toString() {
+		DateFormat dateFormat = new SimpleDateFormat(dateFormatString);
+		StringBuilder sb = new StringBuilder();
+		int max = getLongestName(this, 0);
+		spaces(sb, max + 1);
+		sb.append("Status    ");
+		sb.append("Queued    ");
+		sb.append("Started   ");
+		sb.append("Complete  ");
+		sb.append("Errors    ");
+		sb.append("Started             ");
+		sb.append("Finished\n");
+		sb.append(getSubject().getName());
+		spaces(sb, max - getSubject().getName().length() + 1);
+		sb.append(getState());
+		spaces(sb, 10 - getState().name().length());
+		sb.append("-");
+		spaces(sb, 9);
+		sb.append("-");
+		spaces(sb, 9);
+		sb.append("-");
+		spaces(sb, 9);
+		sb.append("-");
+		spaces(sb, 9);
+		addDates(sb, getStartedDate(), getCompletedDate(), dateFormat);
+		for (ProcessorReport processorReport : getProcessorReports())
+			addProcessor(sb, max, 0, processorReport, dateFormat);
+		return sb.toString();
+	}
+
+	private void addProcessor(StringBuilder sb, int max, int level, ProcessorReport processorReport, DateFormat dateFormat) {
+		String processorName = processorReport.getSubject().getName();
+		spaces(sb, level);
+		sb.append(processorName);
+		spaces(sb, max - processorName.length() - level + 1);
+
+		State processorState = processorReport.getState();
+		sb.append(processorState);
+		spaces(sb, 10 - processorState.name().length());
+
+		String jobsQueued = String.valueOf(processorReport.getJobsQueued());
+		sb.append(jobsQueued);
+		spaces(sb, 10 - jobsQueued.length());
+
+		String jobsStarted = String.valueOf(processorReport.getJobsStarted());
+		sb.append(jobsStarted);
+		spaces(sb, 10 - jobsStarted.length());
+
+		String jobsCompleted = String.valueOf(processorReport.getJobsCompleted());
+		sb.append(jobsCompleted);
+		spaces(sb, 10 - jobsCompleted.length());
+
+		String jobsCompletedWithErrors = String.valueOf(processorReport
+				.getJobsCompletedWithErrors());
+		sb.append(jobsCompletedWithErrors);
+		spaces(sb, 10 - jobsCompletedWithErrors.length());
+
+		addDates(sb, processorReport.getStartedDate(), processorReport.getCompletedDate(), dateFormat);
+
+		for (ActivityReport activityReport : processorReport.getActivityReports()) {
+			WorkflowReport nestedWorkflowReport = activityReport.getNestedWorkflowReport();
+			if (nestedWorkflowReport != null)
+				for (ProcessorReport nestedProcessorReport : nestedWorkflowReport.getProcessorReports())
+					addProcessor(sb, max, level + 1, nestedProcessorReport, dateFormat);
+		}
+	}
+
+	private void addDates(StringBuilder sb, Date started, Date stopped, DateFormat dateFormat) {
+		if (started != null) {
+			sb.append(dateFormat.format(started));
+			sb.append(' ');
+		} else {
+			sb.append('-');
+			spaces(sb, dateFormatString.length());
+		}
+		if (stopped != null)
+			sb.append(dateFormat.format(stopped) + "\n");
+		else
+			sb.append("-\n");
+	}
+
+	private int getLongestName(WorkflowReport workflowReport, int level) {
+		int result = 0;
+		result = Math.max(result, getSubject().getName().length() + level);
+		for (ProcessorReport processorReport : workflowReport.getProcessorReports()) {
+			result = Math.max(result, processorReport.getSubject().getName().length());
+			for (ActivityReport activityReport : processorReport.getActivityReports()) {
+				WorkflowReport nestedWorkflowReport = activityReport.getNestedWorkflowReport();
+				if (nestedWorkflowReport != null)
+					result = Math.max(result, getLongestName(nestedWorkflowReport, level + 1));
+			}
+		}
+		return result;
+	}
+
+	private static void spaces(StringBuilder sb, int length) {
+		for (int i = 0; i < length; i++)
+			sb.append(' ');
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ActivityReport.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ActivityReport.java b/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ActivityReport.java
deleted file mode 100644
index 4a9d1ea..0000000
--- a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ActivityReport.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.report;
-
-import org.apache.taverna.scufl2.api.activity.Activity;
-
-/**
- * Report about the {@link State} of an {@link Activity} invocation.
- *
- * @author David Withers
- */
-public class ActivityReport extends StatusReport<Activity, ProcessorReport> {
-	private WorkflowReport nestedWorkflowReport;
-
-	/**
-	 * Constructs a new <code>ActivityReport</code>.
-	 *
-	 * @param activity
-	 */
-	public ActivityReport(Activity activity) {
-		super(activity);
-	}
-
-	public WorkflowReport getNestedWorkflowReport() {
-		return nestedWorkflowReport;
-	}
-
-	public void setNestedWorkflowReport(WorkflowReport nestedWorkflowReport) {
-		this.nestedWorkflowReport = nestedWorkflowReport;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/main/java/uk/org/taverna/platform/report/Invocation.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/Invocation.java b/taverna-report-api/src/main/java/uk/org/taverna/platform/report/Invocation.java
deleted file mode 100644
index fc95157..0000000
--- a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/Invocation.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.report;
-
-import java.nio.file.Path;
-import java.util.Date;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.SortedSet;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.apache.taverna.scufl2.api.port.Port;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-
-/**
- * A single invocation of a workflow, processor or activity.
- *
- * @author David Withers
- */
-@JsonPropertyOrder({"id","parent", "name",  "index", "state", "startedDate", "completedDate", "inputs", "outputs"})
-public class Invocation implements Comparable<Invocation> {
-	private final String name;
-	private final int[] index;
-	private final Invocation parent;
-	private State state;
-	private Date startedDate, completedDate;
-	private final SortedSet<Invocation> invocations;
-	private final StatusReport<?, ?> report;
-	private SortedMap<String, Path> inputs, outputs;
-
-	/**
-     * Internal constructor for comparison use.
-     *
-     * Only use with {@link #compareTo(Invocation)} use when looking
-     * up from {@link StatusReport#getInvocation(String)}. All fields except
-     * {@link #getName()} are <code>null</code>.
-     *
-     * @param name The name of the invocation to compare with
-     **/
-	Invocation(String name) {
-	    this.name = name;
-	    this.report = null;
-	    this.parent = null;
-	    this.invocations = null;
-	    this.index = null;
-	}
-
-	public Invocation(String name, Invocation parent, StatusReport<?, ?> report) {
-		this(name, new int[0], parent, report);
-	}
-
-	public Invocation(String name, int[] index, Invocation parent, StatusReport<?, ?> report) {
-		this.name = name;
-		this.index = index;
-		this.parent = parent;
-		this.report = report;
-
-		invocations = new TreeSet<>();
-
-		inputs = new TreeMap<>();
-		for (Port port : report.getSubject().getInputPorts())
-			inputs.put(port.getName(), null);
-
-		outputs = new TreeMap<>();
-		for (Port port : report.getSubject().getOutputPorts())
-			outputs.put(port.getName(), null);
-
-		setStartedDate(new Date());
-
-		if (parent != null)
-			parent.getInvocations().add(this);
-		report.addInvocation(this);
-	}
-
-	/**
-	 * Returns the name for this invocation.
-	 *
-	 * @return the name for this invocation
-	 */
-	@JsonProperty("name")
-	public String getName() {
-		return name;
-	}
-
-	public int[] getIndex() {
-		return index;
-	}
-
-	/**
-	 * Returns the  identifier for this invocation by prepending the identifier of the parent
-	 * invocation.
-	 *
-	 * @return the identifier for this invocation
-	 */
-	@JsonProperty("id")
-	public String getId() {
-		if (parent != null) {
-			String parentId = parent.getId();
-			if (parentId != null && !parentId.isEmpty())
-				return parent.getId() + "/" + name;
-		}
-		return name;
-	}
-
-	@JsonIgnore
-	public StatusReport<?, ?> getReport() {
-		return report;
-	}
-
-	/**
-	 * Returns the parent invocation.
-	 * <p>
-	 * Returns <code>null</code> if there is no parent invocation.
-	 *
-	 * @return the parent invocation
-	 */
-	@JsonIgnore
-	public Invocation getParent() {
-		return parent;
-	}
-
-	@JsonProperty("parent")
-	public String getParentId() {
-	    if (parent == null)
-	        return null;
-	    return parent.getId();
-	}
-
-	/**
-	 * Returns the child invocations.
-	 * <p>
-	 * Returns and empty set if there are no child invocations.
-	 *
-	 * @return the child invocations
-	 */
-	@JsonIgnore
-	public SortedSet<Invocation> getInvocations() {
-		return invocations;
-	}
-
-	/**
-	 * Returns a map of input port names to values.
-	 * <p>
-	 * Returns an empty map if there are no input ports. If there is no value for an input port the
-	 * map will contain a <code>null</code> value.
-	 *
-	 * @return a map of input port names to values
-	 */
-	public SortedMap<String, Path> getInputs() {
-		return inputs;
-	}
-
-	/**
-	 * Sets the values of input ports.
-	 *
-	 * @param inputs
-	 *            the values of input ports
-	 */
-	public void setInputs(Map<String, Path> inputs) {
-		this.inputs.putAll(inputs);
-	}
-
-	/**
-	 * Sets the value of an input port.
-	 *
-	 * @param port the port name
-	 * @param value the port value
-	 */
-	public void setInput(String port, Path value) {
-		inputs.put(port, value);
-	}
-
-	/**
-	 * Returns a map of output port names to values.
-	 * <p>
-	 * Returns an empty map if there are no output ports. If there is no value for an output port
-	 * the map will contain a <code>null</code> value.
-	 *
-	 * @return a map of input port names to values
-	 */
-	public SortedMap<String, Path> getOutputs() {
-		return outputs;
-	}
-
-	/**
-	 * Sets the values of input ports.
-	 *
-	 * @param inputs
-	 *            the values of input ports
-	 */
-	public void setOutputs(Map<String, Path> outputs) {
-		this.outputs.putAll(outputs);
-	}
-
-	/**
-	 * Sets the value of an output port.
-	 *
-	 * @param port the port name
-	 * @param value the port value
-	 */
-	public void setOutput(String port, Path value) {
-		outputs.put(port, value);
-	}
-
-	/**
-	 * Returns the current {@link State} of the invocation.
-	 * <p>
-	 * An invocation state can be RUNNING or COMPLETED.
-	 *
-	 * @return the current <code>State</code>
-	 */
-	public State getState() {
-		return state;
-	}
-
-	/**
-	 * Returns the date that the status changed to RUNNING.
-	 * <p>
-	 * If the status has never been RUNNING <code>null</code> is returned.
-	 *
-	 * @return the date that the status changed to started
-	 */
-	public Date getStartedDate() {
-		return startedDate;
-	}
-
-	/**
-	 * Sets the date that the status changed to RUNNING.
-	 *
-	 * @param startedDate
-	 *            the date that the status changed to RUNNING
-	 */
-	public void setStartedDate(Date startedDate) {
-		this.startedDate = startedDate;
-		state = State.RUNNING;
-	}
-
-	/**
-	 * Returns the date that the status changed to COMPLETED.
-	 * <p>
-	 * If the status never been COMPLETED <code>null</code> is returned.
-	 *
-	 * @return the date that the status changed to COMPLETED
-	 */
-	public Date getCompletedDate() {
-		return completedDate;
-	}
-
-	/**
-	 * Sets the date that the status changed to COMPLETED.
-	 *
-	 * @param completedDate
-	 *            the date that the status changed to COMPLETED
-	 */
-	public void setCompletedDate(Date completedDate) {
-		this.completedDate = completedDate;
-		state = State.COMPLETED;
-	}
-
-	@Override
-	public String toString() {
-		return "Invocation " + indexToString(index);
-	}
-
-	@Override
-	public int compareTo(Invocation o) {
-		String id = getId();
-		String otherId = o.getId();
-		if (id.length() == otherId.length())
-			return id.compareTo(otherId);
-		// Make "invoc5" be sorted before "invoc49"
-		return id.length() - otherId.length();
-	}
-
-	private String indexToString(int[] index) {
-		StringBuilder indexString = new StringBuilder();
-		String sep = "";
-		for (int idx : index) {
-			indexString.append(sep).append(idx + 1);
-			sep = ":";
-		}
-		return indexString.toString();
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ProcessorReport.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ProcessorReport.java b/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ProcessorReport.java
deleted file mode 100644
index 1912eb3..0000000
--- a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ProcessorReport.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.report;
-
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import org.apache.taverna.scufl2.api.core.Processor;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-
-/**
- * Report about the {@link State} of a {@link Processor} invocation.
- *
- * @author David Withers
- * @author Stian Soiland-Reyes
- */
-@JsonPropertyOrder({ "subject", "parent", "state", "createdDate",
-        "startedDate", "pausedDate", "pausedDates", "resumedDate",
-        "resumedDates", "cancelledDate", "failedDate", "completedDate",
-        "jobsQueued", "jobsStarted", "jobsCompleted",
-        "jobsCompletedWithErrors", "invocations", "activityReports"})
-public class ProcessorReport extends StatusReport<Processor, WorkflowReport> {
-	private Set<ActivityReport> activityReports = new LinkedHashSet<>();
-	private int jobsCompleted;
-    private int jobsCompletedWithErrors;
-    private int jobsQueued;
-    private int jobsStarted;
-    private SortedMap<String, Object> properties = new TreeMap<>();
-
-    /**
-	 * Constructs a new <code>ProcessorReport</code>.
-	 *
-	 * @param processor The processor to report on
-	 */
-	public ProcessorReport(Processor processor) {
-		super(processor);
-	}
-
-    public void addActivityReport(ActivityReport activityReport) {
-		activityReports.add(activityReport);
-	}
-
-    public Set<ActivityReport> getActivityReports() {
-		return activityReports;
-	}
-
-    /**
-	 * Returns the number of jobs that the processor has completed.
-	 *
-	 * @return the number of jobs that the processor has completed
-	 */
-	public int getJobsCompleted() {
-	    return jobsCompleted;
-	}
-
-	/**
-	 * Returns the number of jobs that completed with an error.
-	 *
-	 * @return the number of jobs that completed with an error
-	 */
-	public int getJobsCompletedWithErrors() {
-	    return jobsCompletedWithErrors;
-	}
-
-	/**
-	 * Returns the number of jobs queued by the processor.
-	 *
-	 * @return the number of jobs queued by the processor
-	 */
-	public int getJobsQueued() {
-        return jobsQueued;
-    }
-
-	/**
-	 * Returns the number of jobs that the processor has started processing.
-	 *
-	 * @return the number of jobs that the processor has started processing
-	 */
-	public int getJobsStarted() {
-	    return jobsStarted;
-	}
-
-	public Object getProperty(String key) {
-		return properties.get(key);
-	}
-
-	@JsonIgnore 
-	public Set<String> getPropertyKeys() {
-		return new HashSet<>(properties.keySet());
-	}
-
-	/**
-     * Set the number of completed jobs.
-     * 
-     * @param jobsCompleted the number of jobs that the processor has completed.
-     */
-    public void setJobsCompleted(int jobsCompleted) {
-        this.jobsCompleted = jobsCompleted;
-    }
-
-	/**
-     * Set the number of jobs that have completed, but with errors.
-     * 
-     * @param jobsCompletedWithErrors the number of jobs that completed with errors
-     */
-    public void setJobsCompletedWithErrors(int jobsCompletedWithErrors) {
-        this.jobsCompletedWithErrors = jobsCompletedWithErrors;
-    }
-
-	/**
-     * Set the number of queued jobs.
-     * 
-     * @param jobsQueued the number of jobs queued by the processor
-     */
-    public void setJobsQueued(int jobsQueued) {
-        this.jobsQueued = jobsQueued;
-    }
-
-	/**
-     * Set the number of started jobs.
-     * 
-     * @param jobsStarted the number of jobs that the processor has started processing
-     */
-    public void setJobsStarted(int jobsStarted) {
-        this.jobsStarted = jobsStarted;
-    }
-
-    /**
-     * Set an additional property
-     * 
-     * @param key
-     * @param value
-     */
-	public void setProperty(String key, Object value) {
-		synchronized (properties) {
-			// if (properties.containsKey(key)) {
-			properties.put(key, value);
-			// }
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ReportListener.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ReportListener.java b/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ReportListener.java
deleted file mode 100644
index 5458fb5..0000000
--- a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/ReportListener.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.report;
-
-import java.nio.file.Path;
-
-/**
- * @author David Withers
- */
-public interface ReportListener {
-	void outputAdded(Path path, String portName, int[] index);
-
-	void stateChanged(State oldState, State newState);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/main/java/uk/org/taverna/platform/report/State.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/State.java b/taverna-report-api/src/main/java/uk/org/taverna/platform/report/State.java
deleted file mode 100755
index 226d3eb..0000000
--- a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/State.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.report;
-
-/**
- * Valid states for status reports.
- *
- * @author David Withers
- */
-public enum State {
-	CREATED, RUNNING, COMPLETED, PAUSED, CANCELLED, FAILED
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/main/java/uk/org/taverna/platform/report/StatusReport.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/StatusReport.java b/taverna-report-api/src/main/java/uk/org/taverna/platform/report/StatusReport.java
deleted file mode 100644
index 254230f..0000000
--- a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/StatusReport.java
+++ /dev/null
@@ -1,373 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.report;
-
-import java.net.URI;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.NavigableSet;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import org.apache.taverna.scufl2.api.common.Ported;
-import org.apache.taverna.scufl2.api.common.URITools;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-
-/**
- * Report about the {@link State} of a workflow component.
- *
- * @author David Withers
- * @param <SUBJECT>
- *            the WorkflowBean that the report is about
- * @param <PARENT>
- *            the parent report type
- */
-
-@JsonPropertyOrder({ "subject", "parent", "state", "createdDate", "startedDate", "pausedDate",
-    "pausedDates", "resumedDate", "resumedDates", "cancelledDate", "failedDate", "completedDate"})
-public class StatusReport<SUBJECT extends Ported, PARENT extends StatusReport<?, ?>> {
-	private final SUBJECT subject;
-	private PARENT parentReport;
-	private State state;
-	private NavigableSet<Invocation> invocations = new TreeSet<>();
-	private Date createdDate, startedDate, pausedDate, resumedDate, cancelledDate, completedDate,
-			failedDate;
-	private final List<Date> pausedDates = new ArrayList<>(),
-			resumedDates = new ArrayList<>();
-	private List<ReportListener> reportListeners = new ArrayList<>();
-
-	/**
-	 * Constructs a new <code>StatusReport</code> for the subject and sets the created date to the
-	 * current date.
-	 *
-	 * @param subject
-	 *            the subject of the report
-	 */
-	public StatusReport(SUBJECT subject) {
-		this.subject = subject;
-		setCreatedDate(new Date());
-	}
-
-	/**
-	 * Returns the subject of this report.
-	 *
-	 * @return the subject of this report
-	 */
-	@JsonIgnore
-	public SUBJECT getSubject() {
-		return subject;
-	}
-
-	@JsonProperty("subject")
-	public URI getSubjectURI() {
-		return new URITools().uriForBean(subject);
-	}
-
-	/**
-	 * Returns the parent report.
-	 * <p>
-	 * Returns null if this report has no parent.
-	 *
-	 * @return the parent report
-	 */
-	@JsonIgnore
-	public PARENT getParentReport() {
-		return parentReport;
-	}
-
-	/**
-	 * Sets the parent report.
-	 * <p>
-	 * Can be null if this report has no parent.
-	 *
-	 * @param workflowReport
-	 *            the parent report
-	 */
-	public void setParentReport(PARENT parentReport) {
-		this.parentReport = parentReport;
-	}
-
-	/**
-	 * Returns the current {@link State}.
-	 * <p>
-	 * A state can be CREATED, RUNNING, COMPLETED, PAUSED, CANCELLED or FAILED.
-	 *
-	 * @return the current <code>State</code>
-	 */
-	public State getState() {
-		return state;
-	}
-
-	public void setState(State state) {
-		synchronized (reportListeners) {
-			if (this.state != state) {
-				State oldState = this.state;
-				this.state = state;
-				for (ReportListener reportListener : reportListeners)
-					reportListener.stateChanged(oldState, state);
-			}
-		}
-	}
-
-	/**
-	 * Returns the date that the status was set to CREATED.
-	 *
-	 * @return the the date that the status was set to CREATED
-	 */
-	public Date getCreatedDate() {
-		return createdDate;
-	}
-
-	/**
-	 * Sets the date that the status was set to CREATED.
-	 *
-	 * @param createdDate
-	 *            the date that the status was set to CREATED
-	 */
-	public void setCreatedDate(Date createdDate) {
-		this.createdDate = createdDate;
-		setState(State.CREATED);
-	}
-
-	/**
-	 * Returns the date that the status changed to RUNNING.
-	 * <p>
-	 * If the status has never been RUNNING <code>null</code> is returned.
-	 *
-	 * @return the date that the status changed to started
-	 */
-	public Date getStartedDate() {
-		return startedDate;
-	}
-
-	/**
-	 * Sets the date that the status changed to RUNNING.
-	 *
-	 * @param startedDate
-	 *            the date that the status changed to RUNNING
-	 */
-	public void setStartedDate(Date startedDate) {
-		if (this.startedDate == null)
-			this.startedDate = startedDate;
-		setState(State.RUNNING);
-	}
-
-	/**
-	 * Returns the date that the status last changed to PAUSED.
-	 * <p>
-	 * If the status has never been PAUSED <code>null</code> is returned.
-	 *
-	 * @return the date that the status last changed to PAUSED
-	 */
-	public Date getPausedDate() {
-		return pausedDate;
-	}
-
-	/**
-	 * Sets the date that the status last changed to PAUSED.
-	 *
-	 * @param pausedDate
-	 *            the date that the status last changed to PAUSED
-	 */
-	public void setPausedDate(Date pausedDate) {
-		this.pausedDate = pausedDate;
-		pausedDates.add(pausedDate);
-		setState(State.PAUSED);
-	}
-
-	/**
-	 * Returns the date that the status last changed form PAUSED to RUNNING.
-	 * <p>
-	 * If the status has never changed form PAUSED to RUNNING <code>null</code> is returned.
-	 *
-	 * @return the date that the status last changed form PAUSED to RUNNING
-	 */
-	public Date getResumedDate() {
-		return resumedDate;
-	}
-
-	/**
-	 * Sets the date that the status last changed form PAUSED to RUNNING.
-	 *
-	 * @param resumedDate
-	 *            the date that the status last changed form PAUSED to RUNNING
-	 */
-	public void setResumedDate(Date resumedDate) {
-		this.resumedDate = resumedDate;
-		resumedDates.add(resumedDate);
-		setState(State.RUNNING);
-	}
-
-	/**
-	 * Returns the date that the status changed to CANCELLED.
-	 * <p>
-	 * If the status has never been CANCELLED <code>null</code> is returned.
-	 *
-	 * @return the date that the status changed to canceled
-	 */
-	public Date getCancelledDate() {
-		return cancelledDate;
-	}
-
-	/**
-	 * Sets the date that the status changed to CANCELLED.
-	 *
-	 * @param cancelledDate
-	 *            the date that the status changed to CANCELLED
-	 */
-	public void setCancelledDate(Date cancelledDate) {
-		this.cancelledDate = cancelledDate;
-		setState(State.CANCELLED);
-	}
-
-	/**
-	 * Returns the date that the status changed to COMPLETED.
-	 * <p>
-	 * If the status never been COMPLETED <code>null</code> is returned.
-	 *
-	 * @return the date that the status changed to COMPLETED
-	 */
-	public Date getCompletedDate() {
-		return completedDate;
-	}
-
-	/**
-	 * Sets the date that the status changed to COMPLETED.
-	 *
-	 * @param completedDate
-	 *            the date that the status changed to COMPLETED
-	 */
-	public void setCompletedDate(Date completedDate) {
-		this.completedDate = completedDate;
-		setState(State.COMPLETED);
-	}
-
-	/**
-	 * Returns the date that the status changed to FAILED. If the status has never been FAILED
-	 * <code>null</code> is returned.
-	 *
-	 * @return the date that the status changed to failed
-	 */
-	public Date getFailedDate() {
-		return failedDate;
-	}
-
-	/**
-	 * Sets the date that the status changed to FAILED.
-	 *
-	 * @param failedDate
-	 *            the date that the status changed to FAILED
-	 */
-	public void setFailedDate(Date failedDate) {
-		this.failedDate = failedDate;
-		setState(State.FAILED);
-	}
-
-	/**
-	 * Returns the dates that the status changed to PAUSED.
-	 * <p>
-	 * If the status has never been PAUSED an empty list is returned.
-	 *
-	 * @return the dates that the status was paused
-	 */
-	public List<Date> getPausedDates() {
-		return pausedDates;
-	}
-
-	/**
-	 * Returns the dates that the status changed from PAUSED to RUNNING.
-	 * <p>
-	 * If the status has never changed from PAUSED to RUNNING an empty list is returned.
-	 *
-	 * @return the dates that the status was resumed
-	 */
-	public List<Date> getResumedDates() {
-		return resumedDates;
-	}
-
-	/**
-	 * Returns the invocations.
-	 *
-	 * @return the invocations
-	 */
-	public NavigableSet<Invocation> getInvocations() {
-		synchronized (invocations) {
-			return new TreeSet<>(invocations);
-		}
-	}
-
-	public void addInvocation(Invocation invocation) {
-		synchronized (invocations) {
-			invocations.add(invocation);
-		}
-	}
-
-	/**
-	 * Informs the report that an output value has been added.
-	 * <p>
-	 * Any <code>ReportListener</code>s registered with this report will be notified that an output
-	 * value has been added.
-	 *
-	 * @param path
-	 *            the path that the value was added to
-	 * @param portName
-	 *            the port that the value belongs to
-	 * @param index
-	 *            the position of the value
-	 */
-	public void outputAdded(Path path, String portName, int[] index) {
-		synchronized (reportListeners) {
-			for (ReportListener reportListener : reportListeners)
-				reportListener.outputAdded(path, portName, index);
-		}
-	}
-
-	public void addReportListener(ReportListener reportListener) {
-		synchronized (reportListeners) {
-			reportListeners.add(reportListener);
-		}
-	}
-
-	public void removeReportListener(ReportListener reportListener) {
-		synchronized (reportListeners) {
-			reportListeners.remove(reportListener);
-		}
-	}
-
-	/**
-	 * Get an invocation with a given name.
-	 * @param invocationName
-	 * @return
-	 */
-    public Invocation getInvocation(String invocationName) {
-        NavigableSet<Invocation> invocs = getInvocations();
-        // A Comparable Invocation with the desired name
-        SortedSet<Invocation> tailSet = invocs.tailSet(new Invocation(invocationName));
-        if (!tailSet.isEmpty())
-        	return tailSet.first();
-        return null;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/main/java/uk/org/taverna/platform/report/WorkflowReport.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/WorkflowReport.java b/taverna-report-api/src/main/java/uk/org/taverna/platform/report/WorkflowReport.java
deleted file mode 100644
index 1b0ca1c..0000000
--- a/taverna-report-api/src/main/java/uk/org/taverna/platform/report/WorkflowReport.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.report;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.LinkedHashSet;
-import java.util.Set;
-import java.util.logging.Logger;
-
-import org.apache.taverna.robundle.Bundle;
-import org.apache.taverna.scufl2.api.core.Workflow;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-
-/**
- * Report about the {@link State} of a {@link Workflow} run.
- *
- * @author David Withers
- */
-public class WorkflowReport extends StatusReport<Workflow, ActivityReport> {
-	@SuppressWarnings("unused")
-	private static final Logger logger = Logger.getLogger(WorkflowReport.class.getName());
-	private static final String dateFormatString = "yyyy-MM-dd HH:mm:ss";
-
-	private Set<ProcessorReport> processorReports = new LinkedHashSet<>();
-	private Bundle dataBundle;
-
-	public WorkflowReport(Workflow workflow) {
-		super(workflow);
-	}
-
-	public Set<ProcessorReport> getProcessorReports() {
-		return processorReports;
-	}
-
-	public void addProcessorReport(ProcessorReport processorReport) {
-		processorReports.add(processorReport);
-	}
-
-	@JsonIgnore
-	public Bundle getDataBundle() {
-		return dataBundle;
-	}
-
-	public void setDataBundle(Bundle dataBundle) {
-		this.dataBundle = dataBundle;
-	}
-
-	@Override
-	public String toString() {
-		DateFormat dateFormat = new SimpleDateFormat(dateFormatString);
-		StringBuilder sb = new StringBuilder();
-		int max = getLongestName(this, 0);
-		spaces(sb, max + 1);
-		sb.append("Status    ");
-		sb.append("Queued    ");
-		sb.append("Started   ");
-		sb.append("Complete  ");
-		sb.append("Errors    ");
-		sb.append("Started             ");
-		sb.append("Finished\n");
-		sb.append(getSubject().getName());
-		spaces(sb, max - getSubject().getName().length() + 1);
-		sb.append(getState());
-		spaces(sb, 10 - getState().name().length());
-		sb.append("-");
-		spaces(sb, 9);
-		sb.append("-");
-		spaces(sb, 9);
-		sb.append("-");
-		spaces(sb, 9);
-		sb.append("-");
-		spaces(sb, 9);
-		addDates(sb, getStartedDate(), getCompletedDate(), dateFormat);
-		for (ProcessorReport processorReport : getProcessorReports())
-			addProcessor(sb, max, 0, processorReport, dateFormat);
-		return sb.toString();
-	}
-
-	private void addProcessor(StringBuilder sb, int max, int level, ProcessorReport processorReport, DateFormat dateFormat) {
-		String processorName = processorReport.getSubject().getName();
-		spaces(sb, level);
-		sb.append(processorName);
-		spaces(sb, max - processorName.length() - level + 1);
-
-		State processorState = processorReport.getState();
-		sb.append(processorState);
-		spaces(sb, 10 - processorState.name().length());
-
-		String jobsQueued = String.valueOf(processorReport.getJobsQueued());
-		sb.append(jobsQueued);
-		spaces(sb, 10 - jobsQueued.length());
-
-		String jobsStarted = String.valueOf(processorReport.getJobsStarted());
-		sb.append(jobsStarted);
-		spaces(sb, 10 - jobsStarted.length());
-
-		String jobsCompleted = String.valueOf(processorReport.getJobsCompleted());
-		sb.append(jobsCompleted);
-		spaces(sb, 10 - jobsCompleted.length());
-
-		String jobsCompletedWithErrors = String.valueOf(processorReport
-				.getJobsCompletedWithErrors());
-		sb.append(jobsCompletedWithErrors);
-		spaces(sb, 10 - jobsCompletedWithErrors.length());
-
-		addDates(sb, processorReport.getStartedDate(), processorReport.getCompletedDate(), dateFormat);
-
-		for (ActivityReport activityReport : processorReport.getActivityReports()) {
-			WorkflowReport nestedWorkflowReport = activityReport.getNestedWorkflowReport();
-			if (nestedWorkflowReport != null)
-				for (ProcessorReport nestedProcessorReport : nestedWorkflowReport.getProcessorReports())
-					addProcessor(sb, max, level + 1, nestedProcessorReport, dateFormat);
-		}
-	}
-
-	private void addDates(StringBuilder sb, Date started, Date stopped, DateFormat dateFormat) {
-		if (started != null) {
-			sb.append(dateFormat.format(started));
-			sb.append(' ');
-		} else {
-			sb.append('-');
-			spaces(sb, dateFormatString.length());
-		}
-		if (stopped != null)
-			sb.append(dateFormat.format(stopped) + "\n");
-		else
-			sb.append("-\n");
-	}
-
-	private int getLongestName(WorkflowReport workflowReport, int level) {
-		int result = 0;
-		result = Math.max(result, getSubject().getName().length() + level);
-		for (ProcessorReport processorReport : workflowReport.getProcessorReports()) {
-			result = Math.max(result, processorReport.getSubject().getName().length());
-			for (ActivityReport activityReport : processorReport.getActivityReports()) {
-				WorkflowReport nestedWorkflowReport = activityReport.getNestedWorkflowReport();
-				if (nestedWorkflowReport != null)
-					result = Math.max(result, getLongestName(nestedWorkflowReport, level + 1));
-			}
-		}
-		return result;
-	}
-
-	private static void spaces(StringBuilder sb, int length) {
-		for (int i = 0; i < length; i++)
-			sb.append(' ');
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/test/java/org/apache/taverna/platform/report/StatusReportTest.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/test/java/org/apache/taverna/platform/report/StatusReportTest.java b/taverna-report-api/src/test/java/org/apache/taverna/platform/report/StatusReportTest.java
new file mode 100644
index 0000000..115104e
--- /dev/null
+++ b/taverna-report-api/src/test/java/org/apache/taverna/platform/report/StatusReportTest.java
@@ -0,0 +1,244 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.report;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Date;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.taverna.scufl2.api.core.Workflow;
+
+/**
+ * Unit tests for StatusReport.
+ *
+ * @author David Withers
+ */
+public class StatusReportTest {
+
+	private StatusReport<Workflow, ?> statusReport;
+	private Workflow subject;
+
+	/**
+	 * @throws java.lang.Exception
+	 */
+	@Before
+	public void setUp() throws Exception {
+		subject = new Workflow();
+		statusReport = new StatusReport<Workflow,StatusReport<?,?>>(subject);
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#StatusReport()}.
+	 */
+	@Test
+	public void testStatusReport() {
+		Date preCreationTime = new Date();
+		statusReport = new StatusReport<Workflow,StatusReport<?,?>>(null);
+		assertFalse(statusReport.getCreatedDate().before(preCreationTime));
+		assertFalse(statusReport.getCreatedDate().after(new Date()));
+		assertEquals(State.CREATED, statusReport.getState());
+		assertTrue(statusReport.getPausedDates().isEmpty());
+		assertTrue(statusReport.getResumedDates().isEmpty());
+		assertNull(statusReport.getCancelledDate());
+		assertNull(statusReport.getCompletedDate());
+		assertNull(statusReport.getFailedDate());
+		assertNull(statusReport.getPausedDate());
+		assertNull(statusReport.getResumedDate());
+		assertNull(statusReport.getStartedDate());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getSubject()}.
+	 */
+	@Test
+	public void testGetSubject() {
+		assertNotNull(statusReport.getSubject());
+		assertEquals(subject, statusReport.getSubject());
+		assertEquals(subject, statusReport.getSubject());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getState()}.
+	 */
+	@Test
+	public void testGetState() {
+		assertEquals(State.CREATED, statusReport.getState());
+		assertEquals(State.CREATED, statusReport.getState());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getCreatedDate()}.
+	 */
+	@Test
+	public void testGetCreatedDate() {
+		assertNotNull(statusReport.getCreatedDate());
+		assertFalse(statusReport.getCreatedDate().after(new Date()));
+		assertEquals(statusReport.getCreatedDate(), statusReport.getCreatedDate());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setCreatedDate(java.util.Date)}.
+	 */
+	@Test
+	public void testSetCreatedDate() {
+		Date now = new Date();
+		statusReport.setCreatedDate(now);
+		assertEquals(now, statusReport.getCreatedDate());
+		assertEquals(State.CREATED, statusReport.getState());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getStartedDate()}.
+	 */
+	@Test
+	public void testGetStartedDate() {
+		assertNull(statusReport.getStartedDate());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setStartedDate(java.util.Date)}.
+	 */
+	@Test
+	public void testSetStartedDate() {
+		Date now = new Date();
+		statusReport.setStartedDate(now);
+		assertEquals(now, statusReport.getStartedDate());
+		assertEquals(State.RUNNING, statusReport.getState());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getPausedDate()}.
+	 */
+	@Test
+	public void testGetPausedDate() {
+		assertNull(statusReport.getPausedDate());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setPausedDate(java.util.Date)}.
+	 */
+	@Test
+	public void testSetPausedDate() {
+		Date now = new Date();
+		statusReport.setPausedDate(now);
+		assertEquals(now, statusReport.getPausedDate());
+		assertEquals(State.PAUSED, statusReport.getState());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getResumedDate()}.
+	 */
+	@Test
+	public void testGetResumedDate() {
+		assertNull(statusReport.getResumedDate());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setResumedDate(java.util.Date)}.
+	 */
+	@Test
+	public void testSetResumedDate() {
+		Date now = new Date();
+		statusReport.setResumedDate(now);
+		assertEquals(now, statusReport.getResumedDate());
+		assertEquals(State.RUNNING, statusReport.getState());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getCancelledDate()}.
+	 */
+	@Test
+	public void testGetCancelledDate() {
+		assertNull(statusReport.getCancelledDate());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setCancelledDate(java.util.Date)}.
+	 */
+	@Test
+	public void testSetCancelledDate() {
+		Date now = new Date();
+		statusReport.setCancelledDate(now);
+		assertEquals(now, statusReport.getCancelledDate());
+		assertEquals(State.CANCELLED, statusReport.getState());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getCompletedDate()}.
+	 */
+	@Test
+	public void testGetCompletedDate() {
+		assertNull(statusReport.getCompletedDate());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setCompletedDate(java.util.Date)}.
+	 */
+	@Test
+	public void testSetCompletedDate() {
+		Date now = new Date();
+		statusReport.setCompletedDate(now);
+		assertEquals(now, statusReport.getCompletedDate());
+		assertEquals(State.COMPLETED, statusReport.getState());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getFailedDate()}.
+	 */
+	@Test
+	public void testGetFailedDate() {
+		assertNull(statusReport.getFailedDate());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setFailedDate(java.util.Date)}.
+	 */
+	@Test
+	public void testSetFailedDate() {
+		Date now = new Date();
+		statusReport.setFailedDate(now);
+		assertEquals(now, statusReport.getFailedDate());
+		assertEquals(State.FAILED, statusReport.getState());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getPausedDates()}.
+	 */
+	@Test
+	public void testGetPausedDates() {
+		assertTrue(statusReport.getPausedDates().isEmpty());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getResumedDates()}.
+	 */
+	@Test
+	public void testGetResumedDates() {
+		assertTrue(statusReport.getResumedDates().isEmpty());
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/test/java/uk/org/taverna/platform/report/StatusReportTest.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/test/java/uk/org/taverna/platform/report/StatusReportTest.java b/taverna-report-api/src/test/java/uk/org/taverna/platform/report/StatusReportTest.java
deleted file mode 100644
index 3c39cbb..0000000
--- a/taverna-report-api/src/test/java/uk/org/taverna/platform/report/StatusReportTest.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.report;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Date;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import org.apache.taverna.scufl2.api.core.Workflow;
-
-/**
- * Unit tests for StatusReport.
- *
- * @author David Withers
- */
-public class StatusReportTest {
-
-	private StatusReport<Workflow, ?> statusReport;
-	private Workflow subject;
-
-	/**
-	 * @throws java.lang.Exception
-	 */
-	@Before
-	public void setUp() throws Exception {
-		subject = new Workflow();
-		statusReport = new StatusReport<Workflow,StatusReport<?,?>>(subject);
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#StatusReport()}.
-	 */
-	@Test
-	public void testStatusReport() {
-		Date preCreationTime = new Date();
-		statusReport = new StatusReport<Workflow,StatusReport<?,?>>(null);
-		assertFalse(statusReport.getCreatedDate().before(preCreationTime));
-		assertFalse(statusReport.getCreatedDate().after(new Date()));
-		assertEquals(State.CREATED, statusReport.getState());
-		assertTrue(statusReport.getPausedDates().isEmpty());
-		assertTrue(statusReport.getResumedDates().isEmpty());
-		assertNull(statusReport.getCancelledDate());
-		assertNull(statusReport.getCompletedDate());
-		assertNull(statusReport.getFailedDate());
-		assertNull(statusReport.getPausedDate());
-		assertNull(statusReport.getResumedDate());
-		assertNull(statusReport.getStartedDate());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getSubject()}.
-	 */
-	@Test
-	public void testGetSubject() {
-		assertNotNull(statusReport.getSubject());
-		assertEquals(subject, statusReport.getSubject());
-		assertEquals(subject, statusReport.getSubject());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getState()}.
-	 */
-	@Test
-	public void testGetState() {
-		assertEquals(State.CREATED, statusReport.getState());
-		assertEquals(State.CREATED, statusReport.getState());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getCreatedDate()}.
-	 */
-	@Test
-	public void testGetCreatedDate() {
-		assertNotNull(statusReport.getCreatedDate());
-		assertFalse(statusReport.getCreatedDate().after(new Date()));
-		assertEquals(statusReport.getCreatedDate(), statusReport.getCreatedDate());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setCreatedDate(java.util.Date)}.
-	 */
-	@Test
-	public void testSetCreatedDate() {
-		Date now = new Date();
-		statusReport.setCreatedDate(now);
-		assertEquals(now, statusReport.getCreatedDate());
-		assertEquals(State.CREATED, statusReport.getState());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getStartedDate()}.
-	 */
-	@Test
-	public void testGetStartedDate() {
-		assertNull(statusReport.getStartedDate());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setStartedDate(java.util.Date)}.
-	 */
-	@Test
-	public void testSetStartedDate() {
-		Date now = new Date();
-		statusReport.setStartedDate(now);
-		assertEquals(now, statusReport.getStartedDate());
-		assertEquals(State.RUNNING, statusReport.getState());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getPausedDate()}.
-	 */
-	@Test
-	public void testGetPausedDate() {
-		assertNull(statusReport.getPausedDate());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setPausedDate(java.util.Date)}.
-	 */
-	@Test
-	public void testSetPausedDate() {
-		Date now = new Date();
-		statusReport.setPausedDate(now);
-		assertEquals(now, statusReport.getPausedDate());
-		assertEquals(State.PAUSED, statusReport.getState());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getResumedDate()}.
-	 */
-	@Test
-	public void testGetResumedDate() {
-		assertNull(statusReport.getResumedDate());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setResumedDate(java.util.Date)}.
-	 */
-	@Test
-	public void testSetResumedDate() {
-		Date now = new Date();
-		statusReport.setResumedDate(now);
-		assertEquals(now, statusReport.getResumedDate());
-		assertEquals(State.RUNNING, statusReport.getState());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getCancelledDate()}.
-	 */
-	@Test
-	public void testGetCancelledDate() {
-		assertNull(statusReport.getCancelledDate());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setCancelledDate(java.util.Date)}.
-	 */
-	@Test
-	public void testSetCancelledDate() {
-		Date now = new Date();
-		statusReport.setCancelledDate(now);
-		assertEquals(now, statusReport.getCancelledDate());
-		assertEquals(State.CANCELLED, statusReport.getState());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getCompletedDate()}.
-	 */
-	@Test
-	public void testGetCompletedDate() {
-		assertNull(statusReport.getCompletedDate());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setCompletedDate(java.util.Date)}.
-	 */
-	@Test
-	public void testSetCompletedDate() {
-		Date now = new Date();
-		statusReport.setCompletedDate(now);
-		assertEquals(now, statusReport.getCompletedDate());
-		assertEquals(State.COMPLETED, statusReport.getState());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getFailedDate()}.
-	 */
-	@Test
-	public void testGetFailedDate() {
-		assertNull(statusReport.getFailedDate());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#setFailedDate(java.util.Date)}.
-	 */
-	@Test
-	public void testSetFailedDate() {
-		Date now = new Date();
-		statusReport.setFailedDate(now);
-		assertEquals(now, statusReport.getFailedDate());
-		assertEquals(State.FAILED, statusReport.getState());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getPausedDates()}.
-	 */
-	@Test
-	public void testGetPausedDates() {
-		assertTrue(statusReport.getPausedDates().isEmpty());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.report.StatusReport#getResumedDates()}.
-	 */
-	@Test
-	public void testGetResumedDates() {
-		assertTrue(statusReport.getResumedDates().isEmpty());
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/InvalidRunIdException.java
----------------------------------------------------------------------
diff --git a/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/InvalidRunIdException.java b/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/InvalidRunIdException.java
new file mode 100644
index 0000000..1637616
--- /dev/null
+++ b/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/InvalidRunIdException.java
@@ -0,0 +1,45 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.run.api;
+
+/**
+ * Thrown when a runID is not valid for the RunService.
+ * 
+ * @author David Withers
+ */
+public class InvalidRunIdException extends Exception {
+	private static final long serialVersionUID = -8524012164316151704L;
+
+	public InvalidRunIdException() {
+		super();
+	}
+
+	public InvalidRunIdException(String message) {
+		super(message);
+	}
+
+	public InvalidRunIdException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+	public InvalidRunIdException(Throwable cause) {
+		super(cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunProfile.java
----------------------------------------------------------------------
diff --git a/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunProfile.java b/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunProfile.java
new file mode 100644
index 0000000..02d42ab
--- /dev/null
+++ b/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunProfile.java
@@ -0,0 +1,215 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.run.api;
+
+import org.apache.taverna.robundle.Bundle;
+
+import org.apache.taverna.platform.execution.api.ExecutionEnvironment;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+
+/**
+ * A <code>RunProfile</code> specifies the parameters required to run a
+ * {@link org.apache.taverna.scufl2.api.core.Workflow}.
+ * 
+ * @author David Withers
+ */
+public class RunProfile {
+	private ExecutionEnvironment executionEnvironment;
+	private WorkflowBundle workflowBundle;
+	private Bundle dataBundle;
+	private String workflowName;
+	private String profileName;
+
+	/**
+	 * Constructs a <code>RunProfile</code> that specifies the parameters
+	 * required to run a {@link org.apache.taverna.scufl2.api.core.Workflow}. The
+	 * main <code>Workflow</code> and <code>Profile</code> from the
+	 * <code>WorkflowBundle</code> are used.
+	 * 
+	 * @param executionEnvironment
+	 *            the {@link ExecutionEnvironment} used to execute the
+	 *            <code>Workflow</code>
+	 * @param workflowBundle
+	 *            the <code>WorkflowBundle</code> containing the
+	 *            <code>Workflow</code> to run
+	 * @param dataBundle
+	 *            the <code>Bundle</code> containing the data values for the
+	 *            <code>Workflow</code>
+	 */
+	public RunProfile(ExecutionEnvironment executionEnvironment,
+			WorkflowBundle workflowBundle, Bundle dataBundle) {
+		this(executionEnvironment, workflowBundle, null, null, dataBundle);
+	}
+
+	/**
+	 * Constructs a <code>RunProfile</code> that specifies the parameters
+	 * required to run a {@link org.apache.taverna.scufl2.api.core.Workflow}.
+	 * 
+	 * @param executionEnvironment
+	 *            the {@link ExecutionEnvironment} used to execute the
+	 *            <code>Workflow</code>
+	 * @param workflowBundle
+	 *            the <code>WorkflowBundle</code> containing the
+	 *            <code>Workflow</code> to run
+	 * @param workflow
+	 *            the <code>Workflow</code> to run. If <code>null</code> uses
+	 *            the main <code>Workflow</code> from the
+	 *            <code>WorkflowBundle</code>
+	 * @param profile
+	 *            the {@link org.apache.taverna.scufl2.api.profiles.Profile} to use
+	 *            when running the <code>Workflow</code>. If null uses the main
+	 *            <code>Profile</code> from the <code>WorkflowBundle</code>
+	 * @param dataBundle
+	 *            the <code>Bundle</code> containing the data values for the
+	 *            <code>Workflow</code>
+	 */
+	public RunProfile(ExecutionEnvironment executionEnvironment,
+			WorkflowBundle workflowBundle, String workflowName,
+			String profileName, Bundle dataBundle) {
+		this.executionEnvironment = executionEnvironment;
+		this.workflowBundle = workflowBundle;
+		this.workflowName = workflowName;
+		this.profileName = profileName;
+		this.dataBundle = dataBundle;
+	}
+
+	/**
+	 * Returns the <code>WorkflowBundle</code>.
+	 * 
+	 * @return the <code>WorkflowBundle</code>
+	 */
+	public WorkflowBundle getWorkflowBundle() {
+		return workflowBundle;
+	}
+
+	/**
+	 * Sets the <code>WorkflowBundle</code> containing the <code>Workflow</code>
+	 * to run.
+	 * 
+	 * @param workflowBundle
+	 *            the <code>WorkflowBundle</code> containing the
+	 *            <code>Workflow</code> to run
+	 */
+	public void setWorkflowBundle(WorkflowBundle workflowBundle) {
+		this.workflowBundle = workflowBundle;
+	}
+
+	/**
+	 * Returns the name of the <code>Workflow</code> to run. If no
+	 * <code>Workflow</code> name is set the main <code>Workflow</code> from the
+	 * <code>WorkflowBundle</code> will be run.
+	 * 
+	 * @return the <code>Workflow</code> to run
+	 */
+	public String getWorkflowName() {
+		if (workflowName == null && workflowBundle.getMainWorkflow() != null)
+			return workflowBundle.getMainWorkflow().getName();
+		return workflowName;
+	}
+
+	/**
+	 * Sets the name of the <code>Workflow</code> to run. If no
+	 * <code>Workflow</code> name is set the main <code>Workflow</code> from the
+	 * <code>WorkflowBundle</code> will be run.
+	 * 
+	 * @param workflowName
+	 *            the name of the <code>Workflow</code> to run
+	 */
+	public void setWorkflowName(String workflowName) {
+		this.workflowName = workflowName;
+	}
+
+	/**
+	 * Returns the name of the <code>Profile</code> to use when running the
+	 * <code>Workflow</code>. If no <code>Profile</code> name is set the main
+	 * <code>Profile</code> from the <code>WorkflowBundle</code> will be used.
+	 * 
+	 * @return the <code>Profile</code> to use when running the
+	 *         <code>Workflow</code>
+	 */
+	public String getProfileName() {
+		if (profileName == null && workflowBundle.getMainProfile() != null) {
+			return workflowBundle.getMainProfile().getName();
+		}
+		return profileName;
+	}
+
+	/**
+	 * Sets the name of the <code>Profile</code> to use when running the
+	 * <code>Workflow</code>.
+	 * <p>
+	 * If no <code>Profile</code> name is set the main <code>Profile</code> from
+	 * the <code>WorkflowBundle</code> will be used.
+	 * 
+	 * @param profileName
+	 *            the name of the <code>Profile</code> to use when running the
+	 *            <code>Workflow</code>
+	 */
+	public void setProfileName(String profileName) {
+		this.profileName = profileName;
+	}
+
+	/**
+	 * Returns the <code>Bundle</code> containing the data values for the
+	 * <code>Workflow</code>.
+	 * 
+	 * @return the <code>Bundle</code> containing the data values for the
+	 *         <code>Workflow</code>
+	 */
+	public Bundle getDataBundle() {
+		return dataBundle;
+	}
+
+	/**
+	 * Sets the <code>Bundle</code> containing the data values for the
+	 * <code>Workflow</code>.
+	 * 
+	 * @param dataBundle
+	 *            the <code>Bundle</code> containing the data values for the
+	 *            <code>Workflow</code>
+	 */
+	public void setDataBundle(Bundle dataBundle) {
+		this.dataBundle = dataBundle;
+	}
+
+	/**
+	 * Returns the <code>ExecutionEnvironment</code> used to execute the
+	 * <code>Workflow</code>.
+	 * 
+	 * @return the <code>ExecutionEnvironment</code> used to execute the
+	 *         <code>Workflow</code>
+	 */
+	public ExecutionEnvironment getExecutionEnvironment() {
+		return executionEnvironment;
+	}
+
+	/**
+	 * Sets the <code>ExecutionEnvironment</code> used to execute the
+	 * <code>Workflow</code>.
+	 * 
+	 * @param executionEnvironment
+	 *            the <code>ExecutionEnvironment</code> used to execute the
+	 *            <code>Workflow</code>
+	 */
+	public void setExecutionEnvironment(
+			ExecutionEnvironment executionEnvironment) {
+		this.executionEnvironment = executionEnvironment;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunProfileException.java
----------------------------------------------------------------------
diff --git a/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunProfileException.java b/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunProfileException.java
new file mode 100644
index 0000000..d932c3c
--- /dev/null
+++ b/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunProfileException.java
@@ -0,0 +1,46 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.run.api;
+
+/**
+ * Thrown when a <code>RunProfile</code> doesn't contain the correct components
+ * to run a workflow.
+ * 
+ * @author David Withers
+ */
+public class RunProfileException extends Exception {
+	private static final long serialVersionUID = 4717267498382223527L;
+
+	public RunProfileException() {
+		super();
+	}
+
+	public RunProfileException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+	public RunProfileException(String message) {
+		super(message);
+	}
+
+	public RunProfileException(Throwable cause) {
+		super(cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunService.java
----------------------------------------------------------------------
diff --git a/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunService.java b/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunService.java
new file mode 100644
index 0000000..ab52ab4
--- /dev/null
+++ b/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunService.java
@@ -0,0 +1,254 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.run.api;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.taverna.robundle.Bundle;
+
+import org.apache.taverna.platform.execution.api.ExecutionEnvironment;
+import org.apache.taverna.platform.execution.api.InvalidExecutionIdException;
+import org.apache.taverna.platform.execution.api.InvalidWorkflowException;
+import org.apache.taverna.platform.report.State;
+import org.apache.taverna.platform.report.WorkflowReport;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+/**
+ * Service for managing runs of Taverna workflows.
+ * 
+ * @author David Withers
+ */
+public interface RunService {
+	String EVENT_TOPIC_ROOT = "uk/org/taverna/platform/run/RunService/";
+	String RUN_CREATED = EVENT_TOPIC_ROOT + "RUN_CREATED";
+	String RUN_DELETED = EVENT_TOPIC_ROOT + "RUN_DELETED";
+	String RUN_STARTED = EVENT_TOPIC_ROOT + "RUN_STARTED";
+	String RUN_STOPPED = EVENT_TOPIC_ROOT + "RUN_STOPPED";
+	String RUN_PAUSED = EVENT_TOPIC_ROOT + "RUN_PAUSED";
+	String RUN_RESUMED = EVENT_TOPIC_ROOT + "RUN_RESUMED";
+	String RUN_OPENED = EVENT_TOPIC_ROOT + "RUN_OPENED";
+	String RUN_CLOSED = EVENT_TOPIC_ROOT + "RUN_CLOSED";
+
+	/**
+	 * Returns the available <code>ExecutionEnvironment</code>s.
+	 * 
+	 * @return the available <code>ExecutionEnvironment</code>s
+	 */
+	Set<ExecutionEnvironment> getExecutionEnvironments();
+
+	/**
+	 * Returns the <code>ExecutionEnvironment</code>s that can execute the
+	 * specified <code>WorkflowBundle</code> using its default
+	 * <code>Profile</code>.
+	 * 
+	 * @param workflowBundle
+	 *            the <code>WorkflowBundle</code> to find
+	 *            <code>ExecutionEnvironment</code>s for
+	 * @return the <code>ExecutionEnvironment</code>s that can execute the
+	 *         specified <code>WorkflowBundle</code>
+	 */
+	Set<ExecutionEnvironment> getExecutionEnvironments(
+			WorkflowBundle workflowBundle);
+
+	/**
+	 * Returns the <code>ExecutionEnvironment</code>s that can execute the
+	 * specified <code>Profile</code>.
+	 * 
+	 * @param profile
+	 *            the <code>Profile</code> to find
+	 *            <code>ExecutionEnvironment</code>s for
+	 * @return the <code>ExecutionEnvironment</code>s that can execute the
+	 *         specified <code>Profile</code>
+	 */
+	Set<ExecutionEnvironment> getExecutionEnvironments(Profile profile);
+
+	/**
+	 * Creates a new run and returns the ID for the run.
+	 * 
+	 * To start the run use the {@link #start(String)} method.
+	 * 
+	 * @param runProfile
+	 *            the workflow to run
+	 * @return the run ID
+	 * @throws InvalidWorkflowException
+	 * @throws RunProfileException
+	 */
+	String createRun(RunProfile runProfile) throws InvalidWorkflowException,
+			RunProfileException;
+
+	/**
+	 * Returns the list of runs that this service is managing.
+	 * <p>
+	 * If there are no runs this method returns an empty list.
+	 * 
+	 * @return the list of runs that this service is managing
+	 */
+	List<String> getRuns();
+
+	/**
+	 * Opens a run and returns the ID for the run.
+	 * 
+	 * @param runFile
+	 *            the workflow run to open
+	 * @return the run ID
+	 * @throws InvalidWorkflowException
+	 * @throws RunProfileException
+	 */
+	String open(File runFile) throws IOException;
+
+	/**
+	 * Closes a run.
+	 * 
+	 * @param runID
+	 *            the ID of the run
+	 * @throws InvalidRunIdException
+	 *             if the run ID is not valid
+	 * @throws InvalidExecutionIdException
+	 */
+	void close(String runID) throws InvalidRunIdException,
+			InvalidExecutionIdException;
+
+	/**
+	 * Saves a run.
+	 * 
+	 * @param runID
+	 *            the ID of the run
+	 * @throws InvalidRunIdException
+	 *             if the run ID is not valid
+	 * @throws InvalidExecutionIdException
+	 */
+	void save(String runID, File runFile) throws InvalidRunIdException,
+			IOException;
+
+	/**
+	 * Deletes a run.
+	 * 
+	 * @param runID
+	 *            the ID of the run
+	 * @throws InvalidRunIdException
+	 *             if the run ID is not valid
+	 * @throws InvalidExecutionIdException
+	 */
+	void delete(String runID) throws InvalidRunIdException,
+			InvalidExecutionIdException;
+
+	/**
+	 * Starts a run.
+	 * 
+	 * @param runID
+	 *            the ID of the run
+	 * @throws InvalidRunIdException
+	 *             if the run ID is not valid
+	 * @throws RunStateException
+	 *             if the run state is not CREATED
+	 * @throws InvalidExecutionIdException
+	 */
+	void start(String runID) throws InvalidRunIdException, RunStateException,
+			InvalidExecutionIdException;
+
+	/**
+	 * Pauses a running run.
+	 * 
+	 * @param runID
+	 *            the ID of the run
+	 * @throws InvalidRunIdException
+	 *             if the run ID is not valid
+	 * @throws RunStateException
+	 *             if the run state is not RUNNING
+	 * @throws InvalidExecutionIdException
+	 */
+	void pause(String runID) throws InvalidRunIdException, RunStateException,
+			InvalidExecutionIdException;
+
+	/**
+	 * Resumes a paused run.
+	 * 
+	 * @param runID
+	 *            the ID of the run
+	 * @throws InvalidRunIdException
+	 *             if the run ID is not valid
+	 * @throws RunStateException
+	 *             if the run state is not PAUSED
+	 * @throws InvalidExecutionIdException
+	 */
+	void resume(String runID) throws InvalidRunIdException, RunStateException,
+			InvalidExecutionIdException;
+
+	/**
+	 * Cancels a running or paused run.
+	 * 
+	 * @param runID
+	 *            the ID of the run
+	 * @throws InvalidRunIdException
+	 *             if the run ID is not valid
+	 * @throws RunStateException
+	 *             if the run state is not RUNNING or PAUSED
+	 * @throws InvalidExecutionIdException
+	 */
+	void cancel(String runID) throws InvalidRunIdException, RunStateException,
+			InvalidExecutionIdException;
+
+	/**
+	 * Returns the current state of the run.
+	 * 
+	 * A run's state can be CREATED, RUNNING, COMPLETED, PAUSED, CANCELLED or
+	 * FAILED.
+	 * 
+	 * @param runID
+	 *            the ID of the run
+	 * @return the current state of the run
+	 * @throws InvalidRunIdException
+	 *             if the run ID is not valid
+	 */
+	State getState(String runID) throws InvalidRunIdException;
+
+	/**
+	 * Returns the <code>Bundle</code> containing the data values of the run.
+	 * 
+	 * @param runID
+	 *            the ID of the run
+	 * @return the <code>Databundle</code> containing the data values of the run
+	 * @throws InvalidRunIdException
+	 *             if the run ID is not valid
+	 */
+	Bundle getDataBundle(String runID) throws InvalidRunIdException;
+
+	/**
+	 * Returns the status report for the run.
+	 * 
+	 * @param runID
+	 *            the ID of the run
+	 * @return the status report for the run
+	 * @throws InvalidRunIdException
+	 *             if the run ID is not valid
+	 */
+	WorkflowReport getWorkflowReport(String runID) throws InvalidRunIdException;
+
+	Workflow getWorkflow(String runID) throws InvalidRunIdException;
+
+	Profile getProfile(String runID) throws InvalidRunIdException;
+
+	String getRunName(String runID) throws InvalidRunIdException;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunStateException.java
----------------------------------------------------------------------
diff --git a/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunStateException.java b/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunStateException.java
new file mode 100644
index 0000000..eb695ad
--- /dev/null
+++ b/taverna-run-api/src/main/java/org/apache/taverna/platform/run/api/RunStateException.java
@@ -0,0 +1,46 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.run.api;
+
+/**
+ * Thrown when an operation is attempted when a workflow is in the wrong state,
+ * e.g., resuming a workflow that is not paused.
+ * 
+ * @author David Withers
+ */
+public class RunStateException extends Exception {
+	private static final long serialVersionUID = 6759341273715906131L;
+
+	public RunStateException() {
+		super();
+	}
+
+	public RunStateException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+	public RunStateException(String message) {
+		super(message);
+	}
+
+	public RunStateException(Throwable cause) {
+		super(cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/InvalidRunIdException.java
----------------------------------------------------------------------
diff --git a/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/InvalidRunIdException.java b/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/InvalidRunIdException.java
deleted file mode 100644
index 2cfecb3..0000000
--- a/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/InvalidRunIdException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.run.api;
-
-/**
- * Thrown when a runID is not valid for the RunService.
- * 
- * @author David Withers
- */
-public class InvalidRunIdException extends Exception {
-	private static final long serialVersionUID = -8524012164316151704L;
-
-	public InvalidRunIdException() {
-		super();
-	}
-
-	public InvalidRunIdException(String message) {
-		super(message);
-	}
-
-	public InvalidRunIdException(String message, Throwable cause) {
-		super(message, cause);
-	}
-
-	public InvalidRunIdException(Throwable cause) {
-		super(cause);
-	}
-}


[11/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchJobEvent.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchJobEvent.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchJobEvent.java
new file mode 100644
index 0000000..f55cb95
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchJobEvent.java
@@ -0,0 +1,105 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.events;
+
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchMessageType.JOB;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.invocation.ProcessIdentifierException;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchMessageType;
+
+/**
+ * An event within the dispatch stack containing a single job's worth of data
+ * along with an ordered list of Activity instances.
+ * 
+ * @author Tom Oinn
+ */
+public class DispatchJobEvent extends AbstractDispatchEvent<DispatchJobEvent> {
+	private Map<String, T2Reference> dataMap;
+	private List<? extends Activity<?>> activities;
+
+	/**
+	 * Create a new job event, specifying a complete set of input data and a
+	 * list of activities which could potentially consume this data
+	 * 
+	 * @param owningProcess
+	 * @param index
+	 * @param context
+	 * @param data
+	 * @param activities
+	 */
+	public DispatchJobEvent(String owningProcess, int[] index,
+			InvocationContext context, Map<String, T2Reference> data,
+			List<? extends Activity<?>> activities) {
+		super(owningProcess, index, context);
+		this.dataMap = data;
+		this.activities = activities;
+	}
+
+	/**
+	 * The actual data carried by this dispatch job event object is in the form
+	 * of a map, where the keys of the map are Strings identifying the named
+	 * input and the values are Strings containing valid data identifiers within
+	 * the context of a visible DataManager object (see CloudOne specification
+	 * for further information on the DataManager system)
+	 * 
+	 * @return Map of name to data reference for this Job
+	 */
+	public Map<String, T2Reference> getData() {
+		return this.dataMap;
+	}
+
+	/**
+	 * Returns a list of activity instances which can be applied to the data
+	 * contained by this job event.
+	 * 
+	 * @return ordered list of Activity instances
+	 */
+	public List<? extends Activity<?>> getActivities() {
+		return this.activities;
+	}
+
+	@Override
+	public DispatchJobEvent popOwningProcess()
+			throws ProcessIdentifierException {
+		return new DispatchJobEvent(popOwner(), index, context, dataMap,
+				activities);
+	}
+
+	@Override
+	public DispatchJobEvent pushOwningProcess(String localProcessName)
+			throws ProcessIdentifierException {
+		return new DispatchJobEvent(pushOwner(localProcessName), index,
+				context, dataMap, activities);
+	}
+
+	/**
+	 * @return Always a {@link DispatchMessageType#JOB}.
+	 */
+	@Override
+	public DispatchMessageType getMessageType() {
+		return JOB;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchJobQueueEvent.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchJobQueueEvent.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchJobQueueEvent.java
new file mode 100644
index 0000000..bbdfc4a
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchJobQueueEvent.java
@@ -0,0 +1,94 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.events;
+
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchMessageType.JOB_QUEUE;
+
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.invocation.IterationInternalEvent;
+import org.apache.taverna.invocation.ProcessIdentifierException;
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchMessageType;
+
+/**
+ * A message within the dispatch stack containing a single reference to the job
+ * queue from the iteration system along with an ordered list of Activity
+ * instances.
+ * 
+ * @author Tom Oinn
+ */
+public class DispatchJobQueueEvent extends
+		AbstractDispatchEvent<DispatchJobQueueEvent> {
+	private BlockingQueue<IterationInternalEvent<? extends IterationInternalEvent<?>>> queue;
+	private List<? extends Activity<?>> activities;
+
+	/**
+	 * Create a new job queue event, specifying the queue of Completion and Job
+	 * objects and the list of activities which will be used to process the
+	 * corresponding dispatch events
+	 * 
+	 * @param owner
+	 * @param context
+	 * @param queue
+	 * @param activities
+	 */
+	public DispatchJobQueueEvent(
+			String owner,
+			InvocationContext context,
+			BlockingQueue<IterationInternalEvent<? extends IterationInternalEvent<?>>> queue,
+			List<? extends Activity<?>> activities) {
+		super(owner, new int[] {}, context);
+		this.queue = queue;
+		this.activities = activities;
+	}
+
+	public BlockingQueue<IterationInternalEvent<? extends IterationInternalEvent<?>>> getQueue() {
+		return this.queue;
+	}
+
+	public List<? extends Activity<?>> getActivities() {
+		return this.activities;
+	}
+
+	@Override
+	public DispatchJobQueueEvent popOwningProcess()
+			throws ProcessIdentifierException {
+		return new DispatchJobQueueEvent(popOwner(), context, queue, activities);
+	}
+
+	@Override
+	public DispatchJobQueueEvent pushOwningProcess(String localProcessName)
+			throws ProcessIdentifierException {
+		return new DispatchJobQueueEvent(pushOwner(localProcessName), context,
+				queue, activities);
+	}
+
+	/**
+	 * @return Always a {@link DispatchMessageType#JOB_QUEUE}.
+	 */
+	@Override
+	public DispatchMessageType getMessageType() {
+		return JOB_QUEUE;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchResultEvent.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchResultEvent.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchResultEvent.java
new file mode 100644
index 0000000..ffed25e
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchResultEvent.java
@@ -0,0 +1,107 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.events;
+
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchMessageType.RESULT;
+
+import java.util.Map;
+
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.invocation.ProcessIdentifierException;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchMessageType;
+
+/**
+ * Dispatch event containing the results from an invocation. If the event is
+ * part of a stream of such events from a single job invocation the streaming
+ * flag will be set to true - when set layers that do not support streaming
+ * should either disable any related functionality or complain bitterly. They
+ * should never see such an event as the type checker will in the future catch
+ * such cases before they occur but for now it's something to watch for.
+ * 
+ * @author Tom Oinn
+ */
+public class DispatchResultEvent extends
+		AbstractDispatchEvent<DispatchResultEvent> {
+	private Map<String, T2Reference> dataMap;
+	private boolean streaming;
+
+	/**
+	 * Construct a new dispatch result event, specifying the data and whether
+	 * the result is part of a stream of multiple results events from a single
+	 * invocation
+	 * 
+	 * @param owner
+	 * @param index
+	 * @param context
+	 * @param data
+	 * @param streaming
+	 */
+	public DispatchResultEvent(String owner, int[] index,
+			InvocationContext context, Map<String, T2Reference> data,
+			boolean streaming) {
+		super(owner, index, context);
+		this.dataMap = data;
+		this.streaming = streaming;
+	}
+
+	/**
+	 * If this result is part of a stream, that is to say multiple result events
+	 * from a single job event, then return true otherwise return false.
+	 * 
+	 * @return whether this is part of a streamed result set
+	 */
+	public boolean isStreamingEvent() {
+		return this.streaming;
+	}
+
+	/**
+	 * The result contains a map of named EntityIdentifier instances
+	 * corresponding to the result data.
+	 * 
+	 * @return the result data for this event
+	 */
+	public Map<String, T2Reference> getData() {
+		return this.dataMap;
+	}
+
+	@Override
+	public DispatchResultEvent popOwningProcess()
+			throws ProcessIdentifierException {
+		return new DispatchResultEvent(popOwner(), index, context, dataMap,
+				streaming);
+	}
+
+	@Override
+	public DispatchResultEvent pushOwningProcess(String localProcessName)
+			throws ProcessIdentifierException {
+		return new DispatchResultEvent(pushOwner(localProcessName), index,
+				context, dataMap, streaming);
+	}
+
+	/**
+	 * @return Always a {@link DispatchMessageType#RESULT}.
+	 */
+	@Override
+	public DispatchMessageType getMessageType() {
+		return RESULT;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/package.html b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/package.html
new file mode 100644
index 0000000..d4dc0d4
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/package.html
@@ -0,0 +1,19 @@
+<body>
+Definition and support classes for the Dispatch Stack. Each processor in
+a workflow contains a stack of dispatch layers with each layer being
+responsible for a particular aspect of the invocation. At a high level
+the stack consumes a queue of events from the iteration system along
+with an initial set of service proxy objects and is repsonsible for
+taking jobs from the queue and matching them to appropriate invocation
+targets.
+<p>Taverna 1 has in effect a single hardcoded dispatch stack for
+each processor with little control over it aside from a few basic
+properties. To replicate the same behaviour within Taverna 2 there are
+dispatch layers for parallelism, retry, failover and invocation. As the
+dispatch layer is an extension point we or others can provide other
+aspects such as recursive invocation and dynamic (runtime) binding from
+abstract service proxies to concrete instances. The last is possible
+because the service list is passed through the stack along with the
+queue or individual job events and can be rewritten or filtered by
+dispatch layer implementations.
+</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/AbstractIterationStrategyNode.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/AbstractIterationStrategyNode.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/AbstractIterationStrategyNode.java
new file mode 100644
index 0000000..279c585
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/AbstractIterationStrategyNode.java
@@ -0,0 +1,224 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.iteration;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Vector;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.MutableTreeNode;
+import javax.swing.tree.TreeNode;
+
+import org.apache.taverna.invocation.Completion;
+import org.apache.taverna.workflowmodel.WorkflowStructureException;
+import org.apache.taverna.workflowmodel.processor.activity.Job;
+
+/**
+ * Abstract superclass for implementations of IterationStrategyNode, adds logic
+ * to connect nodes together and convenience methods to push jobs and completion
+ * events up to the parent node.
+ * 
+ * @author Tom Oinn
+ * @author Stian Soiland-Reyes
+ */
+@SuppressWarnings("serial")
+public abstract class AbstractIterationStrategyNode extends
+		DefaultMutableTreeNode implements IterationStrategyNode {
+	private List<IterationStrategyNode> children = new ArrayList<>();
+	private IterationStrategyNode parent = null;
+
+	/**
+	 * Implement TreeNode
+	 */
+	@Override
+	public final synchronized Enumeration<IterationStrategyNode> children() {
+		return new Vector<>(children).elements(); // TODO arraylist?
+	}
+
+	/**
+	 * Clear the child list and parent of this node
+	 */
+	@Override
+	public final synchronized void clear() {
+		for (IterationStrategyNode child : children)
+			child.setParent(null);
+		children.clear();
+		this.parent = null;
+	}
+
+	/**
+	 * Implement TreeNode
+	 */
+	@Override
+	public boolean getAllowsChildren() {
+		return true;
+	}
+
+	/**
+	 * Implement TreeNode
+	 */
+	@Override
+	public final synchronized IterationStrategyNode getChildAt(int position) {
+		return children.get(position);
+	}
+
+	/**
+	 * Implement TreeNode
+	 */
+	@Override
+	public final int getChildCount() {
+		return children.size();
+	}
+
+	/**
+	 * Implements IterationStrategyNode
+	 */
+	@Override
+	public final synchronized List<IterationStrategyNode> getChildren() {
+		return new ArrayList<>(children);
+	}
+
+	/**
+	 * Implement TreeNode
+	 */
+	@Override
+	public final synchronized int getIndex(TreeNode node) {
+		return children.indexOf(node);
+	}
+
+	/**
+	 * Implement TreeNode
+	 */
+	@Override
+	public final IterationStrategyNode getParent() {
+		return parent;
+	}
+
+	@Override
+	public synchronized void insert(MutableTreeNode child) {
+		insert(child, getChildCount());
+	}
+
+	@Override
+	public synchronized void insert(MutableTreeNode child, int index) {
+		if (!getAllowsChildren())
+			throw new IllegalStateException("Node does not allow children");
+		if (!(child instanceof IterationStrategyNode))
+			throw new IllegalArgumentException(
+					"Child not an instance of IterationStrategyNode: " + child);
+		if (child == this)
+			throw new IllegalArgumentException("Can't be it's own parent");
+
+		// Check if it is already there (in case we'll just move it)
+		int alreadyExistsIndex = children.indexOf(child);
+
+		children.add(index, (IterationStrategyNode) child);
+
+		if (alreadyExistsIndex > -1) {
+			// Remove it from the old position
+			if (index < alreadyExistsIndex
+					&& alreadyExistsIndex + 1 < children.size())
+				alreadyExistsIndex++;
+			children.remove(alreadyExistsIndex);
+		}
+		if (child.getParent() != this)
+			child.setParent(this);
+	}
+
+	/**
+	 * Implement TreeNode
+	 */
+	@Override
+	public boolean isLeaf() {
+		return children.isEmpty();
+	}
+
+	@Override
+	public void remove(int index) {
+		if (!getAllowsChildren())
+			throw new IllegalStateException("Node does not allow children");
+		children.remove(index);
+	}
+
+	@Override
+	public synchronized void remove(MutableTreeNode node) {
+		if (!getAllowsChildren())
+			throw new IllegalStateException("Node does not allow children");
+		children.remove(node);
+		if (node.getParent() == this)
+			node.setParent(null);
+	}
+
+	@Override
+	public void removeFromParent() {
+		if (parent != null) {
+			IterationStrategyNode oldParent = parent;
+			parent = null;
+			oldParent.remove(this);
+		}
+	}
+
+	/**
+	 * Implements IterationStrategyNode
+	 */
+	@Override
+	public final synchronized void setParent(MutableTreeNode newParent) {
+		if (newParent != null && !(newParent instanceof IterationStrategyNode))
+			throw new IllegalArgumentException(
+					"Parent not a IterationStrategyNode instance: " + newParent);
+		if (newParent != null && !newParent.getAllowsChildren())
+			throw new IllegalStateException(
+					"New parent does not allow children");
+		if (newParent == this)
+			throw new IllegalArgumentException("Can't be it's own parent");
+		removeFromParent();
+		parent = (IterationStrategyNode) newParent;
+		if (parent != null && !parent.getChildren().contains(this))
+			parent.insert(this);
+	}
+
+	@Override
+	public void setUserObject(Object object) {
+		throw new UnsupportedOperationException("Can't set user object");
+	}
+
+	/**
+	 * Push the specified completion event to the parent node
+	 */
+	protected final void pushCompletion(Completion completion) {
+		if (parent != null)
+			parent.receiveCompletion(parent.getIndex(this), completion);
+	}
+
+	/**
+	 * Push the specified job up to the parent node in the iteration strategy.
+	 */
+	protected final void pushJob(Job job) {
+		if (parent != null) {
+			int index = parent.getIndex(this);
+			if (index < 0)
+				throw new WorkflowStructureException(
+						"Parent doesn't have this node in its child list!");
+			parent.receiveJob(parent.getIndex(this), job);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/CompletionHandlingAbstractIterationStrategyNode.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/CompletionHandlingAbstractIterationStrategyNode.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/CompletionHandlingAbstractIterationStrategyNode.java
new file mode 100644
index 0000000..c06888e
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/CompletionHandlingAbstractIterationStrategyNode.java
@@ -0,0 +1,135 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.iteration;
+
+import static java.util.Collections.synchronizedMap;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.taverna.invocation.Completion;
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.workflowmodel.processor.activity.Job;
+
+/**
+ * A superclass for all iteration strategy nodes which are required to propagate
+ * final completion events formed from multiple inputs. This is all the 'real'
+ * iteration strategy nodes (but not the internal ones within the iteration
+ * strategy object itself or the named input port nodes). All events are passed
+ * to delegates in subclasses after which the completion state is checked, the
+ * logic is as follows :
+ * <p>
+ * If the event received is final, that is to say it has an index of zero, and
+ * final events have been received on all other inputs and at least one final
+ * completion has been received then emit a final completion, otherwise do
+ * nothing.
+ * <p>
+ * This means that subclasses should not emit final completion events themselves
+ * - these will be handled by this superclass and emiting them in the subclass
+ * will lead to duplicatation.
+ * 
+ * @author Tom Oinn
+ * @author David Withers
+ */
+@SuppressWarnings("serial")
+public abstract class CompletionHandlingAbstractIterationStrategyNode extends
+		AbstractIterationStrategyNode {
+	/**
+	 * Container class for the state of completion for a given process
+	 * identifier
+	 * 
+	 * @author Tom Oinn
+	 */
+	protected final class CompletionState {
+		protected CompletionState(int indexLength) {
+			inputComplete = new boolean[indexLength];
+			for (int i = 0; i < indexLength; i++)
+				inputComplete[i] = false;
+		}
+
+		protected boolean[] inputComplete;
+		protected boolean receivedCompletion = false;
+
+		/**
+		 * Return true iff all inputs have completed
+		 */
+		protected boolean isComplete() {
+			for (boolean inputCompletion : inputComplete)
+				if (!inputCompletion)
+					return false;
+			return true;
+		}
+	}
+
+	private Map<String, CompletionState> ownerToCompletion = synchronizedMap(new HashMap<String, CompletionState>());
+
+	@Override
+	public final void receiveCompletion(int inputIndex, Completion completion) {
+		innerReceiveCompletion(inputIndex, completion);
+		if (completion.getIndex().length == 0)
+			pingCompletionState(inputIndex, completion.getOwningProcess(),
+					true, completion.getContext());
+	}
+
+	@Override
+	public final void receiveJob(int inputIndex, Job newJob) {
+		innerReceiveJob(inputIndex, newJob);
+		if (newJob.getIndex().length == 0)
+			pingCompletionState(inputIndex, newJob.getOwningProcess(), false,
+					newJob.getContext());
+	}
+
+	/**
+	 * Called after a final completion event has been emited for a given owning
+	 * process, should be used by subclasses to do any tidying required,
+	 * removing state etc.
+	 * 
+	 * @param owningProcess
+	 */
+	protected abstract void cleanUp(String owningProcess);
+
+	private void pingCompletionState(int inputIndex, String owningProcess,
+			boolean isCompletion, InvocationContext context) {
+		CompletionState cs = getCompletionState(owningProcess);
+		cs.inputComplete[inputIndex] = true;
+		if (isCompletion)
+			cs.receivedCompletion = true;
+		if (cs.isComplete()) {
+			cleanUp(owningProcess);
+			ownerToCompletion.remove(owningProcess);
+			if (cs.receivedCompletion)
+				pushCompletion(new Completion(owningProcess, new int[0],
+						context));
+		}
+	}
+
+	protected CompletionState getCompletionState(String owningProcess) {
+		if (ownerToCompletion.containsKey(owningProcess))
+			return ownerToCompletion.get(owningProcess);
+		CompletionState cs = new CompletionState(getChildCount());
+		ownerToCompletion.put(owningProcess, cs);
+		return cs;
+	}
+
+	protected abstract void innerReceiveCompletion(int inputIndex,
+			Completion completion);
+
+	protected abstract void innerReceiveJob(int inputIndex, Job newJob);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/CrossProduct.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/CrossProduct.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/CrossProduct.java
new file mode 100644
index 0000000..947c7d6
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/CrossProduct.java
@@ -0,0 +1,163 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.iteration;
+
+import static java.util.Collections.synchronizedMap;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.taverna.invocation.Completion;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.workflowmodel.processor.activity.Job;
+
+/**
+ * A cross product node combines its inputs in an 'all against all' manner. When
+ * a new job is received on index 'n' a set of jobs is emited corresponding to
+ * the combination of the new job with all other jobs on input indices other
+ * than 'n'.
+ * 
+ * @author Tom Oinn
+ * @author David Withers
+ */
+@SuppressWarnings("serial")
+public class CrossProduct extends
+		CompletionHandlingAbstractIterationStrategyNode {
+	private Map<String, List<Set<Job>>> ownerToCache = synchronizedMap(new HashMap<String, List<Set<Job>>>());
+
+	/**
+	 * Receive a job, emit jobs corresponding to the orthogonal join of the new
+	 * job with all jobs in all other input lists.
+	 */
+	@Override
+	public synchronized void innerReceiveJob(int inputIndex, Job newJob) {
+		if (getChildCount() == 1) {
+			/*
+			 * there's only one input and there's nothing to do here so push the
+			 * job through
+			 */
+			pushJob(newJob);
+			return;
+		}
+		if (!ownerToCache.containsKey(newJob.getOwningProcess())) {
+			List<Set<Job>> perInputCache = new ArrayList<>();
+			for (int i = 0; i < getChildCount(); i++)
+				perInputCache.add(new HashSet<Job>());
+			ownerToCache.put(newJob.getOwningProcess(), perInputCache);
+		}
+		// Store the new job
+		List<Set<Job>> perInputCache = ownerToCache.get(newJob
+				.getOwningProcess());
+		perInputCache.get(inputIndex).add(newJob);
+		/*
+		 * Find all combinations of the new job with all permutations of jobs in
+		 * the other caches. We could make this a lot easier by restricting it
+		 * to a single pair of inputs, this might be a more sane way to go in
+		 * the future...
+		 */
+		Set<Job> workingSet = perInputCache.get(0);
+		if (inputIndex == 0) {
+			workingSet = new HashSet<>();
+			workingSet.add(newJob);
+		}
+		for (int i = 1; i < getChildCount(); i++) {
+			Set<Job> thisSet = perInputCache.get(i);
+			if (i == inputIndex) {
+				/*
+				 * This is the cache for the new job, so we rewrite the set to a
+				 * single element one containing only the newly submitted job
+				 */
+				thisSet = new HashSet<>();
+				thisSet.add(newJob);
+			}
+			workingSet = merge(workingSet, thisSet);
+		}
+		for (Job outputJob : workingSet)
+			pushJob(outputJob);
+		if (canClearCache(inputIndex, newJob.getOwningProcess()))
+			/*
+			 * If we've seen completions for all the other indexes we don't need
+			 * to cache jobs for this index
+			 */
+			perInputCache.get(inputIndex).clear();
+	}
+
+	private Set<Job> merge(Set<Job> set1, Set<Job> set2) {
+		Set<Job> newSet = new HashSet<>();
+		for (Job job1 : set1)
+			for (Job job2 : set2) {
+				int[] newIndex = new int[job1.getIndex().length
+						+ job2.getIndex().length];
+				int j = 0;
+				for (int i = 0; i < job1.getIndex().length; i++)
+					newIndex[j++] = job1.getIndex()[i];
+				for (int i = 0; i < job2.getIndex().length; i++)
+					newIndex[j++] = job2.getIndex()[i];
+				Map<String, T2Reference> newDataMap = new HashMap<>();
+				newDataMap.putAll(job1.getData());
+				newDataMap.putAll(job2.getData());
+				newSet.add(new Job(job1.getOwningProcess(), newIndex,
+						newDataMap, job1.getContext()));
+			}
+		return newSet;
+	}
+
+	@Override
+	public void innerReceiveCompletion(int inputIndex, Completion completion) {
+		// Do nothing, let the superclass handle final completion events
+	}
+
+	@Override
+	protected final void cleanUp(String owningProcess) {
+		ownerToCache.remove(owningProcess);
+	}
+
+	/**
+	 * Returns true iff completions have been received for all other inputs.
+	 * 
+	 * @param inputIndex
+	 * @param owningProcess
+	 * @return true iff completions have been received for all other inputs
+	 */
+	private boolean canClearCache(int inputIndex, String owningProcess) {
+		boolean[] completionState = getCompletionState(owningProcess).inputComplete;
+		for (int i = 0; i < completionState.length; i++)
+			if (i != inputIndex && !completionState[i])
+				return false;
+		return true;
+	}
+
+	@Override
+	public int getIterationDepth(Map<String, Integer> inputDepths)
+			throws IterationTypeMismatchException {
+		if (isLeaf())
+			// No children!
+			throw new IterationTypeMismatchException(
+					"Cross product with no children");
+		int temp = 0;
+		for (IterationStrategyNode child : getChildren())
+			temp += child.getIterationDepth(inputDepths);
+		return temp;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/DotProduct.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/DotProduct.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/DotProduct.java
new file mode 100644
index 0000000..084e2db
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/DotProduct.java
@@ -0,0 +1,122 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.iteration;
+
+import static java.util.Collections.synchronizedMap;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.taverna.invocation.Completion;
+import org.apache.taverna.invocation.TreeCache;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.workflowmodel.processor.activity.Job;
+
+/**
+ * The dot product matches jobs by index array, when a job is received a job is
+ * emited if and only if the index array of the new job is matched exactly by
+ * index arrays of one job in each other input index.
+ * 
+ * @author Tom Oinn
+ */
+@SuppressWarnings("serial")
+public class DotProduct extends CompletionHandlingAbstractIterationStrategyNode {
+	Map<String, TreeCache[]> ownerToCache = synchronizedMap(new HashMap<String, TreeCache[]>());
+
+	@Override
+	public synchronized void innerReceiveJob(int inputIndex, Job newJob) {
+		if (getChildCount() == 1) {
+			/*
+			 * if there's only one input there's nothing to do here so push the
+			 * job through
+			 */
+			pushJob(newJob);
+			return;
+		}
+		String owningProcess = newJob.getOwningProcess();
+		if (!ownerToCache.containsKey(owningProcess)) {
+			TreeCache[] caches = new TreeCache[getChildCount()];
+			for (int i = 0; i < getChildCount(); i++)
+				caches[i] = new TreeCache();
+			ownerToCache.put(owningProcess, caches);
+		}
+		/*
+		 * Firstly store the new job in the cache, this isn't optimal but is
+		 * safe for now - we can make this more efficient by doing the
+		 * comparison first and only storing the job if required
+		 */
+		TreeCache[] caches = ownerToCache.get(owningProcess);
+		caches[inputIndex].insertJob(newJob);
+		int[] indexArray = newJob.getIndex();
+		boolean foundMatch = true;
+		Map<String, T2Reference> newDataMap = new HashMap<>();
+		for (TreeCache cache : caches)
+			if (cache.containsLocation(indexArray))
+				newDataMap.putAll(cache.get(indexArray).getData());
+			else
+				foundMatch = false;
+		if (foundMatch) {
+			Job j = new Job(owningProcess, indexArray, newDataMap, newJob
+					.getContext());
+			/*
+			 * Remove all copies of the job with this index from the cache,
+			 * we'll never use it again and it pays to be tidy
+			 */
+			for (TreeCache cache : caches)
+				cache.cut(indexArray);
+			pushJob(j);
+		}
+	}
+
+	/**
+	 * Delegate to the superclass to propogate completion events if and only if
+	 * the completion event is a final one. We can potentially implement finer
+	 * grained logic here in the future.
+	 */
+	@Override
+	public void innerReceiveCompletion(int inputIndex,
+			Completion completion) {
+		/*
+		 * Do nothing, let the superclass handle final completion events, ignore
+		 * others for now (although in theory we should be able to do better
+		 * than this really)
+		 */
+	}
+
+	@Override
+	protected  void cleanUp(String owningProcess) {
+		ownerToCache.remove(owningProcess);
+	}
+
+	@Override
+	public int getIterationDepth(Map<String, Integer> inputDepths)
+			throws IterationTypeMismatchException {
+		// Check that all input depths are the same
+		if (isLeaf())
+			// No children!
+			throw new IterationTypeMismatchException("Dot product with no children");			
+		int depth = getChildAt(0).getIterationDepth(inputDepths);
+		for (IterationStrategyNode childNode : getChildren())
+			if (childNode.getIterationDepth(inputDepths) != depth)
+				throw new IterationTypeMismatchException(
+						"Mismatched input types for dot product node");
+		return depth;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/IterationStrategy.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/IterationStrategy.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/IterationStrategy.java
new file mode 100644
index 0000000..f0f0b07
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/IterationStrategy.java
@@ -0,0 +1,53 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.iteration;
+
+import java.util.Map;
+
+import org.apache.taverna.workflowmodel.WorkflowItem;
+
+public interface IterationStrategy extends WorkflowItem {
+	/**
+	 * The iteration strategy results in a set of job objects with a particular
+	 * job index. This method returns the length of that index array when the
+	 * specified input types are used. Input types are defined in terms of name
+	 * and integer pairs where the name is the name of a NamedInputPortNode in
+	 * the iteration strategy and the integer is the depth of the input data
+	 * collection (i.e. item depth + index array length for that item which
+	 * should be a constant).
+	 * 
+	 * @param inputDepths
+	 *            map of port names to input collection depth
+	 * @return the length of the index array which will be generated for each
+	 *         resultant job object.
+	 */
+	int getIterationDepth(Map<String, Integer> inputDepths)
+			throws IterationTypeMismatchException;
+
+	/**
+	 * Return a map of port name -> desired cardinality for this iteration
+	 * strategy
+	 */
+	Map<String, Integer> getDesiredCardinalities();
+
+	TerminalNode getTerminalNode();
+
+	void normalize();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/IterationStrategyNode.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/IterationStrategyNode.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/IterationStrategyNode.java
new file mode 100644
index 0000000..4dc786e
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/IterationStrategyNode.java
@@ -0,0 +1,120 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.iteration;
+
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Map;
+
+import javax.swing.tree.MutableTreeNode;
+
+import org.apache.taverna.invocation.Completion;
+import org.apache.taverna.workflowmodel.WorkflowItem;
+import org.apache.taverna.workflowmodel.processor.activity.Job;
+
+/**
+ * Interface for nodes within an iteration strategy layer
+ * 
+ * @author Tom Oinn
+ * @author Stian Soiland-Reyes
+ */
+public interface IterationStrategyNode extends MutableTreeNode, WorkflowItem {
+	/**
+	 * Specialised return type of {@link TreeNode#children()}
+	 */
+	@Override
+	Enumeration<IterationStrategyNode> children();
+
+	/**
+	 * Remove all children nodes and set the parent to <code>null</code>.
+	 */
+	void clear();
+
+	/**
+	 * Specialised return type of {@link TreeNode#getChildAt(int)}
+	 */
+	@Override
+	IterationStrategyNode getChildAt(int childIndex);
+
+	/**
+	 * Return a copy of the list of children nodes, or an empty list if
+	 * {@link #getAllowsChildren()} is <code>false</code>.
+	 * 
+	 * @return List of children nodes.
+	 */
+	List<IterationStrategyNode> getChildren();
+
+	/**
+	 * In the context of an enclosing iteration strategy each node should be
+	 * able to return the iteration depth, i.e. the length of the index array,
+	 * for items it will emit. In all cases other than leaf nodes this is
+	 * defined in terms of the depth of child nodes. The input cardinalities for
+	 * named ports are pushed through each node so that the terminal nodes
+	 * corresponding to input port collators can evaluate this expression -
+	 * pushing it through the entire evaluation means we don't have to keep
+	 * state anywhere in the leaf nodes (standard dependency injection)
+	 * <p>
+	 * Nodes can choose to throw the IterationTypeMismatchException if their
+	 * inputs aren't compatible with the operational semantics of the node such
+	 * as in the case of a dot product node with inputs with different depths.
+	 * 
+	 * @param inputDepths
+	 * @return
+	 * @throws IterationTypeMismatchException
+	 */
+	int getIterationDepth(Map<String, Integer> inputDepths)
+			throws IterationTypeMismatchException;
+
+	/**
+	 * Specialised return type of {@link TreeNode#getParent()}
+	 */
+	@Override
+	IterationStrategyNode getParent();
+
+	/**
+	 * Insert a new child node. The new child will be added in the end of the
+	 * list, so this would be equivalent to insert(child, getChildCount()).
+	 * 
+	 * @param child
+	 *            Child node to add
+	 */
+	void insert(MutableTreeNode child);
+
+	/**
+	 * Nodes can also receive completion events, the simplest being one
+	 * declaring that no further input is expected on the given input, or
+	 * partial completion events which are interpreted as 'no event with an
+	 * index array prefixed by the specified completion index array will be
+	 * received on the specified index'
+	 */
+	void receiveCompletion(int inputIndex, Completion completion);
+
+	/**
+	 * The nodes within the iteration strategy, a tree structure, are event
+	 * based. When a new fragment of a job from upstream in the tree (towards
+	 * leaves) arrives it is handled by this method. Implementations will
+	 * probably have to handle state management, i.e. what jobs have we already
+	 * seen, and emit appropriate jobs to downstream nodes.
+	 * 
+	 * @param inputIndex
+	 * @param newJob
+	 */
+	void receiveJob(int inputIndex, Job newJob);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/IterationStrategyStack.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/IterationStrategyStack.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/IterationStrategyStack.java
new file mode 100644
index 0000000..e2305a4
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/IterationStrategyStack.java
@@ -0,0 +1,64 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.iteration;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.taverna.workflowmodel.WorkflowItem;
+
+/**
+ * Stack of iteration strategy containers. The stacking behaviour allows for
+ * staged implicit iteration where intermediate strategies are used to drill
+ * into the collection structure to a certain depth with a final one used to
+ * render job objects containing data at the correct depth for the process. This
+ * was achieved in Taverna 1 through the combination of nested workflows and
+ * 'forcing' processors which could echo and therefore force input types of the
+ * workflow to a particular cardinality.
+ * 
+ * @author Tom Oinn
+ */
+public interface IterationStrategyStack extends WorkflowItem {
+	/**
+	 * The iteration strategy stack consists of an ordered list of iteration
+	 * strategies.
+	 * 
+	 * @return An unmodifiable copy of the list containing the iteration
+	 *         strategy objects in order, with the strategy at position 0 in the
+	 *         list being the one to which data is fed first.
+	 */
+	List<? extends IterationStrategy> getStrategies();
+
+	/**
+	 * Calculate the depth of the iteration strategy stack as a whole given a
+	 * set of named inputs and their cardinalities. This depth is the length of
+	 * the index array which will be added to any output data, so the resultant
+	 * output of each port in the owning processor is the depth of that port as
+	 * defined by the activity plus this value.
+	 * 
+	 * @param inputDepths
+	 * @return
+	 * @throws IterationTypeMismatchException
+	 * @throws MissingIterationInputException
+	 */
+	int getIterationDepth(Map<String, Integer> inputDepths)
+			throws IterationTypeMismatchException,
+			MissingIterationInputException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/IterationTypeMismatchException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/IterationTypeMismatchException.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/IterationTypeMismatchException.java
new file mode 100644
index 0000000..7f17f3f
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/IterationTypeMismatchException.java
@@ -0,0 +1,48 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.iteration;
+
+/**
+ * Thrown during the typecheck phase when an iteration strategy is configured
+ * such that at runtime it would fail. This is generally because a dot product
+ * node has been specified where the children of that node will have different
+ * cardinalities (in this case the dot product isn't defined)
+ * 
+ * @author Tom Oinn
+ */
+public class IterationTypeMismatchException extends Exception {
+	private static final long serialVersionUID = -3034020607723767223L;
+
+	public IterationTypeMismatchException() {
+		super();
+	}
+
+	public IterationTypeMismatchException(String arg0) {
+		super(arg0);
+	}
+
+	public IterationTypeMismatchException(Throwable arg0) {
+		super(arg0);
+	}
+
+	public IterationTypeMismatchException(String arg0, Throwable arg1) {
+		super(arg0, arg1);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/MissingIterationInputException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/MissingIterationInputException.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/MissingIterationInputException.java
new file mode 100644
index 0000000..0c9833e
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/MissingIterationInputException.java
@@ -0,0 +1,49 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.iteration;
+
+/**
+ * Thrown when an attempt is made to evaluate the type of the iteration strategy
+ * but one or more input ports aren't defined in the input array of types.
+ * Shouldn't normally happen as this will be handled by the type checker
+ * detecting that there aren't enough inputs to check but we indicate it for
+ * extra robustness.
+ * 
+ * @author Tom Oinn
+ */
+public class MissingIterationInputException extends Exception {
+	private static final long serialVersionUID = -1615949178096496592L;
+
+	public MissingIterationInputException() {
+		super();
+	}
+
+	public MissingIterationInputException(String arg0) {
+		super(arg0);
+	}
+
+	public MissingIterationInputException(Throwable arg0) {
+		super(arg0);
+	}
+
+	public MissingIterationInputException(String arg0, Throwable arg1) {
+		super(arg0, arg1);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/NamedInputPortNode.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/NamedInputPortNode.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/NamedInputPortNode.java
new file mode 100644
index 0000000..91c2f20
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/NamedInputPortNode.java
@@ -0,0 +1,115 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.iteration;
+
+import java.util.Map;
+
+import org.apache.taverna.invocation.Completion;
+import org.apache.taverna.workflowmodel.processor.activity.Job;
+
+/**
+ * Acts as the input to a stage within the iteration strategy, passes all jobs
+ * straight through. NamedInputPortNode objects are, as the name suggests,
+ * named. These names correspond to the names of abstract input ports on the
+ * Processor object to which the iteration strategy belongs.
+ * 
+ * @author Tom Oinn
+ */
+@SuppressWarnings("serial")
+public class NamedInputPortNode extends AbstractIterationStrategyNode {
+	private String portName;
+	private int desiredCardinality;
+
+	public NamedInputPortNode(String name, int cardinality) {
+		super();
+		this.portName = name;
+		this.desiredCardinality = cardinality;
+	}
+
+	/**
+	 * If this node receives a job it will always be pushed without modification
+	 * up to the parent
+	 */
+	@Override
+	public void receiveJob(int inputIndex, Job newJob) {
+		pushJob(newJob);
+	}
+
+	/**
+	 * Completion events are passed straight through the same as jobs
+	 */
+	@Override
+	public void receiveCompletion(int inputIndex, Completion completion) {
+		pushCompletion(completion);
+	}
+
+	/**
+	 * Each node maps to a single named input port within the processor
+	 */
+	public String getPortName() {
+		return this.portName;
+	}
+
+	/**
+	 * Each node defines the level of collection depth for that input port
+	 */
+	public int getCardinality() {
+		return this.desiredCardinality;
+	}
+
+	/**
+	 * These nodes correspond to inputs to the iteration strategy and are always
+	 * leaf nodes as a result.
+	 * 
+	 * @override
+	 */
+	@Override
+	public boolean isLeaf() {
+		return true;
+	}
+
+	/**
+	 * These nodes can never have children
+	 * 
+	 * @override
+	 */
+	@Override
+	public boolean getAllowsChildren() {
+		return false;
+	}
+
+	/**
+	 * Iteration depth is the difference between the supplied input depth and
+	 * the desired one. If the desired depth is greater then wrapping will
+	 * happen and the iteration depth will be zero (rather than a negative!)
+	 */
+	@Override
+	public int getIterationDepth(Map<String, Integer> inputDepths) {
+		int myInputDepth = inputDepths.get(portName);
+		int depthMismatch = myInputDepth - desiredCardinality;
+		return (depthMismatch > 0 ? depthMismatch : 0);
+	}
+
+	@Override
+	public String toString() {
+		return getClass().getSimpleName() + " " + getPortName() + "("
+				+ getCardinality() + ")";
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/PrefixDotProduct.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/PrefixDotProduct.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/PrefixDotProduct.java
new file mode 100644
index 0000000..cbf45e0
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/PrefixDotProduct.java
@@ -0,0 +1,110 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.iteration;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.taverna.invocation.TreeCache;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.workflowmodel.processor.activity.Job;
+
+/**
+ * Matches jobs where the index array of the job on index 0 is the prefix of the
+ * index array of the job on index 1. This node can only ever have exactly two
+ * child nodes!
+ * 
+ * @author Tom Oinn
+ */
+@SuppressWarnings("serial")
+public class PrefixDotProduct extends DotProduct {
+	@Override
+	protected synchronized final void cleanUp(String owningProcess) {
+		ownerToCache.remove(owningProcess);
+	}
+
+	@Override
+	public void innerReceiveJob(int inputIndex, Job newJob) {
+		String owningProcess = newJob.getOwningProcess();
+		TreeCache[] caches;
+		synchronized (ownerToCache) {
+			caches = ownerToCache.get(owningProcess);
+			// Create the caches if not already initialized
+			if (caches == null) {
+				caches = new TreeCache[getChildCount()];
+				for (int i = 0; i < getChildCount(); i++)
+					caches[i] = new TreeCache();
+				ownerToCache.put(owningProcess, caches);
+			}
+		}
+
+		// Store the job
+		caches[inputIndex].insertJob(newJob);
+
+		/*
+		 * If this job came in on index 0 we have to find all jobs in the cache
+		 * for index 1 which have the index array as a prefix. Fortunately this
+		 * is quite easy due to the tree structure of the cache, we can just ask
+		 * for all nodes in the cache with that index.
+		 */
+		if (inputIndex == 0) {
+			int[] prefixIndexArray = newJob.getIndex();
+			List<Job> matchingJobs;
+			synchronized (caches[1]) {
+				// Match all jobs and remove them so other calls can't produce
+				// duplicates
+				matchingJobs = caches[1].jobsWithPrefix(prefixIndexArray);
+				caches[1].cut(prefixIndexArray);
+			}
+			for (Job job : matchingJobs) {
+				Map<String, T2Reference> newDataMap = new HashMap<>();
+				newDataMap.putAll(newJob.getData());
+				newDataMap.putAll(job.getData());
+				Job mergedJob = new Job(owningProcess, job.getIndex(),
+						newDataMap, newJob.getContext());
+				pushJob(mergedJob);
+			}
+		}
+
+		/*
+		 * If the job came in on index 1 we have to find the job on index 0 that
+		 * matches the first 'n' indices, where 'n' is determined by the depth
+		 * of jobs on the cache for index 0.
+		 */
+		else if (inputIndex == 1) {
+			// Only act if we've received jobs on the cache at index 0
+			if (caches[0].getIndexLength() > 0) {
+				int[] prefix = new int[caches[0].getIndexLength()];
+				for (int i = 0; i < prefix.length; i++)
+					prefix[i] = newJob.getIndex()[i];
+				Job j = caches[0].get(prefix);
+				if (j != null) {
+					Map<String, T2Reference> newDataMap = new HashMap<>();
+					newDataMap.putAll(j.getData());
+					newDataMap.putAll(newJob.getData());
+					Job mergedJob = new Job(owningProcess, newJob.getIndex(),
+							newDataMap, newJob.getContext());
+					pushJob(mergedJob);
+				}
+			}
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/TerminalNode.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/TerminalNode.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/TerminalNode.java
new file mode 100644
index 0000000..504296e
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/TerminalNode.java
@@ -0,0 +1,38 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.iteration;
+
+import javax.swing.tree.MutableTreeNode;
+
+/**
+ * The terminal node is the root of the iteration strategy tree, it is
+ * responsible for forwarding all events up to the iteration strategy itself
+ * which can then propogate them to the strategy stack.
+ */
+@SuppressWarnings("serial")
+public abstract class TerminalNode extends AbstractIterationStrategyNode {
+	@Override
+	public synchronized void insert(MutableTreeNode child, int index) {
+		if (getChildCount() > 0 && getChildAt(0) != child)
+			throw new IllegalStateException(
+					"The terminal node can have maximum one child");
+		super.insert(child, index);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/package.html b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/package.html
new file mode 100644
index 0000000..65f2a61
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/package.html
@@ -0,0 +1,4 @@
+<body>
+Object model and enactment logic for the iteration strategy component of
+a Processor
+</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/serialization/DeserializationException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/serialization/DeserializationException.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/serialization/DeserializationException.java
new file mode 100644
index 0000000..5563566
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/serialization/DeserializationException.java
@@ -0,0 +1,32 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.serialization;
+
+public class DeserializationException extends Exception {
+	public DeserializationException(String msg) {
+		super(msg);
+	}
+
+	public DeserializationException(String msg, Exception cause) {
+		super(msg, cause);
+	}
+
+	private static final long serialVersionUID = -5905705659863088259L;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/serialization/SerializationException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/serialization/SerializationException.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/serialization/SerializationException.java
new file mode 100644
index 0000000..6339305
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/serialization/SerializationException.java
@@ -0,0 +1,32 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.serialization;
+
+public class SerializationException extends Exception {
+	public SerializationException(String msg, Exception cause) {
+		super(msg, cause);
+	}
+
+	public SerializationException(String msg) {
+		super(msg);
+	}
+
+	private static final long serialVersionUID = -218787623524401819L;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/utils/AnnotationTools.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/utils/AnnotationTools.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/utils/AnnotationTools.java
new file mode 100644
index 0000000..2b044c0
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/utils/AnnotationTools.java
@@ -0,0 +1,170 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.utils;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.taverna.annotation.Annotated;
+import org.apache.taverna.annotation.AnnotationAssertion;
+import org.apache.taverna.annotation.AnnotationBeanSPI;
+import org.apache.taverna.annotation.AnnotationChain;
+import org.apache.taverna.annotation.AppliesTo;
+import org.apache.taverna.annotation.annotationbeans.AbstractTextualValueAssertion;
+import org.apache.taverna.workflowmodel.Edit;
+import org.apache.taverna.workflowmodel.EditException;
+import org.apache.taverna.workflowmodel.Edits;
+
+import org.apache.log4j.Logger;
+
+public class AnnotationTools {
+	private static Logger logger = Logger.getLogger(AnnotationTools.class);
+	// private Iterable<Class<?>> annotationBeanRegistry;
+
+	public static Edit<?> addAnnotation(Annotated<?> annotated,
+			AnnotationBeanSPI a, Edits edits) {
+		return edits.getAddAnnotationChainEdit(annotated, a);
+	}
+
+	public static AnnotationBeanSPI getAnnotation(Annotated<?> annotated,
+			Class<?> annotationClass) {
+		AnnotationBeanSPI result = null;
+		Date latestDate = null;
+		for (AnnotationChain chain : annotated.getAnnotations())
+			for (AnnotationAssertion<?> assertion : chain.getAssertions()) {
+				AnnotationBeanSPI detail = assertion.getDetail();
+				if (annotationClass.isInstance(detail)) {
+					Date assertionDate = assertion.getCreationDate();
+					if ((latestDate == null)
+							|| latestDate.before(assertionDate)) {
+						result = detail;
+						latestDate = assertionDate;
+					}
+				}
+			}
+		return result;
+	}
+
+	@SuppressWarnings("unchecked")
+	public <T> List<Class<? extends T>> getAnnotationBeanClasses(
+			List<AnnotationBeanSPI> annotations, Class<T> superClass) {
+		List<Class<? extends T>> results = new ArrayList<>();
+		for (AnnotationBeanSPI annotation : annotations) {
+			Class<? extends AnnotationBeanSPI> annotationBeanClass = annotation
+					.getClass();
+			if (superClass.isAssignableFrom(annotationBeanClass))
+				results.add((Class<? extends T>) annotationBeanClass);
+		}
+		return results;
+	}
+
+	public List<Class<?>> getAnnotatingClasses(
+			List<AnnotationBeanSPI> annotations, Annotated<?> annotated) {
+		List<Class<?>> result = new ArrayList<>();
+		for (Class<? extends AbstractTextualValueAssertion> c : getAnnotationBeanClasses(
+				annotations, AbstractTextualValueAssertion.class)) {
+			AppliesTo appliesToAnnotation = (AppliesTo) c
+					.getAnnotation(AppliesTo.class);
+			if (appliesToAnnotation == null)
+				continue;
+			for (Class<?> target : appliesToAnnotation.targetObjectType())
+				if (target.isInstance(annotated))
+					result.add(c);
+		}
+		return result;
+	}
+
+	public static Edit<?> setAnnotationString(Annotated<?> annotated,
+			Class<?> c, String value, Edits edits) {
+		AbstractTextualValueAssertion a = null;
+		try {
+			logger.info("Setting " + c.getCanonicalName() + " to " + value);
+			a = (AbstractTextualValueAssertion) c.newInstance();
+		} catch (InstantiationException | IllegalAccessException e) {
+			logger.error(e);
+			throw new RuntimeException(e);
+		}
+		a.setText(value);
+		return addAnnotation(annotated, a, edits);
+	}
+
+	public static String getAnnotationString(Annotated<?> annotated,
+			Class<?> annotationClass, String missingValue) {
+		AbstractTextualValueAssertion a = (AbstractTextualValueAssertion) getAnnotation(
+				annotated, annotationClass);
+		if (a == null)
+			return missingValue;
+		return a.getText();
+	}
+
+	/**
+	 * Remove out of date annotations unless many of that class are allowed, or
+	 * it is explicitly not pruned
+	 */
+	@SuppressWarnings("rawtypes")
+	public static void pruneAnnotations(Annotated<?> annotated, Edits edits) {
+		Map<Class<? extends AnnotationBeanSPI>, AnnotationAssertion> remainder = new HashMap<>();
+		Set<AnnotationChain> newChains = new HashSet<AnnotationChain>();
+		for (AnnotationChain chain : annotated.getAnnotations()) {
+			AnnotationChain newChain = edits.createAnnotationChain();
+			for (AnnotationAssertion assertion : chain.getAssertions()) {
+				AnnotationBeanSPI annotation = assertion.getDetail();
+				Class<? extends AnnotationBeanSPI> annotationClass = annotation
+						.getClass();
+				AppliesTo appliesToAnnotation = (AppliesTo) annotationClass
+						.getAnnotation(AppliesTo.class);
+				if ((appliesToAnnotation == null) || appliesToAnnotation.many()
+						|| !appliesToAnnotation.pruned())
+					try {
+						edits.getAddAnnotationAssertionEdit(newChain, assertion)
+								.doEdit();
+					} catch (EditException e) {
+						logger.error("Error while pruning annotations", e);
+					}
+				else if (remainder.containsKey(annotationClass)) {
+					AnnotationAssertion currentAssertion = remainder
+							.get(annotationClass);
+					if (assertion.getCreationDate().compareTo(
+							currentAssertion.getCreationDate()) > 0)
+						remainder.put(annotationClass, assertion);
+				} else
+					remainder.put(annotationClass, assertion);
+			}
+			if (!newChain.getAssertions().isEmpty())
+				newChains.add(newChain);
+		}
+		for (AnnotationAssertion assertion : remainder.values()) {
+			AnnotationChain newChain = edits.createAnnotationChain();
+			try {
+				edits.getAddAnnotationAssertionEdit(newChain, assertion)
+						.doEdit();
+			} catch (EditException e) {
+				logger.error("Error while pruning annotations", e);
+			}
+			newChains.add(newChain);
+		}
+		annotated.setAnnotations(newChains);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/utils/NamedWorkflowEntityComparator.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/utils/NamedWorkflowEntityComparator.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/utils/NamedWorkflowEntityComparator.java
new file mode 100644
index 0000000..df45360
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/utils/NamedWorkflowEntityComparator.java
@@ -0,0 +1,38 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.utils;
+
+import java.util.Comparator;
+
+import org.apache.taverna.workflowmodel.NamedWorkflowEntity;
+
+/**
+ * Compare two named workflow entities (such as a Processor) by their local
+ * name.
+ * 
+ * @author Stian Soiland-Reyes
+ */
+public class NamedWorkflowEntityComparator implements
+		Comparator<NamedWorkflowEntity> {
+	@Override
+	public int compare(NamedWorkflowEntity o1, NamedWorkflowEntity o2) {
+		return o1.getLocalName().compareToIgnoreCase(o2.getLocalName());
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/utils/PortComparator.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/utils/PortComparator.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/utils/PortComparator.java
new file mode 100644
index 0000000..f3a85fd
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/utils/PortComparator.java
@@ -0,0 +1,36 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.utils;
+
+import java.util.Comparator;
+
+import org.apache.taverna.workflowmodel.Port;
+
+/**
+ * Compare two workflow ports by their name.
+ * 
+ * @author Stian Soiland-Reyes
+ */
+public class PortComparator implements Comparator<Port> {
+	@Override
+	public int compare(Port o1, Port o2) {
+		return o1.getName().compareToIgnoreCase(o2.getName());
+	}
+}


[39/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ValueToReferenceConverterSPI.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ValueToReferenceConverterSPI.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ValueToReferenceConverterSPI.java
new file mode 100644
index 0000000..7a93bbe
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ValueToReferenceConverterSPI.java
@@ -0,0 +1,64 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * SPI for components that can convert an arbitrary object to an
+ * ExternalReferenceSPI representing the value of that object. Used by
+ * implementations of {@link ReferenceService#register(Object, int, boolean)} to
+ * map arbitrary objects to ExternalReferenceSPI instances if encountered during
+ * the registration process. This SPI is only used if the boolean
+ * useConverterSPI parameter is set to true on that method.
+ * 
+ * @author Tom Oinn
+ */
+public interface ValueToReferenceConverterSPI {
+	/**
+	 * Can this SPI implementation convert the specified object to an
+	 * ExternalReferenceSPI? This test should be as lightweight as possible, and
+	 * will usually be based on the Class of the object supplied.
+	 * 
+	 * @param context
+	 *            a ReferenceContext to use if required by the plugin, the
+	 *            ability to convert should be interpreted in the scope of this
+	 *            context. In general the context probably not used by most
+	 *            implementations but it's here if required.
+	 * 
+	 * @return whether this converter is applicable to the specified object
+	 */
+	boolean canConvert(Object o, ReferenceContext context);
+
+	/**
+	 * Construct and return a new ExternalReferenceSPI implementation which is
+	 * in some way equivalent to the supplied object. This is not intended to be
+	 * a two-way process necessarily, although the conversion should attempt to
+	 * be conservative (so not actually changing the data!).
+	 * 
+	 * @param context
+	 *            a ReferenceContext to use, if required, during construction of
+	 *            the new external reference
+	 * @return A new instance of ExternalReferenceSPI which references, as far
+	 *         as possible, the value represented by the specified object
+	 * @throws ValueToReferenceConversionException
+	 *             if any problem occurs during the conversion
+	 */
+	ExternalReferenceSPI convert(Object o, ReferenceContext context)
+			throws ValueToReferenceConversionException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/WorkflowRunIdEntity.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/WorkflowRunIdEntity.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/WorkflowRunIdEntity.java
new file mode 100644
index 0000000..126fa0b
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/WorkflowRunIdEntity.java
@@ -0,0 +1,43 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * Entity that wraps workflow run id and can be passed through (
+ * {@link ReferenceContext} to be used by {@link T2ReferenceGenerator} to
+ * generate references that are specific for a workflow run.
+ * 
+ * @author Alex Nenadic
+ */
+public class WorkflowRunIdEntity {
+	private String workflowRunId;
+
+	public WorkflowRunIdEntity(String workflowRunId) {
+		this.setWorkflowRunId(workflowRunId);
+	}
+
+	public void setWorkflowRunId(String workflowRunId) {
+		this.workflowRunId = workflowRunId;
+	}
+
+	public String getWorkflowRunId() {
+		return workflowRunId;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/annotations/DeleteIdentifiedOperation.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/annotations/DeleteIdentifiedOperation.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/annotations/DeleteIdentifiedOperation.java
new file mode 100644
index 0000000..5e821ba
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/annotations/DeleteIdentifiedOperation.java
@@ -0,0 +1,37 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.annotations;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Applied to methods in Dao implementations which delete data in the backing
+ * store.
+ * 
+ * @author Stuart Owen
+ */
+@Retention(RUNTIME)
+@Target(METHOD)
+public @interface DeleteIdentifiedOperation {
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/annotations/GetIdentifiedOperation.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/annotations/GetIdentifiedOperation.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/annotations/GetIdentifiedOperation.java
new file mode 100644
index 0000000..eb34a5e
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/annotations/GetIdentifiedOperation.java
@@ -0,0 +1,37 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.annotations;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Applied to methods in Dao implementations which fetch data from the backing
+ * store by ID
+ * 
+ * @author Tom Oinn
+ */
+@Retention(RUNTIME)
+@Target(METHOD)
+public @interface GetIdentifiedOperation {
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/annotations/PutIdentifiedOperation.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/annotations/PutIdentifiedOperation.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/annotations/PutIdentifiedOperation.java
new file mode 100644
index 0000000..1cae928
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/annotations/PutIdentifiedOperation.java
@@ -0,0 +1,37 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.annotations;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Applied to methods in Dao implementations which store or update data in the
+ * backing store.
+ * 
+ * @author Tom Oinn
+ */
+@Retention(RUNTIME)
+@Target(METHOD)
+public @interface PutIdentifiedOperation {
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/annotations/package.html
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/annotations/package.html b/taverna-reference-api/src/main/java/org/apache/taverna/reference/annotations/package.html
new file mode 100644
index 0000000..0d38e1e
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/annotations/package.html
@@ -0,0 +1,4 @@
+<body>
+Annotations to make methods in the data access object implementations
+for cache injection.
+</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/h3/HibernateComponentClass.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/h3/HibernateComponentClass.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/h3/HibernateComponentClass.java
new file mode 100644
index 0000000..b0a59f1
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/h3/HibernateComponentClass.java
@@ -0,0 +1,37 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.h3;
+
+/**
+ * A marker used to denote that the class should be pre-loaded into hibernate's
+ * class mapping. Used for component classes which are not going to be mapped to
+ * the RDBMS but which must be loadable for mapped classes to instantiate
+ * correctly. Basically if you refer to a class that isn't itself going to be
+ * mapped in hibernate within a mapping definition you'll need to add that
+ * component class to this SPI or hibernate won't be able to find it as it won't
+ * know that it should associate it with the appropriate class loader.
+ * <p>
+ * This should be used as an SPI marker, and set as the first SPI registry in
+ * the preloadRegistries property of the SpiRegistryAwareLocalSessionFactoryBean
+ * 
+ * @author Tom Oinn
+ */
+public interface HibernateComponentClass {
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/h3/HibernateMappedEntity.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/h3/HibernateMappedEntity.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/h3/HibernateMappedEntity.java
new file mode 100644
index 0000000..c607e3d
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/h3/HibernateMappedEntity.java
@@ -0,0 +1,38 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.h3;
+
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceSet;
+
+/**
+ * A marker interface used to denote that the component should be registered
+ * with the Hibernate ORM system prior to any {@link ExternalReferenceSPI}
+ * implementations. This is here to allow implementations of e.g.
+ * {@link ReferenceSet} to be in the implementation package where they belong
+ * and still guarantee that they are registered before any other plugins.
+ * <p>
+ * This should be used as an SPI marker, and set as the first SPI registry in
+ * the spiRegistries property of the SpiRegistryAwareLocalSessionFactoryBean
+ * 
+ * @author Tom Oinn
+ */
+public interface HibernateMappedEntity {
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/h3/package.html
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/h3/package.html b/taverna-reference-api/src/main/java/org/apache/taverna/reference/h3/package.html
new file mode 100644
index 0000000..4ffba14
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/h3/package.html
@@ -0,0 +1,8 @@
+<body>
+Contains the marker interfaces used by the implementation package to
+ensure that all appropriate classes are mapped in hibernate
+<em>before</em>
+implementations of classes that depend upon them, and to ensure that
+'static' classes such as the implementations of reference set etc are
+mapped correctly.
+</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/package.html
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/package.html b/taverna-reference-api/src/main/java/org/apache/taverna/reference/package.html
new file mode 100644
index 0000000..503dc3b
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/package.html
@@ -0,0 +1,43 @@
+<body>
+<p>Interfaces for the Taverna 2 reference manager. This replaces the
+(badly named) DataManager and is, in effect, a version 2 of that system.
+While these APIs are implementation neutral the intent is heavily
+towards the use of an object relational mapping (ORM) tool such as
+Hibernate backed by a relational database to hold the various
+collection, external reference and error documents managed by the
+reference manager.</p>
+<p>For those familiar with the previous DataManager code the table
+below shows the old class names and the equivalent (where appropriate)
+in the new code:
+</p>
+<table>
+	<tr>
+		<td>DataDocument</td>
+		<td>{@link net.sf.taverna.t2.reference.ReferenceSet}</td>
+	</tr>
+	<tr>
+		<td>ReferenceScheme</td>
+		<td>{@link net.sf.taverna.t2.reference.ExternalReferenceSPI}</td>
+	</tr>
+	<tr>
+		<td>EntityIdentifier</td>
+		<td>{@link net.sf.taverna.t2.reference.T2Reference}</td>
+	</tr>
+	<tr>
+		<td colspan="2">...</td>
+	</tr>
+</table>
+<p>One fundamental change is a move to runtime exceptions rather
+than checked exceptions. This follows the pattern used by Spring and
+Hibernate. The rationale is the same as in those systems - in general
+checked exceptions are not handled properly by client code. The loss of
+compiler level functionality from moving to runtime exceptions is
+countered by much higher readability of code which in itself leads to
+more robust and reliable systems.</p>
+<p>A second change is the availability of asynchronous versions of
+all the critical APIs. Reference construction or translation in
+particular can be a costly process taking substantial time to complete.
+Synchronous versions of the get methods still exist but in general the
+simple callback based asynchronous ones are recommended over them for
+most applications.</p>
+</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/resources/net/sf/taverna/t2/reference/AbstractExternalReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/resources/net/sf/taverna/t2/reference/AbstractExternalReference.hbm.xml b/taverna-reference-api/src/main/resources/net/sf/taverna/t2/reference/AbstractExternalReference.hbm.xml
deleted file mode 100644
index e8851e9..0000000
--- a/taverna-reference-api/src/main/resources/net/sf/taverna/t2/reference/AbstractExternalReference.hbm.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
-                "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-                "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!-- Hibernate mapping for the abstract superclass of -->
-<!-- ExternalReferenceSPI implementations             -->
-<hibernate-mapping>
-	<class name="net.sf.taverna.t2.reference.AbstractExternalReference"
-		abstract="true">
-		<!-- Let hibernate choose the primary key generation strategy -->
-		<id name="primaryKey" unsaved-value="0" column="bean_id">
-			<generator class="native" />
-		</id>
-	</class>
-</hibernate-mapping>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/resources/org/apache/taverna/reference/AbstractExternalReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/resources/org/apache/taverna/reference/AbstractExternalReference.hbm.xml b/taverna-reference-api/src/main/resources/org/apache/taverna/reference/AbstractExternalReference.hbm.xml
new file mode 100644
index 0000000..c73b273
--- /dev/null
+++ b/taverna-reference-api/src/main/resources/org/apache/taverna/reference/AbstractExternalReference.hbm.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Hibernate mapping for the abstract superclass of -->
+<!-- ExternalReferenceSPI implementations             -->
+<hibernate-mapping>
+  <class abstract="true" name="org.apache.taverna.reference.AbstractExternalReference">
+    <!-- Let hibernate choose the primary key generation strategy -->
+    <id column="bean_id" name="primaryKey" unsaved-value="0">
+      <generator class="native"/>
+    </id>
+  </class>
+</hibernate-mapping>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/platform/spring/jdbc/TemporaryJDBC.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/platform/spring/jdbc/TemporaryJDBC.java b/taverna-reference-impl/src/main/java/net/sf/taverna/platform/spring/jdbc/TemporaryJDBC.java
deleted file mode 100644
index d041320..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/platform/spring/jdbc/TemporaryJDBC.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.platform.spring.jdbc;
-
-import static java.io.File.createTempFile;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * Create JDBC connection strings for temporary use (ie. from tests)
- * <p>
- * {@link #getTemporaryDerbyJDBC()} creates a temporary directory that is used
- * to construct the JDBC connection string for a local Derby database.
- * </p>
- * <p>
- * This is most useful from a spring configuration, for example when using
- * {@link InterpolatingDriverManagerDataSource}:
- * </p>
- * 
- * <pre>
- * &lt;!-- Apache Derby rooted at a temporary directory --&gt;
- *  &lt;bean id=&quot;t2reference.jdbc.temporaryjdbc&quot;
- *  class=&quot;net.sf.taverna.platform.spring.jdbc.TemporaryJDBC&quot;&gt;
- *  &lt;/bean&gt;
- *  &lt;bean id=&quot;t2reference.jdbc.url&quot; class=&quot;java.lang.String&quot;
- *  factory-bean=&quot;t2reference.jdbc.temporaryjdbc&quot;
- *  factory-method=&quot;getTemporaryDerbyJDBC&quot; /&gt;
- *  &lt;bean id=&quot;t2reference.jdbc.datasource&quot;
- *  class=&quot;net.sf.taverna.platform.spring.jdbc.InterpolatingDriverManagerDataSource&quot;&gt;
- *  &lt;property name=&quot;driverClassName&quot;&gt;
- *  &lt;value&gt;org.apache.derby.jdbc.EmbeddedDriver&lt;/value&gt;
- *  &lt;/property&gt;
- *  &lt;property name=&quot;url&quot;&gt;
- *  &lt;ref bean=&quot;t2reference.jdbc.url&quot; /&gt;
- *  &lt;/property&gt;
- *  &lt;property name=&quot;repository&quot;&gt;
- *  &lt;ref bean=&quot;raven.repository&quot; /&gt;
- *  &lt;/property&gt;
- *  &lt;property name=&quot;driverArtifact&quot;&gt;
- *  &lt;value&gt;org.apache.derby:derby:10.4.1.3&lt;/value&gt;
- *  &lt;/property&gt;
- *  &lt;/bean&gt;
- * </pre>
- * 
- * @author Stian Soiland-Reyes
- */
-public class TemporaryJDBC {
-	public String getTemporaryDerbyJDBC() throws IOException {
-		File tmpDir = createTempFile("t2platform-", ".db");
-		tmpDir.delete();
-		if (!tmpDir.mkdir())
-			throw new IOException("Could not create temporary directory "
-					+ tmpDir);
-		return "jdbc:derby:" + tmpDir.getPath() + "/database;create=true";
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/platform/spring/jdbc/package.html
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/platform/spring/jdbc/package.html b/taverna-reference-impl/src/main/java/net/sf/taverna/platform/spring/jdbc/package.html
deleted file mode 100644
index 2355a14..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/platform/spring/jdbc/package.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<body>
-Extensions to the JDBC parts of Spring, and support for proxying of JDBC 
-drivers so we can load them dynamically from raven artifacts. The proxy 
-approach is inspired by http://www.jroller.com/tackline/entry/dynamically_loading_jdbc_drivers 
-with additions to build from raven rather than from existing jar files.
-</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractEntityImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractEntityImpl.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractEntityImpl.java
deleted file mode 100644
index 8559607..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractEntityImpl.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import net.sf.taverna.t2.reference.T2Reference;
-
-/**
- * Abstract superclass of ReferenceSetImpl, IdentifiedArrayList and
- * ErrorDocumentImpl, manages the T2Reference field for these types and their
- * hibernate backing.
- * 
- * @author Tom Oinn
- */
-public class AbstractEntityImpl {
-	private T2ReferenceImpl id;
-	private String compactId = null;
-
-	public T2Reference getId() {
-		return id;
-	}
-
-	/**
-	 * This method is only ever called from within Hibernate, and is used to
-	 * initialize the unique ID of this reference set.
-	 */
-	public void setTypedId(T2ReferenceImpl newId) {
-		id = newId;
-	}
-
-	/**
-	 * Used because technically you can't accept and return implementation types
-	 * in the methods on a bean which implements an interface, but Hibernate
-	 * needs to construct concrete input and output types!
-	 */
-	public T2ReferenceImpl getTypedId() {
-		return id;
-	}
-
-	public void setInternalId(String newId) {
-		compactId = newId;
-	}
-
-	public final String getInternalId() {
-		if (compactId == null)
-			compactId = id.getCompactForm();
-		return compactId;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractErrorDocumentServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractErrorDocumentServiceImpl.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractErrorDocumentServiceImpl.java
deleted file mode 100644
index ccabf5a..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractErrorDocumentServiceImpl.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import net.sf.taverna.t2.reference.DaoException;
-import net.sf.taverna.t2.reference.ErrorDocument;
-import net.sf.taverna.t2.reference.ErrorDocumentDao;
-import net.sf.taverna.t2.reference.ErrorDocumentService;
-import net.sf.taverna.t2.reference.ErrorDocumentServiceCallback;
-import net.sf.taverna.t2.reference.ErrorDocumentServiceException;
-import net.sf.taverna.t2.reference.ListServiceException;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.T2ReferenceGenerator;
-
-/**
- * Abstract implementation of ErrorDocumentService, inject with an appropriate
- * ErrorDocumentDao and T2ReferenceGenerator to enable. Contains injectors for
- * id generation and dao along with other bookkeeping, leaving the
- * implementation of the actual service logic to the subclass.
- * 
- * @author Tom Oinn
- */
-public abstract class AbstractErrorDocumentServiceImpl extends
-		AbstractServiceImpl implements ErrorDocumentService {
-	protected ErrorDocumentDao errorDao = null;
-	protected T2ReferenceGenerator t2ReferenceGenerator = null;
-
-	/**
-	 * Inject the error document data access object.
-	 */
-	public final void setErrorDao(ErrorDocumentDao dao) {
-		errorDao = dao;
-	}
-
-	/**
-	 * Inject the T2Reference generator used to allocate new IDs when
-	 * registering ErrorDocuments
-	 */
-	public final void setT2ReferenceGenerator(T2ReferenceGenerator t2rg) {
-		t2ReferenceGenerator = t2rg;
-	}
-
-	/**
-	 * Check that the list dao is configured
-	 * 
-	 * @throws ListServiceException
-	 *             if the dao is still null
-	 */
-	protected final void checkDao() throws ErrorDocumentServiceException {
-		if (errorDao == null)
-			throw new ErrorDocumentServiceException(
-					"ErrorDocumentDao not initialized, error document "
-							+ "service operations are not available");
-	}
-
-	/**
-	 * Check that the t2reference generator is configured
-	 * 
-	 * @throws ListServiceException
-	 *             if the generator is still null
-	 */
-	protected final void checkGenerator() throws ErrorDocumentServiceException {
-		if (t2ReferenceGenerator == null)
-			throw new ErrorDocumentServiceException(
-					"T2ReferenceGenerator not initialized, error document "
-							+ "service operations not available");
-	}
-
-	@Override
-	public final void getErrorAsynch(final T2Reference id,
-			final ErrorDocumentServiceCallback callback)
-			throws ErrorDocumentServiceException {
-		checkDao();
-		Runnable r = new Runnable() {
-			@Override
-			public void run() {
-				try {
-					ErrorDocument e = errorDao.get(id);
-					callback.errorRetrieved(e);
-				} catch (DaoException de) {
-					callback.errorRetrievalFailed(new ErrorDocumentServiceException(
-							de));
-				}
-			}
-		};
-		executeRunnable(r);
-	}
-
-	@Override
-	public final ErrorDocument registerError(String message, int depth,
-			ReferenceContext context) throws ErrorDocumentServiceException {
-		return registerError(message, (Throwable) null, depth, context);
-	}
-
-	@Override
-	public final ErrorDocument registerError(Throwable t, int depth,
-			ReferenceContext context) throws ErrorDocumentServiceException {
-		return registerError("", t, depth, context);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractListServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractListServiceImpl.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractListServiceImpl.java
deleted file mode 100644
index ad564fb..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractListServiceImpl.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import net.sf.taverna.t2.reference.ListDao;
-import net.sf.taverna.t2.reference.ListService;
-import net.sf.taverna.t2.reference.ListServiceCallback;
-import net.sf.taverna.t2.reference.ListServiceException;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.T2ReferenceGenerator;
-
-/**
- * Abstract implementation of ListService, inject with an appropriate ListDao
- * and T2ReferenceGenerator to enable. Contains injectors for id generation and
- * dao along with other bookkeeping, leaving the implementation of the actual
- * service logic to the subclass.
- * 
- * @author Tom Oinn
- * 
- */
-public abstract class AbstractListServiceImpl extends AbstractServiceImpl
-		implements ListService {
-	protected ListDao listDao = null;
-	protected T2ReferenceGenerator t2ReferenceGenerator = null;
-
-	/**
-	 * Inject the list data access object.
-	 */
-	public final void setListDao(ListDao dao) {
-		listDao = dao;
-	}
-
-	/**
-	 * Inject the T2Reference generator used to allocate new IDs when
-	 * registering lists of T2Reference
-	 */
-	public final void setT2ReferenceGenerator(T2ReferenceGenerator t2rg) {
-		t2ReferenceGenerator = t2rg;
-	}
-
-	/**
-	 * Check that the list dao is configured
-	 * 
-	 * @throws ListServiceException
-	 *             if the dao is still null
-	 */
-	protected final void checkDao() throws ListServiceException {
-		if (listDao == null)
-			throw new ListServiceException("ListDao not initialized, list "
-					+ "service operations are not available");
-	}
-
-	/**
-	 * Check that the t2reference generator is configured
-	 * 
-	 * @throws ListServiceException
-	 *             if the generator is still null
-	 */
-	protected final void checkGenerator() throws ListServiceException {
-		if (t2ReferenceGenerator == null)
-			throw new ListServiceException(
-					"T2ReferenceGenerator not initialized, list "
-							+ "service operations not available");
-	}
-
-	@Override
-	public final void getListAsynch(final T2Reference id,
-			final ListServiceCallback callback) throws ListServiceException {
-		checkDao();
-		Runnable r = new Runnable() {
-			@Override
-			public void run() {
-				try {
-					callback.listRetrieved(getList(id));
-				} catch (ListServiceException lse) {
-					callback.listRetrievalFailed(lse);
-				}
-			}
-		};
-		executeRunnable(r);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractReferenceServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractReferenceServiceImpl.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractReferenceServiceImpl.java
deleted file mode 100644
index 3ef8e9b..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractReferenceServiceImpl.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import java.util.List;
-import java.util.Set;
-
-import net.sf.taverna.t2.reference.ErrorDocumentService;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ListService;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferenceService;
-import net.sf.taverna.t2.reference.ReferenceServiceException;
-import net.sf.taverna.t2.reference.ReferenceServiceResolutionCallback;
-import net.sf.taverna.t2.reference.ReferenceSetService;
-import net.sf.taverna.t2.reference.StreamToValueConverterSPI;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.ValueToReferenceConverterSPI;
-
-/**
- * Implementation of ReferenceService, inject with ReferenceSetService,
- * ErrorDocumentService and ListService to enable. Inject with an instance
- * registry of ValueToReferenceConvertorSPI to enable on the fly registration of
- * otherwise illegal object types. This class contains the basic injection
- * functionality and the getters for the sub-services, mostly to isolate these
- * mundane bits of code from the more interesting actual implementation of the
- * reference service logic.
- * 
- * @author Tom Oinn
- */
-public abstract class AbstractReferenceServiceImpl extends AbstractServiceImpl
-		implements ReferenceService {
-	protected ErrorDocumentService errorDocumentService = null;
-	protected ReferenceSetService referenceSetService = null;
-	protected ListService listService = null;
-	protected List<ValueToReferenceConverterSPI> converters = null;
-	@SuppressWarnings("rawtypes")
-	protected List<StreamToValueConverterSPI> valueBuilders = null;
-
-	/**
-	 * Inject value to reference convertor SPI
-	 */
-	public final void setConverters(
-			List<ValueToReferenceConverterSPI> converters) {
-		this.converters = converters;
-	}
-
-	/**
-	 * Inject stream to value converter SPI
-	 */
-	@SuppressWarnings("rawtypes")
-	public final void setValueBuilders(
-			List<StreamToValueConverterSPI> valueBuilders) {
-		this.valueBuilders = valueBuilders;
-	}
-
-	/**
-	 * Inject error document service
-	 */
-	public final void setErrorDocumentService(ErrorDocumentService eds) {
-		this.errorDocumentService = eds;
-	}
-
-	/**
-	 * Inject reference set service
-	 */
-	public final void setReferenceSetService(ReferenceSetService rss) {
-		this.referenceSetService = rss;
-	}
-
-	/**
-	 * Inject list service
-	 */
-	public final void setListService(ListService ls) {
-		this.listService = ls;
-	}
-
-	/**
-	 * Throw a ReferenceServiceException if methods in ReferenceService are
-	 * called without the necessary sub-services configured.
-	 */
-	protected final void checkServices() throws ReferenceServiceException {
-		if (errorDocumentService == null)
-			throw new ReferenceServiceException(
-					"Reference service must be configued with an "
-							+ "instance of ErrorDocumentService to function");
-		if (referenceSetService == null)
-			throw new ReferenceServiceException(
-					"Reference service must be configued with an "
-							+ "instance of ReferenceSetService to function");
-		if (listService == null)
-			throw new ReferenceServiceException(
-					"Reference service must be configued with an "
-							+ "instance of ListService to function");
-	}
-
-	/**
-	 * Check whether the converter registry has been defined, throw a
-	 * ReferenceServiceException if not
-	 */
-	protected final void checkConverterRegistry()
-			throws ReferenceServiceException {
-		if (converters == null)
-			throw new ReferenceServiceException(
-					"Reference service must be configued with an "
-							+ "instance registry of ValueToReferenceConvertorSPI "
-							+ "to enable on the fly mapping of arbitrary objects "
-							+ "during compound registration");
-	}
-
-	@Override
-	public final ErrorDocumentService getErrorDocumentService() {
-		checkServices();
-		return this.errorDocumentService;
-	}
-
-	@Override
-	public final ListService getListService() {
-		checkServices();
-		return this.listService;
-	}
-
-	@Override
-	public final ReferenceSetService getReferenceSetService() {
-		checkServices();
-		return this.referenceSetService;
-	}
-
-	/**
-	 * Wraps the synchronous form, using the executeRunnable method to schedule
-	 * it.
-	 */
-	@Override
-	public void resolveIdentifierAsynch(final T2Reference id,
-			final Set<Class<ExternalReferenceSPI>> ensureTypes,
-			final ReferenceContext context,
-			final ReferenceServiceResolutionCallback callback)
-			throws ReferenceServiceException {
-		checkServices();
-		Runnable r = new Runnable() {
-			@Override
-			public void run() {
-				try {
-					callback.identifierResolved(resolveIdentifier(id,
-							ensureTypes, context));
-				} catch (ReferenceServiceException rse) {
-					callback.resolutionFailed(rse);
-				}
-			}
-		};
-		executeRunnable(r);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractReferenceSetServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractReferenceSetServiceImpl.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractReferenceSetServiceImpl.java
deleted file mode 100644
index 9c930a5..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractReferenceSetServiceImpl.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import java.util.Set;
-
-import net.sf.taverna.t2.reference.DaoException;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferenceSet;
-import net.sf.taverna.t2.reference.ReferenceSetAugmentor;
-import net.sf.taverna.t2.reference.ReferenceSetDao;
-import net.sf.taverna.t2.reference.ReferenceSetService;
-import net.sf.taverna.t2.reference.ReferenceSetServiceCallback;
-import net.sf.taverna.t2.reference.ReferenceSetServiceException;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.T2ReferenceGenerator;
-
-/**
- * Abstract implementation of ReferenceSetService, inject with an appropriate
- * ReferenceSetDao to enable. Implements translation functionality as long as an
- * appropriate ReferenceSetAugmentor implementation is injected. Contains
- * injectors for id generation and dao along with other bookkeeping, leaving the
- * implementation of the actual service logic to the subclass.
- * 
- * @author Tom Oinn
- */
-public abstract class AbstractReferenceSetServiceImpl extends
-		AbstractServiceImpl implements ReferenceSetService {
-	protected ReferenceSetDao referenceSetDao = null;
-	protected T2ReferenceGenerator t2ReferenceGenerator = null;
-	protected ReferenceSetAugmentor referenceSetAugmentor = null;
-
-	/**
-	 * Inject the reference set data access object.
-	 */
-	public final void setReferenceSetDao(ReferenceSetDao dao) {
-		this.referenceSetDao = dao;
-	}
-
-	/**
-	 * Inject the T2Reference generator used to allocate new IDs when
-	 * registering sets of ExternalReferenceSPI
-	 */
-	public final void setT2ReferenceGenerator(T2ReferenceGenerator t2rg) {
-		this.t2ReferenceGenerator = t2rg;
-	}
-
-	/**
-	 * Inject the ReferenceSetAugmentor used to translate or construct new
-	 * ExternalReferenceSPI instances within a ReferenceSet
-	 */
-	public final void setReferenceSetAugmentor(ReferenceSetAugmentor rse) {
-		this.referenceSetAugmentor = rse;
-	}
-
-	/**
-	 * Check that the reference set dao is configured
-	 * 
-	 * @throws ReferenceSetServiceException
-	 *             if the dao is still null
-	 */
-	protected final void checkDao() throws ReferenceSetServiceException {
-		if (referenceSetDao == null)
-			throw new ReferenceSetServiceException(
-					"ReferenceSetDao not initialized, reference set "
-							+ "service operations are not available");
-	}
-
-	/**
-	 * Check that the t2reference generator is configured
-	 * 
-	 * @throws ReferenceSetServiceException
-	 *             if the generator is still null
-	 */
-	protected final void checkGenerator() throws ReferenceSetServiceException {
-		if (t2ReferenceGenerator == null)
-			throw new ReferenceSetServiceException(
-					"T2ReferenceGenerator not initialized, reference "
-							+ "set service operations not available");
-	}
-
-	/**
-	 * Check that the reference set augmentor is configured
-	 * 
-	 * @throws ReferenceSetServiceException
-	 *             if the reference set augmentor is still null
-	 */
-	protected final void checkAugmentor() throws ReferenceSetServiceException {
-		if (referenceSetAugmentor == null)
-			throw new ReferenceSetServiceException(
-					"ReferenceSetAugmentor not initialized, reference "
-							+ "set service operations not available");
-	}
-
-	@Override
-	public final void getReferenceSetAsynch(final T2Reference id,
-			final ReferenceSetServiceCallback callback)
-			throws ReferenceSetServiceException {
-		checkDao();
-		Runnable r = new Runnable() {
-			@Override
-			public void run() {
-				try {
-					ReferenceSet rs = referenceSetDao.get(id);
-					callback.referenceSetRetrieved(rs);
-				} catch (DaoException de) {
-					callback.referenceSetRetrievalFailed(new ReferenceSetServiceException(
-							de));
-				}
-			}
-		};
-		executeRunnable(r);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public final void getReferenceSetWithAugmentationAsynch(
-			final T2Reference id,
-			final Set<Class<ExternalReferenceSPI>> ensureTypes,
-			final ReferenceContext context,
-			final ReferenceSetServiceCallback callback)
-			throws ReferenceSetServiceException {
-		checkDao();
-		checkAugmentor();
-		Runnable r = new Runnable() {
-			@Override
-			public void run() {
-				try {
-					callback.referenceSetRetrieved(getReferenceSetWithAugmentation(
-							id, ensureTypes, context));
-				} catch (ReferenceSetServiceException rsse) {
-					callback.referenceSetRetrievalFailed(rsse);
-				}
-			}
-		};
-		executeRunnable(r);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractServiceImpl.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractServiceImpl.java
deleted file mode 100644
index c24981e..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractServiceImpl.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-/**
- * Abstract superclass for all service implementation objects, will be used to
- * allow injection of thread pooling logic as and when we implement it.
- * 
- * @author Tom Oinn
- */
-public class AbstractServiceImpl {
-	/**
-	 * Schedule a runnable for execution - current naive implementation uses a
-	 * new thread and executes immediately, but this is where any thread pool
-	 * logic would go if we wanted to add that.
-	 * 
-	 * @param r
-	 */
-	protected void executeRunnable(Runnable r) {
-		makeExecutionThread(r).start();
-	}
-
-	protected Thread makeExecutionThread(Runnable r) {
-		return new Thread(r);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractT2ReferenceGenerator.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractT2ReferenceGenerator.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractT2ReferenceGenerator.java
deleted file mode 100644
index dedcc67..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/AbstractT2ReferenceGenerator.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import static net.sf.taverna.t2.reference.T2ReferenceType.ErrorDocument;
-import static net.sf.taverna.t2.reference.T2ReferenceType.IdentifiedList;
-import static net.sf.taverna.t2.reference.T2ReferenceType.ReferenceSet;
-
-import java.util.List;
-
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.T2ReferenceGenerator;
-import net.sf.taverna.t2.reference.WorkflowRunIdEntity;
-
-/**
- * An abstract class for implementing simple {@link T2ReferenceGenerator}s.
- * 
- * @author Stian Soiland-Reyes
- */
-public abstract class AbstractT2ReferenceGenerator implements
-		T2ReferenceGenerator {
-	public AbstractT2ReferenceGenerator() {
-		super();
-	}
-
-	private void initReferenceNamespace(T2ReferenceImpl r, ReferenceContext context) {
-		if (context == null) {
-			// this is not good, just use the default namespace
-			r.setNamespacePart(getNamespace());
-			return;
-		}
-
-		List<WorkflowRunIdEntity> workflowRunIdEntities = context
-				.getEntities(WorkflowRunIdEntity.class);
-		if (workflowRunIdEntities == null || workflowRunIdEntities.isEmpty()) {
-			// this is not good, just use the default namespace
-			r.setNamespacePart(getNamespace());
-			return;
-		}
-
-		// there should be only one wf run id entity
-		String workflowRunId = ((WorkflowRunIdEntity) workflowRunIdEntities
-				.get(0)).getWorkflowRunId();
-		r.setNamespacePart(workflowRunId);
-	}
-
-	@Override
-	public synchronized T2Reference nextReferenceSetReference(
-			ReferenceContext context) {
-		T2ReferenceImpl r = new T2ReferenceImpl();
-		initReferenceNamespace(r, context);
-		r.setLocalPart(getNextLocalPart());
-		r.setReferenceType(ReferenceSet);
-		r.setDepth(0);
-		r.setContainsErrors(false);
-		return r;
-	}
-
-	/**
-	 * Generate a new local part for a new {@link T2Reference reference}. The
-	 * local part should be unique within this
-	 * {@link T2ReferenceGenerator#getNamespace() namespace}.
-	 * 
-	 * @return A new, unique local part to identify a new reference.
-	 */
-	protected abstract String getNextLocalPart();
-
-	@Override
-	public T2Reference nextListReference(boolean containsErrors, int listDepth,
-			ReferenceContext context) {
-		T2ReferenceImpl r = new T2ReferenceImpl();
-		initReferenceNamespace(r, context);
-		r.setLocalPart(getNextLocalPart());
-		r.setReferenceType(IdentifiedList);
-		r.setDepth(listDepth);
-		r.setContainsErrors(containsErrors);
-		return r;
-	}
-
-	@Override
-	public T2Reference nextErrorDocumentReference(int depth,
-			ReferenceContext context) {
-		T2ReferenceImpl r = new T2ReferenceImpl();
-		initReferenceNamespace(r, context);
-		r.setLocalPart(getNextLocalPart());
-		r.setReferenceType(ErrorDocument);
-		r.setDepth(depth);
-		// This is an error document, it contains errors by definition
-		r.setContainsErrors(true);
-		return r;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/CacheAspect.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/CacheAspect.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/CacheAspect.java
deleted file mode 100644
index 59b5e04..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/CacheAspect.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import net.sf.taverna.t2.reference.DaoException;
-import net.sf.taverna.t2.reference.Identified;
-import net.sf.taverna.t2.reference.ReferenceServiceCacheProvider;
-import net.sf.taverna.t2.reference.T2Reference;
-
-import org.aspectj.lang.ProceedingJoinPoint;
-
-/**
- * An aspect used to intercept calls to the various data access objects and
- * divert through a write-through cache provider
- * 
- * @author Tom Oinn
- */
-public class CacheAspect {
-	private ReferenceServiceCacheProvider cacheProvider;
-
-	/**
-	 * Return an injected ReferenceServiceCacheProvider
-	 */
-	private final ReferenceServiceCacheProvider getCacheProvider() {
-		return cacheProvider;
-	}
-
-	/**
-	 * Inject an instance of ReferenceServiceCacheProvider
-	 * 
-	 * @param cacheProvider
-	 *            the cache provider to use
-	 */
-	public final void setCacheProvider(
-			final ReferenceServiceCacheProvider cacheProvider) {
-		this.cacheProvider = cacheProvider;
-	}
-
-	/**
-	 * Handle a 'get by T2Reference' operation on a Dao
-	 * 
-	 * @param pjp
-	 *            the join point representing the ongoing method call to the dao
-	 * @return the entity identified by the T2Reference supplied to the method
-	 *         to which this advice applies
-	 * @throws DaoException
-	 *             if anything goes wrong
-	 */
-	public final Identified getObject(final ProceedingJoinPoint pjp)
-			throws DaoException {
-		Identified result = null;
-
-		// Get the T2Reference from the argument to the get method
-		T2Reference id = (T2Reference) pjp.getArgs()[0];
-		if (id != null) {
-			result = getCacheProvider().get(id);
-			if (result != null)
-				return result;
-		}
-		// If we miss the cache then call the method as usual
-		try {
-			result = (Identified) pjp.proceed();
-		} catch (DaoException e) {
-			throw e;
-		} catch (Throwable e) {
-			throw new DaoException("Unexpected exception type during aspect "
-					+ "based invocation", e);
-		}
-
-		// Write back to the cache
-		if (result != null)
-			getCacheProvider().put(result);
-
-		return result;
-	}
-
-	/**
-	 * Called around a write or update operation on the backing store, writes
-	 * through to the cache after modifying the state of the backing store and
-	 * before returning from the dao method
-	 * 
-	 * @param pjp
-	 *            join point representing the ongoing method invocation to cache
-	 * @throws DaoException
-	 *             if anything goes wrong
-	 */
-	public void putObject(final ProceedingJoinPoint pjp) throws DaoException {
-		// Get the Identified being stored by the method we're advising
-		Identified storedObject = (Identified) pjp.getArgs()[0];
-
-		try {
-			// Run the store or update method
-			pjp.proceed();
-		} catch (DaoException e) {
-			throw e;
-		} catch (Throwable e) {
-			throw new DaoException("Unexpected exception type during aspect "
-					+ "based invocation", e);
-		}
-
-		/*
-		 * Assuming the method isn't null and has an identifier (which it will
-		 * if we haven't thrown an exception before now) write it back to the
-		 * cache provider
-		 */
-		if (storedObject != null && storedObject.getId() != null)
-			getCacheProvider().put(storedObject);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ContextualizedT2ReferenceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ContextualizedT2ReferenceImpl.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ContextualizedT2ReferenceImpl.java
deleted file mode 100644
index 30d8492..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ContextualizedT2ReferenceImpl.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import net.sf.taverna.t2.reference.ContextualizedT2Reference;
-import net.sf.taverna.t2.reference.T2Reference;
-
-/**
- * Simple implementation of ContextualizedT2Reference
- * 
- * @author Tom Oinn
- */
-public class ContextualizedT2ReferenceImpl implements ContextualizedT2Reference {
-	private T2Reference reference;
-	private int[] index;
-
-	public ContextualizedT2ReferenceImpl(T2Reference ref, int[] context) {
-		this.reference = ref;
-		this.index = context;
-	}
-
-	@Override
-	public int[] getIndex() {
-		return this.index;
-	}
-
-	@Override
-	public T2Reference getReference() {
-		return this.reference;
-	}
-
-	@Override
-	public String toString() {
-		StringBuilder sb = new StringBuilder("[");
-		String sep = "";
-		for (int idx : index) {
-			sb.append(sep).append(idx);
-			sep = ",";
-		}
-		return sb.append("]").append(reference).toString();
-	}
-	
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/EmptyReferenceContext.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/EmptyReferenceContext.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/EmptyReferenceContext.java
deleted file mode 100644
index 6af0430..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/EmptyReferenceContext.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sf.taverna.t2.reference.ReferenceContext;
-
-/**
- * A trivial implementation of ReferenceContext, used if the context parameter
- * to any service method is null.
- * 
- * @author Tom Oinn
- */
-public class EmptyReferenceContext implements ReferenceContext {
-	/**
-	 * Return an empty entity set for all queries.
-	 */
-	@Override
-	public <T> List<T> getEntities(Class<T> arg0) {
-		return new ArrayList<>();
-	}
-
-	@Override
-	public void addEntity(Object entity) {
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ErrorDocumentImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ErrorDocumentImpl.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ErrorDocumentImpl.java
deleted file mode 100644
index da00d59..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ErrorDocumentImpl.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import net.sf.taverna.t2.reference.ErrorDocument;
-import net.sf.taverna.t2.reference.StackTraceElementBean;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.h3.HibernateMappedEntity;
-
-/**
- * Simple bean implementation of ErrorDocument
- * 
- * @author Tom Oinn
- */
-public class ErrorDocumentImpl extends AbstractEntityImpl implements
-		ErrorDocument, HibernateMappedEntity {
-	private String exceptionMessage = "";
-	private String message = "";
-	List<StackTraceElementBean> stackTrace;
-	Set<T2Reference> errorReferences = new HashSet<>();
-	
-	public ErrorDocumentImpl() {
-		this.stackTrace = new ArrayList<>();
-	}
-
-	@Override
-	public String getExceptionMessage() {
-		return this.exceptionMessage;
-	}
-
-	public void setExceptionMessage(String exceptionMessage) {
-		this.exceptionMessage = exceptionMessage;
-	}
-
-	@Override
-	public String getMessage() {
-		return this.message;
-	}
-
-	public void setMessage(String message) {
-		this.message = message;
-	}
-
-	/**
-	 * From interface, not used by hibernate internally
-	 */
-	@Override
-	public List<StackTraceElementBean> getStackTraceStrings() {
-		return this.stackTrace;
-	}
-
-	/**
-	 * Used by Hibernate to bodge around problems with interface types in the
-	 * API
-	 */
-	@SuppressWarnings({ "unchecked", "rawtypes" })
-	public void setStackTraceList(List newList) {
-		this.stackTrace = newList;
-	}
-
-	/**
-	 * Used by Hibernate to bodge around problems with interface types in the
-	 * API
-	 */
-	@SuppressWarnings("rawtypes")
-	public List getStackTraceList() {
-		return this.stackTrace;
-	}
-
-	@Override
-	public Set<T2Reference> getErrorReferences() {
-		return errorReferences;
-	}
-
-	/**
-	 * Used by Hibernate to bodge around problems with interface types in the
-	 * API
-	 */
-	@SuppressWarnings({ "unchecked", "rawtypes" })
-	public void setErrorReferenceSet(Set errorReferenceSet) {
-		this.errorReferences = errorReferenceSet;
-	}
-	
-	/**
-	 * Used by Hibernate to bodge around problems with interface types in the
-	 * API
-	 */
-	@SuppressWarnings("rawtypes")
-	public Set getErrorReferenceSet() {
-		return this.errorReferences;
-	}
-	
-	@Override
-	public String toString() {
-		return getMessage();
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ErrorDocumentServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ErrorDocumentServiceImpl.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ErrorDocumentServiceImpl.java
deleted file mode 100644
index 1e78f92..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ErrorDocumentServiceImpl.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import static net.sf.taverna.t2.reference.impl.T2ReferenceImpl.getAsImpl;
-
-import java.util.Set;
-
-import net.sf.taverna.t2.reference.ErrorDocument;
-import net.sf.taverna.t2.reference.ErrorDocumentService;
-import net.sf.taverna.t2.reference.ErrorDocumentServiceException;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferenceServiceException;
-import net.sf.taverna.t2.reference.T2Reference;
-
-/**
- * Implementation of ErrorDocumentService, inject with an appropriate
- * ErrorDocumentDao and T2ReferenceGenerator to enable.
- * 
- * @author Tom Oinn
- */
-public class ErrorDocumentServiceImpl extends AbstractErrorDocumentServiceImpl
-		implements ErrorDocumentService {
-	@Override
-	public ErrorDocument getError(T2Reference id)
-			throws ErrorDocumentServiceException {
-		checkDao();
-		try {
-			return errorDao.get(id);
-		} catch (Throwable t) {
-			throw new ErrorDocumentServiceException(t);
-		}
-	}
-
-	/**
-	 * Register the specified error and any child errors (which have the same
-	 * namespace and local part but a lower depth, down to depth of zero
-	 */
-	@Override
-	public ErrorDocument registerError(String message, Throwable t, int depth,
-			ReferenceContext context) throws ErrorDocumentServiceException {
-		checkDao();
-		checkGenerator();
-
-		T2Reference ref = t2ReferenceGenerator.nextErrorDocumentReference(
-				depth, context);
-		T2ReferenceImpl typedId = getAsImpl(ref);
-
-		ErrorDocument docToReturn = null;
-		for (; depth >= 0; depth--) {
-			ErrorDocumentImpl edi = new ErrorDocumentImpl();
-			if (docToReturn == null)
-				docToReturn = edi;
-			edi.setTypedId(typedId);
-			if (message != null)
-				edi.setMessage(message);
-			else
-				edi.setMessage("");
-			if (t != null) {
-				edi.setExceptionMessage(t.toString());
-				for (StackTraceElement ste : t.getStackTrace()) {
-					StackTraceElementBeanImpl stebi = new StackTraceElementBeanImpl();
-					stebi.setClassName(ste.getClassName());
-					stebi.setFileName(ste.getFileName());
-					stebi.setLineNumber(ste.getLineNumber());
-					stebi.setMethodName(ste.getMethodName());
-					edi.stackTrace.add(stebi);
-				}
-			} else
-				edi.setExceptionMessage("");
-			try {
-				errorDao.store(edi);
-			} catch (Throwable t2) {
-				throw new ErrorDocumentServiceException(t2);
-			}
-			if (depth > 0)
-				typedId = typedId.getDeeperErrorReference();
-		}
-		return docToReturn;
-	}
-
-	@Override
-	public ErrorDocument registerError(String message, Set<T2Reference> errors,
-			int depth, ReferenceContext context)
-			throws ErrorDocumentServiceException {
-		checkDao();
-		checkGenerator();
-
-		T2Reference ref = t2ReferenceGenerator.nextErrorDocumentReference(
-				depth, context);
-		T2ReferenceImpl typedId = T2ReferenceImpl.getAsImpl(ref);
-
-		ErrorDocument docToReturn = null;
-		for (; depth >= 0; depth--) {
-			ErrorDocumentImpl edi = new ErrorDocumentImpl();
-			if (docToReturn == null)
-				docToReturn = edi;
-			edi.setTypedId(typedId);
-			if (message != null)
-				edi.setMessage(message);
-			else
-				edi.setMessage("");
-			if (errors != null)
-				edi.setErrorReferenceSet(errors);
-			edi.setExceptionMessage("");
-
-			try {
-				errorDao.store(edi);
-			} catch (Throwable t2) {
-				throw new ErrorDocumentServiceException(t2);
-			}
-			if (depth > 0)
-				typedId = typedId.getDeeperErrorReference();
-		}
-		return docToReturn;
-	}
-
-	@Override
-	public T2Reference getChild(T2Reference errorId)
-			throws ErrorDocumentServiceException {
-		T2ReferenceImpl refImpl = getAsImpl(errorId);
-		try {
-			return refImpl.getDeeperErrorReference();
-		} catch (Throwable t) {
-			throw new ErrorDocumentServiceException(t);
-		}
-	}
-
-	@Override
-	public boolean delete(T2Reference reference)
-			throws ReferenceServiceException {
-		checkDao();
-		ErrorDocument doc = errorDao.get(reference);
-		if (doc == null)
-			return false;
-		return errorDao.delete(doc);
-	}
-
-	@Override
-	public void deleteErrorDocumentsForWorkflowRun(String workflowRunId)
-			throws ReferenceServiceException {
-		checkDao();
-		errorDao.deleteErrorDocumentsForWFRun(workflowRunId);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/HibernateErrorDocumentDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/HibernateErrorDocumentDao.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/HibernateErrorDocumentDao.java
deleted file mode 100644
index 470a82e..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/HibernateErrorDocumentDao.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import static net.sf.taverna.t2.reference.T2ReferenceType.ErrorDocument;
-
-import java.util.List;
-
-import net.sf.taverna.t2.reference.DaoException;
-import net.sf.taverna.t2.reference.ErrorDocument;
-import net.sf.taverna.t2.reference.ErrorDocumentDao;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.annotations.DeleteIdentifiedOperation;
-import net.sf.taverna.t2.reference.annotations.GetIdentifiedOperation;
-import net.sf.taverna.t2.reference.annotations.PutIdentifiedOperation;
-
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
-
-/**
- * An implementation of ErrorDocumentDao based on Spring's HibernateDaoSupport.
- * To use this in spring inject a property 'sessionFactory' with either a
- * {@link org.springframework.orm.hibernate3.LocalSessionFactoryBean
- * LocalSessionFactoryBean} or the equivalent class from the T2Platform module
- * to add SPI based implementation discovery and mapping. To use outside of
- * Spring ensure you call the setSessionFactory(..) method before using this
- * (but really, use it from Spring, so much easier).
- * 
- * @author Tom Oinn
- */
-public class HibernateErrorDocumentDao extends HibernateDaoSupport implements
-		ErrorDocumentDao {
-	private static final String GET_ERRORS_FOR_RUN = "FROM ErrorDocumentImpl WHERE namespacePart = :workflow_run_id";
-
-	/**
-	 * Fetch an ErrorDocument list by id
-	 * 
-	 * @param ref
-	 *            the T2Reference to fetch
-	 * @return a retrieved identified list of T2 references
-	 * @throws DaoException
-	 *             if the supplied reference is of the wrong type or if
-	 *             something goes wrong fetching the data or connecting to the
-	 *             database
-	 */
-	@Override
-	@GetIdentifiedOperation
-	public ErrorDocument get(T2Reference ref) throws DaoException {
-		if (ref == null)
-			throw new DaoException(
-					"Supplied reference is null, can't retrieve.");
-		if (!ref.getReferenceType().equals(ErrorDocument))
-			throw new DaoException(
-					"This dao can only retrieve reference of type T2Reference.ErrorDocument");
-		if (!(ref instanceof T2ReferenceImpl))
-			throw new DaoException(
-					"Reference must be an instance of T2ReferenceImpl");
-
-		try {
-			return (ErrorDocumentImpl) getHibernateTemplate().get(
-					ErrorDocumentImpl.class,
-					((T2ReferenceImpl) ref).getCompactForm());
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-
-	@Override
-	@PutIdentifiedOperation
-	public void store(ErrorDocument theDocument) throws DaoException {
-		if (theDocument.getId() == null)
-			throw new DaoException(
-					"Supplied error document set has a null ID, allocate "
-							+ "an ID before calling the store method in the dao.");
-		if (!theDocument.getId().getReferenceType().equals(ErrorDocument))
-			throw new DaoException("Strangely the list ID doesn't have type "
-					+ "T2ReferenceType.ErrorDocument, something has probably "
-					+ "gone badly wrong somewhere earlier!");
-		if (!(theDocument instanceof ErrorDocumentImpl))
-			throw new DaoException(
-					"Supplied ErrorDocument not an instance of ErrorDocumentImpl");
-
-		try {
-			getHibernateTemplate().save(theDocument);
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-
-	@Override
-	@DeleteIdentifiedOperation
-	public boolean delete(ErrorDocument theDocument) throws DaoException {
-		if (theDocument.getId() == null)
-			throw new DaoException(
-					"Supplied error document set has a null ID, allocate "
-							+ "an ID before calling the store method in the dao.");
-		if (!theDocument.getId().getReferenceType()
-				.equals(ErrorDocument))
-			throw new DaoException("Strangely the list ID doesn't have type "
-					+ "T2ReferenceType.ErrorDocument, something has probably "
-					+ "gone badly wrong somewhere earlier!");
-		if (!(theDocument instanceof ErrorDocumentImpl))
-			throw new DaoException(
-					"Supplied ErrorDocument not an instance of ErrorDocumentImpl");
-
-		try {
-			getHibernateTemplate().delete(theDocument);
-			return true;
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-
-	@Override
-	@SuppressWarnings("unchecked")
-	@DeleteIdentifiedOperation
-	public synchronized void deleteErrorDocumentsForWFRun(String workflowRunId)
-			throws DaoException {
-		try {
-			// Select all ErrorDocuments for this wf run
-			Session session = getSession();
-			Query selectQuery = session.createQuery(GET_ERRORS_FOR_RUN);
-			selectQuery.setString("workflow_run_id", workflowRunId);
-			List<ErrorDocument> errorDocuments = selectQuery.list();
-			session.close();
-			/*
-			 * need to close before we do delete otherwise hibernate complains
-			 * that two sessions are accessing collection
-			 */
-			getHibernateTemplate().deleteAll(errorDocuments);
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-}


[45/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/WorkflowToDataflowMapper.java
----------------------------------------------------------------------
diff --git a/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/WorkflowToDataflowMapper.java b/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/WorkflowToDataflowMapper.java
new file mode 100644
index 0000000..796ae9f
--- /dev/null
+++ b/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/WorkflowToDataflowMapper.java
@@ -0,0 +1,526 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.local;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.workflowmodel.Dataflow;
+import org.apache.taverna.workflowmodel.DataflowInputPort;
+import org.apache.taverna.workflowmodel.DataflowOutputPort;
+import org.apache.taverna.workflowmodel.Datalink;
+import org.apache.taverna.workflowmodel.EditException;
+import org.apache.taverna.workflowmodel.Edits;
+import org.apache.taverna.workflowmodel.EventForwardingOutputPort;
+import org.apache.taverna.workflowmodel.EventHandlingInputPort;
+import org.apache.taverna.workflowmodel.Merge;
+import org.apache.taverna.workflowmodel.MergeInputPort;
+import org.apache.taverna.workflowmodel.ProcessorInputPort;
+import org.apache.taverna.workflowmodel.ProcessorOutputPort;
+import org.apache.taverna.workflowmodel.processor.activity.ActivityInputPort;
+import org.apache.taverna.workflowmodel.processor.activity.ActivityOutputPort;
+import org.apache.taverna.workflowmodel.processor.activity.NestedDataflow;
+import org.apache.taverna.workflowmodel.processor.dispatch.DispatchLayer;
+import org.apache.taverna.workflowmodel.processor.dispatch.DispatchStack;
+import org.apache.taverna.workflowmodel.processor.iteration.IterationStrategy;
+import org.apache.taverna.workflowmodel.processor.iteration.NamedInputPortNode;
+import org.apache.taverna.platform.capability.api.ActivityConfigurationException;
+import org.apache.taverna.platform.capability.api.ActivityNotFoundException;
+import org.apache.taverna.platform.capability.api.ActivityService;
+import org.apache.taverna.platform.capability.api.DispatchLayerConfigurationException;
+import org.apache.taverna.platform.capability.api.DispatchLayerNotFoundException;
+import org.apache.taverna.platform.capability.api.DispatchLayerService;
+import org.apache.taverna.platform.execution.api.InvalidWorkflowException;
+import org.apache.taverna.scufl2.api.activity.Activity;
+import org.apache.taverna.scufl2.api.common.Scufl2Tools;
+import org.apache.taverna.scufl2.api.configurations.Configuration;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.BlockingControlLink;
+import org.apache.taverna.scufl2.api.core.ControlLink;
+import org.apache.taverna.scufl2.api.core.DataLink;
+import org.apache.taverna.scufl2.api.core.Processor;
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.iterationstrategy.CrossProduct;
+import org.apache.taverna.scufl2.api.iterationstrategy.DotProduct;
+import org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyNode;
+import org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyStack;
+import org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyTopNode;
+import org.apache.taverna.scufl2.api.iterationstrategy.PortNode;
+import org.apache.taverna.scufl2.api.port.InputActivityPort;
+import org.apache.taverna.scufl2.api.port.InputProcessorPort;
+import org.apache.taverna.scufl2.api.port.InputWorkflowPort;
+import org.apache.taverna.scufl2.api.port.OutputActivityPort;
+import org.apache.taverna.scufl2.api.port.OutputProcessorPort;
+import org.apache.taverna.scufl2.api.port.OutputWorkflowPort;
+import org.apache.taverna.scufl2.api.port.Port;
+import org.apache.taverna.scufl2.api.port.ReceiverPort;
+import org.apache.taverna.scufl2.api.port.SenderPort;
+import org.apache.taverna.scufl2.api.profiles.ProcessorBinding;
+import org.apache.taverna.scufl2.api.profiles.ProcessorInputPortBinding;
+import org.apache.taverna.scufl2.api.profiles.ProcessorOutputPortBinding;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * Translates a scufl2 {@link Workflow} into a {@link Dataflow}.
+ * 
+ * @author David Withers
+ */
+public class WorkflowToDataflowMapper {
+	private static final URI NESTED_WORKFLOW_URI = URI
+			.create("http://ns.taverna.org.uk/2010/activity/nested-workflow");
+
+	private Edits edits;
+	private final Scufl2Tools scufl2Tools = new Scufl2Tools();
+	private final Map<Port, EventHandlingInputPort> inputPorts;
+	private final Map<Port, EventForwardingOutputPort> outputPorts;
+	private final Map<Port, Merge> merges;
+	private final Map<Workflow, Dataflow> workflowToDataflow;
+	private final Map<Dataflow, Workflow> dataflowToWorkflow;
+	private final Map<Processor, org.apache.taverna.workflowmodel.Processor> workflowToDataflowProcessors;
+	private final Map<org.apache.taverna.workflowmodel.Processor, Processor> dataflowToWorkflowProcessors;
+	private final Map<Activity, org.apache.taverna.workflowmodel.processor.activity.Activity<?>> workflowToDataflowActivities;
+	private final Map<org.apache.taverna.workflowmodel.processor.activity.Activity<?>, Activity> dataflowToWorkflowActivities;
+	@SuppressWarnings("unused")
+	private final WorkflowBundle workflowBundle;
+	private final Profile profile;
+	private final ActivityService activityService;
+	private final DispatchLayerService dispatchLayerService;
+
+	public WorkflowToDataflowMapper(WorkflowBundle workflowBundle,
+			Profile profile, Edits edits, ActivityService activityService,
+			DispatchLayerService dispatchLayerService) {
+		this.workflowBundle = workflowBundle;
+		this.profile = profile;
+		this.edits = edits;
+		this.activityService = activityService;
+		this.dispatchLayerService = dispatchLayerService;
+		inputPorts = new IdentityHashMap<>();
+		outputPorts = new IdentityHashMap<>();
+		merges = new IdentityHashMap<>();
+		workflowToDataflow = new IdentityHashMap<>();
+		dataflowToWorkflow = new HashMap<>();
+		workflowToDataflowProcessors = new IdentityHashMap<>();
+		dataflowToWorkflowProcessors = new HashMap<>();
+		workflowToDataflowActivities = new IdentityHashMap<>();
+		dataflowToWorkflowActivities = new HashMap<>();
+	}
+
+	public Workflow getWorkflow(Dataflow dataflow) {
+		return dataflowToWorkflow.get(dataflow);
+	}
+
+	public Dataflow getDataflow(Workflow workflow)
+			throws InvalidWorkflowException {
+		if (!workflowToDataflow.containsKey(workflow)) {
+			try {
+				Dataflow dataflow = createDataflow(workflow);
+				workflowToDataflow.put(workflow, dataflow);
+				dataflowToWorkflow.put(dataflow, workflow);
+			} catch (EditException | ActivityConfigurationException
+					| DispatchLayerConfigurationException
+					| ActivityNotFoundException
+					| DispatchLayerNotFoundException e) {
+				throw new InvalidWorkflowException(e);
+			}
+		}
+		return workflowToDataflow.get(workflow);
+	}
+
+	public Processor getWorkflowProcessor(
+			org.apache.taverna.workflowmodel.Processor dataflowProcessor) {
+		return dataflowToWorkflowProcessors.get(dataflowProcessor);
+	}
+
+	public org.apache.taverna.workflowmodel.Processor getDataflowProcessor(
+			Processor workflowProcessor) {
+		return workflowToDataflowProcessors.get(workflowProcessor);
+	}
+
+	public Activity getWorkflowActivity(
+			org.apache.taverna.workflowmodel.processor.activity.Activity<?> dataflowActiviy) {
+		return dataflowToWorkflowActivities.get(dataflowActiviy);
+	}
+
+	public org.apache.taverna.workflowmodel.processor.activity.Activity<?> getDataflowActivity(
+			Activity workflowActivity) {
+		return workflowToDataflowActivities.get(workflowActivity);
+	}
+
+	protected Dataflow createDataflow(Workflow workflow) throws EditException,
+			ActivityNotFoundException, ActivityConfigurationException,
+			InvalidWorkflowException, DispatchLayerNotFoundException,
+			DispatchLayerConfigurationException {
+		// create the dataflow
+		Dataflow dataflow = edits.createDataflow();
+		// set the dataflow name
+		edits.getUpdateDataflowNameEdit(dataflow, workflow.getName()).doEdit();
+
+		addInputPorts(workflow, dataflow);
+		addOutputPorts(workflow, dataflow);
+		addProcessors(workflow, dataflow);
+		addDataLinks(workflow, dataflow);
+		addControlLinks(workflow);
+
+		return dataflow;
+	}
+
+	private void addProcessors(Workflow workflow, Dataflow dataflow)
+			throws EditException, ActivityNotFoundException,
+			ActivityConfigurationException, InvalidWorkflowException,
+			DispatchLayerNotFoundException, DispatchLayerConfigurationException {
+		for (Processor processor : workflow.getProcessors()) {
+			org.apache.taverna.workflowmodel.Processor dataflowProcessor = edits
+					.createProcessor(processor.getName());
+			edits.getAddProcessorEdit(dataflow, dataflowProcessor).doEdit();
+			// map the processor
+			workflowToDataflowProcessors.put(processor, dataflowProcessor);
+			dataflowToWorkflowProcessors.put(dataflowProcessor, processor);
+			// add input ports
+			for (InputProcessorPort inputProcessorPort : processor
+					.getInputPorts()) {
+				if (inputProcessorPort.getDatalinksTo().isEmpty())
+					continue;
+				ProcessorInputPort processorInputPort = edits
+						.createProcessorInputPort(dataflowProcessor,
+								inputProcessorPort.getName(),
+								inputProcessorPort.getDepth());
+				edits.getAddProcessorInputPortEdit(dataflowProcessor,
+						processorInputPort).doEdit();
+				inputPorts.put(inputProcessorPort, processorInputPort);
+			}
+			// add output ports
+			for (OutputProcessorPort outputProcessorPort : processor
+					.getOutputPorts()) {
+				ProcessorOutputPort processorOutputPort = edits
+						.createProcessorOutputPort(dataflowProcessor,
+								outputProcessorPort.getName(),
+								outputProcessorPort.getDepth(),
+								outputProcessorPort.getGranularDepth());
+				edits.getAddProcessorOutputPortEdit(dataflowProcessor,
+						processorOutputPort).doEdit();
+				outputPorts.put(outputProcessorPort, processorOutputPort);
+			}
+
+			// add dispatch stack
+			addDispatchStack(processor, dataflowProcessor);
+
+			addIterationStrategy(processor, dataflowProcessor);
+
+			// add bound activities
+			for (ProcessorBinding processorBinding : scufl2Tools
+					.processorBindingsForProcessor(processor, profile))
+				addActivity(processorBinding);
+		}
+	}
+
+	private void addDispatchStack(Processor processor,
+			org.apache.taverna.workflowmodel.Processor dataflowProcessor)
+			throws DispatchLayerNotFoundException,
+			DispatchLayerConfigurationException, EditException {
+		DispatchStack dispatchStack = dataflowProcessor.getDispatchStack();
+
+		JsonNode json = null;
+		try {
+			json = processor.getConfiguration(profile).getJson();
+		} catch (IndexOutOfBoundsException e) {
+			// no configuration for processor
+		}
+
+		int layer = 0;
+		addDispatchLayer(
+				dispatchStack,
+				URI.create("http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/Parallelize"),
+				layer++, json == null ? null : json.get("parallelize"));
+		addDispatchLayer(
+				dispatchStack,
+				URI.create("http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/ErrorBounce"),
+				layer++, null);
+		addDispatchLayer(
+				dispatchStack,
+				URI.create("http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/Failover"),
+				layer++, null);
+		addDispatchLayer(
+				dispatchStack,
+				URI.create("http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/Retry"),
+				layer++, json == null ? null : json.get("retry"));
+		addDispatchLayer(
+				dispatchStack,
+				URI.create("http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/Stop"),
+				layer++, null);
+		addDispatchLayer(
+				dispatchStack,
+				URI.create("http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/Invoke"),
+				layer++, null);
+
+	}
+
+	private void addDispatchLayer(DispatchStack dispatchStack,
+			URI dispatchLayerType, int layer, JsonNode json)
+			throws DispatchLayerConfigurationException,
+			DispatchLayerNotFoundException, EditException {
+		// create the dispatch layer
+		DispatchLayer<?> dispatchLayer = dispatchLayerService
+				.createDispatchLayer(dispatchLayerType, json);
+		// add the dispatch layer to the dispatch layer stack
+		edits.getAddDispatchLayerEdit(dispatchStack, dispatchLayer, layer)
+				.doEdit();
+	}
+
+	private void addIterationStrategy(Processor processor,
+			org.apache.taverna.workflowmodel.Processor dataflowProcessor)
+			throws EditException, InvalidWorkflowException {
+		// get the iteration strategy from the processor
+		org.apache.taverna.workflowmodel.processor.iteration.IterationStrategyStack dataflowIterationStrategyStack = dataflowProcessor
+				.getIterationStrategy();
+		// clear the iteration strategy
+		edits.getClearIterationStrategyStackEdit(dataflowIterationStrategyStack)
+				.doEdit();
+		IterationStrategyStack iterationStrategyStack = processor
+				.getIterationStrategyStack();
+		for (IterationStrategyTopNode iterationStrategyTopNode : iterationStrategyStack) {
+			// create iteration strategy
+			IterationStrategy dataflowIterationStrategy = edits
+					.createIterationStrategy();
+			// add iteration strategy to the stack
+			edits.getAddIterationStrategyEdit(dataflowIterationStrategyStack,
+					dataflowIterationStrategy).doEdit();
+			// add the node to the iteration strategy
+			addIterationStrategyNode(dataflowIterationStrategy,
+					dataflowIterationStrategy.getTerminalNode(),
+					iterationStrategyTopNode);
+		}
+	}
+
+	private void addIterationStrategyNode(
+			IterationStrategy dataflowIterationStrategy,
+			org.apache.taverna.workflowmodel.processor.iteration.IterationStrategyNode dataflowIterationStrategyNode,
+			IterationStrategyNode iterationStrategyNode) throws EditException,
+			InvalidWorkflowException {
+		org.apache.taverna.workflowmodel.processor.iteration.IterationStrategyNode childDataflowIterationStrategyNode = null;
+		if (iterationStrategyNode instanceof CrossProduct) {
+			CrossProduct crossProduct = (CrossProduct) iterationStrategyNode;
+			childDataflowIterationStrategyNode = new org.apache.taverna.workflowmodel.processor.iteration.CrossProduct();
+			for (IterationStrategyNode iterationStrategyNode2 : crossProduct)
+				addIterationStrategyNode(dataflowIterationStrategy,
+						childDataflowIterationStrategyNode,
+						iterationStrategyNode2);
+		} else if (iterationStrategyNode instanceof DotProduct) {
+			DotProduct dotProduct = (DotProduct) iterationStrategyNode;
+			childDataflowIterationStrategyNode = new org.apache.taverna.workflowmodel.processor.iteration.DotProduct();
+			for (IterationStrategyNode iterationStrategyNode2 : dotProduct)
+				addIterationStrategyNode(dataflowIterationStrategy,
+						childDataflowIterationStrategyNode,
+						iterationStrategyNode2);
+		} else if (iterationStrategyNode instanceof PortNode) {
+			PortNode portNode = (PortNode) iterationStrategyNode;
+			Integer desiredDepth = portNode.getDesiredDepth();
+			if (desiredDepth == null)
+				desiredDepth = portNode.getInputProcessorPort().getDepth();
+			NamedInputPortNode namedInputPortNode = new NamedInputPortNode(
+					portNode.getInputProcessorPort().getName(), desiredDepth);
+			edits.getAddIterationStrategyInputNodeEdit(
+					dataflowIterationStrategy, namedInputPortNode).doEdit();
+			childDataflowIterationStrategyNode = namedInputPortNode;
+		} else {
+			throw new InvalidWorkflowException(
+					"Unknown IterationStrategyNode type : "
+							+ iterationStrategyNode.getClass().getName());
+		}
+		childDataflowIterationStrategyNode
+				.setParent(dataflowIterationStrategyNode);
+	}
+
+	private void addActivity(ProcessorBinding processorBinding)
+			throws EditException, ActivityNotFoundException,
+			ActivityConfigurationException, InvalidWorkflowException {
+		org.apache.taverna.workflowmodel.Processor processor = workflowToDataflowProcessors
+				.get(processorBinding.getBoundProcessor());
+		Activity scufl2Activity = processorBinding.getBoundActivity();
+		URI activityType = scufl2Activity.getType();
+		if (!activityService.activityExists(activityType))
+			throw new ActivityNotFoundException("No activity exists for "
+					+ activityType);
+		Configuration configuration = scufl2Activity.getConfiguration();
+
+		// create the activity
+		org.apache.taverna.workflowmodel.processor.activity.Activity<?> activity = activityService
+				.createActivity(activityType, configuration.getJson());
+		// check if we have a nested workflow
+		if (activityType.equals(NESTED_WORKFLOW_URI)) {
+			if (activity instanceof NestedDataflow) {
+				Workflow nestedWorkflow = scufl2Tools
+						.nestedWorkflowForProcessor(
+								processorBinding.getBoundProcessor(), profile);
+				((NestedDataflow) activity)
+						.setNestedDataflow(getDataflow(nestedWorkflow));
+			} else
+				throw new ActivityConfigurationException(
+						"Activity is not an instance of NestedDataflow");
+		}
+
+		// add the activity to the processor
+		edits.getAddActivityEdit(processor, activity).doEdit();
+
+		// add input ports
+		for (InputActivityPort inputActivityPort : scufl2Activity
+				.getInputPorts()) {
+			ActivityInputPort activityInputPort = edits
+					.createActivityInputPort(
+							inputActivityPort.getName(),
+							inputActivityPort.getDepth(),
+							false,
+							new ArrayList<Class<? extends ExternalReferenceSPI>>(),
+							String.class);
+			edits.getAddActivityInputPortEdit(activity, activityInputPort)
+					.doEdit();
+		}
+		// add output ports
+		for (OutputActivityPort outputActivityPort : scufl2Activity
+				.getOutputPorts()) {
+			ActivityOutputPort activitytOutputPort = edits
+					.createActivityOutputPort(outputActivityPort.getName(),
+							outputActivityPort.getDepth(),
+							outputActivityPort.getGranularDepth());
+			edits.getAddActivityOutputPortEdit(activity, activitytOutputPort)
+					.doEdit();
+		}
+		// map input ports
+		for (ProcessorInputPortBinding portBinding : processorBinding
+				.getInputPortBindings()) {
+			InputProcessorPort processorPort = portBinding
+					.getBoundProcessorPort();
+			InputActivityPort activityPort = portBinding.getBoundActivityPort();
+			edits.getAddActivityInputPortMappingEdit(activity,
+					processorPort.getName(), activityPort.getName()).doEdit();
+		}
+		// map output ports
+		for (ProcessorOutputPortBinding portBinding : processorBinding
+				.getOutputPortBindings()) {
+			OutputProcessorPort processorPort = portBinding
+					.getBoundProcessorPort();
+			OutputActivityPort activityPort = portBinding
+					.getBoundActivityPort();
+			edits.getAddActivityOutputPortMappingEdit(activity,
+					processorPort.getName(), activityPort.getName()).doEdit();
+		}
+		workflowToDataflowActivities.put(scufl2Activity, activity);
+		dataflowToWorkflowActivities.put(activity, scufl2Activity);
+	}
+
+	private void addDataLinks(Workflow workflow, Dataflow dataflow)
+			throws EditException {
+		for (DataLink dataLink : workflow.getDataLinks()) {
+			ReceiverPort receiverPort = dataLink.getSendsTo();
+			SenderPort senderPort = dataLink.getReceivesFrom();
+			EventForwardingOutputPort source = outputPorts.get(senderPort);
+			EventHandlingInputPort sink = inputPorts.get(receiverPort);
+			Integer mergePosition = dataLink.getMergePosition();
+			if (mergePosition != null) {
+				if (!merges.containsKey(receiverPort)) {
+					Merge merge = edits.createMerge(dataflow);
+					edits.getAddMergeEdit(dataflow, merge).doEdit();
+					merges.put(receiverPort, merge);
+				}
+				Merge merge = merges.get(receiverPort);
+				// create merge input port
+				MergeInputPort mergeInputPort = edits.createMergeInputPort(
+						merge, "input" + mergePosition, sink.getDepth());
+				// add it to the correct position in the merge
+				@SuppressWarnings("unchecked")
+				List<MergeInputPort> mergeInputPorts = (List<MergeInputPort>) merge
+						.getInputPorts();
+				if (mergePosition > mergeInputPorts.size())
+					mergeInputPorts.add(mergeInputPort);
+				else
+					mergeInputPorts.add(mergePosition, mergeInputPort);
+				// connect a datalink into the merge
+				Datalink datalinkIn = edits.createDatalink(source,
+						mergeInputPort);
+				edits.getConnectDatalinkEdit(datalinkIn).doEdit();
+				// check if the merge output has been connected
+				EventForwardingOutputPort mergeOutputPort = merge
+						.getOutputPort();
+				if (mergeOutputPort.getOutgoingLinks().isEmpty()) {
+					Datalink datalinkOut = edits.createDatalink(
+							merge.getOutputPort(), sink);
+					edits.getConnectDatalinkEdit(datalinkOut).doEdit();
+				} else if (mergeOutputPort.getOutgoingLinks().size() == 1) {
+					if (mergeOutputPort.getOutgoingLinks().iterator().next()
+							.getSink() != sink)
+						throw new EditException(
+								"Cannot add a different sinkPort to a Merge that already has one defined");
+				} else
+					throw new EditException(
+							"The merge instance cannot have more that 1 outgoing Datalink");
+			} else {
+				Datalink datalink = edits.createDatalink(source, sink);
+				edits.getConnectDatalinkEdit(datalink).doEdit();
+			}
+		}
+	}
+
+	private void addControlLinks(Workflow workflow) throws EditException {
+		for (ControlLink controlLink : workflow.getControlLinks()) {
+			if (controlLink instanceof BlockingControlLink) {
+				BlockingControlLink blockingControlLink = (BlockingControlLink) controlLink;
+				Processor untilFinished = blockingControlLink
+						.getUntilFinished();
+				Processor block = blockingControlLink.getBlock();
+				edits.getCreateConditionEdit(
+						workflowToDataflowProcessors.get(untilFinished),
+						workflowToDataflowProcessors.get(block)).doEdit();
+			}
+		}
+	}
+
+	private void addOutputPorts(Workflow workflow, Dataflow dataflow)
+			throws EditException {
+		for (OutputWorkflowPort outputWorkflowPort : workflow.getOutputPorts()) {
+			DataflowOutputPort dataflowOutputPort = edits
+					.createDataflowOutputPort(outputWorkflowPort.getName(),
+							dataflow);
+			edits.getAddDataflowOutputPortEdit(dataflow, dataflowOutputPort)
+					.doEdit();
+			inputPorts.put(outputWorkflowPort,
+					dataflowOutputPort.getInternalInputPort());
+		}
+	}
+
+	private void addInputPorts(Workflow workflow, Dataflow dataflow)
+			throws EditException {
+		for (InputWorkflowPort inputWorkflowPort : workflow.getInputPorts()) {
+			DataflowInputPort dataflowInputPort = edits
+					.createDataflowInputPort(inputWorkflowPort.getName(),
+							inputWorkflowPort.getDepth(),
+							inputWorkflowPort.getDepth(), dataflow);
+			edits.getAddDataflowInputPortEdit(dataflow, dataflowInputPort)
+					.doEdit();
+			outputPorts.put(inputWorkflowPort,
+					dataflowInputPort.getInternalOutputPort());
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/LocalExecution.java
----------------------------------------------------------------------
diff --git a/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/LocalExecution.java b/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/LocalExecution.java
deleted file mode 100644
index df7e47f..0000000
--- a/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/LocalExecution.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.impl.local;
-
-import static java.util.logging.Level.SEVERE;
-import static uk.org.taverna.platform.execution.impl.local.T2ReferenceConverter.convertPathToObject;
-
-import java.io.IOException;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.logging.Logger;
-
-import net.sf.taverna.t2.facade.ResultListener;
-import net.sf.taverna.t2.facade.WorkflowInstanceFacade;
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.invocation.TokenOrderException;
-import net.sf.taverna.t2.invocation.WorkflowDataToken;
-import net.sf.taverna.t2.monitor.MonitorManager;
-import net.sf.taverna.t2.provenance.reporter.ProvenanceReporter;
-import net.sf.taverna.t2.reference.ReferenceService;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import net.sf.taverna.t2.workflowmodel.DataflowInputPort;
-import net.sf.taverna.t2.workflowmodel.Edits;
-import net.sf.taverna.t2.workflowmodel.InvalidDataflowException;
-
-import org.apache.taverna.robundle.Bundle;
-
-import org.apache.taverna.databundle.DataBundles;
-import org.apache.taverna.platform.capability.api.ActivityService;
-import org.apache.taverna.platform.capability.api.DispatchLayerService;
-import uk.org.taverna.platform.execution.api.AbstractExecution;
-import uk.org.taverna.platform.execution.api.InvalidWorkflowException;
-import uk.org.taverna.platform.report.ActivityReport;
-import uk.org.taverna.platform.report.ProcessorReport;
-import uk.org.taverna.platform.report.WorkflowReport;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/**
- * An {@link uk.org.taverna.platform.execution.api.Execution Execution} for
- * executing Taverna workflows on a local Taverna Dataflow Engine.
- * 
- * @author David Withers
- */
-public class LocalExecution extends AbstractExecution implements ResultListener {
-
-	private static Logger logger = Logger.getLogger(LocalExecution.class
-			.getName());
-
-	private final WorkflowToDataflowMapper mapping;
-
-	private final WorkflowInstanceFacade facade;
-
-	private final LocalExecutionMonitor executionMonitor;
-
-	private final ReferenceService referenceService;
-
-	private final Map<String, DataflowInputPort> inputPorts = new HashMap<String, DataflowInputPort>();
-
-	/**
-	 * Constructs an Execution for executing Taverna workflows on a local
-	 * Taverna Dataflow Engine.
-	 * 
-	 * @param workflowBundle
-	 *            the <code>WorkflowBundle</code> containing the
-	 *            <code>Workflow</code>s required for execution
-	 * @param workflow
-	 *            the <code>Workflow</code> to execute
-	 * @param profile
-	 *            the <code>Profile</code> to use when executing the
-	 *            <code>Workflow</code>
-	 * @param dataBundle
-	 *            the <code>Bundle</code> containing the data values for the
-	 *            <code>Workflow</code>
-	 * @param referenceService
-	 *            the <code>ReferenceService</code> used to register inputs,
-	 *            outputs and intermediate values
-	 * @throws InvalidWorkflowException
-	 *             if the specified workflow is invalid
-	 */
-	public LocalExecution(WorkflowBundle workflowBundle, Workflow workflow,
-			Profile profile, Bundle dataBundle,
-			ReferenceService referenceService, Edits edits,
-			ActivityService activityService,
-			DispatchLayerService dispatchLayerService)
-			throws InvalidWorkflowException {
-		super(workflowBundle, workflow, profile, dataBundle);
-		this.referenceService = referenceService;
-		try {
-			mapping = new WorkflowToDataflowMapper(workflowBundle, profile,
-					edits, activityService, dispatchLayerService);
-			Dataflow dataflow = mapping.getDataflow(workflow);
-			for (DataflowInputPort dataflowInputPort : dataflow.getInputPorts())
-				inputPorts.put(dataflowInputPort.getName(), dataflowInputPort);
-			facade = edits.createWorkflowInstanceFacade(dataflow,
-					createContext(), "");
-			executionMonitor = new LocalExecutionMonitor(getWorkflowReport(),
-					getDataBundle(), mapping, facade.getIdentifier());
-		} catch (InvalidDataflowException e) {
-			throw new InvalidWorkflowException(e);
-		}
-	}
-
-	@Override
-	public void delete() {
-		cancel();
-	}
-
-	@Override
-	public void start() {
-		MonitorManager.getInstance().addObserver(executionMonitor);
-		/*
-		 * have to add a result listener otherwise facade doesn't record when
-		 * workflow is finished
-		 */
-		facade.addResultListener(this);
-		facade.fire();
-		try {
-			if (DataBundles.hasInputs(getDataBundle())) {
-				Path inputs = DataBundles.getInputs(getDataBundle());
-				for (Entry<String, DataflowInputPort> inputPort : inputPorts
-						.entrySet()) {
-					String portName = inputPort.getKey();
-					Path path = DataBundles.getPort(inputs, portName);
-					if (!DataBundles.isMissing(path)) {
-						T2Reference identifier = referenceService.register(
-								convertPathToObject(path), inputPort.getValue()
-										.getDepth(), true, null);
-						int[] index = new int[] {};
-						WorkflowDataToken token = new WorkflowDataToken("",
-								index, identifier, facade.getContext());
-						try {
-							facade.pushData(token, portName);
-						} catch (TokenOrderException e) {
-							logger.log(SEVERE, "Unable to push data for input "
-									+ portName, e);
-						}
-					}
-				}
-			}
-		} catch (IOException e) {
-			logger.log(SEVERE, "Error getting input data", e);
-		}
-	}
-
-	@Override
-	public void pause() {
-		facade.pauseWorkflowRun();
-	}
-
-	@Override
-	public void resume() {
-		facade.resumeWorkflowRun();
-	}
-
-	@Override
-	public void cancel() {
-		facade.cancelWorkflowRun();
-		facade.removeResultListener(this);
-		MonitorManager.getInstance().removeObserver(executionMonitor);
-	}
-
-	@Override
-	protected WorkflowReport createWorkflowReport(Workflow workflow) {
-		return new WorkflowReport(workflow);
-	}
-
-	@Override
-	public ProcessorReport createProcessorReport(
-			org.apache.taverna.scufl2.api.core.Processor processor) {
-		return new LocalProcessorReport(processor);
-	}
-
-	@Override
-	public ActivityReport createActivityReport(
-			org.apache.taverna.scufl2.api.activity.Activity activity) {
-		return new ActivityReport(activity);
-	}
-
-	private InvocationContext createContext() {
-		InvocationContext context = new InvocationContext() {
-			private List<Object> entities = Collections
-					.synchronizedList(new ArrayList<Object>());
-
-			@Override
-			public <T> List<T> getEntities(Class<T> entityType) {
-				List<T> entitiesOfType = new ArrayList<>();
-				synchronized (entities) {
-					for (Object entity : entities)
-						if (entityType.isInstance(entity))
-							entitiesOfType.add(entityType.cast(entity));
-				}
-				return entitiesOfType;
-			}
-
-			@Override
-			public void addEntity(Object entity) {
-				entities.add(entity);
-			}
-
-			@Override
-			public ReferenceService getReferenceService() {
-				return referenceService;
-			}
-
-			@Override
-			public ProvenanceReporter getProvenanceReporter() {
-				return null;
-			}
-
-		};
-		return context;
-	}
-
-	@Override
-	public void resultTokenProduced(WorkflowDataToken token, String portName) {
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/LocalExecutionEnvironment.java
----------------------------------------------------------------------
diff --git a/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/LocalExecutionEnvironment.java b/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/LocalExecutionEnvironment.java
deleted file mode 100644
index 35f7a99..0000000
--- a/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/LocalExecutionEnvironment.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.impl.local;
-
-import java.net.URI;
-import java.util.Set;
-
-import org.apache.taverna.platform.capability.api.ActivityConfigurationException;
-import org.apache.taverna.platform.capability.api.ActivityNotFoundException;
-import org.apache.taverna.platform.capability.api.ActivityService;
-import org.apache.taverna.platform.capability.api.DispatchLayerConfigurationException;
-import org.apache.taverna.platform.capability.api.DispatchLayerNotFoundException;
-import org.apache.taverna.platform.capability.api.DispatchLayerService;
-import uk.org.taverna.platform.execution.api.AbstractExecutionEnvironment;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * Execution Environment for a local Taverna Dataflow Engine
- *
- * @author David Withers
- */
-public class LocalExecutionEnvironment extends AbstractExecutionEnvironment {
-
-	private final ActivityService activityService;
-	private final DispatchLayerService dispatchLayerService;
-
-	public LocalExecutionEnvironment(LocalExecutionService localExecutionService,
-			ActivityService activityService, DispatchLayerService dispatchLayerService) {
-		super(LocalExecutionEnvironment.class.getName(), "Taverna Local Execution Environment",
-				"Execution Environment for a local Taverna Dataflow Engine", localExecutionService);
-		this.activityService = activityService;
-		this.dispatchLayerService = dispatchLayerService;
-	}
-
-	@Override
-	public Set<URI> getActivityTypes() {
-		return activityService.getActivityTypes();
-	}
-
-	@Override
-	public boolean activityExists(URI uri) {
-		return activityService.activityExists(uri);
-	}
-
-	@Override
-	public JsonNode getActivityConfigurationSchema(URI uri)
-			throws ActivityNotFoundException, ActivityConfigurationException {
-		return activityService.getActivityConfigurationSchema(uri);
-	}
-
-	@Override
-	public Set<URI> getDispatchLayerTypes() {
-		return dispatchLayerService.getDispatchLayerTypes();
-	}
-
-	@Override
-	public boolean dispatchLayerExists(URI uri) {
-		return dispatchLayerService.dispatchLayerExists(uri);
-	}
-
-	@Override
-	public JsonNode getDispatchLayerConfigurationSchema(URI uri)
-			throws DispatchLayerNotFoundException, DispatchLayerConfigurationException {
-		return dispatchLayerService.getDispatchLayerConfigurationSchema(uri);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/LocalExecutionMonitor.java
----------------------------------------------------------------------
diff --git a/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/LocalExecutionMonitor.java b/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/LocalExecutionMonitor.java
deleted file mode 100755
index 4c57403..0000000
--- a/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/LocalExecutionMonitor.java
+++ /dev/null
@@ -1,548 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.impl.local;
-
-import static java.util.logging.Level.SEVERE;
-import static java.util.logging.Level.WARNING;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.UUID;
-import java.util.logging.Logger;
-
-import net.sf.taverna.t2.facade.ResultListener;
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.invocation.WorkflowDataToken;
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.lang.observer.Observer;
-import net.sf.taverna.t2.monitor.MonitorManager.AddPropertiesMessage;
-import net.sf.taverna.t2.monitor.MonitorManager.DeregisterNodeMessage;
-import net.sf.taverna.t2.monitor.MonitorManager.MonitorMessage;
-import net.sf.taverna.t2.monitor.MonitorManager.RegisterNodeMessage;
-import net.sf.taverna.t2.monitor.MonitorableProperty;
-import net.sf.taverna.t2.reference.ErrorDocument;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.IdentifiedList;
-import net.sf.taverna.t2.reference.ReferenceService;
-import net.sf.taverna.t2.reference.ReferenceServiceException;
-import net.sf.taverna.t2.reference.ReferenceSet;
-import net.sf.taverna.t2.reference.StackTraceElementBean;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.T2ReferenceType;
-import net.sf.taverna.t2.reference.impl.external.file.FileReference;
-import net.sf.taverna.t2.reference.impl.external.http.HttpReference;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import net.sf.taverna.t2.workflowmodel.DataflowOutputPort;
-import net.sf.taverna.t2.workflowmodel.Processor;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchJobEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchResultEvent;
-
-import org.apache.taverna.robundle.Bundle;
-
-import org.apache.taverna.databundle.DataBundles;
-import uk.org.taverna.platform.execution.api.InvalidWorkflowException;
-import uk.org.taverna.platform.report.ActivityReport;
-import uk.org.taverna.platform.report.Invocation;
-import uk.org.taverna.platform.report.ProcessorReport;
-import uk.org.taverna.platform.report.StatusReport;
-import uk.org.taverna.platform.report.WorkflowReport;
-
-/**
- * A workflow monitor for local executions.
- * 
- * @author David Withers
- */
-public class LocalExecutionMonitor implements Observer<MonitorMessage> {
-	private static final Logger logger = Logger
-			.getLogger(LocalExecutionMonitor.class.getName());
-	private static final String ID_SEPARATOR = "/";
-
-	private Map<String, StatusReport<?, ?>> reports;
-	private Map<String, Invocation> invocations;
-	private Map<String, String> invocationToActivity;
-	private Map<T2Reference, Path> referenceToPath;
-	private final String facadeId;
-	private final Bundle dataBundle;
-
-	public LocalExecutionMonitor(WorkflowReport workflowReport,
-			Bundle dataBundle, WorkflowToDataflowMapper mapping, String facadeId)
-			throws InvalidWorkflowException {
-		this.dataBundle = dataBundle;
-		this.facadeId = facadeId;
-		reports = new HashMap<>();
-		invocations = new HashMap<>();
-		invocationToActivity = new HashMap<>();
-		referenceToPath = new HashMap<>();
-		mapReports("", workflowReport, mapping);
-	}
-
-	private void mapReports(String id, WorkflowReport workflowReport,
-			WorkflowToDataflowMapper mapping) throws InvalidWorkflowException {
-		Dataflow dataflow = mapping.getDataflow(workflowReport.getSubject());
-		String dataflowId = null;
-		if (id.isEmpty()) {
-			dataflowId = dataflow.getLocalName();
-		} else {
-			dataflowId = id + ID_SEPARATOR + dataflow.getLocalName();
-		}
-		reports.put(dataflowId, workflowReport);
-		for (ProcessorReport processorReport : workflowReport
-				.getProcessorReports()) {
-			Processor processor = mapping.getDataflowProcessor(processorReport
-					.getSubject());
-			String processorId = dataflowId + ID_SEPARATOR
-					+ processor.getLocalName();
-			reports.put(processorId, (LocalProcessorReport) processorReport);
-			for (ActivityReport activityReport : processorReport
-					.getActivityReports()) {
-				Activity<?> activity = mapping
-						.getDataflowActivity(activityReport.getSubject());
-				String activityId = processorId + ID_SEPARATOR
-						+ activity.hashCode();
-				reports.put(activityId, activityReport);
-				WorkflowReport nestedWorkflowReport = activityReport
-						.getNestedWorkflowReport();
-				if (nestedWorkflowReport != null)
-					mapReports(activityId, nestedWorkflowReport, mapping);
-			}
-		}
-	}
-
-	@Override
-	public void notify(Observable<MonitorMessage> sender, MonitorMessage message)
-			throws Exception {
-		String[] owningProcess = message.getOwningProcess();
-		if (owningProcess.length > 0 && owningProcess[0].equals(facadeId)) {
-			if (message instanceof RegisterNodeMessage) {
-				RegisterNodeMessage regMessage = (RegisterNodeMessage) message;
-				registerNode(regMessage.getWorkflowObject(), owningProcess,
-						regMessage.getProperties());
-			} else if (message instanceof DeregisterNodeMessage) {
-				deregisterNode(owningProcess);
-			} else if (message instanceof AddPropertiesMessage) {
-				AddPropertiesMessage addMessage = (AddPropertiesMessage) message;
-				addPropertiesToNode(owningProcess,
-						addMessage.getNewProperties());
-			} else {
-				logger.warning("Unknown message " + message + " from " + sender);
-			}
-		}
-	}
-
-	public void registerNode(Object dataflowObject, String[] owningProcess,
-			Set<MonitorableProperty<?>> properties) {
-		if (dataflowObject instanceof Dataflow) {
-			Dataflow dataflow = (Dataflow) dataflowObject;
-			Invocation parentInvocation = invocations
-					.get(getParentInvocationId(owningProcess));
-			WorkflowReport report = (WorkflowReport) reports
-					.get(getReportId(owningProcess));
-			report.setStartedDate(new Date());
-			Invocation invocation = new Invocation(
-					getInvocationName(owningProcess), parentInvocation, report);
-			if (parentInvocation == null) {
-				if (DataBundles.hasInputs(dataBundle)) {
-					try {
-						invocation.setInputs(DataBundles.getPorts(DataBundles
-								.getInputs(dataBundle)));
-					} catch (IOException e) {
-						logger.log(WARNING, "Error setting input ports", e);
-					}
-				}
-				try {
-					Path outputs = DataBundles.getOutputs(dataBundle);
-					DataflowResultListener dataflowResultListener = new DataflowResultListener(
-							outputs);
-					for (DataflowOutputPort dataflowOutputPort : dataflow
-							.getOutputPorts()) {
-						String portName = dataflowOutputPort.getName();
-						Path portPath = DataBundles.getPort(outputs, portName);
-						invocation.setOutput(portName, portPath);
-						dataflowOutputPort
-								.addResultListener(dataflowResultListener);
-					}
-				} catch (IOException e) {
-					logger.log(WARNING, "Error setting output ports", e);
-				}
-				invocations.put(getInvocationId(owningProcess), invocation);
-			} else {
-				invocation.setInputs(parentInvocation.getInputs());
-				NestedDataflowResultListener resultListener = new NestedDataflowResultListener(
-						invocation);
-				for (DataflowOutputPort dataflowOutputPort : dataflow
-						.getOutputPorts()) {
-					dataflowOutputPort.addResultListener(resultListener);
-				}
-				invocations.put(getInvocationId(owningProcess), invocation);
-			}
-		} else if (dataflowObject instanceof Processor) {
-			StatusReport<?, ?> report = reports.get(getReportId(owningProcess));
-			report.setStartedDate(new Date());
-			if (report instanceof LocalProcessorReport)
-				((LocalProcessorReport) report).addProperties(properties);
-		} else if (dataflowObject instanceof Activity) {
-			Activity<?> activity = (Activity<?>) dataflowObject;
-			invocationToActivity.put(owningProcess[owningProcess.length - 1],
-					String.valueOf(activity.hashCode()));
-		} else if (dataflowObject instanceof DispatchJobEvent) {
-			DispatchJobEvent jobEvent = (DispatchJobEvent) dataflowObject;
-			StatusReport<?, ?> report = reports.get(getReportId(owningProcess));
-			// create a new invocation
-			Invocation parentInvocation;
-			Invocation invocation;
-
-			if (report instanceof ActivityReport) {
-				parentInvocation = invocations
-						.get(getParentInvocationId(owningProcess)
-								+ indexToString(jobEvent.getIndex()));
-				invocation = new Invocation(getInvocationName(owningProcess),
-						jobEvent.getIndex(), parentInvocation, report);
-				invocations.put(getInvocationId(owningProcess), invocation);
-			} else {
-				parentInvocation = invocations
-						.get(getParentInvocationId(owningProcess));
-				invocation = new Invocation(getInvocationName(owningProcess)
-						+ indexToString(jobEvent.getIndex()),
-						jobEvent.getIndex(), parentInvocation, report);
-				invocations.put(getInvocationId(owningProcess)
-						+ indexToString(jobEvent.getIndex()), invocation);
-			}
-			// set the invocation inputs
-			try {
-				for (Entry<String, T2Reference> inputInfo : jobEvent.getData()
-						.entrySet()) {
-					invocation.setInput(
-							inputInfo.getKey(),
-							getIntermediate(inputInfo.getValue(),
-									jobEvent.getContext()));
-				}
-			} catch (IOException | URISyntaxException e) {
-				logger.log(WARNING, "Error saving intermediate inputs for "
-						+ jobEvent.getOwningProcess(), e);
-			}
-
-		} else if (dataflowObject instanceof DispatchResultEvent) {
-			DispatchResultEvent resultEvent = (DispatchResultEvent) dataflowObject;
-			StatusReport<?, ?> report = reports.get(getReportId(owningProcess));
-			// find the invocation
-			Invocation invocation;
-			if (report instanceof ActivityReport)
-				invocation = invocations.remove(getInvocationId(owningProcess));
-			else
-				invocation = invocations.remove(getInvocationId(owningProcess)
-						+ indexToString(resultEvent.getIndex()));
-
-			if (invocation == null) {
-				logger.log(SEVERE, "Can't find invocation for owning process "
-						+ owningProcess);
-				return;
-			}
-
-			// set the invocation outputs
-			try {
-				for (Entry<String, T2Reference> outputInfo : resultEvent.getData()
-						.entrySet()) {
-					invocation.setOutput(
-							outputInfo.getKey(),
-							getIntermediate(outputInfo.getValue(),
-									resultEvent.getContext()));
-				}
-			} catch (IOException | URISyntaxException e) {
-				logger.log(WARNING, "Error saving intermediate outputs for "
-						+ resultEvent.getOwningProcess(), e);
-			}
-			invocation.setCompletedDate(new Date());
-		}
-	}
-
-	public void deregisterNode(String[] owningProcess) {
-		StatusReport<?, ?> report = reports.get(getReportId(owningProcess));
-		if (report == null) {
-			return;
-		} else if (report instanceof WorkflowReport) {
-			Invocation invocation = invocations
-					.remove(getInvocationId(owningProcess));
-			invocation.setCompletedDate(new Date());
-			report.setCompletedDate(new Date());
-		} else if (report instanceof LocalProcessorReport) {
-			((LocalProcessorReport) report).saveProperties();
-			report.setCompletedDate(new Date());
-		} else if (report instanceof ActivityReport) {
-			// Invocation may still exist if the activity failed
-			Invocation invocation = invocations
-					.remove(getInvocationId(owningProcess));
-			if (invocation != null) {
-				invocation.setCompletedDate(new Date());
-				report.setFailedDate(new Date());
-			} else
-				report.setCompletedDate(new Date());
-			invocationToActivity
-					.remove(owningProcess[owningProcess.length - 1]);
-		}
-	}
-
-	public void addPropertiesToNode(String[] owningProcess,
-			Set<MonitorableProperty<?>> newProperties) {
-		StatusReport<?, ?> report = reports.get(getReportId(owningProcess));
-		if (report instanceof LocalProcessorReport) {
-			LocalProcessorReport processorReport = (LocalProcessorReport) report;
-			processorReport.addProperties(newProperties);
-		}
-	}
-
-	private String getParentInvocationId(String[] owningProcess) {
-		List<String> id = new ArrayList<>();
-		for (int i = 1; i < owningProcess.length - 1; i++)
-			if (i % 4 != 0)
-				id.add(owningProcess[i]);
-		return toPath(id);
-	}
-
-	private String getInvocationId(String[] owningProcess) {
-		List<String> id = new ArrayList<>();
-		for (int i = 1; i < owningProcess.length; i++)
-			if (i % 4 != 0)
-				id.add(owningProcess[i]);
-		return toPath(id);
-	}
-
-	private String getInvocationName(String[] owningProcess) {
-		return owningProcess[owningProcess.length - 1];
-	}
-
-	private String toPath(List<String> id) {
-		StringBuilder sb = new StringBuilder();
-		String sep = "";
-		for (String string : id) {
-			sb.append(sep).append(string);
-			sep = ID_SEPARATOR;
-		}
-		return sb.toString();
-	}
-
-	private String getReportId(String[] owningProcess) {
-		List<String> id = new ArrayList<>();
-		for (int i = 1, position = 0; i < owningProcess.length; i++) {
-			if (i % 4 == 0)
-				continue;
-			if (position == 2) {
-				id.add(invocationToActivity.get(owningProcess[i]));
-				position = 0;
-			} else {
-				id.add(owningProcess[i]);
-				position++;
-			}
-		}
-		return toPath(id);
-	}
-
-	public String getProcessorId(String[] owningProcess) {
-		StringBuffer sb = new StringBuffer();
-		for (int i = 1, skip = 0; i < owningProcess.length; i++, skip--)
-			if (i <= 2 || skip < 0) {
-				sb.append(owningProcess[i]);
-				skip = 3;
-			}
-		return sb.toString();
-	}
-
-	private String indexToString(int[] index) {
-		StringBuilder indexString = new StringBuilder();
-		for (int i = 0; i < index.length; i++) {
-			if (i != 0)
-				indexString.append(":");
-			indexString.append(index[i] + 1);
-		}
-		return indexString.toString();
-	}
-
-	private Path getIntermediate(T2Reference t2Reference,
-			InvocationContext context) throws IOException, URISyntaxException {
-		if (referenceToPath.containsKey(t2Reference))
-			return referenceToPath.get(t2Reference);
-
-		Path path = referencePath(t2Reference);
-		convertReferenceToPath(path, t2Reference, context);
-		referenceToPath.put(t2Reference, path);
-		return path;
-	}
-
-	private Path referencePath(T2Reference t2Reference) throws IOException {
-		String local = t2Reference.getLocalPart();
-		try {
-			return DataBundles.getIntermediate(dataBundle,
-					UUID.fromString(local));
-		} catch (IllegalArgumentException ex) {
-			return DataBundles.getIntermediates(dataBundle)
-					.resolve(t2Reference.getNamespacePart())
-					.resolve(t2Reference.getLocalPart());
-		}
-	}
-
-	public static String getStackTraceElementString(
-			StackTraceElementBean stackTraceElement) {
-		StringBuilder sb = new StringBuilder();
-		sb.append(stackTraceElement.getClassName()).append('.')
-				.append(stackTraceElement.getMethodName());
-		if (stackTraceElement.getFileName() == null) {
-			sb.append("(unknown file)");
-		} else {
-			sb.append('(').append(stackTraceElement.getFileName()).append(':')
-					.append(stackTraceElement.getLineNumber()).append(')');
-		}
-		return sb.toString();
-	}
-
-	public void convertReferenceToPath(Path path, T2Reference reference,
-			InvocationContext context) throws IOException, URISyntaxException {
-		ReferenceService referenceService = context.getReferenceService();
-		if (reference.getReferenceType() == T2ReferenceType.ReferenceSet) {
-			if (DataBundles.isMissing(path)) {
-				ReferenceSet rs = referenceService.getReferenceSetService()
-						.getReferenceSet(reference);
-				if (rs == null)
-					throw new ReferenceServiceException(
-							"Could not find ReferenceSet " + reference);
-				// Check that there are references in the set
-				if (rs.getExternalReferences().isEmpty())
-					throw new ReferenceServiceException("ReferenceSet "
-							+ reference + " is empty");
-
-				for (ExternalReferenceSPI ers : rs.getExternalReferences()) {
-					if (ers instanceof FileReference) {
-						URI uri = ((FileReference) ers).getFile().toURI();
-						DataBundles.setReference(path, uri);
-					} else if (ers instanceof HttpReference) {
-						URI uri = ((HttpReference) ers).getHttpUrl().toURI();
-						DataBundles.setReference(path, uri);
-					} else {
-						try (InputStream in = ers.openStream(context)) {
-							Files.copy(in, path);
-						}
-					}
-				}
-			}
-		} else if (reference.getReferenceType() == T2ReferenceType.ErrorDocument) {
-			if (DataBundles.isMissing(path)) {
-				ErrorDocument errorDocument = referenceService
-						.getErrorDocumentService().getError(reference);
-				String message = errorDocument.getMessage();
-				StringBuilder trace = new StringBuilder();
-				if (errorDocument.getExceptionMessage() != null
-						&& !errorDocument.getExceptionMessage().isEmpty()) {
-					trace.append(errorDocument.getExceptionMessage());
-					trace.append("\n");
-				}
-				List<StackTraceElementBean> stackTraceStrings = errorDocument
-						.getStackTraceStrings();
-				for (StackTraceElementBean stackTraceElement : stackTraceStrings) {
-					trace.append(getStackTraceElementString(stackTraceElement));
-					trace.append("\n");
-				}
-				List<Path> causes = new ArrayList<>();
-				for (T2Reference errorReference : errorDocument
-						.getErrorReferences())
-					causes.add(getIntermediate(errorReference, context));
-				DataBundles.setError(path, message, trace.toString(),
-						causes.toArray(new Path[causes.size()]));
-			}
-		} else { // it is an IdentifiedList<T2Reference>
-			IdentifiedList<T2Reference> identifiedList = referenceService
-					.getListService().getList(reference);
-			if (!DataBundles.isList(path))
-				DataBundles.createList(path);
-			for (T2Reference ref : identifiedList)
-				convertReferenceToPath(DataBundles.newListItem(path), ref,
-						context);
-		}
-	}
-
-	private class NestedDataflowResultListener implements ResultListener {
-		private final Invocation invocation;
-
-		public NestedDataflowResultListener(Invocation invocation) {
-			this.invocation = invocation;
-		}
-
-		@Override
-		public void resultTokenProduced(WorkflowDataToken token, String portName) {
-			try {
-				if (token.isFinal())
-					invocation
-							.setOutput(
-									portName,
-									getIntermediate(token.getData(),
-											token.getContext()));
-			} catch (IOException | URISyntaxException e) {
-				logger.log(SEVERE, "Unable to convert T2Reference", e);
-			}
-		}
-
-	}
-
-	private class DataflowResultListener implements ResultListener {
-		private Path outputs;
-		private Map<String, Integer> depthSeen = new HashMap<>();
-
-		public DataflowResultListener(Path outputs) {
-			this.outputs = outputs;
-		}
-
-		@Override
-		public void resultTokenProduced(WorkflowDataToken token, String portName) {
-			Integer depth = depthSeen.get(portName);
-			if (depth == null || depth.equals(token.getIndex().length)) {
-				if (depth == null)
-					depthSeen.put(portName, token.getIndex().length);
-				try {
-					Path port = DataBundles.getPort(outputs, portName);
-					Path path = getPath(port, 0, token.getIndex());
-					convertReferenceToPath(path, token.getData(),
-							token.getContext());
-				} catch (IOException | URISyntaxException e) {
-					logger.log(SEVERE, "Unable to convert T2Reference", e);
-				}
-			}
-		}
-
-		private Path getPath(Path path, int depth, int[] index)
-				throws IOException {
-			if (depth == index.length)
-				return path;
-			if (!DataBundles.isList(path))
-				DataBundles.createList(path);
-			return getPath(DataBundles.getListItem(path, index[depth]),
-					depth + 1, index);
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/LocalExecutionService.java
----------------------------------------------------------------------
diff --git a/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/LocalExecutionService.java b/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/LocalExecutionService.java
deleted file mode 100644
index ba1ee7f..0000000
--- a/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/LocalExecutionService.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.impl.local;
-
-import java.net.URI;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.WeakHashMap;
-
-import net.sf.taverna.t2.reference.ReferenceService;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import net.sf.taverna.t2.workflowmodel.Edits;
-
-import org.apache.taverna.robundle.Bundle;
-
-import org.apache.taverna.platform.capability.api.ActivityService;
-import org.apache.taverna.platform.capability.api.DispatchLayerService;
-import uk.org.taverna.platform.execution.api.AbstractExecutionService;
-import uk.org.taverna.platform.execution.api.Execution;
-import uk.org.taverna.platform.execution.api.ExecutionEnvironment;
-import uk.org.taverna.platform.execution.api.InvalidWorkflowException;
-import uk.org.taverna.platform.execution.api.WorkflowCompiler;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/**
- * Service for executing Taverna workflows on a local Taverna Dataflow Engine.
- *
- * @author David Withers
- */
-public class LocalExecutionService extends AbstractExecutionService implements
-		WorkflowCompiler {
-	private Edits edits;
-	private ActivityService activityService;
-	private DispatchLayerService dispatchLayerService;
-	private ReferenceService referenceService;
-
-	/**
-	 * Constructs an execution service that executes workflows using the T2
-	 * dataflow engine.
-	 */
-	public LocalExecutionService() {
-		super(
-				LocalExecutionService.class.getName(),
-				"Taverna Local Execution Service",
-				"Execution Service for executing Taverna workflows using a local Taverna Dataflow Engine");
-	}
-
-	@Override
-	public Set<ExecutionEnvironment> getExecutionEnvironments() {
-		Set<ExecutionEnvironment> executionEnvironments = new HashSet<>();
-		executionEnvironments.add(new LocalExecutionEnvironment(this,
-				activityService, dispatchLayerService));
-		return executionEnvironments;
-	}
-
-	@Override
-	protected Execution createExecutionImpl(WorkflowBundle workflowBundle,
-			Workflow workflow, Profile profile, Bundle dataBundle)
-			throws InvalidWorkflowException {
-		return new LocalExecution(workflowBundle, workflow, profile,
-				dataBundle, referenceService, edits, activityService,
-				dispatchLayerService);
-	}
-
-	/**
-	 * Sets the Edits Service for creating Taverna Dataflows.
-	 *
-	 * @param edits
-	 *            the Edits Service for creating Taverna Dataflows
-	 */
-	public void setEdits(Edits edits) {
-		this.edits = edits;
-	}
-
-	/**
-	 * Sets the service for creating activities.
-	 *
-	 * @param activityService
-	 *            the service for creating activities
-	 */
-	public void setActivityService(ActivityService activityService) {
-		this.activityService = activityService;
-	}
-
-	/**
-	 * Sets the service for creating dispatch layers.
-	 *
-	 * @param dispatchLayerService
-	 *            the service for creating dispatch layers
-	 */
-	public void setDispatchLayerService(DispatchLayerService dispatchLayerService) {
-		this.dispatchLayerService = dispatchLayerService;
-	}
-
-	/**
-	 * Sets the reference service.
-	 *
-	 * @param referenceService
-	 *            the reference service
-	 */
-	public void setReferenceService(ReferenceService referenceService) {
-		this.referenceService = referenceService;
-	}
-
-	private WeakHashMap<URI, WorkflowToDataflowMapper> cache = new WeakHashMap<>();
-
-	private synchronized WorkflowToDataflowMapper getMapper(
-			WorkflowBundle bundle) {
-		WorkflowToDataflowMapper m = cache.get(bundle.getIdentifier());
-		if (m == null) {
-			m = new WorkflowToDataflowMapper(bundle, bundle.getMainProfile(),
-					edits, activityService, dispatchLayerService);
-			cache.put(bundle.getIdentifier(), m);
-		}
-		return m;
-	}
-
-	@Override
-	public Dataflow getDataflow(Workflow workflow)
-			throws InvalidWorkflowException {
-		return getMapper(workflow.getParent()).getDataflow(workflow);
-	}
-
-	@Override
-	public synchronized Dataflow getDataflow(WorkflowBundle bundle)
-			throws InvalidWorkflowException {
-		return getMapper(bundle).getDataflow(bundle.getMainWorkflow());
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/LocalProcessorReport.java
----------------------------------------------------------------------
diff --git a/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/LocalProcessorReport.java b/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/LocalProcessorReport.java
deleted file mode 100644
index 2db354c..0000000
--- a/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/LocalProcessorReport.java
+++ /dev/null
@@ -1,141 +0,0 @@
-package uk.org.taverna.platform.execution.impl.local;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import net.sf.taverna.t2.monitor.MonitorableProperty;
-import net.sf.taverna.t2.monitor.NoSuchPropertyException;
-import net.sf.taverna.t2.monitor.SteerableProperty;
-import uk.org.taverna.platform.report.ProcessorReport;
-import org.apache.taverna.scufl2.api.core.Processor;
-
-/**
- * ProcessorReport implementation based on MonitorableProperty objects.
- * 
- * @author David Withers
- */
-public class LocalProcessorReport extends ProcessorReport {
-	private static final String DISPATCH_ERRORBOUNCE_TOTAL_TRANSLATED = "dispatch:errorbounce:totalTranslated";
-	private static final String DISPATCH_PARALLELIZE_COMPLETEDJOBS = "dispatch:parallelize:completedjobs";
-	private static final String DISPATCH_PARALLELIZE_SENTJOBS = "dispatch:parallelize:sentjobs";
-	private static final String DISPATCH_PARALLELIZE_QUEUESIZE = "dispatch:parallelize:queuesize";
-
-	private Map<String, MonitorableProperty<?>> propertyMap;
-
-	public LocalProcessorReport(Processor processor) {
-		super(processor);
-		propertyMap = new HashMap<String, MonitorableProperty<?>>();
-	}
-
-	public void addProperties(Set<MonitorableProperty<?>> properties) {
-		for (MonitorableProperty<?> property : properties) {
-			propertyMap.put(getPropertyName(property), property);
-		}
-	}
-
-	public void saveProperties() {
-		for (Entry<String, MonitorableProperty<?>> entry : propertyMap
-				.entrySet())
-			entry.setValue(new StaticProperty(entry.getValue()));
-	}
-
-	@Override
-	public int getJobsQueued() {
-		int result = -1;
-		MonitorableProperty<?> property = propertyMap
-				.get(DISPATCH_PARALLELIZE_QUEUESIZE);
-		try {
-			if (property != null)
-				result = (Integer) property.getValue();
-		} catch (NoSuchPropertyException e) {
-		}
-		return result;
-	}
-
-	@Override
-	public int getJobsStarted() {
-		int result = -1;
-		MonitorableProperty<?> property = propertyMap
-				.get(DISPATCH_PARALLELIZE_SENTJOBS);
-		if (property != null) {
-			try {
-				result = (Integer) property.getValue();
-			} catch (NoSuchPropertyException e) {
-			}
-		}
-		return result;
-	}
-
-	@Override
-	public int getJobsCompleted() {
-		int result = -1;
-		MonitorableProperty<?> property = propertyMap
-				.get(DISPATCH_PARALLELIZE_COMPLETEDJOBS);
-		try {
-			if (property != null)
-				result = (Integer) property.getValue();
-		} catch (NoSuchPropertyException e) {
-		}
-		return result;
-	}
-
-	@Override
-	public int getJobsCompletedWithErrors() {
-		int result = -1;
-		MonitorableProperty<?> property = propertyMap
-				.get(DISPATCH_ERRORBOUNCE_TOTAL_TRANSLATED);
-		try {
-			if (property != null)
-				result = (Integer) property.getValue();
-		} catch (NoSuchPropertyException e) {
-		}
-		return result;
-	}
-
-	@Override
-	public Set<String> getPropertyKeys() {
-		if (!propertyMap.isEmpty())
-			return new HashSet<>(propertyMap.keySet());
-		return super.getPropertyKeys();
-	}
-
-	@Override
-	public Object getProperty(String key) {
-		Object result = null;
-		MonitorableProperty<?> property = propertyMap.get(key);
-		try {
-			if (property != null)
-				result = property.getValue();
-		} catch (NoSuchPropertyException e) {
-		}
-		return result;
-	}
-
-	@Override
-	public void setProperty(String key, Object value) {
-		MonitorableProperty<?> monitorableProperty = propertyMap.get(key);
-		if (monitorableProperty instanceof SteerableProperty<?>) {
-			@SuppressWarnings("unchecked")
-			SteerableProperty<Object> steerableProperty = (SteerableProperty<Object>) monitorableProperty;
-			try {
-				steerableProperty.setProperty(value);
-			} catch (NoSuchPropertyException e) {
-			}
-		}
-	}
-
-	private String getPropertyName(MonitorableProperty<?> property) {
-		StringBuilder sb = new StringBuilder();
-		String[] name = property.getName();
-		for (int i = 0; i < name.length; i++) {
-			if (i > 0)
-				sb.append(':');
-			sb.append(name[i]);
-		}
-		return sb.toString();
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/StaticProperty.java
----------------------------------------------------------------------
diff --git a/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/StaticProperty.java b/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/StaticProperty.java
deleted file mode 100755
index e8c2c07..0000000
--- a/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/StaticProperty.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.impl.local;
-
-import java.util.Date;
-
-import net.sf.taverna.t2.monitor.MonitorableProperty;
-import net.sf.taverna.t2.monitor.NoSuchPropertyException;
-
-/**
- * A MonitorableProperty with fixed values.
- * 
- * @author David Withers
- */
-public class StaticProperty implements MonitorableProperty<Object> {
-	private Object value;
-	private String[] name;
-	private Date lastModified;
-	
-	/**
-	 * Records the state of the MonitorableProperty.
-	 * 
-	 * @param property
-	 */
-	public StaticProperty(MonitorableProperty<?> property) {
-		try {
-			value = property.getValue();
-		} catch (NoSuchPropertyException e) {
-		}
-		name = property.getName();
-		lastModified = property.getLastModified();
-	}
-	
-	@Override
-	public Object getValue() throws NoSuchPropertyException {
-		return value;
-	}
-
-	@Override
-	public String[] getName() {
-		return name;
-	}
-
-	@Override
-	public Date getLastModified() {
-		return lastModified;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/T2ReferenceConverter.java
----------------------------------------------------------------------
diff --git a/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/T2ReferenceConverter.java b/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/T2ReferenceConverter.java
deleted file mode 100644
index 7de9f48..0000000
--- a/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/T2ReferenceConverter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- *
- */
-package uk.org.taverna.platform.execution.impl.local;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.taverna.databundle.DataBundles;
-
-/**
- * @author David Withers
- */
-public class T2ReferenceConverter {
-	public static Object convertPathToObject(Path path) throws IOException {
-		Object object = null;
-		if (DataBundles.isValue(path)) {
-			object = DataBundles.getStringValue(path);
-		} else if (DataBundles.isReference(path)) {
-			URI reference = DataBundles.getReference(path);
-			String scheme = reference.getScheme();
-			if ("file".equals(scheme)) {
-				object = new File(reference);
-			} else {
-				object = reference.toURL();
-			}
-		} else if (DataBundles.isList(path)) {
-			List<Path> list = DataBundles.getList(path);
-			List<Object> objectList = new ArrayList<Object>(list.size());
-			for (Path pathElement : list) {
-				objectList.add(convertPathToObject(pathElement));
-			}
-			object = objectList;
-		}
-		return object;
-	}
-}


[12/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/UnrecognizedActivity.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/UnrecognizedActivity.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/UnrecognizedActivity.java
new file mode 100644
index 0000000..90bbcb9
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/UnrecognizedActivity.java
@@ -0,0 +1,57 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity;
+
+import org.jdom.Element;
+
+/**
+ * An unrecognized activity is an activity that was not recognized when the
+ * workflow was opened.
+ * 
+ * @author alanrw
+ */
+public final class UnrecognizedActivity extends NonExecutableActivity<Element> {
+	public static final String URI = "http://ns.taverna.org.uk/2010/activity/unrecognized";
+
+	private Element conf;
+
+	/**
+	 * It is not possible to create a "naked" UnrecognizedActivity.
+	 */
+	private UnrecognizedActivity() {
+		super();
+	}
+
+	public UnrecognizedActivity(Element config)
+			throws ActivityConfigurationException {
+		this();
+		this.configure(config);
+	}
+
+	@Override
+	public void configure(Element conf) throws ActivityConfigurationException {
+		this.conf = conf;
+	}
+
+	@Override
+	public Element getConfiguration() {
+		return conf;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/config/ActivityInputPortDefinitionBean.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/config/ActivityInputPortDefinitionBean.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/config/ActivityInputPortDefinitionBean.java
new file mode 100644
index 0000000..a8fd163
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/config/ActivityInputPortDefinitionBean.java
@@ -0,0 +1,66 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity.config;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.workflowmodel.processor.config.ConfigurationBean;
+
+/**
+ * A bean that describes properties of an Input port.
+ * 
+ * @author Stuart Owen
+ * @author Stian Soiland-Reyes
+ */
+@ConfigurationBean(uri = "http://ns.taverna.org.uk/2010/scufl2#InputPortDefinition")
+public class ActivityInputPortDefinitionBean extends ActivityPortDefinitionBean {
+	private List<Class<? extends ExternalReferenceSPI>> handledReferenceSchemes;
+	private Class<?> translatedElementType;
+	private boolean allowsLiteralValues;
+
+	public List<Class<? extends ExternalReferenceSPI>> getHandledReferenceSchemes() {
+		if (handledReferenceSchemes == null)
+			return Collections.emptyList();
+		return handledReferenceSchemes;
+	}
+
+	public void setHandledReferenceSchemes(
+			List<Class<? extends ExternalReferenceSPI>> handledReferenceSchemes) {
+		this.handledReferenceSchemes = handledReferenceSchemes;
+	}
+
+	public Class<?> getTranslatedElementType() {
+		return translatedElementType;
+	}
+
+	public void setTranslatedElementType(Class<?> translatedElementType) {
+		this.translatedElementType = translatedElementType;
+	}
+
+	public boolean getAllowsLiteralValues() {
+		return allowsLiteralValues;
+	}
+
+	public void setAllowsLiteralValues(boolean allowsLiteralValues) {
+		this.allowsLiteralValues = allowsLiteralValues;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/config/ActivityOutputPortDefinitionBean.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/config/ActivityOutputPortDefinitionBean.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/config/ActivityOutputPortDefinitionBean.java
new file mode 100644
index 0000000..0f087cb
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/config/ActivityOutputPortDefinitionBean.java
@@ -0,0 +1,48 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity.config;
+
+import org.apache.taverna.workflowmodel.OutputPort;
+import org.apache.taverna.workflowmodel.processor.config.ConfigurationBean;
+
+/**
+ * A bean that describes properties of an Output port.
+ * 
+ * @author Stuart Owen
+ */
+@ConfigurationBean(uri = "http://ns.taverna.org.uk/2010/scufl2#OutputPortDefinition")
+public class ActivityOutputPortDefinitionBean extends ActivityPortDefinitionBean {
+	private int granularDepth;
+
+	/**
+	 * @return the granular depth of the port
+	 * @see OutputPort#getGranularDepth()
+	 */
+	public int getGranularDepth() {
+		return granularDepth;
+	}
+
+	/**
+	 * @param granularDepth the granular depth of the port
+	 */
+	public void setGranularDepth(int granularDepth) {
+		this.granularDepth = granularDepth;
+	}	
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/config/ActivityPortDefinitionBean.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/config/ActivityPortDefinitionBean.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/config/ActivityPortDefinitionBean.java
new file mode 100644
index 0000000..0cf9172
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/config/ActivityPortDefinitionBean.java
@@ -0,0 +1,103 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity.config;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.taverna.workflowmodel.processor.config.ConfigurationBean;
+import org.apache.taverna.workflowmodel.processor.config.ConfigurationProperty;
+
+/**
+ * A generic bean that describes the shared properties of input and output
+ * ports.
+ * 
+ * @author Stuart Owen
+ * 
+ */
+@ConfigurationBean(uri = "http://ns.taverna.org.uk/2010/scufl2#PortDefinition")
+public abstract class ActivityPortDefinitionBean {
+	private String name;
+	private int depth;
+	private List<String> mimeTypes;
+
+	/**
+	 * @return the port name
+	 */
+	public String getName() {
+		return name;
+	}
+
+	/**
+	 * @param name
+	 *            the port name
+	 */
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	/**
+	 * @return the depth of the port
+	 */
+	public int getDepth() {
+		return depth;
+	}
+
+	/**
+	 * @param depth
+	 *            the depth of the port
+	 */
+	public void setDepth(int depth) {
+		this.depth = depth;
+	}
+
+	/**
+	 * @return a list a MIME types that describe the port
+	 */
+	public List<String> getMimeTypes() {
+		if (mimeTypes == null)
+			return Collections.emptyList();
+		return mimeTypes;
+	}
+
+	/**
+	 * @param mimeTypes
+	 *            the list of MIME-types that describe the port
+	 */
+	public void setMimeTypes(List<String> mimeTypes) {
+		this.mimeTypes = mimeTypes;
+	}
+
+	/**
+	 * @param mimeTypes
+	 *            the list of MIME-types that describe the port
+	 */
+	@ConfigurationProperty(name = "expectedMimeType", label = "Mime Types", description = "The MIME-types that describe the port", required = false)
+	public void setMimeTypes(Set<URI> mimeTypes) {
+		this.mimeTypes = new ArrayList<>();
+		for (URI uri : mimeTypes)
+			this.mimeTypes.add("'"
+					+ URI.create("http://purl.org/NET/mediatypes/").relativize(
+							uri) + "'");
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/config/ActivityPortsDefinitionBean.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/config/ActivityPortsDefinitionBean.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/config/ActivityPortsDefinitionBean.java
new file mode 100644
index 0000000..ee770d4
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/config/ActivityPortsDefinitionBean.java
@@ -0,0 +1,81 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity.config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+import org.apache.taverna.workflowmodel.processor.config.ConfigurationBean;
+import org.apache.taverna.workflowmodel.processor.config.ConfigurationProperty;
+
+/**
+ * <p>
+ * Defines a configuration type that relates directly to an {@link Activity} and
+ * in particular defines details its input and output ports.<br>
+ * An Activity that has its ports implicitly defined may define a ConfigType
+ * that extends this class, but this is not enforced.
+ * </p>
+ * 
+ * @author Stuart Owen
+ */
+@ConfigurationBean(uri = "http://ns.taverna.org.uk/2010/scufl2#ActivityPortsDefinition")
+public class ActivityPortsDefinitionBean {
+	private List<ActivityInputPortDefinitionBean> inputs = new ArrayList<>();
+	private List<ActivityOutputPortDefinitionBean> outputs = new ArrayList<>();
+
+	/**
+	 * @return a list of {@link ActivityInputPortDefinitionBean} that describes
+	 *         each input port
+	 */
+	public List<ActivityInputPortDefinitionBean> getInputPortDefinitions() {
+		return inputs;
+	}
+
+	/**
+	 * @return a list of {@link ActivityOutputPortDefinitionBean} that describes
+	 *         each output port.
+	 */
+	public List<ActivityOutputPortDefinitionBean> getOutputPortDefinitions() {
+		return outputs;
+	}
+
+	/**
+	 * @param portDefinitions
+	 *            a list of {@link ActivityInputPortDefinitionBean} that
+	 *            describes each input port
+	 */
+	@ConfigurationProperty(name = "inputPortDefinition", label = "Input Ports", description = "", required = false, ordering = ConfigurationProperty.OrderPolicy.NON_ORDERED)
+	public void setInputPortDefinitions(
+			List<ActivityInputPortDefinitionBean> portDefinitions) {
+		inputs = portDefinitions;
+	}
+
+	/**
+	 * @param portDefinitions
+	 *            a list of {@link ActivityOutputPortDefinitionBean} that
+	 *            describes each output port
+	 */
+	@ConfigurationProperty(name = "outputPortDefinition", label = "Output Ports", description = "", required = false, ordering = ConfigurationProperty.OrderPolicy.NON_ORDERED)
+	public void setOutputPortDefinitions(
+			List<ActivityOutputPortDefinitionBean> portDefinitions) {
+		outputs = portDefinitions;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/config/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/config/package.html b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/config/package.html
new file mode 100644
index 0000000..fa104d7
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/config/package.html
@@ -0,0 +1,7 @@
+<body>
+A set of helper classes to aid in defining how Activities are configured.
+An Activity class is associated with a ConfigurationType, which is an arbitrary Java object defining
+how the Activity should be configured.<br>
+This package provides classes and interfaces that help in creating these ConfigurationTypes with details that are common
+across different Activities, but there use is in no way enforced.
+</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/package.html b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/package.html
new file mode 100644
index 0000000..72a9076
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/package.html
@@ -0,0 +1,10 @@
+<body>
+Provides definitions for a single Activity to be contained within a
+Processor. Activity was previously called 'Service' but this was
+somewhat misleading as there wasn't always a service backing it. The
+Activity may be abstract, it may be synchronous or asynchronous in which
+case it uses a callback mechanism. It doesn't carry around annotation
+itself instead using an activity annotation container to handle this
+(this avoids third parties having to manage annotation containment
+themselves).
+</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/config/ConfigurationBean.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/config/ConfigurationBean.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/config/ConfigurationBean.java
new file mode 100644
index 0000000..4d2cf0f
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/config/ConfigurationBean.java
@@ -0,0 +1,31 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.config;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface ConfigurationBean {
+	String uri();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/config/ConfigurationProperty.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/config/ConfigurationProperty.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/config/ConfigurationProperty.java
new file mode 100644
index 0000000..8dc2167
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/config/ConfigurationProperty.java
@@ -0,0 +1,46 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.config;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface ConfigurationProperty {
+	// TODO document this
+	String name();
+
+	String label() default "";
+
+	String description() default "";
+
+	boolean required() default true;
+
+	OrderPolicy ordering() default OrderPolicy.DEFAULT;
+
+	enum OrderPolicy {
+		DEFAULT, NON_ORDERED
+	}
+
+	String uri() default "";
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/AbstractDispatchLayer.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/AbstractDispatchLayer.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/AbstractDispatchLayer.java
new file mode 100644
index 0000000..3eb77e3
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/AbstractDispatchLayer.java
@@ -0,0 +1,102 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch;
+
+import java.util.Timer;
+
+import org.apache.taverna.workflowmodel.Processor;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchCompletionEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchErrorEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchJobEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchJobQueueEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchResultEvent;
+
+/**
+ * Convenience abstract implementation of DispatchLayer
+ * 
+ * @author Tom Oinn
+ */
+public abstract class AbstractDispatchLayer<ConfigurationType> implements
+		DispatchLayer<ConfigurationType> {
+	protected static Timer cleanupTimer = new Timer(
+			"Dispatch stack state cleanup", true);
+	protected static final int CLEANUP_DELAY_MS = 1000;
+
+	@Override
+	public void setDispatchStack(DispatchStack parentStack) {
+		this.dispatchStack = parentStack;
+	}
+
+	protected DispatchStack dispatchStack;
+
+	protected final DispatchLayer<?> getAbove() {
+		return dispatchStack.layerAbove(this);
+	}
+
+	protected final DispatchLayer<?> getBelow() {
+		return dispatchStack.layerBelow(this);
+	}
+
+	@Override
+	public void receiveError(DispatchErrorEvent errorEvent) {
+		DispatchLayer<?> above = dispatchStack.layerAbove(this);
+		if (above != null)
+			above.receiveError(errorEvent);
+	}
+
+	@Override
+	public void receiveJob(DispatchJobEvent jobEvent) {
+		DispatchLayer<?> below = dispatchStack.layerBelow(this);
+		if (below != null)
+			below.receiveJob(jobEvent);
+	}
+
+	@Override
+	public void receiveJobQueue(DispatchJobQueueEvent jobQueueEvent) {
+		DispatchLayer<?> below = dispatchStack.layerBelow(this);
+		if (below != null)
+			below.receiveJobQueue(jobQueueEvent);
+	}
+
+	@Override
+	public void receiveResult(DispatchResultEvent resultEvent) {
+		DispatchLayer<?> above = dispatchStack.layerAbove(this);
+		if (above != null)
+			above.receiveResult(resultEvent);
+	}
+
+	@Override
+	public void receiveResultCompletion(DispatchCompletionEvent completionEvent) {
+		DispatchLayer<?> above = dispatchStack.layerAbove(this);
+		if (above != null)
+			above.receiveResultCompletion(completionEvent);
+	}
+
+	@Override
+	public void finishedWith(String owningProcess) {
+		// Do nothing by default
+	}
+
+	public Processor getProcessor() {
+		if (dispatchStack == null)
+			return null;
+		return dispatchStack.getProcessor();
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/AbstractErrorHandlerLayer.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/AbstractErrorHandlerLayer.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/AbstractErrorHandlerLayer.java
new file mode 100644
index 0000000..2cf0038
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/AbstractErrorHandlerLayer.java
@@ -0,0 +1,282 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchCompletionEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchErrorEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchJobEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchResultEvent;
+
+/**
+ * Superclass of error handling dispatch layers (for example retry and
+ * failover). Provides generic functionality required by this class of layers.
+ * 
+ * @author Tom Oinn
+ * @author Stian Soiland-Reyes
+ */
+public abstract class AbstractErrorHandlerLayer<ConfigurationType> extends
+		AbstractDispatchLayer<ConfigurationType> {
+	private static Logger logger = Logger
+			.getLogger(AbstractErrorHandlerLayer.class);
+
+	/**
+	 * Compare two arrays of ints, return true if they are the same length and
+	 * if at every index the two integer values are equal
+	 * 
+	 * @param a
+	 * @param b
+	 * @return
+	 */
+	private static boolean identicalIndex(int[] a, int[] b) {
+		if (a.length != b.length)
+			return false;
+		for (int i = 0; i < a.length; i++)
+			if (a[i] != b[i])
+				return false;
+		return true;
+	}
+
+	/**
+	 * Map of process name -> list of state models. Note that all access to this
+	 * map must be synchronized on the stateMap, and access to the lists inside
+	 * it must be synchronized on the list.
+	 * 
+	 * @see #addJobToStateList(DispatchJobEvent)
+	 * @see #removeJob(String, JobState)
+	 * @see #getJobsDefault(String)
+	 * @see #getJobsCopy(String)
+	 */
+	private Map<String, List<JobState>> stateMap = new HashMap<>();
+
+	protected AbstractErrorHandlerLayer() {
+		super();
+	}
+
+	/**
+	 * Clear cached state for the specified process when notified by the
+	 * dispatch stack
+	 */
+	@Override
+	public void finishedWith(String owningProcess) {
+		synchronized (stateMap) {
+			stateMap.remove(owningProcess);
+		}
+	}
+
+	/**
+	 * If an error occurs we can either handle the error or send it to the layer
+	 * above for further processing.
+	 */
+	@Override
+	public void receiveError(DispatchErrorEvent errorEvent) {
+		String owningProcess = errorEvent.getOwningProcess();
+		for (JobState rs : getJobsCopy(owningProcess))
+			if (identicalIndex(rs.jobEvent.getIndex(), errorEvent.getIndex())) {
+				boolean handled = rs.handleError();
+				if (!handled) {
+					removeJob(owningProcess, rs);
+					getAbove().receiveError(errorEvent);
+					return;
+				}
+			}
+	}
+
+	/**
+	 * Receive a job from the layer above, store it for later retries and pass
+	 * it down to the next layer
+	 */
+	@Override
+	public void receiveJob(DispatchJobEvent jobEvent) {
+		addJobToStateList(jobEvent);
+		getBelow().receiveJob(jobEvent);
+	}
+
+	/**
+	 * If we see a result with an index matching one of those in the current
+	 * retry state we can safely forget that state object
+	 */
+	@Override
+	public void receiveResult(DispatchResultEvent j) {
+		forget(j.getOwningProcess(), j.getIndex());
+		getAbove().receiveResult(j);
+	}
+
+	/**
+	 * If we see a completion event with an index matching one of those in the
+	 * current retry state we can safely forget that state object
+	 */
+	@Override
+	public void receiveResultCompletion(DispatchCompletionEvent c) {
+		forget(c.getOwningProcess(), c.getIndex());
+		getAbove().receiveResultCompletion(c);
+	}
+
+	/**
+	 * Remove the specified pending retry job from the cache
+	 * 
+	 * @param owningProcess
+	 *            Owning process identifier as returned by
+	 *            {@link DispatchJobEvent#getOwningProcess()}
+	 * @param index
+	 *            Index of the job as returned by
+	 *            {@link DispatchJobEvent#getIndex()}
+	 */
+	protected void forget(String owningProcess, int[] index) {
+		for (JobState jobState : getJobsCopy(owningProcess))
+			if (identicalIndex(jobState.jobEvent.getIndex(), index)) {
+				removeJob(owningProcess, jobState);
+				return;
+			}
+		// It could be due to pipelining activities like BioMart 
+		logger.debug("Could not forget " + owningProcess + " " + Arrays.toString(index));
+	}
+
+	protected void addJobToStateList(DispatchJobEvent jobEvent) {
+		List<JobState> stateList = null;
+		stateList = getJobsDefault(jobEvent.getOwningProcess());
+		synchronized (stateList) {
+			stateList.add(getStateObject(jobEvent));
+		}
+	}
+
+	/**
+	 * Get a copy of the list of {@link JobState}s for the owning process, or an
+	 * empty list if the owning process is unknown or have been
+	 * {@link #forget(String, int[]) forgotten}.
+	 * <p>
+	 * This list can safely be iterated over without synchronizing. If you need
+	 * to modify the list, either synchronize over the returned list from
+	 * {@link #getJobsDefault(String)} or use
+	 * {@link #removeJob(String, JobState)}.
+	 * 
+	 * @param owningProcess
+	 *            Owning process identifier as returned by
+	 *            {@link DispatchJobEvent#getOwningProcess()}
+	 * @return A copy of the list of known JobState {@link JobState}s for the
+	 *         owning process,
+	 */
+	protected List<JobState> getJobsCopy(String owningProcess) {
+		List<JobState> activeJobs;
+		synchronized (stateMap) {
+			activeJobs = stateMap.get(owningProcess);
+		}
+		if (activeJobs == null) {
+			logger.warn("Could not find any active jobs for " + owningProcess);
+			return Collections.emptyList();
+		}
+		// Take a copy of the list so we don't modify it while iterating over it
+		List<JobState> activeJobsCopy;
+		synchronized (activeJobs) {
+			activeJobsCopy = new ArrayList<>(activeJobs);
+		}
+		return activeJobsCopy;
+	}
+
+	/**
+	 * Get the list of {@link JobState}s for the owning process, creating and
+	 * adding it to the state map if necessary.
+	 * <p>
+	 * Note that all access to the returned list must be synchronized on the
+	 * list to avoid threading issues.
+	 * <p>
+	 * If you are going to iterate over the list, use
+	 * {@link #getJobsCopy(String)} instead.
+	 * 
+	 * @see #getJobsCopy(String)
+	 * @param owningProcess
+	 *            Owning process identifier as returned by
+	 *            {@link DispatchJobEvent#getOwningProcess()}
+	 * 
+	 * @return List of {@link JobState}s for the owning process
+	 */
+	protected List<JobState> getJobsDefault(String owningProcess) {
+		List<JobState> stateList;
+		synchronized (stateMap) {
+			stateList = stateMap.get(owningProcess);
+			if (stateList == null) {
+				stateList = new ArrayList<>();
+				stateMap.put(owningProcess, stateList);
+			}
+		}
+		return stateList;
+	}
+
+	/**
+	 * Generate an appropriate state object from the specified job event. The
+	 * state object is a concrete subclass of JobState.
+	 * 
+	 * @return
+	 */
+	protected abstract JobState getStateObject(DispatchJobEvent jobEvent);
+
+	protected void removeJob(String owningProcess, JobState jobState) {
+		List<JobState> activeJobs;
+		synchronized (stateMap) {
+			activeJobs = stateMap.get(owningProcess);
+		}
+		if (activeJobs == null) {
+			logger.error("Could not find active jobs for " + owningProcess);
+			return;
+		}
+		synchronized (activeJobs) {
+			activeJobs.remove(jobState);
+		}
+	}
+
+	/**
+	 * Abstract superclass of all state models for pending failure handlers.
+	 * This object is responsible for handling failure messages if they occur
+	 * and represents the current state of the failure handling algorithm on a
+	 * per job basis.
+	 * 
+	 * @author Tom Oinn
+	 */
+	protected abstract class JobState {
+		protected DispatchJobEvent jobEvent;
+
+		protected JobState(DispatchJobEvent jobEvent) {
+			this.jobEvent = jobEvent;
+		}
+
+		/**
+		 * Called when the layer below pushes an error up and where the error
+		 * index and owning process matches that of this state object. The
+		 * implementation must deal with the error, either by handling it and
+		 * pushing a new job down the stack or by rejecting it. If this method
+		 * returns false the error has not been dealt with and MUST be pushed up
+		 * the stack by the active dispatch layer. In this case the layer will
+		 * be a subclass of AbstractErrorHandlerLayer and the logic to do this
+		 * is already included in the receive methods for results, errors and
+		 * completion events.
+		 * 
+		 * @return true if the error was handled.
+		 */
+		public abstract boolean handleError();
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/DispatchLayer.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/DispatchLayer.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/DispatchLayer.java
new file mode 100644
index 0000000..574de6e
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/DispatchLayer.java
@@ -0,0 +1,96 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch;
+
+import org.apache.taverna.workflowmodel.Configurable;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchCompletionEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchErrorEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchJobEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchJobQueueEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchResultEvent;
+
+/**
+ * Layers within the dispatch stack define a control flow to handle dispatch of
+ * jobs from a queue (generated by the iteration system) to appropriate
+ * activities.
+ * <p>
+ * A dispatch layer can receive a reference to the Queue and a set of
+ * Activities, or a single Job and a set of Activities from the layer above it
+ * (or from the DispatchStackImpl object itself if this is the top layer). It
+ * can receive errors, results and partial or total completion events from the
+ * layer immediately below it.
+ * <p>
+ * To assist in graphical representation of the dispatch configuration each
+ * layer declares for each class of message whether it intercepts and alters,
+ * intercepts and observes or ignores (forwards) the message onto the next layer
+ * (either up or down depending on the message) and whether the layer is capable
+ * of instigating the creation of each class of message.
+ * 
+ * @author Tom Oinn
+ */
+public interface DispatchLayer<ConfigurationType> extends
+		Configurable<ConfigurationType> {
+	/**
+	 * Receive a pointer to the job queue along with a set of activities, this
+	 * is received from the layer above in the dispatch stack or from the
+	 * DispatchStackImpl object itself if this is the top layer.
+	 */
+	void receiveJobQueue(DispatchJobQueueEvent queueEvent);
+
+	/**
+	 * Receive a single job and associated set of activities from the layer
+	 * above
+	 */
+	void receiveJob(DispatchJobEvent jobEvent);
+
+	/**
+	 * Receive a single error reference from the layer below
+	 */
+	void receiveError(DispatchErrorEvent errorEvent);
+
+	/**
+	 * Receive a result from the layer below
+	 */
+	void receiveResult(DispatchResultEvent resultEvent);
+
+	/**
+	 * Receive a (possibly partial) completion event from the layer below. This
+	 * is only going to be used when the activities invocation is capable of
+	 * streaming partial data back up through the dispatch stack before the
+	 * activities has completed. Not all dispatch stack layers are compatible
+	 * with this mode of operation, for example retry and recursion do not play
+	 * well here!
+	 */
+	void receiveResultCompletion(DispatchCompletionEvent completionEvent);
+
+	/**
+	 * Called when there will be no more events with the specified process
+	 * identifier, can be used to purge cached state from layers within the
+	 * stack
+	 */
+	void finishedWith(String owningProcess);
+
+	/**
+	 * Set the parent dispatch stack of this layer, this is called when a layer
+	 * is added to the dispatch stack and can be safely ignored by end users of
+	 * this API
+	 */
+	void setDispatchStack(DispatchStack stack);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/DispatchLayerFactory.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/DispatchLayerFactory.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/DispatchLayerFactory.java
new file mode 100644
index 0000000..58fa076
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/DispatchLayerFactory.java
@@ -0,0 +1,61 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch;
+
+import java.net.URI;
+import java.util.Set;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * Factory for creating {@link DispatchLayer} instances.
+ * 
+ * @author David Withers
+ */
+public interface DispatchLayerFactory {
+	/**
+	 * Creates a new {@link DispatchLayer} instance.
+	 * 
+	 * @param dispatchLayerType
+	 *            the type of the {@link DispatchLayer}
+	 * @return a new <code>DispatchLayer</code> instance
+	 */
+	DispatchLayer<?> createDispatchLayer(URI dispatchLayerType);
+
+	/**
+	 * Returns the types of the {@link DispatchLayer}s that this factory
+	 * can create.
+	 * 
+	 * @return the types of the {@link DispatchLayer}s that this factory
+	 *         can create
+	 */
+	Set<URI> getDispatchLayerTypes();
+
+	/**
+	 * Returns the JSON Schema for the configuration required by the
+	 * {@link DispatchLayer}.
+	 * 
+	 * @param dispatchLayerType
+	 *            the type of the {@link DispatchLayer}
+	 * @return the JSON Schema for the configuration required by the
+	 *         {@link DispatchLayer}
+	 */
+	JsonNode getDispatchLayerConfigurationSchema(URI dispatchLayerType);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/DispatchStack.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/DispatchStack.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/DispatchStack.java
new file mode 100644
index 0000000..16084c7
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/DispatchStack.java
@@ -0,0 +1,99 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch;
+
+import static org.apache.taverna.annotation.HierarchyRole.CHILD;
+import static org.apache.taverna.annotation.HierarchyRole.PARENT;
+
+import java.util.List;
+
+import org.apache.taverna.annotation.Annotated;
+import org.apache.taverna.annotation.HierarchyTraversal;
+import org.apache.taverna.monitor.MonitorableProperty;
+import org.apache.taverna.workflowmodel.Processor;
+import org.apache.taverna.workflowmodel.WorkflowItem;
+
+/**
+ * The dispatch stack is responsible for consuming a queue of jobs from the
+ * iteration strategy and dispatching those jobs through a stack based control
+ * flow to an appropriate invocation target. Conceptually the queue and
+ * description of activities enter the stack at the top, travel down to an
+ * invocation layer at the bottom from which results, errors and completion
+ * events rise back up to the top layer. Dispatch stack layers are stored as an
+ * ordered list with index 0 being the top of the stack.
+ * 
+ * @author Tom Oinn
+ */
+public interface DispatchStack extends Annotated<DispatchStack>, WorkflowItem {
+	/**
+	 * The DispatchStack consists of an ordered list of DispatchLayer instances
+	 * where the DispatchLayer at index zero is at the bottom of the stack and
+	 * is almost always an invocation layer of some kind (in any working
+	 * dispatch stack configuration)
+	 * 
+	 */
+	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
+	List<DispatchLayer<?>> getLayers();
+
+	/**
+	 * The dispatch stack is contained within a processor, this can be null if
+	 * the stack is being used out of this context but layers may be relying on
+	 * this link to get information about the processor input ports and their
+	 * annotations for various reasons.
+	 */
+	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { PARENT })
+	Processor getProcessor();
+
+	/**
+	 * Return the layer above (lower index!) the specified layer, or a reference
+	 * to the internal top layer dispatch layer if there is no layer above the
+	 * specified one. Remember - input data and activities go down, results,
+	 * errors and completion events bubble back up the dispatch stack.
+	 * <p>
+	 * The top layer within the dispatch stack is always invisible and is held
+	 * within the DispatchStackImpl object itself, being used to route data out
+	 * of the entire stack
+	 * 
+	 * @param layer
+	 * @return
+	 */
+	DispatchLayer<?> layerAbove(DispatchLayer<?> layer);
+
+	/**
+	 * Return the layer below (higher index) the specified layer, or null if
+	 * there is no layer below this one.
+	 * 
+	 * @param layer
+	 * @return
+	 */
+	DispatchLayer<?> layerBelow(DispatchLayer<?> layer);
+
+	/**
+	 * The dispatch stack acts as an aggregator for monitorable properties
+	 * exposed by the dispatch layers. This is distinct from layers which are
+	 * capable of rewriting the process idenfitier of tokens - these require
+	 * their own nodes in the monitor in addition to any contributed properties.
+	 * 
+	 * @param prop
+	 * @param processID
+	 */
+	void receiveMonitorableProperty(MonitorableProperty<?> prop,
+			String processID);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/NotifiableLayer.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/NotifiableLayer.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/NotifiableLayer.java
new file mode 100644
index 0000000..4d86884
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/NotifiableLayer.java
@@ -0,0 +1,39 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch;
+
+import org.apache.taverna.invocation.Completion;
+import org.apache.taverna.workflowmodel.processor.activity.Job;
+
+/**
+ * If a layer requires notification of the arrival of new items to the event
+ * queues within the dispatcher it should implement this interface.
+ * 
+ * @author Tom Oinn
+ */
+public interface NotifiableLayer {
+	/**
+	 * Called when a new {@link Job} or {@link Completion} is added to a queue
+	 * within the dispatch stack
+	 * 
+	 * @param owningProcess
+	 */
+	void eventAdded(String owningProcess);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/PropertyContributingDispatchLayer.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/PropertyContributingDispatchLayer.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/PropertyContributingDispatchLayer.java
new file mode 100644
index 0000000..ef87bd8
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/PropertyContributingDispatchLayer.java
@@ -0,0 +1,63 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch;
+
+/**
+ * Used by dispatch layers which can contribute property information to their
+ * parent processor instance. This is distinct from dispatch layers which modify
+ * the process identifier and therefore create their own nodes in the monitor
+ * tree, although there's no reason a layer can't perform both functions. For
+ * example, the fault tolerance layers create their own state subtrees for each
+ * failure recovery but could also contribute aggregate fault information to the
+ * parent processor's property set.
+ * 
+ * @author Tom Oinn
+ * 
+ * @param <ConfigType>
+ *            configuration type for the dispatch layer
+ */
+public interface PropertyContributingDispatchLayer<ConfigType> extends
+		DispatchLayer<ConfigType> {
+	/**
+	 * Inject properties for the specified owning process into the parent
+	 * dispatch stack. At some point prior to this call being made the
+	 * setDispatchStack will have been called, implementations of this method
+	 * need to use this DispatchStack reference to push properties in with the
+	 * specified key.
+	 * <p>
+	 * Threading - this thread must not fork, do all the work in this method in
+	 * the thread you're given by the caller. This is because implementations
+	 * may assume that they can collect properties from the dispatch stack
+	 * implementation (which will expose them through a private access method to
+	 * prevent arbitrary access to layer properties) once this call has
+	 * returned.
+	 * <p>
+	 * There is no guarantee that the layer will have seen an event with the
+	 * specified process, and in fact it's unlikely to in the general case as
+	 * any layers above it are free to modify the process identifier of tokens
+	 * as they go. Remember that this method is for aggregating properties into
+	 * the top level (processor) view so you may need to implement the property
+	 * getters such that they check prefixes of identifiers rather than
+	 * equality.
+	 * 
+	 * @param owningProcess
+	 */
+	void injectPropertiesFor(String owningProcess);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerErrorReaction.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerErrorReaction.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerErrorReaction.java
new file mode 100644
index 0000000..1fadabe
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerErrorReaction.java
@@ -0,0 +1,43 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.description;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Describes how a dispatch layer reacts to an error message
+ * 
+ * @author Tom Oinn
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@Documented
+@ReactionTo(messageType = DispatchMessageType.ERROR)
+public @interface DispatchLayerErrorReaction {
+	public DispatchLayerStateEffect[] stateEffects();
+
+	public DispatchMessageType[] emits();
+
+	public boolean relaysUnmodified();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerJobQueueReaction.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerJobQueueReaction.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerJobQueueReaction.java
new file mode 100644
index 0000000..f6a55ca
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerJobQueueReaction.java
@@ -0,0 +1,44 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.description;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Describes how a dispatch layer reacts to a Job Queue message
+ * 
+ * @author Tom Oinn
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@Documented
+@ReactionTo(messageType = DispatchMessageType.JOB_QUEUE)
+public @interface DispatchLayerJobQueueReaction {
+
+	public DispatchLayerStateEffect[] stateEffects();
+
+	public DispatchMessageType[] emits();
+
+	public boolean relaysUnmodified();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerJobReaction.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerJobReaction.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerJobReaction.java
new file mode 100644
index 0000000..79e5583
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerJobReaction.java
@@ -0,0 +1,43 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.description;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Describes how a dispatch layer reacts to a Job message
+ * 
+ * @author Tom Oinn
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@Documented
+@ReactionTo(messageType = DispatchMessageType.JOB)
+public @interface DispatchLayerJobReaction {
+	public DispatchLayerStateEffect[] stateEffects();
+
+	public DispatchMessageType[] emits();
+	
+	public boolean relaysUnmodified();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerResultCompletionReaction.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerResultCompletionReaction.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerResultCompletionReaction.java
new file mode 100644
index 0000000..b243ef7
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerResultCompletionReaction.java
@@ -0,0 +1,43 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.description;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Describes how a dispatch layer reacts to a result completion message
+ * 
+ * @author Tom Oinn
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@Documented
+@ReactionTo(messageType = DispatchMessageType.RESULT_COMPLETION)
+public @interface DispatchLayerResultCompletionReaction {
+	public DispatchLayerStateEffect[] stateEffects();
+
+	public DispatchMessageType[] emits();
+
+	public boolean relaysUnmodified();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerResultReaction.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerResultReaction.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerResultReaction.java
new file mode 100644
index 0000000..2aad593
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerResultReaction.java
@@ -0,0 +1,43 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.description;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Describes how a dispatch layer responds to a result message
+ * 
+ * @author Tom Oinn
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@Documented
+@ReactionTo(messageType = DispatchMessageType.RESULT)
+public @interface DispatchLayerResultReaction {
+	public DispatchLayerStateEffect[] stateEffects();
+
+	public DispatchMessageType[] emits();
+
+	public boolean relaysUnmodified();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerStateEffect.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerStateEffect.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerStateEffect.java
new file mode 100644
index 0000000..56eb26d
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchLayerStateEffect.java
@@ -0,0 +1,83 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.description;
+
+/**
+ * Describes the effect of a message on the state of a dispatch layer, used by
+ * DispatchLayerReaction. If no message causes any of these actions the layer
+ * can be described as state free.
+ * 
+ * @author Tom Oinn
+ */
+public enum DispatchLayerStateEffect {
+	/**
+	 * The message causes a state object within the dispatch layer to be created
+	 * keyed on the process identifier and index
+	 */
+	CREATE_LOCAL_STATE,
+
+	/**
+	 * The message causes the removal of a state object within the dispatch
+	 * layer, the layer to be removed is keyed on process identifier and index
+	 * of the message
+	 */
+	REMOVE_LOCAL_STATE,
+
+	/**
+	 * The message causes the modification of a previously stored state object
+	 * within the dispatch layer, the state object modified is keyed on process
+	 * identifier and index of the message.
+	 */
+	UPDATE_LOCAL_STATE,
+
+	/**
+	 * The message causes a state object within the dispatch layer to be created
+	 * keyed only on the process identifier and not on the index of the message.
+	 */
+	CREATE_PROCESS_STATE,
+
+	/**
+	 * The message causes a state object to be removed from the dispatch layer,
+	 * the state object is identified only by the process identifier
+	 */
+	REMOVE_PROCESS_STATE,
+
+	/**
+	 * The message causes a state object to be modified, the state object is
+	 * identified by process identifier only
+	 */
+	UPDATE_PROCESS_STATE,
+
+	/**
+	 * The message causes global level state to be modified within the dispatch
+	 * layer
+	 */
+	UPDATE_GLOBAL_STATE,
+
+	/**
+	 * The message has no effect on state. This value is used when specifying
+	 * that a message might cause effect or it might not, the interpretation of
+	 * the various reaction annotations is that exactly one of the state effects
+	 * will take place, so if the state side effect array isn't empty you have
+	 * to insert this one to specify that it's possible that no state change
+	 * will occur
+	 */
+	NO_EFFECT;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchMessageType.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchMessageType.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchMessageType.java
new file mode 100644
index 0000000..c809e9f
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/DispatchMessageType.java
@@ -0,0 +1,60 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.description;
+
+/**
+ * Enumeration of the possible message types passed between layers of the
+ * dispatch stack.
+ * 
+ * @author Tom Oinn
+ */
+public enum DispatchMessageType {
+	/**
+	 * A reference to a queue of Job objects waiting to be used as input along
+	 * with a list of activities to process them.
+	 */
+	JOB_QUEUE,
+
+	/**
+	 * A Job object and list of activities to be used to process the data in the
+	 * Job. The Job will have been previously extracted from the JobQueue
+	 */
+	JOB,
+
+	/**
+	 * A Job object containing the result of a single activity invocation.
+	 */
+	RESULT,
+
+	/**
+	 * A (possibly partial) completion event from the layer below. This is only
+	 * going to be used when the activity invocation is capable of streaming
+	 * partial data back up through the dispatch stack before the activity has
+	 * completed. Not all dispatch stack layers are compatible with this mode of
+	 * operation, for example retry and recursion do not play well here!
+	 */
+	RESULT_COMPLETION,
+
+	/**
+	 * A failure message sent by the layer below to denote some kind of failure
+	 * (surprisingly)
+	 */
+	ERROR;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/ReactionTo.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/ReactionTo.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/ReactionTo.java
new file mode 100644
index 0000000..30e052c
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/ReactionTo.java
@@ -0,0 +1,39 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.description;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Describes the type of message to which the various DispatchLayerFooReaction
+ * classes are referring
+ * 
+ * @author Tom Oinn
+ */
+@Documented
+@Target(ElementType.ANNOTATION_TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ReactionTo {
+	public DispatchMessageType messageType();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/SupportsStreamedResult.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/SupportsStreamedResult.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/SupportsStreamedResult.java
new file mode 100644
index 0000000..8852263
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/SupportsStreamedResult.java
@@ -0,0 +1,40 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.description;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Declares that a dispatch layer can handle streamed result data correctly, if
+ * this annotation is attached to a DispatchLayer implementation that
+ * implementation must be able to correctly handle the result completion message
+ * type. By default dispatch layers are assumed to not handle this message type.
+ * 
+ * @author Tom Oinn
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@Documented
+public @interface SupportsStreamedResult {
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/package.html b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/package.html
new file mode 100644
index 0000000..f0629bb
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/description/package.html
@@ -0,0 +1,3 @@
+<body>
+Annotations and enumerations used to describe dispatch layers, specifically the types of messages they can consume and their reactions to those messages.
+</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/AbstractDispatchEvent.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/AbstractDispatchEvent.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/AbstractDispatchEvent.java
new file mode 100644
index 0000000..66a95d7
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/AbstractDispatchEvent.java
@@ -0,0 +1,44 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.events;
+
+import org.apache.taverna.invocation.Event;
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchMessageType;
+
+/**
+ * Superclass of events within the dispatch stack
+ * 
+ * @author Tom Oinn
+ */
+public abstract class AbstractDispatchEvent<EventType extends AbstractDispatchEvent<EventType>>
+		extends Event<EventType> {
+	protected AbstractDispatchEvent(String owner, int[] index,
+			InvocationContext context) {
+		super(owner, index, context);
+	}
+
+	/**
+	 * Return the DispatchMessageType for this event object
+	 * 
+	 * @return instance of DispatchMessageType represented by this event
+	 */
+	public abstract DispatchMessageType getMessageType();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchCompletionEvent.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchCompletionEvent.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchCompletionEvent.java
new file mode 100644
index 0000000..6ef3f45
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchCompletionEvent.java
@@ -0,0 +1,69 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.events;
+
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchMessageType.RESULT_COMPLETION;
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.invocation.ProcessIdentifierException;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchMessageType;
+
+/**
+ * Dispatch event containing detailing a (potentially partial) completion of a
+ * stream of streaming result events. Layers which do not support streaming by
+ * definition can't cope with this event and the dispatch stack checker should
+ * prevent them from ever seeing it.
+ * 
+ * @author Tom Oinn
+ */
+public class DispatchCompletionEvent extends
+		AbstractDispatchEvent<DispatchCompletionEvent> {
+	/**
+	 * Construct a new dispatch result completion event
+	 * 
+	 * @param owner
+	 * @param index
+	 * @param context
+	 */
+	public DispatchCompletionEvent(String owner, int[] index,
+			InvocationContext context) {
+		super(owner, index, context);
+	}
+
+	@Override
+	public DispatchCompletionEvent popOwningProcess()
+			throws ProcessIdentifierException {
+		return new DispatchCompletionEvent(popOwner(), index, context);
+	}
+
+	@Override
+	public DispatchCompletionEvent pushOwningProcess(String localProcessName)
+			throws ProcessIdentifierException {
+		return new DispatchCompletionEvent(pushOwner(localProcessName), index,
+				context);
+	}
+
+	/**
+	 * DispatchMessageType.RESULT_COMPLETION
+	 */
+	@Override
+	public DispatchMessageType getMessageType() {
+		return RESULT_COMPLETION;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchErrorEvent.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchErrorEvent.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchErrorEvent.java
new file mode 100644
index 0000000..b57326e
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchErrorEvent.java
@@ -0,0 +1,118 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.events;
+
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchMessageType.ERROR;
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.invocation.ProcessIdentifierException;
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchMessageType;
+
+/**
+ * Message within the dispatch stack representing a single error report. This
+ * may then be handled by upstream layers to retry jobs etc. If it reaches the
+ * top of the dispatch stack the behaviour is configurable but by default it
+ * will abort that workflow instance, being treated as a catastrophic
+ * unhandleable problem.
+ * 
+ * @author Tom Oinn
+ */
+public class DispatchErrorEvent extends
+		AbstractDispatchEvent<DispatchErrorEvent> {
+	private Throwable cause;
+	private String message;
+	private DispatchErrorType failureType;
+	private Activity<?> failedActivity;
+
+	/**
+	 * Create a new error event
+	 * 
+	 * @param owningProcess
+	 * @param index
+	 * @param context
+	 * @param errorMessage
+	 * @param t
+	 */
+	public DispatchErrorEvent(String owningProcess, int[] index,
+			InvocationContext context, String errorMessage, Throwable t,
+			DispatchErrorType failureType, Activity<?> failedActivity) {
+		super(owningProcess, index, context);
+		this.message = errorMessage;
+		this.cause = t;
+		this.failureType = failureType;
+		this.failedActivity = failedActivity;
+	}
+
+	/**
+	 * Return the type of failure, this is used by upstream dispatch layers to
+	 * determine whether they can reasonably handle the error message
+	 */
+	public DispatchErrorType getFailureType() {
+		return this.failureType;
+	}
+
+	/**
+	 * Return the Activity instance which failed to produce this error message
+	 */
+	public Activity<?> getFailedActivity() {
+		return this.failedActivity;
+	}
+
+	/**
+	 * Return the throwable behind this error, or null if there was no exception
+	 * raised to create it.
+	 * 
+	 * @return
+	 */
+	public Throwable getCause() {
+		return this.cause;
+	}
+
+	/**
+	 * Return the textual message representing this error
+	 * 
+	 * @return
+	 */
+	public String getMessage() {
+		return this.message;
+	}
+
+	@Override
+	public DispatchErrorEvent popOwningProcess()
+			throws ProcessIdentifierException {
+		return new DispatchErrorEvent(popOwner(), index, context, message,
+				cause, failureType, failedActivity);
+	}
+
+	@Override
+	public DispatchErrorEvent pushOwningProcess(String localProcessName)
+			throws ProcessIdentifierException {
+		return new DispatchErrorEvent(pushOwner(localProcessName), index,
+				context, message, cause, failureType, failedActivity);
+	}
+
+	/**
+	 * @return Always a {@link DispatchMessageType#ERROR}
+	 */
+	@Override
+	public DispatchMessageType getMessageType() {
+		return ERROR;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchErrorType.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchErrorType.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchErrorType.java
new file mode 100644
index 0000000..f786f7b
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/events/DispatchErrorType.java
@@ -0,0 +1,53 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.events;
+
+/**
+ * A simple enumeration of possible failure classes, used to determine whether
+ * fault handling dispatch layers should attempt to handle a given failure
+ * message.
+ * 
+ * @author Tom Oinn
+ */
+public enum DispatchErrorType {
+	/**
+	 * Indicates that the failure to invoke the activity was due to invalid
+	 * input data, in this case there is no point in trying to invoke the
+	 * activity again with the same data as it will always fail. Fault handling
+	 * layers such as retry should pass this error type through directly; layers
+	 * such as failover handlers should handle it as the input data may be
+	 * applicable to other activities within the processor.
+	 */
+	DATA,
+
+	/**
+	 * Indicates that the failure was related to the invocation of the resource
+	 * rather than the input data, and that an identical invocation at a later
+	 * time may succeed.
+	 */
+	INVOCATION,
+
+	/**
+	 * Indicates that the failure was due to missing or incorrect authentication
+	 * credentials and that retrying the activity invocation without modifying
+	 * the credential set is pointless.
+	 */
+	AUTHENTICATION;
+}


[23/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/reporter/ProvenanceReporter.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/reporter/ProvenanceReporter.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/reporter/ProvenanceReporter.java
deleted file mode 100644
index d0a68d4..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/reporter/ProvenanceReporter.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package net.sf.taverna.t2.provenance.reporter;
-
-import java.util.List;
-
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.provenance.item.ProvenanceItem;
-import net.sf.taverna.t2.provenance.item.WorkflowProvenanceItem;
-import net.sf.taverna.t2.reference.ReferenceService;
-
-public interface ProvenanceReporter {
-	/**
-	 * Add a {@link ProvenanceItem} to the connector
-	 * 
-	 * @param provenanceItem
-	 * @param invocationContext
-	 */
-	void addProvenanceItem(ProvenanceItem provenanceItem);
-
-	// FIXME is this reference service really needed since we have the context?
-	/**
-	 * Tell the connector what {@link ReferenceService} it should use when
-	 * trying to dereference data items inside {@link ProvenanceItem}s
-	 * 
-	 * @param referenceService
-	 */
-	void setReferenceService(ReferenceService referenceService);
-
-	/**
-	 * Get the {@link ReferenceService} in use by this connector
-	 * 
-	 * @return
-	 */
-	ReferenceService getReferenceService();
-
-	/**
-	 * Get all the {@link ProvenanceItem}s that the connector currently knows
-	 * about
-	 * 
-	 * @return
-	 */
-	List<ProvenanceItem> getProvenanceCollection();
-
-	/**
-	 * Set the {@link InvocationContext} that this reporter should be using
-	 * 
-	 * @param invocationContext
-	 */
-	void setInvocationContext(InvocationContext invocationContext);
-
-	/**
-	 * Get the {@link InvocationContext} that this reporter should be using if
-	 * it needs to dereference any data
-	 * 
-	 * @return
-	 */
-	InvocationContext getInvocationContext();
-
-	/**
-	 * A unique identifier for this run of provenance, should correspond to the
-	 * initial {@link WorkflowProvenanceItem} idenifier that gets sent through
-	 * 
-	 * @param identifier
-	 */
-	void setSessionID(String sessionID);
-
-	/**
-	 * What is the unique identifier used by this connector
-	 * 
-	 * @return
-	 */
-	String getSessionID();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/vocabulary/SharedVocabulary.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/vocabulary/SharedVocabulary.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/vocabulary/SharedVocabulary.java
deleted file mode 100644
index 3abf92c..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/vocabulary/SharedVocabulary.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.provenance.vocabulary;
-
-import net.sf.taverna.t2.provenance.item.ProvenanceItem;
-
-/**
- * Static strings which identify all the {@link ProvenanceItem}s and
- * {@link ProvenanceEventType}s
- * 
- * @author Paolo Missier
- * @author Ian Dunlop
- */
-public enum SharedVocabulary {
-	DATAFLOW_EVENT_TYPE, PROCESS_EVENT_TYPE, PROVENANCE_EVENT_TYPE, ACTIVITY_EVENT_TYPE, DATA_EVENT_TYPE, ERROR_EVENT_TYPE, INMEMORY_EVENT_TYPE, INPUTDATA_EVENT_TYPE, ITERATION_EVENT_TYPE, OUTPUTDATA_EVENT_TYPE, PROCESSOR_EVENT_TYPE, WEBSERVICE_EVENT_TYPE, WORKFLOW_DATA_EVENT_TYPE, WORKFLOW_EVENT_TYPE, END_WORKFLOW_EVENT_TYPE, INVOCATION_STARTED_EVENT_TYPE;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/utility/TreeModelAdapter.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/utility/TreeModelAdapter.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/utility/TreeModelAdapter.java
deleted file mode 100644
index 0355616..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/utility/TreeModelAdapter.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.utility;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.swing.event.TreeModelEvent;
-import javax.swing.event.TreeModelListener;
-import javax.swing.tree.TreeModel;
-import javax.swing.tree.TreePath;
-
-/**
- * Wraps a typed tree model up in a standard tree model for use with JTree and
- * friends.
- * 
- * @author Tom Oinn
- */
-public final class TreeModelAdapter {
-	private static class TypedListenerPair<TT> {
-		TypedTreeModelListener<TT> typedListener;
-
-		TreeModelListener untypedListener;
-
-		TypedListenerPair(TypedTreeModelListener<TT> typedListener,
-				TreeModelListener untypedListener) {
-			this.typedListener = typedListener;
-			this.untypedListener = untypedListener;
-		}
-	}
-
-	private static Set<TypedListenerPair<Object>> mapping = new HashSet<>();
-
-	private static TreeModelAdapter instance = null;
-
-	private TreeModelAdapter() {
-		//
-	}
-
-	private synchronized static TreeModelAdapter getInstance() {
-		if (instance == null)
-			instance = new TreeModelAdapter();
-		return instance;
-	}
-
-	/**
-	 * Return an untyped TreeModel wrapper around the specified TypedTreeModel
-	 * 
-	 * @param <NodeType>
-	 *            the node type of the typed model being wrapped
-	 * @param typedModel
-	 *            typed model to wrap
-	 * @return a TreeModel acting as an untyped view of the typed tree model
-	 */
-	public static <NodeType extends Object> TreeModel untypedView(
-			TypedTreeModel<NodeType> typedModel) {
-		return getInstance().removeType(typedModel);
-	}
-
-	private <NodeType extends Object> TreeModel removeType(
-			final TypedTreeModel<NodeType> typedModel) {
-		return new TreeModel() {
-			@SuppressWarnings({ "rawtypes", "unchecked" })
-			@Override
-			public void addTreeModelListener(final TreeModelListener listener) {
-				TypedTreeModelListener<NodeType> typedListener = new TypedTreeModelListener<NodeType>() {
-					@Override
-					public void treeNodesChanged(TypedTreeModelEvent<NodeType> e) {
-						listener.treeNodesChanged(unwrapType(e));
-					}
-
-					@Override
-					public void treeNodesInserted(
-							TypedTreeModelEvent<NodeType> e) {
-						listener.treeNodesInserted(unwrapType(e));
-					}
-
-					@Override
-					public void treeNodesRemoved(TypedTreeModelEvent<NodeType> e) {
-						listener.treeNodesRemoved(unwrapType(e));
-					}
-
-					@Override
-					public void treeStructureChanged(
-							TypedTreeModelEvent<NodeType> e) {
-						listener.treeStructureChanged(unwrapType(e));
-					}
-
-					private TreeModelEvent unwrapType(
-							final TypedTreeModelEvent<NodeType> e) {
-						return new TreeModelEvent(e.getSource(),
-								e.getTreePath(), e.getChildIndices(),
-								e.getChildren());
-					}
-				};
-				synchronized (mapping) {
-					typedModel.addTreeModelListener(typedListener);
-					mapping.add(new TypedListenerPair(typedListener, listener));
-				}
-			}
-
-			@Override
-			@SuppressWarnings("unchecked")
-			public Object getChild(Object arg0, int arg1) {
-				return typedModel.getChild((NodeType) arg0, arg1);
-			}
-
-			@Override
-			@SuppressWarnings("unchecked")
-			public int getChildCount(Object arg0) {
-				return typedModel.getChildCount((NodeType) arg0);
-			}
-
-			@Override
-			@SuppressWarnings("unchecked")
-			public int getIndexOfChild(Object arg0, Object arg1) {
-				return typedModel.getIndexOfChild((NodeType) arg0,
-						(NodeType) arg1);
-			}
-
-			@Override
-			public Object getRoot() {
-				return typedModel.getRoot();
-			}
-
-			@Override
-			@SuppressWarnings("unchecked")
-			public boolean isLeaf(Object arg0) {
-				return typedModel.isLeaf((NodeType) arg0);
-			}
-
-			@Override
-			@SuppressWarnings("unchecked")
-			public void removeTreeModelListener(TreeModelListener arg0) {
-				synchronized (mapping) {
-					TypedListenerPair<NodeType> toRemove = null;
-					for (TypedListenerPair<Object> tpl : mapping)
-						if (tpl.untypedListener == arg0) {
-							toRemove = (TypedListenerPair<NodeType>) tpl;
-							typedModel
-									.removeTreeModelListener((TypedTreeModelListener<NodeType>) tpl.typedListener);
-							break;
-						}
-					if (toRemove == null)
-						return;
-					mapping.remove(toRemove);
-				}
-			}
-
-			@Override
-			public void valueForPathChanged(TreePath arg0, Object arg1) {
-				typedModel.valueForPathChanged(arg0, arg1);
-			}
-		};
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/utility/TypedTreeModel.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/utility/TypedTreeModel.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/utility/TypedTreeModel.java
deleted file mode 100644
index 8451c60..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/utility/TypedTreeModel.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.utility;
-
-import javax.swing.tree.TreePath;
-
-/**
- * A replacement for TreeModel where nodes are typed rather than being generic
- * objects. Because of the way interfaces and generics work this can't be
- * related in any inheritance heirarchy to the actual javax.swing.TreeModel
- * interface but is very similar (okay, identical) in operation. For cases where
- * you want to use a normal TreeModel such as using this as the backing data
- * model for a JTree you can use the TreeModelAdapter class to create an untyped
- * view over the typed version defined here.
- * 
- * @author Tom Oinn
- * 
- * @see javax.swing.tree.TreeModel
- * 
- * @param <NodeType>
- *            Each node in the tree is of this type
- */
-public interface TypedTreeModel<NodeType> {
-	/**
-	 * Adds a listener for the TreeModelEvent posted after the tree changes.
-	 */
-	void addTreeModelListener(TypedTreeModelListener<NodeType> l);
-
-	/**
-	 * Returns the child of parent at index 'index' in the parent's child array.
-	 * 
-	 * @param parent
-	 *            parent instance of typed node type
-	 * @param index
-	 *            index within parent
-	 * @return child node at the specified index
-	 */
-	NodeType getChild(NodeType parent, int index);
-
-	/**
-	 * Returns the number of children of parent.
-	 * 
-	 * @param parent
-	 *            node to count children for
-	 * @return number of children
-	 */
-	int getChildCount(NodeType parent);
-
-	/**
-	 * Returns the index of child in parent.
-	 * 
-	 * @param parent
-	 *            a node in the tree, obtained from this data source
-	 * @param child
-	 *            the node we are interested in
-	 * @return the index of the child in the parent, or -1 if either child or
-	 *         parent are null
-	 */
-	int getIndexOfChild(NodeType parent, NodeType child);
-
-	/**
-	 * Returns the root of the tree. Returns null only if the tree has no nodes.
-	 * 
-	 * @return the root of the tree
-	 */
-	NodeType getRoot();
-
-	/**
-	 * Returns true if node is a leaf. It is possible for this method to return
-	 * false even if node has no children. A directory in a filesystem, for
-	 * example, may contain no files; the node representing the directory is not
-	 * a leaf, but it also has no children.
-	 * 
-	 * @param node
-	 *            a node in the tree, obtained from this data source
-	 * @return true if node is a leaf
-	 */
-	boolean isLeaf(NodeType node);
-
-	/**
-	 * Removes a listener previously added with addTreeModelListener.
-	 * 
-	 * @param l
-	 *            typed tree model listener to remove
-	 */
-	void removeTreeModelListener(TypedTreeModelListener<NodeType> l);
-
-	/**
-	 * Messaged when the user has altered the value for the item identified by
-	 * path to newValue. If newValue signifies a truly new value the model
-	 * should post a treeNodesChanged event.
-	 * 
-	 * @param path
-	 *            path to the node that the user has altered
-	 * @param newValue
-	 *            the new value from the TreeCellEditor
-	 */
-	void valueForPathChanged(TreePath path, Object newValue);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/utility/TypedTreeModelEvent.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/utility/TypedTreeModelEvent.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/utility/TypedTreeModelEvent.java
deleted file mode 100644
index f5045d9..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/utility/TypedTreeModelEvent.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.utility;
-
-import javax.swing.tree.TreePath;
-
-/**
- * Type aware version of TreeModelEvent
- * 
- * @author Tom Oinn
- * 
- * @see javax.swing.tree.TreeModelEvent
- * 
- * @param <NodeType>
- *            the node type parameter of the TypedTreeModel to which this event
- *            applies
- */
-public class TypedTreeModelEvent<NodeType> {
-	protected int[] childIndices;
-	protected NodeType[] children;
-	protected TreePath path;
-	protected Object source;
-
-	/**
-	 * Used to create an event when the node structure has changed in some way,
-	 * identifying the path to the root of a modified subtree as an array of
-	 * Objects.
-	 * 
-	 * @param source
-	 * @param path
-	 */
-	public TypedTreeModelEvent(Object source, NodeType[] path) {
-		this.path = new TreePath(path);
-		this.source = source;
-		this.childIndices = new int[0];
-	}
-
-	/**
-	 * Used to create an event when the node structure has changed in some way,
-	 * identifying the path to the root of the modified subtree as a TreePath
-	 * object.
-	 * 
-	 * @param source
-	 * @param path
-	 */
-	public TypedTreeModelEvent(Object source, TreePath path) {
-		this.path = path;
-		this.source = source;
-		this.childIndices = new int[0];
-	}
-
-	/**
-	 * Used to create an event when nodes have been changed, inserted, or
-	 * removed, identifying the path to the parent of the modified items as a
-	 * TreePath object.
-	 * 
-	 * @param source
-	 * @param path
-	 * @param childIndices
-	 * @param children
-	 */
-	public TypedTreeModelEvent(Object source, TreePath path,
-			int[] childIndices, NodeType[] children) {
-		this.source = source;
-		this.path = path;
-		this.childIndices = childIndices;
-		this.children = children;
-	}
-
-	/**
-	 * Used to create an event when nodes have been changed, inserted, or
-	 * removed, identifying the path to the parent of the modified items as an
-	 * array of Objects.
-	 * 
-	 * @param source
-	 * @param path
-	 * @param childIndices
-	 * @param children
-	 */
-	public TypedTreeModelEvent(Object source, NodeType[] path,
-			int[] childIndices, NodeType[] children) {
-		this.path = new TreePath(path);
-		this.source = source;
-		this.childIndices = childIndices;
-		this.children = children;
-	}
-
-	/**
-	 * Returns the values of the child indexes.
-	 * 
-	 * @return
-	 */
-	public int[] getChildIndices() {
-		return this.childIndices;
-	}
-
-	/**
-	 * Returns the objects that are children of the node identified by getPath
-	 * at the locations specified by getChildIndices.
-	 * 
-	 * @return
-	 */
-	public NodeType[] getChildren() {
-		return this.children;
-	}
-
-	/**
-	 * The object on which the Event initially occurred.
-	 * 
-	 * @return
-	 */
-	public Object getSource() {
-		return this.source;
-	}
-
-	/**
-	 * For all events, except treeStructureChanged, returns the parent of the
-	 * changed nodes.
-	 * 
-	 * @return
-	 */
-	public TreePath getTreePath() {
-		return path;
-	}
-
-	/**
-	 * Returns a string that displays and identifies this object's properties.
-	 */
-	@Override
-	public String toString() {
-		return "Typed TreeModelEvent " + super.toString();
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/utility/TypedTreeModelListener.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/utility/TypedTreeModelListener.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/utility/TypedTreeModelListener.java
deleted file mode 100644
index 806af01..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/utility/TypedTreeModelListener.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.utility;
-
-/**
- * Equivalent to TreeModelListener for use with the TypedTreeModel
- * 
- * @author Tom Oinn
- * 
- * @see javax.swing.tree.TreeModelListener
- * 
- * @param <NodeType>
- *            Type of the node within the TypedTreeModel and used to
- *            parameterize the typed version of the tree model event.
- */
-public interface TypedTreeModelListener<NodeType> {
-	/**
-	 * Invoked after a node (or a set of siblings) has changed in some way. The
-	 * node(s) have not changed locations in the tree or altered their children
-	 * arrays, but other attributes have changed and may affect presentation.
-	 * Example: the name of a file has changed, but it is in the same location
-	 * in the file system.
-	 * <p>
-	 * To indicate the root has changed, childIndices and children will be null.
-	 * <p>
-	 * Use <code>e.getPath()</code> to get the parent of the changed node(s).
-	 * <code>e.getChildIndices()</code> returns the index(es) of the changed
-	 * node(s).
-	 */
-	void treeNodesChanged(TypedTreeModelEvent<NodeType> e);
-
-	/**
-	 * Invoked after nodes have been inserted into the tree.
-	 * <p>
-	 * Use <code>e.getPath()</code> to get the parent of the new node(s).
-	 * <code>e.getChildIndices()</code> returns the index(es) of the new node(s)
-	 * in ascending order.
-	 */
-	void treeNodesInserted(TypedTreeModelEvent<NodeType> e);
-
-	/**
-	 * Invoked after nodes have been removed from the tree. Note that if a
-	 * subtree is removed from the tree, this method may only be invoked once
-	 * for the root of the removed subtree, not once for each individual set of
-	 * siblings removed.
-	 * <p>
-	 * Use <code>e.getPath()</code> to get the former parent of the deleted
-	 * node(s). <code>e.getChildIndices()</code> returns, in ascending order,
-	 * the index(es) the node(s) had before being deleted.
-	 */
-	void treeNodesRemoved(TypedTreeModelEvent<NodeType> e);
-
-	/**
-	 * Invoked after the tree has drastically changed structure from a given
-	 * node down. If the path returned by <code>e.getPath()</code> is of length
-	 * one and the first element does not identify the current root node the
-	 * first element should become the new root of the tree.
-	 * <p>
-	 * Use
-	 * <code>e.getPath()<code> to get the path to the node. <code>e.getChildIndices()</code>
-	 * returns <code>null</code>.
-	 */
-	void treeStructureChanged(TypedTreeModelEvent<NodeType> e);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/utility/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/utility/package.html b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/utility/package.html
deleted file mode 100644
index 03fc4c0..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/utility/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<body>
-Utility classes, currently consists of a generic type safe alternative
-to TreeModel along with an adapter class to allow it to be used where a
-TreeModel is required (i.e. JTree)
-</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/visit/DataflowCollation.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/visit/DataflowCollation.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/visit/DataflowCollation.java
deleted file mode 100644
index fc4c378..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/visit/DataflowCollation.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package net.sf.taverna.t2.visit;
-
-/**
- * This visit kind is a dummy for collecting together the information associated
- * with a nested workflow.
- * 
- * @author alanrw
- */
-public class DataflowCollation extends VisitKind {
-	public static final int NESTED_ISSUES = 1;
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * There are no visitors that can perform a DataflowCollation visit. This
-	 * is, instead done within the HierarchyTraverser code iteself.
-	 * 
-	 * @see net.sf.taverna.t2.visit.VisitKind#getVisitorClass()
-	 */
-	@Override
-	public Class<? extends Visitor<?>> getVisitorClass() {
-		return null;
-	}
-
-	private static class Singleton {
-		private static DataflowCollation instance = new DataflowCollation();
-	}
-
-	public static DataflowCollation getInstance() {
-		return Singleton.instance;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/visit/HierarchyTraverser.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/visit/HierarchyTraverser.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/visit/HierarchyTraverser.java
deleted file mode 100644
index 2c75030..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/visit/HierarchyTraverser.java
+++ /dev/null
@@ -1,343 +0,0 @@
-package net.sf.taverna.t2.visit;
-
-import static java.lang.System.currentTimeMillis;
-import static java.util.Collections.synchronizedMap;
-import static net.sf.taverna.t2.visit.VisitReport.findAncestor;
-import static net.sf.taverna.t2.visit.VisitReport.getWorstStatus;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.WeakHashMap;
-
-import net.sf.taverna.t2.annotation.HierarchyRole;
-import net.sf.taverna.t2.annotation.HierarchyTraversal;
-import net.sf.taverna.t2.visit.VisitReport.Status;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import net.sf.taverna.t2.workflowmodel.Processor;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-import net.sf.taverna.t2.workflowmodel.processor.activity.NestedDataflow;
-
-import org.apache.log4j.Logger;
-
-/**
- * A HierarchyTraverser allows the traversal of the parent -> child hierarchy
- * (as indicated by annotations) and performs visits conforming to the set of
- * VisitKinds.
- * 
- * @author alanrw
- */
-public class HierarchyTraverser {
-	private static Logger logger = Logger.getLogger(HierarchyTraverser.class);
-
-	/**
-	 * A mapping from the class of an object to the set of names of methods that
-	 * will return children of instances of the object. Note that this has to be
-	 * done by String because of problems with annotations on overridden
-	 * methods.
-	 */
-	private static Map<Class<?>, Set<String>> childrenMethods = synchronizedMap(new WeakHashMap<Class<?>, Set<String>>());
-
-	/**
-	 * The set of visitors that can perform visits of one or more of a set of
-	 * VisitKind.
-	 */
-	protected Set<Visitor<?>> visitors;
-
-	/**
-	 * Create a HierarchyTraverser that can perform visits of the specified set
-	 * of VisitKind.
-	 * 
-	 * @param descriptions
-	 */
-	public HierarchyTraverser(Set<Visitor<?>> visitors) {
-		this.visitors = visitors;
-	}
-
-	/**
-	 * Add a new VisitReport to a set of VisitReport. If the VisitReport has
-	 * sub-reports then, unless the report is about a Dataflow, then the
-	 * VisitReport itself is ignored and the sub-reports added instead. If the
-	 * VisiReport has no sub-reports, or it is a report about a Dataflow, then
-	 * the VisitReport is added to the set.
-	 * 
-	 * @param reports
-	 *            The set of reports to which to add the useful VisitReports
-	 *            corresponding to the new VisitReport.
-	 * @param newReport
-	 *            The VisitReport to be added (or whose sub-reports are to be
-	 *            added) to the set of reports.
-	 */
-	private void addReport(Set<VisitReport> reports, VisitReport newReport) {
-		if (newReport == null)
-			return;
-		Collection<VisitReport> subReports = newReport.getSubReports();
-		if ((subReports == null) || subReports.size() == 0)
-			reports.add(newReport);
-		else if (!(newReport.getSubject() instanceof Dataflow))
-			for (VisitReport r : subReports)
-				addReport(reports, r);
-	}
-
-	/**
-	 * Change the subject of a VisitReport. This is currently done to change a
-	 * VisitReport about an Activity to be about its containing Processor. If
-	 * the VisitReport has sub-reports then their subject is also patched. It is
-	 * not obvious that this should be done here.
-	 * 
-	 * @param vr
-	 *            The VisitReport for which to change the subject
-	 * @param newSubject
-	 *            The new subject of the VisitReport and its sub-reports
-	 */
-	private void patchSubject(VisitReport vr, Object newSubject) {
-		vr.setSubject(newSubject);
-		Collection<VisitReport> subReports = vr.getSubReports();
-		if (subReports != null)
-			for (VisitReport child : subReports)
-				patchSubject(child, newSubject);
-	}
-
-	private void patchCheckTime(VisitReport vr, long time) {
-		vr.setCheckTime(time);
-		Collection<VisitReport> subReports = vr.getSubReports();
-		if (subReports != null)
-			for (VisitReport child : subReports)
-				patchCheckTime(child, time);
-	}
-
-	/**
-	 * Change a VisitReport and its sub-reports (if any) to indicate that the
-	 * visit was time-consuming. This is done to ensure that the time-consuming
-	 * indication of the Visitor is used on the VisitReport.
-	 * 
-	 * @param vr
-	 *            The VisitReport for which to set the time-consuming flag.
-	 */
-	private void patchTimeConsuming(VisitReport vr) {
-		vr.setWasTimeConsuming(true);
-		Collection<VisitReport> subReports = vr.getSubReports();
-		if (subReports != null)
-			for (VisitReport child : subReports)
-				patchTimeConsuming(child);
-	}
-
-	/**
-	 * Carry out the appropriate visits on an object and then traverse down the
-	 * hierarchy of its children.
-	 * 
-	 * @param o
-	 *            The object to visit
-	 * @param ancestry
-	 *            The, possibly empty, list of the ancestors (ordered parents)
-	 *            of the object with the most recent ancestor being the first in
-	 *            the list.
-	 * @param reports
-	 *            The set to which to add reports generated about the object and
-	 *            its descendents
-	 * @param includeTimeConsuming
-	 *            Whether to include visits that are time-consuming.
-	 */
-	@SuppressWarnings({ "rawtypes", "unchecked" })
-	public void traverse(Object o, List ancestry, Set<VisitReport> reports,
-			boolean includeTimeConsuming) {
-		/*
-		 * For each visitor that is able to do visits for the set of VisitKind
-		 * specified for the HierarchyTraverser
-		 */
-		for (Visitor v : visitors)
-			/*
-			 * If time consuming visits are allowed or the visitor is not time
-			 * consuming, and the visitor can visit the specified object
-			 */
-
-			if ((includeTimeConsuming || !v.isTimeConsuming()) && v.canVisit(o)) {
-				// Make the visitor visit the object
-				VisitReport report = null;
-				try {
-					report = v.visit(o, ancestry);
-				} catch (NullPointerException|ClassCastException e) {
-					logger.error("Visit threw exception", e);
-				}
-
-				if (report == null)
-					continue;
-
-				patchCheckTime(report, currentTimeMillis());
-
-				/*
-				 * If the current object is an Activity then change the report
-				 * so that its subject is the Processor containing the Activity
-				 */
-				if (o instanceof Activity) {
-					Processor p = (Processor) findAncestor(ancestry,
-							Processor.class);
-					if (p != null)
-						patchSubject(report, p);
-				}
-				/*
-				 * Note in the VisitReport if it was caused by a time-consuming
-				 * visitor
-				 */
-				if (v.isTimeConsuming() && (report != null))
-					patchTimeConsuming(report);
-				/*
-				 * Add the VisitReport and its sub-reports, if any, to the set
-				 * of VisitReports
-				 */
-				addReport(reports, report);
-			}
-
-		/*
-		 * If the object is a nested dataflow activity then traverse the
-		 * dataflow that is nested. Take the reports about the sub-dataflow and,
-		 * if there are problems with it, create a DataflowCollation report
-		 * about the nested dataflow activity (or to be more precise the
-		 * Procesor containing it.)
-		 */
-		if (o instanceof NestedDataflow) {
-			NestedDataflow nestedDataflow = (NestedDataflow) o;
-			Dataflow subFlow = nestedDataflow.getNestedDataflow();
-			Set<VisitReport> subReports = new HashSet<>();
-			traverse(subFlow, new ArrayList<Object>(), subReports,
-					includeTimeConsuming);
-			Processor p = (Processor) findAncestor(ancestry, Processor.class);
-			if (p != null) {
-				Status worstStatus = getWorstStatus(subReports);
-				if (!worstStatus.equals(Status.OK)) {
-					VisitReport report = new VisitReport(
-							DataflowCollation.getInstance(),
-							p,
-							(worstStatus.equals(Status.WARNING) ? "Warnings in nested workflow"
-									: "Errors in nested workflow"),
-							DataflowCollation.NESTED_ISSUES, worstStatus,
-							subReports);
-					report.setProperty("dataflowIdentifier",
-							subFlow.getIdentifier());
-					report.setWasTimeConsuming(includeTimeConsuming);
-					reports.add(report);
-				}
-			}
-		}
-
-		// Now move on to traversing the descendents
-
-		/*
-		 * For every child-getting method for this object, try to get the
-		 * children and add them into a set.
-		 */
-		Set<String> methodNames = getMethods(o);
-		Set<Object> children = new HashSet<>();
-		for (Method m : o.getClass().getMethods())
-			if (methodNames.contains(m.getName())) {
-				Object methodResult = null;
-				try {
-					methodResult = m.invoke(o);
-				} catch (IllegalArgumentException | IllegalAccessException
-						| InvocationTargetException e) {
-					logger.error(e);
-				}
-				/*
-				 * If the method did not produce a singleton but instead a List
-				 * or similar then add the members of the list.
-				 */
-				children.addAll(getLeafs(methodResult));
-			}
-
-		/*
-		 * For every child of the current object, traverse that object and get
-		 * reports about it and its descendents.
-		 */
-		ArrayList<Object> newAncestry = new ArrayList<>();
-		newAncestry.add(o);
-		newAncestry.addAll(ancestry);
-		for (Object c : children)
-			traverse(c, newAncestry, reports, includeTimeConsuming);
-	}
-
-	/**
-	 * Determine the set of singletons corresponding to an object. If the object
-	 * is a singleton then a set containing just the object is returned. If the
-	 * object is iterable then the singletons of the elements of the iteration
-	 * are returned.
-	 * 
-	 * @param o
-	 *            The object.
-	 * @return The set of singletons
-	 */
-	@SuppressWarnings("unchecked")
-	private static Set<Object> getLeafs(Object o) {
-		Set<Object> result = new HashSet<>();
-		if (o instanceof Iterable)
-			for (Object element : (Iterable<Object>) o)
-				result.addAll(getLeafs(element));
-		else
-			result.add(o);
-		return result;
-	}
-
-	/**
-	 * Determine the set of names of child-getting methods for a given object
-	 * 
-	 * @param o
-	 *            The object to consider.
-	 * @return The set of names of child-getting methods
-	 */
-	private static Set<String> getMethods(Object o) {
-		Class<?> c = o.getClass();
-		return getMethodsForClass(c);
-	}
-
-	/**
-	 * Determine the set of names of child-getting methods for a given Class.
-	 * This includes the names of methods from interfaces and super-classes.
-	 * 
-	 * @param c
-	 *            The class to consider
-	 * @return The set of names of child-getting methods for the class
-	 */
-	private static synchronized Set<String> getMethodsForClass(Class<?> c) {
-		if (!childrenMethods.containsKey(c)) {
-			Set<String> result = new HashSet<>();
-			result.addAll(getExplicitMethodsForClass(c));
-			for (Class<?> i : c.getInterfaces())
-				result.addAll(getMethodsForClass(i));
-			Class<?> s = c.getSuperclass();
-			if (s != null)
-				result.addAll(getMethodsForClass(s));
-			childrenMethods.put(c, result);
-		}
-		return childrenMethods.get(c);
-	}
-
-	/**
-	 * Determine the set of names of child-getting methods explicitly identified
-	 * for an Interface or a Class.
-	 * 
-	 * @param c
-	 *            The Interface or Class to consider
-	 * @return The set of names of child-getting methods.
-	 */
-	private static Collection<? extends String> getExplicitMethodsForClass(
-			Class<?> c) {
-		Method[] methods = c.getDeclaredMethods();
-		Set<String> result = new HashSet<>();
-
-		for (Method m : methods)
-			if (m.getParameterTypes().length == 0) {
-				HierarchyTraversal ht = m
-						.getAnnotation(HierarchyTraversal.class);
-				if (ht != null
-						&& Arrays.asList(ht.role()).contains(
-								HierarchyRole.CHILD))
-					result.add(m.getName());
-			}
-		return result;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/visit/VisitKind.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/visit/VisitKind.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/visit/VisitKind.java
deleted file mode 100644
index 4657950..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/visit/VisitKind.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package net.sf.taverna.t2.visit;
-
-/**
- * A type of visit that can be made e.g. a health check.
- * 
- * @author alanrw
- */
-public abstract class VisitKind {
-	/**
-	 * The class that all visitors that extend/implement if they make this type
-	 * of visit.
-	 * 
-	 * @return
-	 */
-	public abstract Class<? extends Visitor<?>> getVisitorClass();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/visit/VisitReport.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/visit/VisitReport.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/visit/VisitReport.java
deleted file mode 100644
index 6db2040..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/visit/VisitReport.java
+++ /dev/null
@@ -1,346 +0,0 @@
-/**
- * 
- */
-package net.sf.taverna.t2.visit;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author alanrw
- */
-public class VisitReport {
-	private static final String INDENTION = "    ";
-
-	/**
-	 * Enumeration of the possible status's in increasing severity: OK,
-	 * WARNING,SEVERE
-	 */
-	public enum Status {
-		OK, WARNING, SEVERE
-	};
-
-	/**
-	 * A short message describing the state of the report
-	 */
-	private String message;
-	/**
-	 * An integer indicating the outcome of a visit relative to the VisitKind
-	 */
-	private int resultId;
-	/**
-	 * 
-	 */
-	private Status status;
-	/**
-	 * The object about which the report is made
-	 */
-	private Object subject;
-	/**
-	 * The sub-reports of the VisitReport
-	 */
-	private Collection<VisitReport> subReports = new ArrayList<>();
-	/**
-	 * The kind of visit that was made e.g. to check the health of a service or
-	 * examine its up-stream error fragility
-	 */
-	private VisitKind kind;
-	/**
-	 * An indication of whether the visit report was generated by a time
-	 * consuming visitor. This is used to check whether the VisitReport can be
-	 * automatically junked.
-	 */
-	private boolean wasTimeConsuming;
-	private Map<String, Object> propertyMap = new HashMap<>();
-	private long checkTime;
-
-	/**
-	 * @return whether the VisitReport was generated by a time consuming visitor
-	 */
-	public boolean wasTimeConsuming() {
-		return wasTimeConsuming;
-	}
-
-	/**
-	 * @param wasTimeConsuming whether the VisitReport was generated by a time consuming visitot
-	 */
-	public void setWasTimeConsuming(boolean wasTimeConsuming) {
-		this.wasTimeConsuming = wasTimeConsuming;
-	}
-
-	/**
-	 * Constructs the Visit Report. The sub reports default to an empty list.
-	 * 
-	 * @param kind
-	 *            - the type of visit performed
-	 * @param subject
-	 *            - the thing being tested.
-	 * @param message
-	 *            - a summary of the result of the test.
-	 * @param resultId
-	 *            - an identification of the type of result relative to the
-	 *            VisitKind
-	 * @param status
-	 *            - the overall Status.
-	 */
-	public VisitReport(VisitKind kind, Object subject, String message,
-			int resultId, Status status) {
-		this(kind, subject, message, resultId, status,
-				new ArrayList<VisitReport>());
-	}
-	
-	/**
-	 * Used internally by {@link #clone()}.
-	 */
-	protected VisitReport() {}
-
-	/**
-	 * Constructs the Visit Report
-	 * 
-	 * @param kind
-	 *            - the type of visit performed
-	 * @param subject
-	 *            - the thing being tested.
-	 * @param message
-	 *            - a summary of the result of the test.
-	 * @param resultId
-	 *            - an identification of the type of result relative to the
-	 *            VisitKind
-	 * @param status - the overall Status.
-	 * @param subReports
-	 *            - a List of sub reports.
-	 */
-	public VisitReport(VisitKind kind, Object subject, String message,
-			int resultId, Status status, Collection<VisitReport> subReports) {
-		this.kind = kind;
-		this.subject = subject;
-		this.status = status;
-		this.message = message;
-		this.resultId = resultId;
-		this.subReports = subReports;
-		this.wasTimeConsuming = false;
-		this.checkTime = 0;
-	}
-
-	/**
-	 * @param kind The type of visit performed
-	 * @param subject The thing that was visited
-	 * @param message A summary of the result of the test
-	 * @param resultId An indication of the type of the result relative to the kind of visit
-	 * @param subReports A list of sub-reports
-	 */
-	public VisitReport(VisitKind kind, Object subject, String message,
-			int resultId, Collection<VisitReport> subReports) {
-		this(kind, subject, message, resultId, getWorstStatus(subReports),
-				subReports);
-	}
-
-	/**
-	 * @return An indication of the type of the result relative to the kind of visit
-	 */
-	public int getResultId() {
-		return resultId;
-	}
-
-	/**
-	 * @param resultId The type of the result of the visit relative to the kind of visit
-	 */
-	public void setResultId(int resultId) {
-		this.resultId = resultId;
-	}
-
-	/**
-	 * @return a message summarizing the report
-	 */
-	public String getMessage() {
-		return message;
-	}
-
-	/**
-	 * Sets the message
-	 * 
-	 * @param message
-	 *            a message summarizing the report
-	 */
-	public void setMessage(String message) {
-		this.message = message;
-	}
-
-	/**
-	 * Determines the overall Status. This is the most severe status of this
-	 * report and all its sub reports.
-	 * 
-	 * @return the overall status
-	 */
-	public Status getStatus() {
-		Status result = status;
-		for (VisitReport report : subReports)
-			if (report.getStatus().compareTo(result) > 0)
-				result = report.getStatus();
-		return result;
-	}
-
-	/**
-	 * Sets the status of this report. Be aware that the overall status of this
-	 * report may also be affected by its sub reports if they have a more severe
-	 * Status.
-	 * 
-	 * @param status
-	 * @see #getStatus
-	 */
-	public void setStatus(Status status) {
-		this.status = status;
-	}
-
-	/**
-	 * @return an Object representing the subject of this visit report
-	 */
-	public Object getSubject() {
-		return subject;
-	}
-
-	/**
-	 * @param subject
-	 *            an Object representing the subject of this visit report
-	 */
-	public void setSubject(Object subject) {
-		this.subject = subject;
-	}
-
-	/**
-	 * Provides a list of sub reports. This list defaults an empty list, so it
-	 * is safe to add new reports through this method.
-	 * 
-	 * @return a list of sub reports associated with this Visit Report
-	 */
-	public Collection<VisitReport> getSubReports() {
-		return subReports;
-	}
-
-	/**
-	 * Replaces the List of sub reports with those provided.
-	 * 
-	 * @param subReports
-	 *            a list of sub reports
-	 */
-	public void setSubReports(Collection<VisitReport> subReports) {
-		this.subReports = subReports;
-	}
-
-	/**
-	 * 
-	 * @return the kind of visit that was made.
-	 */
-	public VisitKind getKind() {
-		return kind;
-	}
-
-	/**
-	 * @param kind Specify the kind of visit that was made
-	 */
-	public void setKind(VisitKind kind) {
-		this.kind = kind;
-	}
-	
-	public void setProperty(String key, Object value) {
-		propertyMap.put(key, value);
-	}
-	
-	public Object getProperty(String key) {
-		return propertyMap.get(key);
-	}
-
-	public Map<String, Object> getProperties() {
-		return propertyMap;
-	}
-	
-	/**
-	 * Find the most recent ancestor (earliest in the list) of a given class from the list of ancestors
-	 * 
-	 * @param ancestors The list of ancestors to examine
-	 * @param ancestorClass The class to search for
-	 * @return The most recent ancestor, or null if no suitable ancestor
-	 */
-	public static Object findAncestor(List<Object> ancestors,
-			Class<?> ancestorClass) {
-		Object result = null;
-		for (Object o : ancestors)
-			if (ancestorClass.isInstance(o))
-				return o;
-		return result;
-	}
-
-	public void setCheckTime(long time) {
-		this.checkTime = time;
-	}
-
-	public long getCheckTime() {
-		return this.checkTime;
-	}
-
-	/**
-	 * Determine the worst status from a collection of reports
-	 * 
-	 * @param reports
-	 *            The collection of reports to examine
-	 * @return The worst status
-	 */
-	public static Status getWorstStatus(Collection<VisitReport> reports) {
-		Status currentStatus = Status.OK;
-		for (VisitReport report : reports)
-			if (currentStatus.compareTo(report.getStatus()) < 0)
-				currentStatus = report.getStatus();
-		return currentStatus;
-	}
-
-	@Override
-	public String toString() {
-		// TODO Use StringBuilder instead
-		StringBuffer sb = new StringBuffer();
-		visitReportToStringBuffer(sb, "");
-		return sb.toString();
-	}
-
-	protected void visitReportToStringBuffer(
-			StringBuffer sb, String indent) {	
-		sb.append(indent);
-		sb.append(getStatus());
-		sb.append(' ');
-		sb.append(getMessage());
-		if (! propertyMap.isEmpty()) {
-			sb.append(' ');
-			sb.append(propertyMap);
-		}
-		sb.append('\n');
-		indent = indent + INDENTION;
-		for (VisitReport subReport : getSubReports())
-			subReport.visitReportToStringBuffer(sb, indent);
-	}
-	
-	@Override
-	public VisitReport clone() throws CloneNotSupportedException {
-		if (!getClass().equals(VisitReport.class))
-			throw new CloneNotSupportedException("Can't clone subclass "
-					+ getClass()
-					+ ", reimplement clone() and use internalClone()");
-		return internalClone(new VisitReport());
-	}
-
-	protected VisitReport internalClone(VisitReport newReport)
-			throws CloneNotSupportedException {
-		newReport.checkTime = this.checkTime;
-		newReport.kind = this.kind;
-		newReport.message = this.message;
-		newReport.propertyMap.putAll(this.propertyMap);
-		newReport.resultId = this.resultId;
-		newReport.status = this.status;
-		newReport.subject = this.subject;
-		newReport.wasTimeConsuming = this.wasTimeConsuming;
-		for (VisitReport childReport : this.subReports)
-			newReport.subReports.add(childReport.clone());
-		return newReport;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/visit/Visitor.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/visit/Visitor.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/visit/Visitor.java
deleted file mode 100644
index 0c913cc..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/visit/Visitor.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package net.sf.taverna.t2.visit;
-
-import java.util.List;
-
-/**
- * A Visitor can perform a visit of a VisitKind on a object. It can return a
- * VisitReport giving details of the result of the visit, A Visitor may be time
- * consuming, in which case it is only performed upon user request.
- * 
- * @author alanrw
- * 
- * @param <T> The type of the objects being visited.
- */
-public interface Visitor<T> {
-	/**
-	 * Returns true if the visitor can visit the specified object.
-	 * 
-	 * @param o
-	 *            The object that might be visited
-	 * @return true is a visit is possible from this Visitor.
-	 */
-	boolean canVisit(Object o);
-
-	/**
-	 * Visit an object which has the specified ancestry (list of parents) and
-	 * possibly return a VisitReport detailing the result of the visit.
-	 * 
-	 * @param o
-	 *            The object to visit
-	 * @param ancestry
-	 *            A list of the ancestors of the object with the immediate
-	 *            parent at the start of the list.
-	 * @return A VisitReport detailing the result of the visit.
-	 */
-	VisitReport visit(T o, List<Object> ancestry);
-
-	/**
-	 * An indication if the visit would take sufficient time that it should only
-	 * be run upon user request
-	 * 
-	 * @return
-	 */
-	boolean isTimeConsuming();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/AbstractOutputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/AbstractOutputPort.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/AbstractOutputPort.java
deleted file mode 100644
index 59e0fc2..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/AbstractOutputPort.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-/**
- * Simple implementation of OutputPort, extends AbstractPort and adds the
- * granular depth bean getter.
- * 
- * @author Tom Oinn
- */
-public abstract class AbstractOutputPort extends AbstractPort implements
-		OutputPort {
-	protected int granularDepth;
-
-	protected AbstractOutputPort(String portName, int portDepth,
-			int granularDepth) {
-		super(portName, portDepth);
-		this.granularDepth = granularDepth;
-	}
-
-	@Override
-	public int getGranularDepth() {
-		return granularDepth;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/AbstractPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/AbstractPort.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/AbstractPort.java
deleted file mode 100644
index 9a00488..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/AbstractPort.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-import net.sf.taverna.t2.annotation.AbstractAnnotatedThing;
-
-/**
- * Port definition with depth and name
- * 
- * @author Tom Oinn
- */
-public abstract class AbstractPort extends AbstractAnnotatedThing<Port>
-		implements Port {
-	protected String name;
-	protected int depth;
-
-	protected AbstractPort(String name, int depth) {
-		this.name = name;
-		this.depth = depth;
-	}
-
-	@Override
-	public int getDepth() {
-		return this.depth;
-	}
-
-	@Override
-	public final String getName() {
-		return this.name;
-	}
-
-	@Override
-	public String toString() {
-		return getClass().getSimpleName() + " " + getName() + " (" + getDepth() + ")";
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/CompoundEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/CompoundEdit.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/CompoundEdit.java
deleted file mode 100644
index 08ff79c..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/CompoundEdit.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Implementation of Edit which contains an ordered list of child edits. Child
- * edits are applied collectively and in order, any failure in any child edit
- * causes an undo of previously applied children and a propogation of the edit
- * exception.
- * 
- * @author Tom Oinn
- */
-public class CompoundEdit implements Edit<Object> {
-	private final transient List<Edit<?>> childEdits;
-	private transient boolean applied = false;
-
-	/**
-	 * Create a new compound edit with no existing Edit objects.
-	 * 
-	 */
-	public CompoundEdit() {
-		this.childEdits = new ArrayList<>();
-	}
-
-	/**
-	 * Create a new compound edit with the specified edits as children.
-	 */
-	public CompoundEdit(List<Edit<?>> edits) {
-		this.childEdits = edits;
-	}
-
-	public List<Edit<?>> getChildEdits() {
-		return childEdits;
-	}
-
-	/**
-	 * Attempts to call the doEdit method of all child edits. If any of those
-	 * children throws an EditException any successful edits are rolled back and
-	 * the exception is rethrown as the cause of a new EditException from the
-	 * CompoundEdit
-	 */
-	@Override
-	@SuppressWarnings("deprecation")
-	public synchronized Object doEdit() throws EditException {
-		if (isApplied())
-			throw new EditException("Cannot apply an edit more than once!");
-		List<Edit<?>> doneEdits = new ArrayList<>();
-		try {
-			for (Edit<?> edit : childEdits) {
-				edit.doEdit();
-				/*
-				 * Insert the done edit at position 0 in the list so we can
-				 * iterate over the list in the normal order if we need to
-				 * rollback, this ensures that the most recent edit is first.
-				 */
-				doneEdits.add(0, edit);
-			}
-			applied = true;
-			return null;
-		} catch (EditException ee) {
-			// TODO Remove undo; we can't do that any more
-			for (Edit<?> undoMe : doneEdits)
-				undoMe.undo();
-			applied = false;
-			throw new EditException("Failed child of compound edit", ee);
-		}
-	}
-
-	/**
-	 * There is no explicit subject for a compound edit, so this method always
-	 * returns null.
-	 */
-	@Override
-	public Object getSubject() {
-		return null;
-	}
-
-	/**
-	 * Rolls back all child edits in reverse order
-	 */
-	@Override
-	@SuppressWarnings("deprecation")
-	public synchronized void undo() {
-		for (int i = (childEdits.size() - 1); i >= 0; i--)
-			// Undo child edits in reverse order
-			childEdits.get(i).undo();
-		applied = false;
-	}
-
-	@Override
-	public boolean isApplied() {
-		return applied;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Condition.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Condition.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Condition.java
deleted file mode 100644
index 95006ed..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Condition.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-import net.sf.taverna.t2.annotation.Annotated;
-
-/**
- * Defines the base interface for a condition which must be satisfied before a
- * processor can commence invocation. Conditions are expressed in terms of a
- * relationship between a controlling and a target processor where the target
- * processor may not commence invocation until all conditions for which it is a
- * target are satisfied in the context of a particular owning process
- * identifier.
- * 
- * @author Tom Oinn
- */
-public interface Condition extends Annotated<Condition>, WorkflowItem {
-	/**
-	 * @return the Processor constrained by this condition
-	 */
-	Processor getControl();
-
-	/**
-	 * @return the Processor acting as the controller for this condition
-	 */
-	Processor getTarget();
-
-	/**
-	 * @param owningProcess
-	 *            the context in which the condition is to be evaluated
-	 * @return whether the condition is satisfied
-	 */
-	boolean isSatisfied(String owningProcess);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Configurable.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Configurable.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Configurable.java
deleted file mode 100644
index c89b47b..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Configurable.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007-2008 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-import net.sf.taverna.t2.workflowmodel.ConfigurationException;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityConfigurationException;
-
-/**
- * Interface for workflow items that can be configured from a bean.
- * 
- * @param <ConfigurationType>
- *            the ConfigurationType associated with the workflow item. This is
- *            an arbitrary java class that provides details on how the item is
- *            configured. To allow successful serialisation it's recommended to
- *            keep this configuration as a simple Java bean.
- * 
- * @author Tom Oinn
- * @author Stian Soiland-Reyes
- * @see ActivityConfigurationException
- */
-public interface Configurable<ConfigurationType> extends WorkflowItem {
-	/**
-	 * Each item stores configuration within a bean of type ConfigurationType,
-	 * this method returns the configuration. This is used by the automatic
-	 * serialisation framework to store the item definition in the workflow XML.
-	 */
-	ConfigurationType getConfiguration();
-
-	/**
-	 * When the item is built from the workflow definition XML the object is
-	 * first constructed with a default constructor then this method is called,
-	 * passing in the configuration bean returned by getConfiguration().
-	 * 
-	 * @throws ConfigurationException
-	 *             if a problem occurs when configuring the item
-	 */
-	void configure(ConfigurationType conf) throws ConfigurationException;
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ConfigurationException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ConfigurationException.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ConfigurationException.java
deleted file mode 100644
index d815193..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ConfigurationException.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007-2008 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-/**
- * Thrown when attempting to configure a
- * {@link net.sf.taverna.t2.workflowmodel.Configurable} with an invalid
- * configuration. Causes may include actual configuration errors, unavailable
- * implementations etc.
- * 
- * @author Stian Soiland-Reyes
- * @author Tom Oinn
- */
-public class ConfigurationException extends Exception {
-	private static final long serialVersionUID = -2841928064598107156L;
-
-	/**
-	 * {@inheritDoc}
-	 */
-	public ConfigurationException() {
-		super();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	public ConfigurationException(String message, Throwable cause) {
-		super(message, cause);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	public ConfigurationException(String message) {
-		super(message);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	public ConfigurationException(Throwable cause) {
-		super(cause);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ControlBoundary.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ControlBoundary.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ControlBoundary.java
deleted file mode 100644
index 2503224..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ControlBoundary.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Denotes that the associated type creates a boundary of control within the
- * dataflow. Types marked with this annotation are those which can modify the
- * owning process of data tokens they consume and generally correspond to cases
- * where the control flow bifurcates in some fashion.
- * <p>
- * This annotation doesn't currently define this behaviour but serves as an easy
- * way for us to track which objects might potentially do this, something we
- * need to be able to do to guarantee that the monitor works correctly.
- * 
- * @author Tom Oinn
- * 
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-@Documented
-public @interface ControlBoundary {
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Dataflow.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Dataflow.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Dataflow.java
deleted file mode 100644
index f55577e..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Dataflow.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-import static net.sf.taverna.t2.annotation.HierarchyRole.CHILD;
-
-import java.util.List;
-
-import net.sf.taverna.t2.annotation.Annotated;
-import net.sf.taverna.t2.annotation.HierarchyTraversal;
-import net.sf.taverna.t2.invocation.InvocationContext;
-
-/**
- * Top level definition object for a dataflow workflow. Currently Taverna only
- * supports dataflow workflows, this is equivalent to the Taverna 1 ScuflModel
- * class in role.
- * 
- * @author Tom Oinn
- */
-@ControlBoundary
-public interface Dataflow extends Annotated<Dataflow>, TokenProcessingEntity,
-		WorkflowItem {
-	/**
-	 * A Dataflow consists of a set of named Processor instances. This method
-	 * returns an unmodifiable list of these processors. Equivalent to calling
-	 * getEntities(Processor.class).
-	 * 
-	 * @return list of all processors in the dataflow
-	 */
-	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
-	List<? extends Processor> getProcessors();
-
-	/**
-	 * Dataflows also contain a set of merge operations, this method returns an
-	 * unmodifiable copy of the set. Equivalent to calling
-	 * getEntities(Merge.class)
-	 */
-	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
-	List<? extends Merge> getMerges();
-
-	/**
-	 * Dataflows have a list of input ports. These are the input ports the world
-	 * outside the dataflow sees - each one contains an internal output port
-	 * which is used to forward events on to entities (mostly processors) within
-	 * the dataflow.
-	 * 
-	 * @return list of dataflow input port instances
-	 */
-	@Override
-	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
-	List<? extends DataflowInputPort> getInputPorts();
-
-	/**
-	 * Get all workflow entities with the specified type restriction, this
-	 * allows retrieval of Processor, Merge, a mix of the two or any other
-	 * future entity to be added to the workflow model without a significant
-	 * change in this part of the API.
-	 * 
-	 * @return an unmodifiable list of entities of the specified type
-	 * @param entityType
-	 *            a class of the type specified by the type variable T. All
-	 *            entities returned in the list can be cast to this type
-	 */
-	<T extends NamedWorkflowEntity> List<? extends T> getEntities(
-			Class<T> entityType);
-
-	/**
-	 * Dataflows have a list of output ports. The output port in a dataflow is
-	 * the port visible to the outside world and from which the dataflow emits
-	 * events. Each dataflow output port also contains an instance of event
-	 * receiving input port which is used by entities within the dataflow to
-	 * push events to the corresponding external output port.
-	 * 
-	 * @return list of dataflow output port instances
-	 */
-	@Override
-	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
-	List<? extends DataflowOutputPort> getOutputPorts();
-
-	/**
-	 * The dataflow is largely defined by the links between processors and other
-	 * entities within its scope. This method returns them.
-	 * 
-	 * @return list of Datalink implementations
-	 */
-	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
-	List<? extends Datalink> getLinks();
-
-	/**
-	 * Triggers a check for various basic potential problems with the workflow,
-	 * in particular ones related to type checking. Returns a report object
-	 * containing the state of the workflow and any problems found.
-	 * <p>
-	 * If the workflow has been set immutable with {@link #setImmutable()},
-	 * subsequent calls to this method will return the cached
-	 * DataflowValidationReport.
-	 * 
-	 * @return validation report
-	 */
-	DataflowValidationReport checkValidity();
-
-	/**
-	 * A dataflow with no inputs cannot be driven by the supply of data tokens
-	 * as it has nowhere to receive such tokens. This method allows a dataflow
-	 * to fire on an empty input set, in this case the owning process identifier
-	 * must be passed explicitly to the dataflow. This method then calls the
-	 * fire methods of any Processor instances with no input ports.
-	 */
-	void fire(String owningProcess, InvocationContext context);
-
-	/**
-	 * The failure transmitter contains event listeners to be notified of
-	 * workflow level failures - these occur when an error bubbles up to the top
-	 * of the dispatch stack in a processor and is not handled by conversion to
-	 * an error token within the data stream.
-	 * <p>
-	 * Listeners are messaged after all clean-up has been performed on the
-	 * dataflow's internal state and that of any child operations within it,
-	 * guaranteeing that no tokens will be generated with the id of the failed
-	 * process after the message has been received by the listener
-	 */
-	FailureTransmitter getFailureTransmitter();
-
-	/**
-	 * An identifier that is unique to this dataflow and its current state. The
-	 * identifier will change whenever the dataflow is modified.
-	 * 
-	 * @return a String representing a unique internal identifier.
-	 */
-	String getIdentifier();
-
-	String recordIdentifier();
-
-	/**
-	 * Check if the given input port is connected to anything in the workflow.
-	 * 
-	 * @param inputPort
-	 * @return true if the given workflow input port is connected, false
-	 *         otherwise.
-	 */
-	boolean isInputPortConnected(DataflowInputPort inputPort);
-
-	/**
-	 * Mark this dataflow as immutable.
-	 * 
-	 * Subsequent edits to its ports, links, merges, input and output ports will
-	 * throw a RuntimeException like UnsupportedOperationException.
-	 * 
-	 * This method should be called before executing a Dataflow with
-	 * {@link #fire(String, InvocationContext)}, in order to guarantee that
-	 * datalinks, port depths etc. don't change while the dataflow is running.
-	 * 
-	 */
-	void setImmutable();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/DataflowInputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/DataflowInputPort.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/DataflowInputPort.java
deleted file mode 100644
index 7125639..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/DataflowInputPort.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-/**
- * An input port on a Dataflow contains a nested output port within it. This
- * internal output port is used when connecting an edge from the workflow input
- * to a processor or workflow output (which in turn has a nested input port).
- * The workflow ports are therefore effectively pairs of ports with a relay
- * mechanism between the external and internal in the case of the dataflow
- * input.
- * 
- * @author Tom Oinn
- */
-public interface DataflowInputPort extends EventHandlingInputPort, DataflowPort {
-	/**
-	 * Return the internal output port. Output ports have a granular depth
-	 * property denoting the finest grained output token they can possibly
-	 * produce, this is used to configure downstream filtering input ports. In
-	 * this case the finest depth item is determined by the input to the
-	 * workflow port and must be explicitly set.
-	 * 
-	 * @return the internal output port
-	 */
-	EventForwardingOutputPort getInternalOutputPort();
-
-	/**
-	 * Define the finest grained item that will be sent to this input port. As
-	 * all data are relayed through to the internal output port this is used to
-	 * denote output port granularity as well as to configure any downstream
-	 * connected filtering input ports.
-	 */
-	int getGranularInputDepth();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/DataflowOutputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/DataflowOutputPort.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/DataflowOutputPort.java
deleted file mode 100644
index 82eee56..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/DataflowOutputPort.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-import net.sf.taverna.t2.facade.ResultListener;
-
-/**
- * Output port of a DataFlow, exposes an internal EventHandlingInputPort into
- * which the internal workflow logic pushes data to be exposed outside the
- * workflow boundary.
- * 
- * @author Tom Oinn
- */
-public interface DataflowOutputPort extends EventForwardingOutputPort,
-		DataflowPort {
-	/**
-	 * Get the internal input port for this workflow output
-	 * 
-	 * @return port into which the workflow can push data for this output
-	 */
-	EventHandlingInputPort getInternalInputPort();
-
-	/**
-	 * Add a ResultListener, capable of listening to results being received by
-	 * the output port
-	 * 
-	 * @param listener
-	 *            the ResultListener
-	 * 
-	 * @see ResultListener
-	 */
-	void addResultListener(ResultListener listener);
-
-	/**
-	 * Remove a ResultListener
-	 * 
-	 * @param listener
-	 *            the ResultListener
-	 * 
-	 * @see ResultListener
-	 */
-	void removeResultListener(ResultListener listener);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/DataflowPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/DataflowPort.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/DataflowPort.java
deleted file mode 100644
index bc0fcda..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/DataflowPort.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007-2009 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-/**
- * Defines that the implementing port belongs to a Dataflow
- * 
- * @author Tom Oinn
- * @author Stian Soiland-Reyes
- */
-public interface DataflowPort extends Port {
-	/**
-	 * Get the parent DataFlow to which this port belongs
-	 */
-	public Dataflow getDataflow();
-}


[34/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateReferenceSetDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateReferenceSetDao.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateReferenceSetDao.java
new file mode 100644
index 0000000..67e5cac
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateReferenceSetDao.java
@@ -0,0 +1,197 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import static org.apache.taverna.reference.T2ReferenceType.ReferenceSet;
+
+import java.util.List;
+
+import org.apache.taverna.reference.DaoException;
+import org.apache.taverna.reference.ReferenceSet;
+import org.apache.taverna.reference.ReferenceSetDao;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.annotations.DeleteIdentifiedOperation;
+import org.apache.taverna.reference.annotations.GetIdentifiedOperation;
+import org.apache.taverna.reference.annotations.PutIdentifiedOperation;
+
+import org.hibernate.Query;
+import org.hibernate.SessionFactory;
+
+/**
+ * An implementation of ReferenceSetDao based on raw hibernate session factory
+ * injection and running within a spring managed context through auto-proxy
+ * generation. To use this in spring inject a property 'sessionFactory' with
+ * either a {@link org.springframework.orm.hibernate3.LocalSessionFactoryBean
+ * LocalSessionFactoryBean} or the equivalent class from the T2Platform module
+ * to add SPI based implementation discovery and mapping. To use outside of
+ * Spring ensure you call the setSessionFactory(..) method before using this
+ * (but really, use it from Spring, so much easier).
+ * <p>
+ * Methods in this Dao require transactional support
+ * 
+ * @author Tom Oinn
+ */
+public class TransactionalHibernateReferenceSetDao implements ReferenceSetDao {
+	private static final String GET_REFSETS_FOR_RUN = "FROM ReferenceSetImpl WHERE namespacePart=:workflow_run_id";
+	private SessionFactory sessionFactory;
+
+	public void setSessionFactory(SessionFactory sessionFactory) {
+		this.sessionFactory = sessionFactory;
+	}
+
+	/**
+	 * Store the specified new reference set
+	 * 
+	 * @param rs
+	 *            a reference set, must not already exist in the database.
+	 * @throws DaoException
+	 *             if the entry already exists in the database, if the supplied
+	 *             reference set isn't an instance of ReferenceSetImpl or if
+	 *             something else goes wrong connecting to the database
+	 */
+	@Override
+	@PutIdentifiedOperation
+	public void store(ReferenceSet rs) throws DaoException {
+		if (rs.getId() == null)
+			throw new DaoException(
+					"Supplied reference set has a null ID, allocate "
+							+ "an ID before calling the store method in the dao.");
+		if (!rs.getId().getReferenceType().equals(ReferenceSet))
+			throw new DaoException(
+					"Strangely the reference set ID doesn't have type "
+							+ "T2ReferenceType.ReferenceSet, something has probably "
+							+ "gone badly wrong somewhere earlier!");
+		if (!(rs instanceof ReferenceSetImpl))
+			throw new DaoException(
+					"Supplied reference set not an instance of ReferenceSetImpl");
+
+		try {
+			sessionFactory.getCurrentSession().save(rs);
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+
+	/**
+	 * Update a pre-existing entry in the database
+	 * 
+	 * @param rs
+	 *            the reference set to update. This must already exist in the
+	 *            database
+	 * @throws DaoException
+	 */
+	@Override
+	@PutIdentifiedOperation
+	public void update(ReferenceSet rs) throws DaoException {
+		if (rs.getId() == null)
+			throw new DaoException(
+					"Supplied reference set has a null ID, allocate "
+							+ "an ID before calling the store method in the dao.");
+		if (!rs.getId().getReferenceType().equals(ReferenceSet))
+			throw new DaoException(
+					"Strangely the reference set ID doesn't have type "
+							+ "T2ReferenceType.ReferenceSet, something has probably "
+							+ "gone badly wrong somewhere earlier!");
+		if (!(rs instanceof ReferenceSetImpl))
+			throw new DaoException(
+					"Supplied reference set not an instance of ReferenceSetImpl");
+
+		try {
+			sessionFactory.getCurrentSession().update(rs);
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+
+	/**
+	 * Fetch a reference set by id
+	 * 
+	 * @param ref
+	 *            the ReferenceSetT2ReferenceImpl to fetch
+	 * @return a retrieved ReferenceSetImpl
+	 * @throws DaoException
+	 *             if the supplied reference is of the wrong type or if
+	 *             something goes wrong fetching the data or connecting to the
+	 *             database
+	 */
+	@Override
+	@GetIdentifiedOperation
+	public ReferenceSetImpl get(T2Reference ref) throws DaoException {
+		if (ref == null)
+			throw new DaoException(
+					"Supplied reference is null, can't retrieve.");
+		if (!ref.getReferenceType().equals(ReferenceSet))
+			throw new DaoException(
+					"This dao can only retrieve reference of type T2Reference.ReferenceSet");
+		if (!(ref instanceof T2ReferenceImpl))
+			throw new DaoException(
+					"Reference must be an instance of T2ReferenceImpl");
+
+		try {
+			return (ReferenceSetImpl) sessionFactory.getCurrentSession().get(
+					ReferenceSetImpl.class,
+					((T2ReferenceImpl) ref).getCompactForm());
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+
+	@Override
+	@DeleteIdentifiedOperation
+	public boolean delete(ReferenceSet rs) throws DaoException {
+		if (rs.getId() == null)
+			throw new DaoException(
+					"Supplied reference set has a null ID, allocate "
+							+ "an ID before calling the store method in the dao.");
+		if (!rs.getId().getReferenceType().equals(ReferenceSet))
+			throw new DaoException(
+					"Strangely the reference set ID doesn't have type "
+							+ "T2ReferenceType.ReferenceSet, something has probably "
+							+ "gone badly wrong somewhere earlier!");
+		if (!(rs instanceof ReferenceSetImpl))
+			throw new DaoException(
+					"Supplied reference set not an instance of ReferenceSetImpl");
+
+		try {
+			sessionFactory.getCurrentSession().delete(rs);
+			return true;
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+
+	@Override
+	@SuppressWarnings("unchecked")
+	@DeleteIdentifiedOperation
+	public synchronized void deleteReferenceSetsForWFRun(String workflowRunId)
+			throws DaoException {
+		try {
+			// Select all ReferenceSets for this wf run
+			Query selectQuery = sessionFactory.getCurrentSession().createQuery(
+					GET_REFSETS_FOR_RUN);
+			selectQuery.setString("workflow_run_id", workflowRunId);
+			List<ReferenceSet> referenceSets = selectQuery.list();
+			for (ReferenceSet referenceSet : referenceSets)
+				delete(referenceSet);
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TranslationPath.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TranslationPath.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TranslationPath.java
new file mode 100644
index 0000000..6422a0f
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TranslationPath.java
@@ -0,0 +1,285 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.taverna.reference.DereferenceException;
+import org.apache.taverna.reference.ExternalReferenceBuilderSPI;
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ExternalReferenceTranslatorSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferenceSet;
+
+/**
+ * A path from one external reference to another along with a total estimated
+ * path cost through one or more reference translators.
+ */
+public class TranslationPath implements Comparable<TranslationPath>,
+		Iterable<ExternalReferenceTranslatorSPI<?, ?>> {
+	private List<ExternalReferenceTranslatorSPI<?, ?>> translators = new ArrayList<>();
+	private ExternalReferenceBuilderSPI<?> initialBuilder = null;
+	private ExternalReferenceSPI sourceReference = null;
+	private List<ExternalReferenceBuilderSPI<?>> builders;
+
+	public TranslationPath() {
+	}
+
+	/**
+	 * Return a human readable representation of this translation path, used by
+	 * the logging methods to print trace information.
+	 */
+	@SuppressWarnings("rawtypes")
+	@Override
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		sb.append(getPathCost() + " ");
+		if (getSourceReference() != null && getInitialBuilder() != null) {
+			sb.append(getSourceReference()).append("->bytes(")
+					.append(getSourceReference().getResolutionCost())
+					.append(")->");
+			String builderClassName = getInitialBuilder().getClass()
+					.getSimpleName();
+			String builtType = getInitialBuilder().getReferenceType()
+					.getSimpleName();
+			sb.append("builder:").append(builderClassName).append("(")
+					.append(getInitialBuilder().getConstructionCost())
+					.append("):<").append(builtType).append(">");
+		} else if (!getTranslators().isEmpty())
+			sb.append("<")
+					.append(getTranslators().get(0).getSourceReferenceType()
+							.getSimpleName()).append(">");
+		for (ExternalReferenceTranslatorSPI translator : getTranslators())
+			sb.append("-")
+					.append(translator.getClass().getSimpleName())
+					.append("(")
+					.append(translator.getTranslationCost())
+					.append(")-<")
+					.append(translator.getTargetReferenceType().getSimpleName())
+					.append(">");
+		return sb.toString();
+	}
+
+	@SuppressWarnings({ "rawtypes", "unchecked" })
+	public Set<ExternalReferenceSPI> doTranslation(ReferenceSet rs,
+			ReferenceContext context) {
+		Set<ExternalReferenceSPI> results = new HashSet<>();
+		/*
+		 * Firstly check whether we have an initial reference and builder
+		 * defined
+		 */
+		ExternalReferenceSPI currentReference = null;
+		if (getInitialBuilder() != null && getSourceReference() != null)
+			try (InputStream stream = getSourceReference().openStream(context)) {
+				ExternalReferenceSPI builtReference = getInitialBuilder()
+						.createReference(stream, context);
+				results.add(builtReference);
+				currentReference = builtReference;
+			} catch (IOException e) {
+				throw new DereferenceException(
+						"Can't create reference from stream", e);
+			}
+		if (!getTranslators().isEmpty() && currentReference == null)
+			/*
+			 * If there are translators in the path (there may not be if this is
+			 * a pure 'dereference and build' type path) and the
+			 * currentReference hasn't been set then search the existing
+			 * references for an appropriate starting point for the translation.
+			 */
+			for (ExternalReferenceSPI er : rs.getExternalReferences())
+				if (er.getClass().equals(
+						getTranslators().get(0).getSourceReferenceType())) {
+					currentReference = er;
+					break;
+				}
+		if (currentReference == null)
+			throw new RuntimeException(
+					"Can't locate a starting reference for the"
+							+ " translation path");
+
+		for (ExternalReferenceTranslatorSPI translator : getTranslators()) {
+			ExternalReferenceSPI translatedReference = translator
+					.createReference(currentReference, context);
+			results.add(translatedReference);
+			currentReference = translatedReference;
+		}
+		return results;
+	}
+
+	/**
+	 * Sum of translation costs of all translators in path
+	 */
+	public float getPathCost() {
+		float cost = 0.0f;
+		for (ExternalReferenceTranslatorSPI<?, ?> ert : this)
+			cost += ert.getTranslationCost();
+		/*
+		 * If the source reference and initial builder are non-null then we're
+		 * going to start this translation path by downloading a byte stream
+		 * from the specified (current) reference and using it to construct the
+		 * starting point for the translation path via the specified builder.
+		 */
+		if (getSourceReference() != null)
+			cost += getSourceReference().getResolutionCost();
+		if (getInitialBuilder() != null)
+			cost += getInitialBuilder().getConstructionCost();
+		return cost;
+	}
+
+	/**
+	 * Return a list of translation paths based on this one but which start at
+	 * an existing reference within the supplied reference set. Will only
+	 * function if there is a reference builder registered that can build the
+	 * initial reference type used by this translation path, otherwise it
+	 * returns an empty list.
+	 * 
+	 * @param rs
+	 * @return
+	 */
+	@SuppressWarnings("rawtypes")
+	public List<TranslationPath> getDereferenceBasedPaths(ReferenceSet rs) {
+		List<TranslationPath> results = new ArrayList<>();
+		for (ExternalReferenceBuilderSPI erb : getBuilders())
+			/*
+			 * Check for each reference builder to see if it can build the
+			 * source type for this path
+			 */
+			if (erb.getReferenceType().equals(this.getSourceType()))
+				/*
+				 * The builder can construct the type used by the start of this
+				 * translation path, so we can in general create a path from a
+				 * fooreference to the target by de-referencing the fooreference
+				 * and building the start type from it.
+				 */
+				for (ExternalReferenceSPI er : rs.getExternalReferences()) {
+					/*
+					 * For each external reference in the existing reference
+					 * set, check whether that type is already going to be
+					 * created in the translation path - if so then there's not
+					 * much point in emiting the modified path, as you'd have
+					 * something like bytes->a->b->a->result which wouldn't make
+					 * any sense
+					 */
+					boolean overlapsExistingType = false;
+					for (ExternalReferenceTranslatorSPI translationStep : this)
+						if (translationStep.getSourceReferenceType().equals(
+								er.getClass())) {
+							overlapsExistingType = true;
+							break;
+						}
+					if (!overlapsExistingType) {
+						/*
+						 * The type wasn't found anywhere within the translation
+						 * path, so we're not generating obviously stupid
+						 * candidate paths.
+						 */
+						TranslationPath newPath = new TranslationPath();
+						newPath.setBuilders(getBuilders());
+						newPath.setTranslators(getTranslators());
+						newPath.setInitialBuilder(erb);
+						newPath.setSourceReference(er);
+						results.add(newPath);
+					}
+				}
+		return results;
+	}
+
+	public List<ExternalReferenceTranslatorSPI<?, ?>> pathSteps() {
+		return getTranslators();
+	}
+
+	/**
+	 * Order by total path cost
+	 */
+	@Override
+	public int compareTo(TranslationPath tp) {
+		float tpCost = tp.getPathCost();
+		float myCost = getPathCost();
+		if (tpCost > myCost)
+			return -1;
+		if (tpCost < myCost)
+			return 1;
+		return 0;
+	}
+
+	/**
+	 * Wrap translator list iterator for convenience
+	 */
+	@Override
+	public Iterator<ExternalReferenceTranslatorSPI<?, ?>> iterator() {
+		return getTranslators().iterator();
+	}
+
+	public Class<? extends ExternalReferenceSPI> getSourceType() {
+		if (!getTranslators().isEmpty())
+			return getTranslators().get(0).getSourceReferenceType();
+		if (getSourceReference() != null)
+			return getSourceReference().getClass();
+		return null;
+	}
+
+	public Class<? extends ExternalReferenceSPI> getTargetType() {
+		if (!getTranslators().isEmpty())
+			return getTranslators().get(getTranslators().size() - 1)
+					.getTargetReferenceType();
+		if (getInitialBuilder() != null)
+			return getInitialBuilder().getReferenceType();
+		return null;
+	}
+
+	public List<ExternalReferenceTranslatorSPI<?, ?>> getTranslators() {
+		return translators;
+	}
+
+	public void setTranslators(
+			List<ExternalReferenceTranslatorSPI<?, ?>> translators) {
+		this.translators = translators;
+	}
+
+	public ExternalReferenceBuilderSPI<?> getInitialBuilder() {
+		return initialBuilder;
+	}
+
+	public void setInitialBuilder(ExternalReferenceBuilderSPI<?> initialBuilder) {
+		this.initialBuilder = initialBuilder;
+	}
+
+	public ExternalReferenceSPI getSourceReference() {
+		return sourceReference;
+	}
+
+	public void setSourceReference(ExternalReferenceSPI sourceReference) {
+		this.sourceReference = sourceReference;
+	}
+
+	public List<ExternalReferenceBuilderSPI<?>> getBuilders() {
+		return builders;
+	}
+
+	public void setBuilders(List<ExternalReferenceBuilderSPI<?>> builders) {
+		this.builders = builders;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/UUIDT2ReferenceGenerator.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/UUIDT2ReferenceGenerator.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/UUIDT2ReferenceGenerator.java
new file mode 100644
index 0000000..aba8ab4
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/UUIDT2ReferenceGenerator.java
@@ -0,0 +1,55 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import java.util.UUID;
+
+import org.apache.taverna.reference.T2ReferenceGenerator;
+
+/**
+ * A T2ReferenceGenerator based on UUIDs. Not as fast as
+ * {@link SimpleT2ReferenceGenerator}, but IDs will be globally unique.
+ * 
+ * @author Stian Soiland-Reyes
+ */
+public class UUIDT2ReferenceGenerator extends AbstractT2ReferenceGenerator
+		implements T2ReferenceGenerator {
+	private String namespace = "uuid";
+
+	/**
+	 * Set the namespace for identifiers generated by this class as a string
+	 * 
+	 * @param newNamespace
+	 *            the namespace to use
+	 */
+	public void setNamespace(String newNamespace) {
+		this.namespace = newNamespace;
+	}
+	
+	@Override
+	public String getNamespace() {
+		return namespace;
+	}
+
+	@Override
+	protected String getNextLocalPart() {
+		return UUID.randomUUID().toString();
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/WriteQueueAspect.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/WriteQueueAspect.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/WriteQueueAspect.java
new file mode 100644
index 0000000..2dd17f4
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/WriteQueueAspect.java
@@ -0,0 +1,141 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+import java.lang.ref.SoftReference;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+
+import org.apache.taverna.reference.DaoException;
+import org.apache.taverna.reference.Identified;
+import org.apache.taverna.reference.T2Reference;
+
+import org.aspectj.lang.ProceedingJoinPoint;
+
+/**
+ * An aspect used to intercept calls to the various data access objects and
+ * execute data writes on a thread limited executer with an unbounded blocking
+ * queue.
+ * 
+ * @author David Withers
+ */
+public class WriteQueueAspect {
+	private Map<T2Reference, Identified> store = new ConcurrentHashMap<>();
+	private Map<T2Reference, SoftReference<Identified>> cache = new ConcurrentHashMap<>();
+	private ThreadPoolExecutor executer;
+
+	public WriteQueueAspect() {
+		this(5);
+	}
+
+	public WriteQueueAspect(int threads) {
+		executer = new ThreadPoolExecutor(threads, threads, 60, SECONDS,
+				new LinkedBlockingQueue<Runnable>(),
+				Executors.defaultThreadFactory(),
+				new ThreadPoolExecutor.CallerRunsPolicy());
+	}
+
+	/**
+	 * Handle a 'get by T2Reference' operation on a Dao
+	 * 
+	 * @param pjp
+	 *            the join point representing the ongoing method call to the dao
+	 * @return the entity identified by the T2Reference supplied to the method
+	 *         to which this advice applies
+	 * @throws DaoException
+	 *             if anything goes wrong
+	 */
+	public final Identified getObject(final ProceedingJoinPoint pjp)
+			throws DaoException {
+		Identified result = null;
+
+		// Get the T2Reference from the argument to the get method
+		T2Reference id = (T2Reference) pjp.getArgs()[0];
+		if (id != null) {
+			// try the cache
+			SoftReference<Identified> ref = cache.get(id);
+			if (ref != null)
+				result = ref.get();
+			if (result == null)
+				// not in the cache, check if it's still in the write queue
+				result = store.get(id);
+		}
+		// If we miss the cache then call the method as usual
+		if (result == null)
+			try {
+				result = (Identified) pjp.proceed();
+				if (result != null)
+					cache.put(id, new SoftReference<>(result));
+			} catch (DaoException e) {
+				throw e;
+			} catch (Throwable e) {
+				throw new DaoException(
+						"Unexpected exception type during aspect "
+								+ "based invocation", e);
+			}
+
+		return result;
+	}
+
+	/**
+	 * Called around a write or update operation on the backing store, writes
+	 * through to the cache after modifying the state of the backing store and
+	 * before returning from the dao method
+	 * 
+	 * @param pjp
+	 *            join point representing the ongoing method invocation to cache
+	 * @throws DaoException
+	 *             if anything goes wrong
+	 */
+	public void putObject(final ProceedingJoinPoint pjp) throws DaoException {
+		// Get the Identified being stored by the method we're advising
+		final Identified storedObject = (Identified) pjp.getArgs()[0];
+
+		Runnable task = new Runnable() {
+			@Override
+			public void run() {
+				try {
+					// Run the store or update method
+					pjp.proceed();
+					store.remove(storedObject.getId());
+				} catch (DaoException e) {
+					throw e;
+				} catch (Throwable e) {
+					throw new DaoException(
+							"Unexpected exception type during aspect "
+									+ "based invocation", e);
+				}
+			}
+		};
+
+		cache.put(storedObject.getId(), new SoftReference<>(storedObject));
+		store.put(storedObject.getId(), storedObject);
+		executer.execute(task);
+	}
+
+	public int cacheSize() {
+		return executer.getActiveCount() + executer.getQueue().size();
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/package.html
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/package.html b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/package.html
new file mode 100644
index 0000000..79e0107
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/package.html
@@ -0,0 +1,5 @@
+<body>
+Implementation of the reference manager APIs backed by Hibernate. These
+classes are intended to be used with Spring, so have their dependencies
+injected through set methods rather than constructor arguments.
+</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.h3.HibernateComponentClass
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.h3.HibernateComponentClass b/taverna-reference-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.h3.HibernateComponentClass
deleted file mode 100644
index b7b5d58..0000000
--- a/taverna-reference-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.h3.HibernateComponentClass
+++ /dev/null
@@ -1,2 +0,0 @@
-net.sf.taverna.t2.reference.impl.T2ReferenceImpl
-net.sf.taverna.t2.reference.impl.StackTraceElementBeanImpl
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.h3.HibernateMappedEntity
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.h3.HibernateMappedEntity b/taverna-reference-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.h3.HibernateMappedEntity
deleted file mode 100644
index ddf2cc5..0000000
--- a/taverna-reference-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.h3.HibernateMappedEntity
+++ /dev/null
@@ -1,3 +0,0 @@
-net.sf.taverna.t2.reference.impl.ReferenceSetImpl
-net.sf.taverna.t2.reference.impl.T2ReferenceListImpl
-net.sf.taverna.t2.reference.impl.ErrorDocumentImpl
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/META-INF/services/org.apache.taverna.reference.h3.HibernateComponentClass
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/META-INF/services/org.apache.taverna.reference.h3.HibernateComponentClass b/taverna-reference-impl/src/main/resources/META-INF/services/org.apache.taverna.reference.h3.HibernateComponentClass
new file mode 100644
index 0000000..913661c
--- /dev/null
+++ b/taverna-reference-impl/src/main/resources/META-INF/services/org.apache.taverna.reference.h3.HibernateComponentClass
@@ -0,0 +1,2 @@
+org.apache.taverna.reference.impl.T2ReferenceImpl
+org.apache.taverna.reference.impl.StackTraceElementBeanImpl
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/META-INF/services/org.apache.taverna.reference.h3.HibernateMappedEntity
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/META-INF/services/org.apache.taverna.reference.h3.HibernateMappedEntity b/taverna-reference-impl/src/main/resources/META-INF/services/org.apache.taverna.reference.h3.HibernateMappedEntity
new file mode 100644
index 0000000..d9f0cf4
--- /dev/null
+++ b/taverna-reference-impl/src/main/resources/META-INF/services/org.apache.taverna.reference.h3.HibernateMappedEntity
@@ -0,0 +1,3 @@
+org.apache.taverna.reference.impl.ReferenceSetImpl
+org.apache.taverna.reference.impl.T2ReferenceListImpl
+org.apache.taverna.reference.impl.ErrorDocumentImpl
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/META-INF/spring.handlers
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/META-INF/spring.handlers b/taverna-reference-impl/src/main/resources/META-INF/spring.handlers
index 462f844..f3bed57 100644
--- a/taverna-reference-impl/src/main/resources/META-INF/spring.handlers
+++ b/taverna-reference-impl/src/main/resources/META-INF/spring.handlers
@@ -1 +1 @@
-http\://taverna.sf.net/schema/artifact-support=net.sf.taverna.platform.spring.ArtifactSupportNamespaceHandler
\ No newline at end of file
+http\://taverna.sf.net/schema/artifact-support=org.apache.taverna.platform.spring.ArtifactSupportNamespaceHandler
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/META-INF/spring/hibernate-reference-impl-context.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/META-INF/spring/hibernate-reference-impl-context.xml b/taverna-reference-impl/src/main/resources/META-INF/spring/hibernate-reference-impl-context.xml
index 4fb8ba4..ad4ed52 100644
--- a/taverna-reference-impl/src/main/resources/META-INF/spring/hibernate-reference-impl-context.xml
+++ b/taverna-reference-impl/src/main/resources/META-INF/spring/hibernate-reference-impl-context.xml
@@ -3,7 +3,7 @@
 	xsi:schemaLocation="http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans.xsd">
 
-	<bean id="hibernateReferenceService" class="net.sf.taverna.t2.reference.impl.ReferenceServiceImpl">
+	<bean id="hibernateReferenceService" class="org.apache.taverna.reference.impl.ReferenceServiceImpl">
 		<property name="converters" ref="converters" />
 		<property name="valueBuilders" ref="valueBuilders" />
 		<property name="referenceSetService">
@@ -17,7 +17,7 @@
 		</property>
 	</bean>
 
-	<bean id="referenceSetService" class="net.sf.taverna.t2.reference.impl.ReferenceSetServiceImpl">
+	<bean id="referenceSetService" class="org.apache.taverna.reference.impl.ReferenceSetServiceImpl">
 		<property name="referenceSetDao">
 			<ref local="referenceSetDao" />
 		</property>
@@ -25,14 +25,14 @@
 		<property name="referenceSetAugmentor" ref="referenceSetAugmentor" />
 	</bean>
 
-	<bean id="listService" class="net.sf.taverna.t2.reference.impl.ListServiceImpl">
+	<bean id="listService" class="org.apache.taverna.reference.impl.ListServiceImpl">
 		<property name="listDao">
 			<ref local="listDao" />
 		</property>
 		<property name="t2ReferenceGenerator" ref="t2ReferenceGenerator" />
 	</bean>
 
-	<bean id="errorDocumentService" class="net.sf.taverna.t2.reference.impl.ErrorDocumentServiceImpl">
+	<bean id="errorDocumentService" class="org.apache.taverna.reference.impl.ErrorDocumentServiceImpl">
 		<property name="errorDao">
 			<ref local="errorDocumentDao" />
 		</property>
@@ -81,34 +81,34 @@
 		<property name="mappingResources">
 			<list>
 				<value>
-					net/sf/taverna/t2/reference/AbstractExternalReference.hbm.xml
+					org/apache/taverna/reference/AbstractExternalReference.hbm.xml
 				</value>
 				<value>
-					net/sf/taverna/t2/reference/impl/ReferenceSetImpl.hbm.xml
+					org/apache/taverna/reference/impl/ReferenceSetImpl.hbm.xml
 				</value>
 				<value>
-					net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.hbm.xml
+					org/apache/taverna/reference/impl/T2ReferenceListImpl.hbm.xml
 				</value>
 				<value>
-					net/sf/taverna/t2/reference/impl/ErrorDocumentImpl.hbm.xml
+					org/apache/taverna/reference/impl/ErrorDocumentImpl.hbm.xml
 				</value>
 			</list>
 		</property>
 	</bean>
 
-	<bean id="referenceSetDao" class="net.sf.taverna.t2.reference.impl.HibernateReferenceSetDao" >
+	<bean id="referenceSetDao" class="org.apache.taverna.reference.impl.HibernateReferenceSetDao" >
 		<property name="sessionFactory">
 			<ref local="sessionFactoryBean" />
 		</property>
 	</bean>
 
-	<bean id="listDao" class="net.sf.taverna.t2.reference.impl.HibernateListDao" >
+	<bean id="listDao" class="org.apache.taverna.reference.impl.HibernateListDao" >
 		<property name="sessionFactory">
 			<ref local="sessionFactoryBean" />
 		</property>
 	</bean>
 
-	<bean id="errorDocumentDao" class="net.sf.taverna.t2.reference.impl.HibernateErrorDocumentDao" >
+	<bean id="errorDocumentDao" class="org.apache.taverna.reference.impl.HibernateErrorDocumentDao" >
 		<property name="sessionFactory">
 			<ref local="sessionFactoryBean" />
 		</property>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/META-INF/spring/in-memory-reference-impl-context.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/META-INF/spring/in-memory-reference-impl-context.xml b/taverna-reference-impl/src/main/resources/META-INF/spring/in-memory-reference-impl-context.xml
index 3508214..e9b025d 100644
--- a/taverna-reference-impl/src/main/resources/META-INF/spring/in-memory-reference-impl-context.xml
+++ b/taverna-reference-impl/src/main/resources/META-INF/spring/in-memory-reference-impl-context.xml
@@ -3,7 +3,7 @@
 	xsi:schemaLocation="http://www.springframework.org/schema/beans 
         http://www.springframework.org/schema/beans/spring-beans.xsd">
 
-	<bean id="inMemoryReferenceService" class="net.sf.taverna.t2.reference.impl.ReferenceServiceImpl">
+	<bean id="inMemoryReferenceService" class="org.apache.taverna.reference.impl.ReferenceServiceImpl">
 		<property name="converters" ref="converters" />
 		<property name="valueBuilders" ref="valueBuilders" />
 		<property name="referenceSetService">
@@ -17,7 +17,7 @@
 		</property>
 	</bean>
 
-	<bean id="referenceSetService" class="net.sf.taverna.t2.reference.impl.ReferenceSetServiceImpl">
+	<bean id="referenceSetService" class="org.apache.taverna.reference.impl.ReferenceSetServiceImpl">
 		<property name="referenceSetDao">
 			<ref local="referenceSetDao" />
 		</property>
@@ -25,22 +25,22 @@
 		<property name="referenceSetAugmentor" ref="referenceSetAugmentor" />
 	</bean>
 
-	<bean id="listService" class="net.sf.taverna.t2.reference.impl.ListServiceImpl">
+	<bean id="listService" class="org.apache.taverna.reference.impl.ListServiceImpl">
 		<property name="listDao">
 			<ref local="listDao" />
 		</property>
 		<property name="t2ReferenceGenerator" ref="t2ReferenceGenerator" />
 	</bean>
 
-	<bean id="errorDocumentService" class="net.sf.taverna.t2.reference.impl.ErrorDocumentServiceImpl">
+	<bean id="errorDocumentService" class="org.apache.taverna.reference.impl.ErrorDocumentServiceImpl">
 		<property name="errorDao">
 			<ref local="errorDocumentDao" />
 		</property>
 		<property name="t2ReferenceGenerator" ref="t2ReferenceGenerator" />
 	</bean>
 	
-	<bean id="referenceSetDao" class="net.sf.taverna.t2.reference.impl.InMemoryReferenceSetDao" />
-	<bean id="listDao" class="net.sf.taverna.t2.reference.impl.InMemoryListDao" />
-	<bean id="errorDocumentDao" class="net.sf.taverna.t2.reference.impl.InMemoryErrorDocumentDao" />
+	<bean id="referenceSetDao" class="org.apache.taverna.reference.impl.InMemoryReferenceSetDao" />
+	<bean id="listDao" class="org.apache.taverna.reference.impl.InMemoryListDao" />
+	<bean id="errorDocumentDao" class="org.apache.taverna.reference.impl.InMemoryErrorDocumentDao" />
 
 </beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/META-INF/spring/reference-impl-context-osgi.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/META-INF/spring/reference-impl-context-osgi.xml b/taverna-reference-impl/src/main/resources/META-INF/spring/reference-impl-context-osgi.xml
index 27430cd..dd2f2c7 100644
--- a/taverna-reference-impl/src/main/resources/META-INF/spring/reference-impl-context-osgi.xml
+++ b/taverna-reference-impl/src/main/resources/META-INF/spring/reference-impl-context-osgi.xml
@@ -8,18 +8,18 @@
         http://www.springframework.org/schema/osgi-compendium
        	http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd">
 
-	<list id="converters" interface="net.sf.taverna.t2.reference.ValueToReferenceConverterSPI" cardinality="0..N" />
-	<list id="valueBuilders" interface="net.sf.taverna.t2.reference.StreamToValueConverterSPI" cardinality="0..N" />
-	<list id="builders" interface="net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI" cardinality="0..N">
+	<list id="converters" interface="org.apache.taverna.reference.ValueToReferenceConverterSPI" cardinality="0..N" />
+	<list id="valueBuilders" interface="org.apache.taverna.reference.StreamToValueConverterSPI" cardinality="0..N" />
+	<list id="builders" interface="org.apache.taverna.reference.ExternalReferenceBuilderSPI" cardinality="0..N">
 		<listener ref="referenceSetAugmentor" bind-method="buildersUpdated" unbind-method="buildersUpdated" />
 	</list>
-	<list id="translators" interface="net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI" cardinality="0..N">
+	<list id="translators" interface="org.apache.taverna.reference.ExternalReferenceTranslatorSPI" cardinality="0..N">
 		<listener ref="referenceSetAugmentor" bind-method="translatorsUpdated" unbind-method="translatorsUpdated" />
 	</list>
 
-    <reference id="databaseManager" interface="uk.org.taverna.configuration.database.DatabaseManager"/>
+    <reference id="databaseManager" interface="org.apache.taverna.configuration.database.DatabaseManager"/>
 
-	<service ref="inMemoryReferenceService" interface="net.sf.taverna.t2.reference.ReferenceService" />
-	<service ref="hibernateReferenceService" interface="net.sf.taverna.t2.reference.ReferenceService" />
+	<service ref="inMemoryReferenceService" interface="org.apache.taverna.reference.ReferenceService" />
+	<service ref="hibernateReferenceService" interface="org.apache.taverna.reference.ReferenceService" />
 
 </beans:beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/META-INF/spring/reference-impl-context.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/META-INF/spring/reference-impl-context.xml b/taverna-reference-impl/src/main/resources/META-INF/spring/reference-impl-context.xml
index f87847b..855085b 100644
--- a/taverna-reference-impl/src/main/resources/META-INF/spring/reference-impl-context.xml
+++ b/taverna-reference-impl/src/main/resources/META-INF/spring/reference-impl-context.xml
@@ -3,12 +3,12 @@
 	xsi:schemaLocation="http://www.springframework.org/schema/beans 
         http://www.springframework.org/schema/beans/spring-beans.xsd">
 	
-	<bean id="referenceSetAugmentor" class="net.sf.taverna.t2.reference.impl.ReferenceSetAugmentorImpl">
+	<bean id="referenceSetAugmentor" class="org.apache.taverna.reference.impl.ReferenceSetAugmentorImpl">
 		<property name="builders" ref="builders" />
 		<property name="translators" ref="translators" />
 	</bean>
 
-	<bean id="t2ReferenceGenerator" class="net.sf.taverna.t2.reference.impl.UUIDT2ReferenceGenerator">
+	<bean id="t2ReferenceGenerator" class="org.apache.taverna.reference.impl.UUIDT2ReferenceGenerator">
 		<property name="namespace" value="taverna" />
 	</bean>
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/ErrorDocumentImpl.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/ErrorDocumentImpl.hbm.xml b/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/ErrorDocumentImpl.hbm.xml
deleted file mode 100644
index 0bf7bba..0000000
--- a/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/ErrorDocumentImpl.hbm.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
-                "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-                "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!-- Hibernate mapping for ErrorDocumentImpl -->
-<hibernate-mapping>
-	<class name="net.sf.taverna.t2.reference.impl.ErrorDocumentImpl"
-		abstract="false">
-		<id name="internalId" column="id" type="string"/>
-		<!--  Composite key constructed from the namespace and local -->
-		<!--  parts of the T2Reference implementation type           -->
-		<component name="typedId"
-			class="net.sf.taverna.t2.reference.impl.T2ReferenceImpl">
-			<property name="namespacePart" />
-			<property name="localPart" />
-			<property name="containsErrors"/>
-			<property name="depth"/>
-			<property name="referenceType"/>
-		</component>
-		<property name="message" length="10000"/>
-		<property name="exceptionMessage" length="10000"/>
-		<list name="stackTraceList" cascade="all" lazy="false">
-			<key column="id" not-null="true"/>
-			<list-index column="i" base="0" />
-			<composite-element
-				class="net.sf.taverna.t2.reference.impl.StackTraceElementBeanImpl">
-				<property name="fileName" />
-				<property name="className" />
-				<property name="methodName" />
-				<property name="lineNumber" />
-			</composite-element>
-		</list>
-		<set name="errorReferenceSet" cascade="all" lazy="false">
-			<key column="id" not-null="true"/>
-			<composite-element
-				class="net.sf.taverna.t2.reference.impl.T2ReferenceImpl">
-				<property name="namespacePart" />
-				<property name="localPart" />
-				<property name="containsErrors"/>
-				<property name="depth"/>
-				<property name="referenceType"/>
-			</composite-element>
-		</set>
-	</class>
-</hibernate-mapping>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/ReferenceSetImpl.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/ReferenceSetImpl.hbm.xml b/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/ReferenceSetImpl.hbm.xml
deleted file mode 100644
index 04c316d..0000000
--- a/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/ReferenceSetImpl.hbm.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
-                "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-                "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!-- Hibernate mapping for ReferenceSetImpl -->
-<hibernate-mapping>
-	<class name="net.sf.taverna.t2.reference.impl.ReferenceSetImpl"
-		abstract="false" lazy="false">
-		<id name="internalId" column="id" type="string"
-			unsaved-value="null" />
-			
-		<!--  Composite key constructed from the namespace and local -->
-		<!--  parts of the T2Reference implementation type, used as  -->
-		<!--  the foreign key in the one to many relationship with   -->
-		<!--  extensions of AbstractExternalReference                -->
-		
-		<component name="typedId"
-			class="net.sf.taverna.t2.reference.impl.T2ReferenceImpl">
-			<property name="namespacePart" />
-			<property name="localPart" />
-			<property name="containsErrors" />
-			<property name="depth" />
-			<property name="referenceType" />
-		</component>
-		<set name="externalReferences" cascade="all" lazy="false">
-			<key column="id" />
-			<one-to-many
-				class="net.sf.taverna.t2.reference.AbstractExternalReference" />
-		</set>
-		<property name="approximateSizeInBytes" />
-	</class>
-</hibernate-mapping>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.hbm.xml b/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.hbm.xml
deleted file mode 100644
index b24c333..0000000
--- a/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.hbm.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
-                "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-                "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!-- Hibernate mapping for T2ReferenceListImpl, used by HibernateListDao -->
-<hibernate-mapping>
-	<class name="net.sf.taverna.t2.reference.impl.T2ReferenceListImpl"
-		abstract="false">
-		<id name="internalId" column="id" type="string"/>
-		<!--  Composite key constructed from the namespace and local -->
-		<!--  parts of the T2Reference implementation type, used as  -->
-		<!--  the foreign key in the one to many relationship with   -->
-		<!--  extensions of AbstractExternalReference                -->
-		<component name="typedId"
-			class="net.sf.taverna.t2.reference.impl.T2ReferenceImpl">
-			<property name="namespacePart" />
-			<property name="localPart" />
-			<property name="containsErrors" />
-			<property name="depth" />
-			<property name="referenceType" />
-		</component>
-		<list name="listContents" cascade="all" lazy="false">
-			<key column="id"/>
-			<list-index column="i" base="0" />
-			<composite-element
-				class="net.sf.taverna.t2.reference.impl.T2ReferenceImpl">
-				<!-- Explicit column mapping otherwise we collide with the implicit -->
-				<!-- mapping used in the key columns. Oh the joys of composites.. -->
-				<property name="namespacePart" column="c_namespace" />
-				<property name="localPart" column="c_local" />
-				<property name="containsErrors" column="c_errors" />
-				<property name="depth" column="c_depth" />
-				<property name="referenceType" column="c_type" />
-			</composite-element>
-		</list>
-	</class>
-</hibernate-mapping>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/ErrorDocumentImpl.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/ErrorDocumentImpl.hbm.xml b/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/ErrorDocumentImpl.hbm.xml
new file mode 100644
index 0000000..54b3532
--- /dev/null
+++ b/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/ErrorDocumentImpl.hbm.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Hibernate mapping for ErrorDocumentImpl -->
+<hibernate-mapping>
+  <class abstract="false" name="org.apache.taverna.reference.impl.ErrorDocumentImpl">
+    <id column="id" name="internalId" type="string"/>
+    <!--  Composite key constructed from the namespace and local -->
+    <!--  parts of the T2Reference implementation type           -->
+    <component class="org.apache.taverna.reference.impl.T2ReferenceImpl" name="typedId">
+      <property name="namespacePart"/>
+      <property name="localPart"/>
+      <property name="containsErrors"/>
+      <property name="depth"/>
+      <property name="referenceType"/>
+    </component>
+    <property length="10000" name="message"/>
+    <property length="10000" name="exceptionMessage"/>
+    <list cascade="all" lazy="false" name="stackTraceList">
+      <key column="id" not-null="true"/>
+      <list-index base="0" column="i"/>
+      <composite-element class="org.apache.taverna.reference.impl.StackTraceElementBeanImpl">
+        <property name="fileName"/>
+        <property name="className"/>
+        <property name="methodName"/>
+        <property name="lineNumber"/>
+      </composite-element>
+    </list>
+    <set cascade="all" lazy="false" name="errorReferenceSet">
+      <key column="id" not-null="true"/>
+      <composite-element class="org.apache.taverna.reference.impl.T2ReferenceImpl">
+        <property name="namespacePart"/>
+        <property name="localPart"/>
+        <property name="containsErrors"/>
+        <property name="depth"/>
+        <property name="referenceType"/>
+      </composite-element>
+    </set>
+  </class>
+</hibernate-mapping>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/ReferenceSetImpl.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/ReferenceSetImpl.hbm.xml b/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/ReferenceSetImpl.hbm.xml
new file mode 100644
index 0000000..b8c7e9a
--- /dev/null
+++ b/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/ReferenceSetImpl.hbm.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Hibernate mapping for ReferenceSetImpl -->
+<hibernate-mapping>
+  <class abstract="false" lazy="false" name="org.apache.taverna.reference.impl.ReferenceSetImpl">
+    <id column="id" name="internalId" type="string" unsaved-value="null"/>
+    <!--  Composite key constructed from the namespace and local -->
+    <!--  parts of the T2Reference implementation type, used as  -->
+    <!--  the foreign key in the one to many relationship with   -->
+    <!--  extensions of AbstractExternalReference                -->
+    <component class="org.apache.taverna.reference.impl.T2ReferenceImpl" name="typedId">
+      <property name="namespacePart"/>
+      <property name="localPart"/>
+      <property name="containsErrors"/>
+      <property name="depth"/>
+      <property name="referenceType"/>
+    </component>
+    <set cascade="all" lazy="false" name="externalReferences">
+      <key column="id"/>
+      <one-to-many class="org.apache.taverna.reference.AbstractExternalReference"/>
+    </set>
+    <property name="approximateSizeInBytes"/>
+  </class>
+</hibernate-mapping>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/T2ReferenceListImpl.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/T2ReferenceListImpl.hbm.xml b/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/T2ReferenceListImpl.hbm.xml
new file mode 100644
index 0000000..7d980e9
--- /dev/null
+++ b/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/T2ReferenceListImpl.hbm.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Hibernate mapping for T2ReferenceListImpl, used by HibernateListDao -->
+<hibernate-mapping>
+  <class abstract="false" name="org.apache.taverna.reference.impl.T2ReferenceListImpl">
+    <id column="id" name="internalId" type="string"/>
+    <!--  Composite key constructed from the namespace and local -->
+    <!--  parts of the T2Reference implementation type, used as  -->
+    <!--  the foreign key in the one to many relationship with   -->
+    <!--  extensions of AbstractExternalReference                -->
+    <component class="org.apache.taverna.reference.impl.T2ReferenceImpl" name="typedId">
+      <property name="namespacePart"/>
+      <property name="localPart"/>
+      <property name="containsErrors"/>
+      <property name="depth"/>
+      <property name="referenceType"/>
+    </component>
+    <list cascade="all" lazy="false" name="listContents">
+      <key column="id"/>
+      <list-index base="0" column="i"/>
+      <composite-element class="org.apache.taverna.reference.impl.T2ReferenceImpl">
+        <!-- Explicit column mapping otherwise we collide with the implicit -->
+        <!-- mapping used in the key columns. Oh the joys of composites.. -->
+        <property column="c_namespace" name="namespacePart"/>
+        <property column="c_local" name="localPart"/>
+        <property column="c_errors" name="containsErrors"/>
+        <property column="c_depth" name="depth"/>
+        <property column="c_type" name="referenceType"/>
+      </composite-element>
+    </list>
+  </class>
+</hibernate-mapping>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/net/sf/taverna/platform/spring/jdbc/TemporaryJDBCTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/platform/spring/jdbc/TemporaryJDBCTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/platform/spring/jdbc/TemporaryJDBCTest.java
deleted file mode 100644
index 449f2b6..0000000
--- a/taverna-reference-impl/src/test/java/net/sf/taverna/platform/spring/jdbc/TemporaryJDBCTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.platform.spring.jdbc;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-
-import org.junit.Test;
-
-/**
- * Test {@link TemporaryJDBC}
- * 
- * @author Stian Soiland-Reyes
- *
- */
-public class TemporaryJDBCTest {
-
-	private static final String DB = ".db";
-	private static final String T2PLATFORM = "t2platform-";
-	private static final String CREATE_TRUE = ";create=true";
-	private static final String JDBC_DERBY = "jdbc:derby:";
-
-	@Test
-	public void getDerby() throws Exception {
-		TemporaryJDBC temporaryJDBC = new TemporaryJDBC();
-		String jdbcURL = temporaryJDBC.getTemporaryDerbyJDBC();
-		assertTrue("Not a Derby URL", jdbcURL.startsWith(JDBC_DERBY));
-		String url = jdbcURL.split(JDBC_DERBY)[1];
-		assertTrue("Did not end with " + CREATE_TRUE, url.endsWith(CREATE_TRUE));
-		String location = url.split(CREATE_TRUE)[0];
-		assertFalse("Location was an empty string", location.equals(""));
-		File locationFile = new File(location);
-		assertFalse("File already exists: " + locationFile, locationFile.exists());
-		File parentFile = locationFile.getParentFile();
-		assertTrue("Parent directory did not exist", parentFile.isDirectory());
-		assertTrue("Did not end with " + T2PLATFORM, parentFile.getName().startsWith(T2PLATFORM));
-		assertTrue("Did not start with " + DB , parentFile.getName().endsWith(DB));
-	}
-	
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/AppContextSetup.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/AppContextSetup.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/AppContextSetup.java
deleted file mode 100644
index 62b6427..0000000
--- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/AppContextSetup.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package net.sf.taverna.t2.reference.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public class AppContextSetup {
-	public static List<ApplicationContext> contextList;
-
-	public static void setup() throws Exception {
-		if (contextList == null){
-			
-			contextList = new ArrayList<ApplicationContext>();
-			//Add all three contexts for storing referenced data
-			contextList = new ArrayList<ApplicationContext>();
-			ApplicationContext context = null;
-			context = new ClassPathXmlApplicationContext(
-					"vanillaHibernateAppContext.xml"); // hibernate context
-			contextList.add(context);
-			context = new ClassPathXmlApplicationContext(
-			"vanillaInMemoryAppContext.xml");
-			contextList.add(context); // in memory
-			context = new ClassPathXmlApplicationContext(
-			"vanillaHibernateTransactionalAppContext.xml");
-			contextList.add(context);	 // transactional hibernate context
-			
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/DatabaseSetupTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/DatabaseSetupTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/DatabaseSetupTest.java
deleted file mode 100644
index 24f1ce9..0000000
--- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/DatabaseSetupTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import java.util.HashSet;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ListDao;
-import net.sf.taverna.t2.reference.ReferenceSet;
-import net.sf.taverna.t2.reference.ReferenceSetDao;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.T2ReferenceType;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.context.ApplicationContext;
-
-/**
- * Tests initialization of the Derby database and Hibernate ORM system
- * 
- * @author Tom Oinn
- */
-public class DatabaseSetupTest {
-
-	@Before
-	public void setup() throws Exception {
-		AppContextSetup.setup();
-	}
-	
-	
-	@Test
-	public void testListStorage() {
-			ApplicationContext context = AppContextSetup.contextList.get(0); // Hibernate context
-			ListDao o = (ListDao) context.getBean("testListDao");
-			T2ReferenceImpl listReference = new T2ReferenceImpl();
-			listReference.setContainsErrors(false);
-			listReference.setDepth(1);
-			listReference.setLocalPart("list1");
-			listReference.setNamespacePart("testNamespace");
-			listReference.setReferenceType(T2ReferenceType.IdentifiedList);
-
-			T2ReferenceListImpl l = new T2ReferenceListImpl();
-
-			T2ReferenceImpl itemId1 = new T2ReferenceImpl();
-			itemId1.setNamespacePart("testNamespace");
-			itemId1.setLocalPart("item1");
-			T2ReferenceImpl itemId2 = new T2ReferenceImpl();
-			itemId2.setNamespacePart("testNamespace");
-			itemId2.setLocalPart("item2");
-
-			l.add(itemId1);
-			l.add(itemId2);
-
-			l.setTypedId(listReference);
-
-			System.out.println(l);
-
-			o.store(l);
-
-			T2ReferenceImpl listReference2 = new T2ReferenceImpl();
-			listReference2.setContainsErrors(false);
-			listReference2.setDepth(1);
-			listReference2.setLocalPart("list1");
-			listReference2.setNamespacePart("testNamespace");
-			listReference2.setReferenceType(T2ReferenceType.IdentifiedList);
-
-			System.out.println(o.get(listReference2));
-
-	}
-
-	@SuppressWarnings("serial")
-	@Test
-	public void testDatabaseReadWriteWithoutPlugins() {
-			ApplicationContext context = AppContextSetup.contextList.get(0); // Hibernate context
-			ReferenceSetDao o = (ReferenceSetDao) context
-					.getBean("testDao");
-			T2ReferenceImpl id = new T2ReferenceImpl();
-			id.setNamespacePart("testNamespace");
-			id.setLocalPart("testLocal");
-			ReferenceSetImpl rs = new ReferenceSetImpl(
-					new HashSet<ExternalReferenceSPI>(), id);
-			o.store(rs);
-			
-			
-			// Retrieve with a new instance of an anonymous subclass of
-			// ReferenceSetT2ReferenceImpl, just to check that hibernate can cope
-			// with this. It can, but this *must* be a subclass of the registered
-			// component type, which means we need to modify the component type to
-			// be the fully generic T2Reference with all fields accessed via
-			// properties.
-			T2Reference newReference = new T2ReferenceImpl() {
-
-				@Override
-				public boolean containsErrors() {
-					return false;
-				}
-
-				@Override
-				public int getDepth() {
-					return 0;
-				}
-
-				@Override
-				public String getLocalPart() {
-					return "testLocal";
-				}
-
-				@Override
-				public String getNamespacePart() {
-					return "testNamespace";
-				}
-
-			};
-
-			
-			ReferenceSet returnedset = o.get(newReference);
-			Assert.assertNotNull(returnedset.getId());	
-
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentDaoTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentDaoTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentDaoTest.java
deleted file mode 100644
index d5d47af..0000000
--- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentDaoTest.java
+++ /dev/null
@@ -1,151 +0,0 @@
-package net.sf.taverna.t2.reference.impl;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import net.sf.taverna.t2.reference.ErrorDocumentDao;
-import net.sf.taverna.t2.reference.T2ReferenceType;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.context.ApplicationContext;
-
-public class ErrorDocumentDaoTest {
-	
-	@Before
-	public void setup() throws Exception {
-		AppContextSetup.setup();
-	}
-	
-	@Test
-	public void testStore() throws Exception {
-		for (ApplicationContext context : AppContextSetup.contextList){
-			
-			ErrorDocumentDao dao = (ErrorDocumentDao) context.getBean("testErrorDao");
-			ErrorDocumentImpl doc = new ErrorDocumentImpl();
-			T2ReferenceImpl id = new T2ReferenceImpl();
-			id.setReferenceType(T2ReferenceType.ErrorDocument);
-			id.setDepth(0);
-			id.setContainsErrors(true);
-			id.setNamespacePart("testNamespace0");		
-			id.setLocalPart("testLocal0");
-			
-			doc.setExceptionMessage("An exception");		
-			
-			T2ReferenceImpl typedId = T2ReferenceImpl.getAsImpl(id);
-			
-			doc.setTypedId(typedId);
-			
-			dao.store(doc);
-			assertNotNull(dao.get(id));	
-		}
-	}
-	
-	/**
-	 * Tests that .get returns null when its missing, rather than throw an exception
-	 */
-	@Test
-	public void getMissingItemReturnsNull() {
-		for (ApplicationContext context : AppContextSetup.contextList){
-			ErrorDocumentDao dao = (ErrorDocumentDao) context.getBean("testErrorDao");
-			ErrorDocumentImpl doc = new ErrorDocumentImpl();
-			T2ReferenceImpl id = new T2ReferenceImpl();
-			id.setReferenceType(T2ReferenceType.ErrorDocument);
-			id.setDepth(0);
-			id.setContainsErrors(true);
-			id.setNamespacePart("testNamespace1");		
-			id.setLocalPart("testLocal1");
-			
-			doc.setExceptionMessage("An exception");		
-			
-			T2ReferenceImpl typedId = T2ReferenceImpl.getAsImpl(id);
-			
-			doc.setTypedId(typedId);
-			assertNull(dao.get(id));	
-		}
-	}
-	
-	@Test
-	public void testDelete() throws Exception {
-		for (ApplicationContext context : AppContextSetup.contextList){
-			
-			ErrorDocumentDao dao = (ErrorDocumentDao) context.getBean("testErrorDao");
-			ErrorDocumentImpl doc = new ErrorDocumentImpl();
-			T2ReferenceImpl id = new T2ReferenceImpl();
-			id.setReferenceType(T2ReferenceType.ErrorDocument);
-			id.setDepth(0);
-			id.setContainsErrors(true);
-			id.setNamespacePart("testNamespace2");		
-			id.setLocalPart("testLocal2");
-			
-			doc.setExceptionMessage("An exception");		
-			
-			T2ReferenceImpl typedId = T2ReferenceImpl.getAsImpl(id);
-			
-			doc.setTypedId(typedId);
-			
-			dao.store(doc);
-			assertNotNull(dao.get(id));
-			
-			assertTrue(dao.delete(doc));		
-			assertNull(dao.get(id));	
-		}
-
-	}
-
-	@Test
-	public void testDeleteErrorDocumentsForWFRun() throws Exception {
-		for (ApplicationContext context : AppContextSetup.contextList){
-			
-			ErrorDocumentDao dao = (ErrorDocumentDao) context.getBean("testErrorDao");
-			
-			ErrorDocumentImpl doc1 = new ErrorDocumentImpl();	
-			T2ReferenceImpl id1 = new T2ReferenceImpl();
-			id1.setReferenceType(T2ReferenceType.ErrorDocument);
-			id1.setDepth(0);
-			id1.setContainsErrors(true);
-			id1.setNamespacePart("wfRunErrorDocTest1");		
-			id1.setLocalPart("testLocal1");		
-			doc1.setExceptionMessage("An exception 1");			
-			T2ReferenceImpl typedId1 = T2ReferenceImpl.getAsImpl(id1);		
-			doc1.setTypedId(typedId1);	
-			dao.store(doc1);
-			assertNotNull(dao.get(id1));
-			
-			ErrorDocumentImpl doc2 = new ErrorDocumentImpl();	
-			T2ReferenceImpl id2 = new T2ReferenceImpl();
-			id2.setReferenceType(T2ReferenceType.ErrorDocument);
-			id2.setDepth(0);
-			id2.setContainsErrors(true);
-			id2.setNamespacePart("wfRunErrorDocTest1");		
-			id2.setLocalPart("testLocal2");		
-			doc2.setExceptionMessage("An exception 2");			
-			T2ReferenceImpl typedId2 = T2ReferenceImpl.getAsImpl(id2);		
-			doc2.setTypedId(typedId2);	
-			dao.store(doc2);
-			assertNotNull(dao.get(id2));
-			
-			ErrorDocumentImpl doc3 = new ErrorDocumentImpl();	
-			T2ReferenceImpl id3 = new T2ReferenceImpl();
-			id3.setReferenceType(T2ReferenceType.ErrorDocument);
-			id3.setDepth(0);
-			id3.setContainsErrors(true);
-			id3.setNamespacePart("wfRunErrorDocTest2");		
-			id3.setLocalPart("testLocal3");		
-			doc3.setExceptionMessage("An exception 3");			
-			T2ReferenceImpl typedId3 = T2ReferenceImpl.getAsImpl(id3);		
-			doc3.setTypedId(typedId3);	
-			dao.store(doc3);
-			assertNotNull(dao.get(id3));
-			
-			dao.deleteErrorDocumentsForWFRun("wfRunErrorDocTest1");
-			
-			assertNull(dao.get(id1));			
-			assertNull(dao.get(id2));
-			assertNotNull(dao.get(id3));	
-		}
-
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentServiceTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentServiceTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentServiceTest.java
deleted file mode 100644
index e035922..0000000
--- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentServiceTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package net.sf.taverna.t2.reference.impl;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sf.taverna.t2.reference.ErrorDocument;
-import net.sf.taverna.t2.reference.ErrorDocumentDao;
-import net.sf.taverna.t2.reference.WorkflowRunIdEntity;
-
-import org.junit.Before;
-import org.junit.Test;
-
-public class ErrorDocumentServiceTest {
-	
-	private List<ErrorDocumentServiceImpl> serviceList = new ArrayList<ErrorDocumentServiceImpl>();
-	
-	@Before
-	public void setup() throws Exception {
-		
-		AppContextSetup.setup();
-		
-		ErrorDocumentServiceImpl service = null;
-
-			service = new ErrorDocumentServiceImpl();
-			service.setErrorDao((ErrorDocumentDao)AppContextSetup.contextList.get(0).getBean("testErrorDao")); // hiberate
-			service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
-			serviceList.add(service);	
-		
-			service = new ErrorDocumentServiceImpl();
-			service.setErrorDao((ErrorDocumentDao)AppContextSetup.contextList.get(1).getBean("testErrorDao")); // in memory
-			service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
-			serviceList.add(service);
-		
-			service = new ErrorDocumentServiceImpl();
-			service.setErrorDao((ErrorDocumentDao)AppContextSetup.contextList.get(2).getBean("testErrorDao")); // transactional hibernate
-			service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
-			serviceList.add(service);
-				
-	}
-	
-	@Test
-	public void testDelete() throws Exception {
-		ReferenceContextImpl invocationContext = new ReferenceContextImpl();
-		invocationContext.addEntity(new WorkflowRunIdEntity("wfRunErrorDocTest"));
-		for (ErrorDocumentServiceImpl service : serviceList){
-			ErrorDocument doc = service.registerError("Fred", 0, invocationContext);
-			assertNotNull(service.getError(doc.getId()));
-			assertTrue(service.delete(doc.getId()));
-			assertNull(service.getError(doc.getId()));
-			assertFalse(service.delete(doc.getId()));
-		}
-	}
-
-	@Test
-	public void testDeleteErrorDocumentsForWFRun() throws Exception {
-
-		for (ErrorDocumentServiceImpl service : serviceList){
-			
-			String wfRunId1 = "wfRunErrorDocTest1";
-			ReferenceContextImpl invocationContext1 = new ReferenceContextImpl();
-			invocationContext1.addEntity(new WorkflowRunIdEntity(wfRunId1));
-			
-			String wfRunId2 = "wfRunErrorDocTest2";
-			ReferenceContextImpl invocationContext2 = new ReferenceContextImpl();
-			invocationContext2.addEntity(new WorkflowRunIdEntity(wfRunId2));
-			
-			ErrorDocument doc1 = service.registerError("Fred1", 0, invocationContext1);
-			ErrorDocument doc2 = service.registerError("Fred2", 0, invocationContext1);
-			ErrorDocument doc3 = service.registerError("Fred3", 0, invocationContext2);
-
-			assertNotNull(service.getError(doc1.getId()));
-			assertNotNull(service.getError(doc2.getId()));
-			assertNotNull(service.getError(doc3.getId()));
-
-			service.deleteErrorDocumentsForWorkflowRun(wfRunId1);
-			
-			assertNull(service.getError(doc1.getId()));
-			assertNull(service.getError(doc2.getId()));
-			assertNotNull(service.getError(doc3.getId()));
-
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListDaoTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListDaoTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListDaoTest.java
deleted file mode 100644
index a39d353..0000000
--- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListDaoTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package net.sf.taverna.t2.reference.impl;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import net.sf.taverna.t2.reference.ListDao;
-import net.sf.taverna.t2.reference.T2ReferenceType;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.context.ApplicationContext;
-
-public class ListDaoTest {
-	
-	@Before
-	public void setup() throws Exception {
-		AppContextSetup.setup();
-	}
-	
-	@Test
-	public void testStore() throws Exception {
-		for (ApplicationContext context : AppContextSetup.contextList){
-			ListDao dao = (ListDao)context.getBean("testListDao");
-			T2ReferenceImpl r = new T2ReferenceImpl();
-			r.setNamespacePart("testNamespace0");
-			r.setLocalPart("testLocal0");
-			r.setReferenceType(T2ReferenceType.IdentifiedList);
-			r.setDepth(0);
-			r.setContainsErrors(false);
-			T2ReferenceListImpl newList = new T2ReferenceListImpl();
-			newList.setTypedId(r);
-			dao.store(newList);
-			assertNotNull(dao.get(r));	
-		}	
-	}
-	
-	/**
-	 * Tests that .get returns null when its missing, rather than throw an exception
-	 */
-	@Test
-	public void getMissingItemReturnsNull() {
-		for (ApplicationContext context : AppContextSetup.contextList){
-			ListDao dao = (ListDao)context.getBean("testListDao");
-			T2ReferenceImpl r = new T2ReferenceImpl();
-			r.setNamespacePart("testNamespace1");
-			r.setLocalPart("testLocal1");
-			r.setReferenceType(T2ReferenceType.IdentifiedList);
-			r.setDepth(0);
-			r.setContainsErrors(false);
-			T2ReferenceListImpl newList = new T2ReferenceListImpl();
-			newList.setTypedId(r);
-			assertNull(dao.get(r));
-		}
-	}
-	
-	@Test
-	public void testDelete() throws Exception {
-		for (ApplicationContext context : AppContextSetup.contextList){
-			ListDao dao = (ListDao)context.getBean("testListDao");
-			T2ReferenceImpl r = new T2ReferenceImpl();
-			r.setNamespacePart("testNamespace2");
-			r.setLocalPart("testLocal2");
-			r.setReferenceType(T2ReferenceType.IdentifiedList);
-			r.setDepth(0);
-			r.setContainsErrors(false);
-			T2ReferenceListImpl newList = new T2ReferenceListImpl();
-			newList.setTypedId(r);
-			dao.store(newList);
-			assertNotNull(dao.get(r));	
-			assertTrue(dao.delete(newList));
-			assertNull(dao.get(r));	
-		}	
-	}
-
-	@Test
-	public void testIdentifiedListsForWFRun() throws Exception {
-		for (ApplicationContext context : AppContextSetup.contextList){
-			ListDao dao = (ListDao)context.getBean("testListDao");
-			
-			T2ReferenceImpl r1 = new T2ReferenceImpl();
-			r1.setReferenceType(T2ReferenceType.IdentifiedList);
-			r1.setDepth(0);
-			r1.setContainsErrors(true);
-			r1.setNamespacePart("wfRunListsTest1");		
-			r1.setLocalPart("testLocal1");		
-			T2ReferenceListImpl list1 = new T2ReferenceListImpl();		
-			list1.setTypedId(r1);	
-			dao.store(list1);
-			assertNotNull(dao.get(r1));
-			
-			T2ReferenceImpl r2 = new T2ReferenceImpl();
-			r2.setReferenceType(T2ReferenceType.IdentifiedList);
-			r2.setDepth(1);
-			r2.setContainsErrors(true);
-			r2.setNamespacePart("wfRunListsTest1");		
-			r2.setLocalPart("testLocal2");		
-			T2ReferenceListImpl list2 = new T2ReferenceListImpl();		
-			list2.setTypedId(r2);	
-			dao.store(list2);
-			assertNotNull(dao.get(r2));
-			
-			T2ReferenceImpl r3 = new T2ReferenceImpl();
-			r3.setReferenceType(T2ReferenceType.IdentifiedList);
-			r3.setDepth(0);
-			r3.setContainsErrors(true);
-			r3.setNamespacePart("wfRunListsTest2");		
-			r3.setLocalPart("testLocal3");		
-			T2ReferenceListImpl list3 = new T2ReferenceListImpl();		
-			list3.setTypedId(r3);	
-			dao.store(list3);
-			assertNotNull(dao.get(r3));
-			
-			dao.deleteIdentifiedListsForWFRun("wfRunListsTest1");
-			
-			assertNull(dao.get(r1));			
-			assertNull(dao.get(r2));
-			assertNotNull(dao.get(r3));	
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListServiceTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListServiceTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListServiceTest.java
deleted file mode 100644
index 062337a..0000000
--- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListServiceTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package net.sf.taverna.t2.reference.impl;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sf.taverna.t2.reference.IdentifiedList;
-import net.sf.taverna.t2.reference.ListDao;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.WorkflowRunIdEntity;
-
-import org.junit.Before;
-import org.junit.Test;
-
-public class ListServiceTest {
-	
-	private List<ListServiceImpl> serviceList = new ArrayList<ListServiceImpl>();
-
-	@Before
-	public void setup() throws Exception {
-		
-		AppContextSetup.setup();
-		
-		ListServiceImpl service = null;
-		
-			service = new ListServiceImpl();
-			service.setListDao((ListDao)AppContextSetup.contextList.get(0).getBean("testListDao")); // hibernate
-			service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());	
-			serviceList.add(service);
-		
-			service = new ListServiceImpl();
-			service.setListDao((ListDao)AppContextSetup.contextList.get(1).getBean("testListDao")); // in memory
-			service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());	
-			serviceList.add(service);
-
-		
-			service = new ListServiceImpl();
-			service.setListDao((ListDao)AppContextSetup.contextList.get(2).getBean("testListDao")); // transactional hibernate
-			service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());	
-			serviceList.add(service);
-		
-	}
-	
-	@Test
-	public void testDelete() throws Exception {
-		ReferenceContextImpl invocationContext = new ReferenceContextImpl();
-		invocationContext.addEntity(new WorkflowRunIdEntity("wfRunListsTest"));
-		for (ListServiceImpl service : serviceList){
-			IdentifiedList<T2Reference> list =service.registerEmptyList(1, invocationContext);
-			assertNotNull(service.getList(list.getId()));
-			assertTrue(service.delete(list.getId()));
-			assertNull(service.getList(list.getId()));
-			assertFalse(service.delete(list.getId()));
-		}
-	}
-	
-	@Test
-	public void testDeleteIdentifiedListsForWFRun() throws Exception {
-
-		for (ListServiceImpl service : serviceList){
-			
-			String wfRunId1 = "wfRunListsTest1";
-			ReferenceContextImpl invocationContext1 = new ReferenceContextImpl();
-			invocationContext1.addEntity(new WorkflowRunIdEntity(wfRunId1));
-			
-			String wfRunId2 = "wfRunListsTest2";
-			ReferenceContextImpl invocationContext2 = new ReferenceContextImpl();
-			invocationContext2.addEntity(new WorkflowRunIdEntity(wfRunId2));
-			
-			IdentifiedList<T2Reference> list1 = service.registerEmptyList(2, invocationContext1);
-			IdentifiedList<T2Reference> list2 = service.registerEmptyList(1, invocationContext1);
-			IdentifiedList<T2Reference> list3 = service.registerEmptyList(1, invocationContext2);
-
-			assertNotNull(service.getList(list1.getId()));
-			assertNotNull(service.getList(list2.getId()));
-			assertNotNull(service.getList(list3.getId()));
-
-			service.deleteIdentifiedListsForWorkflowRun(wfRunId1);
-			
-			assertNull(service.getList(list1.getId()));
-			assertNull(service.getList(list2.getId()));
-			assertNotNull(service.getList(list3.getId()));
-
-		}
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceContextImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceContextImpl.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceContextImpl.java
deleted file mode 100644
index a898d27..0000000
--- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceContextImpl.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package net.sf.taverna.t2.reference.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sf.taverna.t2.reference.ReferenceContext;
-
-class ReferenceContextImpl implements ReferenceContext{
-	private List<Object> entities;
-
-	public ReferenceContextImpl(){
-		entities = new ArrayList<Object>();
-	}
-	
-	@Override
-	public <T> List<T> getEntities(Class<T> entityType) {
-		List<T> entitiesOfType = new ArrayList<T>();
-		for (Object entity : entities){
-			if (entityType.isInstance(entity)){
-				entitiesOfType.add(entityType.cast(entity));
-			}
-		}
-		return entitiesOfType;
-	}
-
-	@Override
-	public void addEntity(Object entity){
-		entities.add(entity);
-	}
-};

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceSetDaoTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceSetDaoTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceSetDaoTest.java
deleted file mode 100644
index f453cca..0000000
--- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceSetDaoTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package net.sf.taverna.t2.reference.impl;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.HashSet;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceSetDao;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.context.ApplicationContext;
-
-public class ReferenceSetDaoTest {
-
-	@Before
-	public void setup() throws Exception {
-
-		AppContextSetup.setup();
-	}
-
-	@Test
-	public void testStore() throws Exception {
-		for (ApplicationContext context : AppContextSetup.contextList){
-			ReferenceSetDao dao = (ReferenceSetDao) context.getBean("testDao");
-			T2ReferenceImpl id = new T2ReferenceImpl();
-			id.setNamespacePart("testNamespace0");		
-			id.setLocalPart("testLocal0");
-			ReferenceSetImpl rs = new ReferenceSetImpl(
-					new HashSet<ExternalReferenceSPI>(), id);
-			dao.store(rs);
-			assertNotNull(dao.get(id));
-		}
-	}
-	
-	@Test
-	public void testDelete() throws Exception {
-		for (ApplicationContext context : AppContextSetup.contextList){
-			ReferenceSetDao dao = (ReferenceSetDao) context.getBean("testDao");
-			T2ReferenceImpl id = new T2ReferenceImpl();
-			id.setNamespacePart("testNamespace1");
-			id.setLocalPart("testLocal1");
-			ReferenceSetImpl rs = new ReferenceSetImpl(
-					new HashSet<ExternalReferenceSPI>(), id);		
-			dao.store(rs);
-			assertNotNull(dao.get(id));
-			assertTrue(dao.delete(rs));
-			assertNull(dao.get(id));
-		}
-	}
-	
-	@Test
-	public void testDeleteRerefenceSetsForWFRun() throws Exception {
-		for (ApplicationContext context : AppContextSetup.contextList){
-			ReferenceSetDao dao = (ReferenceSetDao) context.getBean("testDao");
-			
-			T2ReferenceImpl id1 = new T2ReferenceImpl();
-			id1.setNamespacePart("wfRunRefSetTest1");
-			id1.setLocalPart("testLocal1");
-			ReferenceSetImpl rs1 = new ReferenceSetImpl(
-					new HashSet<ExternalReferenceSPI>(), id1);		
-			dao.store(rs1);
-			assertNotNull(dao.get(id1));
-			
-			T2ReferenceImpl id2 = new T2ReferenceImpl();
-			id2.setNamespacePart("wfRunRefSetTest1");
-			id2.setLocalPart("testLocal2");
-			ReferenceSetImpl rs2 = new ReferenceSetImpl(
-					new HashSet<ExternalReferenceSPI>(), id2);		
-			dao.store(rs2);
-			assertNotNull(dao.get(id2));
-			
-			T2ReferenceImpl id3 = new T2ReferenceImpl();
-			id3.setNamespacePart("wfRunRefSetTest2");
-			id3.setLocalPart("testLocal3");
-			ReferenceSetImpl rs3 = new ReferenceSetImpl(
-					new HashSet<ExternalReferenceSPI>(), id3);		
-			dao.store(rs3);
-			assertNotNull(dao.get(id3));
-			
-			dao.deleteReferenceSetsForWFRun("wfRunRefSetTest1");
-			
-			assertNull(dao.get(id1));			
-			assertNull(dao.get(id2));
-			assertNotNull(dao.get(id3));	
-		}
-	}
-	
-	/**
-	 * Tests that .get returns null when its missing, rather than throw an exception
-	 */
-	@Test
-	public void getMissingItemReturnsNull() {
-		for (ApplicationContext context : AppContextSetup.contextList){
-			ReferenceSetDao dao = (ReferenceSetDao) context.getBean("testDao");
-			T2ReferenceImpl id = new T2ReferenceImpl();
-			id.setNamespacePart("testNamespace2");		
-			id.setLocalPart("testLocal2");
-			assertNull(dao.get(id));
-		}
-	}
-		
-}


[19/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchMessageType.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchMessageType.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchMessageType.java
deleted file mode 100644
index ca44bf2..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/DispatchMessageType.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.description;
-
-/**
- * Enumeration of the possible message types passed between layers of the
- * dispatch stack.
- * 
- * @author Tom Oinn
- */
-public enum DispatchMessageType {
-	/**
-	 * A reference to a queue of Job objects waiting to be used as input along
-	 * with a list of activities to process them.
-	 */
-	JOB_QUEUE,
-
-	/**
-	 * A Job object and list of activities to be used to process the data in the
-	 * Job. The Job will have been previously extracted from the JobQueue
-	 */
-	JOB,
-
-	/**
-	 * A Job object containing the result of a single activity invocation.
-	 */
-	RESULT,
-
-	/**
-	 * A (possibly partial) completion event from the layer below. This is only
-	 * going to be used when the activity invocation is capable of streaming
-	 * partial data back up through the dispatch stack before the activity has
-	 * completed. Not all dispatch stack layers are compatible with this mode of
-	 * operation, for example retry and recursion do not play well here!
-	 */
-	RESULT_COMPLETION,
-
-	/**
-	 * A failure message sent by the layer below to denote some kind of failure
-	 * (surprisingly)
-	 */
-	ERROR;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/ReactionTo.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/ReactionTo.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/ReactionTo.java
deleted file mode 100644
index 40600ac..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/ReactionTo.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.description;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Describes the type of message to which the various DispatchLayerFooReaction
- * classes are referring
- * 
- * @author Tom Oinn
- */
-@Documented
-@Target(ElementType.ANNOTATION_TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface ReactionTo {
-	public DispatchMessageType messageType();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/SupportsStreamedResult.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/SupportsStreamedResult.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/SupportsStreamedResult.java
deleted file mode 100644
index 87dc6fa..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/SupportsStreamedResult.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.description;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Declares that a dispatch layer can handle streamed result data correctly, if
- * this annotation is attached to a DispatchLayer implementation that
- * implementation must be able to correctly handle the result completion message
- * type. By default dispatch layers are assumed to not handle this message type.
- * 
- * @author Tom Oinn
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-@Documented
-public @interface SupportsStreamedResult {
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/package.html b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/package.html
deleted file mode 100644
index f0629bb..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/description/package.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<body>
-Annotations and enumerations used to describe dispatch layers, specifically the types of messages they can consume and their reactions to those messages.
-</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/AbstractDispatchEvent.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/AbstractDispatchEvent.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/AbstractDispatchEvent.java
deleted file mode 100644
index 3f8d011..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/AbstractDispatchEvent.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.events;
-
-import net.sf.taverna.t2.invocation.Event;
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchMessageType;
-
-/**
- * Superclass of events within the dispatch stack
- * 
- * @author Tom Oinn
- */
-public abstract class AbstractDispatchEvent<EventType extends AbstractDispatchEvent<EventType>>
-		extends Event<EventType> {
-	protected AbstractDispatchEvent(String owner, int[] index,
-			InvocationContext context) {
-		super(owner, index, context);
-	}
-
-	/**
-	 * Return the DispatchMessageType for this event object
-	 * 
-	 * @return instance of DispatchMessageType represented by this event
-	 */
-	public abstract DispatchMessageType getMessageType();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchCompletionEvent.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchCompletionEvent.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchCompletionEvent.java
deleted file mode 100644
index 6a57321..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchCompletionEvent.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.events;
-
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchMessageType.RESULT_COMPLETION;
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.invocation.ProcessIdentifierException;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchMessageType;
-
-/**
- * Dispatch event containing detailing a (potentially partial) completion of a
- * stream of streaming result events. Layers which do not support streaming by
- * definition can't cope with this event and the dispatch stack checker should
- * prevent them from ever seeing it.
- * 
- * @author Tom Oinn
- */
-public class DispatchCompletionEvent extends
-		AbstractDispatchEvent<DispatchCompletionEvent> {
-	/**
-	 * Construct a new dispatch result completion event
-	 * 
-	 * @param owner
-	 * @param index
-	 * @param context
-	 */
-	public DispatchCompletionEvent(String owner, int[] index,
-			InvocationContext context) {
-		super(owner, index, context);
-	}
-
-	@Override
-	public DispatchCompletionEvent popOwningProcess()
-			throws ProcessIdentifierException {
-		return new DispatchCompletionEvent(popOwner(), index, context);
-	}
-
-	@Override
-	public DispatchCompletionEvent pushOwningProcess(String localProcessName)
-			throws ProcessIdentifierException {
-		return new DispatchCompletionEvent(pushOwner(localProcessName), index,
-				context);
-	}
-
-	/**
-	 * DispatchMessageType.RESULT_COMPLETION
-	 */
-	@Override
-	public DispatchMessageType getMessageType() {
-		return RESULT_COMPLETION;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchErrorEvent.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchErrorEvent.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchErrorEvent.java
deleted file mode 100644
index d048040..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchErrorEvent.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.events;
-
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchMessageType.ERROR;
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.invocation.ProcessIdentifierException;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchMessageType;
-
-/**
- * Message within the dispatch stack representing a single error report. This
- * may then be handled by upstream layers to retry jobs etc. If it reaches the
- * top of the dispatch stack the behaviour is configurable but by default it
- * will abort that workflow instance, being treated as a catastrophic
- * unhandleable problem.
- * 
- * @author Tom Oinn
- */
-public class DispatchErrorEvent extends
-		AbstractDispatchEvent<DispatchErrorEvent> {
-	private Throwable cause;
-	private String message;
-	private DispatchErrorType failureType;
-	private Activity<?> failedActivity;
-
-	/**
-	 * Create a new error event
-	 * 
-	 * @param owningProcess
-	 * @param index
-	 * @param context
-	 * @param errorMessage
-	 * @param t
-	 */
-	public DispatchErrorEvent(String owningProcess, int[] index,
-			InvocationContext context, String errorMessage, Throwable t,
-			DispatchErrorType failureType, Activity<?> failedActivity) {
-		super(owningProcess, index, context);
-		this.message = errorMessage;
-		this.cause = t;
-		this.failureType = failureType;
-		this.failedActivity = failedActivity;
-	}
-
-	/**
-	 * Return the type of failure, this is used by upstream dispatch layers to
-	 * determine whether they can reasonably handle the error message
-	 */
-	public DispatchErrorType getFailureType() {
-		return this.failureType;
-	}
-
-	/**
-	 * Return the Activity instance which failed to produce this error message
-	 */
-	public Activity<?> getFailedActivity() {
-		return this.failedActivity;
-	}
-
-	/**
-	 * Return the throwable behind this error, or null if there was no exception
-	 * raised to create it.
-	 * 
-	 * @return
-	 */
-	public Throwable getCause() {
-		return this.cause;
-	}
-
-	/**
-	 * Return the textual message representing this error
-	 * 
-	 * @return
-	 */
-	public String getMessage() {
-		return this.message;
-	}
-
-	@Override
-	public DispatchErrorEvent popOwningProcess()
-			throws ProcessIdentifierException {
-		return new DispatchErrorEvent(popOwner(), index, context, message,
-				cause, failureType, failedActivity);
-	}
-
-	@Override
-	public DispatchErrorEvent pushOwningProcess(String localProcessName)
-			throws ProcessIdentifierException {
-		return new DispatchErrorEvent(pushOwner(localProcessName), index,
-				context, message, cause, failureType, failedActivity);
-	}
-
-	/**
-	 * @return Always a {@link DispatchMessageType#ERROR}
-	 */
-	@Override
-	public DispatchMessageType getMessageType() {
-		return ERROR;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchErrorType.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchErrorType.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchErrorType.java
deleted file mode 100644
index 226fd6f..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchErrorType.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.events;
-
-/**
- * A simple enumeration of possible failure classes, used to determine whether
- * fault handling dispatch layers should attempt to handle a given failure
- * message.
- * 
- * @author Tom Oinn
- */
-public enum DispatchErrorType {
-	/**
-	 * Indicates that the failure to invoke the activity was due to invalid
-	 * input data, in this case there is no point in trying to invoke the
-	 * activity again with the same data as it will always fail. Fault handling
-	 * layers such as retry should pass this error type through directly; layers
-	 * such as failover handlers should handle it as the input data may be
-	 * applicable to other activities within the processor.
-	 */
-	DATA,
-
-	/**
-	 * Indicates that the failure was related to the invocation of the resource
-	 * rather than the input data, and that an identical invocation at a later
-	 * time may succeed.
-	 */
-	INVOCATION,
-
-	/**
-	 * Indicates that the failure was due to missing or incorrect authentication
-	 * credentials and that retrying the activity invocation without modifying
-	 * the credential set is pointless.
-	 */
-	AUTHENTICATION;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchJobEvent.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchJobEvent.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchJobEvent.java
deleted file mode 100644
index ecf03c8..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchJobEvent.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.events;
-
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchMessageType.JOB;
-
-import java.util.List;
-import java.util.Map;
-
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.invocation.ProcessIdentifierException;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchMessageType;
-
-/**
- * An event within the dispatch stack containing a single job's worth of data
- * along with an ordered list of Activity instances.
- * 
- * @author Tom Oinn
- */
-public class DispatchJobEvent extends AbstractDispatchEvent<DispatchJobEvent> {
-	private Map<String, T2Reference> dataMap;
-	private List<? extends Activity<?>> activities;
-
-	/**
-	 * Create a new job event, specifying a complete set of input data and a
-	 * list of activities which could potentially consume this data
-	 * 
-	 * @param owningProcess
-	 * @param index
-	 * @param context
-	 * @param data
-	 * @param activities
-	 */
-	public DispatchJobEvent(String owningProcess, int[] index,
-			InvocationContext context, Map<String, T2Reference> data,
-			List<? extends Activity<?>> activities) {
-		super(owningProcess, index, context);
-		this.dataMap = data;
-		this.activities = activities;
-	}
-
-	/**
-	 * The actual data carried by this dispatch job event object is in the form
-	 * of a map, where the keys of the map are Strings identifying the named
-	 * input and the values are Strings containing valid data identifiers within
-	 * the context of a visible DataManager object (see CloudOne specification
-	 * for further information on the DataManager system)
-	 * 
-	 * @return Map of name to data reference for this Job
-	 */
-	public Map<String, T2Reference> getData() {
-		return this.dataMap;
-	}
-
-	/**
-	 * Returns a list of activity instances which can be applied to the data
-	 * contained by this job event.
-	 * 
-	 * @return ordered list of Activity instances
-	 */
-	public List<? extends Activity<?>> getActivities() {
-		return this.activities;
-	}
-
-	@Override
-	public DispatchJobEvent popOwningProcess()
-			throws ProcessIdentifierException {
-		return new DispatchJobEvent(popOwner(), index, context, dataMap,
-				activities);
-	}
-
-	@Override
-	public DispatchJobEvent pushOwningProcess(String localProcessName)
-			throws ProcessIdentifierException {
-		return new DispatchJobEvent(pushOwner(localProcessName), index,
-				context, dataMap, activities);
-	}
-
-	/**
-	 * @return Always a {@link DispatchMessageType#JOB}.
-	 */
-	@Override
-	public DispatchMessageType getMessageType() {
-		return JOB;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchJobQueueEvent.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchJobQueueEvent.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchJobQueueEvent.java
deleted file mode 100644
index d2d0461..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchJobQueueEvent.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.events;
-
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchMessageType.JOB_QUEUE;
-
-import java.util.List;
-import java.util.concurrent.BlockingQueue;
-
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.invocation.IterationInternalEvent;
-import net.sf.taverna.t2.invocation.ProcessIdentifierException;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchMessageType;
-
-/**
- * A message within the dispatch stack containing a single reference to the job
- * queue from the iteration system along with an ordered list of Activity
- * instances.
- * 
- * @author Tom Oinn
- */
-public class DispatchJobQueueEvent extends
-		AbstractDispatchEvent<DispatchJobQueueEvent> {
-	private BlockingQueue<IterationInternalEvent<? extends IterationInternalEvent<?>>> queue;
-	private List<? extends Activity<?>> activities;
-
-	/**
-	 * Create a new job queue event, specifying the queue of Completion and Job
-	 * objects and the list of activities which will be used to process the
-	 * corresponding dispatch events
-	 * 
-	 * @param owner
-	 * @param context
-	 * @param queue
-	 * @param activities
-	 */
-	public DispatchJobQueueEvent(
-			String owner,
-			InvocationContext context,
-			BlockingQueue<IterationInternalEvent<? extends IterationInternalEvent<?>>> queue,
-			List<? extends Activity<?>> activities) {
-		super(owner, new int[] {}, context);
-		this.queue = queue;
-		this.activities = activities;
-	}
-
-	public BlockingQueue<IterationInternalEvent<? extends IterationInternalEvent<?>>> getQueue() {
-		return this.queue;
-	}
-
-	public List<? extends Activity<?>> getActivities() {
-		return this.activities;
-	}
-
-	@Override
-	public DispatchJobQueueEvent popOwningProcess()
-			throws ProcessIdentifierException {
-		return new DispatchJobQueueEvent(popOwner(), context, queue, activities);
-	}
-
-	@Override
-	public DispatchJobQueueEvent pushOwningProcess(String localProcessName)
-			throws ProcessIdentifierException {
-		return new DispatchJobQueueEvent(pushOwner(localProcessName), context,
-				queue, activities);
-	}
-
-	/**
-	 * @return Always a {@link DispatchMessageType#JOB_QUEUE}.
-	 */
-	@Override
-	public DispatchMessageType getMessageType() {
-		return JOB_QUEUE;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchResultEvent.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchResultEvent.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchResultEvent.java
deleted file mode 100644
index 6e2c4b9..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/events/DispatchResultEvent.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.events;
-
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchMessageType.RESULT;
-
-import java.util.Map;
-
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.invocation.ProcessIdentifierException;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchMessageType;
-
-/**
- * Dispatch event containing the results from an invocation. If the event is
- * part of a stream of such events from a single job invocation the streaming
- * flag will be set to true - when set layers that do not support streaming
- * should either disable any related functionality or complain bitterly. They
- * should never see such an event as the type checker will in the future catch
- * such cases before they occur but for now it's something to watch for.
- * 
- * @author Tom Oinn
- */
-public class DispatchResultEvent extends
-		AbstractDispatchEvent<DispatchResultEvent> {
-	private Map<String, T2Reference> dataMap;
-	private boolean streaming;
-
-	/**
-	 * Construct a new dispatch result event, specifying the data and whether
-	 * the result is part of a stream of multiple results events from a single
-	 * invocation
-	 * 
-	 * @param owner
-	 * @param index
-	 * @param context
-	 * @param data
-	 * @param streaming
-	 */
-	public DispatchResultEvent(String owner, int[] index,
-			InvocationContext context, Map<String, T2Reference> data,
-			boolean streaming) {
-		super(owner, index, context);
-		this.dataMap = data;
-		this.streaming = streaming;
-	}
-
-	/**
-	 * If this result is part of a stream, that is to say multiple result events
-	 * from a single job event, then return true otherwise return false.
-	 * 
-	 * @return whether this is part of a streamed result set
-	 */
-	public boolean isStreamingEvent() {
-		return this.streaming;
-	}
-
-	/**
-	 * The result contains a map of named EntityIdentifier instances
-	 * corresponding to the result data.
-	 * 
-	 * @return the result data for this event
-	 */
-	public Map<String, T2Reference> getData() {
-		return this.dataMap;
-	}
-
-	@Override
-	public DispatchResultEvent popOwningProcess()
-			throws ProcessIdentifierException {
-		return new DispatchResultEvent(popOwner(), index, context, dataMap,
-				streaming);
-	}
-
-	@Override
-	public DispatchResultEvent pushOwningProcess(String localProcessName)
-			throws ProcessIdentifierException {
-		return new DispatchResultEvent(pushOwner(localProcessName), index,
-				context, dataMap, streaming);
-	}
-
-	/**
-	 * @return Always a {@link DispatchMessageType#RESULT}.
-	 */
-	@Override
-	public DispatchMessageType getMessageType() {
-		return RESULT;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/package.html b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/package.html
deleted file mode 100644
index d4dc0d4..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/package.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<body>
-Definition and support classes for the Dispatch Stack. Each processor in
-a workflow contains a stack of dispatch layers with each layer being
-responsible for a particular aspect of the invocation. At a high level
-the stack consumes a queue of events from the iteration system along
-with an initial set of service proxy objects and is repsonsible for
-taking jobs from the queue and matching them to appropriate invocation
-targets.
-<p>Taverna 1 has in effect a single hardcoded dispatch stack for
-each processor with little control over it aside from a few basic
-properties. To replicate the same behaviour within Taverna 2 there are
-dispatch layers for parallelism, retry, failover and invocation. As the
-dispatch layer is an extension point we or others can provide other
-aspects such as recursive invocation and dynamic (runtime) binding from
-abstract service proxies to concrete instances. The last is possible
-because the service list is passed through the stack along with the
-queue or individual job events and can be rewritten or filtered by
-dispatch layer implementations.
-</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/AbstractIterationStrategyNode.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/AbstractIterationStrategyNode.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/AbstractIterationStrategyNode.java
deleted file mode 100644
index 22eaf69..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/AbstractIterationStrategyNode.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.iteration;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Vector;
-
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.MutableTreeNode;
-import javax.swing.tree.TreeNode;
-
-import net.sf.taverna.t2.invocation.Completion;
-import net.sf.taverna.t2.workflowmodel.WorkflowStructureException;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Job;
-
-/**
- * Abstract superclass for implementations of IterationStrategyNode, adds logic
- * to connect nodes together and convenience methods to push jobs and completion
- * events up to the parent node.
- * 
- * @author Tom Oinn
- * @author Stian Soiland-Reyes
- */
-@SuppressWarnings("serial")
-public abstract class AbstractIterationStrategyNode extends
-		DefaultMutableTreeNode implements IterationStrategyNode {
-	private List<IterationStrategyNode> children = new ArrayList<>();
-	private IterationStrategyNode parent = null;
-
-	/**
-	 * Implement TreeNode
-	 */
-	@Override
-	public final synchronized Enumeration<IterationStrategyNode> children() {
-		return new Vector<>(children).elements(); // TODO arraylist?
-	}
-
-	/**
-	 * Clear the child list and parent of this node
-	 */
-	@Override
-	public final synchronized void clear() {
-		for (IterationStrategyNode child : children)
-			child.setParent(null);
-		children.clear();
-		this.parent = null;
-	}
-
-	/**
-	 * Implement TreeNode
-	 */
-	@Override
-	public boolean getAllowsChildren() {
-		return true;
-	}
-
-	/**
-	 * Implement TreeNode
-	 */
-	@Override
-	public final synchronized IterationStrategyNode getChildAt(int position) {
-		return children.get(position);
-	}
-
-	/**
-	 * Implement TreeNode
-	 */
-	@Override
-	public final int getChildCount() {
-		return children.size();
-	}
-
-	/**
-	 * Implements IterationStrategyNode
-	 */
-	@Override
-	public final synchronized List<IterationStrategyNode> getChildren() {
-		return new ArrayList<>(children);
-	}
-
-	/**
-	 * Implement TreeNode
-	 */
-	@Override
-	public final synchronized int getIndex(TreeNode node) {
-		return children.indexOf(node);
-	}
-
-	/**
-	 * Implement TreeNode
-	 */
-	@Override
-	public final IterationStrategyNode getParent() {
-		return parent;
-	}
-
-	@Override
-	public synchronized void insert(MutableTreeNode child) {
-		insert(child, getChildCount());
-	}
-
-	@Override
-	public synchronized void insert(MutableTreeNode child, int index) {
-		if (!getAllowsChildren())
-			throw new IllegalStateException("Node does not allow children");
-		if (!(child instanceof IterationStrategyNode))
-			throw new IllegalArgumentException(
-					"Child not an instance of IterationStrategyNode: " + child);
-		if (child == this)
-			throw new IllegalArgumentException("Can't be it's own parent");
-
-		// Check if it is already there (in case we'll just move it)
-		int alreadyExistsIndex = children.indexOf(child);
-
-		children.add(index, (IterationStrategyNode) child);
-
-		if (alreadyExistsIndex > -1) {
-			// Remove it from the old position
-			if (index < alreadyExistsIndex
-					&& alreadyExistsIndex + 1 < children.size())
-				alreadyExistsIndex++;
-			children.remove(alreadyExistsIndex);
-		}
-		if (child.getParent() != this)
-			child.setParent(this);
-	}
-
-	/**
-	 * Implement TreeNode
-	 */
-	@Override
-	public boolean isLeaf() {
-		return children.isEmpty();
-	}
-
-	@Override
-	public void remove(int index) {
-		if (!getAllowsChildren())
-			throw new IllegalStateException("Node does not allow children");
-		children.remove(index);
-	}
-
-	@Override
-	public synchronized void remove(MutableTreeNode node) {
-		if (!getAllowsChildren())
-			throw new IllegalStateException("Node does not allow children");
-		children.remove(node);
-		if (node.getParent() == this)
-			node.setParent(null);
-	}
-
-	@Override
-	public void removeFromParent() {
-		if (parent != null) {
-			IterationStrategyNode oldParent = parent;
-			parent = null;
-			oldParent.remove(this);
-		}
-	}
-
-	/**
-	 * Implements IterationStrategyNode
-	 */
-	@Override
-	public final synchronized void setParent(MutableTreeNode newParent) {
-		if (newParent != null && !(newParent instanceof IterationStrategyNode))
-			throw new IllegalArgumentException(
-					"Parent not a IterationStrategyNode instance: " + newParent);
-		if (newParent != null && !newParent.getAllowsChildren())
-			throw new IllegalStateException(
-					"New parent does not allow children");
-		if (newParent == this)
-			throw new IllegalArgumentException("Can't be it's own parent");
-		removeFromParent();
-		parent = (IterationStrategyNode) newParent;
-		if (parent != null && !parent.getChildren().contains(this))
-			parent.insert(this);
-	}
-
-	@Override
-	public void setUserObject(Object object) {
-		throw new UnsupportedOperationException("Can't set user object");
-	}
-
-	/**
-	 * Push the specified completion event to the parent node
-	 */
-	protected final void pushCompletion(Completion completion) {
-		if (parent != null)
-			parent.receiveCompletion(parent.getIndex(this), completion);
-	}
-
-	/**
-	 * Push the specified job up to the parent node in the iteration strategy.
-	 */
-	protected final void pushJob(Job job) {
-		if (parent != null) {
-			int index = parent.getIndex(this);
-			if (index < 0)
-				throw new WorkflowStructureException(
-						"Parent doesn't have this node in its child list!");
-			parent.receiveJob(parent.getIndex(this), job);
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/CompletionHandlingAbstractIterationStrategyNode.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/CompletionHandlingAbstractIterationStrategyNode.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/CompletionHandlingAbstractIterationStrategyNode.java
deleted file mode 100644
index 117afe2..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/CompletionHandlingAbstractIterationStrategyNode.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.iteration;
-
-import static java.util.Collections.synchronizedMap;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import net.sf.taverna.t2.invocation.Completion;
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Job;
-
-/**
- * A superclass for all iteration strategy nodes which are required to propagate
- * final completion events formed from multiple inputs. This is all the 'real'
- * iteration strategy nodes (but not the internal ones within the iteration
- * strategy object itself or the named input port nodes). All events are passed
- * to delegates in subclasses after which the completion state is checked, the
- * logic is as follows :
- * <p>
- * If the event received is final, that is to say it has an index of zero, and
- * final events have been received on all other inputs and at least one final
- * completion has been received then emit a final completion, otherwise do
- * nothing.
- * <p>
- * This means that subclasses should not emit final completion events themselves
- * - these will be handled by this superclass and emiting them in the subclass
- * will lead to duplicatation.
- * 
- * @author Tom Oinn
- * @author David Withers
- */
-@SuppressWarnings("serial")
-public abstract class CompletionHandlingAbstractIterationStrategyNode extends
-		AbstractIterationStrategyNode {
-	/**
-	 * Container class for the state of completion for a given process
-	 * identifier
-	 * 
-	 * @author Tom Oinn
-	 */
-	protected final class CompletionState {
-		protected CompletionState(int indexLength) {
-			inputComplete = new boolean[indexLength];
-			for (int i = 0; i < indexLength; i++)
-				inputComplete[i] = false;
-		}
-
-		protected boolean[] inputComplete;
-		protected boolean receivedCompletion = false;
-
-		/**
-		 * Return true iff all inputs have completed
-		 */
-		protected boolean isComplete() {
-			for (boolean inputCompletion : inputComplete)
-				if (!inputCompletion)
-					return false;
-			return true;
-		}
-	}
-
-	private Map<String, CompletionState> ownerToCompletion = synchronizedMap(new HashMap<String, CompletionState>());
-
-	@Override
-	public final void receiveCompletion(int inputIndex, Completion completion) {
-		innerReceiveCompletion(inputIndex, completion);
-		if (completion.getIndex().length == 0)
-			pingCompletionState(inputIndex, completion.getOwningProcess(),
-					true, completion.getContext());
-	}
-
-	@Override
-	public final void receiveJob(int inputIndex, Job newJob) {
-		innerReceiveJob(inputIndex, newJob);
-		if (newJob.getIndex().length == 0)
-			pingCompletionState(inputIndex, newJob.getOwningProcess(), false,
-					newJob.getContext());
-	}
-
-	/**
-	 * Called after a final completion event has been emited for a given owning
-	 * process, should be used by subclasses to do any tidying required,
-	 * removing state etc.
-	 * 
-	 * @param owningProcess
-	 */
-	protected abstract void cleanUp(String owningProcess);
-
-	private void pingCompletionState(int inputIndex, String owningProcess,
-			boolean isCompletion, InvocationContext context) {
-		CompletionState cs = getCompletionState(owningProcess);
-		cs.inputComplete[inputIndex] = true;
-		if (isCompletion)
-			cs.receivedCompletion = true;
-		if (cs.isComplete()) {
-			cleanUp(owningProcess);
-			ownerToCompletion.remove(owningProcess);
-			if (cs.receivedCompletion)
-				pushCompletion(new Completion(owningProcess, new int[0],
-						context));
-		}
-	}
-
-	protected CompletionState getCompletionState(String owningProcess) {
-		if (ownerToCompletion.containsKey(owningProcess))
-			return ownerToCompletion.get(owningProcess);
-		CompletionState cs = new CompletionState(getChildCount());
-		ownerToCompletion.put(owningProcess, cs);
-		return cs;
-	}
-
-	protected abstract void innerReceiveCompletion(int inputIndex,
-			Completion completion);
-
-	protected abstract void innerReceiveJob(int inputIndex, Job newJob);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/CrossProduct.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/CrossProduct.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/CrossProduct.java
deleted file mode 100644
index 4bf606c..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/CrossProduct.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.iteration;
-
-import static java.util.Collections.synchronizedMap;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import net.sf.taverna.t2.invocation.Completion;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Job;
-
-/**
- * A cross product node combines its inputs in an 'all against all' manner. When
- * a new job is received on index 'n' a set of jobs is emited corresponding to
- * the combination of the new job with all other jobs on input indices other
- * than 'n'.
- * 
- * @author Tom Oinn
- * @author David Withers
- */
-@SuppressWarnings("serial")
-public class CrossProduct extends
-		CompletionHandlingAbstractIterationStrategyNode {
-	private Map<String, List<Set<Job>>> ownerToCache = synchronizedMap(new HashMap<String, List<Set<Job>>>());
-
-	/**
-	 * Receive a job, emit jobs corresponding to the orthogonal join of the new
-	 * job with all jobs in all other input lists.
-	 */
-	@Override
-	public synchronized void innerReceiveJob(int inputIndex, Job newJob) {
-		if (getChildCount() == 1) {
-			/*
-			 * there's only one input and there's nothing to do here so push the
-			 * job through
-			 */
-			pushJob(newJob);
-			return;
-		}
-		if (!ownerToCache.containsKey(newJob.getOwningProcess())) {
-			List<Set<Job>> perInputCache = new ArrayList<>();
-			for (int i = 0; i < getChildCount(); i++)
-				perInputCache.add(new HashSet<Job>());
-			ownerToCache.put(newJob.getOwningProcess(), perInputCache);
-		}
-		// Store the new job
-		List<Set<Job>> perInputCache = ownerToCache.get(newJob
-				.getOwningProcess());
-		perInputCache.get(inputIndex).add(newJob);
-		/*
-		 * Find all combinations of the new job with all permutations of jobs in
-		 * the other caches. We could make this a lot easier by restricting it
-		 * to a single pair of inputs, this might be a more sane way to go in
-		 * the future...
-		 */
-		Set<Job> workingSet = perInputCache.get(0);
-		if (inputIndex == 0) {
-			workingSet = new HashSet<>();
-			workingSet.add(newJob);
-		}
-		for (int i = 1; i < getChildCount(); i++) {
-			Set<Job> thisSet = perInputCache.get(i);
-			if (i == inputIndex) {
-				/*
-				 * This is the cache for the new job, so we rewrite the set to a
-				 * single element one containing only the newly submitted job
-				 */
-				thisSet = new HashSet<>();
-				thisSet.add(newJob);
-			}
-			workingSet = merge(workingSet, thisSet);
-		}
-		for (Job outputJob : workingSet)
-			pushJob(outputJob);
-		if (canClearCache(inputIndex, newJob.getOwningProcess()))
-			/*
-			 * If we've seen completions for all the other indexes we don't need
-			 * to cache jobs for this index
-			 */
-			perInputCache.get(inputIndex).clear();
-	}
-
-	private Set<Job> merge(Set<Job> set1, Set<Job> set2) {
-		Set<Job> newSet = new HashSet<>();
-		for (Job job1 : set1)
-			for (Job job2 : set2) {
-				int[] newIndex = new int[job1.getIndex().length
-						+ job2.getIndex().length];
-				int j = 0;
-				for (int i = 0; i < job1.getIndex().length; i++)
-					newIndex[j++] = job1.getIndex()[i];
-				for (int i = 0; i < job2.getIndex().length; i++)
-					newIndex[j++] = job2.getIndex()[i];
-				Map<String, T2Reference> newDataMap = new HashMap<>();
-				newDataMap.putAll(job1.getData());
-				newDataMap.putAll(job2.getData());
-				newSet.add(new Job(job1.getOwningProcess(), newIndex,
-						newDataMap, job1.getContext()));
-			}
-		return newSet;
-	}
-
-	@Override
-	public void innerReceiveCompletion(int inputIndex, Completion completion) {
-		// Do nothing, let the superclass handle final completion events
-	}
-
-	@Override
-	protected final void cleanUp(String owningProcess) {
-		ownerToCache.remove(owningProcess);
-	}
-
-	/**
-	 * Returns true iff completions have been received for all other inputs.
-	 * 
-	 * @param inputIndex
-	 * @param owningProcess
-	 * @return true iff completions have been received for all other inputs
-	 */
-	private boolean canClearCache(int inputIndex, String owningProcess) {
-		boolean[] completionState = getCompletionState(owningProcess).inputComplete;
-		for (int i = 0; i < completionState.length; i++)
-			if (i != inputIndex && !completionState[i])
-				return false;
-		return true;
-	}
-
-	@Override
-	public int getIterationDepth(Map<String, Integer> inputDepths)
-			throws IterationTypeMismatchException {
-		if (isLeaf())
-			// No children!
-			throw new IterationTypeMismatchException(
-					"Cross product with no children");
-		int temp = 0;
-		for (IterationStrategyNode child : getChildren())
-			temp += child.getIterationDepth(inputDepths);
-		return temp;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/DotProduct.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/DotProduct.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/DotProduct.java
deleted file mode 100644
index 057c017..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/DotProduct.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.iteration;
-
-import static java.util.Collections.synchronizedMap;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import net.sf.taverna.t2.invocation.Completion;
-import net.sf.taverna.t2.invocation.TreeCache;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Job;
-
-/**
- * The dot product matches jobs by index array, when a job is received a job is
- * emited if and only if the index array of the new job is matched exactly by
- * index arrays of one job in each other input index.
- * 
- * @author Tom Oinn
- */
-@SuppressWarnings("serial")
-public class DotProduct extends CompletionHandlingAbstractIterationStrategyNode {
-	Map<String, TreeCache[]> ownerToCache = synchronizedMap(new HashMap<String, TreeCache[]>());
-
-	@Override
-	public synchronized void innerReceiveJob(int inputIndex, Job newJob) {
-		if (getChildCount() == 1) {
-			/*
-			 * if there's only one input there's nothing to do here so push the
-			 * job through
-			 */
-			pushJob(newJob);
-			return;
-		}
-		String owningProcess = newJob.getOwningProcess();
-		if (!ownerToCache.containsKey(owningProcess)) {
-			TreeCache[] caches = new TreeCache[getChildCount()];
-			for (int i = 0; i < getChildCount(); i++)
-				caches[i] = new TreeCache();
-			ownerToCache.put(owningProcess, caches);
-		}
-		/*
-		 * Firstly store the new job in the cache, this isn't optimal but is
-		 * safe for now - we can make this more efficient by doing the
-		 * comparison first and only storing the job if required
-		 */
-		TreeCache[] caches = ownerToCache.get(owningProcess);
-		caches[inputIndex].insertJob(newJob);
-		int[] indexArray = newJob.getIndex();
-		boolean foundMatch = true;
-		Map<String, T2Reference> newDataMap = new HashMap<>();
-		for (TreeCache cache : caches)
-			if (cache.containsLocation(indexArray))
-				newDataMap.putAll(cache.get(indexArray).getData());
-			else
-				foundMatch = false;
-		if (foundMatch) {
-			Job j = new Job(owningProcess, indexArray, newDataMap, newJob
-					.getContext());
-			/*
-			 * Remove all copies of the job with this index from the cache,
-			 * we'll never use it again and it pays to be tidy
-			 */
-			for (TreeCache cache : caches)
-				cache.cut(indexArray);
-			pushJob(j);
-		}
-	}
-
-	/**
-	 * Delegate to the superclass to propogate completion events if and only if
-	 * the completion event is a final one. We can potentially implement finer
-	 * grained logic here in the future.
-	 */
-	@Override
-	public void innerReceiveCompletion(int inputIndex,
-			Completion completion) {
-		/*
-		 * Do nothing, let the superclass handle final completion events, ignore
-		 * others for now (although in theory we should be able to do better
-		 * than this really)
-		 */
-	}
-
-	@Override
-	protected  void cleanUp(String owningProcess) {
-		ownerToCache.remove(owningProcess);
-	}
-
-	@Override
-	public int getIterationDepth(Map<String, Integer> inputDepths)
-			throws IterationTypeMismatchException {
-		// Check that all input depths are the same
-		if (isLeaf())
-			// No children!
-			throw new IterationTypeMismatchException("Dot product with no children");			
-		int depth = getChildAt(0).getIterationDepth(inputDepths);
-		for (IterationStrategyNode childNode : getChildren())
-			if (childNode.getIterationDepth(inputDepths) != depth)
-				throw new IterationTypeMismatchException(
-						"Mismatched input types for dot product node");
-		return depth;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/IterationStrategy.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/IterationStrategy.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/IterationStrategy.java
deleted file mode 100644
index 3de1846..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/IterationStrategy.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.iteration;
-
-import java.util.Map;
-
-import net.sf.taverna.t2.workflowmodel.WorkflowItem;
-
-public interface IterationStrategy extends WorkflowItem {
-	/**
-	 * The iteration strategy results in a set of job objects with a particular
-	 * job index. This method returns the length of that index array when the
-	 * specified input types are used. Input types are defined in terms of name
-	 * and integer pairs where the name is the name of a NamedInputPortNode in
-	 * the iteration strategy and the integer is the depth of the input data
-	 * collection (i.e. item depth + index array length for that item which
-	 * should be a constant).
-	 * 
-	 * @param inputDepths
-	 *            map of port names to input collection depth
-	 * @return the length of the index array which will be generated for each
-	 *         resultant job object.
-	 */
-	int getIterationDepth(Map<String, Integer> inputDepths)
-			throws IterationTypeMismatchException;
-
-	/**
-	 * Return a map of port name -> desired cardinality for this iteration
-	 * strategy
-	 */
-	Map<String, Integer> getDesiredCardinalities();
-
-	TerminalNode getTerminalNode();
-
-	void normalize();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/IterationStrategyNode.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/IterationStrategyNode.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/IterationStrategyNode.java
deleted file mode 100644
index e2b0385..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/IterationStrategyNode.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.iteration;
-
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Map;
-
-import javax.swing.tree.MutableTreeNode;
-
-import net.sf.taverna.t2.invocation.Completion;
-import net.sf.taverna.t2.workflowmodel.WorkflowItem;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Job;
-
-/**
- * Interface for nodes within an iteration strategy layer
- * 
- * @author Tom Oinn
- * @author Stian Soiland-Reyes
- */
-public interface IterationStrategyNode extends MutableTreeNode, WorkflowItem {
-	/**
-	 * Specialised return type of {@link TreeNode#children()}
-	 */
-	@Override
-	Enumeration<IterationStrategyNode> children();
-
-	/**
-	 * Remove all children nodes and set the parent to <code>null</code>.
-	 */
-	void clear();
-
-	/**
-	 * Specialised return type of {@link TreeNode#getChildAt(int)}
-	 */
-	@Override
-	IterationStrategyNode getChildAt(int childIndex);
-
-	/**
-	 * Return a copy of the list of children nodes, or an empty list if
-	 * {@link #getAllowsChildren()} is <code>false</code>.
-	 * 
-	 * @return List of children nodes.
-	 */
-	List<IterationStrategyNode> getChildren();
-
-	/**
-	 * In the context of an enclosing iteration strategy each node should be
-	 * able to return the iteration depth, i.e. the length of the index array,
-	 * for items it will emit. In all cases other than leaf nodes this is
-	 * defined in terms of the depth of child nodes. The input cardinalities for
-	 * named ports are pushed through each node so that the terminal nodes
-	 * corresponding to input port collators can evaluate this expression -
-	 * pushing it through the entire evaluation means we don't have to keep
-	 * state anywhere in the leaf nodes (standard dependency injection)
-	 * <p>
-	 * Nodes can choose to throw the IterationTypeMismatchException if their
-	 * inputs aren't compatible with the operational semantics of the node such
-	 * as in the case of a dot product node with inputs with different depths.
-	 * 
-	 * @param inputDepths
-	 * @return
-	 * @throws IterationTypeMismatchException
-	 */
-	int getIterationDepth(Map<String, Integer> inputDepths)
-			throws IterationTypeMismatchException;
-
-	/**
-	 * Specialised return type of {@link TreeNode#getParent()}
-	 */
-	@Override
-	IterationStrategyNode getParent();
-
-	/**
-	 * Insert a new child node. The new child will be added in the end of the
-	 * list, so this would be equivalent to insert(child, getChildCount()).
-	 * 
-	 * @param child
-	 *            Child node to add
-	 */
-	void insert(MutableTreeNode child);
-
-	/**
-	 * Nodes can also receive completion events, the simplest being one
-	 * declaring that no further input is expected on the given input, or
-	 * partial completion events which are interpreted as 'no event with an
-	 * index array prefixed by the specified completion index array will be
-	 * received on the specified index'
-	 */
-	void receiveCompletion(int inputIndex, Completion completion);
-
-	/**
-	 * The nodes within the iteration strategy, a tree structure, are event
-	 * based. When a new fragment of a job from upstream in the tree (towards
-	 * leaves) arrives it is handled by this method. Implementations will
-	 * probably have to handle state management, i.e. what jobs have we already
-	 * seen, and emit appropriate jobs to downstream nodes.
-	 * 
-	 * @param inputIndex
-	 * @param newJob
-	 */
-	void receiveJob(int inputIndex, Job newJob);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/IterationStrategyStack.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/IterationStrategyStack.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/IterationStrategyStack.java
deleted file mode 100644
index ee7f099..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/IterationStrategyStack.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.iteration;
-
-import java.util.List;
-import java.util.Map;
-
-import net.sf.taverna.t2.workflowmodel.WorkflowItem;
-
-/**
- * Stack of iteration strategy containers. The stacking behaviour allows for
- * staged implicit iteration where intermediate strategies are used to drill
- * into the collection structure to a certain depth with a final one used to
- * render job objects containing data at the correct depth for the process. This
- * was achieved in Taverna 1 through the combination of nested workflows and
- * 'forcing' processors which could echo and therefore force input types of the
- * workflow to a particular cardinality.
- * 
- * @author Tom Oinn
- */
-public interface IterationStrategyStack extends WorkflowItem {
-	/**
-	 * The iteration strategy stack consists of an ordered list of iteration
-	 * strategies.
-	 * 
-	 * @return An unmodifiable copy of the list containing the iteration
-	 *         strategy objects in order, with the strategy at position 0 in the
-	 *         list being the one to which data is fed first.
-	 */
-	List<? extends IterationStrategy> getStrategies();
-
-	/**
-	 * Calculate the depth of the iteration strategy stack as a whole given a
-	 * set of named inputs and their cardinalities. This depth is the length of
-	 * the index array which will be added to any output data, so the resultant
-	 * output of each port in the owning processor is the depth of that port as
-	 * defined by the activity plus this value.
-	 * 
-	 * @param inputDepths
-	 * @return
-	 * @throws IterationTypeMismatchException
-	 * @throws MissingIterationInputException
-	 */
-	int getIterationDepth(Map<String, Integer> inputDepths)
-			throws IterationTypeMismatchException,
-			MissingIterationInputException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/IterationTypeMismatchException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/IterationTypeMismatchException.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/IterationTypeMismatchException.java
deleted file mode 100644
index 9566039..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/IterationTypeMismatchException.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.iteration;
-
-/**
- * Thrown during the typecheck phase when an iteration strategy is configured
- * such that at runtime it would fail. This is generally because a dot product
- * node has been specified where the children of that node will have different
- * cardinalities (in this case the dot product isn't defined)
- * 
- * @author Tom Oinn
- */
-public class IterationTypeMismatchException extends Exception {
-	private static final long serialVersionUID = -3034020607723767223L;
-
-	public IterationTypeMismatchException() {
-		super();
-	}
-
-	public IterationTypeMismatchException(String arg0) {
-		super(arg0);
-	}
-
-	public IterationTypeMismatchException(Throwable arg0) {
-		super(arg0);
-	}
-
-	public IterationTypeMismatchException(String arg0, Throwable arg1) {
-		super(arg0, arg1);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/MissingIterationInputException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/MissingIterationInputException.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/MissingIterationInputException.java
deleted file mode 100644
index 8df9328..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/MissingIterationInputException.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.iteration;
-
-/**
- * Thrown when an attempt is made to evaluate the type of the iteration strategy
- * but one or more input ports aren't defined in the input array of types.
- * Shouldn't normally happen as this will be handled by the type checker
- * detecting that there aren't enough inputs to check but we indicate it for
- * extra robustness.
- * 
- * @author Tom Oinn
- */
-public class MissingIterationInputException extends Exception {
-	private static final long serialVersionUID = -1615949178096496592L;
-
-	public MissingIterationInputException() {
-		super();
-	}
-
-	public MissingIterationInputException(String arg0) {
-		super(arg0);
-	}
-
-	public MissingIterationInputException(Throwable arg0) {
-		super(arg0);
-	}
-
-	public MissingIterationInputException(String arg0, Throwable arg1) {
-		super(arg0, arg1);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/NamedInputPortNode.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/NamedInputPortNode.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/NamedInputPortNode.java
deleted file mode 100644
index bd76a27..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/NamedInputPortNode.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.iteration;
-
-import java.util.Map;
-
-import net.sf.taverna.t2.invocation.Completion;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Job;
-
-/**
- * Acts as the input to a stage within the iteration strategy, passes all jobs
- * straight through. NamedInputPortNode objects are, as the name suggests,
- * named. These names correspond to the names of abstract input ports on the
- * Processor object to which the iteration strategy belongs.
- * 
- * @author Tom Oinn
- */
-@SuppressWarnings("serial")
-public class NamedInputPortNode extends AbstractIterationStrategyNode {
-	private String portName;
-	private int desiredCardinality;
-
-	public NamedInputPortNode(String name, int cardinality) {
-		super();
-		this.portName = name;
-		this.desiredCardinality = cardinality;
-	}
-
-	/**
-	 * If this node receives a job it will always be pushed without modification
-	 * up to the parent
-	 */
-	@Override
-	public void receiveJob(int inputIndex, Job newJob) {
-		pushJob(newJob);
-	}
-
-	/**
-	 * Completion events are passed straight through the same as jobs
-	 */
-	@Override
-	public void receiveCompletion(int inputIndex, Completion completion) {
-		pushCompletion(completion);
-	}
-
-	/**
-	 * Each node maps to a single named input port within the processor
-	 */
-	public String getPortName() {
-		return this.portName;
-	}
-
-	/**
-	 * Each node defines the level of collection depth for that input port
-	 */
-	public int getCardinality() {
-		return this.desiredCardinality;
-	}
-
-	/**
-	 * These nodes correspond to inputs to the iteration strategy and are always
-	 * leaf nodes as a result.
-	 * 
-	 * @override
-	 */
-	@Override
-	public boolean isLeaf() {
-		return true;
-	}
-
-	/**
-	 * These nodes can never have children
-	 * 
-	 * @override
-	 */
-	@Override
-	public boolean getAllowsChildren() {
-		return false;
-	}
-
-	/**
-	 * Iteration depth is the difference between the supplied input depth and
-	 * the desired one. If the desired depth is greater then wrapping will
-	 * happen and the iteration depth will be zero (rather than a negative!)
-	 */
-	@Override
-	public int getIterationDepth(Map<String, Integer> inputDepths) {
-		int myInputDepth = inputDepths.get(portName);
-		int depthMismatch = myInputDepth - desiredCardinality;
-		return (depthMismatch > 0 ? depthMismatch : 0);
-	}
-
-	@Override
-	public String toString() {
-		return getClass().getSimpleName() + " " + getPortName() + "("
-				+ getCardinality() + ")";
-	}
-}


[08/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Parallelize.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Parallelize.java b/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Parallelize.java
deleted file mode 100644
index bd0e69a..0000000
--- a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Parallelize.java
+++ /dev/null
@@ -1,463 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.layers;
-
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.CREATE_PROCESS_STATE;
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.NO_EFFECT;
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.REMOVE_PROCESS_STATE;
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchMessageType.JOB;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.TimerTask;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-
-import net.sf.taverna.t2.invocation.Completion;
-import net.sf.taverna.t2.invocation.IterationInternalEvent;
-import net.sf.taverna.t2.monitor.MonitorManager;
-import net.sf.taverna.t2.monitor.MonitorableProperty;
-import net.sf.taverna.t2.monitor.NoSuchPropertyException;
-import net.sf.taverna.t2.workflowmodel.WorkflowStructureException;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Job;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.AbstractDispatchLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.NotifiableLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.PropertyContributingDispatchLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerErrorReaction;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerJobQueueReaction;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerResultCompletionReaction;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerResultReaction;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.SupportsStreamedResult;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchCompletionEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchErrorEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchJobEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchJobQueueEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchResultEvent;
-
-import org.apache.log4j.Logger;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Dispatch layer which consumes a queue of events and fires off a fixed number
- * of simultaneous jobs to the layer below. It observes failure, data and
- * completion events coming up and uses these to determine when to push more
- * jobs downwards into the stack as well as when it can safely emit completion
- * events from the queue.
- *
- * @author Tom Oinn
- *
- */
-@DispatchLayerErrorReaction(emits = {}, relaysUnmodified = true, stateEffects = {
-		REMOVE_PROCESS_STATE, NO_EFFECT })
-@DispatchLayerJobQueueReaction(emits = { JOB }, relaysUnmodified = false, stateEffects = { CREATE_PROCESS_STATE })
-@DispatchLayerResultReaction(emits = {}, relaysUnmodified = true, stateEffects = {
-		REMOVE_PROCESS_STATE, NO_EFFECT })
-@DispatchLayerResultCompletionReaction(emits = {}, relaysUnmodified = true, stateEffects = {
-		REMOVE_PROCESS_STATE, NO_EFFECT })
-@SupportsStreamedResult
-public class Parallelize extends AbstractDispatchLayer<JsonNode>
-		implements NotifiableLayer,
-		PropertyContributingDispatchLayer<JsonNode> {
-	public static final String URI = "http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/Parallelize";
-	private static Logger logger = Logger.getLogger(Parallelize.class);
-
-	private Map<String, StateModel> stateMap = new HashMap<>();
-	private JsonNode config = JsonNodeFactory.instance.objectNode();
-	int sentJobsCount = 0;
-	int completedJobsCount = 0;
-
-	public Parallelize() {
-		super();
-	}
-
-	/**
-	 * Test constructor, only used by unit tests, should probably not be public
-	 * access here?
-	 *
-	 * @param maxJobs
-	 */
-	public Parallelize(int maxJobs) {
-		super();
-		((ObjectNode)config).put("maxJobs", maxJobs);
-	}
-
-	@Override
-	public void eventAdded(String owningProcess) {
-		StateModel stateModel;
-		synchronized (stateMap) {
-			stateModel = stateMap.get(owningProcess);
-		}
-		if (stateModel == null)
-			/*
-			 * Should never see this here, it means we've had duplicate
-			 * completion events from upstream
-			 */
-			throw new WorkflowStructureException(
-					"Unknown owning process " + owningProcess);
-		synchronized (stateModel) {
-			stateModel.fillFromQueue();
-		}
-	}
-
-	@Override
-	public void receiveJobQueue(DispatchJobQueueEvent queueEvent) {
-		StateModel model = new StateModel(queueEvent,
-				config.has("maxJobs") ? config.get("maxJobs").intValue() : 1);
-		synchronized (stateMap) {
-			stateMap.put(queueEvent.getOwningProcess(), model);
-		}
-		model.fillFromQueue();
-	}
-
-	public void receiveJob(Job job, List<? extends Activity<?>> activities) {
-		throw new WorkflowStructureException(
-				"Parallelize layer cannot handle job events");
-	}
-
-	@Override
-	public void receiveError(DispatchErrorEvent errorEvent) {
-		StateModel model;
-		String owningProcess = errorEvent.getOwningProcess();
-		synchronized(stateMap) {
-			model = stateMap.get(owningProcess);
-		}
-		if (model == null) {
-			logger.warn("Error received for unknown owning process: " + owningProcess);
-			return;
-		}
-		model.finishWith(errorEvent.getIndex());
-		getAbove().receiveError(errorEvent);
-	}
-
-	@Override
-	public void receiveResult(DispatchResultEvent resultEvent) {
-		StateModel model;
-		String owningProcess = resultEvent.getOwningProcess();
-		synchronized(stateMap) {
-			model = stateMap.get(owningProcess);
-		}
-		if (model == null) {
-			logger.warn("Error received for unknown owning process: " + owningProcess);
-			return;
-		}
-		if (!resultEvent.isStreamingEvent()) {
-			MonitorManager.getInstance().registerNode(resultEvent,
-					owningProcess,
-					new HashSet<MonitorableProperty<?>>());
-		}
-		model.finishWith(resultEvent.getIndex());
-		getAbove().receiveResult(resultEvent);
-	}
-
-	/**
-	 * Only going to receive this if the activity invocation was streaming, in
-	 * which case we need to handle all completion events and pass them up the
-	 * stack.
-	 */
-	@Override
-	public void receiveResultCompletion(DispatchCompletionEvent completionEvent) {
-		StateModel model;
-		String owningProcess = completionEvent.getOwningProcess();
-		synchronized(stateMap) {
-			model = stateMap.get(owningProcess);
-		}
-		if (model == null) {
-			logger.warn("Error received for unknown owning process: " + owningProcess);
-			return;
-		}
-		model.finishWith(completionEvent.getIndex());
-		getAbove().receiveResultCompletion(completionEvent);
-	}
-
-	@Override
-	public void finishedWith(final String owningProcess) {
-		// Delay the removal of the state to give the monitor a chance to poll
-		cleanupTimer.schedule(new TimerTask() {
-			@Override
-			public void run() {
-				synchronized(stateMap) {
-					stateMap.remove(owningProcess);
-				}
-			}
-		}, CLEANUP_DELAY_MS);
-	}
-
-	@Override
-	public void configure(JsonNode config) {
-		this.config = config;
-	}
-
-	@Override
-	public JsonNode getConfiguration() {
-		return this.config;
-	}
-
-	/**
-	 * Injects the following properties into its parent processor's property set:
-	 * <ul>
-	 * <li><code>dispatch.parallelize.queuesize [Integer]</code><br/>The current
-	 * size of the incomming job queue, or -1 if the state isn't defined for the
-	 * registered process identifier (which will be the case if the process
-	 * hasn't started or has had its state purged after a final completion of
-	 * some kind.</li>
-	 * </ul>
-	 */
-	@Override
-	public void injectPropertiesFor(final String owningProcess) {
-		/**
-		 * Property for the queue depth, will evaluate to -1 if there isn't a
-		 * queue in the state model for this identifier (which will be the case
-		 * if we haven't created the state yet or the queue has been collected)
-		 */
-		MonitorableProperty<Integer> queueSizeProperty = new MonitorableProperty<Integer>() {
-			@Override
-			public Date getLastModified() {
-				return new Date();
-			}
-
-			@Override
-			public String[] getName() {
-				return new String[] { "dispatch", "parallelize", "queuesize" };
-			}
-
-			@Override
-			public Integer getValue() throws NoSuchPropertyException {
-				StateModel model;
-				synchronized(stateMap) {
-					model = stateMap.get(owningProcess);
-				}
-				if (model == null)
-					return -1;
-				return model.queueSize();
-			}
-		};
-		dispatchStack.receiveMonitorableProperty(queueSizeProperty,
-				owningProcess);
-
-		MonitorableProperty<Integer> sentJobsProperty = new MonitorableProperty<Integer>() {
-			@Override
-			public Date getLastModified() {
-				return new Date();
-			}
-
-			@Override
-			public String[] getName() {
-				return new String[] { "dispatch", "parallelize", "sentjobs" };
-			}
-
-			@Override
-			public Integer getValue() throws NoSuchPropertyException {
-				return sentJobsCount;
-			}
-		};
-		dispatchStack.receiveMonitorableProperty(sentJobsProperty,
-				owningProcess);
-
-		MonitorableProperty<Integer> completedJobsProperty = new MonitorableProperty<Integer>() {
-			@Override
-			public Date getLastModified() {
-				return new Date();
-			}
-
-			@Override
-			public String[] getName() {
-				return new String[] { "dispatch", "parallelize",
-						"completedjobs" };
-			}
-
-			@Override
-			public Integer getValue() throws NoSuchPropertyException {
-				return completedJobsCount;
-			}
-		};
-		dispatchStack.receiveMonitorableProperty(completedJobsProperty,
-				owningProcess);
-	}
-
-	/**
-	 * Holds the state for a given owning process
-	 *
-	 * @author Tom Oinn
-	 *
-	 */
-	// suppressed to avoid jdk1.5 error messages caused by the declaration
-	// IterationInternalEvent<? extends IterationInternalEvent<?>> e
-	@SuppressWarnings("rawtypes")
-	class StateModel {
-		private DispatchJobQueueEvent queueEvent;
-		private BlockingQueue<IterationInternalEvent> pendingEvents = new LinkedBlockingQueue<>();
-		private int activeJobs = 0;
-		private int maximumJobs;
-
-		/**
-		 * Construct state model for a particular owning process
-		 *
-		 * @param owningProcess
-		 *            Process to track parallel execution
-		 * @param queue
-		 *            reference to the queue into which jobs are inserted by the
-		 *            iteration strategy
-		 * @param activities
-		 *            activities to pass along with job events down into the
-		 *            stack below
-		 * @param maxJobs
-		 *            maximum number of concurrent jobs to keep 'hot' at any
-		 *            given point
-		 */
-		protected StateModel(DispatchJobQueueEvent queueEvent, int maxJobs) {
-			this.queueEvent = queueEvent;
-			this.maximumJobs = maxJobs;
-		}
-
-		Integer queueSize() {
-			return queueEvent.getQueue().size();
-		}
-
-		/**
-		 * Poll the queue repeatedly until either the queue is empty or we have
-		 * enough jobs pulled from it. The semantics for this are:
-		 * <ul>
-		 * <li>If the head of the queue is a Job and activeJobs < maximumJobs
-		 * then increment activeJobs, add the Job to the pending events list at
-		 * the end and send the message down the stack
-		 * <li>If the head of the queue is a Completion and the pending jobs
-		 * list is empty then send it to the layer above
-		 * <li>If the head of the queue is a Completion and the pending jobs
-		 * list is not empty then add the Completion to the end of the pending
-		 * jobs list and return
-		 * </ul>
-		 */
-		protected void fillFromQueue() {
-			synchronized (this) {
-				while (queueEvent.getQueue().peek() != null
-						&& activeJobs < maximumJobs) {
-					final IterationInternalEvent e = queueEvent.getQueue()
-							.remove();
-
-					if (e instanceof Completion && pendingEvents.peek() == null) {
-						new Thread(new Runnable() {
-							@Override
-							public void run() {
-								getAbove().receiveResultCompletion(
-										new DispatchCompletionEvent(e
-												.getOwningProcess(), e
-												.getIndex(), e.getContext()));
-							}
-						}, "Parallelize " + e.getOwningProcess()).start();
-						// getAbove().receiveResultCompletion((Completion) e);
-					} else {
-						pendingEvents.add(e);
-					}
-					if (e instanceof Job) {
-						synchronized (this) {
-							activeJobs++;
-						}
-						sentJobsCount++;
-
-						DispatchJobEvent dispatchJobEvent = new DispatchJobEvent(e
-								.getOwningProcess(), e
-								.getIndex(), e.getContext(),
-								((Job) e).getData(), queueEvent
-										.getActivities());
-						// Register with the monitor
-						MonitorManager.getInstance().registerNode(dispatchJobEvent,
-								e.getOwningProcess(),
-								new HashSet<MonitorableProperty<?>>());
-
-						getBelow().receiveJob(dispatchJobEvent);
-					}
-				}
-			}
-		}
-
-		/**
-		 * Returns true if the index matched an existing Job exactly, if this
-		 * method returns false then you have a partial completion event which
-		 * should be sent up the stack without modification.
-		 *
-		 * @param index
-		 * @return
-		 */
-		protected boolean finishWith(int[] index) {
-			synchronized (this) {
-				for (IterationInternalEvent e : new ArrayList<>(pendingEvents)) {
-					if (!(e instanceof Job))
-						continue;
-					Job j = (Job) e;
-					if (!arrayEquals(j.getIndex(), index))
-						continue;
-
-					/*
-					 * Found a job in the pending events list which has the
-					 * same index, remove it and decrement the current count
-					 * of active jobs
-					 */
-					pendingEvents.remove(e);
-					activeJobs--;
-					completedJobsCount++;
-					/*
-					 * Now pull any completion events that have reached the head
-					 * of the queue - this indicates that all the job events
-					 * which came in before them have been processed and we can
-					 * emit the completions
-					 */
-					while (pendingEvents.peek() != null
-							&& pendingEvents.peek() instanceof Completion) {
-						Completion c = (Completion) pendingEvents.remove();
-						getAbove().receiveResultCompletion(
-								new DispatchCompletionEvent(c
-										.getOwningProcess(), c.getIndex(), c
-										.getContext()));
-					}
-					/*
-					 * Refresh from the queue; as we've just decremented the
-					 * active job count there should be a worker available
-					 */
-					fillFromQueue();
-					/*
-					 * Return true to indicate that we removed a job event from
-					 * the queue, that is to say that the index wasn't that of a
-					 * partial completion.
-					 */
-					return true;
-				}
-			}
-			return false;
-		}
-
-		private boolean arrayEquals(int[] a, int[] b) {
-			if (a.length != b.length)
-				return false;
-			for (int i = 0; i < a.length; i++)
-				if (a[i] != b[i])
-					return false;
-			return true;
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/ParallelizeConfig.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/ParallelizeConfig.java b/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/ParallelizeConfig.java
deleted file mode 100644
index 29d69d6..0000000
--- a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/ParallelizeConfig.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.layers;
-
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationBean;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationProperty;
-
-/**
- * Bean to hold the configuration for the parallelize layer, specifically a
- * single int property defining the number of concurrent jobs in that processor
- * instance per owning process ID.
- * 
- * @author Tom Oinn
- */
-@ConfigurationBean(uri = Parallelize.URI + "#Config")
-public class ParallelizeConfig {
-	private int maxJobs;
-
-	public ParallelizeConfig() {
-		super();
-		this.maxJobs = 1;
-	}
-
-	@ConfigurationProperty(name = "maxJobs", label = "Maximum Parallel Jobs", description = "The maximum number of jobs that can run in parallel", required = false)
-	public void setMaximumJobs(int maxJobs) {
-		this.maxJobs = maxJobs;
-	}
-
-	public int getMaximumJobs() {
-		return this.maxJobs;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Retry.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Retry.java b/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Retry.java
deleted file mode 100644
index f2054d9..0000000
--- a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Retry.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.layers;
-
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.CREATE_LOCAL_STATE;
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.REMOVE_LOCAL_STATE;
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.UPDATE_LOCAL_STATE;
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchMessageType.JOB;
-
-import java.util.Iterator;
-import java.util.Timer;
-import java.util.TimerTask;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.AbstractErrorHandlerLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerErrorReaction;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerJobReaction;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerResultReaction;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchJobEvent;
-
-/**
- * Implements retry policy with delay between retries and exponential backoff
- * <p>
- * Default properties are as follows :
- * <ul>
- * <li>maxRetries = 0 (int)</li>
- * <li>initialDelay = 1000 (milliseconds)</li>
- * <li>maxDelay = 2000 (milliseconds)</li>
- * <li>backoffFactor = 1.0 (double)</li>
- * </ul>
- *
- * @author Tom Oinn
- * @author David Withers
- * @author Stian Soiland-Reyes
- */
-@DispatchLayerErrorReaction(emits = { JOB }, relaysUnmodified = true, stateEffects = {
-		UPDATE_LOCAL_STATE, REMOVE_LOCAL_STATE })
-@DispatchLayerJobReaction(emits = {}, relaysUnmodified = true, stateEffects = { CREATE_LOCAL_STATE })
-@DispatchLayerResultReaction(emits = {}, relaysUnmodified = true, stateEffects = { REMOVE_LOCAL_STATE })
-public class Retry extends AbstractErrorHandlerLayer<JsonNode> {
-	private static final String BACKOFF_FACTOR = "backoffFactor";
-    private static final String MAX_DELAY = "maxDelay";
-    private static final String MAX_RETRIES = "maxRetries";
-    private static final String INITIAL_DELAY = "initialDelay";
-    public static final String URI = "http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/Retry";
-
-	private ObjectNode config;
-    private int maxRetries;
-    private int initialDelay;
-    private int maxDelay;
-    private double backoffFactor;
-
-	private static Timer retryTimer = new Timer("Retry timer", true);
-
-	public Retry() {
-		super();
-		configure(JsonNodeFactory.instance.objectNode());
-	}
-
-	public Retry(int maxRetries, int initialDelay, int maxDelay,
-			double backoffFactor) {
-		super();
-		ObjectNode conf = JsonNodeFactory.instance.objectNode();
-		conf.put(MAX_RETRIES, maxRetries);
-		conf.put(INITIAL_DELAY, initialDelay);
-		conf.put(MAX_DELAY, maxDelay);
-		conf.put(BACKOFF_FACTOR, backoffFactor);
-		configure(conf);
-	}
-
-	class RetryState extends JobState {
-		int currentRetryCount = 0;
-
-		public RetryState(DispatchJobEvent jobEvent) {
-			super(jobEvent);
-		}
-
-		/**
-		 * Try to schedule a retry, returns true if a retry is scheduled, false
-		 * if the retry count has already been reached (in which case no retry
-		 * is scheduled
-		 *
-		 * @return
-		 */
-		@Override
-		public boolean handleError() {
-			if (currentRetryCount >= maxRetries)
-				return false;
-			int delay = (int) (initialDelay * Math.pow(backoffFactor, currentRetryCount));
-			delay = Math.min(delay, maxDelay);
-			TimerTask task = new TimerTask() {
-				@Override
-				public void run() {
-					currentRetryCount++;
-					getBelow().receiveJob(jobEvent);
-				}
-			};
-			retryTimer.schedule(task, delay);
-			return true;
-		}
-	}
-
-	@Override
-	protected JobState getStateObject(DispatchJobEvent jobEvent) {
-		return new RetryState(jobEvent);
-	}
-
-	@Override
-	public void configure(JsonNode config) {
-	    ObjectNode defaultConfig = defaultConfig();
-        setAllMissingFields((ObjectNode) config, defaultConfig);
-        checkConfig((ObjectNode)config);
-        this.config = (ObjectNode) config;
-        maxRetries = config.get(MAX_RETRIES).intValue();
-        initialDelay = config.get(INITIAL_DELAY).intValue();
-        maxDelay = config.get(MAX_DELAY).intValue();
-        backoffFactor = config.get(BACKOFF_FACTOR).doubleValue();       
-	}
-
-    private void setAllMissingFields(ObjectNode config, ObjectNode defaults) {
-        for (String fieldName : forEach(defaults.fieldNames()))
-	        if (! config.has(fieldName) || config.get(fieldName).isNull())
-	            config.put(fieldName, defaults.get(fieldName));
-    }
-
-	private <T> Iterable<T> forEach(final Iterator<T> iterator) {
-	    return new Iterable<T>() {
-            @Override
-            public Iterator<T> iterator() {
-                return iterator;
-            }
-        };
-    }
-
-    private void checkConfig(ObjectNode conf) {
-        if (conf.get(MAX_RETRIES).intValue() < 0)
-            throw new IllegalArgumentException("maxRetries < 0");
-        if (conf.get(INITIAL_DELAY).intValue() < 0)
-            throw new IllegalArgumentException("initialDelay < 0");
-        if (conf.get(MAX_DELAY).intValue() < conf.get(INITIAL_DELAY).intValue())
-            throw new IllegalArgumentException("maxDelay < initialDelay");
-        if (conf.get(BACKOFF_FACTOR).doubleValue() < 0.0)
-            throw new IllegalArgumentException("backoffFactor < 0.0");
-    }
-
-    public static ObjectNode defaultConfig() {
-	    ObjectNode conf = JsonNodeFactory.instance.objectNode();
-	    conf.put(MAX_RETRIES, 0);
-	    conf.put(INITIAL_DELAY, 1000);
-	    conf.put(MAX_DELAY, 5000);
-	    conf.put(BACKOFF_FACTOR, 1.0);
-	    return conf;
-    }
-
-    @Override
-	public JsonNode getConfiguration() {
-		return this.config;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/RetryConfig.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/RetryConfig.java b/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/RetryConfig.java
deleted file mode 100644
index 39dedbf..0000000
--- a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/RetryConfig.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.layers;
-
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationBean;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationProperty;
-
-@ConfigurationBean(uri = Retry.URI + "#Config")
-public class RetryConfig {
-	private static final float BACKOFF_FACTOR = 1.0f;
-	private static final int MAX_DELAY = 5000;
-	private static final int INITIAL_DELAY = 1000;
-	private static final int MAX_RETRIES = 0;
-
-	private float backoffFactor = BACKOFF_FACTOR;
-	private int initialDelay = INITIAL_DELAY;
-	private int maxDelay = MAX_DELAY;
-	private int maxRetries = MAX_RETRIES;
-
-	/**
-	 * Factor by which the initial delay is multiplied for each retry after the
-	 * first, this allows for exponential backoff of retry times up to a certain
-	 * ceiling
-	 *
-	 * @return
-	 */
-	public float getBackoffFactor() {
-		return this.backoffFactor;
-	}
-
-	/**
-	 * Delay in milliseconds between the initial failure message and the first
-	 * attempt to retry the failed job
-	 *
-	 * @return
-	 */
-	public int getInitialDelay() {
-		return this.initialDelay;
-	}
-
-	/**
-	 * Maximum delay in milliseconds between failure reception and retry. This
-	 * acts as a ceiling for the exponential backoff factor allowing the retry
-	 * delay to initially increase to a certain value then remain constant after
-	 * that point rather than exploding to unreasonable levels.
-	 */
-	public int getMaxDelay() {
-		return this.maxDelay;
-	}
-
-	/**
-	 * Maximum number of retries for a failing process
-	 *
-	 * @return
-	 */
-	public int getMaxRetries() {
-		return this.maxRetries;
-	}
-
-	@ConfigurationProperty(name = "backoffFactor", label = "Backoff Factor", description = "Factor by which the initial delay is multiplied for each retry after the first retry", required=false)
-	public void setBackoffFactor(float factor) {
-		this.backoffFactor = factor;
-	}
-
-	@ConfigurationProperty(name = "initialDelay", label = "Initial Delay", description = "Delay in milliseconds between the initial failure message and the first attempt to retry the failed job", required=false)
-	public void setInitialDelay(int delay) {
-		this.initialDelay = delay;
-	}
-
-	@ConfigurationProperty(name = "maxDelay", label = "Maximum Delay", description = "Maximum delay in milliseconds between failure reception and retry", required=false)
-	public void setMaxDelay(int delay) {
-		this.maxDelay = delay;
-	}
-
-	@ConfigurationProperty(name = "maxRetries", label = "Maximum Retries", description = "Maximum number of retries for a failing process", required=false)
-	public void setMaxRetries(int max) {
-		this.maxRetries = max;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Stop.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Stop.java b/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Stop.java
deleted file mode 100644
index 3169f8c..0000000
--- a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Stop.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.layers;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import net.sf.taverna.t2.reference.WorkflowRunIdEntity;
-import net.sf.taverna.t2.workflowmodel.ConfigurationException;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.AbstractDispatchLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchJobEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchJobQueueEvent;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * This layer allows for the cancellation, pausing and resuming of workflow
- * runs. It does so by intercepting jobs sent to the layer.
- *
- * @author alanrw
- */
-public class Stop extends AbstractDispatchLayer<JsonNode> {
-	public static final String URI = "http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/Stop";
-	/**
-	 * The set of ids of workflow runs that have been cancelled.
-	 */
-	private static Set<String> cancelledWorkflowRuns = new HashSet<>();
-	/**
-	 * A map from workflow run ids to the set of Stop layers where jobs have
-	 * been intercepted for that run.
-	 */
-	private static Map<String, Set<Stop>> pausedLayerMap = new HashMap<>();
-	/**
-	 * A map for a given Stop from ids of suspended workflow runs to the jobs
-	 * that have been intercepted.
-	 */
-	private Map<String, Set<DispatchJobEvent>> suspendedJobEventMap = new HashMap<>();
-
-	@Override
-	public void configure(JsonNode conf) throws ConfigurationException {
-		// nothing
-	}
-
-	@Override
-	public JsonNode getConfiguration() {
-		return null;
-	}
-
-	@Override
-	public void receiveJob(final DispatchJobEvent jobEvent) {
-		List<WorkflowRunIdEntity> entities = jobEvent.getContext().getEntities(
-				WorkflowRunIdEntity.class);
-		if (entities != null && !entities.isEmpty()) {
-			final String wfRunId = entities.get(0).getWorkflowRunId();
-			// If the workflow run is cancelled then simply "eat" the jobEvent.
-			// This does a hard-cancel.
-			if (cancelledWorkflowRuns.contains(wfRunId))
-				return;
-			// If the workflow run is paused
-			if (pausedLayerMap.containsKey(wfRunId))
-				synchronized (Stop.class) {
-					// double check as pausedLayerMap may have been changed
-					// waiting for the lock
-					if (pausedLayerMap.containsKey(wfRunId)) {
-						// Remember that this Stop layer was affected by the
-						// workflow pause
-						pausedLayerMap.get(wfRunId).add(this);
-						if (!suspendedJobEventMap.containsKey(wfRunId))
-							suspendedJobEventMap.put(wfRunId,
-									new HashSet<DispatchJobEvent>());
-						// Remember the suspended jobEvent
-						suspendedJobEventMap.get(wfRunId).add(jobEvent);
-						return;
-					}
-				}
-		}
-		// By default pass the jobEvent down to the next layer
-		super.receiveJob(jobEvent);
-	}
-
-	@Override
-	public void receiveJobQueue(DispatchJobQueueEvent jobQueueEvent) {
-		super.receiveJobQueue(jobQueueEvent);
-	}
-
-	/**
-	 * Cancel the workflow run with the specified id
-	 *
-	 * @param workflowRunId
-	 *            The id of the workflow run to cancel
-	 * @return If the workflow run was cancelled then true. If it was already
-	 *         cancelled then false.
-	 */
-	public static synchronized boolean cancelWorkflow(String workflowRunId) {
-		if (cancelledWorkflowRuns.contains(workflowRunId))
-			return false;
-		Set<String> cancelledWorkflowRunsCopy = new HashSet<>(
-				cancelledWorkflowRuns);
-		cancelledWorkflowRunsCopy.add(workflowRunId);
-		cancelledWorkflowRuns = cancelledWorkflowRunsCopy;
-		return true;
-	}
-
-	/**
-	 * Pause the workflow run with the specified id
-	 *
-	 * @param workflowRunId
-	 *            The id of the workflow run to pause
-	 * @return If the workflow run was paused then true. If it was already
-	 *         paused or cancelled then false.
-	 */
-	public static synchronized boolean pauseWorkflow(String workflowRunId) {
-		if (cancelledWorkflowRuns.contains(workflowRunId))
-			return false;
-		if (pausedLayerMap.containsKey(workflowRunId))
-			return false;
-		Map<String, Set<Stop>> pausedLayerMapCopy = new HashMap<>(pausedLayerMap);
-		pausedLayerMapCopy.put(workflowRunId, new HashSet<Stop>());
-		pausedLayerMap = pausedLayerMapCopy;
-		return true;
-	}
-
-	/**
-	 * Resume the workflow run with the specified id
-	 *
-	 * @param workflowRunId
-	 *            The id of the workflow run to resume
-	 * @return If the workflow run was resumed then true. If the workflow run
-	 *         was not paused or it was cancelled, then false.
-	 */
-	public static synchronized boolean resumeWorkflow(String workflowRunId) {
-		if (cancelledWorkflowRuns.contains(workflowRunId))
-			return false;
-		if (!pausedLayerMap.containsKey(workflowRunId))
-			return false;
-		Map<String, Set<Stop>> pausedLayerMapCopy = new HashMap<>();
-		pausedLayerMapCopy.putAll(pausedLayerMap);
-		Set<Stop> stops = pausedLayerMapCopy.remove(workflowRunId);
-		pausedLayerMap = pausedLayerMapCopy;
-		for (Stop s : stops)
-			s.resumeLayerWorkflow(workflowRunId);
-		return true;
-	}
-
-	/**
-	 * Resume the workflow run with the specified id on this Stop layer. This
-	 * method processes any suspended job events.
-	 *
-	 * @param workflowRunId
-	 *            The id of the workflow run to resume.
-	 */
-	private void resumeLayerWorkflow(String workflowRunId) {
-		synchronized (Stop.class) {
-			for (DispatchJobEvent dje : suspendedJobEventMap
-					.remove(workflowRunId))
-				receiveJob(dje);
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/package.html b/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/package.html
deleted file mode 100644
index fe6e73f..0000000
--- a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/package.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<body>
-Contains implementations of DispatchLayer defined by the core Taverna 2
-specification.
-</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/CoreDispatchLayerFactory.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/CoreDispatchLayerFactory.java b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/CoreDispatchLayerFactory.java
new file mode 100644
index 0000000..3f51a13
--- /dev/null
+++ b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/CoreDispatchLayerFactory.java
@@ -0,0 +1,102 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.layers;
+
+import java.net.URI;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.taverna.workflowmodel.processor.dispatch.DispatchLayer;
+import org.apache.taverna.workflowmodel.processor.dispatch.DispatchLayerFactory;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * Factory for creating core dispatch layers.
+ *
+ * The core dispatch layers are :
+ * <ul>
+ * <li>ErrorBounce</li>
+ * <li>Parallelize</li>
+ * <li>Failover</li>
+ * <li>Retry</li>
+ * <li>Stop</li>
+ * <li>Invoke</li>
+ * <li>Loop</li>
+ * <li>IntermediateProvenance</li>
+ * </ul>
+ *
+ * @author David Withers
+ */
+public class CoreDispatchLayerFactory implements DispatchLayerFactory {
+	private static final URI parallelizeLayer = URI.create(Parallelize.URI);
+	private static final URI errorBounceLayer = URI.create(ErrorBounce.URI);
+	private static final URI failoverLayer = URI.create(Failover.URI);
+	private static final URI retryLayer = URI.create(Retry.URI);
+	private static final URI invokeLayer = URI.create(Invoke.URI);
+	private static final URI loopLayer = URI.create(Loop.URI);
+	private static final URI intermediateProvenanceLayer = URI.create(IntermediateProvenance.URI);
+	private static final URI stopLayer = URI.create(Stop.URI);
+
+	private final static Set<URI> dispatchLayerURIs = new HashSet<URI>();
+
+	static {
+		dispatchLayerURIs.add(parallelizeLayer);
+		dispatchLayerURIs.add(errorBounceLayer);
+		dispatchLayerURIs.add(failoverLayer);
+		dispatchLayerURIs.add(retryLayer);
+		dispatchLayerURIs.add(invokeLayer);
+		dispatchLayerURIs.add(loopLayer);
+		dispatchLayerURIs.add(intermediateProvenanceLayer);
+		dispatchLayerURIs.add(stopLayer);
+	}
+
+	@Override
+	public DispatchLayer<?> createDispatchLayer(URI uri) {
+		if (parallelizeLayer.equals(uri))
+			return new Parallelize();
+		else if (errorBounceLayer.equals(uri))
+			return new ErrorBounce();
+		else if (failoverLayer.equals(uri))
+			return new Failover();
+		else if (retryLayer.equals(uri))
+			return new Retry();
+		else if (invokeLayer.equals(uri))
+			return new Invoke();
+		else if (loopLayer.equals(uri))
+			return new Loop();
+		else if (intermediateProvenanceLayer.equals(uri))
+			return new IntermediateProvenance();
+		else if (stopLayer.equals(uri))
+			return new Stop();
+		return null;
+	}
+
+	@Override
+	public JsonNode getDispatchLayerConfigurationSchema(URI uri) {
+		// TODO
+		return null;
+	}
+
+	@Override
+	public Set<URI> getDispatchLayerTypes() {
+		return dispatchLayerURIs;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/ErrorBounce.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/ErrorBounce.java b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/ErrorBounce.java
new file mode 100644
index 0000000..4eef732
--- /dev/null
+++ b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/ErrorBounce.java
@@ -0,0 +1,323 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.layers;
+
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.CREATE_PROCESS_STATE;
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.NO_EFFECT;
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.UPDATE_PROCESS_STATE;
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchMessageType.RESULT;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.TimerTask;
+import java.util.concurrent.ConcurrentHashMap;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+import org.apache.taverna.invocation.Event;
+import org.apache.taverna.monitor.MonitorableProperty;
+import org.apache.taverna.monitor.NoSuchPropertyException;
+import org.apache.taverna.reference.ErrorDocument;
+import org.apache.taverna.reference.ReferenceService;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.workflowmodel.OutputPort;
+import org.apache.taverna.workflowmodel.Processor;
+import org.apache.taverna.workflowmodel.processor.dispatch.AbstractDispatchLayer;
+import org.apache.taverna.workflowmodel.processor.dispatch.PropertyContributingDispatchLayer;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerErrorReaction;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerJobReaction;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerResultCompletionReaction;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerResultReaction;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.SupportsStreamedResult;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchErrorEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchJobEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchResultEvent;
+
+/**
+ * Receives job events, checks to see whether any parameters in the job are
+ * error tokens or collections which contain errors. If so then sends a
+ * corresponding result message back where all outputs are error tokens having
+ * registered such with the invocation context's data manager. It also re-writes
+ * any failure messages as result messages containing error tokens at the
+ * appropriate depth - this means that it must be placed above any error
+ * handling layers in order for those to have an effect at all. In general this
+ * layer should be placed immediately below the parallelize layer in most
+ * default cases (this will guarantee the processor never sees a failure message
+ * though, which may or may not be desirable)
+ * 
+ * @author Tom Oinn
+ * 
+ */
+@DispatchLayerErrorReaction(emits = { RESULT }, relaysUnmodified = false, stateEffects = {
+		CREATE_PROCESS_STATE, UPDATE_PROCESS_STATE })
+@DispatchLayerJobReaction(emits = { RESULT }, relaysUnmodified = true, stateEffects = {
+		CREATE_PROCESS_STATE, UPDATE_PROCESS_STATE, NO_EFFECT })
+@DispatchLayerResultReaction(emits = {}, relaysUnmodified = true, stateEffects = {})
+@DispatchLayerResultCompletionReaction(emits = {}, relaysUnmodified = true, stateEffects = {})
+@SupportsStreamedResult
+public class ErrorBounce extends AbstractDispatchLayer<JsonNode> implements
+		PropertyContributingDispatchLayer<JsonNode> {
+	public static final String URI = "http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/ErrorBounce";
+
+	/**
+	 * Track the number of reflected and translated errors handled by this error
+	 * bounce instance
+	 */
+	private Map<String, ErrorBounceState> state = new ConcurrentHashMap<>();
+
+	private int totalTranslatedErrors = 0;
+	private int totalReflectedErrors = 0;
+
+	private synchronized ErrorBounceState getState(String owningProcess) {
+		if (state.containsKey(owningProcess))
+			return state.get(owningProcess);
+		ErrorBounceState ebs = new ErrorBounceState();
+		state.put(owningProcess, ebs);
+		return ebs;
+	}
+
+	/**
+	 * If the job contains errors, or collections which contain errors
+	 * themselves then bounce a result message with error documents in back up
+	 * to the layer above
+	 */
+	@Override
+	public void receiveJob(DispatchJobEvent jobEvent) {
+		Set<T2Reference> errorReferences = new HashSet<>();
+		for (T2Reference ei : jobEvent.getData().values())
+			if (ei.containsErrors())
+				errorReferences.add(ei);
+		if (errorReferences.isEmpty())
+			// relay the message down...
+			getBelow().receiveJob(jobEvent);
+		else {
+			getState(jobEvent.getOwningProcess()).incrementErrorsReflected();
+			sendErrorOutput(jobEvent, null, errorReferences);
+		}
+	}
+
+	/**
+	 * Always send the error document job result on receiving a failure, at
+	 * least for now! This should be configurable, in effect this is the part
+	 * that ensures the processor never sees a top level failure.
+	 */
+	@Override
+	public void receiveError(DispatchErrorEvent errorEvent) {
+		getState(errorEvent.getOwningProcess()).incrementErrorsTranslated();
+		sendErrorOutput(errorEvent, errorEvent.getCause(), null);
+	}
+
+	/**
+	 * Construct and send a new result message with error documents in place of
+	 * all outputs at the appropriate depth
+	 * 
+	 * @param event
+	 * @param cause
+	 * @param errorReferences
+	 */
+	private void sendErrorOutput(Event<?> event, Throwable cause,
+			Set<T2Reference> errorReferences) {
+		ReferenceService rs = event.getContext().getReferenceService();
+
+		Processor p = dispatchStack.getProcessor();
+		Map<String, T2Reference> outputDataMap = new HashMap<>();
+		String[] owningProcessArray = event.getOwningProcess().split(":");
+		String processor = owningProcessArray[owningProcessArray.length - 1];
+		for (OutputPort op : p.getOutputPorts()) {
+			String message = "Processor '" + processor + "' - Port '"
+					+ op.getName() + "'";
+			if (event instanceof DispatchErrorEvent)
+				message += ": " + ((DispatchErrorEvent) event).getMessage();
+			ErrorDocument ed;
+			if (cause != null)
+				ed = rs.getErrorDocumentService().registerError(message, cause,
+						op.getDepth(), event.getContext());
+			else
+				ed = rs.getErrorDocumentService().registerError(message,
+						errorReferences, op.getDepth(), event.getContext());
+			outputDataMap.put(op.getName(), ed.getId());
+		}
+		DispatchResultEvent dre = new DispatchResultEvent(
+				event.getOwningProcess(), event.getIndex(), event.getContext(),
+				outputDataMap, false);
+		getAbove().receiveResult(dre);
+	}
+
+	@Override
+	public void configure(JsonNode config) {
+		// Do nothing - no configuration required
+	}
+
+	@Override
+	public JsonNode getConfiguration() {
+		// Layer has no configuration associated
+		return null;
+	}
+
+	@Override
+	public void finishedWith(final String owningProcess) {
+		/*
+		 * Delay the removal of the state to give the monitor a chance to poll
+		 */
+		cleanupTimer.schedule(new TimerTask() {
+			@Override
+			public void run() {
+				state.remove(owningProcess);
+			}
+		}, CLEANUP_DELAY_MS);
+	}
+
+	/**
+	 * Two properties, dispatch.errorbounce.reflected(integer) is the number of
+	 * incoming jobs which have been bounced back as results with errors,
+	 * dispatch.errorbounce.translated(integer) is the number of failures from
+	 * downstream in the stack that have been re-written as complete results
+	 * containing error documents.
+	 */
+	@Override
+	public void injectPropertiesFor(final String owningProcess) {
+		MonitorableProperty<Integer> errorsReflectedProperty = new MonitorableProperty<Integer>() {
+			@Override
+			public Date getLastModified() {
+				return new Date();
+			}
+
+			@Override
+			public String[] getName() {
+				return new String[] { "dispatch", "errorbounce", "reflected" };
+			}
+
+			@Override
+			public Integer getValue() throws NoSuchPropertyException {
+				ErrorBounceState ebs = state.get(owningProcess);
+				if (ebs == null)
+					return 0;
+				return ebs.getErrorsReflected();
+			}
+		};
+		dispatchStack.receiveMonitorableProperty(errorsReflectedProperty,
+				owningProcess);
+
+		MonitorableProperty<Integer> errorsTranslatedProperty = new MonitorableProperty<Integer>() {
+			@Override
+			public Date getLastModified() {
+				return new Date();
+			}
+
+			@Override
+			public String[] getName() {
+				return new String[] { "dispatch", "errorbounce", "translated" };
+			}
+
+			@Override
+			public Integer getValue() throws NoSuchPropertyException {
+				ErrorBounceState ebs = state.get(owningProcess);
+				if (ebs == null)
+					return 0;
+				return ebs.getErrorsTranslated();
+			}
+		};
+		dispatchStack.receiveMonitorableProperty(errorsTranslatedProperty,
+				owningProcess);
+
+		MonitorableProperty<Integer> totalTranslatedTranslatedProperty = new MonitorableProperty<Integer>() {
+			@Override
+			public Date getLastModified() {
+				return new Date();
+			}
+
+			@Override
+			public String[] getName() {
+				return new String[] { "dispatch", "errorbounce",
+						"totalTranslated" };
+			}
+
+			@Override
+			public Integer getValue() throws NoSuchPropertyException {
+				return totalTranslatedErrors;
+			}
+		};
+		dispatchStack.receiveMonitorableProperty(
+				totalTranslatedTranslatedProperty, owningProcess);
+
+		MonitorableProperty<Integer> totalReflectedTranslatedProperty = new MonitorableProperty<Integer>() {
+			@Override
+			public Date getLastModified() {
+				return new Date();
+			}
+
+			@Override
+			public String[] getName() {
+				return new String[] { "dispatch", "errorbounce",
+						"totalReflected" };
+			}
+
+			@Override
+			public Integer getValue() throws NoSuchPropertyException {
+				return totalReflectedErrors;
+			}
+		};
+		dispatchStack.receiveMonitorableProperty(
+				totalReflectedTranslatedProperty, owningProcess);
+	}
+
+	public class ErrorBounceState {
+		private int errorsReflected = 0;
+		private int errorsTranslated = 0;
+
+		/**
+		 * Number of times the bounce layer has converted an incoming job event
+		 * where the input data contained error tokens into a result event
+		 * containing all errors.
+		 */
+		int getErrorsReflected() {
+			return this.errorsReflected;
+		}
+
+		/**
+		 * Number of times the bounce layer has converted an incoming failure
+		 * event into a result containing error tokens
+		 */
+		int getErrorsTranslated() {
+			return errorsTranslated;
+		}
+
+		void incrementErrorsReflected() {
+			synchronized (this) {
+				errorsReflected++;
+			}
+			synchronized (ErrorBounce.this) {
+				totalReflectedErrors++;
+			}
+		}
+
+		void incrementErrorsTranslated() {
+			synchronized (this) {
+				errorsTranslated++;
+			}
+			synchronized (ErrorBounce.this) {
+				totalTranslatedErrors++;
+			}
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Failover.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Failover.java b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Failover.java
new file mode 100644
index 0000000..9fe0d6c
--- /dev/null
+++ b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/Failover.java
@@ -0,0 +1,110 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.layers;
+
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.CREATE_LOCAL_STATE;
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.REMOVE_LOCAL_STATE;
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.UPDATE_LOCAL_STATE;
+import static org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchMessageType.JOB;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+import org.apache.taverna.workflowmodel.processor.dispatch.AbstractErrorHandlerLayer;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerErrorReaction;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerJobReaction;
+import org.apache.taverna.workflowmodel.processor.dispatch.description.DispatchLayerResultReaction;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchJobEvent;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * Failure handling dispatch layer, consumes job events with multiple activities
+ * and emits the same job but with only the first activity. On failures the job
+ * is resent to the layer below with a new activity list containing the second
+ * in the original list and so on. If a failure is received and there are no
+ * further activities to use the job fails and the failure is sent back up to
+ * the layer above.
+ * 
+ * @author Tom Oinn
+ * @author Stian Soiland-Reyes
+ */
+@DispatchLayerErrorReaction(emits = { JOB }, relaysUnmodified = true, stateEffects = {
+		UPDATE_LOCAL_STATE, REMOVE_LOCAL_STATE })
+@DispatchLayerJobReaction(emits = {}, relaysUnmodified = true, stateEffects = { CREATE_LOCAL_STATE })
+@DispatchLayerResultReaction(emits = {}, relaysUnmodified = true, stateEffects = { REMOVE_LOCAL_STATE })
+public class Failover extends AbstractErrorHandlerLayer<JsonNode> {
+	public static final String URI = "http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/Failover";
+
+	@Override
+	protected JobState getStateObject(DispatchJobEvent jobEvent) {
+		return new FailoverState(jobEvent);
+	}
+
+	/**
+	 * Receive a job from the layer above, store it in the state map then relay
+	 * it to the layer below with a modified activity list containing only the
+	 * activity at index 0
+	 */
+	@Override
+	public void receiveJob(DispatchJobEvent jobEvent) {
+		addJobToStateList(jobEvent);
+		List<Activity<?>> newActivityList = new ArrayList<>();
+		newActivityList.add(jobEvent.getActivities().get(0));
+		getBelow().receiveJob(
+				new DispatchJobEvent(jobEvent.getOwningProcess(), jobEvent
+						.getIndex(), jobEvent.getContext(), jobEvent.getData(),
+						newActivityList));
+	}
+
+	class FailoverState extends JobState {
+		int currentActivityIndex = 0;
+
+		public FailoverState(DispatchJobEvent jobEvent) {
+			super(jobEvent);
+		}
+
+		@Override
+		public boolean handleError() {
+			currentActivityIndex++;
+			if (currentActivityIndex == jobEvent.getActivities().size())
+				return false;
+			List<Activity<?>> newActivityList = new ArrayList<>();
+			newActivityList.add(jobEvent.getActivities().get(
+					currentActivityIndex));
+			getBelow().receiveJob(
+					new DispatchJobEvent(jobEvent.getOwningProcess(), jobEvent
+							.getIndex(), jobEvent.getContext(), jobEvent
+							.getData(), newActivityList));
+			return true;
+		}
+	}
+
+	@Override
+	public void configure(JsonNode config) {
+		// Do nothing - there is no configuration to do
+	}
+
+	@Override
+	public JsonNode getConfiguration() {
+		return null;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/IntermediateProvenance.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/IntermediateProvenance.java b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/IntermediateProvenance.java
new file mode 100644
index 0000000..c4b0fb3
--- /dev/null
+++ b/taverna-workflowmodel-extensions/src/main/java/org/apache/taverna/workflowmodel/processor/dispatch/layers/IntermediateProvenance.java
@@ -0,0 +1,507 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.dispatch.layers;
+
+import static java.lang.System.currentTimeMillis;
+
+import java.beans.XMLDecoder;
+import java.beans.XMLEncoder;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.taverna.invocation.Event;
+import org.apache.taverna.provenance.item.ActivityProvenanceItem;
+import org.apache.taverna.provenance.item.ErrorProvenanceItem;
+import org.apache.taverna.provenance.item.InputDataProvenanceItem;
+import org.apache.taverna.provenance.item.IterationProvenanceItem;
+import org.apache.taverna.provenance.item.OutputDataProvenanceItem;
+import org.apache.taverna.provenance.item.ProcessProvenanceItem;
+import org.apache.taverna.provenance.item.ProcessorProvenanceItem;
+import org.apache.taverna.provenance.item.ProvenanceItem;
+import org.apache.taverna.provenance.item.WorkflowProvenanceItem;
+import org.apache.taverna.provenance.reporter.ProvenanceReporter;
+import org.apache.taverna.reference.ReferenceService;
+import org.apache.taverna.workflowmodel.Dataflow;
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+import org.apache.taverna.workflowmodel.processor.activity.AsynchronousActivity;
+import org.apache.taverna.workflowmodel.processor.dispatch.AbstractDispatchLayer;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchCompletionEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchErrorEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchJobEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchJobQueueEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchResultEvent;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Sits above the {@link Invoke} layer and collects information about the
+ * current workflow run to be stored by the {@link ProvenanceConnector}.
+ * 
+ * @author Ian Dunlop
+ * @author Stian Soiland-Reyes
+ * 
+ */
+public class IntermediateProvenance extends AbstractDispatchLayer<String> {
+	public static final String URI = "http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/IntermediateProvenance";
+	private static final Logger logger = Logger.getLogger(IntermediateProvenance.class);
+
+	private ProvenanceReporter reporter;
+	private Map<String, Map<String, IterationProvenanceItem>> processToIndexes = new HashMap<>();
+	private Map<ActivityProvenanceItem, List<Object>> activityProvenanceItemMap = new HashMap<>();
+	private Map<InputDataProvenanceItem, List<Object>> inputDataProvenanceItemMap = new HashMap<>();
+
+	// private List<ActivityProvenanceItem> activityProvenanceItemList = new ArrayList<>();
+	// private List<InputDataProvenanceItem> inputDataProvenanceItemList = new ArrayList<>();
+
+	private WorkflowProvenanceItem workflowItem;
+
+	@Override
+	public void configure(String o) {
+	}
+
+	/**
+	 * A set of provenance events for a particular owning process has been
+	 * finished with so you can remove all the {@link IterationProvenanceItem}s
+	 * from the map
+	 */
+	@Override
+	public void finishedWith(String owningProcess) {
+		processToIndexes.remove(owningProcess);
+	}
+
+	@Override
+	public String getConfiguration() {
+		return null;
+	}
+
+	protected Map<String, IterationProvenanceItem> getIndexesByProcess(
+			String owningProcess) {
+		synchronized (processToIndexes) {
+			Map<String, IterationProvenanceItem> indexes = processToIndexes
+					.get(owningProcess);
+			if (indexes == null) {
+				indexes = new HashMap<>();
+				processToIndexes.put(owningProcess, indexes);
+			}
+			return indexes;
+		}
+	}
+
+	protected IterationProvenanceItem getIterationProvItem(Event<?> event) {
+		String owningProcess = event.getOwningProcess();
+		int[] originalIndex = event.getIndex();
+		int[] index = event.getIndex();
+		String indexStr = indexStr(index);
+		Map<String, IterationProvenanceItem> indexes = getIndexesByProcess(owningProcess);
+		IterationProvenanceItem iterationProvenanceItem = null;
+		synchronized (indexes) {
+			// find the iteration item for the int index eg [1]
+			iterationProvenanceItem = indexes.get(indexStr);
+			// if it is null then strip the index and look again
+
+			while (iterationProvenanceItem == null) {
+				try {
+					index = removeLastIndex(index);
+					iterationProvenanceItem = indexes.get(indexStr(index));
+					/*
+					 * if we have a 'parent' iteration then create a new
+					 * iteration for the original index and link it to the
+					 * activity and the input data
+					 * 
+					 * FIXME should this be linked to the parent iteration
+					 * instead?
+					 */
+					if (iterationProvenanceItem != null) {
+						// set the index to the one from the event
+						IterationProvenanceItem iterationProvenanceItem1 = new IterationProvenanceItem();
+						iterationProvenanceItem1.setIteration(originalIndex);
+						iterationProvenanceItem1.setProcessId(owningProcess);
+						iterationProvenanceItem1.setIdentifier(UUID
+								.randomUUID().toString());
+						iterationProvenanceItem1.setWorkflowId(workflowItem.getParentId());
+						iterationProvenanceItem1.setParentIterationItem(iterationProvenanceItem);
+						iterationProvenanceItem1.setParentId(iterationProvenanceItem.getParentId());
+						iterationProvenanceItem1.setInputDataItem(iterationProvenanceItem.getInputDataItem());
+
+//						for (Entry<ActivityProvenanceItem, List<Object>> entrySet : activityProvenanceItemMap
+//								.entrySet()) {
+//							List<Object> value = entrySet.getValue();
+//							int[] newIndex = (int[]) value.get(0);
+//							String owner = (String) value.get(1);
+//							String indexString = indexStr(newIndex);
+//							String indexString2 = indexStr(index);
+//
+//							if (owningProcess.equalsIgnoreCase(owner)
+//									&& indexString
+//											.equalsIgnoreCase(indexString2))
+//								iterationProvenanceItem1.setParentId(entrySet
+//										.getKey().getIdentifier());
+//						}
+//						for (Entry<InputDataProvenanceItem, List<Object>> entrySet : inputDataProvenanceItemMap
+//								.entrySet()) {
+//							List<Object> value = entrySet.getValue();
+//							int[] newIndex = (int[]) value.get(0);
+//							String owner = (String) value.get(1);
+//							String indexString = indexStr(newIndex);
+//							String indexString2 = indexStr(index);
+//							if (owningProcess.equalsIgnoreCase(owner)
+//									&& indexString
+//											.equalsIgnoreCase(indexString2))
+//								iterationProvenanceItem1
+//										.setInputDataItem(entrySet.getKey());
+//						}
+
+						// for (ActivityProvenanceItem item :
+						// activityProvenanceItemList) {
+						// if (owningProcess.equalsIgnoreCase(item
+						// .getProcessId())) {
+						// iterationProvenanceItem1.setParentId(item
+						// .getIdentifier());
+						// }
+						// }
+						// for (InputDataProvenanceItem item :
+						// inputDataProvenanceItemList) {
+						// if (owningProcess.equalsIgnoreCase(item
+						// .getProcessId())) {
+						// iterationProvenanceItem1.setInputDataItem(item);
+						// }
+						// indexes.put(indexStr, iterationProvenanceItem1);
+						// return iterationProvenanceItem1;
+						// // }
+						// }
+
+						// add this new iteration item to the map
+						getIndexesByProcess(event.getOwningProcess()).put(
+								indexStr(event.getIndex()),
+								iterationProvenanceItem1);
+						return iterationProvenanceItem1;
+					}
+					/*
+					 * if we have not found an iteration items and the index is
+					 * [] then something is wrong remove the last index in the
+					 * int array before we go back through the while
+					 */
+				} catch (IllegalStateException e) {
+					logger
+							.warn("Cannot find a parent iteration with index [] for owning process: "
+									+ owningProcess
+									+ "Workflow invocation is in an illegal state");
+					throw e;
+				}
+			}
+
+			// if (iterationProvenanceItem == null) {
+			// logger.info("Iteration item was null for: "
+			// + event.getOwningProcess() + " " + event.getIndex());
+			// System.out.println("Iteration item was null for: "
+			// + event.getOwningProcess() + " " + event.getIndex());
+			// iterationProvenanceItem = new IterationProvenanceItem(index);
+			// iterationProvenanceItem.setProcessId(owningProcess);
+			// iterationProvenanceItem.setIdentifier(UUID.randomUUID()
+			// .toString());
+			// // for (ActivityProvenanceItem
+			// item:activityProvenanceItemList)
+			// // {
+			// // if (owningProcess.equalsIgnoreCase(item.getProcessId())) {
+			// // iterationProvenanceItem.setParentId(item.getIdentifier());
+			// // }
+			// // }
+			// // for (InputDataProvenanceItem item:
+			// // inputDataProvenanceItemList) {
+			// // if (owningProcess.equalsIgnoreCase(item.getProcessId())) {
+			// // iterationProvenanceItem.setInputDataItem(item);
+			// // }
+			// // }
+			// indexes.put(indexStr, iterationProvenanceItem);
+
+		}
+		return iterationProvenanceItem;
+	}
+
+	private String indexStr(int[] index) {
+		StringBuilder indexStr = new StringBuilder();
+		for (int ind : index)
+			indexStr.append(":").append(ind);
+		return indexStr.toString();
+	}
+
+	/**
+	 * Remove the last index of the int array in the form 1:2:3 etc
+	 * 
+	 * @param index
+	 * @return
+	 */
+	@SuppressWarnings("unused")
+	private String[] stripLastIndex(int[] index) {
+		// will be in form :1:2:3
+		return indexStr(index).split(":");
+	}
+
+	/**
+	 * Remove the last value in the int array
+	 * 
+	 * @param index
+	 * @return
+	 */
+	private int[] removeLastIndex(int[] index) {
+		if (index.length == 0)
+			throw new IllegalStateException(
+					"There is no parent iteration of index [] for this result");
+		int[] newIntArray = new int[index.length - 1];
+		for (int i = 0; i < index.length - 1; i++)
+			newIntArray[i] = index[i];
+		return newIntArray;
+	}
+
+	private static String uuid() {
+		return UUID.randomUUID().toString();
+	}
+
+	/**
+	 * Create an {@link ErrorProvenanceItem} and send across to the
+	 * {@link ProvenanceConnector}
+	 */
+	@Override
+	public void receiveError(DispatchErrorEvent errorEvent) {
+		IterationProvenanceItem iterationProvItem = getIterationProvItem(errorEvent);
+		// get using errorEvent.getOwningProcess();
+		
+		ErrorProvenanceItem errorItem = new ErrorProvenanceItem();
+		errorItem.setCause(errorEvent
+				.getCause());
+		errorItem.setErrorType(errorEvent
+				.getFailureType().toString());
+		errorItem.setMessage(errorEvent.getMessage());
+		
+		errorItem.setProcessId(errorEvent.getOwningProcess());
+		errorItem.setIdentifier(uuid());
+		errorItem.setParentId(iterationProvItem.getIdentifier());
+		// iterationProvItem.setErrorItem(errorItem);
+		// FIXME don't need to add to the processor item earlier
+		getReporter().addProvenanceItem(errorItem);
+		super.receiveError(errorEvent);
+	}
+
+	/**
+	 * Create the {@link ProvenanceItem}s and send them all across to the
+	 * {@link ProvenanceConnector} except for the
+	 * {@link IterationProvenanceItem}, this one is told what it's inputs are
+	 * but has to wait until the results are received before being sent across.
+	 * Each item has a unique identifier and also knows who its parent item is
+	 */
+	@Override
+	public void receiveJob(DispatchJobEvent jobEvent) {
+			try {
+			// FIXME do we need this ProcessProvenanceItem?
+			ProcessProvenanceItem provenanceItem;
+			String[] split = jobEvent.getOwningProcess().split(":");
+			provenanceItem = new ProcessProvenanceItem();
+			String parentDataflowId = workflowItem.getParentId();
+			provenanceItem.setWorkflowId(parentDataflowId);
+			provenanceItem.setFacadeID(split[0]);
+			provenanceItem.setDataflowID(split[1]);
+			provenanceItem.setProcessId(jobEvent.getOwningProcess());
+			provenanceItem.setIdentifier(uuid());
+			provenanceItem.setParentId(workflowItem.getIdentifier());
+			ProcessorProvenanceItem processorProvItem;
+			processorProvItem = new ProcessorProvenanceItem();
+			processorProvItem.setWorkflowId(parentDataflowId);
+			processorProvItem.setProcessId(jobEvent
+					.getOwningProcess());
+			processorProvItem.setIdentifier(uuid());
+			processorProvItem.setParentId(provenanceItem.getIdentifier());
+			provenanceItem.setProcessId(jobEvent.getOwningProcess());
+			getReporter().addProvenanceItem(provenanceItem);
+			getReporter().addProvenanceItem(processorProvItem);
+	
+			IterationProvenanceItem iterationProvItem = null;
+			iterationProvItem = new IterationProvenanceItem();
+			iterationProvItem.setWorkflowId(parentDataflowId);
+			iterationProvItem.setIteration(jobEvent.getIndex());
+			iterationProvItem.setIdentifier(uuid());
+			
+			ReferenceService referenceService = jobEvent.getContext()
+					.getReferenceService();
+	
+			InputDataProvenanceItem inputDataItem = new InputDataProvenanceItem();
+			inputDataItem.setDataMap(jobEvent.getData());
+			inputDataItem.setReferenceService(referenceService);
+			inputDataItem.setIdentifier(uuid());
+			inputDataItem.setParentId(iterationProvItem.getIdentifier());
+			inputDataItem.setProcessId(jobEvent.getOwningProcess());
+	
+			List<Object> inputIndexOwnerList = new ArrayList<>();
+			inputIndexOwnerList.add(jobEvent.getIndex());
+			inputIndexOwnerList.add(jobEvent.getOwningProcess());
+			inputDataProvenanceItemMap.put(inputDataItem, inputIndexOwnerList);
+	
+			// inputDataProvenanceItemList.add(inputDataItem);
+			iterationProvItem.setInputDataItem(inputDataItem);
+			iterationProvItem.setIteration(jobEvent.getIndex());
+			iterationProvItem.setProcessId(jobEvent.getOwningProcess());
+	
+			for (Activity<?> activity : jobEvent.getActivities())
+				if (activity instanceof AsynchronousActivity) {
+					ActivityProvenanceItem activityProvItem = new ActivityProvenanceItem();
+					activityProvItem.setWorkflowId(parentDataflowId);
+					activityProvItem.setIdentifier(uuid());
+					iterationProvItem.setParentId(activityProvItem.getIdentifier());
+					// getConnector().addProvenanceItem(iterationProvItem);
+					activityProvItem.setParentId(processorProvItem.getIdentifier());
+					// processorProvItem.setActivityProvenanceItem(activityProvItem);
+					activityProvItem.setProcessId(jobEvent.getOwningProcess());
+					List<Object> activityIndexOwnerList = new ArrayList<>();
+					activityIndexOwnerList.add(jobEvent.getOwningProcess());
+					activityIndexOwnerList.add(jobEvent.getIndex());
+					activityProvenanceItemMap.put(activityProvItem,
+							inputIndexOwnerList);
+					// activityProvenanceItemList.add(activityProvItem);
+					// activityProvItem.setIterationProvenanceItem(iterationProvItem);
+					getReporter().addProvenanceItem(activityProvItem);
+					break;
+				}
+			getIndexesByProcess(jobEvent.getOwningProcess()).put(
+					indexStr(jobEvent.getIndex()), iterationProvItem);
+			iterationProvItem.setEnactmentStarted(new Timestamp(currentTimeMillis()));
+			getReporter().addProvenanceItem(iterationProvItem);
+		} catch (RuntimeException ex) {
+			logger.error("Could not store provenance for " + jobEvent, ex);
+		}
+		
+		super.receiveJob(jobEvent);
+	}
+
+	@Override
+	public void receiveJobQueue(DispatchJobQueueEvent jobQueueEvent) {
+		super.receiveJobQueue(jobQueueEvent);
+	}
+
+	/**
+	 * Populate an {@link OutputDataProvenanceItem} with the results and attach
+	 * it to the appropriate {@link IterationProvenanceItem}. Then send the
+	 * {@link IterationProvenanceItem} across to the {@link ProvenanceConnector}
+	 */
+	@Override
+	public void receiveResult(DispatchResultEvent resultEvent) {
+		try {
+			// FIXME use the connector from the result event context
+			IterationProvenanceItem iterationProvItem = getIterationProvItem(resultEvent);
+			iterationProvItem.setEnactmentEnded(new Timestamp(currentTimeMillis()));
+			
+			ReferenceService referenceService = resultEvent.getContext()
+					.getReferenceService();
+
+			OutputDataProvenanceItem outputDataItem = new OutputDataProvenanceItem();
+			outputDataItem.setDataMap(resultEvent.getData());
+			outputDataItem.setReferenceService(referenceService);
+			outputDataItem.setIdentifier(uuid());
+			outputDataItem.setProcessId(resultEvent.getOwningProcess());
+			outputDataItem.setParentId(iterationProvItem.getIdentifier());
+			iterationProvItem.setOutputDataItem(outputDataItem);
+			
+			getReporter().addProvenanceItem(iterationProvItem);
+			// getConnector().addProvenanceItem(outputDataItem);
+	
+			// PM -- testing
+			// add xencoding of data value here??
+	//		Map<String, T2Reference> inputDataMap = iterationProvItem.getInputDataItem().getDataMap();
+	//		for(Map.Entry<String, T2Reference> entry:inputDataMap.entrySet()) {
+	//			// create a simpler bean that we can serialize?
+	//			
+	//			T2Reference ref = entry.getValue();
+	//			
+	//			SimplerT2Reference t2RefBean = new SimplerT2Reference();
+	//			t2RefBean.setReferenceType(ref.getReferenceType());
+	//			t2RefBean.setDepth(ref.getDepth());
+	//			t2RefBean.setLocalPart(ref.getLocalPart());
+	//			t2RefBean.setNamespacePart(ref.getNamespacePart());
+	//						
+	//			System.out.println("data ref: "+ref);
+	//			String serializedInput = SerializeParam(t2RefBean);
+	//			System.out.println("serialized reference:" + serializedInput);
+	//			
+	//			System.out.println(referenceService.renderIdentifier(entry.getValue(), String.class, resultEvent.getContext()));
+//		}
+		} catch (Exception ex) {
+			logger.error("Could not store provenance for "
+					+ resultEvent.getOwningProcess() + " "
+					+ Arrays.toString(resultEvent.getIndex()), ex);
+			// But don't break super.receiveResult() !!
+		}
+		super.receiveResult(resultEvent);
+	}
+
+	@Override
+	public void receiveResultCompletion(DispatchCompletionEvent completionEvent) {
+		super.receiveResultCompletion(completionEvent);
+	}
+
+	/**
+	 * Tell this layer what {@link ProvenanceConnector} implementation is being
+	 * used to capture the {@link ProvenanceItem}s. NOTE: should probably use
+	 * the connector from the result events context where possible
+	 * 
+	 * @param connector
+	 */
+	public void setReporter(ProvenanceReporter connector) {
+		this.reporter = connector;
+	}
+
+	public ProvenanceReporter getReporter() {
+		return reporter;
+	}
+
+	/**
+	 * So that the {@link ProvenanceItem}s know which {@link Dataflow} has been
+	 * enacted this layer has to know about the {@link WorkflowProvenanceItem}
+	 * 
+	 * @param workflowItem
+	 */
+	public void setWorkflow(WorkflowProvenanceItem workflowItem) {
+		this.workflowItem = workflowItem;
+	}
+
+	// TODO is this unused?
+	public static String SerializeParam(Object ParamValue) {
+		ByteArrayOutputStream BStream = new ByteArrayOutputStream();
+		XMLEncoder encoder = new XMLEncoder(BStream);
+		encoder.writeObject(ParamValue);
+		encoder.close();
+		return BStream.toString();
+	}
+
+	// TODO is this unused?
+	public static Object DeserializeParam(String SerializedParam) {
+		InputStream IStream = new ByteArrayInputStream(
+				SerializedParam.getBytes());
+		XMLDecoder decoder = new XMLDecoder(IStream);
+		Object output = decoder.readObject();
+		decoder.close();
+		return output;
+	}
+}


[28/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/RunProfile.java
----------------------------------------------------------------------
diff --git a/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/RunProfile.java b/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/RunProfile.java
deleted file mode 100644
index deecf8e..0000000
--- a/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/RunProfile.java
+++ /dev/null
@@ -1,196 +0,0 @@
-package uk.org.taverna.platform.run.api;
-
-import org.apache.taverna.robundle.Bundle;
-
-import uk.org.taverna.platform.execution.api.ExecutionEnvironment;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-
-/**
- * A <code>RunProfile</code> specifies the parameters required to run a
- * {@link org.apache.taverna.scufl2.api.core.Workflow}.
- * 
- * @author David Withers
- */
-public class RunProfile {
-	private ExecutionEnvironment executionEnvironment;
-	private WorkflowBundle workflowBundle;
-	private Bundle dataBundle;
-	private String workflowName;
-	private String profileName;
-
-	/**
-	 * Constructs a <code>RunProfile</code> that specifies the parameters
-	 * required to run a {@link org.apache.taverna.scufl2.api.core.Workflow}. The
-	 * main <code>Workflow</code> and <code>Profile</code> from the
-	 * <code>WorkflowBundle</code> are used.
-	 * 
-	 * @param executionEnvironment
-	 *            the {@link ExecutionEnvironment} used to execute the
-	 *            <code>Workflow</code>
-	 * @param workflowBundle
-	 *            the <code>WorkflowBundle</code> containing the
-	 *            <code>Workflow</code> to run
-	 * @param dataBundle
-	 *            the <code>Bundle</code> containing the data values for the
-	 *            <code>Workflow</code>
-	 */
-	public RunProfile(ExecutionEnvironment executionEnvironment,
-			WorkflowBundle workflowBundle, Bundle dataBundle) {
-		this(executionEnvironment, workflowBundle, null, null, dataBundle);
-	}
-
-	/**
-	 * Constructs a <code>RunProfile</code> that specifies the parameters
-	 * required to run a {@link org.apache.taverna.scufl2.api.core.Workflow}.
-	 * 
-	 * @param executionEnvironment
-	 *            the {@link ExecutionEnvironment} used to execute the
-	 *            <code>Workflow</code>
-	 * @param workflowBundle
-	 *            the <code>WorkflowBundle</code> containing the
-	 *            <code>Workflow</code> to run
-	 * @param workflow
-	 *            the <code>Workflow</code> to run. If <code>null</code> uses
-	 *            the main <code>Workflow</code> from the
-	 *            <code>WorkflowBundle</code>
-	 * @param profile
-	 *            the {@link org.apache.taverna.scufl2.api.profiles.Profile} to use
-	 *            when running the <code>Workflow</code>. If null uses the main
-	 *            <code>Profile</code> from the <code>WorkflowBundle</code>
-	 * @param dataBundle
-	 *            the <code>Bundle</code> containing the data values for the
-	 *            <code>Workflow</code>
-	 */
-	public RunProfile(ExecutionEnvironment executionEnvironment,
-			WorkflowBundle workflowBundle, String workflowName,
-			String profileName, Bundle dataBundle) {
-		this.executionEnvironment = executionEnvironment;
-		this.workflowBundle = workflowBundle;
-		this.workflowName = workflowName;
-		this.profileName = profileName;
-		this.dataBundle = dataBundle;
-	}
-
-	/**
-	 * Returns the <code>WorkflowBundle</code>.
-	 * 
-	 * @return the <code>WorkflowBundle</code>
-	 */
-	public WorkflowBundle getWorkflowBundle() {
-		return workflowBundle;
-	}
-
-	/**
-	 * Sets the <code>WorkflowBundle</code> containing the <code>Workflow</code>
-	 * to run.
-	 * 
-	 * @param workflowBundle
-	 *            the <code>WorkflowBundle</code> containing the
-	 *            <code>Workflow</code> to run
-	 */
-	public void setWorkflowBundle(WorkflowBundle workflowBundle) {
-		this.workflowBundle = workflowBundle;
-	}
-
-	/**
-	 * Returns the name of the <code>Workflow</code> to run. If no
-	 * <code>Workflow</code> name is set the main <code>Workflow</code> from the
-	 * <code>WorkflowBundle</code> will be run.
-	 * 
-	 * @return the <code>Workflow</code> to run
-	 */
-	public String getWorkflowName() {
-		if (workflowName == null && workflowBundle.getMainWorkflow() != null)
-			return workflowBundle.getMainWorkflow().getName();
-		return workflowName;
-	}
-
-	/**
-	 * Sets the name of the <code>Workflow</code> to run. If no
-	 * <code>Workflow</code> name is set the main <code>Workflow</code> from the
-	 * <code>WorkflowBundle</code> will be run.
-	 * 
-	 * @param workflowName
-	 *            the name of the <code>Workflow</code> to run
-	 */
-	public void setWorkflowName(String workflowName) {
-		this.workflowName = workflowName;
-	}
-
-	/**
-	 * Returns the name of the <code>Profile</code> to use when running the
-	 * <code>Workflow</code>. If no <code>Profile</code> name is set the main
-	 * <code>Profile</code> from the <code>WorkflowBundle</code> will be used.
-	 * 
-	 * @return the <code>Profile</code> to use when running the
-	 *         <code>Workflow</code>
-	 */
-	public String getProfileName() {
-		if (profileName == null && workflowBundle.getMainProfile() != null) {
-			return workflowBundle.getMainProfile().getName();
-		}
-		return profileName;
-	}
-
-	/**
-	 * Sets the name of the <code>Profile</code> to use when running the
-	 * <code>Workflow</code>.
-	 * <p>
-	 * If no <code>Profile</code> name is set the main <code>Profile</code> from
-	 * the <code>WorkflowBundle</code> will be used.
-	 * 
-	 * @param profileName
-	 *            the name of the <code>Profile</code> to use when running the
-	 *            <code>Workflow</code>
-	 */
-	public void setProfileName(String profileName) {
-		this.profileName = profileName;
-	}
-
-	/**
-	 * Returns the <code>Bundle</code> containing the data values for the
-	 * <code>Workflow</code>.
-	 * 
-	 * @return the <code>Bundle</code> containing the data values for the
-	 *         <code>Workflow</code>
-	 */
-	public Bundle getDataBundle() {
-		return dataBundle;
-	}
-
-	/**
-	 * Sets the <code>Bundle</code> containing the data values for the
-	 * <code>Workflow</code>.
-	 * 
-	 * @param dataBundle
-	 *            the <code>Bundle</code> containing the data values for the
-	 *            <code>Workflow</code>
-	 */
-	public void setDataBundle(Bundle dataBundle) {
-		this.dataBundle = dataBundle;
-	}
-
-	/**
-	 * Returns the <code>ExecutionEnvironment</code> used to execute the
-	 * <code>Workflow</code>.
-	 * 
-	 * @return the <code>ExecutionEnvironment</code> used to execute the
-	 *         <code>Workflow</code>
-	 */
-	public ExecutionEnvironment getExecutionEnvironment() {
-		return executionEnvironment;
-	}
-
-	/**
-	 * Sets the <code>ExecutionEnvironment</code> used to execute the
-	 * <code>Workflow</code>.
-	 * 
-	 * @param executionEnvironment
-	 *            the <code>ExecutionEnvironment</code> used to execute the
-	 *            <code>Workflow</code>
-	 */
-	public void setExecutionEnvironment(
-			ExecutionEnvironment executionEnvironment) {
-		this.executionEnvironment = executionEnvironment;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/RunProfileException.java
----------------------------------------------------------------------
diff --git a/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/RunProfileException.java b/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/RunProfileException.java
deleted file mode 100644
index c6477d3..0000000
--- a/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/RunProfileException.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.run.api;
-
-/**
- * Thrown when a <code>RunProfile</code> doesn't contain the correct components
- * to run a workflow.
- * 
- * @author David Withers
- */
-public class RunProfileException extends Exception {
-	private static final long serialVersionUID = 4717267498382223527L;
-
-	public RunProfileException() {
-		super();
-	}
-
-	public RunProfileException(String message, Throwable cause) {
-		super(message, cause);
-	}
-
-	public RunProfileException(String message) {
-		super(message);
-	}
-
-	public RunProfileException(Throwable cause) {
-		super(cause);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/RunService.java
----------------------------------------------------------------------
diff --git a/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/RunService.java b/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/RunService.java
deleted file mode 100644
index 03705d7..0000000
--- a/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/RunService.java
+++ /dev/null
@@ -1,235 +0,0 @@
-package uk.org.taverna.platform.run.api;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.taverna.robundle.Bundle;
-
-import uk.org.taverna.platform.execution.api.ExecutionEnvironment;
-import uk.org.taverna.platform.execution.api.InvalidExecutionIdException;
-import uk.org.taverna.platform.execution.api.InvalidWorkflowException;
-import uk.org.taverna.platform.report.State;
-import uk.org.taverna.platform.report.WorkflowReport;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/**
- * Service for managing runs of Taverna workflows.
- * 
- * @author David Withers
- */
-public interface RunService {
-	String EVENT_TOPIC_ROOT = "uk/org/taverna/platform/run/RunService/";
-	String RUN_CREATED = EVENT_TOPIC_ROOT + "RUN_CREATED";
-	String RUN_DELETED = EVENT_TOPIC_ROOT + "RUN_DELETED";
-	String RUN_STARTED = EVENT_TOPIC_ROOT + "RUN_STARTED";
-	String RUN_STOPPED = EVENT_TOPIC_ROOT + "RUN_STOPPED";
-	String RUN_PAUSED = EVENT_TOPIC_ROOT + "RUN_PAUSED";
-	String RUN_RESUMED = EVENT_TOPIC_ROOT + "RUN_RESUMED";
-	String RUN_OPENED = EVENT_TOPIC_ROOT + "RUN_OPENED";
-	String RUN_CLOSED = EVENT_TOPIC_ROOT + "RUN_CLOSED";
-
-	/**
-	 * Returns the available <code>ExecutionEnvironment</code>s.
-	 * 
-	 * @return the available <code>ExecutionEnvironment</code>s
-	 */
-	Set<ExecutionEnvironment> getExecutionEnvironments();
-
-	/**
-	 * Returns the <code>ExecutionEnvironment</code>s that can execute the
-	 * specified <code>WorkflowBundle</code> using its default
-	 * <code>Profile</code>.
-	 * 
-	 * @param workflowBundle
-	 *            the <code>WorkflowBundle</code> to find
-	 *            <code>ExecutionEnvironment</code>s for
-	 * @return the <code>ExecutionEnvironment</code>s that can execute the
-	 *         specified <code>WorkflowBundle</code>
-	 */
-	Set<ExecutionEnvironment> getExecutionEnvironments(
-			WorkflowBundle workflowBundle);
-
-	/**
-	 * Returns the <code>ExecutionEnvironment</code>s that can execute the
-	 * specified <code>Profile</code>.
-	 * 
-	 * @param profile
-	 *            the <code>Profile</code> to find
-	 *            <code>ExecutionEnvironment</code>s for
-	 * @return the <code>ExecutionEnvironment</code>s that can execute the
-	 *         specified <code>Profile</code>
-	 */
-	Set<ExecutionEnvironment> getExecutionEnvironments(Profile profile);
-
-	/**
-	 * Creates a new run and returns the ID for the run.
-	 * 
-	 * To start the run use the {@link #start(String)} method.
-	 * 
-	 * @param runProfile
-	 *            the workflow to run
-	 * @return the run ID
-	 * @throws InvalidWorkflowException
-	 * @throws RunProfileException
-	 */
-	String createRun(RunProfile runProfile) throws InvalidWorkflowException,
-			RunProfileException;
-
-	/**
-	 * Returns the list of runs that this service is managing.
-	 * <p>
-	 * If there are no runs this method returns an empty list.
-	 * 
-	 * @return the list of runs that this service is managing
-	 */
-	List<String> getRuns();
-
-	/**
-	 * Opens a run and returns the ID for the run.
-	 * 
-	 * @param runFile
-	 *            the workflow run to open
-	 * @return the run ID
-	 * @throws InvalidWorkflowException
-	 * @throws RunProfileException
-	 */
-	String open(File runFile) throws IOException;
-
-	/**
-	 * Closes a run.
-	 * 
-	 * @param runID
-	 *            the ID of the run
-	 * @throws InvalidRunIdException
-	 *             if the run ID is not valid
-	 * @throws InvalidExecutionIdException
-	 */
-	void close(String runID) throws InvalidRunIdException,
-			InvalidExecutionIdException;
-
-	/**
-	 * Saves a run.
-	 * 
-	 * @param runID
-	 *            the ID of the run
-	 * @throws InvalidRunIdException
-	 *             if the run ID is not valid
-	 * @throws InvalidExecutionIdException
-	 */
-	void save(String runID, File runFile) throws InvalidRunIdException,
-			IOException;
-
-	/**
-	 * Deletes a run.
-	 * 
-	 * @param runID
-	 *            the ID of the run
-	 * @throws InvalidRunIdException
-	 *             if the run ID is not valid
-	 * @throws InvalidExecutionIdException
-	 */
-	void delete(String runID) throws InvalidRunIdException,
-			InvalidExecutionIdException;
-
-	/**
-	 * Starts a run.
-	 * 
-	 * @param runID
-	 *            the ID of the run
-	 * @throws InvalidRunIdException
-	 *             if the run ID is not valid
-	 * @throws RunStateException
-	 *             if the run state is not CREATED
-	 * @throws InvalidExecutionIdException
-	 */
-	void start(String runID) throws InvalidRunIdException, RunStateException,
-			InvalidExecutionIdException;
-
-	/**
-	 * Pauses a running run.
-	 * 
-	 * @param runID
-	 *            the ID of the run
-	 * @throws InvalidRunIdException
-	 *             if the run ID is not valid
-	 * @throws RunStateException
-	 *             if the run state is not RUNNING
-	 * @throws InvalidExecutionIdException
-	 */
-	void pause(String runID) throws InvalidRunIdException, RunStateException,
-			InvalidExecutionIdException;
-
-	/**
-	 * Resumes a paused run.
-	 * 
-	 * @param runID
-	 *            the ID of the run
-	 * @throws InvalidRunIdException
-	 *             if the run ID is not valid
-	 * @throws RunStateException
-	 *             if the run state is not PAUSED
-	 * @throws InvalidExecutionIdException
-	 */
-	void resume(String runID) throws InvalidRunIdException, RunStateException,
-			InvalidExecutionIdException;
-
-	/**
-	 * Cancels a running or paused run.
-	 * 
-	 * @param runID
-	 *            the ID of the run
-	 * @throws InvalidRunIdException
-	 *             if the run ID is not valid
-	 * @throws RunStateException
-	 *             if the run state is not RUNNING or PAUSED
-	 * @throws InvalidExecutionIdException
-	 */
-	void cancel(String runID) throws InvalidRunIdException, RunStateException,
-			InvalidExecutionIdException;
-
-	/**
-	 * Returns the current state of the run.
-	 * 
-	 * A run's state can be CREATED, RUNNING, COMPLETED, PAUSED, CANCELLED or
-	 * FAILED.
-	 * 
-	 * @param runID
-	 *            the ID of the run
-	 * @return the current state of the run
-	 * @throws InvalidRunIdException
-	 *             if the run ID is not valid
-	 */
-	State getState(String runID) throws InvalidRunIdException;
-
-	/**
-	 * Returns the <code>Bundle</code> containing the data values of the run.
-	 * 
-	 * @param runID
-	 *            the ID of the run
-	 * @return the <code>Databundle</code> containing the data values of the run
-	 * @throws InvalidRunIdException
-	 *             if the run ID is not valid
-	 */
-	Bundle getDataBundle(String runID) throws InvalidRunIdException;
-
-	/**
-	 * Returns the status report for the run.
-	 * 
-	 * @param runID
-	 *            the ID of the run
-	 * @return the status report for the run
-	 * @throws InvalidRunIdException
-	 *             if the run ID is not valid
-	 */
-	WorkflowReport getWorkflowReport(String runID) throws InvalidRunIdException;
-
-	Workflow getWorkflow(String runID) throws InvalidRunIdException;
-
-	Profile getProfile(String runID) throws InvalidRunIdException;
-
-	String getRunName(String runID) throws InvalidRunIdException;
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/RunStateException.java
----------------------------------------------------------------------
diff --git a/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/RunStateException.java b/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/RunStateException.java
deleted file mode 100644
index 56cd032..0000000
--- a/taverna-run-api/src/main/java/uk/org/taverna/platform/run/api/RunStateException.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.run.api;
-
-/**
- * Thrown when an operation is attempted when a workflow is in the wrong state,
- * e.g., resuming a workflow that is not paused.
- * 
- * @author David Withers
- */
-public class RunStateException extends Exception {
-	private static final long serialVersionUID = 6759341273715906131L;
-
-	public RunStateException() {
-		super();
-	}
-
-	public RunStateException(String message, Throwable cause) {
-		super(message, cause);
-	}
-
-	public RunStateException(String message) {
-		super(message);
-	}
-
-	public RunStateException(Throwable cause) {
-		super(cause);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-api/src/test/java/org/apache/taverna/platform/run/api/RunProfileTest.java
----------------------------------------------------------------------
diff --git a/taverna-run-api/src/test/java/org/apache/taverna/platform/run/api/RunProfileTest.java b/taverna-run-api/src/test/java/org/apache/taverna/platform/run/api/RunProfileTest.java
new file mode 100644
index 0000000..4144eb6
--- /dev/null
+++ b/taverna-run-api/src/test/java/org/apache/taverna/platform/run/api/RunProfileTest.java
@@ -0,0 +1,232 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.run.api;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.apache.taverna.robundle.Bundle;
+
+import org.apache.taverna.databundle.DataBundles;
+import org.apache.taverna.platform.execution.api.ExecutionEnvironment;
+import org.apache.taverna.platform.execution.impl.local.LocalExecutionEnvironment;
+import org.apache.taverna.platform.execution.impl.local.LocalExecutionService;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+/**
+ *
+ *
+ * @author David Withers
+ */
+@Ignore
+public class RunProfileTest {
+
+	private RunProfile runProfile;
+	private ExecutionEnvironment executionEnvironment;
+	private WorkflowBundle workflowBundle;
+	private LocalExecutionService executionService;
+	private Workflow workflow, mainWorkflow;
+	private Profile profile, mainProfile;
+	private Bundle dataBundle;
+
+	/**
+	 * @throws java.lang.Exception
+	 */
+	@Before
+	public void setUp() throws Exception {
+		workflow = new Workflow();
+		mainWorkflow = new Workflow();
+		profile = new Profile();
+		mainProfile = new Profile();
+		workflowBundle = new WorkflowBundle();
+		workflowBundle.setMainProfile(mainProfile);
+		workflowBundle.setMainWorkflow(mainWorkflow);
+		executionService = new LocalExecutionService();
+		executionEnvironment = new LocalExecutionEnvironment(executionService, null, null);
+
+		dataBundle = DataBundles.createBundle();
+		runProfile = new RunProfile(executionEnvironment, workflowBundle, workflow.getName(), profile.getName(), dataBundle);
+	}
+
+	/**
+	 * Test method for
+	 * {@link uk.org.taverna.platform.run.api.RunProfile#RunProfile(org.apache.taverna.scufl2.api.container.WorkflowBundle, java.util.Map, org.apache.taverna.reference.ReferenceService, org.apache.taverna.platform.execution.api.ExecutionService)}
+	 * .
+	 */
+	@Test
+	public void testRunProfileWorkflowBundleMapOfStringT2ReferenceReferenceServiceExecutionService() {
+		runProfile = new RunProfile(executionEnvironment, workflowBundle, dataBundle);
+	}
+
+	/**
+	 * Test method for
+	 * {@link org.apache.taverna.platform.run.api.RunProfile#RunProfile(org.apache.taverna.scufl2.api.container.WorkflowBundle, org.apache.taverna.scufl2.api.core.Workflow, org.apache.taverna.scufl2.api.profiles.Profile, java.util.Map, org.apache.taverna.reference.ReferenceService, org.apache.taverna.platform.execution.api.ExecutionService)}
+	 * .
+	 */
+	@Test
+	public void testRunProfileWorkflowBundleWorkflowProfileMapOfStringT2ReferenceReferenceServiceExecutionService() {
+		runProfile = new RunProfile(executionEnvironment, workflowBundle, workflow.getName(), profile.getName(), dataBundle);
+	}
+
+	/**
+	 * Test method for
+	 * {@link org.apache.taverna.platform.run.api.RunProfile#getWorkflowBundle()}.
+	 */
+	@Test
+	public void testGetWorkflowBundle() {
+		assertNotNull(runProfile.getWorkflowBundle());
+		assertEquals(workflowBundle, runProfile.getWorkflowBundle());
+		assertEquals(runProfile.getWorkflowBundle(), runProfile.getWorkflowBundle());
+	}
+
+	/**
+	 * Test method for
+	 * {@link org.apache.taverna.platform.run.api.RunProfile#setWorkflowBundle(org.apache.taverna.scufl2.api.container.WorkflowBundle)}
+	 * .
+	 */
+	@Test
+	public void testSetWorkflowBundle() {
+		runProfile.setWorkflowBundle(null);
+		assertNull(runProfile.getWorkflowBundle());
+		runProfile.setWorkflowBundle(workflowBundle);
+		assertEquals(workflowBundle, runProfile.getWorkflowBundle());
+	}
+
+	/**
+	 * Test method for
+	 * {@link uk.org.taverna.platform.run.api.RunProfile#getWorkflow()}.
+	 */
+	@Test
+	public void testGetWorkflow() {
+		assertNotNull(runProfile.getWorkflowName());
+		assertEquals(workflow.getName(), runProfile.getWorkflowName());
+		assertEquals(runProfile.getWorkflowName(), runProfile.getWorkflowName());
+		runProfile.setWorkflowName(null);
+		assertNotNull(runProfile.getWorkflowName());
+		assertEquals(mainWorkflow.getName(), runProfile.getWorkflowName());
+	}
+
+	/**
+	 * Test method for
+	 * {@link uk.org.taverna.platform.run.api.RunProfile#setWorkflow(org.apache.taverna.scufl2.api.core.Workflow)}
+	 * .
+	 */
+	@Test
+	public void testSetWorkflow() {
+		runProfile.setWorkflowName(null);
+		assertNotNull(runProfile.getWorkflowName());
+		assertEquals(mainWorkflow.getName(), runProfile.getWorkflowName());
+		runProfile.setWorkflowBundle(new WorkflowBundle());
+		runProfile.setWorkflowName(null);
+		assertNull(runProfile.getWorkflowName());
+		runProfile.setWorkflowName(workflow.getName());
+		assertEquals(workflow.getName(), runProfile.getWorkflowName());
+		runProfile.setWorkflowName(mainWorkflow.getName());
+		assertEquals(mainWorkflow.getName(), runProfile.getWorkflowName());
+	}
+
+	/**
+	 * Test method for
+	 * {@link uk.org.taverna.platform.run.api.RunProfile#getProfile()}.
+	 */
+	@Test
+	public void testGetProfile() {
+		assertNotNull(runProfile.getProfileName());
+		assertEquals(profile.getName(), runProfile.getProfileName());
+		assertEquals(runProfile.getProfileName(), runProfile.getProfileName());
+		runProfile.setProfileName(null);
+		assertNotNull(runProfile.getProfileName());
+		assertEquals(mainProfile.getName(), runProfile.getProfileName());
+	}
+
+	/**
+	 * Test method for
+	 * {@link uk.org.taverna.platform.run.api.RunProfile#setProfile(org.apache.taverna.scufl2.api.profiles.Profile)}
+	 * .
+	 */
+	@Test
+	public void testSetProfile() {
+		runProfile.setProfileName(null);
+		assertNotNull(runProfile.getProfileName());
+		assertEquals(mainProfile.getName(), runProfile.getProfileName());
+		runProfile.setWorkflowBundle(new WorkflowBundle());
+		runProfile.setProfileName(null);
+		assertNull(runProfile.getProfileName());
+		runProfile.setProfileName(profile.getName());
+		assertEquals(profile.getName(), runProfile.getProfileName());
+		runProfile.setProfileName(mainProfile.getName());
+		assertEquals(mainProfile.getName(), runProfile.getProfileName());
+	}
+
+	/**
+	 * Test method for
+	 * {@link uk.org.taverna.platform.run.api.RunProfile#getDataBundle()}.
+	 */
+	@Test
+	public void testGetDataBundle() {
+		assertNotNull(runProfile.getDataBundle());
+		assertEquals(dataBundle, runProfile.getDataBundle());
+		assertEquals(runProfile.getDataBundle(), runProfile.getDataBundle());
+	}
+
+	/**
+	 * Test method for
+	 * {@link uk.org.taverna.platform.run.api.RunProfile#setDataBundle(org.apache.taverna.robundle.Bundle)}
+	 * .
+	 */
+	@Test
+	public void testSetDataBundle() {
+		runProfile.setDataBundle(null);
+		assertNull(runProfile.getDataBundle());
+		runProfile.setDataBundle(dataBundle);
+		assertEquals(dataBundle, runProfile.getDataBundle());
+	}
+
+	/**
+	 * Test method for
+	 * {@link uk.org.taverna.platform.run.api.RunProfile#getExecutionEnvironment()}.
+	 */
+	@Test
+	public void testGetExecutionEnvironment() {
+		assertNotNull(runProfile.getExecutionEnvironment());
+		assertEquals(executionEnvironment, runProfile.getExecutionEnvironment());
+		assertEquals(runProfile.getExecutionEnvironment(), runProfile.getExecutionEnvironment());
+	}
+
+	/**
+	 * Test method for
+	 * {@link uk.org.taverna.platform.run.api.RunProfile#setExecutionEnvironment(uk.org.taverna.platform.execution.api.ExecutionEnvironment)}
+	 * .
+	 */
+	@Test
+	public void testSetExecutionEnvironment() {
+		runProfile.setExecutionEnvironment(null);
+		assertNull(runProfile.getExecutionEnvironment());
+		runProfile.setExecutionEnvironment(executionEnvironment);
+		assertEquals(executionEnvironment, runProfile.getExecutionEnvironment());
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-api/src/test/java/uk/org/taverna/platform/run/api/RunProfileTest.java
----------------------------------------------------------------------
diff --git a/taverna-run-api/src/test/java/uk/org/taverna/platform/run/api/RunProfileTest.java b/taverna-run-api/src/test/java/uk/org/taverna/platform/run/api/RunProfileTest.java
deleted file mode 100644
index ec3830a..0000000
--- a/taverna-run-api/src/test/java/uk/org/taverna/platform/run/api/RunProfileTest.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.run.api;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.apache.taverna.robundle.Bundle;
-
-import org.apache.taverna.databundle.DataBundles;
-import uk.org.taverna.platform.execution.api.ExecutionEnvironment;
-import uk.org.taverna.platform.execution.impl.local.LocalExecutionEnvironment;
-import uk.org.taverna.platform.execution.impl.local.LocalExecutionService;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/**
- *
- *
- * @author David Withers
- */
-@Ignore
-public class RunProfileTest {
-
-	private RunProfile runProfile;
-	private ExecutionEnvironment executionEnvironment;
-	private WorkflowBundle workflowBundle;
-	private LocalExecutionService executionService;
-	private Workflow workflow, mainWorkflow;
-	private Profile profile, mainProfile;
-	private Bundle dataBundle;
-
-	/**
-	 * @throws java.lang.Exception
-	 */
-	@Before
-	public void setUp() throws Exception {
-		workflow = new Workflow();
-		mainWorkflow = new Workflow();
-		profile = new Profile();
-		mainProfile = new Profile();
-		workflowBundle = new WorkflowBundle();
-		workflowBundle.setMainProfile(mainProfile);
-		workflowBundle.setMainWorkflow(mainWorkflow);
-		executionService = new LocalExecutionService();
-		executionEnvironment = new LocalExecutionEnvironment(executionService, null, null);
-
-		dataBundle = DataBundles.createBundle();
-		runProfile = new RunProfile(executionEnvironment, workflowBundle, workflow.getName(), profile.getName(), dataBundle);
-	}
-
-	/**
-	 * Test method for
-	 * {@link uk.org.taverna.platform.run.api.RunProfile#RunProfile(org.apache.taverna.scufl2.api.container.WorkflowBundle, java.util.Map, net.sf.taverna.t2.reference.ReferenceService, uk.org.taverna.platform.execution.api.ExecutionService)}
-	 * .
-	 */
-	@Test
-	public void testRunProfileWorkflowBundleMapOfStringT2ReferenceReferenceServiceExecutionService() {
-		runProfile = new RunProfile(executionEnvironment, workflowBundle, dataBundle);
-	}
-
-	/**
-	 * Test method for
-	 * {@link uk.org.taverna.platform.run.api.RunProfile#RunProfile(org.apache.taverna.scufl2.api.container.WorkflowBundle, org.apache.taverna.scufl2.api.core.Workflow, org.apache.taverna.scufl2.api.profiles.Profile, java.util.Map, net.sf.taverna.t2.reference.ReferenceService, uk.org.taverna.platform.execution.api.ExecutionService)}
-	 * .
-	 */
-	@Test
-	public void testRunProfileWorkflowBundleWorkflowProfileMapOfStringT2ReferenceReferenceServiceExecutionService() {
-		runProfile = new RunProfile(executionEnvironment, workflowBundle, workflow.getName(), profile.getName(), dataBundle);
-	}
-
-	/**
-	 * Test method for
-	 * {@link uk.org.taverna.platform.run.api.RunProfile#getWorkflowBundle()}.
-	 */
-	@Test
-	public void testGetWorkflowBundle() {
-		assertNotNull(runProfile.getWorkflowBundle());
-		assertEquals(workflowBundle, runProfile.getWorkflowBundle());
-		assertEquals(runProfile.getWorkflowBundle(), runProfile.getWorkflowBundle());
-	}
-
-	/**
-	 * Test method for
-	 * {@link uk.org.taverna.platform.run.api.RunProfile#setWorkflowBundle(org.apache.taverna.scufl2.api.container.WorkflowBundle)}
-	 * .
-	 */
-	@Test
-	public void testSetWorkflowBundle() {
-		runProfile.setWorkflowBundle(null);
-		assertNull(runProfile.getWorkflowBundle());
-		runProfile.setWorkflowBundle(workflowBundle);
-		assertEquals(workflowBundle, runProfile.getWorkflowBundle());
-	}
-
-	/**
-	 * Test method for
-	 * {@link uk.org.taverna.platform.run.api.RunProfile#getWorkflow()}.
-	 */
-	@Test
-	public void testGetWorkflow() {
-		assertNotNull(runProfile.getWorkflowName());
-		assertEquals(workflow.getName(), runProfile.getWorkflowName());
-		assertEquals(runProfile.getWorkflowName(), runProfile.getWorkflowName());
-		runProfile.setWorkflowName(null);
-		assertNotNull(runProfile.getWorkflowName());
-		assertEquals(mainWorkflow.getName(), runProfile.getWorkflowName());
-	}
-
-	/**
-	 * Test method for
-	 * {@link uk.org.taverna.platform.run.api.RunProfile#setWorkflow(org.apache.taverna.scufl2.api.core.Workflow)}
-	 * .
-	 */
-	@Test
-	public void testSetWorkflow() {
-		runProfile.setWorkflowName(null);
-		assertNotNull(runProfile.getWorkflowName());
-		assertEquals(mainWorkflow.getName(), runProfile.getWorkflowName());
-		runProfile.setWorkflowBundle(new WorkflowBundle());
-		runProfile.setWorkflowName(null);
-		assertNull(runProfile.getWorkflowName());
-		runProfile.setWorkflowName(workflow.getName());
-		assertEquals(workflow.getName(), runProfile.getWorkflowName());
-		runProfile.setWorkflowName(mainWorkflow.getName());
-		assertEquals(mainWorkflow.getName(), runProfile.getWorkflowName());
-	}
-
-	/**
-	 * Test method for
-	 * {@link uk.org.taverna.platform.run.api.RunProfile#getProfile()}.
-	 */
-	@Test
-	public void testGetProfile() {
-		assertNotNull(runProfile.getProfileName());
-		assertEquals(profile.getName(), runProfile.getProfileName());
-		assertEquals(runProfile.getProfileName(), runProfile.getProfileName());
-		runProfile.setProfileName(null);
-		assertNotNull(runProfile.getProfileName());
-		assertEquals(mainProfile.getName(), runProfile.getProfileName());
-	}
-
-	/**
-	 * Test method for
-	 * {@link uk.org.taverna.platform.run.api.RunProfile#setProfile(org.apache.taverna.scufl2.api.profiles.Profile)}
-	 * .
-	 */
-	@Test
-	public void testSetProfile() {
-		runProfile.setProfileName(null);
-		assertNotNull(runProfile.getProfileName());
-		assertEquals(mainProfile.getName(), runProfile.getProfileName());
-		runProfile.setWorkflowBundle(new WorkflowBundle());
-		runProfile.setProfileName(null);
-		assertNull(runProfile.getProfileName());
-		runProfile.setProfileName(profile.getName());
-		assertEquals(profile.getName(), runProfile.getProfileName());
-		runProfile.setProfileName(mainProfile.getName());
-		assertEquals(mainProfile.getName(), runProfile.getProfileName());
-	}
-
-	/**
-	 * Test method for
-	 * {@link uk.org.taverna.platform.run.api.RunProfile#getDataBundle()}.
-	 */
-	@Test
-	public void testGetDataBundle() {
-		assertNotNull(runProfile.getDataBundle());
-		assertEquals(dataBundle, runProfile.getDataBundle());
-		assertEquals(runProfile.getDataBundle(), runProfile.getDataBundle());
-	}
-
-	/**
-	 * Test method for
-	 * {@link uk.org.taverna.platform.run.api.RunProfile#setDataBundle(org.apache.taverna.robundle.Bundle)}
-	 * .
-	 */
-	@Test
-	public void testSetDataBundle() {
-		runProfile.setDataBundle(null);
-		assertNull(runProfile.getDataBundle());
-		runProfile.setDataBundle(dataBundle);
-		assertEquals(dataBundle, runProfile.getDataBundle());
-	}
-
-	/**
-	 * Test method for
-	 * {@link uk.org.taverna.platform.run.api.RunProfile#getExecutionEnvironment()}.
-	 */
-	@Test
-	public void testGetExecutionEnvironment() {
-		assertNotNull(runProfile.getExecutionEnvironment());
-		assertEquals(executionEnvironment, runProfile.getExecutionEnvironment());
-		assertEquals(runProfile.getExecutionEnvironment(), runProfile.getExecutionEnvironment());
-	}
-
-	/**
-	 * Test method for
-	 * {@link uk.org.taverna.platform.run.api.RunProfile#setExecutionEnvironment(uk.org.taverna.platform.execution.api.ExecutionEnvironment)}
-	 * .
-	 */
-	@Test
-	public void testSetExecutionEnvironment() {
-		runProfile.setExecutionEnvironment(null);
-		assertNull(runProfile.getExecutionEnvironment());
-		runProfile.setExecutionEnvironment(executionEnvironment);
-		assertEquals(executionEnvironment, runProfile.getExecutionEnvironment());
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-impl/src/main/java/org/apache/taverna/platform/run/impl/Run.java
----------------------------------------------------------------------
diff --git a/taverna-run-impl/src/main/java/org/apache/taverna/platform/run/impl/Run.java b/taverna-run-impl/src/main/java/org/apache/taverna/platform/run/impl/Run.java
new file mode 100755
index 0000000..894bc58
--- /dev/null
+++ b/taverna-run-impl/src/main/java/org/apache/taverna/platform/run/impl/Run.java
@@ -0,0 +1,278 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.run.impl;
+
+import static java.util.logging.Level.WARNING;
+import static org.apache.taverna.platform.report.State.CANCELLED;
+import static org.apache.taverna.platform.report.State.COMPLETED;
+import static org.apache.taverna.platform.report.State.CREATED;
+import static org.apache.taverna.platform.report.State.FAILED;
+import static org.apache.taverna.platform.report.State.PAUSED;
+import static org.apache.taverna.platform.report.State.RUNNING;
+
+import java.io.IOException;
+import java.text.ParseException;
+import java.util.Date;
+import java.util.UUID;
+import java.util.logging.Logger;
+
+import org.apache.taverna.robundle.Bundle;
+import org.apache.taverna.robundle.manifest.Manifest;
+
+import org.apache.taverna.databundle.DataBundles;
+import org.apache.taverna.platform.execution.api.ExecutionEnvironment;
+import org.apache.taverna.platform.execution.api.InvalidExecutionIdException;
+import org.apache.taverna.platform.execution.api.InvalidWorkflowException;
+import org.apache.taverna.platform.report.State;
+import org.apache.taverna.platform.report.WorkflowReport;
+import org.apache.taverna.platform.run.api.RunProfile;
+import org.apache.taverna.platform.run.api.RunProfileException;
+import org.apache.taverna.platform.run.api.RunStateException;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.io.ReaderException;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+/**
+ * A single run of a {@link Workflow}.
+ * 
+ * @author David Withers
+ */
+public class Run {
+	private static final WorkflowReportJSON workflowReportJson = new WorkflowReportJSON();
+	private static final Logger logger = Logger.getLogger(Run.class.getName());
+
+	private final String ID, executionID;
+	private final ExecutionEnvironment executionEnvironment;
+	private final WorkflowReport workflowReport;
+	private final WorkflowBundle workflowBundle;
+	private final Bundle dataBundle;
+	private final Workflow workflow;
+	private final Profile profile;
+
+	/**
+	 * Constructs a <code>Run</code> from the specified <code>RunProfile</code>.
+	 * 
+	 * @param runProfile
+	 *            the profile to create a <code>Run</code> from
+	 * @throws InvalidWorkflowException
+	 *             if the <code>Workflow</code> specified by the
+	 *             <code>RunProfile</code> is not valid
+	 * @throws RunProfileException
+	 *             if the <code>RunProfile</code> does not contain the correct
+	 *             information to run a <code>Workflow</code>
+	 */
+	public Run(RunProfile runProfile) throws InvalidWorkflowException,
+			RunProfileException {
+		if (runProfile.getWorkflowBundle() == null) {
+			String message = "No WorkflowBundle specified in the RunProfile";
+			logger.warning(message);
+			throw new RunProfileException(message);
+		}
+		workflowBundle = runProfile.getWorkflowBundle();
+		if (runProfile.getWorkflowName() == null) {
+			if (workflowBundle.getMainWorkflow() == null) {
+				String message = "No Workflow specified in either the RunProfile or the WorkflowBundle";
+				logger.warning(message);
+				throw new RunProfileException(message);
+			}
+			logger.info("No Workflow specified - using the main Workflow from the WorkflowBundle");
+			workflow = workflowBundle.getMainWorkflow();
+		} else {
+			workflow = workflowBundle.getWorkflows().getByName(
+					runProfile.getWorkflowName());
+		}
+		if (runProfile.getProfileName() == null) {
+			if (workflowBundle.getMainProfile() == null) {
+				String message = "No Profile specified in either the RunProfile or the WorkflowBundle";
+				logger.warning(message);
+				throw new RunProfileException(message);
+			}
+			logger.info("No Profile specified - using the main Profile from the WorkflowBundle");
+			profile = workflowBundle.getMainProfile();
+		} else {
+			profile = workflowBundle.getProfiles().getByName(
+					runProfile.getProfileName());
+		}
+		if (runProfile.getDataBundle() == null) {
+			String message = "No DataBundle specified in the RunProfile";
+			logger.warning(message);
+			throw new RunProfileException(message);
+		}
+		dataBundle = runProfile.getDataBundle();
+		try {
+			DataBundles.setWorkflowBundle(dataBundle, workflowBundle);
+		} catch (IOException e) {
+			String message = "Could not save workflow bundle to data bundle";
+			logger.log(WARNING, message, e);
+			throw new InvalidWorkflowException(message, e);
+		}
+		if (runProfile.getExecutionEnvironment() == null) {
+			String message = "No ExecutionEnvironment specified in the RunProfile";
+			logger.warning(message);
+			throw new RunProfileException(message);
+		}
+		executionEnvironment = runProfile.getExecutionEnvironment();
+
+		ID = UUID.randomUUID().toString();
+		executionID = executionEnvironment.getExecutionService()
+				.createExecution(executionEnvironment, workflowBundle,
+						workflow, profile, dataBundle);
+		try {
+			workflowReport = executionEnvironment.getExecutionService()
+					.getWorkflowReport(executionID);
+		} catch (InvalidExecutionIdException e) {
+			String message = "Error while creating a execution on the "
+					+ executionEnvironment.getName();
+			logger.severe(message);
+			throw new RuntimeException(message, e);
+		}
+	}
+
+	public Run(String id, Bundle bundle) throws IOException, ReaderException,
+			ParseException {
+		this.ID = id;
+		executionID = null;
+		executionEnvironment = null;
+		workflowReport = workflowReportJson.load(bundle);
+		workflowBundle = DataBundles.getWorkflowBundle(bundle);
+		dataBundle = bundle;
+		workflow = workflowBundle.getMainWorkflow();
+		profile = workflowBundle.getMainProfile();
+	}
+
+	/**
+	 * Returns the identifier for this <code>Run</code>.
+	 * 
+	 * @return the identifier for this <code>Run</code>
+	 */
+	public String getID() {
+		return ID;
+	}
+
+	/**
+	 * Returns the current {@link State} of the <code>Run</code>.
+	 * 
+	 * A <code>Run</code>'s state can be CREATED, RUNNING, COMPLETED, PAUSED,
+	 * CANCELLED or FAILED.
+	 * 
+	 * @return the current <code>State</code> of the <code>Run</code>
+	 */
+	public State getState() {
+		return workflowReport.getState();
+	}
+
+	/**
+	 * Returns the <code>Bundle</code> containing the data values of the run.
+	 * <p>
+	 * 
+	 * @return the <code>Bundle</code> containing the data values for the
+	 *         <code>Workflow</code>
+	 */
+	public Bundle getDataBundle() {
+		if (getWorkflowReport() != null)
+			// Save the workflow report
+			try {
+				workflowReportJson.save(getWorkflowReport(), dataBundle);
+			} catch (IOException e) {
+				logger.log(WARNING,
+						"Can't save workflow report to data bundle", e);
+			}
+		// Update manifest
+		try {
+			Manifest manifest = new Manifest(dataBundle);
+			manifest.populateFromBundle();
+			manifest.writeAsJsonLD();
+		} catch (IOException e) {
+			logger.log(WARNING, "Can't add manifest to data bundle", e);
+		}
+		return dataBundle;
+	}
+
+	/**
+	 * Returns the status report for the run.
+	 * 
+	 * @return the status report for the run
+	 */
+	public WorkflowReport getWorkflowReport() {
+		return workflowReport;
+	}
+
+	public Workflow getWorkflow() {
+		return workflow;
+	}
+
+	public Profile getProfile() {
+		return profile;
+	}
+
+	/**
+	 * Deletes a run.
+	 * 
+	 * @throws InvalidExecutionIdException
+	 */
+	public void delete() throws InvalidExecutionIdException {
+		synchronized (workflowReport) {
+			executionEnvironment.getExecutionService().delete(executionID);
+		}
+	}
+
+	public void start() throws RunStateException, InvalidExecutionIdException {
+		synchronized (workflowReport) {
+			State state = workflowReport.getState();
+			if (!state.equals(CREATED))
+				throw new RunStateException("Cannot start a " + state + " run.");
+			executionEnvironment.getExecutionService().start(executionID);
+		}
+	}
+
+	public void pause() throws RunStateException, InvalidExecutionIdException {
+		synchronized (workflowReport) {
+			State state = workflowReport.getState();
+			if (!state.equals(RUNNING))
+				throw new RunStateException("Cannot pause a " + state + " run.");
+			executionEnvironment.getExecutionService().pause(executionID);
+			workflowReport.setPausedDate(new Date());
+		}
+	}
+
+	public void resume() throws RunStateException, InvalidExecutionIdException {
+		synchronized (workflowReport) {
+			State state = workflowReport.getState();
+			if (!state.equals(PAUSED))
+				throw new RunStateException("Cannot resume a " + state
+						+ " run.");
+			executionEnvironment.getExecutionService().resume(executionID);
+			workflowReport.setResumedDate(new Date());
+		}
+	}
+
+	public void cancel() throws RunStateException, InvalidExecutionIdException {
+		synchronized (workflowReport) {
+			State state = workflowReport.getState();
+			if (state.equals(CANCELLED) || state.equals(COMPLETED)
+					|| state.equals(FAILED))
+				throw new RunStateException("Cannot cancel a " + state
+						+ " run.");
+			executionEnvironment.getExecutionService().cancel(executionID);
+			workflowReport.setCancelledDate(new Date());
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-impl/src/main/java/org/apache/taverna/platform/run/impl/RunServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-run-impl/src/main/java/org/apache/taverna/platform/run/impl/RunServiceImpl.java b/taverna-run-impl/src/main/java/org/apache/taverna/platform/run/impl/RunServiceImpl.java
new file mode 100755
index 0000000..f7afba3
--- /dev/null
+++ b/taverna-run-impl/src/main/java/org/apache/taverna/platform/run/impl/RunServiceImpl.java
@@ -0,0 +1,267 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.run.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.ClosedFileSystemException;
+import java.nio.file.InvalidPathException;
+import java.nio.file.Path;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.osgi.service.event.Event;
+import org.osgi.service.event.EventAdmin;
+import org.apache.taverna.robundle.Bundle;
+
+import org.apache.taverna.databundle.DataBundles;
+import org.apache.taverna.platform.execution.api.ExecutionEnvironment;
+import org.apache.taverna.platform.execution.api.ExecutionEnvironmentService;
+import org.apache.taverna.platform.execution.api.InvalidExecutionIdException;
+import org.apache.taverna.platform.execution.api.InvalidWorkflowException;
+import org.apache.taverna.platform.report.ReportListener;
+import org.apache.taverna.platform.report.State;
+import org.apache.taverna.platform.report.WorkflowReport;
+import org.apache.taverna.platform.run.api.InvalidRunIdException;
+import org.apache.taverna.platform.run.api.RunProfile;
+import org.apache.taverna.platform.run.api.RunProfileException;
+import org.apache.taverna.platform.run.api.RunService;
+import org.apache.taverna.platform.run.api.RunStateException;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.io.ReaderException;
+import org.apache.taverna.scufl2.api.io.WorkflowBundleIO;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+/**
+ * Implementation of the <code>RunService</code>.
+ *
+ * @author David Withers
+ */
+public class RunServiceImpl implements RunService {
+	private static final Logger logger = Logger.getLogger(RunServiceImpl.class.getName());
+	private static SimpleDateFormat ISO_8601 = new SimpleDateFormat("yyyy-MM-dd_HHmmss");
+
+	private final Map<String, Run> runMap;
+	private ExecutionEnvironmentService executionEnvironmentService;
+	private EventAdmin eventAdmin;
+
+	public RunServiceImpl() {
+		runMap = new TreeMap<>();
+	}
+
+	@Override
+	public Set<ExecutionEnvironment> getExecutionEnvironments() {
+		return executionEnvironmentService.getExecutionEnvironments();
+	}
+
+	@Override
+	public Set<ExecutionEnvironment> getExecutionEnvironments(WorkflowBundle workflowBundle) {
+		return getExecutionEnvironments(workflowBundle.getMainProfile());
+	}
+
+	@Override
+	public Set<ExecutionEnvironment> getExecutionEnvironments(Profile profile) {
+		return executionEnvironmentService.getExecutionEnvironments(profile);
+	}
+
+	@Override
+	public List<String> getRuns() {
+		return new ArrayList<>(runMap.keySet());
+	}
+
+	@Override
+	public String createRun(RunProfile runProfile) throws InvalidWorkflowException, RunProfileException {
+		Run run = new Run(runProfile);
+		run.getWorkflowReport().addReportListener(new RunReportListener(run.getID()));
+		runMap.put(run.getID(), run);
+		postEvent(RUN_CREATED, run.getID());
+		return run.getID();
+	}
+
+	@Override
+	public String open(File runFile) throws IOException {
+		try {
+			String runID = runFile.getName();
+			int dot = runID.indexOf('.');
+			if (dot > 0)
+				runID = runID.substring(0, dot);
+			if (!runMap.containsKey(runID)) {
+				Bundle bundle = DataBundles.openBundle(runFile.toPath());
+				Run run = new Run(runID, bundle);
+				runMap.put(run.getID(), run);
+			}
+			postEvent(RUN_OPENED, runID);
+			return runID;
+		} catch (ReaderException | ParseException e) {
+			throw new IOException("Error opening file " + runFile, e);
+		}
+	}
+
+	@Override
+	public void close(String runID) throws InvalidRunIdException, InvalidExecutionIdException {
+		Run run = getRun(runID);
+		try {
+			Bundle dataBundle = run.getDataBundle();
+			DataBundles.closeBundle(dataBundle);
+		} catch (IOException | ClosedFileSystemException e) {
+			logger.log(Level.WARNING, "Error closing data bundle for run " + runID, e);
+		}
+		runMap.remove(runID);
+		postEvent(RUN_CLOSED, runID);
+	}
+
+	@Override
+	public void save(String runID, File runFile) throws InvalidRunIdException, IOException {
+		Run run = getRun(runID);
+		Bundle dataBundle = run.getDataBundle();
+		try {
+			DataBundles.closeAndSaveBundle(dataBundle, runFile.toPath());
+		} catch (InvalidPathException e) {
+			throw new IOException(e);
+		}
+	}
+
+	@Override
+	public void delete(String runID) throws InvalidRunIdException, InvalidExecutionIdException {
+		Run run = getRun(runID);
+		run.delete();
+		Bundle dataBundle = run.getDataBundle();
+		try {
+			DataBundles.closeBundle(dataBundle);
+		} catch (IOException e) {
+			logger.log(Level.WARNING, "Error closing data bundle for run " + runID, e);
+		}
+		runMap.remove(runID);
+		postEvent(RUN_DELETED, runID);
+	}
+
+	@Override
+	public void start(String runID) throws InvalidRunIdException, RunStateException, InvalidExecutionIdException {
+		getRun(runID).start();
+		postEvent(RUN_STARTED, runID);
+	}
+
+	@Override
+	public void pause(String runID) throws InvalidRunIdException, RunStateException, InvalidExecutionIdException {
+		getRun(runID).pause();
+		postEvent(RUN_PAUSED, runID);
+	}
+
+	@Override
+	public void resume(String runID) throws InvalidRunIdException, RunStateException, InvalidExecutionIdException {
+		getRun(runID).resume();
+		postEvent(RUN_RESUMED, runID);
+	}
+
+	@Override
+	public void cancel(String runID) throws InvalidRunIdException, RunStateException, InvalidExecutionIdException {
+		getRun(runID).cancel();
+		postEvent(RUN_STOPPED, runID);
+	}
+
+	@Override
+	public State getState(String runID) throws InvalidRunIdException {
+		return getRun(runID).getState();
+	}
+
+	@Override
+	public Bundle getDataBundle(String runID) throws InvalidRunIdException {
+		return getRun(runID).getDataBundle();
+	}
+
+	@Override
+	public WorkflowReport getWorkflowReport(String runID) throws InvalidRunIdException {
+		return getRun(runID).getWorkflowReport();
+	}
+
+	@Override
+	public Workflow getWorkflow(String runID) throws InvalidRunIdException {
+		return getRun(runID).getWorkflow();
+	}
+
+	@Override
+	public Profile getProfile(String runID) throws InvalidRunIdException {
+		return getRun(runID).getProfile();
+	}
+
+	@Override
+	public String getRunName(String runID) throws InvalidRunIdException {
+		WorkflowReport workflowReport = getWorkflowReport(runID);
+		return workflowReport.getSubject().getName() + "_" + ISO_8601.format(workflowReport.getCreatedDate());
+	}
+
+	private Run getRun(String runID) throws InvalidRunIdException {
+		Run run = runMap.get(runID);
+		if (run == null)
+			throw new InvalidRunIdException("Run ID " + runID + " is not valid");
+		return run;
+	}
+
+	private void postEvent(String topic, String runId) {
+		HashMap<String, String> properties = new HashMap<>();
+		properties.put("RUN_ID", runId);
+		Event event = new Event(topic, properties);
+		eventAdmin.postEvent(event);
+	}
+
+	public void setExecutionEnvironmentService(ExecutionEnvironmentService executionEnvironmentService) {
+		this.executionEnvironmentService = executionEnvironmentService;
+	}
+
+	public void setEventAdmin(EventAdmin eventAdmin) {
+		this.eventAdmin = eventAdmin;
+	}
+
+	public void setWorkflowBundleIO(WorkflowBundleIO workflowBundleIO) {
+		DataBundles.setWfBundleIO(workflowBundleIO);
+	}
+
+	private class RunReportListener implements ReportListener {
+		private final String runId;
+
+		public RunReportListener(String runId) {
+			this.runId = runId;
+		}
+
+		@Override
+		public void outputAdded(Path path, String portName, int[] index) {
+		}
+
+		@Override
+		public void stateChanged(State oldState, State newState) {
+			switch (newState) {
+			case COMPLETED:
+			case FAILED:
+				postEvent(RUN_STOPPED, runId);
+			default:
+				break;
+			}
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-impl/src/main/java/org/apache/taverna/platform/run/impl/WorkflowReportJSON.java
----------------------------------------------------------------------
diff --git a/taverna-run-impl/src/main/java/org/apache/taverna/platform/run/impl/WorkflowReportJSON.java b/taverna-run-impl/src/main/java/org/apache/taverna/platform/run/impl/WorkflowReportJSON.java
new file mode 100644
index 0000000..470df04
--- /dev/null
+++ b/taverna-run-impl/src/main/java/org/apache/taverna/platform/run/impl/WorkflowReportJSON.java
@@ -0,0 +1,347 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.run.impl;
+
+import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
+import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;
+import static com.fasterxml.jackson.databind.SerializationFeature.FAIL_ON_EMPTY_BEANS;
+import static com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT;
+import static com.fasterxml.jackson.databind.SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS;
+import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS;
+import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_EMPTY_JSON_ARRAYS;
+import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_NULL_MAP_VALUES;
+import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED;
+import static java.nio.file.Files.newBufferedWriter;
+import static java.nio.file.StandardOpenOption.CREATE;
+import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
+import static java.nio.file.StandardOpenOption.WRITE;
+import static org.apache.taverna.databundle.DataBundles.getWorkflow;
+import static org.apache.taverna.databundle.DataBundles.getWorkflowBundle;
+import static org.apache.taverna.databundle.DataBundles.getWorkflowRunReport;
+import static org.apache.taverna.databundle.DataBundles.setWorkflowBundle;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Writer;
+import java.net.URI;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.text.ParseException;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.apache.taverna.robundle.Bundle;
+import org.apache.taverna.robundle.manifest.Manifest.PathMixin;
+
+import org.apache.taverna.platform.report.ActivityReport;
+import org.apache.taverna.platform.report.Invocation;
+import org.apache.taverna.platform.report.ProcessorReport;
+import org.apache.taverna.platform.report.State;
+import org.apache.taverna.platform.report.StatusReport;
+import org.apache.taverna.platform.report.WorkflowReport;
+import org.apache.taverna.scufl2.api.activity.Activity;
+import org.apache.taverna.scufl2.api.common.URITools;
+import org.apache.taverna.scufl2.api.common.WorkflowBean;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.Processor;
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.io.ReaderException;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.fasterxml.jackson.databind.util.StdDateFormat;
+
+public class WorkflowReportJSON {
+	private static URITools uriTools = new URITools();
+	private static final StdDateFormat STD_DATE_FORMAT = new StdDateFormat();
+
+	public void save(WorkflowReport wfReport, Path path) throws IOException {
+		ObjectMapper om = makeObjectMapperForSave();
+		try (Writer w = newBufferedWriter(path, Charset.forName("UTF-8"),
+				WRITE, CREATE, TRUNCATE_EXISTING)) {
+			om.writeValue(w, wfReport);
+		}
+	}
+
+	protected static ObjectMapper makeObjectMapperForLoad() {
+		ObjectMapper om = new ObjectMapper();
+		om.disable(FAIL_ON_UNKNOWN_PROPERTIES);
+		return om;
+	}
+
+	protected static ObjectMapper makeObjectMapperForSave() {
+		ObjectMapper om = new ObjectMapper();
+		om.enable(INDENT_OUTPUT);
+		om.disable(FAIL_ON_EMPTY_BEANS);
+		om.enable(ORDER_MAP_ENTRIES_BY_KEYS);
+		om.disable(WRITE_EMPTY_JSON_ARRAYS);
+		om.disable(WRITE_NULL_MAP_VALUES);
+		om.disable(WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED);
+		om.disable(WRITE_DATES_AS_TIMESTAMPS);
+		om.disable(WRITE_NULL_MAP_VALUES);
+		om.addMixInAnnotations(Path.class, PathMixin.class);
+		om.setSerializationInclusion(NON_NULL);
+		return om;
+	}
+
+	@SuppressWarnings("unused")
+	private void injectContext(ObjectNode objNode) {
+		ObjectNode context = objNode.with("@context");
+		context.put("wfprov", "http://purl.org/wf4ever/wfprov#");
+		context.put("wfdesc", "http://purl.org/wf4ever/wfdesc#");
+		context.put("prov", "http://www.w3.org/ns/prov#");
+	}
+
+	public void save(WorkflowReport wfReport, Bundle dataBundle)
+			throws IOException {
+		Path path = getWorkflowRunReport(dataBundle);
+		save(wfReport, path);
+		if (!Files.exists(getWorkflow(dataBundle)))
+			// Usually already done by Run constructor
+			setWorkflowBundle(wfReport.getDataBundle(), wfReport.getSubject()
+					.getParent());
+	}
+
+	public WorkflowReport load(Bundle bundle) throws IOException,
+			ReaderException, ParseException {
+		Path path = getWorkflowRunReport(bundle);
+		WorkflowBundle workflow = getWorkflowBundle(bundle);
+		return load(path, workflow);
+	}
+
+	public WorkflowReport load(Path workflowReportJson,
+			WorkflowBundle workflowBundle) throws IOException, ParseException {
+		JsonNode json = loadWorkflowReportJson(workflowReportJson);
+		if (!json.isObject())
+			throw new IOException(
+					"Invalid workflow report, expected JSON Object:\n" + json);
+		return parseWorkflowReport(json, workflowReportJson, null,
+				workflowBundle);
+	}
+
+	protected WorkflowReport parseWorkflowReport(JsonNode reportJson,
+			Path workflowReportJson, ActivityReport actReport,
+			WorkflowBundle workflowBundle) throws ParseException {
+		Workflow wf = (Workflow) getSubject(reportJson, workflowBundle);
+		WorkflowReport workflowReport = new WorkflowReport(wf);
+		workflowReport.setParentReport(actReport);
+
+		parseDates(reportJson, workflowReport);
+
+		for (JsonNode invocJson : reportJson.path("invocations"))
+			// NOTE: Invocation constructor will add to parents
+			parseInvocation(invocJson, workflowReportJson, workflowReport);
+
+		for (JsonNode procJson : reportJson.path("processorReports")) {
+			ProcessorReport procReport = parseProcessorReport(procJson,
+					workflowReportJson, workflowReport, workflowBundle);
+			workflowReport.addProcessorReport(procReport);
+		}
+		return workflowReport;
+	}
+
+	protected ProcessorReport parseProcessorReport(JsonNode reportJson,
+			Path workflowReportJson, WorkflowReport workflowReport,
+			WorkflowBundle workflowBundle) throws ParseException {
+		Processor p = (Processor) getSubject(reportJson, workflowBundle);
+		ProcessorReport procReport = new ProcessorReport(p);
+		procReport.setParentReport(workflowReport);
+
+		procReport.setJobsQueued(reportJson.path("jobsQueued").asInt());
+		procReport.setJobsStarted(reportJson.path("jobsStarted").asInt());
+		procReport.setJobsCompleted(reportJson.path("jobsCompleted").asInt());
+		procReport.setJobsCompletedWithErrors(reportJson.path(
+				"jobsCompletedWithErrors").asInt());
+		// TODO: procReport properties
+
+		parseDates(reportJson, procReport);
+
+		for (JsonNode invocJson : reportJson.path("invocations"))
+			parseInvocation(invocJson, workflowReportJson, procReport);
+
+		for (JsonNode actJson : reportJson.path("activityReports")) {
+			ActivityReport activityReport = parseActivityReport(actJson,
+					workflowReportJson, procReport, workflowBundle);
+			procReport.addActivityReport(activityReport);
+		}
+		return procReport;
+	}
+
+	protected ActivityReport parseActivityReport(JsonNode actJson,
+			Path workflowReportJson, ProcessorReport procReport,
+			WorkflowBundle workflowBundle) throws ParseException {
+		Activity a = (Activity) getSubject(actJson, workflowBundle);
+		ActivityReport actReport = new ActivityReport(a);
+		actReport.setParentReport(procReport);
+
+		parseDates(actJson, actReport);
+
+		for (JsonNode invocJson : actJson.path("invocations"))
+			parseInvocation(invocJson, workflowReportJson, actReport);
+
+		JsonNode nestedWf = actJson.get("nestedWorkflowReport");
+		if (nestedWf != null)
+			actReport.setNestedWorkflowReport(parseWorkflowReport(nestedWf,
+					workflowReportJson, actReport, workflowBundle));
+		return actReport;
+	}
+
+	protected void parseInvocation(JsonNode json, Path workflowReportJson,
+			@SuppressWarnings("rawtypes") StatusReport report)
+			throws ParseException {
+		String name = json.path("name").asText();
+
+		String parentId = json.path("parent").asText();
+		Invocation parent = null;
+		if (!parentId.isEmpty()) {
+			@SuppressWarnings("rawtypes")
+			StatusReport parentReport = report.getParentReport();
+			if (parentReport != null)
+				parent = parentReport.getInvocation(parentId);
+		}
+
+		int[] index;
+		if (json.has("index")) {
+			ArrayNode array = (ArrayNode) json.get("index");
+			index = new int[array.size()];
+			for (int i = 0; i < index.length; i++)
+				index[i] = array.get(i).asInt();
+		} else
+			index = new int[0];
+
+		Invocation invocation = new Invocation(name, index, parent, report);
+		Date startedDate = getDate(json, "startedDate");
+		if (startedDate != null)
+			invocation.setStartedDate(startedDate);
+		Date completedDate = getDate(json, "completedDate");
+		if (completedDate != null)
+			invocation.setCompletedDate(completedDate);
+
+		invocation.setInputs(parseValues(json.path("inputs"),
+				workflowReportJson));
+		invocation.setOutputs(parseValues(json.path("outputs"),
+				workflowReportJson));
+	}
+
+	protected Map<String, Path> parseValues(JsonNode json, Path basePath) {
+		SortedMap<String, Path> values = new TreeMap<>();
+		for (String port : iterate(json.fieldNames())) {
+			String pathStr = json.get(port).asText();
+			Path value = basePath.resolve(pathStr);
+			values.put(port, value);
+		}
+		return values;
+	}
+
+	private static <T> Iterable<T> iterate(final Iterator<T> iterator) {
+		return new Iterable<T>() {
+			@Override
+			public Iterator<T> iterator() {
+				return iterator;
+			}
+		};
+	}
+
+	protected void parseDates(JsonNode json,
+			@SuppressWarnings("rawtypes") StatusReport report)
+			throws ParseException {
+		Date createdDate = getDate(json, "createdDate");
+		if (createdDate != null)
+			report.setCreatedDate(createdDate);
+
+		Date startedDate = getDate(json, "startedDate");
+		if (startedDate != null)
+			report.setStartedDate(startedDate);
+
+		// Special case for paused and resumed dates>
+		for (JsonNode s : json.path("pausedDates")) {
+			Date pausedDate = STD_DATE_FORMAT.parse(s.asText());
+			report.setPausedDate(pausedDate);
+		}
+		Date pausedDate = getDate(json, "pausedDate");
+		if (report.getPausedDates().isEmpty() && pausedDate != null) {
+			/*
+			 * "pausedDate" is normally redundant (last value of "pausedDates")
+			 * but here for some reason the list is missing, so we'll parse it
+			 * separately.
+			 * 
+			 * Note that if there was a list, we will ignore "pauseDate" no
+			 * matter its value
+			 */
+			report.setPausedDate(pausedDate);
+		}
+
+		for (JsonNode s : json.path("resumedDates")) {
+			Date resumedDate = STD_DATE_FORMAT.parse(s.asText());
+			report.setResumedDate(resumedDate);
+		}
+		Date resumedDate = getDate(json, "resumedDate");
+		if (report.getResumedDates().isEmpty() && resumedDate != null)
+			// Same fall-back as for "pausedDate" above
+			report.setResumedDate(resumedDate);
+
+		Date cancelledDate = getDate(json, "cancelledDate");
+		if (cancelledDate != null)
+			report.setCancelledDate(cancelledDate);
+
+		Date failedDate = getDate(json, "failedDate");
+		if (failedDate != null)
+			report.setFailedDate(failedDate);
+
+		Date completedDate = getDate(json, "completedDate");
+		if (completedDate != null)
+			report.setCompletedDate(completedDate);
+
+		try {
+			State state = State.valueOf(json.get("state").asText());
+			report.setState(state);
+		} catch (IllegalArgumentException ex) {
+			throw new ParseException("Invalid state: " + json.get("state"), -1);
+		}
+	}
+
+	protected Date getDate(JsonNode json, String name) throws ParseException {
+		String date = json.path(name).asText();
+		if (date.isEmpty())
+			return null;
+		return STD_DATE_FORMAT.parse(date);
+	}
+
+	private WorkflowBean getSubject(JsonNode reportJson,
+			WorkflowBundle workflowBundle) {
+		URI subjectUri = URI.create(reportJson.path("subject").asText());
+		return uriTools.resolveUri(subjectUri, workflowBundle);
+	}
+
+	protected JsonNode loadWorkflowReportJson(Path path) throws IOException,
+			JsonProcessingException {
+		ObjectMapper om = makeObjectMapperForLoad();
+		try (InputStream stream = Files.newInputStream(path)) {
+			return om.readTree(stream);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-impl/src/main/java/uk/org/taverna/platform/run/impl/Run.java
----------------------------------------------------------------------
diff --git a/taverna-run-impl/src/main/java/uk/org/taverna/platform/run/impl/Run.java b/taverna-run-impl/src/main/java/uk/org/taverna/platform/run/impl/Run.java
deleted file mode 100755
index 90b44db..0000000
--- a/taverna-run-impl/src/main/java/uk/org/taverna/platform/run/impl/Run.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.run.impl;
-
-import static java.util.logging.Level.WARNING;
-import static uk.org.taverna.platform.report.State.CANCELLED;
-import static uk.org.taverna.platform.report.State.COMPLETED;
-import static uk.org.taverna.platform.report.State.CREATED;
-import static uk.org.taverna.platform.report.State.FAILED;
-import static uk.org.taverna.platform.report.State.PAUSED;
-import static uk.org.taverna.platform.report.State.RUNNING;
-
-import java.io.IOException;
-import java.text.ParseException;
-import java.util.Date;
-import java.util.UUID;
-import java.util.logging.Logger;
-
-import org.apache.taverna.robundle.Bundle;
-import org.apache.taverna.robundle.manifest.Manifest;
-
-import org.apache.taverna.databundle.DataBundles;
-import uk.org.taverna.platform.execution.api.ExecutionEnvironment;
-import uk.org.taverna.platform.execution.api.InvalidExecutionIdException;
-import uk.org.taverna.platform.execution.api.InvalidWorkflowException;
-import uk.org.taverna.platform.report.State;
-import uk.org.taverna.platform.report.WorkflowReport;
-import uk.org.taverna.platform.run.api.RunProfile;
-import uk.org.taverna.platform.run.api.RunProfileException;
-import uk.org.taverna.platform.run.api.RunStateException;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.io.ReaderException;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/**
- * A single run of a {@link Workflow}.
- * 
- * @author David Withers
- */
-public class Run {
-	private static final WorkflowReportJSON workflowReportJson = new WorkflowReportJSON();
-	private static final Logger logger = Logger.getLogger(Run.class.getName());
-
-	private final String ID, executionID;
-	private final ExecutionEnvironment executionEnvironment;
-	private final WorkflowReport workflowReport;
-	private final WorkflowBundle workflowBundle;
-	private final Bundle dataBundle;
-	private final Workflow workflow;
-	private final Profile profile;
-
-	/**
-	 * Constructs a <code>Run</code> from the specified <code>RunProfile</code>.
-	 * 
-	 * @param runProfile
-	 *            the profile to create a <code>Run</code> from
-	 * @throws InvalidWorkflowException
-	 *             if the <code>Workflow</code> specified by the
-	 *             <code>RunProfile</code> is not valid
-	 * @throws RunProfileException
-	 *             if the <code>RunProfile</code> does not contain the correct
-	 *             information to run a <code>Workflow</code>
-	 */
-	public Run(RunProfile runProfile) throws InvalidWorkflowException,
-			RunProfileException {
-		if (runProfile.getWorkflowBundle() == null) {
-			String message = "No WorkflowBundle specified in the RunProfile";
-			logger.warning(message);
-			throw new RunProfileException(message);
-		}
-		workflowBundle = runProfile.getWorkflowBundle();
-		if (runProfile.getWorkflowName() == null) {
-			if (workflowBundle.getMainWorkflow() == null) {
-				String message = "No Workflow specified in either the RunProfile or the WorkflowBundle";
-				logger.warning(message);
-				throw new RunProfileException(message);
-			}
-			logger.info("No Workflow specified - using the main Workflow from the WorkflowBundle");
-			workflow = workflowBundle.getMainWorkflow();
-		} else {
-			workflow = workflowBundle.getWorkflows().getByName(
-					runProfile.getWorkflowName());
-		}
-		if (runProfile.getProfileName() == null) {
-			if (workflowBundle.getMainProfile() == null) {
-				String message = "No Profile specified in either the RunProfile or the WorkflowBundle";
-				logger.warning(message);
-				throw new RunProfileException(message);
-			}
-			logger.info("No Profile specified - using the main Profile from the WorkflowBundle");
-			profile = workflowBundle.getMainProfile();
-		} else {
-			profile = workflowBundle.getProfiles().getByName(
-					runProfile.getProfileName());
-		}
-		if (runProfile.getDataBundle() == null) {
-			String message = "No DataBundle specified in the RunProfile";
-			logger.warning(message);
-			throw new RunProfileException(message);
-		}
-		dataBundle = runProfile.getDataBundle();
-		try {
-			DataBundles.setWorkflowBundle(dataBundle, workflowBundle);
-		} catch (IOException e) {
-			String message = "Could not save workflow bundle to data bundle";
-			logger.log(WARNING, message, e);
-			throw new InvalidWorkflowException(message, e);
-		}
-		if (runProfile.getExecutionEnvironment() == null) {
-			String message = "No ExecutionEnvironment specified in the RunProfile";
-			logger.warning(message);
-			throw new RunProfileException(message);
-		}
-		executionEnvironment = runProfile.getExecutionEnvironment();
-
-		ID = UUID.randomUUID().toString();
-		executionID = executionEnvironment.getExecutionService()
-				.createExecution(executionEnvironment, workflowBundle,
-						workflow, profile, dataBundle);
-		try {
-			workflowReport = executionEnvironment.getExecutionService()
-					.getWorkflowReport(executionID);
-		} catch (InvalidExecutionIdException e) {
-			String message = "Error while creating a execution on the "
-					+ executionEnvironment.getName();
-			logger.severe(message);
-			throw new RuntimeException(message, e);
-		}
-	}
-
-	public Run(String id, Bundle bundle) throws IOException, ReaderException,
-			ParseException {
-		this.ID = id;
-		executionID = null;
-		executionEnvironment = null;
-		workflowReport = workflowReportJson.load(bundle);
-		workflowBundle = DataBundles.getWorkflowBundle(bundle);
-		dataBundle = bundle;
-		workflow = workflowBundle.getMainWorkflow();
-		profile = workflowBundle.getMainProfile();
-	}
-
-	/**
-	 * Returns the identifier for this <code>Run</code>.
-	 * 
-	 * @return the identifier for this <code>Run</code>
-	 */
-	public String getID() {
-		return ID;
-	}
-
-	/**
-	 * Returns the current {@link State} of the <code>Run</code>.
-	 * 
-	 * A <code>Run</code>'s state can be CREATED, RUNNING, COMPLETED, PAUSED,
-	 * CANCELLED or FAILED.
-	 * 
-	 * @return the current <code>State</code> of the <code>Run</code>
-	 */
-	public State getState() {
-		return workflowReport.getState();
-	}
-
-	/**
-	 * Returns the <code>Bundle</code> containing the data values of the run.
-	 * <p>
-	 * 
-	 * @return the <code>Bundle</code> containing the data values for the
-	 *         <code>Workflow</code>
-	 */
-	public Bundle getDataBundle() {
-		if (getWorkflowReport() != null)
-			// Save the workflow report
-			try {
-				workflowReportJson.save(getWorkflowReport(), dataBundle);
-			} catch (IOException e) {
-				logger.log(WARNING,
-						"Can't save workflow report to data bundle", e);
-			}
-		// Update manifest
-		try {
-			Manifest manifest = new Manifest(dataBundle);
-			manifest.populateFromBundle();
-			manifest.writeAsJsonLD();
-		} catch (IOException e) {
-			logger.log(WARNING, "Can't add manifest to data bundle", e);
-		}
-		return dataBundle;
-	}
-
-	/**
-	 * Returns the status report for the run.
-	 * 
-	 * @return the status report for the run
-	 */
-	public WorkflowReport getWorkflowReport() {
-		return workflowReport;
-	}
-
-	public Workflow getWorkflow() {
-		return workflow;
-	}
-
-	public Profile getProfile() {
-		return profile;
-	}
-
-	/**
-	 * Deletes a run.
-	 * 
-	 * @throws InvalidExecutionIdException
-	 */
-	public void delete() throws InvalidExecutionIdException {
-		synchronized (workflowReport) {
-			executionEnvironment.getExecutionService().delete(executionID);
-		}
-	}
-
-	public void start() throws RunStateException, InvalidExecutionIdException {
-		synchronized (workflowReport) {
-			State state = workflowReport.getState();
-			if (!state.equals(CREATED))
-				throw new RunStateException("Cannot start a " + state + " run.");
-			executionEnvironment.getExecutionService().start(executionID);
-		}
-	}
-
-	public void pause() throws RunStateException, InvalidExecutionIdException {
-		synchronized (workflowReport) {
-			State state = workflowReport.getState();
-			if (!state.equals(RUNNING))
-				throw new RunStateException("Cannot pause a " + state + " run.");
-			executionEnvironment.getExecutionService().pause(executionID);
-			workflowReport.setPausedDate(new Date());
-		}
-	}
-
-	public void resume() throws RunStateException, InvalidExecutionIdException {
-		synchronized (workflowReport) {
-			State state = workflowReport.getState();
-			if (!state.equals(PAUSED))
-				throw new RunStateException("Cannot resume a " + state
-						+ " run.");
-			executionEnvironment.getExecutionService().resume(executionID);
-			workflowReport.setResumedDate(new Date());
-		}
-	}
-
-	public void cancel() throws RunStateException, InvalidExecutionIdException {
-		synchronized (workflowReport) {
-			State state = workflowReport.getState();
-			if (state.equals(CANCELLED) || state.equals(COMPLETED)
-					|| state.equals(FAILED))
-				throw new RunStateException("Cannot cancel a " + state
-						+ " run.");
-			executionEnvironment.getExecutionService().cancel(executionID);
-			workflowReport.setCancelledDate(new Date());
-		}
-	}
-}


[05/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractEventHandlingInputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractEventHandlingInputPort.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractEventHandlingInputPort.java
deleted file mode 100644
index 8e4359f..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractEventHandlingInputPort.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import net.sf.taverna.t2.workflowmodel.AbstractPort;
-import net.sf.taverna.t2.workflowmodel.Datalink;
-import net.sf.taverna.t2.workflowmodel.EventHandlingInputPort;
-
-/**
- * Extends AbstractPort with the getIncomingLink method and an additional
- * implementation method to set the incoming data link
- * 
- * @author Tom Oinn
- */
-public abstract class AbstractEventHandlingInputPort extends AbstractPort
-		implements EventHandlingInputPort {
-	private Datalink incomingLink = null;
-
-	protected AbstractEventHandlingInputPort(String name, int depth) {
-		super(name, depth);
-	}
-
-	@Override
-	public Datalink getIncomingLink() {
-		return this.incomingLink;
-	}
-
-	protected void setIncomingLink(Datalink newLink) {
-		this.incomingLink = newLink;
-	}
-	
-	protected void setName(String name) {
-		this.name = name;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractFilteringInputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractFilteringInputPort.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractFilteringInputPort.java
deleted file mode 100644
index a0f48be..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractFilteringInputPort.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.invocation.WorkflowDataToken;
-import net.sf.taverna.t2.reference.ContextualizedT2Reference;
-import net.sf.taverna.t2.reference.ReferenceService;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.FilteringInputPort;
-import net.sf.taverna.t2.workflowmodel.WorkflowStructureException;
-
-/**
- * Abstract superclass for filtering input ports, extend and implement the
- * pushXXX methods to configure behaviour
- * 
- * @author Tom Oinn
- */
-public abstract class AbstractFilteringInputPort extends
-		AbstractEventHandlingInputPort implements FilteringInputPort {
-	protected AbstractFilteringInputPort(String name, int depth) {
-		super(name, depth);
-		this.filterDepth = depth;
-	}
-
-	@Override
-	public int getFilterDepth() {
-		return this.filterDepth;
-	}
-
-	private int filterDepth;
-
-	@Override
-	public void receiveEvent(WorkflowDataToken token) {
-		receiveToken(token);
-	}
-
-	public void pushToken(WorkflowDataToken dt, String owningProcess,
-			int desiredDepth) {
-		if (dt.getData().getDepth() == desiredDepth)
-			pushData(getName(), owningProcess, dt.getIndex(), dt.getData(), dt
-					.getContext());
-		else {
-			ReferenceService rs = dt.getContext().getReferenceService();
-			Iterator<ContextualizedT2Reference> children = rs.traverseFrom(dt
-					.getData(), dt.getData().getDepth() - 1);
-
-			while (children.hasNext()) {
-				ContextualizedT2Reference ci = children.next();
-				int[] newIndex = new int[dt.getIndex().length
-						+ ci.getIndex().length];
-				int i = 0;
-				for (int indx : dt.getIndex())
-					newIndex[i++] = indx;
-				for (int indx : ci.getIndex())
-					newIndex[i++] = indx;
-				pushToken(new WorkflowDataToken(owningProcess, newIndex, ci
-						.getReference(), dt.getContext()), owningProcess,
-						desiredDepth);
-			}
-			pushCompletion(getName(), owningProcess, dt.getIndex(), dt
-					.getContext());
-		}
-	}
-
-	public void receiveToken(WorkflowDataToken token) {
-		String newOwner = transformOwningProcess(token.getOwningProcess());
-		if (filterDepth == -1)
-			throw new WorkflowStructureException(
-					"Input depth filter not configured on input port, failing");
-
-		int tokenDepth = token.getData().getDepth();
-		if (tokenDepth == filterDepth) {
-			if (filterDepth == getDepth())
-				/*
-				 * Pass event straight through, the filter depth is the same as
-				 * the desired input port depth
-				 */
-				pushData(getName(), newOwner, token.getIndex(),
-						token.getData(), token.getContext());
-			else {
-				pushToken(token, newOwner, getDepth());
-				/*
-				 * Shred the input identifier into the appropriate port depth
-				 * and send the events through, pushing a completion event at
-				 * the end.
-				 */
-			}
-		} else if (tokenDepth > filterDepth) {
-			// Convert to a completion event and push into the iteration strategy
-			pushCompletion(getName(), newOwner, token.getIndex(), token
-					.getContext());
-		} else if (tokenDepth < filterDepth) {
-			/*
-			 * Normally we can ignore these, but there is a special case where
-			 * token depth is less than filter depth and there is no index
-			 * array. In this case we can't throw the token away as there will
-			 * never be an enclosing one so we have to use the data manager to
-			 * register a new single element collection and recurse.
-			 */
-			if (token.getIndex().length == 0) {
-				T2Reference ref = token.getData();
-				ReferenceService rs = token.getContext().getReferenceService();
-				int currentDepth = tokenDepth;
-				while (currentDepth < filterDepth) {
-					// Wrap in a single item list
-					List<T2Reference> newList = new ArrayList<>();
-					newList.add(ref);
-					ref = rs.getListService()
-							.registerList(newList, token.getContext()).getId();
-					currentDepth++;
-				}
-				pushData(getName(), newOwner, new int[0], ref,
-						token.getContext());
-			}
-		}
-	}
-
-	public void setFilterDepth(int filterDepth) {
-		this.filterDepth = filterDepth;
-		if (filterDepth < getDepth())
-			this.filterDepth = getDepth();
-	}
-
-	/**
-	 * Action to take when the filter pushes a completion event out
-	 * 
-	 * @param portName
-	 * @param owningProcess
-	 * @param index
-	 */
-	protected abstract void pushCompletion(String portName,
-			String owningProcess, int[] index, InvocationContext context);
-
-	/**
-	 * Action to take when a data event is created by the filter
-	 * 
-	 * @param portName
-	 * @param owningProcess
-	 * @param index
-	 * @param data
-	 */
-	protected abstract void pushData(String portName, String owningProcess,
-			int[] index, T2Reference data, InvocationContext context);
-
-	/**
-	 * Override this to transform owning process identifiers as they pass
-	 * through the filter, by default this is the identity transformation
-	 * 
-	 * @param oldOwner
-	 * @return
-	 */
-	protected String transformOwningProcess(String oldOwner) {
-		return oldOwner;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractMergeEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractMergeEdit.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractMergeEdit.java
deleted file mode 100644
index 8e14f00..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractMergeEdit.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import net.sf.taverna.t2.workflowmodel.EditException;
-import net.sf.taverna.t2.workflowmodel.Merge;
-
-public abstract class AbstractMergeEdit extends EditSupport<Merge> {
-	private final MergeImpl merge;
-	
-	public AbstractMergeEdit(Merge merge) {
-		if (merge == null)
-			throw new RuntimeException(
-					"Cannot construct a merge edit with a null merge");
-		if (!(merge instanceof MergeImpl))
-			throw new RuntimeException("Merge must be an instanceof MergeImpl");
-		this.merge = (MergeImpl) merge;
-	}
-
-	@Override
-	public final Merge applyEdit() throws EditException {
-		synchronized (merge) {
-			doEditAction(merge);
-		}
-		return merge;
-	}
-
-	protected abstract void doEditAction(MergeImpl mergeImpl) throws EditException;
-	
-	@Override
-	public final Object getSubject() {
-		return merge;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractProcessorEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractProcessorEdit.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractProcessorEdit.java
deleted file mode 100644
index a00bc0c..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractProcessorEdit.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import net.sf.taverna.t2.workflowmodel.EditException;
-import net.sf.taverna.t2.workflowmodel.Processor;
-
-/**
- * Abstraction of an edit acting on a Processor instance. Handles the check to
- * see that the Processor supplied is really a ProcessorImpl.
- * 
- * @author Tom Oinn
- * 
- */
-public abstract class AbstractProcessorEdit extends EditSupport<Processor> {
-	private final ProcessorImpl processor;
-
-	protected AbstractProcessorEdit(Processor processor) {
-		if (processor == null)
-			throw new RuntimeException(
-					"Cannot construct a processor edit with null processor");
-		if (!(processor instanceof ProcessorImpl))
-			throw new RuntimeException(
-					"Edit cannot be applied to a Processor which isn't an instance of ProcessorImpl");
-		this.processor = (ProcessorImpl) processor;
-	}
-
-	@Override
-	public final Processor applyEdit() throws EditException {
-		synchronized (processor) {
-			doEditAction(processor);
-		}
-		return processor;
-	}
-
-	/**
-	 * Do the actual edit here
-	 * 
-	 * @param processor
-	 *            The ProcessorImpl to which the edit applies
-	 * @throws EditException
-	 */
-	protected abstract void doEditAction(ProcessorImpl processor)
-			throws EditException;
-
-	@Override
-	public final Processor getSubject() {
-		return processor;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/BasicEventForwardingOutputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/BasicEventForwardingOutputPort.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/BasicEventForwardingOutputPort.java
deleted file mode 100644
index 7b29a8a..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/BasicEventForwardingOutputPort.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import net.sf.taverna.t2.invocation.WorkflowDataToken;
-import net.sf.taverna.t2.workflowmodel.AbstractOutputPort;
-import net.sf.taverna.t2.workflowmodel.Datalink;
-import net.sf.taverna.t2.workflowmodel.EventForwardingOutputPort;
-
-/**
- * Extension of AbstractOutputPort implementing EventForwardingOutputPort
- * 
- * @author Tom Oinn
- * 
- */
-public class BasicEventForwardingOutputPort extends AbstractOutputPort
-		implements EventForwardingOutputPort {
-	protected Set<DatalinkImpl> outgoingLinks;
-
-	/**
-	 * Construct a new abstract output port with event forwarding capability
-	 * 
-	 * @param portName
-	 * @param portDepth
-	 * @param granularDepth
-	 */
-	public BasicEventForwardingOutputPort(String portName, int portDepth,
-			int granularDepth) {
-		super(portName, portDepth, granularDepth);
-		this.outgoingLinks = new HashSet<>();
-	}
-
-	/**
-	 * Implements EventForwardingOutputPort
-	 */
-	@Override
-	public final Set<? extends Datalink> getOutgoingLinks() {
-		return Collections.unmodifiableSet(this.outgoingLinks);
-	}
-
-	/**
-	 * Forward the specified event to all targets
-	 * 
-	 * @param e
-	 */
-	public void sendEvent(WorkflowDataToken e) {
-		for (Datalink link : outgoingLinks)
-			link.getSink().receiveEvent(e);
-	}
-
-	protected void addOutgoingLink(DatalinkImpl link) {
-		if (outgoingLinks.contains(link) == false)
-			outgoingLinks.add(link);
-	}
-
-	protected void removeOutgoingLink(Datalink link) {
-		outgoingLinks.remove(link);
-	}
-
-	protected void setDepth(int depth) {
-		this.depth = depth;
-	}
-	
-	protected void setGranularDepth(int granularDepth) {
-		this.granularDepth = granularDepth;
-	}
-	
-	protected void setName(String name) {
-		this.name = name;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ConditionImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ConditionImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ConditionImpl.java
deleted file mode 100644
index c3440ec..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ConditionImpl.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import static java.lang.Boolean.TRUE;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import net.sf.taverna.t2.annotation.AbstractAnnotatedThing;
-import net.sf.taverna.t2.workflowmodel.Condition;
-
-class ConditionImpl extends AbstractAnnotatedThing<Condition> implements Condition {
-	private ProcessorImpl control, target;
-	private Map<String, Boolean> stateMap = new HashMap<>();
-
-	protected ConditionImpl(ProcessorImpl control, ProcessorImpl target) {
-		this.control = control;
-		this.target = target;
-	}
-
-	@Override
-	public ProcessorImpl getControl() {
-		return this.control;
-	}
-
-	@Override
-	public ProcessorImpl getTarget() {
-		return this.target;
-	}
-
-	@Override
-	public boolean isSatisfied(String owningProcess) {
-		if (!stateMap.containsKey(owningProcess))
-			return false;
-		return stateMap.get(owningProcess);
-	}
-
-	protected void satisfy(String owningProcess) {
-		stateMap.put(owningProcess, TRUE);
-		// TODO - poke target processor here
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ConfigureEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ConfigureEdit.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ConfigureEdit.java
deleted file mode 100644
index edfaf01..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ConfigureEdit.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import net.sf.taverna.t2.workflowmodel.Configurable;
-import net.sf.taverna.t2.workflowmodel.ConfigurationException;
-import net.sf.taverna.t2.workflowmodel.EditException;
-
-import org.apache.log4j.Logger;
-
-/**
- * An Edit that is responsible for configuring a {@link Configurable} with a
- * given configuration bean.
- * 
- * @author Stuart Owen
- * @author Stian Soiland-Reyes
- * @author Donal Fellows
- */
-class ConfigureEdit<T> extends EditSupport<Configurable<T>> {
-	private static Logger logger = Logger.getLogger(ConfigureEdit.class);
-
-	private final Configurable<T> configurable;
-	private final Class<? extends Configurable<T>> configurableType;
-	private final T configurationBean;
-
-	ConfigureEdit(Class<? extends Configurable<T>> subjectType,
-			Configurable<T> configurable, T configurationBean) {
-		if (configurable == null)
-			throw new RuntimeException(
-					"Cannot construct an edit with null subject");
-		this.configurableType = subjectType;
-		this.configurable = configurable;
-		this.configurationBean = configurationBean;
-		if (!configurableType.isInstance(configurable))
-			throw new RuntimeException(
-					"Edit cannot be applied to an object which isn't an instance of "
-							+ configurableType);
-	}
-
-	@Override
-	public final Configurable<T> applyEdit() throws EditException {
-		try {
-			// FIXME: Should clone bean on configuration to prevent caller from
-			// modifying bean afterwards
-			synchronized (configurable) {
-				configurable.configure(configurationBean);
-			}
-			return configurable;
-		} catch (ConfigurationException e) {
-			logger.error("Error configuring :"
-					+ configurable.getClass().getSimpleName(), e);
-			throw new EditException(e);
-		}
-	}
-
-	@Override
-	public final Configurable<T> getSubject() {
-		return configurable;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/Crystalizer.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/Crystalizer.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/Crystalizer.java
deleted file mode 100644
index 7b95012..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/Crystalizer.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import net.sf.taverna.t2.invocation.Completion;
-import net.sf.taverna.t2.invocation.IterationInternalEvent;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Job;
-
-/**
- * Recieves Job and Completion events and emits Jobs unaltered. Completion
- * events additionally cause registration of lists for each key in the datamap
- * of the jobs at immediate child locations in the index structure. These list
- * identifiers are sent in place of the Completion events.
- * <p>
- * State for a given process ID is purged when a final completion event is
- * received so there is no need for an explicit cache purge operation in the
- * public API (although for termination of partially complete workflows it may
- * be sensible for subclasses to provide one)
- * 
- * @author Tom Oinn
- */
-public interface Crystalizer {
-	/**
-	 * Receive a Job or Completion, Jobs are emitted unaltered and cached,
-	 * Completion events trigger registration of a corresponding list - this may
-	 * be recursive in nature if the completion event's index implies nested
-	 * lists which have not been registered.
-	 */
-	void receiveEvent(
-			IterationInternalEvent<? extends IterationInternalEvent<?>> event);
-
-	/**
-	 * This method is called when a new Job has been handled by the
-	 * AbstractCrystalizer, either by direct passthrough or by list
-	 * registration.
-	 * 
-	 */
-	void jobCreated(Job outputJob);
-
-	/**
-	 * Called whenever a completion not corresponding to a node in the cache is
-	 * generated. In many cases this is an indication of an error state, the
-	 * processor implementation should ensure that completion events are only
-	 * sent to the crystalizer if there has been at least one data event with a
-	 * lower depth on the same path.
-	 */
-	void completionCreated(Completion completion);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/DataflowImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/DataflowImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/DataflowImpl.java
deleted file mode 100644
index b087359..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/DataflowImpl.java
+++ /dev/null
@@ -1,797 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import static java.util.Collections.unmodifiableList;
-import static net.sf.taverna.t2.workflowmodel.utils.Tools.addDataflowIdentification;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
-import net.sf.taverna.t2.annotation.AbstractAnnotatedThing;
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.monitor.MonitorManager;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import net.sf.taverna.t2.workflowmodel.DataflowInputPort;
-import net.sf.taverna.t2.workflowmodel.DataflowOutputPort;
-import net.sf.taverna.t2.workflowmodel.DataflowValidationReport;
-import net.sf.taverna.t2.workflowmodel.Datalink;
-import net.sf.taverna.t2.workflowmodel.EditException;
-import net.sf.taverna.t2.workflowmodel.EventHandlingInputPort;
-import net.sf.taverna.t2.workflowmodel.FailureTransmitter;
-import net.sf.taverna.t2.workflowmodel.InvalidDataflowException;
-import net.sf.taverna.t2.workflowmodel.Merge;
-import net.sf.taverna.t2.workflowmodel.NamedWorkflowEntity;
-import net.sf.taverna.t2.workflowmodel.NamingException;
-import net.sf.taverna.t2.workflowmodel.Processor;
-import net.sf.taverna.t2.workflowmodel.TokenProcessingEntity;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.IterationTypeMismatchException;
-
-/**
- * Implementation of Dataflow including implementation of the dataflow level
- * type checker. Other than this the implementation is fairly simple as it's
- * effectively just a container for other things especially the dataflow input
- * and output port implementations.
- * 
- * @author Tom Oinn
- * 
- */
-public class DataflowImpl extends AbstractAnnotatedThing<Dataflow> implements
-		Dataflow {
-	List<ProcessorImpl> processors;
-	List<MergeImpl> merges;
-	private String name;
-	private static int nameIndex = 1;
-	private List<DataflowInputPortImpl> inputs;
-	private List<DataflowOutputPortImpl> outputs;
-	protected String internalIdentifier;
-	private DataflowValidationReport validationReport;
-
-    /**
-	 * Protected constructor, assigns a default name. To build an instance of
-	 * DataflowImpl you should use the appropriate Edit object from the Edits
-	 * interface
-	 */
-	protected DataflowImpl() {
-		this.name = "Workflow" + (nameIndex++);
-		this.processors = new ArrayList<ProcessorImpl>();
-		this.merges = new ArrayList<MergeImpl>();
-		this.inputs = new ArrayList<DataflowInputPortImpl>();
-		this.outputs = new ArrayList<DataflowOutputPortImpl>();
-		refreshInternalIdentifier();
-	}
-
-	/**
-	 * Adds a processor on the DataFlow.
-	 * 
-	 * @param processor
-	 *            the ProcessorImpl to be added to the Dataflow
-	 * @return
-	 * @throws NamingException
-	 *             if a processor already exists with the same local name
-	 */
-	protected synchronized void addProcessor(ProcessorImpl processor)
-			throws NamingException {
-		for (Processor existingProcessor : new ArrayList<>(processors))
-			if (existingProcessor.getLocalName().equals(
-					processor.getLocalName()))
-				throw new NamingException("There already is a processor named:"
-						+ processor.getLocalName());
-		processors.add(processor);
-	}
-
-	protected synchronized void removeProcessor(Processor processor) {
-		processors.remove(processor);
-	}
-
-	/**
-	 * Adds a processor on the DataFlow.
-	 * 
-	 * @param processor
-	 *            the ProcessorImpl to be added to the Dataflow
-	 * @return
-	 * @throws NamingException
-	 *             if a processor already exists with the same local name
-	 */
-	protected synchronized void addMerge(MergeImpl merge)
-			throws NamingException {
-		for (Merge existingMerge : new ArrayList<>(merges))
-			if (existingMerge.getLocalName().equals(merge.getLocalName()))
-				throw new NamingException(
-						"There already is a merge operation named:"
-								+ merge.getLocalName());
-		merges.add(merge);
-	}
-
-	protected synchronized void removeMerge(Merge merge) {
-		merges.remove(merge);
-	}
-
-	/**
-	 * Build a new dataflow input port, the granular depth is set for the input
-	 * port so it can be copied onto the internal output port
-	 * 
-	 * @param name
-	 *            name of the dataflow input port to build
-	 * @param depth
-	 *            input depth
-	 * @param granularDepth
-	 *            granular depth to copy to the internal output port
-	 * @throws NamingException
-	 *             in the event of a duplicate or invalid name
-	 * @return the newly created input port
-	 */
-	protected synchronized DataflowInputPort createInputPort(String name,
-			int depth, int granularDepth) throws NamingException {
-		for (DataflowInputPort dip : inputs)
-			if (dip.getName().equals(name))
-				throw new NamingException(
-						"Duplicate workflow input port name '" + name
-								+ "' in workflow already.");
-		DataflowInputPortImpl dipi = new DataflowInputPortImpl(name, depth,
-				granularDepth, this);
-		inputs.add(dipi);
-		return dipi;
-	}
-
-	/**
-	 * Adds an input port to the DataFlow.
-	 * 
-	 * @param inputPort
-	 *            the DataflowInputPortImpl to be added to the Dataflow
-	 * @throws EditException
-	 */
-	protected synchronized void addInputPort(DataflowInputPortImpl inputPort)
-			throws EditException {
-		for (DataflowInputPort existingInputPort : new ArrayList<>(inputs))
-			if (existingInputPort.getName().equals(inputPort.getName()))
-				throw new NamingException(
-						"There already is a workflow input port named:"
-								+ inputPort.getName());
-		if (inputPort.getDataflow() != this)
-			throw new EditException("Port specifies a different workflow");
-		inputs.add(inputPort);
-	}
-
-	/**
-	 * Remove the named dataflow input port
-	 * 
-	 * @param name
-	 *            name of the dataflow input port to remove
-	 * @throws EditException
-	 *             if the specified port doesn't exist within this dataflow
-	 */
-	protected synchronized void removeDataflowInputPort(String name)
-			throws EditException {
-		for (DataflowInputPort dip : inputs)
-			if (dip.getName().equals(name)) {
-				removeDataflowInputPort(dip);
-				return;
-			}
-		throw new EditException("No such input port '" + name
-				+ "' in workflow.");
-	}
-
-	/**
-	 * Remove the specified input port from this dataflow
-	 * 
-	 * @param dip
-	 *            dataflow input port to remove
-	 * @throws EditException
-	 *             if the input port isn't in the list of inputs - should never
-	 *             happen but you never know.
-	 */
-	protected synchronized void removeDataflowInputPort(DataflowInputPort dip)
-			throws EditException {
-		if (!inputs.contains(dip))
-			throw new EditException(
-					"Can't locate the specified input port in workflow. Input port has name '"
-							+ dip.getName() + "'.");
-		inputs.remove(dip);
-	}
-
-	/**
-	 * Create and return a new DataflowOutputPort in this dataflow
-	 * 
-	 * @param name
-	 *            name of the port to create, must be unique within the set of
-	 *            output ports for this dataflow
-	 * @return the newly created DataflowOutputPort
-	 * @throws NamingException
-	 *             if the name is invalid or already exists as a name for a
-	 *             dataflow output
-	 */
-	protected synchronized DataflowOutputPort createOutputPort(String name)
-			throws NamingException {
-		for (DataflowOutputPort dop : outputs)
-			if (dop.getName().equals(name))
-				throw new NamingException(
-						"Duplicate workflow output port name '" + name
-								+ "' in workflow already.");
-		DataflowOutputPortImpl dopi = new DataflowOutputPortImpl(name, this);
-		outputs.add(dopi);
-		return dopi;
-	}
-
-	/**
-	 * Adds an output port to the DataFlow.
-	 * 
-	 * @param outputPort
-	 *            the DataflowOutputPortImpl to be added to the Dataflow
-	 * @throws EditException
-	 */
-	protected synchronized void addOutputPort(DataflowOutputPortImpl outputPort)
-			throws EditException {
-		for (DataflowOutputPort existingOutputPort : new ArrayList<>(outputs))
-			if (existingOutputPort.getName().equals(outputPort.getName()))
-				throw new NamingException(
-						"There already is a workflow output port named:"
-								+ outputPort.getName());
-		if (outputPort.getDataflow() != this)
-			throw new EditException("Port specifies a different workflow");
-		outputs.add(outputPort);
-	}
-
-	/**
-	 * Remove the named dataflow output port
-	 * 
-	 * @param name
-	 *            name of the dataflow output port to remove
-	 * @throws EditException
-	 *             if the specified port doesn't exist within this dataflow
-	 */
-	protected synchronized void removeDataflowOutputPort(String name)
-			throws EditException {
-		for (DataflowOutputPort dop : outputs)
-			if (dop.getName().equals(name)) {
-				removeDataflowOutputPort(dop);
-				return;
-			}
-		throw new EditException("No such output port '" + name
-				+ "' in workflow.");
-	}
-
-	/**
-	 * Remove the specified output port from this dataflow
-	 * 
-	 * @param dop
-	 *            dataflow output port to remove
-	 * @throws EditException
-	 *             if the output port isn't in the list of outputs for this
-	 *             dataflow
-	 */
-	protected synchronized void removeDataflowOutputPort(DataflowOutputPort dop)
-			throws EditException {
-		if (!outputs.contains(dop))
-			throw new EditException(
-					"Can't locate the specified output port in workflow, output port has name '"
-							+ dop.getName() + "'.");
-		outputs.remove(dop);
-	}
-
-	/**
-	 * Create a new datalink between two entities within the workflow
-	 * 
-	 * @param sourceName
-	 *            interpreted either as the literal name of a dataflow input
-	 *            port or the colon seperated name of a
-	 *            [processorName|mergeName]:[outputPort]
-	 * @param sinkName
-	 *            as with sourceName but for processor or merge input ports and
-	 *            dataflow output ports
-	 * @return the created Datalink
-	 * @throws EditException
-	 *             if either source or sink isn't found within this dataflow or
-	 *             if the link would violate workflow structural constraints in
-	 *             an immediate way. This won't catch cycles (see the validation
-	 *             methods for that) but will prevent you from having more than
-	 *             one link going to an input port.
-	 */
-	protected synchronized Datalink link(String sourceName, String sinkName)
-			throws EditException {
-		BasicEventForwardingOutputPort source = findSourcePort(sourceName);
-		EventHandlingInputPort sink = findSinkPort(sinkName);
-
-		// Check whether the sink is already linked
-		if (sink.getIncomingLink() != null)
-			throw new EditException("Cannot link to sink port '" + sinkName
-					+ "' as it is already linked");
-
-		/*
-		 * Got here so we have both source and sink and the sink isn't already
-		 * linked from somewhere. If the sink isn't linked we can't have a
-		 * duplicate link here which would have been the other condition to
-		 * check for.
-		 */
-
-		DatalinkImpl link = new DatalinkImpl(source, sink);
-		source.addOutgoingLink(link);
-		((AbstractEventHandlingInputPort) sink).setIncomingLink(link);
-
-		return link;
-	}
-
-	/* @nonnull */
-	private BasicEventForwardingOutputPort findSourcePort(String sourceName)
-			throws EditException {
-		BasicEventForwardingOutputPort source = null;
-		String[] split = sourceName.split(":");
-		if (split.length == 2) {
-			/* source is a processor */
-			// TODO - update to include Merge when it's added
-			for (ProcessorImpl pi : processors)
-				if (pi.getLocalName().equals(split[0])) {
-					source = pi.getOutputPortWithName(split[1]);
-					break;
-				}
-		} else if (split.length == 1) {
-			/*
-			 * source is a workflow input port, or at least the internal output
-			 * port within it
-			 */
-			for (DataflowInputPortImpl dipi : inputs)
-				if (dipi.getName().equals(split[0])) {
-					source = dipi.internalOutput;
-					break;
-				}
-		} else
-			throw new EditException("Invalid source link name '" + sourceName
-					+ "'.");
-		if (source == null)
-			throw new EditException("Unable to find source port named '"
-					+ sourceName + "' in link creation.");
-		return source;
-	}
-
-	/* @nonnull */
-	private EventHandlingInputPort findSinkPort(String sinkName)
-			throws EditException {
-		EventHandlingInputPort sink = null;
-		String[] split;
-		split = sinkName.split(":");
-		if (split.length == 2) {
-			/* sink is a processor */
-			// TODO - update to include Merge when it's added
-			for (ProcessorImpl pi : processors)
-				if (pi.getLocalName().equals(split[0])) {
-					sink = pi.getInputPortWithName(split[1]);
-					break;
-				}
-		} else if (split.length == 1) {
-			/*
-			 * source is a workflow input port, or at least the internal output
-			 * port within it
-			 */
-			for (DataflowOutputPortImpl dopi : outputs)
-				if (dopi.getName().equals(split[0])) {
-					sink = dopi.getInternalInputPort();
-					break;
-				}
-		} else
-			throw new EditException("Invalid link sink name '" + sinkName
-					+ "'.");
-		if (sink == null)
-			throw new EditException("Unable to find sink port named '"
-					+ sinkName + "' in link creation");
-		return sink;
-	}
-	
-	/**
-	 * Return a copy of the list of dataflow input ports for this dataflow
-	 */
-	@Override
-	public synchronized List<? extends DataflowInputPort> getInputPorts() {
-		return unmodifiableList(inputs);
-	}
-
-	/**
-	 * For each processor input, merge input and workflow output get the
-	 * incoming link and, if non null, add to a list and return the entire list.
-	 */
-	@Override
-	public synchronized List<? extends Datalink> getLinks() {
-		List<Datalink> result = new ArrayList<>();
-		/*
-		 * All processors have a set of input ports each of which has at most
-		 * one incoming data link
-		 */
-		for (TokenProcessingEntity p : getEntities(TokenProcessingEntity.class))
-			for (EventHandlingInputPort pip : p.getInputPorts()) {
-				Datalink dl = pip.getIncomingLink();
-				if (dl != null)
-					result.add(dl);
-			}
-		/*
-		 * Workflow outputs have zero or one incoming data link to their
-		 * internal input port
-		 */
-		for (DataflowOutputPort dop : getOutputPorts()) {
-			Datalink dl = dop.getInternalInputPort().getIncomingLink();
-			if (dl != null)
-				result.add(dl);
-		}
-
-		return result;
-	}
-
-	/**
-	 * Return the list of all processors within the dataflow
-	 */
-	@Override
-	public synchronized List<? extends Processor> getProcessors() {
-		return getEntities(Processor.class);
-	}
-
-	/**
-	 * Return the list of all merge operations within the dataflow
-	 */
-	@Override
-	public synchronized List<? extends Merge> getMerges() {
-		return getEntities(Merge.class);
-	}
-
-	/**
-	 * Return all dataflow output ports
-	 */
-	@Override
-	public synchronized List<? extends DataflowOutputPort> getOutputPorts() {
-		return unmodifiableList(outputs);
-	}
-
-	/**
-	 * Return the local name of this workflow
-	 */
-	@Override
-	public String getLocalName() {
-		return this.name;
-	}
-
-	/**
-	 * Run the type check algorithm and return a report on any problems found.
-	 * This method must be called prior to actually pushing data through the
-	 * dataflow as it sets various properties as a side effect.
-	 * 
-	 * If the workflow has been set immutable with {@link #setImmutable()},
-	 * subsequent calls to this method will return the cached
-	 * DataflowValidationReport.
-	 * 
-	 */
-	@Override
-	public DataflowValidationReport checkValidity() {
-		if (!immutable)
-			// Don't store it!
-			return checkValidityImpl();
-		if (validationReport == null)
-			validationReport = checkValidityImpl();
-		return validationReport;
-	}
-
-	/**
-	 * Works out whether a dataflow is valid. <strong>This includes working out
-	 * the real depths of output ports.</strong>
-	 */
-	public synchronized DataflowValidationReport checkValidityImpl() {
-		// First things first - nullify the resolved depths in all datalinks
-		for (Datalink dl : getLinks())
-			if (dl instanceof DatalinkImpl)
-				((DatalinkImpl) dl).setResolvedDepth(-1);
-		// Now copy type information from workflow inputs
-		for (DataflowInputPort dip : getInputPorts())
-			for (Datalink dl : dip.getInternalOutputPort().getOutgoingLinks())
-				if (dl instanceof DatalinkImpl)
-					((DatalinkImpl) dl).setResolvedDepth(dip.getDepth());
-
-		/*
-		 * ==================================================================
-		 * Now iteratively attempt to resolve everything else.
-		 * ==================================================================
-		 */
-
-		/*
-		 * Firstly take a copy of the processor list, we'll processors from this
-		 * list as they become either failed or resolved
-		 */
-		List<TokenProcessingEntity> unresolved = new ArrayList<>(
-				getEntities(TokenProcessingEntity.class));
-
-		// Keep a list of processors that have failed, initially empty
-		List<TokenProcessingEntity> failed = new ArrayList<>();
-
-		/**
-		 * Is the dataflow valid? The flow is valid if and only if both
-		 * unresolved and failed lists are empty at the end. This doesn't
-		 * guarantee that the workflow will run, in particular it doesn't
-		 * actually check for issues such as unresolved output edges.
-		 */
-
-		// Flag to indicate whether we've finished yet, set to true if no
-		// changes are made in an iteration
-		boolean finished = false;
-
-		Map<TokenProcessingEntity, DataflowValidationReport> invalidDataflows = new HashMap<>();
-		while (!finished) {
-			// We're finished unless something happens later
-			finished = true;
-			// Keep a list of processors to remove from the unresolved list
-			// because they've been resolved properly
-			List<TokenProcessingEntity> removeValidated = new ArrayList<>();
-			// Keep another list of those that have failed
-			List<TokenProcessingEntity> removeFailed = new ArrayList<>();
-
-			for (TokenProcessingEntity p : unresolved)
-				try {
-					/*
-					 * true = checked and valid, false = can't check, the
-					 * exception means the processor was checked but was invalid
-					 * for some reason
-					 */
-
-					if (p.doTypeCheck()) {
-						removeValidated.add(p);
-						/*
-						 * At least one thing validated; we will need to run the
-						 * check loop at least once more.
-						 */
-						finished = false;
-					}
-				} catch (IterationTypeMismatchException e) {
-					removeFailed.add(p);
-				} catch (InvalidDataflowException e) {
-					invalidDataflows.put(p, e.getDataflowValidationReport());
-					removeFailed.add(p);
-				}
-
-			/*
-			 * Remove validated and failed items from the pending lists.
-			 */
-			unresolved.removeAll(removeValidated);
-			unresolved.removeAll(removeFailed);
-			failed.addAll(removeFailed);
-		}
-
-		/*
-		 * At this point we know whether the processors within the workflow
-		 * validated. If all the processors validated then we're probably okay,
-		 * but there are a few other problems to check for. Firstly we need to
-		 * check whether all the dataflow outputs are connected; any unconnected
-		 * output is by definition a validation failure.
-		 */
-		List<DataflowOutputPort> unresolvedOutputs = new ArrayList<>();
-		for (DataflowOutputPortImpl dopi : outputs) {
-			Datalink dl = dopi.getInternalInputPort().getIncomingLink();
-			/*
-			 * Unset any type information on the output port, we'll set it again
-			 * later if there's a suitably populated link going into it
-			 */
-			dopi.setDepths(-1, -1);
-			if (dl == null)
-				// not linked, this is by definition an unsatisfied link!
-				unresolvedOutputs.add(dopi);
-			else if (dl.getResolvedDepth() == -1)
-				/*
-				 * linked but the edge hasn't had its depth resolved, i.e. it
-				 * links from an unresolved entity
-				 */
-				unresolvedOutputs.add(dopi);
-			else {
-				/*
-				 * linked and edge depth is defined, we can therefore populate
-				 * the granular and real depth of the dataflow output port. Note
-				 * that this is the only way these values can be populated, you
-				 * don't define them when creating the ports as they are
-				 * entirely based on the type check stage.
-				 */
-
-				int granularDepth = dl.getSource().getGranularDepth();
-				int resolvedDepth = dl.getResolvedDepth();
-				dopi.setDepths(resolvedDepth, granularDepth);
-			}
-		}
-
-		/*
-		 * Check if workflow is 'incomplete' - i.e. if it contains no processors
-		 * and no output ports. This is to prevent empty workflows or ones that
-		 * contain input ports from being run.
-		 */
-
-		boolean dataflowIsIncomplete = getProcessors().isEmpty()
-				&& getOutputPorts().isEmpty();
-
-		/*
-		 * For a workflow to be valid - workflow must not be 'empty' and lists
-		 * of problems must all be empty
-		 */
-
-		boolean dataflowValid = (!dataflowIsIncomplete)
-				&& unresolvedOutputs.isEmpty() && failed.isEmpty()
-				&& unresolved.isEmpty();
-
-		/*
-		 * Build and return a new validation report containing the overall state
-		 * along with lists of failed and unsatisfied processors and unsatisfied
-		 * output ports
-		 */
-
-		return new DataflowValidationReportImpl(dataflowValid,
-				dataflowIsIncomplete, failed, unresolved, unresolvedOutputs,
-				invalidDataflows);
-	}
-
-	/**
-	 * Gets all workflow entities of the specified type and returns as an
-	 * unmodifiable list of that type
-	 */
-	@Override
-	public <T extends NamedWorkflowEntity> List<? extends T> getEntities(
-			Class<T> entityType) {
-		List<T> result = new ArrayList<T>();
-		filterAndAdd(processors, result, entityType);
-		filterAndAdd(merges, result, entityType);
-		return unmodifiableList(result);
-	}
-
-	private <T extends NamedWorkflowEntity> void filterAndAdd(
-			Iterable<?> source, List<T> target, Class<T> type) {
-		for (Object o : source)
-			if (type.isAssignableFrom(o.getClass()))
-				target.add(type.cast(o));
-	}
-
-	/**
-	 * The active process identifiers correspond to current strands of data
-	 * running through this dataflow.
-	 */
-	private Set<String> activeProcessIdentifiers = new HashSet<>();
-	private volatile boolean immutable;
-
-	/**
-	 * Called when a token is received or the dataflow is fired, checks to see
-	 * whether the process identifier is already known (in which case we assume
-	 * it's been registered and can ignore it) or registers it with the monitor
-	 * along with all child entities. The method is called with the ID of the
-	 * new process, that is to say the ID of the token with ':'getLocalName()
-	 * appended.
-	 * 
-	 * @param owningProcess
-	 * 
-	 * @return true if the owning process specified was already in the active
-	 *         process identifier set, false otherwise
-	 */
-	protected boolean tokenReceived(String owningProcess,
-			InvocationContext context) {
-		synchronized (activeProcessIdentifiers) {
-			if (activeProcessIdentifiers.contains(owningProcess))
-				return true;
-			MonitorManager.getInstance().registerNode(this, owningProcess);
-
-			/*
-			 * Message each processor within the dataflow and instruct it to
-			 * register any properties with the monitor including any processor
-			 * level properties it can aggregate from its dispatch stack.
-			 */
-
-			for (ProcessorImpl p : getEntities(ProcessorImpl.class)) {
-				p.registerWithMonitor(owningProcess);
-				if (p.getInputPorts().isEmpty())
-					p.fire(owningProcess, context);
-			}
-			activeProcessIdentifiers.add(owningProcess);
-			return false;
-		}
-	}
-
-	/**
-	 * Sets the local name for the dataflow
-	 * 
-	 * @param localName
-	 */
-	public void setLocalName(String localName) {
-		if (immutable)
-			throw new UnsupportedOperationException("Dataflow is immutable");
-		name = localName;
-	}
-
-	@Override
-	public String toString() {
-		return "Dataflow " + getLocalName() + "[" + getIdentifier() + "]";
-	}
-
-	@Override
-	public void fire(String owningProcess, InvocationContext context) {
-		String newOwningProcess = owningProcess + ":" + getLocalName();
-		if (tokenReceived(newOwningProcess, context)) {
-			/*
-			 * This is not good - should ideally handle it as it means the
-			 * workflow has been fired when in a state where this wasn't
-			 * sensible, i.e. already having been fired on this process
-			 * identifier. For now we'll ignore it (ho hum, release deadline
-			 * etc!)
-			 */
-		}
-		/*
-		 * The code below now happens in the tokenReceived method, we need to
-		 * fire any processors which don't have dependencies when a new token
-		 * arrives and we weren't doing that anywhere.
-		 */
-		/**
-		 * for (Processor p : getEntities(Processor.class)) { if
-		 * (p.getInputPorts().isEmpty()) { p.fire(newOwningProcess, context); }
-		 * }
-		 */
-	}
-
-	@Override
-	public FailureTransmitter getFailureTransmitter() {
-		throw new UnsupportedOperationException(
-				"Not implemented for DataflowImpl yet");
-	}
-
-	@Override
-	public boolean doTypeCheck() throws IterationTypeMismatchException {
-		throw new UnsupportedOperationException(
-				"Not implemented for DataflowImpl yet");
-	}
-
-	public void refreshInternalIdentifier() {
-		setIdentifier(UUID.randomUUID().toString());
-	}
-
-	@Override
-	public String getIdentifier() {
-		return internalIdentifier;
-	}
-
-	@Override
-	public String recordIdentifier() {
-		addDataflowIdentification(this, internalIdentifier, new EditsImpl());
-		return internalIdentifier;
-	}
-
-	void setIdentifier(String id) {
-		if (immutable)
-			throw new UnsupportedOperationException("Dataflow is immutable");
-		this.internalIdentifier = id;
-	}
-
-	@Override
-	public boolean isInputPortConnected(DataflowInputPort inputPort) {
-		for (Datalink link : getLinks())
-			if (link.getSource().equals(inputPort.getInternalOutputPort()))
-				return true;
-		return false;
-	}
-
-	@Override
-	public synchronized void setImmutable() {
-		if (immutable)
-			return;
-		processors = unmodifiableList(processors);
-		merges = unmodifiableList(merges);
-		outputs = unmodifiableList(outputs);
-		inputs = unmodifiableList(inputs);
-		immutable = true;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/DataflowInputPortImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/DataflowInputPortImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/DataflowInputPortImpl.java
deleted file mode 100644
index 804bc5a..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/DataflowInputPortImpl.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import net.sf.taverna.t2.invocation.WorkflowDataToken;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import net.sf.taverna.t2.workflowmodel.DataflowInputPort;
-import net.sf.taverna.t2.workflowmodel.Datalink;
-import net.sf.taverna.t2.workflowmodel.EventForwardingOutputPort;
-
-public class DataflowInputPortImpl extends AbstractEventHandlingInputPort
-		implements DataflowInputPort {
-	protected BasicEventForwardingOutputPort internalOutput;
-	private int granularInputDepth;
-	private Dataflow dataflow;
-
-	DataflowInputPortImpl(String name, int depth, int granularDepth, Dataflow df) {
-		super(name, depth);
-		granularInputDepth = granularDepth;
-		dataflow = df;
-		internalOutput = new BasicEventForwardingOutputPort(name, depth,
-				granularDepth);
-	}
-
-	@Override
-	public int getGranularInputDepth() {
-		return granularInputDepth;
-	}
-
-	void setDepth(int depth) {
-		this.depth = depth;
-		internalOutput.setDepth(depth);
-	}
-	
-	void setGranularDepth(int granularDepth) {
-		this.granularInputDepth = granularDepth;
-		internalOutput.setGranularDepth(granularDepth);
-	}
-	
-	@Override
-	public EventForwardingOutputPort getInternalOutputPort() {
-		return internalOutput;
-	}
-
-	/**
-	 * Receive an input event, relay it through the internal output port to all
-	 * connected entities
-	 */
-	@Override
-	public void receiveEvent(WorkflowDataToken t) {
-		WorkflowDataToken transformedToken = t.pushOwningProcess(dataflow.getLocalName());
-		/*
-		 * I'd rather avoid casting to the implementation but in this case we're
-		 * in the same package - the only reason to do this is to allow dummy
-		 * implementations of parts of this infrastructure during testing, in
-		 * 'real' use this should always be a dataflowimpl
-		 */
-		if (dataflow instanceof DataflowImpl)
-			((DataflowImpl) dataflow).tokenReceived(transformedToken
-					.getOwningProcess(), t.getContext());
-		for (Datalink dl : internalOutput.getOutgoingLinks())
-			dl.getSink().receiveEvent(transformedToken);
-	}
-
-	@Override
-	public Dataflow getDataflow() {
-		return dataflow;
-	}
-	
-	@Override
-	public void setName(String newName) {
-		this.name = newName;
-		internalOutput.setName(newName);
-	}	
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/DataflowOutputPortImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/DataflowOutputPortImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/DataflowOutputPortImpl.java
deleted file mode 100644
index a341628..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/DataflowOutputPortImpl.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import static java.util.Collections.synchronizedList;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sf.taverna.t2.facade.ResultListener;
-import net.sf.taverna.t2.invocation.WorkflowDataToken;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import net.sf.taverna.t2.workflowmodel.DataflowOutputPort;
-import net.sf.taverna.t2.workflowmodel.EventHandlingInputPort;
-
-class DataflowOutputPortImpl extends BasicEventForwardingOutputPort
-		implements DataflowOutputPort {
-	protected InternalInputPort internalInput;
-	/**
-	 * Remember to synchronize access to this list
-	 */
-	protected List<ResultListener> resultListeners = synchronizedList(new ArrayList<ResultListener>());
-	private Dataflow dataflow;
-
-	DataflowOutputPortImpl(String portName, Dataflow dataflow) {
-		super(portName, -1, -1);
-		this.dataflow = dataflow;
-		this.internalInput = new InternalInputPort(name, dataflow, portName);
-	}
-
-	@Override
-	public EventHandlingInputPort getInternalInputPort() {
-		return this.internalInput;
-	}
-
-	@Override
-	public Dataflow getDataflow() {
-		return this.dataflow;
-	}
-
-	void setDepths(int depth, int granularDepth) {
-		this.depth = depth;
-		this.granularDepth = granularDepth;
-	}
-
-	@Override
-	public void addResultListener(ResultListener listener) {
-		resultListeners.add(listener);		
-	}
-
-	@Override
-	public void removeResultListener(ResultListener listener) {
-		resultListeners.remove(listener);
-	}
-	
-	@Override
-	public void setName(String newName) {
-		this.name = newName;
-		internalInput.setName(newName);
-	}
-
-	/** This makes a thread-safe copy. */
-	private List<ResultListener> getListeners() {
-		synchronized (resultListeners) {
-			return new ArrayList<>(resultListeners);
-		}
-	}
-
-	private class InternalInputPort extends AbstractEventHandlingInputPort {
-		InternalInputPort(String name, Dataflow dataflow, String portName) {
-			super(name, -1);
-		}
-
-		/**
-		 * Forward the event through the output port Also informs any
-		 * ResultListeners on the output port to the new token.
-		 */
-		@Override
-		public void receiveEvent(WorkflowDataToken token) {
-			WorkflowDataToken newToken = token.popOwningProcess();
-			sendEvent(newToken);
-			for (ResultListener listener : getListeners())
-				listener.resultTokenProduced(newToken, this.getName());
-		}
-
-		/**
-		 * Always copy the value of the enclosing dataflow output port
-		 */
-		@Override
-		public int getDepth() {
-			return DataflowOutputPortImpl.this.getDepth();
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/DataflowValidationReportImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/DataflowValidationReportImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/DataflowValidationReportImpl.java
deleted file mode 100644
index 9e2abc0..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/DataflowValidationReportImpl.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import static java.util.Collections.unmodifiableList;
-import static java.util.Collections.unmodifiableMap;
-
-import java.util.List;
-import java.util.Map;
-
-import net.sf.taverna.t2.workflowmodel.DataflowOutputPort;
-import net.sf.taverna.t2.workflowmodel.DataflowValidationReport;
-import net.sf.taverna.t2.workflowmodel.TokenProcessingEntity;
-
-/**
- * Simple implementation of the DataflowValidationReport interface
- * 
- * @author Tom Oinn
- */
-public class DataflowValidationReportImpl implements DataflowValidationReport {
-	private final List<TokenProcessingEntity> failed;
-	private final Map<TokenProcessingEntity, DataflowValidationReport> invalidDataflows;
-	private final List<DataflowOutputPort> unresolvedOutputs;
-	private final List<TokenProcessingEntity> unsatisfied;
-	private boolean valid;
-	/**
-	 * whether a workflow is incomplete (contains no processors and no output
-	 * ports), in which case it also must be invalid
-	 */
-	private boolean isWorkflowIncomplete;
-
-	DataflowValidationReportImpl(
-			boolean isValid,
-			boolean isWorkflowIncomplete,
-			List<TokenProcessingEntity> failedProcessors,
-			List<TokenProcessingEntity> unsatisfiedProcessors,
-			List<DataflowOutputPort> unresolvedOutputs,
-			Map<TokenProcessingEntity, DataflowValidationReport> invalidDataflows) {
-		this.valid = isValid;
-		this.isWorkflowIncomplete = isWorkflowIncomplete;
-		this.invalidDataflows = unmodifiableMap(invalidDataflows);
-		this.failed = unmodifiableList(failedProcessors);
-		this.unsatisfied = unmodifiableList(unsatisfiedProcessors);
-		this.unresolvedOutputs = unmodifiableList(unresolvedOutputs);
-	}
-
-	@Override
-	public List<? extends TokenProcessingEntity> getFailedEntities() {
-		return failed;
-	}
-
-	@Override
-	public Map<TokenProcessingEntity, DataflowValidationReport> getInvalidDataflows() {
-		return invalidDataflows;
-	}
-
-	@Override
-	public List<? extends DataflowOutputPort> getUnresolvedOutputs() {
-		return unresolvedOutputs;
-	}
-
-	@Override
-	public List<? extends TokenProcessingEntity> getUnsatisfiedEntities() {
-		return unsatisfied;
-	}
-
-	@Override
-	public boolean isValid() {
-		return valid;
-	}
-
-	@Override
-	public boolean isWorkflowIncomplete() {
-		return isWorkflowIncomplete;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/DatalinkImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/DatalinkImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/DatalinkImpl.java
deleted file mode 100644
index c33d83f..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/DatalinkImpl.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import net.sf.taverna.t2.annotation.AbstractAnnotatedThing;
-import net.sf.taverna.t2.workflowmodel.Datalink;
-import net.sf.taverna.t2.workflowmodel.EventForwardingOutputPort;
-import net.sf.taverna.t2.workflowmodel.EventHandlingInputPort;
-
-/**
- * Naive bean implementation of Datalink
- * 
- * @author Tom Oinn
- */
-class DatalinkImpl extends AbstractAnnotatedThing<Datalink> implements Datalink {
-	private EventForwardingOutputPort source;
-	private EventHandlingInputPort sink;
-	private transient int resolvedDepth = -1;
-
-	@Override
-	public int getResolvedDepth() {
-		return this.resolvedDepth;
-	}
-
-	protected void setResolvedDepth(int newResolvedDepth) {
-		this.resolvedDepth = newResolvedDepth;
-	}
-
-	protected DatalinkImpl(EventForwardingOutputPort source,
-			EventHandlingInputPort sink) {
-		this.source = source;
-		this.sink = sink;
-	}
-
-	@Override
-	public EventHandlingInputPort getSink() {
-		return sink;
-	}
-
-	@Override
-	public EventForwardingOutputPort getSource() {
-		return source;
-	}
-
-	@Override
-	public String toString() {
-		return "link(" + resolvedDepth + ")" + source.getName() + ":"
-				+ sink.getName();
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/EditSupport.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/EditSupport.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/EditSupport.java
deleted file mode 100644
index e7447ff..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/EditSupport.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import net.sf.taverna.t2.workflowmodel.Edit;
-import net.sf.taverna.t2.workflowmodel.EditException;
-
-abstract class EditSupport<T> implements Edit<T> {
-	protected boolean applied;
-
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public final T doEdit() throws EditException {
-		if (applied)
-			throw new EditException("Edit has already been applied!");
-		T result = applyEdit();
-		applied = true;
-		return result;
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public final boolean isApplied() {
-		return applied;
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public final void undo() {
-		if (!applied)
-			throw new RuntimeException(
-					"Attempt to undo edit that was never applied");
-		applyUndo();
-	}
-
-	protected abstract T applyEdit() throws EditException;
-
-	protected void applyUndo() {
-		throw new UnsupportedOperationException(
-				"undo not supported by this interface in Taverna 3");
-	}
-}


[26/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-services-api/src/main/java/uk/org/taverna/commons/services/ServiceRegistry.java
----------------------------------------------------------------------
diff --git a/taverna-services-api/src/main/java/uk/org/taverna/commons/services/ServiceRegistry.java b/taverna-services-api/src/main/java/uk/org/taverna/commons/services/ServiceRegistry.java
deleted file mode 100644
index 62e45b4..0000000
--- a/taverna-services-api/src/main/java/uk/org/taverna/commons/services/ServiceRegistry.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.commons.services;
-
-import java.net.URI;
-import java.util.Set;
-
-import org.apache.taverna.scufl2.api.port.InputActivityPort;
-import org.apache.taverna.scufl2.api.port.OutputActivityPort;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * Register of Taverna services.
- *
- * @author David Withers
- */
-public interface ServiceRegistry {
-
-	/**
-	 * Returns the activity types in the registry.
-	 *
-	 * @return the activity types in the registry
-	 */
-	public Set<URI> getActivityTypes();
-
-	/**
-	 * Returns the JSON Schema for the configuration required by an activity.
-	 *
-	 * @param activityType
-	 *            the activity type
-	 * @return the JSON Schema for the configuration required by an activity
-	 * @throws ActivityTypeNotFoundException
-	 *             if the activity type is not in the registry
-	 */
-	public JsonNode getActivityConfigurationSchema(URI activityType)
-			throws InvalidConfigurationException, ActivityTypeNotFoundException;
-
-	/**
-	 * Returns the input ports that the activity type requires to be present in order to execute
-	 * with the specified configuration.
-	 * <p>
-	 * If the activity does not require any input port for the configuration then an empty set is
-	 * returned.
-	 *
-	 * @param configuration
-	 *            the activity configuration
-	 * @throws ActivityTypeNotFoundException
-	 *             if the activity type is not in the registry
-	 * @return the input ports that the activity requires to be present in order to execute
-	 */
-	public Set<InputActivityPort> getActivityInputPorts(URI activityType,
-			JsonNode configuration) throws InvalidConfigurationException, ActivityTypeNotFoundException;
-
-	/**
-	 * Returns the output ports that the activity type requires to be present in order to execute
-	 * with the specified configuration.
-	 * <p>
-	 * If the activity type does not require any output ports for the configuration then an empty
-	 * set is returned.
-	 *
-	 * @param configuration
-	 *            the activity configuration
-	 * @throws ActivityTypeNotFoundException
-	 *             if the activity type is not in the registry
-	 * @return the output ports that the activity requires to be present in order to execute
-	 */
-	public Set<OutputActivityPort> getActivityOutputPorts(URI activityType,
-			JsonNode configuration) throws InvalidConfigurationException, ActivityTypeNotFoundException;
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-services-impl/src/main/java/org/apache/taverna/commons/services/impl/ServiceRegistryImpl.java
----------------------------------------------------------------------
diff --git a/taverna-services-impl/src/main/java/org/apache/taverna/commons/services/impl/ServiceRegistryImpl.java b/taverna-services-impl/src/main/java/org/apache/taverna/commons/services/impl/ServiceRegistryImpl.java
new file mode 100644
index 0000000..1aaf1de
--- /dev/null
+++ b/taverna-services-impl/src/main/java/org/apache/taverna/commons/services/impl/ServiceRegistryImpl.java
@@ -0,0 +1,91 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.commons.services.impl;
+
+import java.net.URI;
+import java.util.Set;
+
+import org.apache.taverna.commons.services.ActivityTypeNotFoundException;
+import org.apache.taverna.commons.services.InvalidConfigurationException;
+import org.apache.taverna.commons.services.ServiceRegistry;
+import org.apache.taverna.platform.capability.api.ActivityConfigurationException;
+import org.apache.taverna.platform.capability.api.ActivityNotFoundException;
+import org.apache.taverna.platform.capability.api.ActivityService;
+import org.apache.taverna.scufl2.api.port.InputActivityPort;
+import org.apache.taverna.scufl2.api.port.OutputActivityPort;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * Simple implementation of a ServiceRegistry that discovers available services from the
+ * ActivityService.
+ *
+ * @author David Withers
+ */
+public class ServiceRegistryImpl implements ServiceRegistry {
+
+	private ActivityService activityService;
+
+	@Override
+	public Set<URI> getActivityTypes() {
+		return activityService.getActivityTypes();
+	}
+
+	@Override
+	public JsonNode getActivityConfigurationSchema(URI activityType)
+			throws InvalidConfigurationException, ActivityTypeNotFoundException {
+		try {
+			return activityService.getActivityConfigurationSchema(activityType);
+		} catch (ActivityConfigurationException e) {
+			throw new InvalidConfigurationException(e);
+		} catch (ActivityNotFoundException e) {
+			throw new ActivityTypeNotFoundException(e);
+		}
+	}
+
+	@Override
+	public Set<InputActivityPort> getActivityInputPorts(URI activityType, JsonNode configuration)
+			throws InvalidConfigurationException, ActivityTypeNotFoundException {
+		try {
+			return activityService.getActivityInputPorts(activityType, configuration);
+		} catch (ActivityConfigurationException e) {
+			throw new InvalidConfigurationException(e);
+		} catch (ActivityNotFoundException e) {
+			throw new ActivityTypeNotFoundException(e);
+		}
+	}
+
+	@Override
+	public Set<OutputActivityPort> getActivityOutputPorts(URI activityType, JsonNode configuration)
+			throws InvalidConfigurationException, ActivityTypeNotFoundException {
+		try {
+			return activityService.getActivityOutputPorts(activityType, configuration);
+		} catch (ActivityConfigurationException e) {
+			throw new InvalidConfigurationException(e);
+		} catch (ActivityNotFoundException e) {
+			throw new ActivityTypeNotFoundException(e);
+		}
+	}
+
+	public void setActivityService(ActivityService activityService) {
+		this.activityService = activityService;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-services-impl/src/main/java/uk/org/taverna/commons/services/impl/ServiceRegistryImpl.java
----------------------------------------------------------------------
diff --git a/taverna-services-impl/src/main/java/uk/org/taverna/commons/services/impl/ServiceRegistryImpl.java b/taverna-services-impl/src/main/java/uk/org/taverna/commons/services/impl/ServiceRegistryImpl.java
deleted file mode 100644
index bb5a0d0..0000000
--- a/taverna-services-impl/src/main/java/uk/org/taverna/commons/services/impl/ServiceRegistryImpl.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.commons.services.impl;
-
-import java.net.URI;
-import java.util.Set;
-
-import uk.org.taverna.commons.services.ActivityTypeNotFoundException;
-import uk.org.taverna.commons.services.InvalidConfigurationException;
-import uk.org.taverna.commons.services.ServiceRegistry;
-import org.apache.taverna.platform.capability.api.ActivityConfigurationException;
-import org.apache.taverna.platform.capability.api.ActivityNotFoundException;
-import org.apache.taverna.platform.capability.api.ActivityService;
-import org.apache.taverna.scufl2.api.port.InputActivityPort;
-import org.apache.taverna.scufl2.api.port.OutputActivityPort;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * Simple implementation of a ServiceRegistry that discovers available services from the
- * ActivityService.
- *
- * @author David Withers
- */
-public class ServiceRegistryImpl implements ServiceRegistry {
-
-	private ActivityService activityService;
-
-	@Override
-	public Set<URI> getActivityTypes() {
-		return activityService.getActivityTypes();
-	}
-
-	@Override
-	public JsonNode getActivityConfigurationSchema(URI activityType)
-			throws InvalidConfigurationException, ActivityTypeNotFoundException {
-		try {
-			return activityService.getActivityConfigurationSchema(activityType);
-		} catch (ActivityConfigurationException e) {
-			throw new InvalidConfigurationException(e);
-		} catch (ActivityNotFoundException e) {
-			throw new ActivityTypeNotFoundException(e);
-		}
-	}
-
-	@Override
-	public Set<InputActivityPort> getActivityInputPorts(URI activityType, JsonNode configuration)
-			throws InvalidConfigurationException, ActivityTypeNotFoundException {
-		try {
-			return activityService.getActivityInputPorts(activityType, configuration);
-		} catch (ActivityConfigurationException e) {
-			throw new InvalidConfigurationException(e);
-		} catch (ActivityNotFoundException e) {
-			throw new ActivityTypeNotFoundException(e);
-		}
-	}
-
-	@Override
-	public Set<OutputActivityPort> getActivityOutputPorts(URI activityType, JsonNode configuration)
-			throws InvalidConfigurationException, ActivityTypeNotFoundException {
-		try {
-			return activityService.getActivityOutputPorts(activityType, configuration);
-		} catch (ActivityConfigurationException e) {
-			throw new InvalidConfigurationException(e);
-		} catch (ActivityNotFoundException e) {
-			throw new ActivityTypeNotFoundException(e);
-		}
-	}
-
-	public void setActivityService(ActivityService activityService) {
-		this.activityService = activityService;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-services-impl/src/main/resources/META-INF/spring/taverna-services-context-osgi.xml
----------------------------------------------------------------------
diff --git a/taverna-services-impl/src/main/resources/META-INF/spring/taverna-services-context-osgi.xml b/taverna-services-impl/src/main/resources/META-INF/spring/taverna-services-context-osgi.xml
index 70fdfef..b33d451 100644
--- a/taverna-services-impl/src/main/resources/META-INF/spring/taverna-services-context-osgi.xml
+++ b/taverna-services-impl/src/main/resources/META-INF/spring/taverna-services-context-osgi.xml
@@ -6,7 +6,7 @@
                                  http://www.springframework.org/schema/osgi
                                  http://www.springframework.org/schema/osgi/spring-osgi.xsd">
 
-	<service ref="serviceRegistry" interface="uk.org.taverna.commons.services.ServiceRegistry" />
+	<service ref="serviceRegistry" interface="org.apache.taverna.commons.services.ServiceRegistry" />
 
     <reference id="activityService" interface="uk.org.taverna.platform.capability.api.ActivityService" />
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-services-impl/src/main/resources/META-INF/spring/taverna-services-context.xml
----------------------------------------------------------------------
diff --git a/taverna-services-impl/src/main/resources/META-INF/spring/taverna-services-context.xml b/taverna-services-impl/src/main/resources/META-INF/spring/taverna-services-context.xml
index 72c88d1..4ee6119 100644
--- a/taverna-services-impl/src/main/resources/META-INF/spring/taverna-services-context.xml
+++ b/taverna-services-impl/src/main/resources/META-INF/spring/taverna-services-context.xml
@@ -3,7 +3,7 @@
 	xsi:schemaLocation="http://www.springframework.org/schema/beans
                            http://www.springframework.org/schema/beans/spring-beans.xsd">
 
-	<bean id="serviceRegistry" class="uk.org.taverna.commons.services.impl.ServiceRegistryImpl">
+	<bean id="serviceRegistry" class="org.apache.taverna.commons.services.impl.ServiceRegistryImpl">
 		<property name="activityService" ref="activityService" />
 	</bean>
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-stringconstant-activity/src/main/java/net/sf/taverna/t2/activities/stringconstant/StringConstantActivity.java
----------------------------------------------------------------------
diff --git a/taverna-stringconstant-activity/src/main/java/net/sf/taverna/t2/activities/stringconstant/StringConstantActivity.java b/taverna-stringconstant-activity/src/main/java/net/sf/taverna/t2/activities/stringconstant/StringConstantActivity.java
deleted file mode 100644
index 7248f90..0000000
--- a/taverna-stringconstant-activity/src/main/java/net/sf/taverna/t2/activities/stringconstant/StringConstantActivity.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.stringconstant;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import net.sf.taverna.t2.annotation.annotationbeans.MimeType;
-import net.sf.taverna.t2.reference.ReferenceService;
-import net.sf.taverna.t2.reference.ReferenceServiceException;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.EditException;
-import net.sf.taverna.t2.workflowmodel.processor.activity.AbstractAsynchronousActivity;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityConfigurationException;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityOutputPort;
-import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback;
-
-import org.apache.log4j.Logger;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * An Activity that holds a constant string value.
- * <p>
- * It is automatically configured to have no input ports and only one output port named
- * <em>value</em>.
- *
- * @author Stuart Owen
- * @author David Withers
- */
-public class StringConstantActivity extends AbstractAsynchronousActivity<JsonNode> {
-
-	public static final String URI = "http://ns.taverna.org.uk/2010/activity/constant";
-
-	private static final Logger logger = Logger.getLogger(StringConstantActivity.class);
-
-	private String value;
-
-	private JsonNode json;
-
-	@Override
-	public void configure(JsonNode json) throws ActivityConfigurationException {
-		this.json = json;
-		this.value = json.get("string").asText();
-//		if (outputPorts.size() == 0) {
-//			addOutput("value", 0, "text/plain");
-//		}
-	}
-
-	public String getStringValue() {
-		return json.get("string").asText();
-	}
-
-	@Override
-	public JsonNode getConfiguration() {
-		return json;
-	}
-
-	@Override
-	public void executeAsynch(final Map<String, T2Reference> data,
-			final AsynchronousActivityCallback callback) {
-		callback.requestRun(new Runnable() {
-
-			@Override
-			public void run() {
-				ReferenceService referenceService = callback.getContext().getReferenceService();
-				try {
-					T2Reference id = referenceService.register(value, 0, true,
-							callback.getContext());
-					Map<String, T2Reference> outputData = new HashMap<String, T2Reference>();
-					outputData.put("value", id);
-					callback.receiveResult(outputData, new int[0]);
-				} catch (ReferenceServiceException e) {
-					callback.fail(e.getMessage(), e);
-				}
-			}
-
-		});
-
-	}
-
-//	protected void addOutput(String portName, int portDepth, String type) {
-//		ActivityOutputPort port = edits.createActivityOutputPort(portName, portDepth, portDepth);
-//		MimeType mimeType = new MimeType();
-//		mimeType.setText(type);
-//		try {
-//			edits.getAddAnnotationChainEdit(port, mimeType).doEdit();
-//		} catch (EditException e) {
-//			logger.debug("Error adding MimeType annotation to port", e);
-//		}
-//		outputPorts.add(port);
-//	}
-
-	public String getExtraDescription() {
-		if (value.length() > 60) {
-			return value.substring(0, 60 - 3) + "...";
-		}
-		return value;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-stringconstant-activity/src/main/java/net/sf/taverna/t2/activities/stringconstant/StringConstantActivityFactory.java
----------------------------------------------------------------------
diff --git a/taverna-stringconstant-activity/src/main/java/net/sf/taverna/t2/activities/stringconstant/StringConstantActivityFactory.java b/taverna-stringconstant-activity/src/main/java/net/sf/taverna/t2/activities/stringconstant/StringConstantActivityFactory.java
deleted file mode 100644
index d11d15e..0000000
--- a/taverna-stringconstant-activity/src/main/java/net/sf/taverna/t2/activities/stringconstant/StringConstantActivityFactory.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.stringconstant;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.HashSet;
-import java.util.Set;
-
-import net.sf.taverna.t2.workflowmodel.Edits;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityFactory;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityInputPort;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityOutputPort;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * An {@link ActivityFactory} for creating <code>StringConstantActivity</code>.
- *
- * @author David Withers
- */
-public class StringConstantActivityFactory implements ActivityFactory {
-
-	private Edits edits;
-
-	@Override
-	public StringConstantActivity createActivity() {
-		return new StringConstantActivity();
-	}
-
-	@Override
-	public URI getActivityType() {
-		return URI.create(StringConstantActivity.URI);
-	}
-
-	@Override
-	public JsonNode getActivityConfigurationSchema() {
-		ObjectMapper objectMapper = new ObjectMapper();
-		try {
- 			return objectMapper.readTree(getClass().getResource("/schema.json"));
-		} catch (IOException e) {
-			return objectMapper.createObjectNode();
-		}
-	}
-
-	@Override
-	public Set<ActivityInputPort> getInputPorts(JsonNode configuration) {
-		return new HashSet<>();
-	}
-
-	@Override
-	public Set<ActivityOutputPort> getOutputPorts(JsonNode configuration) {
-		Set<ActivityOutputPort> outputPorts = new HashSet<>();
-		outputPorts.add(edits.createActivityOutputPort("value", 0, 0));
-		return outputPorts;
-	}
-
-	public void setEdits(Edits edits) {
-		this.edits = edits;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-stringconstant-activity/src/main/java/net/sf/taverna/t2/activities/stringconstant/StringConstantActivityHealthChecker.java
----------------------------------------------------------------------
diff --git a/taverna-stringconstant-activity/src/main/java/net/sf/taverna/t2/activities/stringconstant/StringConstantActivityHealthChecker.java b/taverna-stringconstant-activity/src/main/java/net/sf/taverna/t2/activities/stringconstant/StringConstantActivityHealthChecker.java
deleted file mode 100644
index 27cef3f..0000000
--- a/taverna-stringconstant-activity/src/main/java/net/sf/taverna/t2/activities/stringconstant/StringConstantActivityHealthChecker.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.stringconstant;
-
-import java.util.List;
-
-import net.sf.taverna.t2.workflowmodel.Processor;
-import net.sf.taverna.t2.workflowmodel.health.HealthCheck;
-import net.sf.taverna.t2.workflowmodel.health.HealthChecker;
-import net.sf.taverna.t2.visit.VisitReport;
-import net.sf.taverna.t2.visit.VisitReport.Status;
-
-public class StringConstantActivityHealthChecker implements HealthChecker<StringConstantActivity> {
-
-	public boolean canVisit(Object subject) {
-		return subject!=null && subject instanceof StringConstantActivity;
-	}
-
-	public VisitReport visit(StringConstantActivity activity, List<Object> ancestors) {
-		Processor p = (Processor) VisitReport.findAncestor(ancestors, Processor.class);
-		if (p == null) {
-			return null;
-		}
-		String value = activity.getConfiguration().get("string").asText();
-		if (value==null) {
-			return new VisitReport(HealthCheck.getInstance(), p,"No value", HealthCheck.NULL_VALUE, Status.SEVERE);
-		}
-		if ("Add your own value here".equals(value)) {
-			VisitReport vr = new VisitReport(HealthCheck.getInstance(), p, "Default value", HealthCheck.DEFAULT_VALUE, Status.WARNING);
-			vr.setProperty("value", value);
-			return vr;
-		}
-		return new VisitReport(HealthCheck.getInstance(), p, "StringConstant is OK", HealthCheck.NO_PROBLEM, Status.OK);
-	}
-
-	public boolean isTimeConsuming() {
-		return false;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-stringconstant-activity/src/main/java/net/sf/taverna/t2/activities/stringconstant/StringConstantConfigurationBean.java
----------------------------------------------------------------------
diff --git a/taverna-stringconstant-activity/src/main/java/net/sf/taverna/t2/activities/stringconstant/StringConstantConfigurationBean.java b/taverna-stringconstant-activity/src/main/java/net/sf/taverna/t2/activities/stringconstant/StringConstantConfigurationBean.java
deleted file mode 100644
index f4ae082..0000000
--- a/taverna-stringconstant-activity/src/main/java/net/sf/taverna/t2/activities/stringconstant/StringConstantConfigurationBean.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.stringconstant;
-
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationBean;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationProperty;
-
-/**
- * Configuration bean for setting up a StringConstantActivity.<br>
- * The only thing to be configured is the string value, since the ports are fixed.
- * 
- * @author Stuart Owen
- * @see StringConstantActivity
- */
-@ConfigurationBean(uri = StringConstantActivity.URI + "#Config")
-public class StringConstantConfigurationBean {
-	private String value;
-
-	public String getValue() {
-		return value;
-	}
-
-	@ConfigurationProperty(name = "string", label = "Constant String Value", description = "The value of the string constant")
-	public void setValue(String value) {
-		this.value = value;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-stringconstant-activity/src/main/java/net/sf/taverna/t2/activities/stringconstant/package.html
----------------------------------------------------------------------
diff --git a/taverna-stringconstant-activity/src/main/java/net/sf/taverna/t2/activities/stringconstant/package.html b/taverna-stringconstant-activity/src/main/java/net/sf/taverna/t2/activities/stringconstant/package.html
deleted file mode 100644
index 400b576..0000000
--- a/taverna-stringconstant-activity/src/main/java/net/sf/taverna/t2/activities/stringconstant/package.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<body>
-Contains the activity classes required in the execution of Beanshell scripts.
-</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-stringconstant-activity/src/main/java/org/apache/taverna/activities/stringconstant/StringConstantActivity.java
----------------------------------------------------------------------
diff --git a/taverna-stringconstant-activity/src/main/java/org/apache/taverna/activities/stringconstant/StringConstantActivity.java b/taverna-stringconstant-activity/src/main/java/org/apache/taverna/activities/stringconstant/StringConstantActivity.java
new file mode 100644
index 0000000..28d723d
--- /dev/null
+++ b/taverna-stringconstant-activity/src/main/java/org/apache/taverna/activities/stringconstant/StringConstantActivity.java
@@ -0,0 +1,118 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.activities.stringconstant;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.taverna.annotation.annotationbeans.MimeType;
+import org.apache.taverna.reference.ReferenceService;
+import org.apache.taverna.reference.ReferenceServiceException;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.workflowmodel.EditException;
+import org.apache.taverna.workflowmodel.processor.activity.AbstractAsynchronousActivity;
+import org.apache.taverna.workflowmodel.processor.activity.ActivityConfigurationException;
+import org.apache.taverna.workflowmodel.processor.activity.ActivityOutputPort;
+import org.apache.taverna.workflowmodel.processor.activity.AsynchronousActivityCallback;
+
+import org.apache.log4j.Logger;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * An Activity that holds a constant string value.
+ * <p>
+ * It is automatically configured to have no input ports and only one output port named
+ * <em>value</em>.
+ *
+ * @author Stuart Owen
+ * @author David Withers
+ */
+public class StringConstantActivity extends AbstractAsynchronousActivity<JsonNode> {
+
+	public static final String URI = "http://ns.taverna.org.uk/2010/activity/constant";
+
+	private static final Logger logger = Logger.getLogger(StringConstantActivity.class);
+
+	private String value;
+
+	private JsonNode json;
+
+	@Override
+	public void configure(JsonNode json) throws ActivityConfigurationException {
+		this.json = json;
+		this.value = json.get("string").asText();
+//		if (outputPorts.size() == 0) {
+//			addOutput("value", 0, "text/plain");
+//		}
+	}
+
+	public String getStringValue() {
+		return json.get("string").asText();
+	}
+
+	@Override
+	public JsonNode getConfiguration() {
+		return json;
+	}
+
+	@Override
+	public void executeAsynch(final Map<String, T2Reference> data,
+			final AsynchronousActivityCallback callback) {
+		callback.requestRun(new Runnable() {
+
+			@Override
+			public void run() {
+				ReferenceService referenceService = callback.getContext().getReferenceService();
+				try {
+					T2Reference id = referenceService.register(value, 0, true,
+							callback.getContext());
+					Map<String, T2Reference> outputData = new HashMap<String, T2Reference>();
+					outputData.put("value", id);
+					callback.receiveResult(outputData, new int[0]);
+				} catch (ReferenceServiceException e) {
+					callback.fail(e.getMessage(), e);
+				}
+			}
+
+		});
+
+	}
+
+//	protected void addOutput(String portName, int portDepth, String type) {
+//		ActivityOutputPort port = edits.createActivityOutputPort(portName, portDepth, portDepth);
+//		MimeType mimeType = new MimeType();
+//		mimeType.setText(type);
+//		try {
+//			edits.getAddAnnotationChainEdit(port, mimeType).doEdit();
+//		} catch (EditException e) {
+//			logger.debug("Error adding MimeType annotation to port", e);
+//		}
+//		outputPorts.add(port);
+//	}
+
+	public String getExtraDescription() {
+		if (value.length() > 60) {
+			return value.substring(0, 60 - 3) + "...";
+		}
+		return value;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-stringconstant-activity/src/main/java/org/apache/taverna/activities/stringconstant/StringConstantActivityFactory.java
----------------------------------------------------------------------
diff --git a/taverna-stringconstant-activity/src/main/java/org/apache/taverna/activities/stringconstant/StringConstantActivityFactory.java b/taverna-stringconstant-activity/src/main/java/org/apache/taverna/activities/stringconstant/StringConstantActivityFactory.java
new file mode 100644
index 0000000..ceab1b5
--- /dev/null
+++ b/taverna-stringconstant-activity/src/main/java/org/apache/taverna/activities/stringconstant/StringConstantActivityFactory.java
@@ -0,0 +1,80 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.activities.stringconstant;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.taverna.workflowmodel.Edits;
+import org.apache.taverna.workflowmodel.processor.activity.ActivityFactory;
+import org.apache.taverna.workflowmodel.processor.activity.ActivityInputPort;
+import org.apache.taverna.workflowmodel.processor.activity.ActivityOutputPort;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+/**
+ * An {@link ActivityFactory} for creating <code>StringConstantActivity</code>.
+ *
+ * @author David Withers
+ */
+public class StringConstantActivityFactory implements ActivityFactory {
+
+	private Edits edits;
+
+	@Override
+	public StringConstantActivity createActivity() {
+		return new StringConstantActivity();
+	}
+
+	@Override
+	public URI getActivityType() {
+		return URI.create(StringConstantActivity.URI);
+	}
+
+	@Override
+	public JsonNode getActivityConfigurationSchema() {
+		ObjectMapper objectMapper = new ObjectMapper();
+		try {
+ 			return objectMapper.readTree(getClass().getResource("/schema.json"));
+		} catch (IOException e) {
+			return objectMapper.createObjectNode();
+		}
+	}
+
+	@Override
+	public Set<ActivityInputPort> getInputPorts(JsonNode configuration) {
+		return new HashSet<>();
+	}
+
+	@Override
+	public Set<ActivityOutputPort> getOutputPorts(JsonNode configuration) {
+		Set<ActivityOutputPort> outputPorts = new HashSet<>();
+		outputPorts.add(edits.createActivityOutputPort("value", 0, 0));
+		return outputPorts;
+	}
+
+	public void setEdits(Edits edits) {
+		this.edits = edits;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-stringconstant-activity/src/main/java/org/apache/taverna/activities/stringconstant/StringConstantActivityHealthChecker.java
----------------------------------------------------------------------
diff --git a/taverna-stringconstant-activity/src/main/java/org/apache/taverna/activities/stringconstant/StringConstantActivityHealthChecker.java b/taverna-stringconstant-activity/src/main/java/org/apache/taverna/activities/stringconstant/StringConstantActivityHealthChecker.java
new file mode 100644
index 0000000..3557547
--- /dev/null
+++ b/taverna-stringconstant-activity/src/main/java/org/apache/taverna/activities/stringconstant/StringConstantActivityHealthChecker.java
@@ -0,0 +1,57 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.activities.stringconstant;
+
+import java.util.List;
+
+import org.apache.taverna.workflowmodel.Processor;
+import org.apache.taverna.workflowmodel.health.HealthCheck;
+import org.apache.taverna.workflowmodel.health.HealthChecker;
+import org.apache.taverna.visit.VisitReport;
+import org.apache.taverna.visit.VisitReport.Status;
+
+public class StringConstantActivityHealthChecker implements HealthChecker<StringConstantActivity> {
+
+	public boolean canVisit(Object subject) {
+		return subject!=null && subject instanceof StringConstantActivity;
+	}
+
+	public VisitReport visit(StringConstantActivity activity, List<Object> ancestors) {
+		Processor p = (Processor) VisitReport.findAncestor(ancestors, Processor.class);
+		if (p == null) {
+			return null;
+		}
+		String value = activity.getConfiguration().get("string").asText();
+		if (value==null) {
+			return new VisitReport(HealthCheck.getInstance(), p,"No value", HealthCheck.NULL_VALUE, Status.SEVERE);
+		}
+		if ("Add your own value here".equals(value)) {
+			VisitReport vr = new VisitReport(HealthCheck.getInstance(), p, "Default value", HealthCheck.DEFAULT_VALUE, Status.WARNING);
+			vr.setProperty("value", value);
+			return vr;
+		}
+		return new VisitReport(HealthCheck.getInstance(), p, "StringConstant is OK", HealthCheck.NO_PROBLEM, Status.OK);
+	}
+
+	public boolean isTimeConsuming() {
+		return false;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-stringconstant-activity/src/main/java/org/apache/taverna/activities/stringconstant/StringConstantConfigurationBean.java
----------------------------------------------------------------------
diff --git a/taverna-stringconstant-activity/src/main/java/org/apache/taverna/activities/stringconstant/StringConstantConfigurationBean.java b/taverna-stringconstant-activity/src/main/java/org/apache/taverna/activities/stringconstant/StringConstantConfigurationBean.java
new file mode 100644
index 0000000..c176aa4
--- /dev/null
+++ b/taverna-stringconstant-activity/src/main/java/org/apache/taverna/activities/stringconstant/StringConstantConfigurationBean.java
@@ -0,0 +1,44 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.activities.stringconstant;
+
+import org.apache.taverna.workflowmodel.processor.config.ConfigurationBean;
+import org.apache.taverna.workflowmodel.processor.config.ConfigurationProperty;
+
+/**
+ * Configuration bean for setting up a StringConstantActivity.<br>
+ * The only thing to be configured is the string value, since the ports are fixed.
+ * 
+ * @author Stuart Owen
+ * @see StringConstantActivity
+ */
+@ConfigurationBean(uri = StringConstantActivity.URI + "#Config")
+public class StringConstantConfigurationBean {
+	private String value;
+
+	public String getValue() {
+		return value;
+	}
+
+	@ConfigurationProperty(name = "string", label = "Constant String Value", description = "The value of the string constant")
+	public void setValue(String value) {
+		this.value = value;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-stringconstant-activity/src/main/java/org/apache/taverna/activities/stringconstant/package.html
----------------------------------------------------------------------
diff --git a/taverna-stringconstant-activity/src/main/java/org/apache/taverna/activities/stringconstant/package.html b/taverna-stringconstant-activity/src/main/java/org/apache/taverna/activities/stringconstant/package.html
new file mode 100644
index 0000000..400b576
--- /dev/null
+++ b/taverna-stringconstant-activity/src/main/java/org/apache/taverna/activities/stringconstant/package.html
@@ -0,0 +1,3 @@
+<body>
+Contains the activity classes required in the execution of Beanshell scripts.
+</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-stringconstant-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
----------------------------------------------------------------------
diff --git a/taverna-stringconstant-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker b/taverna-stringconstant-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
deleted file mode 100644
index ed959fb..0000000
--- a/taverna-stringconstant-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
+++ /dev/null
@@ -1 +0,0 @@
-net.sf.taverna.t2.activities.stringconstant.StringConstantActivityHealthChecker
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-stringconstant-activity/src/main/resources/META-INF/services/org.apache.taverna.workflowmodel.health.HealthChecker
----------------------------------------------------------------------
diff --git a/taverna-stringconstant-activity/src/main/resources/META-INF/services/org.apache.taverna.workflowmodel.health.HealthChecker b/taverna-stringconstant-activity/src/main/resources/META-INF/services/org.apache.taverna.workflowmodel.health.HealthChecker
new file mode 100644
index 0000000..11c7f33
--- /dev/null
+++ b/taverna-stringconstant-activity/src/main/resources/META-INF/services/org.apache.taverna.workflowmodel.health.HealthChecker
@@ -0,0 +1 @@
+org.apache.taverna.activities.stringconstant.StringConstantActivityHealthChecker
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-stringconstant-activity/src/main/resources/META-INF/spring/stringconstant-activity-context-osgi.xml
----------------------------------------------------------------------
diff --git a/taverna-stringconstant-activity/src/main/resources/META-INF/spring/stringconstant-activity-context-osgi.xml b/taverna-stringconstant-activity/src/main/resources/META-INF/spring/stringconstant-activity-context-osgi.xml
index d6750b1..098154d 100644
--- a/taverna-stringconstant-activity/src/main/resources/META-INF/spring/stringconstant-activity-context-osgi.xml
+++ b/taverna-stringconstant-activity/src/main/resources/META-INF/spring/stringconstant-activity-context-osgi.xml
@@ -6,10 +6,10 @@
                                  http://www.springframework.org/schema/osgi
                                  http://www.springframework.org/schema/osgi/spring-osgi.xsd">
 
-	<service ref="stringconstantActivityHealthChecker" interface="net.sf.taverna.t2.workflowmodel.health.HealthChecker" />
+	<service ref="stringconstantActivityHealthChecker" interface="org.apache.taverna.workflowmodel.health.HealthChecker" />
 
-	<service ref="stringconstantActivityFactory" interface="net.sf.taverna.t2.workflowmodel.processor.activity.ActivityFactory" />
+	<service ref="stringconstantActivityFactory" interface="org.apache.taverna.workflowmodel.processor.activity.ActivityFactory" />
 
-	<reference id="edits" interface="net.sf.taverna.t2.workflowmodel.Edits" />
+	<reference id="edits" interface="org.apache.taverna.workflowmodel.Edits" />
 
 </beans:beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-stringconstant-activity/src/main/resources/META-INF/spring/stringconstant-activity-context.xml
----------------------------------------------------------------------
diff --git a/taverna-stringconstant-activity/src/main/resources/META-INF/spring/stringconstant-activity-context.xml b/taverna-stringconstant-activity/src/main/resources/META-INF/spring/stringconstant-activity-context.xml
index 4df863a..806bb1f 100644
--- a/taverna-stringconstant-activity/src/main/resources/META-INF/spring/stringconstant-activity-context.xml
+++ b/taverna-stringconstant-activity/src/main/resources/META-INF/spring/stringconstant-activity-context.xml
@@ -3,9 +3,9 @@
 	xsi:schemaLocation="http://www.springframework.org/schema/beans
                            http://www.springframework.org/schema/beans/spring-beans.xsd">
 
-	<bean id="stringconstantActivityHealthChecker" class="net.sf.taverna.t2.activities.stringconstant.StringConstantActivityHealthChecker" />
+	<bean id="stringconstantActivityHealthChecker" class="org.apache.taverna.activities.stringconstant.StringConstantActivityHealthChecker" />
 
-	<bean id="stringconstantActivityFactory" class="net.sf.taverna.t2.activities.stringconstant.StringConstantActivityFactory">
+	<bean id="stringconstantActivityFactory" class="org.apache.taverna.activities.stringconstant.StringConstantActivityFactory">
 		<property name="edits" ref="edits" />
 	</bean>
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-stringconstant-activity/src/test/java/net/sf/taverna/t2/activities/stringconstant/StringConstantActivityFactoryTest.java
----------------------------------------------------------------------
diff --git a/taverna-stringconstant-activity/src/test/java/net/sf/taverna/t2/activities/stringconstant/StringConstantActivityFactoryTest.java b/taverna-stringconstant-activity/src/test/java/net/sf/taverna/t2/activities/stringconstant/StringConstantActivityFactoryTest.java
deleted file mode 100644
index 61560f2..0000000
--- a/taverna-stringconstant-activity/src/test/java/net/sf/taverna/t2/activities/stringconstant/StringConstantActivityFactoryTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.stringconstant;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.net.URI;
-
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * 
- * @author David Withers
- */
-public class StringConstantActivityFactoryTest {
-
-	private StringConstantActivityFactory factory;
-	
-	/**
-	 * @throws java.lang.Exception
-	 */
-	@Before
-	public void setUp() throws Exception {
-		factory = new StringConstantActivityFactory();
-	}
-
-	/**
-	 * Test method for {@link net.sf.taverna.t2.activities.beanshell.BeanshellActivityFactory#createActivity()}.
-	 */
-	@Test
-	public void testCreateActivity() {
-		StringConstantActivity createActivity = factory.createActivity();
-		assertNotNull(createActivity);
-	}
-
-	/**
-	 * Test method for {@link net.sf.taverna.t2.activities.beanshell.BeanshellActivityFactory#getActivityType()}.
-	 */
-	@Test
-	public void testGetActivityURI() {
-		assertEquals(URI.create(StringConstantActivity.URI), factory.getActivityType());
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-stringconstant-activity/src/test/java/net/sf/taverna/t2/activities/stringconstant/StringConstantActivityTest.java
----------------------------------------------------------------------
diff --git a/taverna-stringconstant-activity/src/test/java/net/sf/taverna/t2/activities/stringconstant/StringConstantActivityTest.java b/taverna-stringconstant-activity/src/test/java/net/sf/taverna/t2/activities/stringconstant/StringConstantActivityTest.java
deleted file mode 100644
index a191e8e..0000000
--- a/taverna-stringconstant-activity/src/test/java/net/sf/taverna/t2/activities/stringconstant/StringConstantActivityTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.stringconstant;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import net.sf.taverna.t2.activities.testutils.ActivityInvoker;
-import net.sf.taverna.t2.workflowmodel.AbstractPort;
-
-import org.junit.Test;
-
-/**
- * Tests the StringConstantActivity
- * @author Stuart Owen
- *
- */
-public class StringConstantActivityTest {
-
-	/**
-	 * Simple invocation test. Also tests Activity.configure sets up the correct output port.
-	 * @throws Exception
-	 */
-	@Test
-	public void testInvoke() throws Exception {
-		return;
-//		StringConstantConfigurationBean bean = new StringConstantConfigurationBean();
-//		bean.setValue("this_is_a_string");
-//		StringConstantActivity activity = new StringConstantActivity();
-//		activity.configure(bean);
-//		
-//		assertEquals("there should be no inputs",0,activity.getInputPorts().size());
-//		assertEquals("there should be 1 output",1,activity.getOutputPorts().size());
-//		assertEquals("the output port name should be value","value",((AbstractPort)activity.getOutputPorts().toArray()[0]).getName());
-//		
-//		Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>();
-//		expectedOutputs.put("value", String.class);
-//
-//		Map<String,Object> outputs = ActivityInvoker.invokeAsyncActivity(activity, new HashMap<String, Object>(), expectedOutputs);
-//		
-//		assertEquals("there should be 1 output",1,outputs.size());
-//		assertTrue("there should be an output named value",outputs.containsKey("value"));
-//		assertEquals("The value of the output should be 'this_is_a_string'","this_is_a_string",outputs.get("value"));
-//		assertTrue("The output type should be String",outputs.get("value") instanceof String);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-stringconstant-activity/src/test/java/org/apache/taverna/activities/stringconstant/StringConstantActivityFactoryTest.java
----------------------------------------------------------------------
diff --git a/taverna-stringconstant-activity/src/test/java/org/apache/taverna/activities/stringconstant/StringConstantActivityFactoryTest.java b/taverna-stringconstant-activity/src/test/java/org/apache/taverna/activities/stringconstant/StringConstantActivityFactoryTest.java
new file mode 100644
index 0000000..f3d6a2c
--- /dev/null
+++ b/taverna-stringconstant-activity/src/test/java/org/apache/taverna/activities/stringconstant/StringConstantActivityFactoryTest.java
@@ -0,0 +1,63 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.activities.stringconstant;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.net.URI;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * 
+ * @author David Withers
+ */
+public class StringConstantActivityFactoryTest {
+
+	private StringConstantActivityFactory factory;
+	
+	/**
+	 * @throws java.lang.Exception
+	 */
+	@Before
+	public void setUp() throws Exception {
+		factory = new StringConstantActivityFactory();
+	}
+
+	/**
+	 * Test method for {@link org.apache.taverna.activities.beanshell.BeanshellActivityFactory#createActivity()}.
+	 */
+	@Test
+	public void testCreateActivity() {
+		StringConstantActivity createActivity = factory.createActivity();
+		assertNotNull(createActivity);
+	}
+
+	/**
+	 * Test method for {@link org.apache.taverna.activities.beanshell.BeanshellActivityFactory#getActivityType()}.
+	 */
+	@Test
+	public void testGetActivityURI() {
+		assertEquals(URI.create(StringConstantActivity.URI), factory.getActivityType());
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-stringconstant-activity/src/test/java/org/apache/taverna/activities/stringconstant/StringConstantActivityTest.java
----------------------------------------------------------------------
diff --git a/taverna-stringconstant-activity/src/test/java/org/apache/taverna/activities/stringconstant/StringConstantActivityTest.java b/taverna-stringconstant-activity/src/test/java/org/apache/taverna/activities/stringconstant/StringConstantActivityTest.java
new file mode 100644
index 0000000..d42058a
--- /dev/null
+++ b/taverna-stringconstant-activity/src/test/java/org/apache/taverna/activities/stringconstant/StringConstantActivityTest.java
@@ -0,0 +1,58 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.activities.stringconstant;
+
+
+import org.junit.Test;
+
+/**
+ * Tests the StringConstantActivity
+ * @author Stuart Owen
+ *
+ */
+public class StringConstantActivityTest {
+
+	/**
+	 * Simple invocation test. Also tests Activity.configure sets up the correct output port.
+	 * @throws Exception
+	 */
+	@Test
+	public void testInvoke() throws Exception {
+		return;
+//		StringConstantConfigurationBean bean = new StringConstantConfigurationBean();
+//		bean.setValue("this_is_a_string");
+//		StringConstantActivity activity = new StringConstantActivity();
+//		activity.configure(bean);
+//		
+//		assertEquals("there should be no inputs",0,activity.getInputPorts().size());
+//		assertEquals("there should be 1 output",1,activity.getOutputPorts().size());
+//		assertEquals("the output port name should be value","value",((AbstractPort)activity.getOutputPorts().toArray()[0]).getName());
+//		
+//		Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>();
+//		expectedOutputs.put("value", String.class);
+//
+//		Map<String,Object> outputs = ActivityInvoker.invokeAsyncActivity(activity, new HashMap<String, Object>(), expectedOutputs);
+//		
+//		assertEquals("there should be 1 output",1,outputs.size());
+//		assertTrue("there should be an output named value",outputs.containsKey("value"));
+//		assertEquals("The value of the output should be 'this_is_a_string'","this_is_a_string",outputs.get("value"));
+//		assertTrue("The output type should be String",outputs.get("value") instanceof String);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AbstractAnnotatedThing.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AbstractAnnotatedThing.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AbstractAnnotatedThing.java
deleted file mode 100644
index e9dda93..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AbstractAnnotatedThing.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation;
-
-import static java.util.Collections.unmodifiableSet;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import net.sf.taverna.t2.workflowmodel.Edit;
-import net.sf.taverna.t2.workflowmodel.EditException;
-
-/**
- * Convenient abstract superclass for annotated things, manages edits.
- * Subclasses of this must implement the Annotated interface with their own
- * interface type as the parameter, so for example Processor subclasses would
- * implement Annotated&lt;Processor&gt;
- * 
- * @author Tom Oinn
- * @author Alan R Williams
- */
-public abstract class AbstractAnnotatedThing<T> implements Annotated<T> {
-	private Set<AnnotationChain> annotations = new HashSet<>();
-
-	/**
-	 * Return the set of annotations bound to this annotated object, the set
-	 * returned is an unmodifiable copy of the internal annotation set, if you
-	 * need to modify the annotations you should use the get methods for Edit
-	 * objects to do so.
-	 * 
-	 * @see net.sf.taverna.t2.annotation.Annotated#getAnnotations()
-	 */
-	@Override
-	public final Set<AnnotationChain> getAnnotations() {
-		return unmodifiableSet(annotations);
-	}
-
-	/**
-	 * Set the annotation chains associated with this annotated object. This is
-	 * only needed for deserialization and could almost certainly be done in a
-	 * better way.
-	 * 
-	 * @param annotations
-	 */
-	@Override
-	public final void setAnnotations(Set<AnnotationChain> annotations) {
-		this.annotations = annotations;
-	}
-
-	/**
-	 * Superclass of edits to remove, add and replace annotations on instances
-	 * of the enclosing AbstractAnnotatedThing class
-	 * 
-	 * @author Tom
-	 * @param <TargetType>
-	 */
-	private static abstract class AbstractAnnotationEdit<TargetType> implements
-			Edit<TargetType> {
-		private AbstractAnnotatedThing<TargetType> subject;
-		private boolean applied = false;
-
-		protected AbstractAnnotationEdit(
-				AbstractAnnotatedThing<TargetType> subject) {
-			this.subject = subject;
-		}
-
-		@Override
-		@SuppressWarnings("unchecked")
-		public final TargetType doEdit() throws EditException {
-			synchronized (subject) {
-				if (applied)
-					throw new EditException("Edit already applied!");
-				doEditAction(subject);
-				this.applied = true;
-				return (TargetType) subject;
-			}
-		}
-
-		protected abstract void doEditAction(AbstractAnnotatedThing<?> subject)
-				throws EditException;
-
-		protected abstract void undoEditAction(AbstractAnnotatedThing<?> subject);
-
-		@Override
-		@SuppressWarnings("unchecked")
-		public final TargetType getSubject() {
-			return (TargetType) subject;
-		}
-
-		@Override
-		public final boolean isApplied() {
-			return this.applied;
-		}
-
-		@Override
-		public final void undo() {
-			synchronized (subject) {
-				if (!applied)
-					throw new RuntimeException(
-							"Attempt to undo edit that was never applied");
-				undoEditAction(subject);
-				applied = false;
-			}
-		}
-	}
-
-	/**
-	 * @see net.sf.taverna.t2.annotation.Annotated#getAddAnnotationEdit(net.sf.taverna.t2.annotation.WorkflowAnnotation)
-	 */
-	@Override
-	public final Edit<T> getAddAnnotationEdit(
-			final AnnotationChain newAnnotation) {
-		return new AbstractAnnotationEdit<T>(this) {
-			@Override
-			protected void doEditAction(AbstractAnnotatedThing<?> subject)
-					throws EditException {
-				annotations.add(newAnnotation);
-			}
-
-			@Override
-			protected void undoEditAction(AbstractAnnotatedThing<?> subject) {
-				annotations.remove(newAnnotation);
-			}
-		};
-	}
-
-	/**
-	 * @see net.sf.taverna.t2.annotation.Annotated#getRemoveAnnotationEdit(net.sf.taverna.t2.annotation.WorkflowAnnotation)
-	 */
-	@Override
-	public final Edit<T> getRemoveAnnotationEdit(
-			final AnnotationChain annotationToRemove) {
-		return new AbstractAnnotationEdit<T>(this) {
-			@Override
-			protected void doEditAction(AbstractAnnotatedThing<?> subject)
-					throws EditException {
-				annotations.remove(annotationToRemove);
-			}
-
-			@Override
-			protected void undoEditAction(AbstractAnnotatedThing<?> subject) {
-				annotations.add(annotationToRemove);
-			}
-		};
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/Annotated.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/Annotated.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/Annotated.java
deleted file mode 100644
index ab7ed2c..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/Annotated.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation;
-
-import java.util.Set;
-
-import net.sf.taverna.t2.workflowmodel.Edit;
-
-/**
- * Denotes that the object carries workflow object level annotation. Rather than
- * defining specific annotation types for each workflow entity we work on the
- * basis that multiple annotations of different types may apply, so free text
- * description is one example, semantic annotation of the internal function of a
- * processor might be another.
- * <p>
- * Where annotations are conceptually editable such as free text descriptions
- * the editing framework should internally remove the original annotation and
- * add the replacement rather than modifying the previous annotation in place.
- * 
- * @author Tom Oinn
- * 
- */
-public interface Annotated<TargetType> {
-
-	/**
-	 * Each annotated object contains a bag of metadata object instances
-	 * 
-	 * @return set of metadata objects that apply to the annotated object
-	 */
-	Set<? extends AnnotationChain> getAnnotations();
-	
-	void setAnnotations(Set<AnnotationChain> annotations);
-
-	/**
-	 * Add new workflow object metadata to this annotated entity
-	 * 
-	 * @param <TargetType>
-	 *            the type of the object being annotated
-	 * @param newAnnotation
-	 *            metadata object to add to the annotated object
-	 * @return edit object to perform and undo the metadata assignment
-	 */
-	public Edit<? extends TargetType> getAddAnnotationEdit(
-			AnnotationChain newAnnotation);
-
-	/**
-	 * Remove an annotation object from the this annotated entity
-	 * 
-	 * @param <TargetType>
-	 *            type of the workflow object from which the annotation is
-	 *            removed
-	 * @param annotationToRemove
-	 *            metadata object to remove
-	 * @param objectToAnnotate
-	 *            object from which the metadata is removed
-	 * @return edit object to perform and undo the metadata removal
-	 */
-	public Edit<? extends TargetType> getRemoveAnnotationEdit(
-			AnnotationChain annotationToRemove);
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationAssertion.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationAssertion.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationAssertion.java
deleted file mode 100644
index 6f68c35..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationAssertion.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation;
-
-/**
- * Represents a single assertion of information, providing access to a bean
- * containing the information in the assertion and one specifying the source of
- * the information contained.
- * 
- * @author Tom Oinn
- * 
- */
-public interface AnnotationAssertion<AnnotationBeanType extends AnnotationBeanSPI>
-		extends Curateable {
-
-	/**
-	 * Each annotation assertion contains a bean specifying the actual
-	 * annotation, varying from a simple string for a free text description to
-	 * more sophisticated semantic annotations or controlled vocabularies.
-	 * 
-	 * @return the annotation bean specifying this annotation assertion
-	 */
-	public AnnotationBeanType getDetail();
-
-	/**
-	 * The annotation assertion plays one of several roles within the annotation
-	 * chain, either an initial assertion, a refinement of a previous assertion
-	 * or a replacement of a previous assertion.
-	 * 
-	 * @return the annotation role of this annotation
-	 */
-	public AnnotationRole getRole();
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationBeanSPI.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationBeanSPI.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationBeanSPI.java
deleted file mode 100644
index a754148..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationBeanSPI.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation;
-
-/**
- * Marker interface to denote that a bean class is a container for the
- * information encapsulated by an InformationAssertion object
- * 
- * @author Tom Oinn
- * 
- */
-public interface AnnotationBeanSPI {
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationChain.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationChain.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationChain.java
deleted file mode 100644
index 6f70faa..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationChain.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation;
-
-import java.util.List;
-
-/**
- * A fact about an annotated entity is expressed in terms of an annotation
- * chain. The annotation chain contains one or more information assertions in a
- * list ordered by the creation date of each assertion. Annotation chains are
- * then interpreted by an AnnotationPerspective which is responsible for
- * reasoning over the information in the chain and extracting the set of
- * information assertions that are valid according to the rules in the
- * particular AnnotationPerspective.
- * 
- * @author Tom Oinn
- * 
- */
-public interface AnnotationChain {
-
-	/**
-	 * Returns the ordered list of AnnotationAssertions. This is the 'raw' set
-	 * of annotations in creation order - this order is not necessarily the
-	 * order they were curated, and may include refuted or otherwise wrong
-	 * annotations. Consumers of this API are recommended to use an
-	 * AnnotationPerspective to resolve any such conflicts appropriately.
-	 * 
-	 * @return read only copy of the ordered list of AnnotationAssertion
-	 *         instances
-	 */
-	List<AnnotationAssertion<?>> getAssertions();
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationPerspective.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationPerspective.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationPerspective.java
deleted file mode 100644
index 656b026..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationPerspective.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation;
-
-import java.util.List;
-
-/**
- * Responsible for the interpretation of an AnnotationChain (which may contain
- * conflicting or disputed information) into a set of AnnotationAssertion
- * instances from that chain which are valid given the chain and some
- * interpretation rule.
- * 
- * @author Tom Oinn
- * 
- */
-public interface AnnotationPerspective {
-
-	/**
-	 * Evaluate the annotations and their curation events in the specified
-	 * chain, resolve conflicts if possible and return the resultant set of
-	 * annotations
-	 * 
-	 * @param chain
-	 *            the annotation chain to evaluate
-	 * @return the set of annotations which are valid within this chain
-	 */
-	public List<? extends AnnotationAssertion<?>> getAnnotations(
-			AnnotationChain chain);
-
-	/**
-	 * Annotation chains may be in a disputed state if there are conflicting
-	 * mutually exclusive events within them under the interpretation imposed by
-	 * the annotation perspective and the perspective is unable to sensibly
-	 * reconcile them. For example, if the perspective is configured to trust
-	 * two parties equally and they disagree.
-	 * 
-	 * @param chain
-	 *            the annotation chain to check for conflict
-	 * @return true if there are conflicts under the interpretation of this
-	 *         annotation perspective
-	 */
-	public boolean isDisputed(AnnotationChain chain);
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationRole.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationRole.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationRole.java
deleted file mode 100644
index 06b37b1..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationRole.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation;
-
-/**
- * Specifies the role of an AnnotationAssertion within an AnnotationChain
- * 
- * @author Tom Oinn
- */
-public enum AnnotationRole {
-
-	/**
-	 * The information assertion is the first in the chain (if this is applied
-	 * to an annotation that isn't the earliest in its chain it should be
-	 * treated as a validation failure)
-	 */
-	INITIAL_ASSERTION,
-
-	/**
-	 * The information assertion was added to the chain to refine the existing
-	 * annotation assertion or assertions, such as cases where a generic
-	 * description exists which can be specialized in a particular instance but
-	 * where the original more generic form is still correct
-	 */
-	REFINEMENT,
-
-	/**
-	 * The information assertion was added to the chain in order to override an
-	 * earlier information assertion which was regarded as incorrect.
-	 */
-	REPLACEMENT;
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationSourceSPI.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationSourceSPI.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationSourceSPI.java
deleted file mode 100644
index 1f7a74d..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AnnotationSourceSPI.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation;
-
-/**
- * A marker interface that specified that the implementation is a bean
- * containing information about a source of annotations. These might be
- * publications, web URIs, a free text container, a person (etc). We should be
- * able to use existing schemes for identification of sources, publications etc
- * here.
- * 
- * @author Tom Oinn
- * 
- */
-public interface AnnotationSourceSPI {
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AppliesTo.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AppliesTo.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AppliesTo.java
deleted file mode 100644
index 561b48d..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/AppliesTo.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation;
-
-import java.lang.annotation.*;
-
-/**
- * Annotation to be used on metadata objects to denote which workflow objects
- * they apply to
- * 
- * @author Tom Oinn
- * 
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-@Documented
-public @interface AppliesTo {
-
-	/**
-	 * The class of the metadata object allowed by this annotation
-	 */
-	Class<?>[] targetObjectType();
-
-	/**
-	 * Can you have more than one of these metadata objects in the resolved set?
-	 */
-	boolean many() default true;
-	
-   /**
-     * Should the annotation be pruned, i.e. only most recent kept, when saving?
-     */
-    boolean pruned() default true;
-
-
-}


[37/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ReferenceSetServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ReferenceSetServiceImpl.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ReferenceSetServiceImpl.java
deleted file mode 100644
index 7f04709..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ReferenceSetServiceImpl.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import static net.sf.taverna.t2.reference.impl.T2ReferenceImpl.getAsImpl;
-
-import java.net.URI;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.WeakHashMap;
-
-import net.sf.taverna.t2.reference.DaoException;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferenceServiceException;
-import net.sf.taverna.t2.reference.ReferenceSet;
-import net.sf.taverna.t2.reference.ReferenceSetAugmentationException;
-import net.sf.taverna.t2.reference.ReferenceSetService;
-import net.sf.taverna.t2.reference.ReferenceSetServiceException;
-import net.sf.taverna.t2.reference.T2Reference;
-
-/**
- * Implementation of ReferenceSetService, inject with an appropriate
- * ReferenceSetDao to enable. Implements translation functionality as long as an
- * appropriate ReferenceSetAugmentor implementation is injected.
- * 
- * @author Tom Oinn
- */
-public class ReferenceSetServiceImpl extends AbstractReferenceSetServiceImpl
-		implements ReferenceSetService {
-	@Override
-	public ReferenceSet getReferenceSet(T2Reference id)
-			throws ReferenceSetServiceException {
-		checkDao();
-		try {
-			return referenceSetDao.get(id);
-		} catch (DaoException de) {
-			throw new ReferenceSetServiceException(de);
-		}
-	}
-
-	private Map<URI,Object> locks = new WeakHashMap<>();
-
-	private Object getLock(T2Reference id) {
-		URI uri = id.toUri();
-		synchronized (locks) {
-			Object lock = locks.get(uri);
-			if (lock == null) {
-				lock = new Object();
-				locks.put(uri, lock);
-			}
-			return lock;
-		}
-	}
-
-	@Override
-	public ReferenceSet getReferenceSetWithAugmentation(T2Reference id,
-			Set<Class<ExternalReferenceSPI>> ensureTypes,
-			ReferenceContext context) throws ReferenceSetServiceException {
-		checkDao();
-		checkAugmentor();
-		if (context == null)
-			context = new EmptyReferenceContext();
-		// Obtain the reference set
-
-		try {
-			/*
-			 * Synchronize on the reference set, should ensure that we don't
-			 * have multiple concurrent translations assuming that Hibernate
-			 * retrieves the same entity each time. Except we have to
-			 * synchronize on the reference, and in fact we have to synchronize
-			 * on the URI form.
-			 */
-			synchronized (getLock(id)) {
-				ReferenceSet rs = getReferenceSet(id);
-				Set<ExternalReferenceSPI> newReferences = referenceSetAugmentor
-						.augmentReferenceSet(rs, ensureTypes, context);
-				if (!newReferences.isEmpty()) {
-					/*
-					 * Write back changes to the store if we got here, this can
-					 * potentially throw an unsupported operation exception in
-					 * which case we have to fail the augmentation.
-					 */
-					try {
-						rs.getExternalReferences().addAll(newReferences);
-					} catch (RuntimeException re) {
-						throw new ReferenceSetAugmentationException(
-								"Can't add new references back into existing reference set instance");
-					}
-					referenceSetDao.update(rs);
-				}
-				return rs;
-			}
-		} catch (ReferenceSetAugmentationException rsae) {
-			throw new ReferenceSetServiceException(rsae);
-		}
-	}
-
-	@Override
-	public ReferenceSet registerReferenceSet(
-			Set<ExternalReferenceSPI> references, ReferenceContext context)
-			throws ReferenceSetServiceException {
-		checkDao();
-		checkGenerator();
-		
-		ReferenceSetImpl rsi = new ReferenceSetImpl(new HashSet<>(references),
-				getAsImpl(t2ReferenceGenerator
-						.nextReferenceSetReference(context)));
-
-		try {
-			referenceSetDao.store(rsi);
-			return rsi;
-		} catch (DaoException de) {
-			throw new ReferenceSetServiceException(de);
-		}
-	}
-
-	@Override
-	public boolean delete(T2Reference reference)
-			throws ReferenceServiceException {
-		checkDao();
-		ReferenceSet set = referenceSetDao.get(reference);
-		if (set == null)
-			return false;
-		return referenceSetDao.delete(set);
-	}
-
-	@Override
-	public void deleteReferenceSetsForWorkflowRun(String workflowRunId)
-			throws ReferenceServiceException {
-		checkDao();
-		referenceSetDao.deleteReferenceSetsForWFRun(workflowRunId);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/SimpleCacheProviderImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/SimpleCacheProviderImpl.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/SimpleCacheProviderImpl.java
deleted file mode 100644
index ccbf67b..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/SimpleCacheProviderImpl.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import net.sf.taverna.t2.reference.Identified;
-import net.sf.taverna.t2.reference.ReferenceServiceCacheProvider;
-import net.sf.taverna.t2.reference.T2Reference;
-
-import org.apache.log4j.Logger;
-
-/**
- * Completely naive cache provider that just stores everything in a map. This
- * <em>will</em> run out of memory as it makes no attempt to evict old items,
- * it's really just here as a test!
- * 
- * @author Tom Oinn
- */
-public class SimpleCacheProviderImpl implements ReferenceServiceCacheProvider {
-	private final Logger log = Logger.getLogger(SimpleCacheProviderImpl.class);
-	private Map<T2Reference, Identified> cache = new HashMap<>();
-
-	@Override
-	public Identified get(T2Reference id) {
-		if (log.isDebugEnabled())
-			log.debug("Get " + id.toString() + " (" + cache.containsKey(id)
-					+ ")");
-		return cache.get(id);
-	}
-
-	@Override
-	public void put(Identified i) {
-		if (log.isDebugEnabled())
-			log.debug("Put " + i.getId().toString());
-		cache.put(i.getId(), i);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/SimpleT2ReferenceGenerator.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/SimpleT2ReferenceGenerator.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/SimpleT2ReferenceGenerator.java
deleted file mode 100644
index 897fc96..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/SimpleT2ReferenceGenerator.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import net.sf.taverna.t2.reference.T2ReferenceGenerator;
-
-/**
- * Simple implementation of T2ReferenceGenerator intended to be injected into
- * the service layers for integration testing. Exposes a namespace property
- * which can be configured through spring and allocates local parts based on an
- * integer counter - this is only guaranteed to be unique within a single
- * instance of this object so isn't suitable for real production use. For proper
- * usage use an implementation tied to the backing store you're putting t2
- * reference objects into.
- * 
- * @author Tom Oinn
- */
-public class SimpleT2ReferenceGenerator extends AbstractT2ReferenceGenerator implements T2ReferenceGenerator {
-	private String namespace = "testNS";
-	private String localPrefix = "test";
-	private int counter = 0;
-
-	/**
-	 * Set the namespace for identifiers generated by this class as a string
-	 * 
-	 * @param newNamespace
-	 *            the namespace to use
-	 */
-	public void setNamespace(String newNamespace) {
-		this.namespace = newNamespace;
-	}
-
-	/**
-	 * Get the namespace for identifiers generated by this class
-	 */
-	@Override
-	public String getNamespace() {
-		return namespace;
-	}
-
-	@Override
-	protected synchronized String getNextLocalPart() {
-		return localPrefix + (counter++);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/StackTraceElementBeanImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/StackTraceElementBeanImpl.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/StackTraceElementBeanImpl.java
deleted file mode 100644
index 6943127..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/StackTraceElementBeanImpl.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import net.sf.taverna.t2.reference.StackTraceElementBean;
-import net.sf.taverna.t2.reference.h3.HibernateComponentClass;
-
-/**
- * Simple bean implementation of StackTraceElement for Hibernate
- * 
- * @author Tom Oinn
- */
-public class StackTraceElementBeanImpl implements StackTraceElementBean,
-		HibernateComponentClass {
-	private String className;
-	private String fileName;
-	private String methodName;
-	private int lineNumber;
-
-	public StackTraceElementBeanImpl() {
-		//
-	}
-
-	@Override
-	public String getClassName() {
-		return this.className;
-	}
-
-	public void setClassName(String className) {
-		this.className = className;
-	}
-
-	@Override
-	public String getFileName() {
-		return this.fileName;
-	}
-
-	public void setFileName(String fileName) {
-		this.fileName = fileName;
-	}
-
-	@Override
-	public int getLineNumber() {
-		return lineNumber;
-	}
-
-	public void setLineNumber(int lineNumber) {
-		this.lineNumber = lineNumber;
-	}
-
-	@Override
-	public String getMethodName() {
-		return this.methodName;
-	}
-
-	public void setMethodName(String methodName) {
-		this.methodName = methodName;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/T2ReferenceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/T2ReferenceImpl.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/T2ReferenceImpl.java
deleted file mode 100644
index f5f00d3..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/T2ReferenceImpl.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import static net.sf.taverna.t2.reference.T2ReferenceType.ErrorDocument;
-
-import java.io.Serializable;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.UUID;
-
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.T2ReferenceType;
-import net.sf.taverna.t2.reference.h3.HibernateComponentClass;
-
-import org.apache.log4j.Logger;
-
-/**
- * An implementation of T2Reference specific to the ReferenceSetImpl. This is
- * needed because ReferenceSetImpl uses a component based primary key driven
- * from the namespace and local parts of T2Reference. This in turn means we can
- * query hibernate directly with a T2Reference instance in the data access
- * object. Because this is only used as a component (i.e. a value type) we don't
- * need to define a hibernate mapping file for it.
- * 
- * @author Tom Oinn
- * @author David Withers
- */
-public class T2ReferenceImpl implements T2Reference, Serializable, HibernateComponentClass {
-	private static Logger logger = Logger.getLogger(T2ReferenceImpl.class);
-
-	private static final long serialVersionUID = 8363330461158750319L;
-	private String localPart;
-	private String namespacePart;
-	private long localMostSigBits, localLeastSigBits;
-	private boolean containsErrors = false;
-	private T2ReferenceType referenceType = T2ReferenceType.ReferenceSet;
-	private int depth = 0;
-	private transient URI cachedURI;
-
-	public T2ReferenceImpl() {
-		// Default constructor for Hibernate et al
-	}
-
-	/**
-	 * Construct a deep copy of the given T2Reference
-	 * 
-	 * @param source
-	 *            T2Reference to copy
-	 */
-	private T2ReferenceImpl(T2Reference source) {
-		super();
-		setNamespacePart(source.getNamespacePart());
-		setLocalPart(source.getLocalPart());
-		setContainsErrors(source.containsErrors());
-		setReferenceType(source.getReferenceType());
-		setDepth(source.getDepth());
-	}
-
-	public static T2ReferenceImpl getAsImpl(T2Reference source) {
-		if (source instanceof T2ReferenceImpl)
-			return (T2ReferenceImpl) source;
-		return new T2ReferenceImpl(source);
-	}
-
-	/**
-	 * Return whether the identified entity either is or contains errors
-	 */
-	@Override
-	public boolean containsErrors() {
-		return this.containsErrors;
-	}
-
-	/**
-	 * Property accessor for Hibernate, complies with java bean spec
-	 */
-	public boolean getContainsErrors() {
-		return this.containsErrors;
-	}
-
-	/**
-	 * Get the depth of the entity referred to by this reference
-	 */
-	@Override
-	public int getDepth() {
-		return this.depth;
-	}
-
-	/**
-	 * Get the local part of the URI for this reference
-	 */
-	@Override
-	public String getLocalPart() {
-		if (localPart == null) {
-			UUID localPartUUID = new UUID(localMostSigBits, localLeastSigBits);
-			return localPartUUID.toString();
-		}
-		return localPart;
-	}
-
-	/**
-	 * Get the namespace part of the URI for this reference
-	 */
-	@Override
-	public String getNamespacePart() {
-		return namespacePart;
-	}
-
-	/**
-	 * Get the type of the entity to which this reference refers
-	 */
-	@Override
-	public T2ReferenceType getReferenceType() {
-		return referenceType;
-	}
-
-	/**
-	 * This method is only ever called from within Hibernate when
-	 * re-constructing the identifier component to set the namespace part of the
-	 * identifier.
-	 */
-	public synchronized void setNamespacePart(String namespacePart) {
-		this.namespacePart = namespacePart;
-	}
-
-	/**
-	 * This method is only ever called from within Hibernate when
-	 * re-constructing the identifier component to set the local part of the
-	 * identifier.
-	 */
-	public synchronized void setLocalPart(String localPart) {
-		try {
-			UUID namespacePartUUID = UUID.fromString(localPart);
-			localMostSigBits = namespacePartUUID.getMostSignificantBits();
-			localLeastSigBits = namespacePartUUID.getLeastSignificantBits();
-			this.localPart = null;
-		} catch (IllegalArgumentException e) {
-			this.localPart = localPart;
-		}
-	}
-
-	/**
-	 * This method is only ever called from within Hibernate when
-	 * re-constructing the identifier component to set the depth of the
-	 * identifier.
-	 */
-	public synchronized void setDepth(int depth) {
-		this.depth = depth;
-	}
-
-	/**
-	 * This method is only ever called from within Hibernate when
-	 * re-constructing the identifier component to set the error property of the
-	 * identifier.
-	 */
-	public synchronized void setContainsErrors(boolean containsErrors) {
-		this.containsErrors = containsErrors;
-	}
-
-	/**
-	 * This method is only ever called from within Hibernate when
-	 * re-constructing the identifier component to set the reference type
-	 * property of the identifier.
-	 */
-	public synchronized void setReferenceType(T2ReferenceType type) {
-		this.referenceType = type;
-	}
-
-	/**
-	 * By default when printing an identifier we use {@link #toUri()}.
-	 * {@link java.net.URI#toASCIIString() toASCIIString()}
-	 */
-	@Override
-	public String toString() {
-		return toUri().toASCIIString();
-	}
-
-	/**
-	 * Drill inside an error document reference to get the error one deeper than
-	 * this as long as it is at least depth 1.
-	 */
-	T2ReferenceImpl getDeeperErrorReference() {
-		if (!getReferenceType().equals(ErrorDocument))
-			throw new AssertionError(
-					"Attempt to get a deeper reference on something that isn't an error ref");
-		if (getDepth() == 0)
-			throw new AssertionError(
-					"Error identifier already has depth 0, cannot decrease");
-
-		T2ReferenceImpl result = new T2ReferenceImpl();
-		result.setContainsErrors(true);
-		result.setDepth(getDepth() - 1);
-		result.setLocalPart(getLocalPart());
-		result.setNamespacePart(getNamespacePart());
-		result.setReferenceType(ErrorDocument);
-		return result;
-	}
-
-	/**
-	 * Returns the identifier expressed as a {@link java.net.URI URI},
-	 * constructed based on the reference type. For references to ReferenceSet
-	 * this is
-	 * <code>new URI("t2:ref//" + namespacePart + "?" + localPart)</code>
-	 * leading to URIs of the form <code>t2:ref//namespace?local</code>
-	 */
-	@Override
-	public synchronized URI toUri() {
-		try {
-			if (cachedURI == null)
-				switch (referenceType) {
-				case ReferenceSet:
-					cachedURI = new URI("t2:ref//" + getNamespacePart() + "?"
-							+ getLocalPart());
-				case IdentifiedList:
-					cachedURI = new URI("t2:list//" + getNamespacePart() + "?"
-							+ getLocalPart() + "/" + containsErrors + "/"
-							+ depth);
-				case ErrorDocument:
-					cachedURI = new URI("t2:error//" + getNamespacePart() + "?"
-							+ getLocalPart() + "/" + depth);
-				}
-		} catch (URISyntaxException e) {
-			logger.error("Unable to create URI", e);
-		}
-		return cachedURI;
-	}
-
-	@Override
-	public int hashCode() {
-		int result = 1;
-		result = 31 * result + depth;
-		result = 31 * result + (int) (localLeastSigBits ^ (localLeastSigBits >>> 32));
-		result = 31 * result + (int) (localMostSigBits ^ (localMostSigBits >>> 32));
-		result = 31 * result + ((localPart == null) ? 0 : localPart.hashCode());
-		result = 31 * result + ((namespacePart == null) ? 0 : namespacePart.hashCode());
-		return result;
-	}
-
-	@Override
-	public boolean equals(Object obj) {
-		if (this == obj)
-			return true;
-		if (obj == null)
-			return false;
-		if (getClass() != obj.getClass())
-			return false;
-		T2ReferenceImpl other = (T2ReferenceImpl) obj;
-		if (depth != other.depth)
-			return false;
-		if (localLeastSigBits != other.localLeastSigBits)
-			return false;
-		if (localMostSigBits != other.localMostSigBits)
-			return false;
-		if (localPart == null) {
-			if (other.localPart != null)
-				return false;
-		} else if (!localPart.equals(other.localPart))
-			return false;
-		if (namespacePart == null) {
-			if (other.namespacePart != null)
-				return false;
-		} else if (!namespacePart.equals(other.namespacePart))
-			return false;
-		return true;
-	}
-
-	public synchronized String getCompactForm() {
-		return getNamespacePart() + ":" + getLocalPart() + ":" + getDepth();
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.java
deleted file mode 100644
index 3b865dd..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import java.util.List;
-
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.h3.HibernateMappedEntity;
-
-/**
- * Simple extension of
- * <code>{@link IdentifiedArrayList IdentifiedArrayList&lt;T2Reference&gt;}</code>
- * exposing get and set methods for the list contents so we can map it in
- * hibernate.
- * 
- * @author Tom Oinn
- */
-public class T2ReferenceListImpl extends IdentifiedArrayList<T2Reference>
-		implements HibernateMappedEntity {
-	public T2ReferenceListImpl() {
-		super();
-	}
-
-	/**
-	 * This is only called from Hibernate, outside of test code, so is
-	 * relatively safe to leave unchecked.
-	 */
-	@SuppressWarnings("rawtypes")
-	public List getListContents() {
-		return this.listDelegate;
-	}
-
-	/**
-	 * This is only called from Hibernate, outside of test code, so is
-	 * relatively safe to leave unchecked.
-	 */
-	@SuppressWarnings({ "unchecked", "rawtypes" })
-	public void setListContents(List newList) {
-		this.listDelegate = newList;
-	}
-
-	/**
-	 * Print the contents of this list for vaguely human readable debug
-	 * purposes.
-	 */
-	@Override
-	public String toString() {
-		StringBuilder sb = new StringBuilder();
-		sb.append(getId()).append("\n");
-		int counter = 0;
-		for (T2Reference ref : listDelegate)
-			sb.append("  ").append(++counter).append(") ").append(ref)
-					.append("\n");
-		return sb.toString();
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateErrorDocumentDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateErrorDocumentDao.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateErrorDocumentDao.java
deleted file mode 100644
index 987facb..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateErrorDocumentDao.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import static net.sf.taverna.t2.reference.T2ReferenceType.ErrorDocument;
-
-import java.util.List;
-
-import net.sf.taverna.t2.reference.DaoException;
-import net.sf.taverna.t2.reference.ErrorDocument;
-import net.sf.taverna.t2.reference.ErrorDocumentDao;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.annotations.DeleteIdentifiedOperation;
-import net.sf.taverna.t2.reference.annotations.GetIdentifiedOperation;
-import net.sf.taverna.t2.reference.annotations.PutIdentifiedOperation;
-
-import org.hibernate.Query;
-import org.hibernate.SessionFactory;
-
-/**
- * An implementation of ErrorDocumentDao based on raw hibernate session factory
- * injection and running within a spring managed context through auto-proxy
- * generation. To use this in spring inject a property 'sessionFactory' with
- * either a {@link org.springframework.orm.hibernate3.LocalSessionFactoryBean
- * LocalSessionFactoryBean} or the equivalent class from the T2Platform module
- * to add SPI based implementation discovery and mapping. To use outside of
- * Spring ensure you call the setSessionFactory(..) method before using this
- * (but really, use it from Spring, so much easier).
- * <p>
- * Methods in this Dao require transactional support
- * 
- * @author Tom Oinn
- */
-public class TransactionalHibernateErrorDocumentDao implements ErrorDocumentDao {
-	private static final String GET_ERRORS_FOR_RUN = "FROM ErrorDocumentImpl WHERE namespacePart = :workflow_run_id";
-	private SessionFactory sessionFactory;
-
-	public void setSessionFactory(SessionFactory sessionFactory) {
-		this.sessionFactory = sessionFactory;
-	}
-
-	/**
-	 * Fetch an ErrorDocument list by id
-	 * 
-	 * @param ref
-	 *            the T2Reference to fetch
-	 * @return a retrieved identified list of T2 references
-	 * @throws DaoException
-	 *             if the supplied reference is of the wrong type or if
-	 *             something goes wrong fetching the data or connecting to the
-	 *             database
-	 */
-	@Override
-	@GetIdentifiedOperation
-	public ErrorDocument get(T2Reference ref) throws DaoException {
-		if (ref == null)
-			throw new DaoException(
-					"Supplied reference is null, can't retrieve.");
-		if (!ref.getReferenceType().equals(ErrorDocument))
-			throw new DaoException(
-					"This dao can only retrieve reference of type T2Reference.ErrorDocument");
-		if (!(ref instanceof T2ReferenceImpl))
-			throw new DaoException(
-					"Reference must be an instance of T2ReferenceImpl");
-
-		try {
-			return (ErrorDocumentImpl) sessionFactory.getCurrentSession().get(
-					ErrorDocumentImpl.class,
-					((T2ReferenceImpl) ref).getCompactForm());
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-
-	@Override
-	@PutIdentifiedOperation
-	public void store(ErrorDocument theDocument) throws DaoException {
-		if (theDocument.getId() == null)
-			throw new DaoException(
-					"Supplied error document set has a null ID, allocate "
-							+ "an ID before calling the store method in the dao.");
-		if (!theDocument.getId().getReferenceType().equals(ErrorDocument))
-			throw new DaoException("Strangely the list ID doesn't have type "
-					+ "T2ReferenceType.ErrorDocument, something has probably "
-					+ "gone badly wrong somewhere earlier!");
-		if (!(theDocument instanceof ErrorDocumentImpl))
-			throw new DaoException(
-					"Supplied ErrorDocument not an instance of ErrorDocumentImpl");
-
-		try {
-			sessionFactory.getCurrentSession().save(theDocument);
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-
-	@Override
-	@DeleteIdentifiedOperation
-	public boolean delete(ErrorDocument theDocument) throws DaoException {
-		if (theDocument.getId() == null)
-			throw new DaoException(
-					"Supplied error document set has a null ID, allocate "
-							+ "an ID before calling the store method in the dao.");
-		if (!theDocument.getId().getReferenceType().equals(ErrorDocument))
-			throw new DaoException("Strangely the list ID doesn't have type "
-					+ "T2ReferenceType.ErrorDocument, something has probably "
-					+ "gone badly wrong somewhere earlier!");
-		if (!(theDocument instanceof ErrorDocumentImpl))
-			throw new DaoException(
-					"Supplied ErrorDocument not an instance of ErrorDocumentImpl");
-
-		try {
-			sessionFactory.getCurrentSession().delete(theDocument);
-			return true;
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-
-	@Override
-	@SuppressWarnings("unchecked")
-	@DeleteIdentifiedOperation
-	public synchronized void deleteErrorDocumentsForWFRun(String workflowRunId)
-			throws DaoException {
-		try {
-			// Select all ErrorDocuments for this wf run
-			Query selectQuery = sessionFactory.getCurrentSession().createQuery(
-					GET_ERRORS_FOR_RUN);
-			selectQuery.setString("workflow_run_id", workflowRunId);
-			List<ErrorDocument> errorDocuments = selectQuery.list();
-			for (ErrorDocument errorDocument : errorDocuments)
-				delete(errorDocument);
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateListDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateListDao.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateListDao.java
deleted file mode 100644
index 1a57041..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateListDao.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import static net.sf.taverna.t2.reference.T2ReferenceType.IdentifiedList;
-
-import java.util.List;
-
-import net.sf.taverna.t2.reference.DaoException;
-import net.sf.taverna.t2.reference.IdentifiedList;
-import net.sf.taverna.t2.reference.ListDao;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.annotations.DeleteIdentifiedOperation;
-import net.sf.taverna.t2.reference.annotations.GetIdentifiedOperation;
-import net.sf.taverna.t2.reference.annotations.PutIdentifiedOperation;
-
-import org.hibernate.Query;
-import org.hibernate.SessionFactory;
-
-/**
- * An implementation of ListDao based on based on raw hibernate session factory
- * injection and running within a spring managed context through auto-proxy
- * generation. To use this in spring inject a property 'sessionFactory' with
- * either a {@link org.springframework.orm.hibernate3.LocalSessionFactoryBean
- * LocalSessionFactoryBean} or the equivalent class from the T2Platform module
- * to add SPI based implementation discovery and mapping. To use outside of
- * Spring ensure you call the setSessionFactory(..) method before using this
- * (but really, use it from Spring, so much easier).
- * <p>
- * Methods in this Dao require transactional support
- * 
- * @author Tom Oinn
- */
-public class TransactionalHibernateListDao implements ListDao {
-	private static final String GET_REFLISTS_FOR_RUN = "FROM T2ReferenceListImpl WHERE namespacePart = :workflow_run_id";
-	private SessionFactory sessionFactory;
-
-	public void setSessionFactory(SessionFactory sessionFactory) {
-		this.sessionFactory = sessionFactory;
-	}
-
-	/**
-	 * Fetch a t2reference list by id
-	 * 
-	 * @param ref
-	 *            the T2Reference to fetch
-	 * @return a retrieved identified list of T2 references
-	 * @throws DaoException
-	 *             if the supplied reference is of the wrong type or if
-	 *             something goes wrong fetching the data or connecting to the
-	 *             database
-	 */
-	@Override
-	@GetIdentifiedOperation
-	public IdentifiedList<T2Reference> get(T2Reference ref) throws DaoException {
-		if (ref == null)
-			throw new DaoException(
-					"Supplied reference is null, can't retrieve.");
-		if (!ref.getReferenceType().equals(IdentifiedList))
-			throw new DaoException(
-					"This dao can only retrieve reference of type T2Reference.IdentifiedList");
-		if (!(ref instanceof T2ReferenceImpl))
-			throw new DaoException(
-					"Reference must be an instance of T2ReferenceImpl");
-
-		try {
-			return (T2ReferenceListImpl) sessionFactory.getCurrentSession()
-					.get(T2ReferenceListImpl.class,
-							((T2ReferenceImpl) ref).getCompactForm());
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-
-	@Override
-	@PutIdentifiedOperation
-	public void store(IdentifiedList<T2Reference> theList) throws DaoException {
-		if (theList.getId() == null)
-			throw new DaoException("Supplied list set has a null ID, allocate "
-					+ "an ID before calling the store method in the dao.");
-		if (!theList.getId().getReferenceType().equals(IdentifiedList))
-			throw new DaoException("Strangely the list ID doesn't have type "
-					+ "T2ReferenceType.IdentifiedList, something has probably "
-					+ "gone badly wrong somewhere earlier!");
-		if (!(theList instanceof T2ReferenceListImpl))
-			throw new DaoException(
-					"Supplied identifier list not an instance of T2ReferenceList");
-
-		try {
-			sessionFactory.getCurrentSession().save(theList);
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-
-	@Override
-	public boolean delete(IdentifiedList<T2Reference> theList)
-			throws DaoException {
-		if (theList.getId() == null)
-			throw new DaoException("Supplied list set has a null ID, allocate "
-					+ "an ID before calling the store method in the dao.");
-		if (!theList.getId().getReferenceType().equals(IdentifiedList))
-			throw new DaoException("Strangely the list ID doesn't have type "
-					+ "T2ReferenceType.IdentifiedList, something has probably "
-					+ "gone badly wrong somewhere earlier!");
-		if (!(theList instanceof T2ReferenceListImpl))
-			throw new DaoException(
-					"Supplied identifier list not an instance of T2ReferenceList");
-
-		try {
-			sessionFactory.getCurrentSession().delete(theList);
-			return true;
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-
-	@Override
-	@SuppressWarnings("unchecked")
-	@DeleteIdentifiedOperation
-	public synchronized void deleteIdentifiedListsForWFRun(String workflowRunId)
-			throws DaoException {
-		try {
-			// Select all T2Reference lists for this wf run
-			Query selectQuery = sessionFactory.getCurrentSession().createQuery(
-					GET_REFLISTS_FOR_RUN);
-			selectQuery.setString("workflow_run_id", workflowRunId);
-			List<IdentifiedList<T2Reference>> referenceLists = selectQuery
-					.list();
-			for (IdentifiedList<T2Reference> referenceList : referenceLists)
-				delete(referenceList);
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateReferenceSetDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateReferenceSetDao.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateReferenceSetDao.java
deleted file mode 100644
index 2fc1edd..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateReferenceSetDao.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import static net.sf.taverna.t2.reference.T2ReferenceType.ReferenceSet;
-
-import java.util.List;
-
-import net.sf.taverna.t2.reference.DaoException;
-import net.sf.taverna.t2.reference.ReferenceSet;
-import net.sf.taverna.t2.reference.ReferenceSetDao;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.annotations.DeleteIdentifiedOperation;
-import net.sf.taverna.t2.reference.annotations.GetIdentifiedOperation;
-import net.sf.taverna.t2.reference.annotations.PutIdentifiedOperation;
-
-import org.hibernate.Query;
-import org.hibernate.SessionFactory;
-
-/**
- * An implementation of ReferenceSetDao based on raw hibernate session factory
- * injection and running within a spring managed context through auto-proxy
- * generation. To use this in spring inject a property 'sessionFactory' with
- * either a {@link org.springframework.orm.hibernate3.LocalSessionFactoryBean
- * LocalSessionFactoryBean} or the equivalent class from the T2Platform module
- * to add SPI based implementation discovery and mapping. To use outside of
- * Spring ensure you call the setSessionFactory(..) method before using this
- * (but really, use it from Spring, so much easier).
- * <p>
- * Methods in this Dao require transactional support
- * 
- * @author Tom Oinn
- */
-public class TransactionalHibernateReferenceSetDao implements ReferenceSetDao {
-	private static final String GET_REFSETS_FOR_RUN = "FROM ReferenceSetImpl WHERE namespacePart=:workflow_run_id";
-	private SessionFactory sessionFactory;
-
-	public void setSessionFactory(SessionFactory sessionFactory) {
-		this.sessionFactory = sessionFactory;
-	}
-
-	/**
-	 * Store the specified new reference set
-	 * 
-	 * @param rs
-	 *            a reference set, must not already exist in the database.
-	 * @throws DaoException
-	 *             if the entry already exists in the database, if the supplied
-	 *             reference set isn't an instance of ReferenceSetImpl or if
-	 *             something else goes wrong connecting to the database
-	 */
-	@Override
-	@PutIdentifiedOperation
-	public void store(ReferenceSet rs) throws DaoException {
-		if (rs.getId() == null)
-			throw new DaoException(
-					"Supplied reference set has a null ID, allocate "
-							+ "an ID before calling the store method in the dao.");
-		if (!rs.getId().getReferenceType().equals(ReferenceSet))
-			throw new DaoException(
-					"Strangely the reference set ID doesn't have type "
-							+ "T2ReferenceType.ReferenceSet, something has probably "
-							+ "gone badly wrong somewhere earlier!");
-		if (!(rs instanceof ReferenceSetImpl))
-			throw new DaoException(
-					"Supplied reference set not an instance of ReferenceSetImpl");
-
-		try {
-			sessionFactory.getCurrentSession().save(rs);
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-
-	/**
-	 * Update a pre-existing entry in the database
-	 * 
-	 * @param rs
-	 *            the reference set to update. This must already exist in the
-	 *            database
-	 * @throws DaoException
-	 */
-	@Override
-	@PutIdentifiedOperation
-	public void update(ReferenceSet rs) throws DaoException {
-		if (rs.getId() == null)
-			throw new DaoException(
-					"Supplied reference set has a null ID, allocate "
-							+ "an ID before calling the store method in the dao.");
-		if (!rs.getId().getReferenceType().equals(ReferenceSet))
-			throw new DaoException(
-					"Strangely the reference set ID doesn't have type "
-							+ "T2ReferenceType.ReferenceSet, something has probably "
-							+ "gone badly wrong somewhere earlier!");
-		if (!(rs instanceof ReferenceSetImpl))
-			throw new DaoException(
-					"Supplied reference set not an instance of ReferenceSetImpl");
-
-		try {
-			sessionFactory.getCurrentSession().update(rs);
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-
-	/**
-	 * Fetch a reference set by id
-	 * 
-	 * @param ref
-	 *            the ReferenceSetT2ReferenceImpl to fetch
-	 * @return a retrieved ReferenceSetImpl
-	 * @throws DaoException
-	 *             if the supplied reference is of the wrong type or if
-	 *             something goes wrong fetching the data or connecting to the
-	 *             database
-	 */
-	@Override
-	@GetIdentifiedOperation
-	public ReferenceSetImpl get(T2Reference ref) throws DaoException {
-		if (ref == null)
-			throw new DaoException(
-					"Supplied reference is null, can't retrieve.");
-		if (!ref.getReferenceType().equals(ReferenceSet))
-			throw new DaoException(
-					"This dao can only retrieve reference of type T2Reference.ReferenceSet");
-		if (!(ref instanceof T2ReferenceImpl))
-			throw new DaoException(
-					"Reference must be an instance of T2ReferenceImpl");
-
-		try {
-			return (ReferenceSetImpl) sessionFactory.getCurrentSession().get(
-					ReferenceSetImpl.class,
-					((T2ReferenceImpl) ref).getCompactForm());
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-
-	@Override
-	@DeleteIdentifiedOperation
-	public boolean delete(ReferenceSet rs) throws DaoException {
-		if (rs.getId() == null)
-			throw new DaoException(
-					"Supplied reference set has a null ID, allocate "
-							+ "an ID before calling the store method in the dao.");
-		if (!rs.getId().getReferenceType().equals(ReferenceSet))
-			throw new DaoException(
-					"Strangely the reference set ID doesn't have type "
-							+ "T2ReferenceType.ReferenceSet, something has probably "
-							+ "gone badly wrong somewhere earlier!");
-		if (!(rs instanceof ReferenceSetImpl))
-			throw new DaoException(
-					"Supplied reference set not an instance of ReferenceSetImpl");
-
-		try {
-			sessionFactory.getCurrentSession().delete(rs);
-			return true;
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-
-	@Override
-	@SuppressWarnings("unchecked")
-	@DeleteIdentifiedOperation
-	public synchronized void deleteReferenceSetsForWFRun(String workflowRunId)
-			throws DaoException {
-		try {
-			// Select all ReferenceSets for this wf run
-			Query selectQuery = sessionFactory.getCurrentSession().createQuery(
-					GET_REFSETS_FOR_RUN);
-			selectQuery.setString("workflow_run_id", workflowRunId);
-			List<ReferenceSet> referenceSets = selectQuery.list();
-			for (ReferenceSet referenceSet : referenceSets)
-				delete(referenceSet);
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TranslationPath.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TranslationPath.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TranslationPath.java
deleted file mode 100644
index bd4a1f0..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TranslationPath.java
+++ /dev/null
@@ -1,266 +0,0 @@
-package net.sf.taverna.t2.reference.impl;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import net.sf.taverna.t2.reference.DereferenceException;
-import net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferenceSet;
-
-/**
- * A path from one external reference to another along with a total estimated
- * path cost through one or more reference translators.
- */
-public class TranslationPath implements Comparable<TranslationPath>,
-		Iterable<ExternalReferenceTranslatorSPI<?, ?>> {
-	private List<ExternalReferenceTranslatorSPI<?, ?>> translators = new ArrayList<>();
-	private ExternalReferenceBuilderSPI<?> initialBuilder = null;
-	private ExternalReferenceSPI sourceReference = null;
-	private List<ExternalReferenceBuilderSPI<?>> builders;
-
-	public TranslationPath() {
-	}
-
-	/**
-	 * Return a human readable representation of this translation path, used by
-	 * the logging methods to print trace information.
-	 */
-	@SuppressWarnings("rawtypes")
-	@Override
-	public String toString() {
-		StringBuilder sb = new StringBuilder();
-		sb.append(getPathCost() + " ");
-		if (getSourceReference() != null && getInitialBuilder() != null) {
-			sb.append(getSourceReference()).append("->bytes(")
-					.append(getSourceReference().getResolutionCost())
-					.append(")->");
-			String builderClassName = getInitialBuilder().getClass()
-					.getSimpleName();
-			String builtType = getInitialBuilder().getReferenceType()
-					.getSimpleName();
-			sb.append("builder:").append(builderClassName).append("(")
-					.append(getInitialBuilder().getConstructionCost())
-					.append("):<").append(builtType).append(">");
-		} else if (!getTranslators().isEmpty())
-			sb.append("<")
-					.append(getTranslators().get(0).getSourceReferenceType()
-							.getSimpleName()).append(">");
-		for (ExternalReferenceTranslatorSPI translator : getTranslators())
-			sb.append("-")
-					.append(translator.getClass().getSimpleName())
-					.append("(")
-					.append(translator.getTranslationCost())
-					.append(")-<")
-					.append(translator.getTargetReferenceType().getSimpleName())
-					.append(">");
-		return sb.toString();
-	}
-
-	@SuppressWarnings({ "rawtypes", "unchecked" })
-	public Set<ExternalReferenceSPI> doTranslation(ReferenceSet rs,
-			ReferenceContext context) {
-		Set<ExternalReferenceSPI> results = new HashSet<>();
-		/*
-		 * Firstly check whether we have an initial reference and builder
-		 * defined
-		 */
-		ExternalReferenceSPI currentReference = null;
-		if (getInitialBuilder() != null && getSourceReference() != null)
-			try (InputStream stream = getSourceReference().openStream(context)) {
-				ExternalReferenceSPI builtReference = getInitialBuilder()
-						.createReference(stream, context);
-				results.add(builtReference);
-				currentReference = builtReference;
-			} catch (IOException e) {
-				throw new DereferenceException(
-						"Can't create reference from stream", e);
-			}
-		if (!getTranslators().isEmpty() && currentReference == null)
-			/*
-			 * If there are translators in the path (there may not be if this is
-			 * a pure 'dereference and build' type path) and the
-			 * currentReference hasn't been set then search the existing
-			 * references for an appropriate starting point for the translation.
-			 */
-			for (ExternalReferenceSPI er : rs.getExternalReferences())
-				if (er.getClass().equals(
-						getTranslators().get(0).getSourceReferenceType())) {
-					currentReference = er;
-					break;
-				}
-		if (currentReference == null)
-			throw new RuntimeException(
-					"Can't locate a starting reference for the"
-							+ " translation path");
-
-		for (ExternalReferenceTranslatorSPI translator : getTranslators()) {
-			ExternalReferenceSPI translatedReference = translator
-					.createReference(currentReference, context);
-			results.add(translatedReference);
-			currentReference = translatedReference;
-		}
-		return results;
-	}
-
-	/**
-	 * Sum of translation costs of all translators in path
-	 */
-	public float getPathCost() {
-		float cost = 0.0f;
-		for (ExternalReferenceTranslatorSPI<?, ?> ert : this)
-			cost += ert.getTranslationCost();
-		/*
-		 * If the source reference and initial builder are non-null then we're
-		 * going to start this translation path by downloading a byte stream
-		 * from the specified (current) reference and using it to construct the
-		 * starting point for the translation path via the specified builder.
-		 */
-		if (getSourceReference() != null)
-			cost += getSourceReference().getResolutionCost();
-		if (getInitialBuilder() != null)
-			cost += getInitialBuilder().getConstructionCost();
-		return cost;
-	}
-
-	/**
-	 * Return a list of translation paths based on this one but which start at
-	 * an existing reference within the supplied reference set. Will only
-	 * function if there is a reference builder registered that can build the
-	 * initial reference type used by this translation path, otherwise it
-	 * returns an empty list.
-	 * 
-	 * @param rs
-	 * @return
-	 */
-	@SuppressWarnings("rawtypes")
-	public List<TranslationPath> getDereferenceBasedPaths(ReferenceSet rs) {
-		List<TranslationPath> results = new ArrayList<>();
-		for (ExternalReferenceBuilderSPI erb : getBuilders())
-			/*
-			 * Check for each reference builder to see if it can build the
-			 * source type for this path
-			 */
-			if (erb.getReferenceType().equals(this.getSourceType()))
-				/*
-				 * The builder can construct the type used by the start of this
-				 * translation path, so we can in general create a path from a
-				 * fooreference to the target by de-referencing the fooreference
-				 * and building the start type from it.
-				 */
-				for (ExternalReferenceSPI er : rs.getExternalReferences()) {
-					/*
-					 * For each external reference in the existing reference
-					 * set, check whether that type is already going to be
-					 * created in the translation path - if so then there's not
-					 * much point in emiting the modified path, as you'd have
-					 * something like bytes->a->b->a->result which wouldn't make
-					 * any sense
-					 */
-					boolean overlapsExistingType = false;
-					for (ExternalReferenceTranslatorSPI translationStep : this)
-						if (translationStep.getSourceReferenceType().equals(
-								er.getClass())) {
-							overlapsExistingType = true;
-							break;
-						}
-					if (!overlapsExistingType) {
-						/*
-						 * The type wasn't found anywhere within the translation
-						 * path, so we're not generating obviously stupid
-						 * candidate paths.
-						 */
-						TranslationPath newPath = new TranslationPath();
-						newPath.setBuilders(getBuilders());
-						newPath.setTranslators(getTranslators());
-						newPath.setInitialBuilder(erb);
-						newPath.setSourceReference(er);
-						results.add(newPath);
-					}
-				}
-		return results;
-	}
-
-	public List<ExternalReferenceTranslatorSPI<?, ?>> pathSteps() {
-		return getTranslators();
-	}
-
-	/**
-	 * Order by total path cost
-	 */
-	@Override
-	public int compareTo(TranslationPath tp) {
-		float tpCost = tp.getPathCost();
-		float myCost = getPathCost();
-		if (tpCost > myCost)
-			return -1;
-		if (tpCost < myCost)
-			return 1;
-		return 0;
-	}
-
-	/**
-	 * Wrap translator list iterator for convenience
-	 */
-	@Override
-	public Iterator<ExternalReferenceTranslatorSPI<?, ?>> iterator() {
-		return getTranslators().iterator();
-	}
-
-	public Class<? extends ExternalReferenceSPI> getSourceType() {
-		if (!getTranslators().isEmpty())
-			return getTranslators().get(0).getSourceReferenceType();
-		if (getSourceReference() != null)
-			return getSourceReference().getClass();
-		return null;
-	}
-
-	public Class<? extends ExternalReferenceSPI> getTargetType() {
-		if (!getTranslators().isEmpty())
-			return getTranslators().get(getTranslators().size() - 1)
-					.getTargetReferenceType();
-		if (getInitialBuilder() != null)
-			return getInitialBuilder().getReferenceType();
-		return null;
-	}
-
-	public List<ExternalReferenceTranslatorSPI<?, ?>> getTranslators() {
-		return translators;
-	}
-
-	public void setTranslators(
-			List<ExternalReferenceTranslatorSPI<?, ?>> translators) {
-		this.translators = translators;
-	}
-
-	public ExternalReferenceBuilderSPI<?> getInitialBuilder() {
-		return initialBuilder;
-	}
-
-	public void setInitialBuilder(ExternalReferenceBuilderSPI<?> initialBuilder) {
-		this.initialBuilder = initialBuilder;
-	}
-
-	public ExternalReferenceSPI getSourceReference() {
-		return sourceReference;
-	}
-
-	public void setSourceReference(ExternalReferenceSPI sourceReference) {
-		this.sourceReference = sourceReference;
-	}
-
-	public List<ExternalReferenceBuilderSPI<?>> getBuilders() {
-		return builders;
-	}
-
-	public void setBuilders(List<ExternalReferenceBuilderSPI<?>> builders) {
-		this.builders = builders;
-	}
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/UUIDT2ReferenceGenerator.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/UUIDT2ReferenceGenerator.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/UUIDT2ReferenceGenerator.java
deleted file mode 100644
index 9e6bbef..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/UUIDT2ReferenceGenerator.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import java.util.UUID;
-
-import net.sf.taverna.t2.reference.T2ReferenceGenerator;
-
-/**
- * A T2ReferenceGenerator based on UUIDs. Not as fast as
- * {@link SimpleT2ReferenceGenerator}, but IDs will be globally unique.
- * 
- * @author Stian Soiland-Reyes
- */
-public class UUIDT2ReferenceGenerator extends AbstractT2ReferenceGenerator
-		implements T2ReferenceGenerator {
-	private String namespace = "uuid";
-
-	/**
-	 * Set the namespace for identifiers generated by this class as a string
-	 * 
-	 * @param newNamespace
-	 *            the namespace to use
-	 */
-	public void setNamespace(String newNamespace) {
-		this.namespace = newNamespace;
-	}
-	
-	@Override
-	public String getNamespace() {
-		return namespace;
-	}
-
-	@Override
-	protected String getNextLocalPart() {
-		return UUID.randomUUID().toString();
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/WriteQueueAspect.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/WriteQueueAspect.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/WriteQueueAspect.java
deleted file mode 100644
index be1b68b..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/WriteQueueAspect.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import static java.util.concurrent.TimeUnit.SECONDS;
-
-import java.lang.ref.SoftReference;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Executors;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-
-import net.sf.taverna.t2.reference.DaoException;
-import net.sf.taverna.t2.reference.Identified;
-import net.sf.taverna.t2.reference.T2Reference;
-
-import org.aspectj.lang.ProceedingJoinPoint;
-
-/**
- * An aspect used to intercept calls to the various data access objects and
- * execute data writes on a thread limited executer with an unbounded blocking
- * queue.
- * 
- * @author David Withers
- */
-public class WriteQueueAspect {
-	private Map<T2Reference, Identified> store = new ConcurrentHashMap<>();
-	private Map<T2Reference, SoftReference<Identified>> cache = new ConcurrentHashMap<>();
-	private ThreadPoolExecutor executer;
-
-	public WriteQueueAspect() {
-		this(5);
-	}
-
-	public WriteQueueAspect(int threads) {
-		executer = new ThreadPoolExecutor(threads, threads, 60, SECONDS,
-				new LinkedBlockingQueue<Runnable>(),
-				Executors.defaultThreadFactory(),
-				new ThreadPoolExecutor.CallerRunsPolicy());
-	}
-
-	/**
-	 * Handle a 'get by T2Reference' operation on a Dao
-	 * 
-	 * @param pjp
-	 *            the join point representing the ongoing method call to the dao
-	 * @return the entity identified by the T2Reference supplied to the method
-	 *         to which this advice applies
-	 * @throws DaoException
-	 *             if anything goes wrong
-	 */
-	public final Identified getObject(final ProceedingJoinPoint pjp)
-			throws DaoException {
-		Identified result = null;
-
-		// Get the T2Reference from the argument to the get method
-		T2Reference id = (T2Reference) pjp.getArgs()[0];
-		if (id != null) {
-			// try the cache
-			SoftReference<Identified> ref = cache.get(id);
-			if (ref != null)
-				result = ref.get();
-			if (result == null)
-				// not in the cache, check if it's still in the write queue
-				result = store.get(id);
-		}
-		// If we miss the cache then call the method as usual
-		if (result == null)
-			try {
-				result = (Identified) pjp.proceed();
-				if (result != null)
-					cache.put(id, new SoftReference<>(result));
-			} catch (DaoException e) {
-				throw e;
-			} catch (Throwable e) {
-				throw new DaoException(
-						"Unexpected exception type during aspect "
-								+ "based invocation", e);
-			}
-
-		return result;
-	}
-
-	/**
-	 * Called around a write or update operation on the backing store, writes
-	 * through to the cache after modifying the state of the backing store and
-	 * before returning from the dao method
-	 * 
-	 * @param pjp
-	 *            join point representing the ongoing method invocation to cache
-	 * @throws DaoException
-	 *             if anything goes wrong
-	 */
-	public void putObject(final ProceedingJoinPoint pjp) throws DaoException {
-		// Get the Identified being stored by the method we're advising
-		final Identified storedObject = (Identified) pjp.getArgs()[0];
-
-		Runnable task = new Runnable() {
-			@Override
-			public void run() {
-				try {
-					// Run the store or update method
-					pjp.proceed();
-					store.remove(storedObject.getId());
-				} catch (DaoException e) {
-					throw e;
-				} catch (Throwable e) {
-					throw new DaoException(
-							"Unexpected exception type during aspect "
-									+ "based invocation", e);
-				}
-			}
-		};
-
-		cache.put(storedObject.getId(), new SoftReference<>(storedObject));
-		store.put(storedObject.getId(), storedObject);
-		executer.execute(task);
-	}
-
-	public int cacheSize() {
-		return executer.getActiveCount() + executer.getQueue().size();
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/package.html
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/package.html b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/package.html
deleted file mode 100644
index 79e0107..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<body>
-Implementation of the reference manager APIs backed by Hibernate. These
-classes are intended to be used with Spring, so have their dependencies
-injected through set methods rather than constructor arguments.
-</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/platform/spring/jdbc/TemporaryJDBC.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/platform/spring/jdbc/TemporaryJDBC.java b/taverna-reference-impl/src/main/java/org/apache/taverna/platform/spring/jdbc/TemporaryJDBC.java
new file mode 100644
index 0000000..b89da6f
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/platform/spring/jdbc/TemporaryJDBC.java
@@ -0,0 +1,74 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.spring.jdbc;
+
+import static java.io.File.createTempFile;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Create JDBC connection strings for temporary use (ie. from tests)
+ * <p>
+ * {@link #getTemporaryDerbyJDBC()} creates a temporary directory that is used
+ * to construct the JDBC connection string for a local Derby database.
+ * </p>
+ * <p>
+ * This is most useful from a spring configuration, for example when using
+ * {@link InterpolatingDriverManagerDataSource}:
+ * </p>
+ * 
+ * <pre>
+ * &lt;!-- Apache Derby rooted at a temporary directory --&gt;
+ *  &lt;bean id=&quot;t2reference.jdbc.temporaryjdbc&quot;
+ *  class=&quot;org.apache.taverna.platform.spring.jdbc.TemporaryJDBC&quot;&gt;
+ *  &lt;/bean&gt;
+ *  &lt;bean id=&quot;t2reference.jdbc.url&quot; class=&quot;java.lang.String&quot;
+ *  factory-bean=&quot;t2reference.jdbc.temporaryjdbc&quot;
+ *  factory-method=&quot;getTemporaryDerbyJDBC&quot; /&gt;
+ *  &lt;bean id=&quot;t2reference.jdbc.datasource&quot;
+ *  class=&quot;org.apache.taverna.platform.spring.jdbc.InterpolatingDriverManagerDataSource&quot;&gt;
+ *  &lt;property name=&quot;driverClassName&quot;&gt;
+ *  &lt;value&gt;org.apache.derby.jdbc.EmbeddedDriver&lt;/value&gt;
+ *  &lt;/property&gt;
+ *  &lt;property name=&quot;url&quot;&gt;
+ *  &lt;ref bean=&quot;t2reference.jdbc.url&quot; /&gt;
+ *  &lt;/property&gt;
+ *  &lt;property name=&quot;repository&quot;&gt;
+ *  &lt;ref bean=&quot;raven.repository&quot; /&gt;
+ *  &lt;/property&gt;
+ *  &lt;property name=&quot;driverArtifact&quot;&gt;
+ *  &lt;value&gt;org.apache.derby:derby:10.4.1.3&lt;/value&gt;
+ *  &lt;/property&gt;
+ *  &lt;/bean&gt;
+ * </pre>
+ * 
+ * @author Stian Soiland-Reyes
+ */
+public class TemporaryJDBC {
+	public String getTemporaryDerbyJDBC() throws IOException {
+		File tmpDir = createTempFile("t2platform-", ".db");
+		tmpDir.delete();
+		if (!tmpDir.mkdir())
+			throw new IOException("Could not create temporary directory "
+					+ tmpDir);
+		return "jdbc:derby:" + tmpDir.getPath() + "/database;create=true";
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/platform/spring/jdbc/package.html
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/platform/spring/jdbc/package.html b/taverna-reference-impl/src/main/java/org/apache/taverna/platform/spring/jdbc/package.html
new file mode 100644
index 0000000..2355a14
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/platform/spring/jdbc/package.html
@@ -0,0 +1,6 @@
+<body>
+Extensions to the JDBC parts of Spring, and support for proxying of JDBC 
+drivers so we can load them dynamically from raven artifacts. The proxy 
+approach is inspired by http://www.jroller.com/tackline/entry/dynamically_loading_jdbc_drivers 
+with additions to build from raven rather than from existing jar files.
+</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractEntityImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractEntityImpl.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractEntityImpl.java
new file mode 100644
index 0000000..c0ef737
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractEntityImpl.java
@@ -0,0 +1,65 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import org.apache.taverna.reference.T2Reference;
+
+/**
+ * Abstract superclass of ReferenceSetImpl, IdentifiedArrayList and
+ * ErrorDocumentImpl, manages the T2Reference field for these types and their
+ * hibernate backing.
+ * 
+ * @author Tom Oinn
+ */
+public class AbstractEntityImpl {
+	private T2ReferenceImpl id;
+	private String compactId = null;
+
+	public T2Reference getId() {
+		return id;
+	}
+
+	/**
+	 * This method is only ever called from within Hibernate, and is used to
+	 * initialize the unique ID of this reference set.
+	 */
+	public void setTypedId(T2ReferenceImpl newId) {
+		id = newId;
+	}
+
+	/**
+	 * Used because technically you can't accept and return implementation types
+	 * in the methods on a bean which implements an interface, but Hibernate
+	 * needs to construct concrete input and output types!
+	 */
+	public T2ReferenceImpl getTypedId() {
+		return id;
+	}
+
+	public void setInternalId(String newId) {
+		compactId = newId;
+	}
+
+	public final String getInternalId() {
+		if (compactId == null)
+			compactId = id.getCompactForm();
+		return compactId;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractErrorDocumentServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractErrorDocumentServiceImpl.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractErrorDocumentServiceImpl.java
new file mode 100644
index 0000000..f004b99
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractErrorDocumentServiceImpl.java
@@ -0,0 +1,118 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import org.apache.taverna.reference.DaoException;
+import org.apache.taverna.reference.ErrorDocument;
+import org.apache.taverna.reference.ErrorDocumentDao;
+import org.apache.taverna.reference.ErrorDocumentService;
+import org.apache.taverna.reference.ErrorDocumentServiceCallback;
+import org.apache.taverna.reference.ErrorDocumentServiceException;
+import org.apache.taverna.reference.ListServiceException;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.T2ReferenceGenerator;
+
+/**
+ * Abstract implementation of ErrorDocumentService, inject with an appropriate
+ * ErrorDocumentDao and T2ReferenceGenerator to enable. Contains injectors for
+ * id generation and dao along with other bookkeeping, leaving the
+ * implementation of the actual service logic to the subclass.
+ * 
+ * @author Tom Oinn
+ */
+public abstract class AbstractErrorDocumentServiceImpl extends
+		AbstractServiceImpl implements ErrorDocumentService {
+	protected ErrorDocumentDao errorDao = null;
+	protected T2ReferenceGenerator t2ReferenceGenerator = null;
+
+	/**
+	 * Inject the error document data access object.
+	 */
+	public final void setErrorDao(ErrorDocumentDao dao) {
+		errorDao = dao;
+	}
+
+	/**
+	 * Inject the T2Reference generator used to allocate new IDs when
+	 * registering ErrorDocuments
+	 */
+	public final void setT2ReferenceGenerator(T2ReferenceGenerator t2rg) {
+		t2ReferenceGenerator = t2rg;
+	}
+
+	/**
+	 * Check that the list dao is configured
+	 * 
+	 * @throws ListServiceException
+	 *             if the dao is still null
+	 */
+	protected final void checkDao() throws ErrorDocumentServiceException {
+		if (errorDao == null)
+			throw new ErrorDocumentServiceException(
+					"ErrorDocumentDao not initialized, error document "
+							+ "service operations are not available");
+	}
+
+	/**
+	 * Check that the t2reference generator is configured
+	 * 
+	 * @throws ListServiceException
+	 *             if the generator is still null
+	 */
+	protected final void checkGenerator() throws ErrorDocumentServiceException {
+		if (t2ReferenceGenerator == null)
+			throw new ErrorDocumentServiceException(
+					"T2ReferenceGenerator not initialized, error document "
+							+ "service operations not available");
+	}
+
+	@Override
+	public final void getErrorAsynch(final T2Reference id,
+			final ErrorDocumentServiceCallback callback)
+			throws ErrorDocumentServiceException {
+		checkDao();
+		Runnable r = new Runnable() {
+			@Override
+			public void run() {
+				try {
+					ErrorDocument e = errorDao.get(id);
+					callback.errorRetrieved(e);
+				} catch (DaoException de) {
+					callback.errorRetrievalFailed(new ErrorDocumentServiceException(
+							de));
+				}
+			}
+		};
+		executeRunnable(r);
+	}
+
+	@Override
+	public final ErrorDocument registerError(String message, int depth,
+			ReferenceContext context) throws ErrorDocumentServiceException {
+		return registerError(message, (Throwable) null, depth, context);
+	}
+
+	@Override
+	public final ErrorDocument registerError(Throwable t, int depth,
+			ReferenceContext context) throws ErrorDocumentServiceException {
+		return registerError("", t, depth, context);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractListServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractListServiceImpl.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractListServiceImpl.java
new file mode 100644
index 0000000..4745682
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractListServiceImpl.java
@@ -0,0 +1,99 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import org.apache.taverna.reference.ListDao;
+import org.apache.taverna.reference.ListService;
+import org.apache.taverna.reference.ListServiceCallback;
+import org.apache.taverna.reference.ListServiceException;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.T2ReferenceGenerator;
+
+/**
+ * Abstract implementation of ListService, inject with an appropriate ListDao
+ * and T2ReferenceGenerator to enable. Contains injectors for id generation and
+ * dao along with other bookkeeping, leaving the implementation of the actual
+ * service logic to the subclass.
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public abstract class AbstractListServiceImpl extends AbstractServiceImpl
+		implements ListService {
+	protected ListDao listDao = null;
+	protected T2ReferenceGenerator t2ReferenceGenerator = null;
+
+	/**
+	 * Inject the list data access object.
+	 */
+	public final void setListDao(ListDao dao) {
+		listDao = dao;
+	}
+
+	/**
+	 * Inject the T2Reference generator used to allocate new IDs when
+	 * registering lists of T2Reference
+	 */
+	public final void setT2ReferenceGenerator(T2ReferenceGenerator t2rg) {
+		t2ReferenceGenerator = t2rg;
+	}
+
+	/**
+	 * Check that the list dao is configured
+	 * 
+	 * @throws ListServiceException
+	 *             if the dao is still null
+	 */
+	protected final void checkDao() throws ListServiceException {
+		if (listDao == null)
+			throw new ListServiceException("ListDao not initialized, list "
+					+ "service operations are not available");
+	}
+
+	/**
+	 * Check that the t2reference generator is configured
+	 * 
+	 * @throws ListServiceException
+	 *             if the generator is still null
+	 */
+	protected final void checkGenerator() throws ListServiceException {
+		if (t2ReferenceGenerator == null)
+			throw new ListServiceException(
+					"T2ReferenceGenerator not initialized, list "
+							+ "service operations not available");
+	}
+
+	@Override
+	public final void getListAsynch(final T2Reference id,
+			final ListServiceCallback callback) throws ListServiceException {
+		checkDao();
+		Runnable r = new Runnable() {
+			@Override
+			public void run() {
+				try {
+					callback.listRetrieved(getList(id));
+				} catch (ListServiceException lse) {
+					callback.listRetrievalFailed(lse);
+				}
+			}
+		};
+		executeRunnable(r);
+	}
+}


[22/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/DataflowValidationReport.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/DataflowValidationReport.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/DataflowValidationReport.java
deleted file mode 100644
index 16d4dde..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/DataflowValidationReport.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Contains a validation report from a dataflow validation check. Processors are
- * classified as failed, unsatisfied or valid depending on whether they directly
- * fail type validation, cannot be checked due to unsatisfied incoming links or
- * pass respectively.
- * 
- * @author Tom Oinn
- */
-public interface DataflowValidationReport {
-	/**
-	 * Overall validity - if the workflow is valid it can be run, otherwise
-	 * there are problems somewhere and a facade can't be created from it.
-	 * 
-	 * @return whether the workflow is valid (true) or not (false)
-	 */
-	boolean isValid();
-
-	/**
-	 * Whether the workflow is incomplete, i.e. contains no processors and no
-	 * connected output ports. For example, it is empty or contains only input
-	 * ports. Even though one can technically run such a workflow it should be
-	 * prohibited as it does not make any sense. If a workflow is incomplete
-	 * {@link DataflowValidationReport#isValid()} should return
-	 * <code>false</code>.
-	 * 
-	 * @return whether the workflow is incomplete or not
-	 */
-	boolean isWorkflowIncomplete();
-
-	/**
-	 * The workflow will be marked as invalid if there are entities with
-	 * unlinked input ports or where there are cycles causing the type checking
-	 * algorithm to give up. In these cases offending processors or any
-	 * ancestors that are affected as a knock on effect will be returned in this
-	 * list.
-	 * 
-	 * @return list of TokenProcessingEntity instances within the Dataflow for
-	 *         which it is impossible to determine validity due to missing
-	 *         inputs or cyclic dependencies
-	 */
-	List<? extends TokenProcessingEntity> getUnsatisfiedEntities();
-
-	/**
-	 * The workflow will be marked as invalid if any entity fails to type check.
-	 * 
-	 * @return list of TokenProcessingEntity instances within the Dataflow which
-	 *         caused explicit type check failures
-	 */
-	List<? extends TokenProcessingEntity> getFailedEntities();
-
-	/**
-	 * The workflow will be marked as invalid if any of the dataflow output
-	 * ports can't be typed based on incoming links. This happens if the port
-	 * isn't linked (a common enough issue for new users in previous releases of
-	 * Taverna) or if the internal port is linked but the entity it links to
-	 * isn't validated.
-	 * 
-	 * @return a list of DataflowOutputPort implementations which are not typed
-	 *         correctly. These will have output depth of -1 indicating an
-	 *         unknown depth, they may or may not have a granular depth set but
-	 *         if the overall depth is -1 this isn't important as the thing
-	 *         won't run anyway.
-	 */
-	List<? extends DataflowOutputPort> getUnresolvedOutputs();
-
-	/**
-	 * An entity will be marked invalid if it depends on a nested dataflow which
-	 * itself is invalid. If this is the case the entity will be be present both
-	 * in {@link #getFailedEntities()} and can be used as a key with this method
-	 * to get the DataflowValidationReport explaining how the nested dataflow
-	 * failed.
-	 */
-	Map<TokenProcessingEntity, DataflowValidationReport> getInvalidDataflows();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Datalink.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Datalink.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Datalink.java
deleted file mode 100644
index cb3806f..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Datalink.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-import net.sf.taverna.t2.annotation.Annotated;
-
-/**
- * A single point to point data link from an instance of
- * EventForwardingOutputPort to an instance of EventHandlingInputPort
- * 
- * @author Tom Oinn
- */
-public interface Datalink extends Annotated<Datalink>, WorkflowItem {
-	/**
-	 * Get the sink for events flowing through this link
-	 * 
-	 * @return input port receiving events
-	 */
-	EventHandlingInputPort getSink();
-
-	/**
-	 * Get the source for events flowing through this link
-	 * 
-	 * @return output port generating events
-	 */
-	EventForwardingOutputPort getSource();
-
-	/**
-	 * Each datalink has a resolved depth, this being the constant sum of index
-	 * array length + item depth for all tokens exchanged along this link. Where
-	 * no iteration or data streaming is occuring this will evaluate to the
-	 * output port depth the link is from (as is always the case with the
-	 * internal output ports in dataflow inputs)
-	 * 
-	 * @return
-	 */
-	int getResolvedDepth();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Edit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Edit.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Edit.java
deleted file mode 100644
index 3c0f595..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Edit.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-/**
- * The workflow object model exposed by this API is read only. Properties of the
- * model can only be changed through implementations of this interface, this
- * ensures a consistant approach to grouped edits (transactions) and undo / redo
- * support within the UI. It also potentially allows for capture of editing
- * provenance where a workflow is repurposed or created from an aggregate of
- * several others.
- * 
- * @author Tom Oinn
- */
-public interface Edit<TargetType> {
-	/**
-	 * Perform the edit
-	 * 
-	 * @throws EditException
-	 *             if the edit fails. If an edit throws EditException it should
-	 *             try to ensure the subject is unaltered. Where this is
-	 *             impossible consider breaking edits down into a compound edit.
-	 */
-	TargetType doEdit() throws EditException;
-
-	/**
-	 * Undo the edit, reverting the subject to the state it was in prior to the
-	 * edit
-	 */
-	@Deprecated
-	void undo();
-
-	/**
-	 * Return the object to which this edit applies
-	 * 
-	 * @return
-	 */
-	Object getSubject();
-
-	/**
-	 * Has the edit been applied yet?
-	 * 
-	 * @return true if and only if the edit has been successfully applied to the
-	 *         subject
-	 */
-	boolean isApplied();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/EditException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/EditException.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/EditException.java
deleted file mode 100644
index 4b49a77..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/EditException.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-/**
- * Superclass of all exceptions thrown when altering the workflow model through
- * the edit manager.
- * 
- * @author Tom Oinn
- */
-public class EditException extends Exception {
-	public EditException(String string) {
-		super(string);
-	}
-
-	public EditException(String string, Throwable cause) {
-		super(string, cause);
-	}
-	
-	public EditException(Throwable t) {
-		super(t);
-	}
-
-	private static final long serialVersionUID = 1L;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Edits.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Edits.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Edits.java
deleted file mode 100644
index 742b0fe..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Edits.java
+++ /dev/null
@@ -1,832 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-import java.util.List;
-
-import net.sf.taverna.t2.annotation.Annotated;
-import net.sf.taverna.t2.annotation.AnnotationAssertion;
-import net.sf.taverna.t2.annotation.AnnotationBeanSPI;
-import net.sf.taverna.t2.annotation.AnnotationChain;
-import net.sf.taverna.t2.annotation.AnnotationRole;
-import net.sf.taverna.t2.annotation.AnnotationSourceSPI;
-import net.sf.taverna.t2.annotation.CurationEvent;
-import net.sf.taverna.t2.annotation.CurationEventBeanSPI;
-import net.sf.taverna.t2.annotation.Person;
-import net.sf.taverna.t2.facade.WorkflowInstanceFacade;
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityInputPort;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityOutputPort;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchStack;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.IterationStrategy;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.IterationStrategyStack;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.NamedInputPortNode;
-
-/**
- * Defines the set of all available edit actions over a workflow model. This is
- * the only point at which you can modify any of the entities in the workflow
- * object model, the rest of this API is purely read only.
- * <p>
- * In theory this would be some kind of static interface but Java doesn't have
- * this as a concept so the pattern here will be to discover an appropriate
- * implementation of this interface from whatever version of the implementation
- * package you want to use, instantiate it then use the methods defined here to
- * construct and manipulate the workflow model.
- * 
- * @author Tom Oinn
- * @author Stuart Owen
- * @author David Withers
- * @author Stian Soiland-Reyes
- * 
- */
-public interface Edits {
-
-	/**
-	 * Build a new Dataflow workflow
-	 * 
-	 * @return
-	 */
-	public Dataflow createDataflow();
-
-	/**
-	 * Builds a new DataflowInputPort.
-	 * 
-	 * @param name
-	 * @param depth
-	 * @param granularDepth
-	 * @param dataflow
-	 * @return a new DataflowInputPort
-	 */
-	public DataflowInputPort createDataflowInputPort(String name, int depth,
-			int granularDepth, Dataflow dataflow);
-
-	/**
-	 * Builds a new DataflowOutputPort.
-	 * 
-	 * @param name
-	 * @param dataflow
-	 * @return a new DataflowOutputPort
-	 */
-	public DataflowOutputPort createDataflowOutputPort(String name,
-			Dataflow dataflow);
-
-	/**
-	 * Builds a new Datalink with the given source and sink ports
-	 * 
-	 * @param source
-	 *            the source port
-	 * @param sink
-	 *            the sink port
-	 * @return a new Datalink instance
-	 */
-	public Datalink createDatalink(EventForwardingOutputPort source,
-			EventHandlingInputPort sink);
-
-	/**
-	 * @param dataflow
-	 * @return an instance of Merge
-	 * 
-	 * @see Merge
-	 */
-	public Merge createMerge(Dataflow dataflow);
-
-	/**
-	 * Builds a new MergeOutputPort.
-	 * 
-	 * @param merge
-	 *            the merge that the port eill be added to
-	 * @param name
-	 *            the name of the port
-	 * @param depth
-	 *            the depth of the port
-	 * @return a new MergeOutputPort
-	 */
-	public MergeInputPort createMergeInputPort(Merge merge, String name,
-			int depth);
-
-	/**
-	 * Builds a new instance of a Processor with the given name. The processor
-	 * is setup with a default dispatch stack.
-	 * 
-	 * @param the
-	 *            local name for the processor.
-	 */
-	public Processor createProcessor(String name);
-
-	/**
-	 * Builds a new instance of a IterationStrategy.
-	 * 
-	 * @return a new IterationStrategy
-	 */
-	public IterationStrategy createIterationStrategy();
-
-	/**
-	 * Build a new WorkflowInstanceFacade using the supplied Dataflow
-	 * 
-	 * @param dataflow
-	 * @param context
-	 * @return an instance of a WorkflowInstanceFacade
-	 * @throws InvalidDataflowException
-	 *             if the workflow was not valid
-	 * 
-	 * @see WorkflowInstanceFacade
-	 */
-	public WorkflowInstanceFacade createWorkflowInstanceFacade(
-			Dataflow dataflow, InvocationContext context, String parentProcess)
-			throws InvalidDataflowException;
-
-	/**
-	 * Add an Activity implementation to the set of activities within a
-	 * Processor
-	 * 
-	 * @param processor
-	 *            Processor to add the activity to
-	 * @param activity
-	 *            Activity to add
-	 */
-	public Edit<Processor> getAddActivityEdit(Processor processor,
-			Activity<?> activity);
-
-	/**
-	 * Returns an edit to add an ActivityInputPort to an Activity.
-	 * 
-	 * @param activity
-	 *            activity to add the port to
-	 * @param activityInputPort
-	 *            the port to add to the activity
-	 * @return an edit to add an ActivityInputPort to an Activity
-	 */
-	public Edit<Activity<?>> getAddActivityInputPortEdit(Activity<?> activity,
-			ActivityInputPort activityInputPort);
-
-	/**
-	 * Returns an edit to add a ProcessorInputPort to ActivityInputPort mapping
-	 * to an Activity.
-	 * 
-	 * @param activity
-	 *            activity to add the port mapping to
-	 * @param processorPortName
-	 *            the name of the processor port
-	 * @param activityPortName
-	 *            the name of the activity port
-	 * @return an edit to add a ProcessorInputPort to ActivityInputPort mapping
-	 *         to an Activity
-	 */
-	public Edit<Activity<?>> getAddActivityInputPortMappingEdit(
-			Activity<?> activity, String processorPortName,
-			String activityPortName);
-
-	/**
-	 * Returns an edit to add an ActivityOutputPort to an Activity.
-	 * 
-	 * @param activity
-	 *            activity to add the port to
-	 * @param activityOutputPort
-	 *            the port to add to the activity
-	 * @return an edit to add an ActivityOutputPort to an Activity
-	 */
-	public Edit<Activity<?>> getAddActivityOutputPortEdit(Activity<?> activity,
-			ActivityOutputPort activityOutputPort);
-
-	/**
-	 * Returns an edit to add a ProcessorOutputPort to OutputPort mapping to an
-	 * Activity.
-	 * 
-	 * @param activity
-	 *            activity to add the port mapping to
-	 * @param processorPortName
-	 *            the name of the processor port
-	 * @param activityPortName
-	 *            the name of the activity port
-	 * @return an edit to add a ProcessorOutputPort to OutputPort mapping to an
-	 *         Activity
-	 */
-	public Edit<Activity<?>> getAddActivityOutputPortMappingEdit(
-			Activity<?> activity, String processorPortName,
-			String activityPortName);
-
-	/**
-	 * Builds a new AnnotationChain.
-	 * 
-	 * @return a new AnnotationChain
-	 */
-	public AnnotationChain createAnnotationChain();
-
-	/**
-	 * Add an {@link AnnotationAssertion} to an {@link AnnotationChain}
-	 * 
-	 * @param annotationChain
-	 * @param annotationAssertion
-	 * @return an {@link Edit}able object with undo feature
-	 */
-	public Edit<AnnotationChain> getAddAnnotationAssertionEdit(
-			AnnotationChain annotationChain,
-			AnnotationAssertion<?> annotationAssertion);
-
-	/**
-	 * Add an {@link AnnotationBeanSPI} to an {@link AnnotationAssertion}
-	 * 
-	 * @param annotationAssertion
-	 * @param annotationBean
-	 * @return the edit which has do/undo functionality
-	 */
-	public <T extends AnnotationBeanSPI> Edit<AnnotationAssertion<T>> getAddAnnotationBean(
-			AnnotationAssertion<T> annotationAssertion,
-			AnnotationBeanSPI annotationBean);
-
-	/**
-	 * Returnes an edit that creates an AnnotationAssertion, adds the
-	 * AnnotationAssertion to an AnnotationChain and adds the AnnotationChain to
-	 * the Annotated.
-	 * 
-	 * @param annotated
-	 *            the Annotated to add an AnnotationChain to
-	 * @param annotation
-	 *            the annotation to add to the chain
-	 * @return an edit that creates and adds an AnnotationChain to an Annotated
-	 */
-	public Edit<?> getAddAnnotationChainEdit(Annotated<?> annotated,
-			AnnotationBeanSPI annotation);
-
-	public <T extends AnnotationBeanSPI> Edit<AnnotationAssertion<T>> getAddAnnotationRole(
-			AnnotationAssertion<T> annotationAssertion,
-			AnnotationRole annotationRole);
-
-	public <T extends AnnotationBeanSPI> Edit<AnnotationAssertion<T>> getAddAnnotationSource(
-			AnnotationAssertion<T> annotationAssertion,
-			AnnotationSourceSPI annotationSource);
-
-	public <T extends AnnotationBeanSPI> Edit<AnnotationAssertion<T>> getAddCreator(
-			AnnotationAssertion<T> annotationAssertion, Person person);
-
-	public <T extends AnnotationBeanSPI, S extends CurationEventBeanSPI> Edit<AnnotationAssertion<T>> getAddCurationEvent(
-			AnnotationAssertion<T> annotationAssertion,
-			CurationEvent<S> curationEvent);
-
-	/**
-	 * Returns an edit to add a DataflowInputPort to a Dataflow.
-	 * 
-	 * @param dataflow
-	 *            dataflow to add the port to
-	 * @param dataflowInputPort
-	 *            the port to add to the dataflow
-	 * @return an edit to add a DataflowInputPort to a Dataflow
-	 */
-	public Edit<Dataflow> getAddDataflowInputPortEdit(Dataflow dataflow,
-			DataflowInputPort dataflowInputPort);
-
-	/**
-	 * Returns an edit to add a DataflowOutputPort to a Dataflow.
-	 * 
-	 * @param dataflow
-	 *            dataflow to add the port to
-	 * @param dataflowOutputPort
-	 *            the port to add to the dataflow
-	 * @return an edit to add a DataflowOutputPort to a Dataflow
-	 */
-	public Edit<Dataflow> getAddDataflowOutputPortEdit(Dataflow dataflow,
-			DataflowOutputPort dataflowOutputPort);
-
-	/**
-	 * Returns an edit to change the depth of a DataflowInputPort.
-	 * 
-	 * @param dataflowInputPort
-	 *            the port to change the depth of
-	 * @param depth
-	 *            the new depth
-	 * @return an edit to change the depth of a Dataflow
-	 */
-	public Edit<DataflowInputPort> getChangeDataflowInputPortDepthEdit(
-			DataflowInputPort dataflowInputPort, int depth);
-
-	/**
-	 * Returns an edit to change the granular depth of a DataflowInputPort.
-	 * 
-	 * @param dataflowInputPort
-	 *            the port to change the granular depth of
-	 * @param granularDepth
-	 *            the new granular depth
-	 * @return an edit to change the granular depth of a Dataflow
-	 */
-	public Edit<DataflowInputPort> getChangeDataflowInputPortGranularDepthEdit(
-			DataflowInputPort dataflowInputPort, int granularDepth);
-
-	/**
-	 * Add a new layer to the specified dispatch stack
-	 * 
-	 * @param stack
-	 *            Stack to add to
-	 * @param layer
-	 *            New dispatch layer to add
-	 * @param position
-	 *            Where to add the new layer? 0 is at the top of the stack.
-	 */
-	public Edit<DispatchStack> getAddDispatchLayerEdit(DispatchStack stack,
-			DispatchLayer<?> layer, int position);
-
-	public Edit<Dataflow> getAddMergeEdit(Dataflow dataflow, Merge processor);
-
-	/**
-	 * Returns an edit to add a MergeInputPort to a Merge.
-	 * 
-	 * @param merge
-	 *            merge to add the port to
-	 * @param mergeInputPort
-	 *            the port to add to the merge
-	 * @return an edit to add a MergeInputPort to a Merge
-	 */
-	public Edit<Merge> getAddMergeInputPortEdit(Merge merge,
-			MergeInputPort mergeInputPort);
-
-	/**
-	 * Returns an edit to reorder the list of MergeInputPortS in a Merge.
-	 * 
-	 * @param merge
-	 *            merge to reorder the list of input ports to
-	 * @param reorderedMergeInputPortList
-	 *            a list of reordered input ports
-	 * @return an edit to reorder the list of MergeInputPortS to a Merge
-	 */
-	public Edit<Merge> getReorderMergeInputPortsEdit(Merge merge,
-			List<MergeInputPort> reorderedMergeInputPortList);
-
-	/**
-	 * Provides an edit object responsible for adding a Processor to a Dataflow
-	 * 
-	 * @param dataflow
-	 *            the dataflow to add this processor to
-	 * @param processor
-	 *            the processor to be added to the dataflow
-	 */
-	public Edit<Dataflow> getAddProcessorEdit(Dataflow dataflow,
-			Processor processor);
-
-	/**
-	 * Provides an Edit to add an input port a processor, creating matching
-	 * ports in the iteration strategy or strategies as a side effect.
-	 * 
-	 * @param processor
-	 *            processor to add the port to
-	 * 
-	 * @param port
-	 *            the input port to be added
-	 */
-	public Edit<Processor> getAddProcessorInputPortEdit(Processor processor,
-			ProcessorInputPort port);
-
-	/**
-	 * Provides an Edit to add a new output port on a processor
-	 * 
-	 * @param processor
-	 *            processor to add the new output port to
-	 * 
-	 * @param port
-	 *            the port to be added
-	 */
-	public Edit<Processor> getAddProcessorOutputPortEdit(Processor processor,
-			ProcessorOutputPort port);
-
-	/**
-	 * Returns an Edit that is responsible for configuring an Activity with a
-	 * given configuration bean.
-	 * 
-	 * @see #getConfigureEdit(Configurable, Object)
-	 * @param activity
-	 * @param configurationBean
-	 * @return
-	 */
-	public <ConfigurationBean> Edit<Activity<?>> getConfigureActivityEdit(
-			Activity<ConfigurationBean> activity,
-			ConfigurationBean configurationBean);
-
-	/**
-	 * Return an Edit that can configure a {@link Configurable} (such as an
-	 * {@link Activity} or {@link DispatchLayer} with a given configuration
-	 * bean.
-	 * 
-	 * @param <ConfigurationType>
-	 * @param configurable
-	 * @param configBean
-	 * @return
-	 */
-	public <ConfigurationType> Edit<? extends Configurable<ConfigurationType>> getConfigureEdit(
-			Configurable<ConfigurationType> configurable,
-			ConfigurationType configBean);
-
-	/**
-	 * Connect a datalink to its source and sink.
-	 * 
-	 * @param datalink
-	 *            the datalink to connect
-	 * @return a datalink edit
-	 */
-	public Edit<Datalink> getConnectDatalinkEdit(Datalink datalink);
-
-	/**
-	 * Creates and returns an instance of an Edit<Merge> that is responsible for
-	 * generating the links to an from the Merge instance to link together the
-	 * source and sink port via the merge instance.
-	 * 
-	 * @return a new instance of Edit<Merge> constructed from the provided
-	 *         parameters.
-	 * 
-	 * @param merge
-	 *            a Merge instance
-	 * @param sourcePort
-	 *            the source port from which a link is to be created.
-	 * @param sinkPort
-	 *            the sink port to which the link is to be created.
-	 * 
-	 * @see Merge
-	 */
-	public Edit<Merge> getConnectMergedDatalinkEdit(Merge merge,
-			EventForwardingOutputPort sourcePort,
-			EventHandlingInputPort sinkPort);
-
-	/**
-	 * Connect the output port of the specified processor to a target input
-	 * port. To connect multiple inputs use this method multiple times with
-	 * different targetPort arguments.
-	 * 
-	 * @param processor
-	 *            Processor to link from
-	 * @param outputPortName
-	 *            Name of the output port within the specified processor to link
-	 *            from
-	 * @param targetPort
-	 *            Input port (specifically an EventHandlingInputPort) to forward
-	 *            data events to.
-	 */
-	public Edit<Processor> getConnectProcessorOutputEdit(Processor processor,
-			String outputPortName, EventHandlingInputPort targetPort);
-
-	/**
-	 * Create a condition governing execution of the target processor. The
-	 * target will not consume jobs from any inputs until all control processors
-	 * linked through this edit have completed.
-	 * 
-	 * @param control
-	 *            Processor controlling execution - this must complete before
-	 *            the target can start.
-	 * @param target
-	 *            Processor controlled by this condition.
-	 */
-	public Edit<OrderedPair<Processor>> getCreateConditionEdit(
-			Processor control, Processor target);
-
-	/**
-	 * Add an input port to a dataflow.
-	 * 
-	 * @param dataflow
-	 *            dataflow to add the port to
-	 * @param portName
-	 *            name of the port, unique in the dataflow
-	 * @param portDepth
-	 *            the conceptual depth of collections consumed by this input
-	 *            port
-	 * @param granularDepth
-	 *            granular depth to copy to the internal output port
-	 */
-	public Edit<Dataflow> getCreateDataflowInputPortEdit(Dataflow dataflow,
-			String portName, int portDepth, int granularDepth);
-
-	/**
-	 * Add an output port to a dataflow.
-	 * 
-	 * @param dataflow
-	 *            dataflow to add the port to
-	 * @param portName
-	 *            name of the port, unique in the dataflow
-	 */
-	public Edit<Dataflow> getCreateDataflowOutputPortEdit(Dataflow dataflow,
-			String portName);
-
-	/**
-	 * Provides an edit that setup the default dispatch stack on a raw
-	 * processor.
-	 * 
-	 * @param processor
-	 * @return
-	 */
-	public Edit<Processor> getDefaultDispatchStackEdit(Processor processor);
-
-	/**
-	 * Remove a dispatch layer from its dispatch stack
-	 * 
-	 * @param stack
-	 *            The stack from which to remove the layer
-	 * @param layer
-	 *            The layer to remove
-	 */
-	public Edit<DispatchStack> getDeleteDispatchLayerEdit(DispatchStack stack,
-			DispatchLayer<?> layer);
-
-	/**
-	 * Disconnect a datalink from its source and sink.
-	 * 
-	 * @param datalink
-	 *            the datalink to disconnect
-	 * @return a datalink edit
-	 */
-	public Edit<Datalink> getDisconnectDatalinkEdit(Datalink datalink);
-
-	/**
-	 * Provides an edit that will configure the processors ports to map to those
-	 * of its internal Activity. If there is more than 1 activity then only
-	 * first activity is used. If there are zero then an EditException will be
-	 * thrown when using the Edit.
-	 * 
-	 * @param processor
-	 * @return
-	 */
-	public Edit<Processor> getMapProcessorPortsForActivityEdit(
-			Processor processor);
-
-	/**
-	 * Returns an edit to remove an Activity from a Processor
-	 */
-	public Edit<Processor> getRemoveActivityEdit(Processor processor,
-			Activity<?> activity);
-
-	/**
-	 * Returns an edit to remove an ActivityInputPort from an Activity.
-	 * 
-	 * @param activity
-	 *            activity to remove the port from
-	 * @param activityInputPort
-	 *            the port to remove from the activity
-	 * @return an edit to remove an ActivityInputPort from an Activity
-	 */
-	public Edit<Activity<?>> getRemoveActivityInputPortEdit(
-			Activity<?> activity, ActivityInputPort activityInputPort);
-
-	/**
-	 * Returns an edit to remove a ProcessorInputPort to ActivityInputPort
-	 * mapping from an Activity.
-	 * 
-	 * @param activity
-	 *            activity to remove the port mapping from
-	 * @param processorPortName
-	 *            the name of the processor port to remove from the mapping
-	 * @return an edit to remove a ProcessorInputPort to ActivityInputPort
-	 *         mapping from an Activity
-	 */
-	public Edit<Activity<?>> getRemoveActivityInputPortMappingEdit(
-			Activity<?> activity, String processorPortName);
-
-	/**
-	 * Returns an edit to remove an OutputPort from an Activity.
-	 * 
-	 * @param activity
-	 *            activity to remove the port from
-	 * @param activityOutputPort
-	 *            the port to remove from the activity
-	 * @return an edit to remove an OutputPort from an Activity
-	 */
-	public Edit<Activity<?>> getRemoveActivityOutputPortEdit(
-			Activity<?> activity, ActivityOutputPort activityOutputPort);
-
-	/**
-	 * Returns an edit to remove a ProcessorOutputPort to OutputPort mapping
-	 * from an Activity.
-	 * 
-	 * @param activity
-	 *            activity to remove the port mapping from
-	 * @param processorPortName
-	 *            the name of the processor port to remove from the mapping
-	 * @return an edit to remove a ProcessorOutputPort to OutputPort mapping
-	 *         from an Activity
-	 */
-	public Edit<Activity<?>> getRemoveActivityOutputPortMappingEdit(
-			Activity<?> activity, String processorPortName);
-
-	/**
-	 * Remove a condition previously applied to the specified pair of Processor
-	 * instances
-	 * 
-	 * @param control
-	 *            Processor controlling execution - this must complete before
-	 *            the target can start.
-	 * @param target
-	 *            Processor controlled by this condition.
-	 * @return
-	 */
-	public Edit<OrderedPair<Processor>> getRemoveConditionEdit(
-			Processor control, Processor target);
-
-	/**
-	 * Returns an edit to remove a DataflowInputPort from a Dataflow.
-	 * 
-	 * @param dataflow
-	 *            the Dataflow to remove this DataflowInputPort from
-	 * @param dataflowInputPort
-	 *            the DataflowInputPort to be removed from the Dataflow
-	 */
-	public Edit<Dataflow> getRemoveDataflowInputPortEdit(Dataflow dataflow,
-			DataflowInputPort dataflowInputPort);
-
-	/**
-	 * Returns an edit to remove a DataflowOutputPort from a Dataflow.
-	 * 
-	 * @param dataflow
-	 *            the Dataflow to remove this DataflowOutputPort from
-	 * @param dataflowOutputPort
-	 *            the DataflowOutputPort to be removed from the Dataflow
-	 */
-	public Edit<Dataflow> getRemoveDataflowOutputPortEdit(Dataflow dataflow,
-			DataflowOutputPort dataflowOutputPort);
-
-	/**
-	 * Returns an edit to remove a Processor from a Dataflow.
-	 * 
-	 * @param dataflow
-	 *            the dataflow to remove the processor from
-	 * @param processor
-	 *            the processor to be removed from the dataflow
-	 */
-	public Edit<Dataflow> getRemoveProcessorEdit(Dataflow dataflow,
-			Processor processor);
-
-	/**
-	 * Removes a Processor input port.
-	 * 
-	 * @param processor
-	 * @param port
-	 * @return
-	 */
-	public Edit<Processor> getRemoveProcessorInputPortEdit(Processor processor,
-			ProcessorInputPort port);
-
-	/**
-	 * @param processor
-	 * @param port
-	 * @return
-	 */
-	public Edit<Processor> getRemoveProcessorOutputPortEdit(
-			Processor processor, ProcessorOutputPort port);
-
-	/**
-	 * Removes a merge from the dataflow.
-	 * 
-	 * @param dataflow
-	 * @param processor
-	 * @return
-	 */
-	public Edit<Dataflow> getRemoveMergeEdit(Dataflow dataflow, Merge merge);
-
-	/**
-	 * Rename a dataflow input port
-	 * 
-	 * @param dataflowInputPort
-	 *            the dataflow input port to rename
-	 * @param newName
-	 *            the new name, must be unique within the workflow enclosing the
-	 *            dataflow input port instance
-	 */
-	public Edit<DataflowInputPort> getRenameDataflowInputPortEdit(
-			DataflowInputPort dataflowInputPort, String newName);
-
-	/**
-	 * Rename a dataflow output port
-	 * 
-	 * @param dataflowOutputPort
-	 *            the dataflow output port to rename
-	 * @param newName
-	 *            the new name, must be unique within the workflow enclosing the
-	 *            dataflow output port instance
-	 */
-	public Edit<DataflowOutputPort> getRenameDataflowOutputPortEdit(
-			DataflowOutputPort dataflowOutputPort, String newName);
-
-	/**
-	 * Rename a processor
-	 * 
-	 * @param processor
-	 *            the processor to rename
-	 * @param newName
-	 *            the new name, must be unique within the workflow enclosing the
-	 *            processor instance
-	 */
-	public Edit<Processor> getRenameProcessorEdit(Processor processor,
-			String newName);
-
-	/**
-	 * Rename a merge
-	 * 
-	 * @param merge
-	 *            the merge to rename
-	 * @param newName
-	 *            the new name, must be unique within the workflow enclosing the
-	 *            merge instance
-	 */
-	public Edit<Merge> getRenameMergeEdit(Merge merge, String newName);
-
-	/**
-	 * Provide an edit that will configure a processors's iteration strategy
-	 * stack to the one provided.
-	 * 
-	 * @param processor
-	 *            Processor which iteration stack is to be set
-	 * @param iterationStrategyStack
-	 *            The new iteration strategy stack
-	 * @return An Edit that will set the iteration strategy stack of a processor
-	 */
-	public Edit<Processor> getSetIterationStrategyStackEdit(
-			Processor processor, IterationStrategyStack iterationStrategyStack);
-
-	public Edit<IterationStrategyStack> getClearIterationStrategyStackEdit(
-			IterationStrategyStack iterationStrategyStack);
-
-	public Edit<IterationStrategyStack> getAddIterationStrategyEdit(
-			IterationStrategyStack iterationStrategyStack,
-			IterationStrategy iterationStrategy);
-
-	public Edit<IterationStrategy> getAddIterationStrategyInputNodeEdit(
-			IterationStrategy iterationStrategy,
-			NamedInputPortNode namedInputPortNode);
-
-	public Edit<Dataflow> getUpdateDataflowInternalIdentifierEdit(
-			Dataflow dataflow, String newId);
-
-	public Edit<Dataflow> getUpdateDataflowNameEdit(Dataflow dataflow,
-			String newName);
-
-	/**
-	 * Builds an instance of an {@link InputPort} for an Activity.
-	 * 
-	 * @param portName
-	 * @param portDepth
-	 * @param allowsLiteralValues
-	 *            whether the input port can cope with literal values
-	 * @param handledReferenceSchemes
-	 *            a list of the reference scheme types that can be legitimately
-	 *            pushed into this input port
-	 * @param translatedElementClass
-	 *            the class desired as result (or elements of collections of
-	 *            results) when interpreted by the data facade
-	 * @return an instance of InputPort
-	 */
-	ActivityInputPort createActivityInputPort(
-			String portName,
-			int portDepth,
-			boolean allowsLiteralValues,
-			List<Class<? extends ExternalReferenceSPI>> handledReferenceSchemes,
-			Class<?> translatedElementClass);
-
-	/**
-	 * Builds an instance of an {@link ActivityOutputPort} for an Activity.
-	 * 
-	 * @param portName
-	 * @param portDepth
-	 * @param portGranularDepth
-	 * @return an instance of ActivityOutputPort
-	 */
-	ActivityOutputPort createActivityOutputPort(String portName, int portDepth,
-			int portGranularDepth);
-
-	/**
-	 * Creates a new ProcessorInputPort
-	 * 
-	 * @param processor
-	 *            the processor to with the port will be added
-	 * @param name
-	 * @param depth
-	 * @return
-	 */
-	ProcessorInputPort createProcessorInputPort(Processor processor,
-			String name, int depth);
-
-	/**
-	 * Creates a new ProcessorOutputPort
-	 * 
-	 * @param processor
-	 * @param name
-	 * @param depth
-	 * @param granularDepth
-	 * @return
-	 */
-	ProcessorOutputPort createProcessorOutputPort(Processor processor,
-			String name, int depth, int granularDepth);
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/EventForwardingOutputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/EventForwardingOutputPort.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/EventForwardingOutputPort.java
deleted file mode 100644
index cf483c1..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/EventForwardingOutputPort.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-import java.util.Set;
-
-/**
- * An extension of OutputPort defining a set of target EventReceivingInputPorts
- * to which internally generated events will be relayed. This is the interface
- * used by output ports on a workflow entity with internal logic generating or
- * relaying events.
- * 
- * @author Tom Oinn
- */
-public interface EventForwardingOutputPort extends OutputPort {
-	/**
-	 * The set of EventHandlingInputPort objects which act as targets for events
-	 * produced from this OutputPort
-	 * 
-	
-	public Set<EventHandlingInputPort> getTargets();
-*/ //FIXME What is happening here???
-
-	/**
-	 * The set of datalinks for which this output port is the source of events
-	 */
-	Set<? extends Datalink> getOutgoingLinks();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/EventHandlingInputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/EventHandlingInputPort.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/EventHandlingInputPort.java
deleted file mode 100644
index 51e31d4..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/EventHandlingInputPort.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-import net.sf.taverna.t2.invocation.WorkflowDataToken;
-
-/**
- * Input port capable of receiving and reacting to workflow events.
- * 
- * @author Tom Oinn
- */
-public interface EventHandlingInputPort extends InputPort {
-	/**
-	 * Receive an arbitrary workflow event.
-	 */
-	void receiveEvent(WorkflowDataToken t);
-
-	/**
-	 * If this port is connected to a Datalink return the link, otherwise return
-	 * null
-	 */
-	Datalink getIncomingLink();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/FailureTransmitter.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/FailureTransmitter.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/FailureTransmitter.java
deleted file mode 100644
index 39e222b..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/FailureTransmitter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-/**
- * Used to message interested parties when a top level failure occurs within a
- * {@link Dataflow}
- * <p>
- * Not implemented in the current code, this is a placeholder for the failure
- * handling system.
- * 
- * @author Tom Oinn
- */
-public interface FailureTransmitter {
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/FilteringInputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/FilteringInputPort.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/FilteringInputPort.java
deleted file mode 100644
index 0c57b17..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/FilteringInputPort.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-/**
- * A filtering input port is one capable of filtering events to only pass
- * through data events at a certain depth. Other events are either ignored (in
- * the case of finer granularity) or converted to completion events (for
- * coarser). Where the filter depth and the port depth are distinct this port
- * type will filter on the filter depth then drill into the data to get down to
- * the port depth. Filter depth must always be equal to or greater than port
- * depth.
- * <p>
- * This is used as the interface for Processor input ports.
- * <p>
- * A condition to use this type is that the stream of events for a given process
- * ID must terminate with a top level (i.e. zero length index array) token. This
- * can be accomplished by use of the crystalizer (as found on the output of a
- * Processor instance) or some other mechanism but is required. Similarly it is
- * assumed that all intermediate collections are emited in the correct sequence,
- * if this is not the case the filtering may not function correctly.
- * 
- * @author Tom Oinn
- */
-public interface FilteringInputPort extends EventHandlingInputPort {
-	/**
-	 * Set the depth at which to filter events. Events at a lower depth than
-	 * this are ignored completely, those at exactly this depth are passed
-	 * through intact and those above are converted to completion events.
-	 * 
-	 * @param filterDepth
-	 */
-	int getFilterDepth();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/InputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/InputPort.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/InputPort.java
deleted file mode 100644
index 6ecd056..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/InputPort.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-/**
- * Marker interface denoting that the instance is an input port.
- * 
- * @author Tom Oinn
- */
-public interface InputPort extends Port {
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/InvalidDataflowException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/InvalidDataflowException.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/InvalidDataflowException.java
deleted file mode 100644
index 50258d4..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/InvalidDataflowException.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-/**
- * Thrown if attempting to use a workflow that is not
- * {@link Dataflow#checkValidity() valid}.
- * <p>
- * The {@link DataflowValidationReport} can be retrieved using
- * {@link #getDataflowValidationReport()} and will provide details on how the
- * dataflow is invalid. The {@link #getDataflow()} will provide the invalid
- * dataflow.
- * 
- * @author Stian Soiland-Reyes
- */
-public class InvalidDataflowException extends Exception {
-	private static final long serialVersionUID = -8470683930687738369L;
-	private final DataflowValidationReport report;
-	private final Dataflow dataflow;
-
-	public InvalidDataflowException(Dataflow dataflow,
-			DataflowValidationReport report) {
-		this.report = report;
-		this.dataflow = dataflow;
-	}
-
-	/**
-	 * Get the {@link DataflowValidationReport validation report} for the
-	 * failing dataflow.
-	 * 
-	 * @return Dataflow validation report
-	 */
-	public DataflowValidationReport getDataflowValidationReport() {
-		return report;
-	}
-
-	/**
-	 * Get the {@link Dataflow} that is not valid.
-	 * 
-	 * @return Invalid Dataflow
-	 */
-	public Dataflow getDataflow() {
-		return dataflow;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Merge.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Merge.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Merge.java
deleted file mode 100644
index 706e69b..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Merge.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-import java.util.List;
-
-/**
- * Allows multiple outputs to be routed to a single input within the dataflow.
- * The merge operation defines a total order over its input ports, this order is
- * used to modify the index array of all incoming events by adding the port
- * index as a prefix to that array. At a conceptual level this means that any
- * event coming in is 'binned' by port index creating a collection of whatever
- * the port type was. This also places a constraint that all input ports must
- * have the same cardinality (i.e. depth + length of index array must be equal
- * for all events on all ports). If this constraint is violated the merge
- * operation is free to throw a WorkflowStructureException at runtime although
- * it would be preferable if implementing classes were capable of static type
- * analysis to preclude this from happening.
- * 
- * @author Tom Oinn
- */
-public interface Merge extends TokenProcessingEntity {
-	/**
-	 * The Merge object contains an ordered list of InputPort objects. Data and
-	 * completion events arriving at an input port have the index of that input
-	 * within the list prepended to their index array, effectively placing them
-	 * in a virtual collection the top level of which corresponds to the various
-	 * input ports defined within the Merge node. When final completion events
-	 * from all input ports are received the Merge object registers the top
-	 * level collection with the attached DataManager and emits it and the
-	 * completion event through the single output port.
-	 * 
-	 * @return Ordered list of InputPort objects
-	 */
-	@Override
-	List<? extends MergeInputPort> getInputPorts();
-
-	/**
-	 * The Merge object has a single output port through which modified events
-	 * are emitted as described in the javadoc for getInputPorts
-	 * 
-	 * @return OutputPort for this Merge object
-	 */
-	EventForwardingOutputPort getOutputPort();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/MergeInputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/MergeInputPort.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/MergeInputPort.java
deleted file mode 100644
index 3468301..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/MergeInputPort.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007-2009 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-import net.sf.taverna.t2.invocation.WorkflowDataToken;
-
-/**
- * Input port on a Merge object
- * 
- * @author Tom Oinn
- * @author Stian Soiland-Reyes
- */
-public interface MergeInputPort extends EventHandlingInputPort, MergePort {
-	/**
-	 * Receive an arbitrary workflow event. The index of this port relative to
-	 * its parent Merge object is prepended to the event index and the event
-	 * forwarded through the Merge output port to any targets.
-	 * <p>
-	 * If this is a workflow data token and the first such received under a
-	 * given owning process ID the implementing method also must also store the
-	 * cardinality, i.e. length of index array + depth of token. Subsequent
-	 * events are matched to this, if they have unequal cardinality the parent
-	 * Merge operation will throw a WorkflowStructureException as the merge
-	 * would result in a collection which violated the constraints defined by
-	 * the Taverna 2 data model.
-	 * 
-	 * @param e
-	 *            arbitrary workflow event, will be forwarded unchanged other
-	 *            than an alteration of the index array by prefixing the index
-	 *            of this input port relative to the parent Merge object
-	 */
-	@Override
-	public void receiveEvent(WorkflowDataToken t);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/MergeOutputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/MergeOutputPort.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/MergeOutputPort.java
deleted file mode 100644
index c43e869..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/MergeOutputPort.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007-2009 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-/**
- * An EventForwardingOutputPort that is associated with Merge instances.
- * In particular it provides access to the Merge instance it is associated with.
- * 
- * @see Merge
- * @see MergePort
- * @see EventForwardingOutputPort
- * 
- * @author Stuart Owen
- * @author Stian Soiland-Reyes
- */
-public interface MergeOutputPort extends EventForwardingOutputPort, MergePort {
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/MergePort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/MergePort.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/MergePort.java
deleted file mode 100644
index 0fb88f3..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/MergePort.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-/**
- * An input or output {@link Port} for a {@link Merge}.
- * 
- * @see MergeInputPort
- * @see MergeOutputPort
- * @author Stian Soiland-Reyes
- */
-public interface MergePort extends Port {
-	/**
-	 * @return the Merge instance the port is associated with. 
-	 */
-	Merge getMerge();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/NamedWorkflowEntity.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/NamedWorkflowEntity.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/NamedWorkflowEntity.java
deleted file mode 100644
index 854685d..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/NamedWorkflowEntity.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-/**
- * Entities existing directly within a workflow such as Processors, Merge
- * operators and other potential future extensions exist within a naming scheme.
- * The local name of an entity is unique relative to the enclosing workflow.
- * Global names are not defined outside of the context of a given instance of a
- * workflow as the same workflow may be re-used in multiple other workflows,
- * there is therefore no single parent defined for some entities and the
- * approach of traversing the hierarchy to build a fully qualified name cannot
- * be applied. A given instance can be treated this way but this depends on
- * dataflow rather than inherent workflow structure.
- * <p>
- * All named workflow entities support the sticky note annotation type
- * 
- * @author Tom Oinn
- */
-public interface NamedWorkflowEntity extends WorkflowItem {
-	/**
-	 * Every workflow level entity has a name which is unique within the
-	 * workflow in which it exists. This only applies to the immediate parent
-	 * workflow, names may be duplicated in child workflows etc.
-	 */
-	String getLocalName();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/NamingException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/NamingException.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/NamingException.java
deleted file mode 100644
index 2ce2f33..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/NamingException.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-/**
- * Potentially thrown when an edit fails due to naming of entities created or
- * modified by the edit. This could be because there are duplicate names in e.g.
- * processor input ports or invalid characters in the name itself
- * 
- * @author Tom Oinn
- * 
- */
-public class NamingException extends EditException {
-
-	private static final long serialVersionUID = -6945542133180017313L;
-
-	public NamingException(String message) {
-		super(message);
-	}
-
-	public NamingException(Throwable cause) {
-		super(cause);
-	}
-
-	public NamingException(String message, Throwable cause) {
-		super(message, cause);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/OrderedPair.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/OrderedPair.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/OrderedPair.java
deleted file mode 100644
index fa8cc6a..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/OrderedPair.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-/**
- * A simple generic class to hold a pair of same type objects. Used by various
- * Edit implementations that operate on pairs of Processors amongst other
- * things.
- * 
- * @author Tom Oinn
- * 
- * @param <T>
- *            Type of the pair of contained objects
- */
-public class OrderedPair<T> {
-	private T a, b;
-
-	/**
-	 * Build a new ordered pair with the specified objects.
-	 * 
-	 * @throws RuntimeException
-	 *             if either a or b are null
-	 * @param a
-	 * @param b
-	 */
-	public OrderedPair(T a, T b) {
-		if (a == null || b == null)
-			throw new RuntimeException(
-					"Cannot construct ordered pair with null arguments");
-		this.a = a;
-		this.b = b;
-	}
-
-	/**
-	 * Return object a
-	 */
-	public T getA() {
-		return this.a;
-	}
-
-	/**
-	 * Return object b
-	 */
-	public T getB() {
-		return this.b;
-	}
-
-	/**
-	 * A pair of objects (a,b) is equal to another pair (c,d) if and only if a,
-	 * b, c and d are all the same type and the condition (a.equals(c) &
-	 * b.equals(d)) is true.
-	 */
-	@Override
-	public boolean equals(Object other) {
-		if (!(other instanceof OrderedPair))
-			return false;
-		OrderedPair<?> op = (OrderedPair<?>) other;
-		return (a.equals(op.getA()) && b.equals(op.getB()));
-	}
-
-	@Override
-	public int hashCode() {
-		int aHash = a.hashCode();
-		int bHash = b.hashCode();
-		return (aHash << 16) | (aHash >> 16) | bHash;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/OutputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/OutputPort.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/OutputPort.java
deleted file mode 100644
index acd5f5c..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/OutputPort.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-/**
- * Port representing the output of an activity, processor or workflow. In
- * addition to the name and port depth defined by the Port interface this
- * includes a granular depth property. The granular depth of an output is the
- * depth of the finest grained entity that can be emitted from that port. For
- * example, if a process conceptually returned a list of strings but was
- * actually capable of streaming strings as they were generated it would set a
- * port depth of 1 and granular depth of zero.
- * 
- * @author Tom Oinn
- */
-public interface OutputPort extends Port {
-	/**
-	 * The granular depth is the depth of the finest grained item that can be
-	 * emitted from this output port. A difference in this and the port depth
-	 * indicates that the entity this port is attached to is capable of
-	 * streaming data resulting from a single process invocation. The port depth
-	 * defines the conceptual depth, so a process returning a stream of single
-	 * items would set port depth to 1 and granular depth to zero.
-	 * 
-	 * @return granular depth of output port
-	 */
-	int getGranularDepth();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Port.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Port.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Port.java
deleted file mode 100644
index b6b53b4..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Port.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-import net.sf.taverna.t2.annotation.Annotated;
-
-/**
- * Named port which receives events from some other entity and handles them
- * appropriately.
- * 
- * @author Tom Oinn
- */
-public interface Port extends Annotated<Port>, WorkflowItem {
-	String getName();
-
-	int getDepth();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Processor.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Processor.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Processor.java
deleted file mode 100644
index 703e100..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/Processor.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-import static net.sf.taverna.t2.annotation.HierarchyRole.CHILD;
-
-import java.util.List;
-
-import net.sf.taverna.t2.annotation.Annotated;
-import net.sf.taverna.t2.annotation.HierarchyTraversal;
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchStack;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.IterationStrategyStack;
-
-/**
- * A single node within the dataflow digraph, the Processor is the basic
- * functional unit within a Taverna workflow. It should also notify interested
- * observers when it has finished execution (including all iterations of the
- * processor).
- * 
- * @author Tom Oinn
- * @author Alex Nenadic
- */
-@ControlBoundary
-public interface Processor extends TokenProcessingEntity, Annotated<Processor>,
-		Observable<ProcessorFinishedEvent>, WorkflowItem {
-	/**
-	 * The iteration strategy is responsible for combining input data events
-	 * into jobs which are then queued for execution through the dispatch stack
-	 * 
-	 * @return IterationStrategyStack containing one or more IterationStrategy
-	 *         objects. In most cases this will only contain a single
-	 *         IterationStrategy but there are particular scenarios where
-	 *         staging partial iteration strategies together is the only way to
-	 *         get the desired combination of inputs
-	 */
-	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
-	IterationStrategyStack getIterationStrategy();
-
-	/**
-	 * Each processor has a list of zero or more input ports. These are uniquely
-	 * named within the list. Any input port may have a default value associated
-	 * with it and may be attached to exactly one upstream output port. Where it
-	 * is necessary to connect a single input port to multiple output ports a
-	 * Merge object is used. Ordering within the list is not meaningful but we
-	 * use List rather than Set to preserve the ordering across serialisation
-	 * operations.
-	 * <p>
-	 * Processor inputs are instances of FilteringInputPort - they must have the
-	 * filter depth set before any data events arrive at the Processor. In
-	 * addition they assume that a full collection will be supplied, i.e. that
-	 * there will be exactly one event at the end of the list of events for a
-	 * given process ID with an index array of length zero.
-	 * 
-	 * @return List of named input ports
-	 */
-	@Override
-	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
-	List<? extends ProcessorInputPort> getInputPorts();
-
-	/**
-	 * Each processor has a list of zero or more output ports. Output ports are
-	 * uniquely named within the list and may be connected to arbitrarily many
-	 * downstream input ports or Merge objects. Ordering within the list is not
-	 * meaningful but we use List rather than Set to preserve the ordering
-	 * across serialisation operations.
-	 * 
-	 * @return List of named output ports
-	 */
-	@Override
-	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
-	List<? extends ProcessorOutputPort> getOutputPorts();
-
-	/**
-	 * The dispatch stack pulls jobs from the queue generated by the iteration
-	 * system and handles the dispatch of these jobs to appropriate activity
-	 * workers
-	 * 
-	 * @return the DispatchStackImpl for this processor
-	 */
-	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
-	DispatchStack getDispatchStack();
-
-	/**
-	 * A processor contains zero or more activities in an ordered list. To be
-	 * any use in a workflow the processor should contain at least one activity
-	 * but it's technically valid to have none! Activities may be abstract or
-	 * concrete where an abstract activity is one with no invocation mechanism,
-	 * in these cases additional logic must be added to the dispatch stack of
-	 * the containing processor to convert these to concrete invokable
-	 * activities during the workflow invocation.
-	 * 
-	 * @return list of Activity instances
-	 */
-	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
-	List<? extends Activity<?>> getActivityList();
-
-	/**
-	 * A processor with no inputs cannot be driven by the supply of data tokens
-	 * as it has nowhere to receive such tokens. This method allows a processor
-	 * to fire on an empty input set, in this case the owning process identifier
-	 * must be passed explicitly to the processor. Internally this pushes a
-	 * single empty job event into the dispatch queue, bypassing the iteration
-	 * logic (which is entirely predicated on the existence of input ports).
-	 * Callers must ensure that an appropriate process identifier is specified,
-	 * the behaviour on missing or duplicate process identifiers is not defined.
-	 */
-	void fire(String owningProcess, InvocationContext context);
-
-	/**
-	 * A processor has zero or more preconditions explicitly declared. All such
-	 * preconditions must be satisfied before any jobs are passed into the
-	 * dispatch stack. These preconditions replace and generalise the
-	 * coordination constraints from Taverna 1.
-	 * 
-	 * @return a List of Condition objects defining constraints on this
-	 *         processor's execution
-	 */
-	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
-	List<? extends Condition> getPreconditionList();
-
-	/**
-	 * A processor may control zero or more other processors within the same
-	 * level of the workflow through preconditions.
-	 * 
-	 * @return a List of Condition objects for which this is the controlling
-	 *         processor
-	 */
-	List<? extends Condition> getControlledPreconditionList();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ProcessorFinishedEvent.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ProcessorFinishedEvent.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ProcessorFinishedEvent.java
deleted file mode 100644
index 1aa6e9b..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ProcessorFinishedEvent.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package net.sf.taverna.t2.workflowmodel;
-
-/**
- * 
- * An event saying that a processor with a given owning process has finished with execution
- * (that includes the whole dispatch stack - iterations of the processor and all).
- * 
- * @author Alex Nenadic
- */
-public class ProcessorFinishedEvent {
-	private Processor processor;
-	private String owningProcess;
-	
-	public ProcessorFinishedEvent(Processor processor, String owningProcess) {
-		this.setProcessor(processor);
-		this.setOwningProcess(owningProcess);
-	}
-
-	public void setOwningProcess(String owningProcess) {
-		this.owningProcess = owningProcess;
-	}
-
-	public String getOwningProcess() {
-		return owningProcess;
-	}
-
-	public void setProcessor(Processor processor) {
-		this.processor = processor;
-	}
-
-	public Processor getProcessor() {
-		return processor;
-	}
-}


[48/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/ExecutionService.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/ExecutionService.java b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/ExecutionService.java
new file mode 100755
index 0000000..f0c58b3
--- /dev/null
+++ b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/ExecutionService.java
@@ -0,0 +1,148 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.api;
+
+import java.util.Set;
+
+import org.apache.taverna.robundle.Bundle;
+
+import org.apache.taverna.platform.report.WorkflowReport;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+/**
+ * Service for executing Taverna workflows. There may be several <code>ExecutionService</code>s
+ * available that offer different execution environments, e.g. one <code>ExecutionService</code> may
+ * execute workflows on a remote server while another executes workflows on the local machine.
+ *
+ * @author David Withers
+ */
+public interface ExecutionService {
+
+	/**
+	 * Returns the identifier for this ExecutionService.
+	 *
+	 * @return the identifier for this ExecutionService
+	 */
+	public String getID();
+
+	/**
+	 * Returns the name of this ExecutionService.
+	 *
+	 * @return the name of this ExecutionService
+	 */
+	public String getName();
+
+	/**
+	 * Returns a description of this ExecutionService.
+	 *
+	 * @return a description of this ExecutionService
+	 */
+	public String getDescription();
+
+	/**
+	 * Returns the ExecutionEnvironments available for this ExecutionService.
+	 *
+	 * @return the ExecutionEnvironments available for this ExecutionService
+	 */
+	public Set<ExecutionEnvironment> getExecutionEnvironments();
+
+	/**
+	 * Creates a workflow execution and returns its ID.
+	 *
+	 * @param executionEnvironment
+	 *            the {@link ExecutionEnvironment} used to execute the
+	 *            <code>Workflow</code>
+	 * @param workflowBundle
+	 *            the <code>WorkflowBundle</code> containing the workflows required for execution
+	 * @param workflow
+	 *            the workflow to execute
+	 * @param profile
+	 *            the profile to use when executing the workflow
+	 * @param dataBundle
+	 *            the <code>Bundle</code> containing the data values for the <code>Workflow</code>
+	 * @return the ID of the created workflow execution
+	 * @throws InvalidWorkflowException
+	 */
+	public String createExecution(ExecutionEnvironment executionEnvironment, WorkflowBundle workflowBundle, Workflow workflow, Profile profile,
+			Bundle dataBundle)
+			throws InvalidWorkflowException;
+
+	/**
+	 * Returns the workflow report for the specified execution.
+	 *
+	 * @param executionID
+	 *            the ID of the execution
+	 * @return the workflow report for this execution
+	 */
+	public WorkflowReport getWorkflowReport(String executionID) throws InvalidExecutionIdException;
+
+	/**
+	 * Deletes the execution of a workflow.
+	 *
+	 * @param executionID
+	 *            the ID of the execution to delete
+	 * @throws InvalidExecutionIdException
+	 *             if the execution ID is not valid
+	 */
+	public void delete(String executionID) throws InvalidExecutionIdException;
+
+	/**
+	 * Starts the execution of a workflow.
+	 *
+	 * @param executionID
+	 *            the ID of the execution to start
+	 * @throws InvalidExecutionIdException
+	 *             if the execution ID is not valid
+	 */
+	public void start(String executionID) throws InvalidExecutionIdException;
+
+	/**
+	 * Pauses the execution of a workflow.
+	 *
+	 * @param executionID
+	 *            the ID of the execution to pause
+	 * @throws InvalidExecutionIdException
+	 *             if the execution ID is not valid
+	 */
+	public void pause(String executionID) throws InvalidExecutionIdException;
+
+	/**
+	 * Resumes the execution of a paused workflow.
+	 *
+	 * @param executionID
+	 *            the ID of the execution to resume
+	 * @throws InvalidExecutionIdException
+	 *             if the execution ID is not valid
+	 */
+	public void resume(String executionID) throws InvalidExecutionIdException;
+
+	/**
+	 * Cancels the execution of a workflow.
+	 *
+	 * @param executionID
+	 *            the ID of the execution to cancel
+	 * @throws InvalidExecutionIdException
+	 *             if the execution ID is not valid
+	 */
+	public void cancel(String executionID) throws InvalidExecutionIdException;
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/InvalidExecutionIdException.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/InvalidExecutionIdException.java b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/InvalidExecutionIdException.java
new file mode 100644
index 0000000..09e2a57
--- /dev/null
+++ b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/InvalidExecutionIdException.java
@@ -0,0 +1,47 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.api;
+
+/**
+ * Thrown when an executionID is not valid for an ExecutionService.
+ * 
+ * @author David Withers
+ */
+public class InvalidExecutionIdException extends Exception {
+
+	private static final long serialVersionUID = 4086661335641172903L;
+
+	public InvalidExecutionIdException() {
+    	super();
+    }
+
+    public InvalidExecutionIdException(String message) {
+    	super(message);
+    }
+
+    public InvalidExecutionIdException(String message, Throwable cause) {
+    	super(message, cause);
+    }
+
+    public InvalidExecutionIdException(Throwable cause) {
+    	super(cause);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/InvalidWorkflowException.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/InvalidWorkflowException.java b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/InvalidWorkflowException.java
new file mode 100644
index 0000000..6b74bae
--- /dev/null
+++ b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/InvalidWorkflowException.java
@@ -0,0 +1,47 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.api;
+
+/**
+ * Thrown when a Workflow fails to validate.
+ * 
+ * @author David Withers
+ */
+public class InvalidWorkflowException extends Exception {
+
+	private static final long serialVersionUID = 7491175798204912590L;
+
+	public InvalidWorkflowException() {
+		super();
+	}
+
+	public InvalidWorkflowException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+	public InvalidWorkflowException(String message) {
+		super(message);
+	}
+
+	public InvalidWorkflowException(Throwable cause) {
+		super(cause);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/WorkflowCompiler.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/WorkflowCompiler.java b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/WorkflowCompiler.java
new file mode 100644
index 0000000..e63c49a
--- /dev/null
+++ b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/WorkflowCompiler.java
@@ -0,0 +1,55 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.api;
+
+import org.apache.taverna.workflowmodel.Dataflow;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.Workflow;
+
+/**
+ * A workflow compilation service converts a workflow (in a
+ * {@link WorkflowBundle}) into a dataflow. Most code should ignore this.
+ * 
+ * @author Donal Fellows
+ */
+public interface WorkflowCompiler {
+	/**
+	 * Convert a workflow into a dataflow. May cache.
+	 * 
+	 * @param workflow
+	 *            the workflow to convert; must not be <tt>null</tt>
+	 * @return the dataflow, which should not be modified.
+	 * @throws InvalidWorkflowException
+	 *             If the compilation fails.
+	 */
+	Dataflow getDataflow(Workflow workflow) throws InvalidWorkflowException;
+	
+	/**
+	 * Convert a workflow bundle into a dataflow. May cache. Only the the
+	 * primary workflow is guaranteed to be converted.
+	 * 
+	 * @param bundle
+	 *            the workflow bundle to convert; must not be <tt>null</tt>
+	 * @return the dataflow, which should not be modified.
+	 * @throws InvalidWorkflowException
+	 *             If the compilation fails.
+	 */
+	Dataflow getDataflow(WorkflowBundle bundle) throws InvalidWorkflowException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecution.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecution.java b/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecution.java
deleted file mode 100644
index 5688460..0000000
--- a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecution.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.api;
-
-import java.util.UUID;
-
-import org.apache.taverna.robundle.Bundle;
-
-import uk.org.taverna.platform.report.ActivityReport;
-import uk.org.taverna.platform.report.ProcessorReport;
-import uk.org.taverna.platform.report.WorkflowReport;
-import org.apache.taverna.scufl2.api.activity.Activity;
-import org.apache.taverna.scufl2.api.common.Scufl2Tools;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Processor;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.profiles.ProcessorBinding;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/**
- * Abstract implementation of an {@link Execution}.
- *
- * @author David Withers
- */
-public abstract class AbstractExecution implements Execution {
-
-	private final String ID;
-	private final WorkflowBundle workflowBundle;
-	private final Bundle dataBundle;
-	private final Workflow workflow;
-	private final Profile profile;
-	private final WorkflowReport workflowReport;
-
-	private final Scufl2Tools scufl2Tools = new Scufl2Tools();
-
-	/**
-	 * Constructs an abstract implementation of an Execution.
-	 *
-	 * @param workflowBundle
-	 *            the <code>WorkflowBundle</code> containing the <code>Workflow</code>s required for
-	 *            execution
-	 * @param workflow
-	 *            the <code>Workflow</code> to execute
-	 * @param profile
-	 *            the <code>Profile</code> to use when executing the <code>Workflow</code>
-	 * @param dataBundle
-	 *            the <code>Bundle</code> containing the data values for the <code>Workflow</code>
-	 * @throws InvalidWorkflowException
-	 *             if the specified workflow is invalid
-	 */
-	public AbstractExecution(WorkflowBundle workflowBundle, Workflow workflow, Profile profile,
-			Bundle dataBundle) {
-		this.workflowBundle = workflowBundle;
-		this.workflow = workflow;
-		this.profile = profile;
-		this.dataBundle = dataBundle;
-		ID = UUID.randomUUID().toString();
-		workflowReport = generateWorkflowReport(workflow);
-	}
-
-	protected abstract WorkflowReport createWorkflowReport(Workflow workflow);
-
-	protected abstract ProcessorReport createProcessorReport(Processor processor);
-
-	protected abstract ActivityReport createActivityReport(Activity activity);
-
-	public WorkflowReport generateWorkflowReport(Workflow workflow) {
-		WorkflowReport workflowReport = createWorkflowReport(workflow);
-		for (Processor processor : workflow.getProcessors()) {
-			ProcessorReport processorReport = createProcessorReport(processor);
-			processorReport.setParentReport(workflowReport);
-			workflowReport.addProcessorReport(processorReport);
-			for (ProcessorBinding processorBinding : scufl2Tools.processorBindingsForProcessor(
-					processor, profile)) {
-				Activity boundActivity = processorBinding.getBoundActivity();
-				ActivityReport activityReport = createActivityReport(boundActivity);
-				activityReport.setParentReport(processorReport);
-				if (scufl2Tools.containsNestedWorkflow(processor, profile)) {
-					Workflow nestedWorkflow = scufl2Tools.nestedWorkflowForProcessor(processor,
-							profile);
-					WorkflowReport nestedWorkflowReport = generateWorkflowReport(nestedWorkflow);
-					nestedWorkflowReport.setParentReport(activityReport);
-					activityReport.setNestedWorkflowReport(nestedWorkflowReport);
-				}
-				processorReport.addActivityReport(activityReport);
-			}
-		}
-		return workflowReport;
-	}
-
-	@Override
-	public String getID() {
-		return ID;
-	}
-
-	@Override
-	public WorkflowBundle getWorkflowBundle() {
-		return workflowBundle;
-	}
-
-	@Override
-	public Bundle getDataBundle() {
-		return dataBundle;
-	}
-
-	@Override
-	public Workflow getWorkflow() {
-		return workflow;
-	}
-
-	@Override
-	public Profile getProfile() {
-		return profile;
-	}
-
-	@Override
-	public WorkflowReport getWorkflowReport() {
-		return workflowReport;
-	}
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecutionEnvironment.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecutionEnvironment.java b/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecutionEnvironment.java
deleted file mode 100644
index a6475e5..0000000
--- a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecutionEnvironment.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.api;
-
-import java.net.URI;
-
-/**
- * A common super type for concrete implementations of <code>ExecutionEnvironment</code>s.
- *
- * @author David Withers
- */
-public abstract class AbstractExecutionEnvironment implements ExecutionEnvironment {
-	private final String ID;
-	private final String name;
-	private final String description;
-	private final ExecutionService executionService;
-
-	public AbstractExecutionEnvironment(String ID, String name, String description,
-			ExecutionService executionService) {
-		this.ID = ID;
-		this.name = name;
-		this.description = description;
-		this.executionService = executionService;
-	}
-
-	@Override
-	public String getID() {
-		return ID;
-	}
-
-	@Override
-	public String getName() {
-		return name;
-	}
-
-	@Override
-	public String getDescription() {
-		return description;
-	}
-
-	@Override
-	public ExecutionService getExecutionService() {
-		return executionService;
-	}
-
-	@Override
-	public String toString() {
-		StringBuilder sb = new StringBuilder();
-		sb.append(ID + "\n");
-		sb.append(name + "\n");
-		sb.append(description + "\n");
-		sb.append("Activities : \n");
-		for (URI uri : getActivityTypes())
-			sb.append("  " + uri + "\n");
-		sb.append("Dispatch Layers : \n");
-		for (URI uri : getDispatchLayerTypes())
-			sb.append("  " + uri + "\n");
-		return sb.toString();
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecutionService.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecutionService.java b/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecutionService.java
deleted file mode 100755
index 18b5a09..0000000
--- a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecutionService.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.api;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.taverna.robundle.Bundle;
-
-import uk.org.taverna.platform.report.WorkflowReport;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/**
- * A common super type for concrete implementations of <code>ExecutionService</code>s.
- *
- * @author David Withers
- */
-public abstract class AbstractExecutionService implements ExecutionService {
-	private final String ID;
-	private final String name;
-	private final String description;
-	private final Map<String, Execution> executionMap;
-
-	public AbstractExecutionService(String ID, String name, String description) {
-		this.ID = ID;
-		this.name = name;
-		this.description = description;
-		executionMap = Collections.synchronizedMap(new HashMap<String, Execution>());
-	}
-
-	@Override
-	public String getID() {
-		return ID;
-	}
-
-	@Override
-	public String getName() {
-		return name;
-	}
-
-	@Override
-	public String getDescription() {
-		return description;
-	}
-
-	@Override
-	public String createExecution(ExecutionEnvironment executionEnvironment,
-			WorkflowBundle workflowBundle, Workflow workflow, Profile profile,
-			Bundle dataBundle) throws InvalidWorkflowException {
-		Execution execution = createExecutionImpl(workflowBundle, workflow, profile, dataBundle);
-		executionMap.put(execution.getID(), execution);
-		return execution.getID();
-	}
-
-	/**
-	 * Creates an implementation of an Execution.
-	 *
-	 * To be implemented by concrete implementations of <code>ExecutionService</code>.
-	 *
-	 * @param workflowBundle
-	 *            the <code>WorkflowBundle</code> containing the <code>Workflow</code>s required for
-	 *            execution
-	 * @param workflow
-	 *            the <code>Workflow</code> to execute
-	 * @param profile
-	 *            the <code>Profile</code> to use when executing the <code>Workflow</code>
-	 * @param dataBundle
-	 *            the <code>Bundle</code> containing the data values for the <code>Workflow</code>
-	 * @return a new Execution implementation
-	 * @throws InvalidWorkflowException
-	 *             if the specified workflow is invalid
-	 */
-	protected abstract Execution createExecutionImpl(
-			WorkflowBundle workflowBundle, Workflow workflow, Profile profile,
-			Bundle dataBundle) throws InvalidWorkflowException;
-
-	@Override
-	public WorkflowReport getWorkflowReport(String executionID)
-			throws InvalidExecutionIdException {
-		return getExecution(executionID).getWorkflowReport();
-	}
-
-	@Override
-	public void delete(String executionID) throws InvalidExecutionIdException {
-		getExecution(executionID).delete();
-		executionMap.remove(executionID);
-	}
-
-	@Override
-	public void start(String executionID) throws InvalidExecutionIdException {
-		getExecution(executionID).start();
-	}
-
-	@Override
-	public void pause(String executionID) throws InvalidExecutionIdException {
-		getExecution(executionID).pause();
-	}
-
-	@Override
-	public void resume(String executionID) throws InvalidExecutionIdException {
-		getExecution(executionID).resume();
-	}
-
-	@Override
-	public void cancel(String executionID) throws InvalidExecutionIdException {
-		getExecution(executionID).cancel();
-	}
-
-	protected Execution getExecution(String executionID)
-			throws InvalidExecutionIdException {
-		Execution execution = executionMap.get(executionID);
-		if (execution == null)
-			throw new InvalidExecutionIdException("Execution ID " + executionID
-					+ " is not valid");
-		return execution;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/Execution.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/Execution.java b/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/Execution.java
deleted file mode 100644
index 6f12edd..0000000
--- a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/Execution.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.api;
-
-import org.apache.taverna.robundle.Bundle;
-
-import uk.org.taverna.platform.report.WorkflowReport;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/**
- * Interface for a single execution of a Taverna workflow.
- *
- * @author David Withers
- */
-public interface Execution {
-
-	/**
-	 * Returns the identifier for this execution.
-	 *
-	 * @return the identifier for this execution
-	 */
-	public abstract String getID();
-
-	/**
-	 * Returns the <code>WorkflowBundle</code> containing the <code>Workflow</code>s required for execution.
-	 *
-	 * @return the <code>WorkflowBundle</code> containing the <code>Workflow</code>s required for execution
-	 */
-	public abstract WorkflowBundle getWorkflowBundle();
-
-	/**
-	 * Returns the <code>Bundle</code> containing the data values for the <code>Workflow</code>.
-	 *
-	 * @return the <code>Bundle</code> containing the data values for the <code>Workflow</code>
-	 */
-	public abstract Bundle getDataBundle();
-
-	/**
-	 * Returns the <code>Workflow</code> to execute.
-	 *
-	 * @return the <code>Workflow</code> to execute
-	 */
-	public abstract Workflow getWorkflow();
-
-	/**
-	 * Returns the <code>Profile</code> to use when executing the <code>Workflow</code>.
-	 *
-	 * @return the <code>Profile</code> to use when executing the <code>Workflow</code>
-	 */
-	public abstract Profile getProfile();
-
-	/**
-	 * Returns the <code>WorkflowReport</code> for the execution.
-	 *
-	 * @return the <code>WorkflowReport</code> for the execution
-	 */
-	public abstract WorkflowReport getWorkflowReport();
-
-	/**
-	 * Deletes the execution.
-	 */
-	public abstract void delete();
-
-	/**
-	 * Starts the execution.
-	 */
-	public abstract void start();
-
-	/**
-	 * Pauses the execution.
-	 */
-	public abstract void pause();
-
-	/**
-	 * Resumes a paused execution.
-	 */
-	public abstract void resume();
-
-	/**
-	 * Cancels the execution.
-	 */
-	public abstract void cancel();
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionEnvironment.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionEnvironment.java b/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionEnvironment.java
deleted file mode 100644
index a61e68d..0000000
--- a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionEnvironment.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.api;
-
-import java.net.URI;
-import java.util.Set;
-
-import org.apache.taverna.platform.capability.api.ActivityConfigurationException;
-import org.apache.taverna.platform.capability.api.ActivityNotFoundException;
-import org.apache.taverna.platform.capability.api.DispatchLayerConfigurationException;
-import org.apache.taverna.platform.capability.api.DispatchLayerNotFoundException;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * The ExecutionEnvironment specifies the capabilities of a workflow execution environment.
- *
- * @author David Withers
- */
-public interface ExecutionEnvironment {
-
-	/**
-	 * Returns the identifier for this ExecutionEnvironment.
-	 *
-	 * @return the identifier for this ExecutionEnvironment
-	 */
-	public String getID();
-
-	/**
-	 * Returns the name of this ExecutionEnvironment.
-	 *
-	 * @return the name of this ExecutionEnvironment
-	 */
-	public String getName();
-
-	/**
-	 * Returns a description of this ExecutionEnvironment.
-	 *
-	 * @return a description of this ExecutionEnvironment
-	 */
-	public String getDescription();
-
-	/**
-	 * Returns the ExecutionService that provides this ExecutionEnvironment.
-	 *
-	 * @return the ExecutionService that provides this ExecutionEnvironment
-	 */
-	public ExecutionService getExecutionService();
-
-	/**
-	 * Returns the activity types available in this ExecutionEnvironment.
-	 *
-	 * @return the activity types available in this ExecutionEnvironment
-	 */
-	public Set<URI> getActivityTypes();
-
-	/**
-	 * Returns true iff an activity exists for the specified URI in this ExecutionEnvironment.
-	 *
-	 * @param uri
-	 *            the activity URI to check
-	 * @return true if an activity exists for the specified URI in this ExecutionEnvironment
-	 */
-	public boolean activityExists(URI uri);
-
-	/**
-	 * Returns a JSON Schema for the configuration required by an activity.
-	 *
-	 * @param uri
-	 *            a URI that identifies an activity
-	 * @return a JSON Schema for the configuration required by an activity
-	 * @throws ActivityNotFoundException
-	 *             if an activity cannot be found for the specified URI
-	 * @throws ActivityConfigurationException
-	 *             if the ConfigurationDefinition cannot be created
-	 */
-	public JsonNode getActivityConfigurationSchema(URI uri)
-			throws ActivityNotFoundException, ActivityConfigurationException;
-
-	/**
-	 * Returns the dispatch layer types available in this ExecutionEnvironment.
-	 *
-	 * @return the dispatch layer types available in this ExecutionEnvironment
-	 */
-	public Set<URI> getDispatchLayerTypes();
-
-	/**
-	 * Returns true iff a dispatch layer exists for the specified URI in this ExecutionEnvironment.
-	 *
-	 * @param uri
-	 *            the dispatch layer URI to check
-	 * @return true if a dispatch layer exists for the specified URI in this ExecutionEnvironment
-	 */
-	public boolean dispatchLayerExists(URI uri);
-
-	/**
-	 * Returns a JSON Schema for the configuration required by a dispatch layer.
-	 *
-	 * @param uri
-	 *            a URI that identifies a dispatch layer
-	 * @return
-	 * @return a JSON Schema for the configuration required by a dispatch layer
-	 * @throws DispatchLayerNotFoundException
-	 *             if a dispatch layer cannot be found for the specified URI
-	 * @throws DispatchLayerConfigurationException
-	 *             if the ConfigurationDefinition cannot be created
-	 */
-	public JsonNode getDispatchLayerConfigurationSchema(URI uri)
-			throws DispatchLayerNotFoundException, DispatchLayerConfigurationException;
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionEnvironmentService.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionEnvironmentService.java b/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionEnvironmentService.java
deleted file mode 100644
index 9f0b5fd..0000000
--- a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionEnvironmentService.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.api;
-
-import java.util.Set;
-
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/**
- * Service for finding <code>ExecutionEnvironment</code>s.
- *
- * @author David Withers
- */
-public interface ExecutionEnvironmentService {
-
-	/**
-	 * Returns the available <code>ExecutionEnvironment</code>s.
-	 *
-	 * @return the available <code>ExecutionEnvironment</code>s
-	 */
-	public Set<ExecutionEnvironment> getExecutionEnvironments();
-
-	/**
-	 * Returns the <code>ExecutionEnvironment</code>s that can execute the specified
-	 * <code>Profile</code>.
-	 *
-	 * @param profile
-	 *            the <code>Profile</code> to find <code>ExecutionEnvironment</code>s for
-	 * @return the <code>ExecutionEnvironment</code>s that can execute a workflow with the specified
-	 *         <code>Profile</code>
-	 */
-	public Set<ExecutionEnvironment> getExecutionEnvironments(Profile profile);
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionService.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionService.java b/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionService.java
deleted file mode 100755
index 0f73ab3..0000000
--- a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionService.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.api;
-
-import java.util.Set;
-
-import org.apache.taverna.robundle.Bundle;
-
-import uk.org.taverna.platform.report.WorkflowReport;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/**
- * Service for executing Taverna workflows. There may be several <code>ExecutionService</code>s
- * available that offer different execution environments, e.g. one <code>ExecutionService</code> may
- * execute workflows on a remote server while another executes workflows on the local machine.
- *
- * @author David Withers
- */
-public interface ExecutionService {
-
-	/**
-	 * Returns the identifier for this ExecutionService.
-	 *
-	 * @return the identifier for this ExecutionService
-	 */
-	public String getID();
-
-	/**
-	 * Returns the name of this ExecutionService.
-	 *
-	 * @return the name of this ExecutionService
-	 */
-	public String getName();
-
-	/**
-	 * Returns a description of this ExecutionService.
-	 *
-	 * @return a description of this ExecutionService
-	 */
-	public String getDescription();
-
-	/**
-	 * Returns the ExecutionEnvironments available for this ExecutionService.
-	 *
-	 * @return the ExecutionEnvironments available for this ExecutionService
-	 */
-	public Set<ExecutionEnvironment> getExecutionEnvironments();
-
-	/**
-	 * Creates a workflow execution and returns its ID.
-	 *
-	 * @param executionEnvironment
-	 *            the {@link ExecutionEnvironment} used to execute the
-	 *            <code>Workflow</code>
-	 * @param workflowBundle
-	 *            the <code>WorkflowBundle</code> containing the workflows required for execution
-	 * @param workflow
-	 *            the workflow to execute
-	 * @param profile
-	 *            the profile to use when executing the workflow
-	 * @param dataBundle
-	 *            the <code>Bundle</code> containing the data values for the <code>Workflow</code>
-	 * @return the ID of the created workflow execution
-	 * @throws InvalidWorkflowException
-	 */
-	public String createExecution(ExecutionEnvironment executionEnvironment, WorkflowBundle workflowBundle, Workflow workflow, Profile profile,
-			Bundle dataBundle)
-			throws InvalidWorkflowException;
-
-	/**
-	 * Returns the workflow report for the specified execution.
-	 *
-	 * @param executionID
-	 *            the ID of the execution
-	 * @return the workflow report for this execution
-	 */
-	public WorkflowReport getWorkflowReport(String executionID) throws InvalidExecutionIdException;
-
-	/**
-	 * Deletes the execution of a workflow.
-	 *
-	 * @param executionID
-	 *            the ID of the execution to delete
-	 * @throws InvalidExecutionIdException
-	 *             if the execution ID is not valid
-	 */
-	public void delete(String executionID) throws InvalidExecutionIdException;
-
-	/**
-	 * Starts the execution of a workflow.
-	 *
-	 * @param executionID
-	 *            the ID of the execution to start
-	 * @throws InvalidExecutionIdException
-	 *             if the execution ID is not valid
-	 */
-	public void start(String executionID) throws InvalidExecutionIdException;
-
-	/**
-	 * Pauses the execution of a workflow.
-	 *
-	 * @param executionID
-	 *            the ID of the execution to pause
-	 * @throws InvalidExecutionIdException
-	 *             if the execution ID is not valid
-	 */
-	public void pause(String executionID) throws InvalidExecutionIdException;
-
-	/**
-	 * Resumes the execution of a paused workflow.
-	 *
-	 * @param executionID
-	 *            the ID of the execution to resume
-	 * @throws InvalidExecutionIdException
-	 *             if the execution ID is not valid
-	 */
-	public void resume(String executionID) throws InvalidExecutionIdException;
-
-	/**
-	 * Cancels the execution of a workflow.
-	 *
-	 * @param executionID
-	 *            the ID of the execution to cancel
-	 * @throws InvalidExecutionIdException
-	 *             if the execution ID is not valid
-	 */
-	public void cancel(String executionID) throws InvalidExecutionIdException;
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/InvalidExecutionIdException.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/InvalidExecutionIdException.java b/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/InvalidExecutionIdException.java
deleted file mode 100644
index 9cb8ef2..0000000
--- a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/InvalidExecutionIdException.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.api;
-
-/**
- * Thrown when an executionID is not valid for an ExecutionService.
- * 
- * @author David Withers
- */
-public class InvalidExecutionIdException extends Exception {
-
-	private static final long serialVersionUID = 4086661335641172903L;
-
-	public InvalidExecutionIdException() {
-    	super();
-    }
-
-    public InvalidExecutionIdException(String message) {
-    	super(message);
-    }
-
-    public InvalidExecutionIdException(String message, Throwable cause) {
-    	super(message, cause);
-    }
-
-    public InvalidExecutionIdException(Throwable cause) {
-    	super(cause);
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/InvalidWorkflowException.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/InvalidWorkflowException.java b/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/InvalidWorkflowException.java
deleted file mode 100644
index b0cc3fa..0000000
--- a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/InvalidWorkflowException.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.api;
-
-/**
- * Thrown when a Workflow fails to validate.
- * 
- * @author David Withers
- */
-public class InvalidWorkflowException extends Exception {
-
-	private static final long serialVersionUID = 7491175798204912590L;
-
-	public InvalidWorkflowException() {
-		super();
-	}
-
-	public InvalidWorkflowException(String message, Throwable cause) {
-		super(message, cause);
-	}
-
-	public InvalidWorkflowException(String message) {
-		super(message);
-	}
-
-	public InvalidWorkflowException(Throwable cause) {
-		super(cause);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/WorkflowCompiler.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/WorkflowCompiler.java b/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/WorkflowCompiler.java
deleted file mode 100644
index a183cd1..0000000
--- a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/WorkflowCompiler.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package uk.org.taverna.platform.execution.api;
-
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Workflow;
-
-/**
- * A workflow compilation service converts a workflow (in a
- * {@link WorkflowBundle}) into a dataflow. Most code should ignore this.
- * 
- * @author Donal Fellows
- */
-public interface WorkflowCompiler {
-	/**
-	 * Convert a workflow into a dataflow. May cache.
-	 * 
-	 * @param workflow
-	 *            the workflow to convert; must not be <tt>null</tt>
-	 * @return the dataflow, which should not be modified.
-	 * @throws InvalidWorkflowException
-	 *             If the compilation fails.
-	 */
-	Dataflow getDataflow(Workflow workflow) throws InvalidWorkflowException;
-	
-	/**
-	 * Convert a workflow bundle into a dataflow. May cache. Only the the
-	 * primary workflow is guaranteed to be converted.
-	 * 
-	 * @param bundle
-	 *            the workflow bundle to convert; must not be <tt>null</tt>
-	 * @return the dataflow, which should not be modified.
-	 * @throws InvalidWorkflowException
-	 *             If the compilation fails.
-	 */
-	Dataflow getDataflow(WorkflowBundle bundle) throws InvalidWorkflowException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/test/java/org/apache/taverna/platform/execution/api/AbstractExecutionTest.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/test/java/org/apache/taverna/platform/execution/api/AbstractExecutionTest.java b/taverna-execution-api/src/test/java/org/apache/taverna/platform/execution/api/AbstractExecutionTest.java
new file mode 100644
index 0000000..95a5bca
--- /dev/null
+++ b/taverna-execution-api/src/test/java/org/apache/taverna/platform/execution/api/AbstractExecutionTest.java
@@ -0,0 +1,127 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.api;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.apache.taverna.robundle.Bundle;
+
+import org.apache.taverna.databundle.DataBundles;
+import org.apache.taverna.platform.report.ActivityReport;
+import org.apache.taverna.platform.report.ProcessorReport;
+import org.apache.taverna.platform.report.WorkflowReport;
+import org.apache.taverna.scufl2.api.activity.Activity;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.Processor;
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+/**
+ * @author David Withers
+ */
+@Ignore
+public class AbstractExecutionTest {
+	private WorkflowBundle workflowBundle;
+	private Execution execution;
+	private Workflow workflow;
+	private Profile profile;
+	private Bundle dataBundle;
+
+	/**
+	 * @throws java.lang.Exception
+	 */
+	@Before
+	public void setUp() throws Exception {
+		workflowBundle = new WorkflowBundle();
+		workflow = new Workflow();
+		profile = new Profile();
+		dataBundle = DataBundles.createBundle();
+		execution = new AbstractExecution(workflowBundle, workflow, profile, dataBundle) {
+			@Override
+			public void start() {}
+			@Override
+			public void resume() {}
+			@Override
+			public void pause() {}
+			@Override
+			public void cancel() {}
+			@Override
+			public void delete() {}
+			@Override
+			protected WorkflowReport createWorkflowReport(Workflow workflow) {
+				return new WorkflowReport(workflow) {
+				};
+			}
+			@Override
+			public ProcessorReport createProcessorReport(Processor processor) {
+				return null;
+			}
+			@Override
+			public ActivityReport createActivityReport(Activity activity) {
+				return null;
+			}
+		};
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.execution.api.AbstractExecution#getID()}.
+	 */
+	@Test
+	public void testGetID() {
+		assertNotNull(execution.getID());
+		assertEquals(execution.getID(), execution.getID());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.execution.api.AbstractExecution#getWorkflowBundle()}.
+	 */
+	@Test
+	public void testGetWorkflowBundle() {
+		assertEquals(workflowBundle, execution.getWorkflowBundle());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.execution.api.AbstractExecution#getWorkflow()}.
+	 */
+	@Test
+	public void testGetWorkflow() {
+		assertEquals(workflow, execution.getWorkflow());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.execution.api.AbstractExecution#getInputs()}.
+	 */
+	@Test
+	public void testGetInputs() {
+		assertEquals(dataBundle, execution.getDataBundle());
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.execution.api.AbstractExecution#getWorkflowReport()}.
+	 */
+	@Test
+	public void testGetWorkflowReport() {
+		assertNotNull(execution.getWorkflowReport());
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/test/java/uk/org/taverna/platform/execution/api/AbstractExecutionTest.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/test/java/uk/org/taverna/platform/execution/api/AbstractExecutionTest.java b/taverna-execution-api/src/test/java/uk/org/taverna/platform/execution/api/AbstractExecutionTest.java
deleted file mode 100644
index 9b3361e..0000000
--- a/taverna-execution-api/src/test/java/uk/org/taverna/platform/execution/api/AbstractExecutionTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.api;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.apache.taverna.robundle.Bundle;
-
-import org.apache.taverna.databundle.DataBundles;
-import uk.org.taverna.platform.report.ActivityReport;
-import uk.org.taverna.platform.report.ProcessorReport;
-import uk.org.taverna.platform.report.WorkflowReport;
-import org.apache.taverna.scufl2.api.activity.Activity;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Processor;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/**
- * @author David Withers
- */
-@Ignore
-public class AbstractExecutionTest {
-	private WorkflowBundle workflowBundle;
-	private Execution execution;
-	private Workflow workflow;
-	private Profile profile;
-	private Bundle dataBundle;
-
-	/**
-	 * @throws java.lang.Exception
-	 */
-	@Before
-	public void setUp() throws Exception {
-		workflowBundle = new WorkflowBundle();
-		workflow = new Workflow();
-		profile = new Profile();
-		dataBundle = DataBundles.createBundle();
-		execution = new AbstractExecution(workflowBundle, workflow, profile, dataBundle) {
-			@Override
-			public void start() {}
-			@Override
-			public void resume() {}
-			@Override
-			public void pause() {}
-			@Override
-			public void cancel() {}
-			@Override
-			public void delete() {}
-			@Override
-			protected WorkflowReport createWorkflowReport(Workflow workflow) {
-				return new WorkflowReport(workflow) {
-				};
-			}
-			@Override
-			public ProcessorReport createProcessorReport(Processor processor) {
-				return null;
-			}
-			@Override
-			public ActivityReport createActivityReport(Activity activity) {
-				return null;
-			}
-		};
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.execution.api.AbstractExecution#getID()}.
-	 */
-	@Test
-	public void testGetID() {
-		assertNotNull(execution.getID());
-		assertEquals(execution.getID(), execution.getID());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.execution.api.AbstractExecution#getWorkflowBundle()}.
-	 */
-	@Test
-	public void testGetWorkflowBundle() {
-		assertEquals(workflowBundle, execution.getWorkflowBundle());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.execution.api.AbstractExecution#getWorkflow()}.
-	 */
-	@Test
-	public void testGetWorkflow() {
-		assertEquals(workflow, execution.getWorkflow());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.execution.api.AbstractExecution#getInputs()}.
-	 */
-	@Test
-	public void testGetInputs() {
-		assertEquals(dataBundle, execution.getDataBundle());
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.execution.api.AbstractExecution#getWorkflowReport()}.
-	 */
-	@Test
-	public void testGetWorkflowReport() {
-		assertNotNull(execution.getWorkflowReport());
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductInputFormat.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductInputFormat.java b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductInputFormat.java
new file mode 100644
index 0000000..d130cd3
--- /dev/null
+++ b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductInputFormat.java
@@ -0,0 +1,107 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.hadoop;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.fs.BlockLocation;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.PathFilter;
+import org.apache.hadoop.io.ArrayWritable;
+import org.apache.hadoop.io.MapWritable;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapreduce.InputSplit;
+import org.apache.hadoop.mapreduce.JobContext;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.hadoop.mapreduce.TaskAttemptContext;
+import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
+
+/**
+ * An input format that receives an input directory containing a number of directories with input files 
+ * for each input port to a Taverna processor/activity that will be executed as part of this
+ * MapReduce job. Mapping between directory name -> Taverna processor/activity input port name
+ * is carried in the job's Context.
+ * 
+ * @author Alex Nenadic
+ *
+ */
+public class CrossProductInputFormat extends
+		FileInputFormat<Text, TextArrayWritable> {
+
+	private static final Log Logger = LogFactory.getLog(CrossProductInputFormat.class);
+
+	// Do not split files into blocks
+	@Override
+	protected boolean isSplitable(JobContext context, Path filename) {
+		return false;
+	}
+
+	@Override
+	public RecordReader<Text, TextArrayWritable> createRecordReader(
+			InputSplit split, TaskAttemptContext context) {
+		return new CrossProductRecordReader();
+	}
+
+	@Override
+	public List<InputSplit> getSplits(JobContext job) throws IOException {
+
+	    // Generate splits. Split is a list of directories where each directory 
+		// contains inputs for one input port of the Taverna processor/activity we 
+		// are invoking. 
+		// We will have only one split for cross product that will know about all
+		// the files in all input directories and will generate RecordReaders 
+		// for every combination of files inside these directories.
+//	    CrossProductInputSplit split = new CrossProductInputSplit();
+	    
+	    // List the input port directories contained in the input directory passed 
+	    // in from the command line.
+	    List<FileStatus> inputPortDirectories = listStatus(job); 
+	    
+		final FileSystem fs = job.getWorkingDirectory().getFileSystem(job.getConfiguration());
+		Path workingDirectory = job.getWorkingDirectory();
+		System.out.println("Working directory: " + workingDirectory);
+		System.out.println("Adding directories to the cross product split:");
+		ArrayList<Path> inputPortDirectoriesPaths = new ArrayList<Path>();
+    	for (FileStatus inputPortDirectory : inputPortDirectories){
+    		// TODO input port directories need to be ordered in the order of the 
+    		// input ports of the Taverna processor/activity they are going into
+            
+    		//inputPortDirectoriesPaths.add(new Text(inputPortDirectory.getPath().toString()));
+    		inputPortDirectoriesPaths.add(inputPortDirectory.getPath());
+    		System.out.println(inputPortDirectory.getPath());
+
+    	}
+	    CrossProductInputSplit split = new CrossProductInputSplit(workingDirectory, inputPortDirectoriesPaths);
+	    
+
+	    List<InputSplit> splits = new ArrayList<InputSplit>();
+	    splits.add(split);
+		
+	    return splits;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductInputSplit.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductInputSplit.java b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductInputSplit.java
new file mode 100644
index 0000000..d19bf85
--- /dev/null
+++ b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductInputSplit.java
@@ -0,0 +1,87 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.hadoop;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapreduce.lib.input.FileSplit;
+
+/**
+ *
+ *
+ * @author Alex Nenadic
+ */
+public class CrossProductInputSplit extends FileSplit {
+	//
+	// private long length = 0;
+	// private String[] hosts;
+	private List<Path> inputPortDirectories;
+	private Path workingDirectory;
+
+	public CrossProductInputSplit() {
+		super(null,0,0,null);
+		inputPortDirectories = new ArrayList<Path>();
+		System.out.println("Calling default constructor for cross product split");
+	}
+
+	public CrossProductInputSplit(Path workingDirectory, List<Path> inputPortDirectories) {
+		// this.length = length;
+		// this.hosts = hosts;
+		super(workingDirectory, 0, 0, new String[0]);
+		this.workingDirectory = workingDirectory;
+		this.inputPortDirectories = inputPortDirectories;
+		System.out.println("Calling non-default constructor for cross product split");
+	}
+
+	public void addInputPortDirectory(Path path) {
+		inputPortDirectories.add(path);
+	}
+
+	public List<Path> getInputPortDirectories() {
+		return inputPortDirectories;
+	}
+
+	@Override
+	public void write(DataOutput out) throws IOException {
+		super.write(out);
+		Text.writeString(out, workingDirectory.toString());
+		out.writeInt(inputPortDirectories.size());
+		for (Path path : inputPortDirectories) {
+			Text.writeString(out, path.toString());
+		}
+	}
+
+	@Override
+	public void readFields(DataInput in) throws IOException {
+		super.readFields(in);
+		workingDirectory = new Path(Text.readString(in));
+		int length = in.readInt();
+		for (int i = 0; i < length; i++) {
+			inputPortDirectories.add(new Path(Text.readString(in)));
+		}
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductRecordReader.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductRecordReader.java b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductRecordReader.java
new file mode 100644
index 0000000..94479ef
--- /dev/null
+++ b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductRecordReader.java
@@ -0,0 +1,131 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.hadoop;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapreduce.InputSplit;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.hadoop.mapreduce.TaskAttemptContext;
+import org.pingel.util.CrossProduct;
+
+public class CrossProductRecordReader extends RecordReader<Text, TextArrayWritable>{
+
+	private static final Log Logger = LogFactory.getLog(CrossProductRecordReader.class);
+
+	// Input directories (one for each port) containing files that are used 
+	// as inputs to Taverna processor/activity
+	private List<Path> inputPortDirectories;
+	
+	private CrossProduct<String> crossProduct ;
+
+	private Iterator<List<String>> crossProductIterator;
+
+	private List<String> currentIndexes;
+
+	@Override
+	public void initialize(InputSplit split, TaskAttemptContext context)
+			throws IOException, InterruptedException {
+
+		System.out.println("Inside record reader's initialize");
+		
+		CrossProductInputSplit crossProductSplit = (CrossProductInputSplit)split;
+		inputPortDirectories = crossProductSplit.getInputPortDirectories();
+		System.out.println("Record reader received " + +inputPortDirectories.size() + " input port directories");
+
+		List<List<String>> iterables = new ArrayList<List<String>>();
+		for (int i=0; i<inputPortDirectories.size();i++ ){
+	
+			Path inputPortDirectory = inputPortDirectories.get(i);
+			//Path inputPortDirectory = inputPortDirectories.get(i);
+			FileStatus[] files = inputPortDirectory.getFileSystem(context.getConfiguration()).listStatus(inputPortDirectory);
+			List<String> fileNames = new ArrayList<String>();
+			for (FileStatus file : files){
+				fileNames.add(file.getPath().getName());
+			}
+			iterables.add(fileNames);
+		}
+
+		crossProduct = new CrossProduct<String>(iterables);
+		crossProductIterator = crossProduct.iterator();
+		
+	}
+
+	@Override
+	public boolean nextKeyValue(){
+
+		boolean hasNextKey = crossProductIterator.hasNext();
+		System.out.println("Has record reader next key value? " + hasNextKey);
+		if (hasNextKey){
+			currentIndexes = crossProductIterator.next();
+		}
+		return hasNextKey;
+	}
+
+	@Override
+	public Text getCurrentKey() throws IOException, InterruptedException {
+	
+		StringBuffer sb = new StringBuffer();
+		for (String index : currentIndexes){
+			sb.append(index + ".");
+		}
+		// Remove last "."
+		String indexesString = sb.toString();
+		System.out.println("Get current key: " + indexesString);
+		if (indexesString.contains(".")){
+			indexesString = indexesString.substring(0, indexesString.length() - 1);
+		}
+		return new Text(indexesString);
+	}
+
+	@Override
+	public TextArrayWritable getCurrentValue() {
+				
+		TextArrayWritable arrayWritable = new TextArrayWritable();
+		Text[] array = new Text[currentIndexes.size()];
+		for(int i= 0; i< currentIndexes.size(); i++){
+			Path file = new Path(inputPortDirectories.get(i).toString(), currentIndexes.get(i));
+			array[i] = new Text(file.toString());
+		}
+		arrayWritable.set(array);
+		return arrayWritable;
+	}
+
+	@Override
+	public float getProgress() throws IOException, InterruptedException {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public void close() throws IOException {
+		// TODO Auto-generated method stub
+		
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductTest.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductTest.java b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductTest.java
new file mode 100644
index 0000000..17275eb
--- /dev/null
+++ b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductTest.java
@@ -0,0 +1,115 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.hadoop;
+
+import java.io.IOException;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.ArrayWritable;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.MapWritable;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapreduce.Job;
+import org.apache.hadoop.mapreduce.Mapper;
+import org.apache.hadoop.mapreduce.Reducer;
+import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
+import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
+import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
+import org.apache.hadoop.util.Tool;
+import org.apache.hadoop.util.ToolRunner;
+
+public class CrossProductTest extends Configured implements Tool {
+
+	public static class Map extends Mapper<Text, TextArrayWritable, Text, TextArrayWritable> {
+		public void map(Text key, TextArrayWritable value, Context context) throws IOException,
+				InterruptedException {
+			System.out.println("Map key = " + key);
+			System.out.println("Map value = " );
+
+			for (int i = 0; i < value.get().length; i++){
+				System.out.println("  " + value.get()[i]);
+			}
+
+			context.write(key, value);
+		}
+	}
+
+	public static class Reduce extends Reducer<Text, TextArrayWritable, Text, Text> {
+		public void reduce(Text key, Iterable<TextArrayWritable> values, Context context)
+				throws IOException, InterruptedException {
+
+			System.out.println("Reduce key = " + key);
+			context.write(key, f(values));
+		}
+
+		private Text f(Iterable<TextArrayWritable> values) {
+			StringBuilder sb = new StringBuilder();
+
+			// There should be only one array
+			TextArrayWritable arrayValue = values.iterator().next();
+
+			for (int i = 0; i < arrayValue.get().length; i++){
+				sb.append(arrayValue.get()[i] + "\nx");
+			}
+			String str = sb.toString();
+			if (str.contains("\nx")){
+				str = str.substring(0, sb.lastIndexOf("\nx") -1);
+			}
+			System.out.println("Result of function f(): " + str);
+
+			return new Text(str);
+		}
+	}
+
+	public int run(String[] args) throws Exception {
+
+		Configuration configuration = getConf();
+		configuration.set("taverna.datalinks", "A|X,B|Y");
+		System.out.println(configuration);
+		Job job = new Job(configuration);
+		job.setJarByClass(CrossProductTest.class);
+		job.setJobName("crossproduct");
+
+		job.setOutputKeyClass(Text.class);
+		job.setOutputValueClass(TextArrayWritable.class);
+
+		job.setMapperClass(Map.class);
+//		job.setCombinerClass(Reduce.class);
+		job.setReducerClass(Reduce.class);
+
+		job.setInputFormatClass(CrossProductInputFormat.class);
+		job.setOutputFormatClass(TextOutputFormat.class);
+
+		FileInputFormat.setInputPaths(job, new Path(args[0]));
+		System.out.println("Input dir: " + args[0]);
+		FileOutputFormat.setOutputPath(job, new Path(args[1]));
+		System.out.println("Output dir: " + args[1]);
+
+		boolean success = job.waitForCompletion(true);
+		return success ? 0 : 1;
+	}
+
+	public static void main(String[] args) throws Exception {
+		int ret = ToolRunner.run(new CrossProductTest(), args);
+		System.exit(ret);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/DotProductTest.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/DotProductTest.java b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/DotProductTest.java
new file mode 100644
index 0000000..ff9cf37
--- /dev/null
+++ b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/DotProductTest.java
@@ -0,0 +1,105 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.hadoop;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.MapWritable;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapreduce.Job;
+import org.apache.hadoop.mapreduce.Mapper;
+import org.apache.hadoop.mapreduce.Reducer;
+import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
+import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
+import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
+import org.apache.hadoop.util.Tool;
+import org.apache.hadoop.util.ToolRunner;
+
+public class DotProductTest extends Configured implements Tool {
+
+	public static class Map extends Mapper<LongWritable, MapWritable, LongWritable, MapWritable> {
+		public void map(LongWritable key, MapWritable value, Context context) throws IOException,
+				InterruptedException {
+			System.out.println("Map key = " + key);
+			System.out.println("Map value tag = " + value.get(new Text("tag")));
+			System.out.println("Map value record = " + value.get(new Text("record")));
+			context.write(key, value);
+		}
+	}
+
+	public static class Reduce extends Reducer<LongWritable, MapWritable, LongWritable, Text> {
+		public void reduce(LongWritable key, Iterable<MapWritable> values, Context context)
+				throws IOException, InterruptedException {
+
+			System.out.println("Reduce key = " + key);
+			context.write(key, f(values));
+			context.write(key, f(values));
+		}
+
+		private Text f(Iterable<MapWritable> values) {
+			StringBuilder sb = new StringBuilder();
+			for (MapWritable value : values) {
+				System.out.println("Reduce tag = " + value.get(new Text("tag")));
+				System.out.println("Reduce value = " + value.get(new Text("record")));
+				sb.append(value.get(new Text("record")) + " ");
+			}
+			return new Text(sb.toString());
+		}
+	}
+
+	public int run(String[] args) throws Exception {
+		java.util.Map datalinks = new HashMap();
+
+
+		Configuration configuration = getConf();
+		configuration.set("taverna.datalinks", "A|X,B|Y");
+		System.out.println(configuration);
+		Job job = new Job(configuration);
+		job.setJarByClass(DotProductTest.class);
+		job.setJobName("dotproduct");
+
+		job.setOutputKeyClass(LongWritable.class);
+		job.setOutputValueClass(MapWritable.class);
+
+		job.setMapperClass(Map.class);
+//		job.setCombinerClass(Reduce.class);
+		job.setReducerClass(Reduce.class);
+
+		job.setInputFormatClass(TavernaInputFormat.class);
+		job.setOutputFormatClass(TextOutputFormat.class);
+
+		FileInputFormat.setInputPaths(job, new Path(args[0]));
+		FileOutputFormat.setOutputPath(job, new Path(args[1]));
+
+		boolean success = job.waitForCompletion(true);
+		return success ? 0 : 1;
+	}
+
+	public static void main(String[] args) throws Exception {
+		int ret = ToolRunner.run(new DotProductTest(), args);
+		System.exit(ret);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaInputFormat.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaInputFormat.java b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaInputFormat.java
new file mode 100644
index 0000000..1b95a95
--- /dev/null
+++ b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaInputFormat.java
@@ -0,0 +1,51 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.hadoop;
+
+import java.io.IOException;
+
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.MapWritable;
+import org.apache.hadoop.mapreduce.InputSplit;
+import org.apache.hadoop.mapreduce.JobContext;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.hadoop.mapreduce.TaskAttemptContext;
+import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
+
+/**
+ *
+ *
+ * @author David Withers
+ */
+public class TavernaInputFormat extends FileInputFormat<LongWritable, MapWritable> {
+
+	@Override
+	public RecordReader<LongWritable, MapWritable> createRecordReader(InputSplit split,
+			TaskAttemptContext context) throws IOException, InterruptedException {
+		return new TavernaRecordReader();
+	}
+
+	@Override
+	protected boolean isSplitable(JobContext context, Path filename) {
+		return false;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaInputSplit.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaInputSplit.java b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaInputSplit.java
new file mode 100644
index 0000000..6ce3cfa
--- /dev/null
+++ b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaInputSplit.java
@@ -0,0 +1,68 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.hadoop;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.mapreduce.InputSplit;
+
+/**
+ *
+ *
+ * @author David Withers
+ */
+public class TavernaInputSplit extends InputSplit {
+	private int[] index;
+	private Map<String, Path> inputs;
+	private long length;
+	private String[] hosts;
+
+	public TavernaInputSplit(int[] index, Map<String, Path> inputs, long length, String[] hosts) {
+		this.index = index;
+		this.inputs = inputs;
+		this.length = length;
+		this.hosts = hosts;
+	}
+
+	public int[] getIndex() {
+		return index;
+	}
+
+	public Map<String, Path> getInputs() {
+		return inputs;
+	}
+
+	@Override
+	public long getLength() throws IOException, InterruptedException {
+		return length;
+	}
+
+	@Override
+	public String[] getLocations() throws IOException, InterruptedException {
+		if (hosts == null) {
+			return new String[] {};
+		} else {
+			return this.hosts;
+		}
+	}
+
+}


[46/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-impl/src/main/java/uk/org/taverna/platform/execution/impl/ExecutionEnvironmentServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-execution-impl/src/main/java/uk/org/taverna/platform/execution/impl/ExecutionEnvironmentServiceImpl.java b/taverna-execution-impl/src/main/java/uk/org/taverna/platform/execution/impl/ExecutionEnvironmentServiceImpl.java
deleted file mode 100644
index d45366e..0000000
--- a/taverna-execution-impl/src/main/java/uk/org/taverna/platform/execution/impl/ExecutionEnvironmentServiceImpl.java
+++ /dev/null
@@ -1,354 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.impl;
-
-import java.net.URI;
-import java.text.MessageFormat;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.logging.Logger;
-
-import org.apache.taverna.platform.capability.api.ActivityConfigurationException;
-import org.apache.taverna.platform.capability.api.ActivityNotFoundException;
-import org.apache.taverna.platform.capability.api.DispatchLayerConfigurationException;
-import org.apache.taverna.platform.capability.api.DispatchLayerNotFoundException;
-import uk.org.taverna.platform.execution.api.ExecutionEnvironment;
-import uk.org.taverna.platform.execution.api.ExecutionEnvironmentService;
-import uk.org.taverna.platform.execution.api.ExecutionService;
-import org.apache.taverna.scufl2.api.activity.Activity;
-import org.apache.taverna.scufl2.api.common.NamedSet;
-import org.apache.taverna.scufl2.api.common.Scufl2Tools;
-import org.apache.taverna.scufl2.api.configurations.Configuration;
-import org.apache.taverna.scufl2.api.core.Processor;
-import org.apache.taverna.scufl2.api.profiles.ProcessorBinding;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * Implementation of the ExecutionEnvironmentService.
- *
- * @author David Withers
- */
-public class ExecutionEnvironmentServiceImpl implements ExecutionEnvironmentService {
-	private static final Logger logger = Logger.getLogger(ExecutionEnvironmentServiceImpl.class.getName());
-
-	@SuppressWarnings("unused")
-	private final Scufl2Tools scufl2Tools = new Scufl2Tools();
-	private Set<ExecutionService> executionServices;
-
-	@Override
-	public Set<ExecutionEnvironment> getExecutionEnvironments() {
-		Set<ExecutionEnvironment> executionEnvironments = new HashSet<>();
-		for (ExecutionService executionService : executionServices)
-			executionEnvironments.addAll(executionService
-					.getExecutionEnvironments());
-		return executionEnvironments;
-	}
-
-	@Override
-	public Set<ExecutionEnvironment> getExecutionEnvironments(Profile profile) {
-		Set<ExecutionEnvironment> validExecutionEnvironments = new HashSet<>();
-		for (ExecutionEnvironment executionEnvironment : getExecutionEnvironments())
-			if (isValidExecutionEnvironment(executionEnvironment, profile))
-				validExecutionEnvironments.add(executionEnvironment);
-		return validExecutionEnvironments;
-	}
-
-	/**
-	 * Sets the ExecutionServices that will be used to find ExecutionEnvironments.
-	 *
-	 * @param executionServices
-	 *            the ExecutionServices that will be used to find ExecutionEnvironments
-	 */
-	public void setExecutionServices(Set<ExecutionService> executionServices) {
-		this.executionServices = executionServices;
-	}
-
-	/**
-	 * @param executionEnvironment
-	 * @param profile
-	 * @return
-	 */
-	private boolean isValidExecutionEnvironment(ExecutionEnvironment executionEnvironment,
-			Profile profile) {
-		NamedSet<ProcessorBinding> processorBindings = profile.getProcessorBindings();
-		for (ProcessorBinding processorBinding : processorBindings) {
-			Activity activity = processorBinding.getBoundActivity();
-			if (!executionEnvironment.activityExists(activity.getType())) {
-				logger.fine(MessageFormat.format("{0} does not contain activity {1}",
-						executionEnvironment.getName(), activity.getType()));
-				return false;
-			}
-			Configuration activityConfiguration = activity.getConfiguration();
-			if (!isValidActivityConfiguration(executionEnvironment, activityConfiguration, activity)) {
-				logger.fine(MessageFormat.format("Invalid activity configuration for {1} in {0}",
-						executionEnvironment.getName(), activity.getType()));
-				return false;
-			}
-			@SuppressWarnings("unused")
-			Processor processor = processorBinding.getBoundProcessor();
-			// TODO check that environment has required dispatch layers for processor configuration
-//			for (DispatchStackLayer dispatchStackLayer : processor.getDispatchStack()) {
-//				if (!executionEnvironment.dispatchLayerExists(dispatchStackLayer
-//						.getType())) {
-//					logger.fine(MessageFormat.format("{0} does not contain dispatch layer {1}",
-//							executionEnvironment.getName(),
-//							dispatchStackLayer.getType()));
-//					return false;
-//				}
-//
-//				List<Configuration> dispatchLayerConfigurations = scufl2Tools.configurationsFor(dispatchStackLayer, profile);
-//				if (dispatchLayerConfigurations.size() > 1) {
-//					logger.fine(MessageFormat.format("{0} contains multiple configurations for dispatch layer {1}",
-//							executionEnvironment.getName(),
-//							dispatchStackLayer.getType()));
-//				} else if (dispatchLayerConfigurations.size() == 1) {
-//					if (!isValidDispatchLayerConfiguration(executionEnvironment, dispatchLayerConfigurations.get(0), dispatchStackLayer)) {
-//						logger.fine(MessageFormat.format("Invalid dispatch layer configuration for {1} in {0}",
-//								executionEnvironment.getName(), dispatchStackLayer.getType()));
-//						return false;
-//					}
-//				}
-//			}
-		}
-		return true;
-	}
-
-	private boolean isValidActivityConfiguration(ExecutionEnvironment executionEnvironment,
-			Configuration configuration, Activity activity) {
-		try {
-			configuration.getJson();
-			configuration.getJsonSchema();
-			@SuppressWarnings("unused")
-			JsonNode environmentSchema = executionEnvironment.getActivityConfigurationSchema(activity.getType());
-			// TODO validate against schema
-		} catch (ActivityNotFoundException e) {
-			logger.fine(MessageFormat.format("{0} does not contain activity {1}",
-					executionEnvironment.getName(), activity.getType()));
-			return false;
-		} catch (ActivityConfigurationException e) {
-			logger.fine(MessageFormat.format("Configuration for {1} is incorrect in {0}",
-					executionEnvironment.getName(), activity.getType()));
-			return false;
-		}
-		return true;
-	}
-
-	@SuppressWarnings("unused")
-	private boolean isValidDispatchLayerConfiguration(ExecutionEnvironment executionEnvironment,
-			Configuration configuration, URI dispatchLayerType) {
-		try {
-			JsonNode environmentSchema = executionEnvironment.getDispatchLayerConfigurationSchema(dispatchLayerType);
-			// TODO validate against schema
-		} catch (DispatchLayerNotFoundException e) {
-			logger.fine(MessageFormat.format("{0} does not contain dispatch layer {1}",
-					executionEnvironment.getName(), dispatchLayerType));
-			return false;
-		} catch (DispatchLayerConfigurationException e) {
-			logger.fine(MessageFormat.format("Configuration for {1} is incorrect in {0}",
-					executionEnvironment.getName(), dispatchLayerType));
-			return false;
-		}
-		return true;
-	}
-
-//	/**
-//	 * @param propertyResourceDefinition
-//	 * @param propertyResource
-//	 * @return
-//	 */
-//	private boolean isValidPropertyResource(Configuration configuration,
-//			PropertyResourceDefinition propertyResourceDefinition, PropertyResource propertyResource) {
-//		if (!propertyResourceDefinition.getTypeURI().equals(propertyResource.getTypeURI())) {
-//			logger.fine(MessageFormat.format(
-//					"Property type {0} does not equal property definition type {1}",
-//					propertyResource.getTypeURI(), propertyResourceDefinition.getTypeURI()));
-//			return false;
-//		}
-//		List<PropertyDefinition> propertyDefinitions = propertyResourceDefinition
-//				.getPropertyDefinitions();
-//		Map<URI, SortedSet<PropertyObject>> properties = propertyResource.getProperties();
-//		for (PropertyDefinition propertyDefinition : propertyDefinitions) {
-//			SortedSet<PropertyObject> propertySet = properties.get(propertyDefinition
-//					.getPredicate());
-//			if (propertySet == null) {
-//				if (propertyDefinition.isRequired()) {
-//					logger.fine(MessageFormat.format("Required property {0} is missing",
-//							propertyDefinition.getPredicate()));
-//					return false;
-//				}
-//			} else {
-//				if (propertySet.size() == 0 && propertyDefinition.isRequired()) {
-//					logger.fine(MessageFormat.format("Required property {0} is missing",
-//							propertyDefinition.getPredicate()));
-//					return false;
-//				}
-//				if (propertySet.size() > 1 && !propertyDefinition.isMultiple()) {
-//					logger.fine(MessageFormat.format(
-//							"{0} properties found for singleton property {1}", propertySet.size(),
-//							propertyDefinition.getPredicate()));
-//					return false;
-//				}
-//				if (propertySet.size() > 1 && propertyDefinition.isMultiple() && propertyDefinition.isOrdered()) {
-//					logger.fine(MessageFormat.format(
-//							"{0} property lists found for property {1}", propertySet.size(),
-//							propertyDefinition.getPredicate()));
-//					return false;
-//				}
-//				for (PropertyObject property : propertySet) {
-//					if (propertyDefinition.isMultiple() && propertyDefinition.isOrdered()) {
-//						if (property instanceof PropertyList) {
-//							PropertyList propertyList = (PropertyList) property;
-//							for (PropertyObject propertyObject : propertyList) {
-//								if (!isValidProperty(configuration, propertyDefinition, propertyObject)) {
-//									logger.fine(MessageFormat.format("Property {0} is invalid",
-//											propertyDefinition.getPredicate()));
-//									return false;
-//								}
-//							}
-//						}
-//
-//					} else if (!isValidProperty(configuration, propertyDefinition, property)) {
-//						logger.fine(MessageFormat.format("Property {0} is invalid",
-//								propertyDefinition.getPredicate()));
-//						return false;
-//					}
-//				}
-//			}
-//		}
-//		return true;
-//	}
-//
-//	/**
-//	 * @param propertyDefinition
-//	 * @param property
-//	 * @return
-//	 */
-//	private boolean isValidProperty(Configuration configuration,
-//			PropertyDefinition propertyDefinition, PropertyObject property) {
-//		if (propertyDefinition instanceof PropertyLiteralDefinition) {
-//			if (property instanceof PropertyLiteral) {
-//				PropertyLiteralDefinition propertyLiteralDefinition = (PropertyLiteralDefinition) propertyDefinition;
-//				PropertyLiteral propertyLiteral = (PropertyLiteral) property;
-//				if (!propertyLiteral.getLiteralType().equals(
-//						propertyLiteralDefinition.getLiteralType())) {
-//					logger.fine(MessageFormat.format(
-//							"Property type {0} does not equal property definition type {1}",
-//							propertyLiteral.getLiteralType(),
-//							propertyLiteralDefinition.getLiteralType()));
-//					return false;
-//				}
-//				LinkedHashSet<String> options = propertyLiteralDefinition.getOptions();
-//				if (options != null && options.size() > 0) {
-//					if (!options.contains(propertyLiteral.getLiteralValue())) {
-//						logger.fine(MessageFormat.format("Property value {0} is not permitted",
-//								propertyLiteral.getLiteralValue()));
-//						return false;
-//					}
-//				}
-//			} else {
-//				logger.fine(MessageFormat.format("Expected a PropertyLiteral but got a {0}",
-//						property.getClass().getSimpleName()));
-//				return false;
-//			}
-//		} else if (propertyDefinition instanceof PropertyReferenceDefinition) {
-//			if (property instanceof PropertyReference) {
-//				PropertyReferenceDefinition propertyReferenceDefinition = (PropertyReferenceDefinition) propertyDefinition;
-//				PropertyReference propertyReference = (PropertyReference) property;
-//				LinkedHashSet<URI> options = propertyReferenceDefinition.getOptions();
-//				if (options != null && options.size() > 0) {
-//					if (!options.contains(propertyReference.getResourceURI())) {
-//						logger.fine(MessageFormat.format("Property value {0} is not permitted",
-//								propertyReference.getResourceURI()));
-//						return false;
-//					}
-//				}
-//			} else {
-//				logger.fine(MessageFormat.format("Expected a PropertyReference but got a {0}",
-//						property.getClass().getSimpleName()));
-//				return false;
-//			}
-//		} else if (propertyDefinition instanceof PropertyResourceDefinition) {
-//			if (property instanceof PropertyResource) {
-//				PropertyResourceDefinition propertyResourceDefinition = (PropertyResourceDefinition) propertyDefinition;
-//				PropertyResource propertyResource = (PropertyResource) property;
-//				return isValidPropertyResource(configuration, propertyResourceDefinition,
-//						propertyResource);
-//			} else if (property instanceof PropertyReference) {
-//				// special cases where a PropertyResource is actually a reference to a WorkflowBundle component
-//				PropertyReference propertyReference = (PropertyReference) property;
-//				WorkflowBundle workflowBundle = scufl2Tools.findParent(WorkflowBundle.class,
-//						configuration);
-//				URI configUri = uriTools.uriForBean(configuration);
-//				URI referenceUri = configUri.resolve(propertyReference.getResourceURI());
-//				if (workflowBundle != null) {
-//					URI predicate = propertyDefinition.getPredicate();
-//					WorkflowBean workflowBean = uriTools.resolveUri(referenceUri, workflowBundle);
-//					if (workflowBean == null) {
-//						logger.fine(MessageFormat.format(
-//								"Cannot resolve {0} in WorkflowBundle {1}",
-//								propertyReference.getResourceURI(), workflowBundle.getName()));
-//					}
-//					if (predicate.equals(SCUFL2.resolve("#definesInputPort"))) {
-//						if (workflowBean == null) {
-//							return false;
-//						}
-//						if (!(workflowBean instanceof InputActivityPort)) {
-//							logger.fine(MessageFormat.format(
-//									"{0} resolved to a {1}, expected a InputActivityPort",
-//									propertyReference.getResourceURI(), workflowBean.getClass()
-//											.getSimpleName()));
-//							return false;
-//						}
-//					} else if (predicate.equals(SCUFL2.resolve("#definesOutputPort"))) {
-//						if (workflowBean == null) {
-//							return false;
-//						}
-//						if (!(workflowBean instanceof OutputActivityPort)) {
-//							logger.fine(MessageFormat.format(
-//									"{0} resolved to a {1}, expected a OutputActivityPort",
-//									propertyReference.getResourceURI(), workflowBean.getClass()
-//											.getSimpleName()));
-//							return false;
-//						}
-//					} else {
-//						logger.fine(MessageFormat.format("Unexpected reference to {0}", predicate));
-//					}
-//				} else {
-//					logger.fine(MessageFormat
-//							.format("Cannot resolve reference to {0} because Configuration {1} not contained within a WorkflowBundle",
-//									referenceUri, configuration.getName()));
-//				}
-//			} else {
-//				logger.fine(MessageFormat.format("Expected a PropertyResource or PropertyReference but got a {0}",
-//						property.getClass().getSimpleName()));
-//				return false;
-//			}
-//		} else {
-//			logger.fine(MessageFormat.format("Unknown propery definition class {0}",
-//					propertyDefinition.getClass().getSimpleName()));
-//			return false;
-//		}
-//		return true;
-//	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-impl/src/main/resources/META-INF/spring/execution-context-osgi.xml
----------------------------------------------------------------------
diff --git a/taverna-execution-impl/src/main/resources/META-INF/spring/execution-context-osgi.xml b/taverna-execution-impl/src/main/resources/META-INF/spring/execution-context-osgi.xml
index 87eef58..dffb912 100644
--- a/taverna-execution-impl/src/main/resources/META-INF/spring/execution-context-osgi.xml
+++ b/taverna-execution-impl/src/main/resources/META-INF/spring/execution-context-osgi.xml
@@ -6,8 +6,8 @@
                                  http://www.springframework.org/schema/osgi
                                  http://www.springframework.org/schema/osgi/spring-osgi.xsd">
 
-	<service ref="executionEnvironmentService" interface="uk.org.taverna.platform.execution.api.ExecutionEnvironmentService" />
+	<service ref="executionEnvironmentService" interface="org.apache.taverna.platform.execution.api.ExecutionEnvironmentService" />
 
-	<set id="executionServices" interface="uk.org.taverna.platform.execution.api.ExecutionService" />
+	<set id="executionServices" interface="org.apache.taverna.platform.execution.api.ExecutionService" />
 
 </beans:beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-impl/src/main/resources/META-INF/spring/execution-context.xml
----------------------------------------------------------------------
diff --git a/taverna-execution-impl/src/main/resources/META-INF/spring/execution-context.xml b/taverna-execution-impl/src/main/resources/META-INF/spring/execution-context.xml
index 61f5107..15f8c90 100644
--- a/taverna-execution-impl/src/main/resources/META-INF/spring/execution-context.xml
+++ b/taverna-execution-impl/src/main/resources/META-INF/spring/execution-context.xml
@@ -3,7 +3,7 @@
 	xsi:schemaLocation="http://www.springframework.org/schema/beans
                            http://www.springframework.org/schema/beans/spring-beans.xsd">
 
-	<bean id="executionEnvironmentService" class="uk.org.taverna.platform.execution.impl.ExecutionEnvironmentServiceImpl">
+	<bean id="executionEnvironmentService" class="org.apache.taverna.platform.execution.impl.ExecutionEnvironmentServiceImpl">
 		<property name="executionServices" ref="executionServices" />
 	</bean>
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/LocalExecution.java
----------------------------------------------------------------------
diff --git a/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/LocalExecution.java b/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/LocalExecution.java
new file mode 100644
index 0000000..3fea278
--- /dev/null
+++ b/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/LocalExecution.java
@@ -0,0 +1,242 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.local;
+
+import static java.util.logging.Level.SEVERE;
+import static org.apache.taverna.platform.execution.impl.local.T2ReferenceConverter.convertPathToObject;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.logging.Logger;
+
+import org.apache.taverna.facade.ResultListener;
+import org.apache.taverna.facade.WorkflowInstanceFacade;
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.invocation.TokenOrderException;
+import org.apache.taverna.invocation.WorkflowDataToken;
+import org.apache.taverna.monitor.MonitorManager;
+import org.apache.taverna.provenance.reporter.ProvenanceReporter;
+import org.apache.taverna.reference.ReferenceService;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.workflowmodel.Dataflow;
+import org.apache.taverna.workflowmodel.DataflowInputPort;
+import org.apache.taverna.workflowmodel.Edits;
+import org.apache.taverna.workflowmodel.InvalidDataflowException;
+
+import org.apache.taverna.robundle.Bundle;
+
+import org.apache.taverna.databundle.DataBundles;
+import org.apache.taverna.platform.capability.api.ActivityService;
+import org.apache.taverna.platform.capability.api.DispatchLayerService;
+import org.apache.taverna.platform.execution.api.AbstractExecution;
+import org.apache.taverna.platform.execution.api.InvalidWorkflowException;
+import org.apache.taverna.platform.report.ActivityReport;
+import org.apache.taverna.platform.report.ProcessorReport;
+import org.apache.taverna.platform.report.WorkflowReport;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+/**
+ * An {@link org.apache.taverna.platform.execution.api.Execution Execution} for
+ * executing Taverna workflows on a local Taverna Dataflow Engine.
+ * 
+ * @author David Withers
+ */
+public class LocalExecution extends AbstractExecution implements ResultListener {
+
+	private static Logger logger = Logger.getLogger(LocalExecution.class
+			.getName());
+
+	private final WorkflowToDataflowMapper mapping;
+
+	private final WorkflowInstanceFacade facade;
+
+	private final LocalExecutionMonitor executionMonitor;
+
+	private final ReferenceService referenceService;
+
+	private final Map<String, DataflowInputPort> inputPorts = new HashMap<String, DataflowInputPort>();
+
+	/**
+	 * Constructs an Execution for executing Taverna workflows on a local
+	 * Taverna Dataflow Engine.
+	 * 
+	 * @param workflowBundle
+	 *            the <code>WorkflowBundle</code> containing the
+	 *            <code>Workflow</code>s required for execution
+	 * @param workflow
+	 *            the <code>Workflow</code> to execute
+	 * @param profile
+	 *            the <code>Profile</code> to use when executing the
+	 *            <code>Workflow</code>
+	 * @param dataBundle
+	 *            the <code>Bundle</code> containing the data values for the
+	 *            <code>Workflow</code>
+	 * @param referenceService
+	 *            the <code>ReferenceService</code> used to register inputs,
+	 *            outputs and intermediate values
+	 * @throws InvalidWorkflowException
+	 *             if the specified workflow is invalid
+	 */
+	public LocalExecution(WorkflowBundle workflowBundle, Workflow workflow,
+			Profile profile, Bundle dataBundle,
+			ReferenceService referenceService, Edits edits,
+			ActivityService activityService,
+			DispatchLayerService dispatchLayerService)
+			throws InvalidWorkflowException {
+		super(workflowBundle, workflow, profile, dataBundle);
+		this.referenceService = referenceService;
+		try {
+			mapping = new WorkflowToDataflowMapper(workflowBundle, profile,
+					edits, activityService, dispatchLayerService);
+			Dataflow dataflow = mapping.getDataflow(workflow);
+			for (DataflowInputPort dataflowInputPort : dataflow.getInputPorts())
+				inputPorts.put(dataflowInputPort.getName(), dataflowInputPort);
+			facade = edits.createWorkflowInstanceFacade(dataflow,
+					createContext(), "");
+			executionMonitor = new LocalExecutionMonitor(getWorkflowReport(),
+					getDataBundle(), mapping, facade.getIdentifier());
+		} catch (InvalidDataflowException e) {
+			throw new InvalidWorkflowException(e);
+		}
+	}
+
+	@Override
+	public void delete() {
+		cancel();
+	}
+
+	@Override
+	public void start() {
+		MonitorManager.getInstance().addObserver(executionMonitor);
+		/*
+		 * have to add a result listener otherwise facade doesn't record when
+		 * workflow is finished
+		 */
+		facade.addResultListener(this);
+		facade.fire();
+		try {
+			if (DataBundles.hasInputs(getDataBundle())) {
+				Path inputs = DataBundles.getInputs(getDataBundle());
+				for (Entry<String, DataflowInputPort> inputPort : inputPorts
+						.entrySet()) {
+					String portName = inputPort.getKey();
+					Path path = DataBundles.getPort(inputs, portName);
+					if (!DataBundles.isMissing(path)) {
+						T2Reference identifier = referenceService.register(
+								convertPathToObject(path), inputPort.getValue()
+										.getDepth(), true, null);
+						int[] index = new int[] {};
+						WorkflowDataToken token = new WorkflowDataToken("",
+								index, identifier, facade.getContext());
+						try {
+							facade.pushData(token, portName);
+						} catch (TokenOrderException e) {
+							logger.log(SEVERE, "Unable to push data for input "
+									+ portName, e);
+						}
+					}
+				}
+			}
+		} catch (IOException e) {
+			logger.log(SEVERE, "Error getting input data", e);
+		}
+	}
+
+	@Override
+	public void pause() {
+		facade.pauseWorkflowRun();
+	}
+
+	@Override
+	public void resume() {
+		facade.resumeWorkflowRun();
+	}
+
+	@Override
+	public void cancel() {
+		facade.cancelWorkflowRun();
+		facade.removeResultListener(this);
+		MonitorManager.getInstance().removeObserver(executionMonitor);
+	}
+
+	@Override
+	protected WorkflowReport createWorkflowReport(Workflow workflow) {
+		return new WorkflowReport(workflow);
+	}
+
+	@Override
+	public ProcessorReport createProcessorReport(
+			org.apache.taverna.scufl2.api.core.Processor processor) {
+		return new LocalProcessorReport(processor);
+	}
+
+	@Override
+	public ActivityReport createActivityReport(
+			org.apache.taverna.scufl2.api.activity.Activity activity) {
+		return new ActivityReport(activity);
+	}
+
+	private InvocationContext createContext() {
+		InvocationContext context = new InvocationContext() {
+			private List<Object> entities = Collections
+					.synchronizedList(new ArrayList<Object>());
+
+			@Override
+			public <T> List<T> getEntities(Class<T> entityType) {
+				List<T> entitiesOfType = new ArrayList<>();
+				synchronized (entities) {
+					for (Object entity : entities)
+						if (entityType.isInstance(entity))
+							entitiesOfType.add(entityType.cast(entity));
+				}
+				return entitiesOfType;
+			}
+
+			@Override
+			public void addEntity(Object entity) {
+				entities.add(entity);
+			}
+
+			@Override
+			public ReferenceService getReferenceService() {
+				return referenceService;
+			}
+
+			@Override
+			public ProvenanceReporter getProvenanceReporter() {
+				return null;
+			}
+
+		};
+		return context;
+	}
+
+	@Override
+	public void resultTokenProduced(WorkflowDataToken token, String portName) {
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/LocalExecutionEnvironment.java
----------------------------------------------------------------------
diff --git a/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/LocalExecutionEnvironment.java b/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/LocalExecutionEnvironment.java
new file mode 100644
index 0000000..da41b13
--- /dev/null
+++ b/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/LocalExecutionEnvironment.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.local;
+
+import java.net.URI;
+import java.util.Set;
+
+import org.apache.taverna.platform.capability.api.ActivityConfigurationException;
+import org.apache.taverna.platform.capability.api.ActivityNotFoundException;
+import org.apache.taverna.platform.capability.api.ActivityService;
+import org.apache.taverna.platform.capability.api.DispatchLayerConfigurationException;
+import org.apache.taverna.platform.capability.api.DispatchLayerNotFoundException;
+import org.apache.taverna.platform.capability.api.DispatchLayerService;
+import org.apache.taverna.platform.execution.api.AbstractExecutionEnvironment;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * Execution Environment for a local Taverna Dataflow Engine
+ *
+ * @author David Withers
+ */
+public class LocalExecutionEnvironment extends AbstractExecutionEnvironment {
+
+	private final ActivityService activityService;
+	private final DispatchLayerService dispatchLayerService;
+
+	public LocalExecutionEnvironment(LocalExecutionService localExecutionService,
+			ActivityService activityService, DispatchLayerService dispatchLayerService) {
+		super(LocalExecutionEnvironment.class.getName(), "Taverna Local Execution Environment",
+				"Execution Environment for a local Taverna Dataflow Engine", localExecutionService);
+		this.activityService = activityService;
+		this.dispatchLayerService = dispatchLayerService;
+	}
+
+	@Override
+	public Set<URI> getActivityTypes() {
+		return activityService.getActivityTypes();
+	}
+
+	@Override
+	public boolean activityExists(URI uri) {
+		return activityService.activityExists(uri);
+	}
+
+	@Override
+	public JsonNode getActivityConfigurationSchema(URI uri)
+			throws ActivityNotFoundException, ActivityConfigurationException {
+		return activityService.getActivityConfigurationSchema(uri);
+	}
+
+	@Override
+	public Set<URI> getDispatchLayerTypes() {
+		return dispatchLayerService.getDispatchLayerTypes();
+	}
+
+	@Override
+	public boolean dispatchLayerExists(URI uri) {
+		return dispatchLayerService.dispatchLayerExists(uri);
+	}
+
+	@Override
+	public JsonNode getDispatchLayerConfigurationSchema(URI uri)
+			throws DispatchLayerNotFoundException, DispatchLayerConfigurationException {
+		return dispatchLayerService.getDispatchLayerConfigurationSchema(uri);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/LocalExecutionMonitor.java
----------------------------------------------------------------------
diff --git a/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/LocalExecutionMonitor.java b/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/LocalExecutionMonitor.java
new file mode 100755
index 0000000..f14be54
--- /dev/null
+++ b/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/LocalExecutionMonitor.java
@@ -0,0 +1,547 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.local;
+
+import static java.util.logging.Level.SEVERE;
+import static java.util.logging.Level.WARNING;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.UUID;
+import java.util.logging.Logger;
+
+import org.apache.taverna.facade.ResultListener;
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.invocation.WorkflowDataToken;
+import org.apache.taverna.lang.observer.Observable;
+import org.apache.taverna.lang.observer.Observer;
+import org.apache.taverna.monitor.MonitorManager.AddPropertiesMessage;
+import org.apache.taverna.monitor.MonitorManager.DeregisterNodeMessage;
+import org.apache.taverna.monitor.MonitorManager.MonitorMessage;
+import org.apache.taverna.monitor.MonitorManager.RegisterNodeMessage;
+import org.apache.taverna.monitor.MonitorableProperty;
+import org.apache.taverna.reference.ErrorDocument;
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.IdentifiedList;
+import org.apache.taverna.reference.ReferenceService;
+import org.apache.taverna.reference.ReferenceServiceException;
+import org.apache.taverna.reference.ReferenceSet;
+import org.apache.taverna.reference.StackTraceElementBean;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.T2ReferenceType;
+import org.apache.taverna.reference.impl.external.file.FileReference;
+import org.apache.taverna.reference.impl.external.http.HttpReference;
+import org.apache.taverna.workflowmodel.Dataflow;
+import org.apache.taverna.workflowmodel.DataflowOutputPort;
+import org.apache.taverna.workflowmodel.Processor;
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchJobEvent;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchResultEvent;
+
+import org.apache.taverna.robundle.Bundle;
+
+import org.apache.taverna.databundle.DataBundles;
+import org.apache.taverna.platform.execution.api.InvalidWorkflowException;
+import org.apache.taverna.platform.report.ActivityReport;
+import org.apache.taverna.platform.report.Invocation;
+import org.apache.taverna.platform.report.ProcessorReport;
+import org.apache.taverna.platform.report.StatusReport;
+import org.apache.taverna.platform.report.WorkflowReport;
+
+/**
+ * A workflow monitor for local executions.
+ * 
+ * @author David Withers
+ */
+public class LocalExecutionMonitor implements Observer<MonitorMessage> {
+	private static final Logger logger = Logger
+			.getLogger(LocalExecutionMonitor.class.getName());
+	private static final String ID_SEPARATOR = "/";
+
+	private Map<String, StatusReport<?, ?>> reports;
+	private Map<String, Invocation> invocations;
+	private Map<String, String> invocationToActivity;
+	private Map<T2Reference, Path> referenceToPath;
+	private final String facadeId;
+	private final Bundle dataBundle;
+
+	public LocalExecutionMonitor(WorkflowReport workflowReport,
+			Bundle dataBundle, WorkflowToDataflowMapper mapping, String facadeId)
+			throws InvalidWorkflowException {
+		this.dataBundle = dataBundle;
+		this.facadeId = facadeId;
+		reports = new HashMap<>();
+		invocations = new HashMap<>();
+		invocationToActivity = new HashMap<>();
+		referenceToPath = new HashMap<>();
+		mapReports("", workflowReport, mapping);
+	}
+
+	private void mapReports(String id, WorkflowReport workflowReport,
+			WorkflowToDataflowMapper mapping) throws InvalidWorkflowException {
+		Dataflow dataflow = mapping.getDataflow(workflowReport.getSubject());
+		String dataflowId = null;
+		if (id.isEmpty()) {
+			dataflowId = dataflow.getLocalName();
+		} else {
+			dataflowId = id + ID_SEPARATOR + dataflow.getLocalName();
+		}
+		reports.put(dataflowId, workflowReport);
+		for (ProcessorReport processorReport : workflowReport
+				.getProcessorReports()) {
+			Processor processor = mapping.getDataflowProcessor(processorReport
+					.getSubject());
+			String processorId = dataflowId + ID_SEPARATOR
+					+ processor.getLocalName();
+			reports.put(processorId, (LocalProcessorReport) processorReport);
+			for (ActivityReport activityReport : processorReport
+					.getActivityReports()) {
+				Activity<?> activity = mapping
+						.getDataflowActivity(activityReport.getSubject());
+				String activityId = processorId + ID_SEPARATOR
+						+ activity.hashCode();
+				reports.put(activityId, activityReport);
+				WorkflowReport nestedWorkflowReport = activityReport
+						.getNestedWorkflowReport();
+				if (nestedWorkflowReport != null)
+					mapReports(activityId, nestedWorkflowReport, mapping);
+			}
+		}
+	}
+
+	@Override
+	public void notify(Observable<MonitorMessage> sender, MonitorMessage message)
+			throws Exception {
+		String[] owningProcess = message.getOwningProcess();
+		if (owningProcess.length > 0 && owningProcess[0].equals(facadeId)) {
+			if (message instanceof RegisterNodeMessage) {
+				RegisterNodeMessage regMessage = (RegisterNodeMessage) message;
+				registerNode(regMessage.getWorkflowObject(), owningProcess,
+						regMessage.getProperties());
+			} else if (message instanceof DeregisterNodeMessage) {
+				deregisterNode(owningProcess);
+			} else if (message instanceof AddPropertiesMessage) {
+				AddPropertiesMessage addMessage = (AddPropertiesMessage) message;
+				addPropertiesToNode(owningProcess,
+						addMessage.getNewProperties());
+			} else {
+				logger.warning("Unknown message " + message + " from " + sender);
+			}
+		}
+	}
+
+	public void registerNode(Object dataflowObject, String[] owningProcess,
+			Set<MonitorableProperty<?>> properties) {
+		if (dataflowObject instanceof Dataflow) {
+			Dataflow dataflow = (Dataflow) dataflowObject;
+			Invocation parentInvocation = invocations
+					.get(getParentInvocationId(owningProcess));
+			WorkflowReport report = (WorkflowReport) reports
+					.get(getReportId(owningProcess));
+			report.setStartedDate(new Date());
+			Invocation invocation = new Invocation(
+					getInvocationName(owningProcess), parentInvocation, report);
+			if (parentInvocation == null) {
+				if (DataBundles.hasInputs(dataBundle)) {
+					try {
+						invocation.setInputs(DataBundles.getPorts(DataBundles
+								.getInputs(dataBundle)));
+					} catch (IOException e) {
+						logger.log(WARNING, "Error setting input ports", e);
+					}
+				}
+				try {
+					Path outputs = DataBundles.getOutputs(dataBundle);
+					DataflowResultListener dataflowResultListener = new DataflowResultListener(
+							outputs);
+					for (DataflowOutputPort dataflowOutputPort : dataflow
+							.getOutputPorts()) {
+						String portName = dataflowOutputPort.getName();
+						Path portPath = DataBundles.getPort(outputs, portName);
+						invocation.setOutput(portName, portPath);
+						dataflowOutputPort
+								.addResultListener(dataflowResultListener);
+					}
+				} catch (IOException e) {
+					logger.log(WARNING, "Error setting output ports", e);
+				}
+				invocations.put(getInvocationId(owningProcess), invocation);
+			} else {
+				invocation.setInputs(parentInvocation.getInputs());
+				NestedDataflowResultListener resultListener = new NestedDataflowResultListener(
+						invocation);
+				for (DataflowOutputPort dataflowOutputPort : dataflow
+						.getOutputPorts()) {
+					dataflowOutputPort.addResultListener(resultListener);
+				}
+				invocations.put(getInvocationId(owningProcess), invocation);
+			}
+		} else if (dataflowObject instanceof Processor) {
+			StatusReport<?, ?> report = reports.get(getReportId(owningProcess));
+			report.setStartedDate(new Date());
+			if (report instanceof LocalProcessorReport)
+				((LocalProcessorReport) report).addProperties(properties);
+		} else if (dataflowObject instanceof Activity) {
+			Activity<?> activity = (Activity<?>) dataflowObject;
+			invocationToActivity.put(owningProcess[owningProcess.length - 1],
+					String.valueOf(activity.hashCode()));
+		} else if (dataflowObject instanceof DispatchJobEvent) {
+			DispatchJobEvent jobEvent = (DispatchJobEvent) dataflowObject;
+			StatusReport<?, ?> report = reports.get(getReportId(owningProcess));
+			// create a new invocation
+			Invocation parentInvocation;
+			Invocation invocation;
+
+			if (report instanceof ActivityReport) {
+				parentInvocation = invocations
+						.get(getParentInvocationId(owningProcess)
+								+ indexToString(jobEvent.getIndex()));
+				invocation = new Invocation(getInvocationName(owningProcess),
+						jobEvent.getIndex(), parentInvocation, report);
+				invocations.put(getInvocationId(owningProcess), invocation);
+			} else {
+				parentInvocation = invocations
+						.get(getParentInvocationId(owningProcess));
+				invocation = new Invocation(getInvocationName(owningProcess)
+						+ indexToString(jobEvent.getIndex()),
+						jobEvent.getIndex(), parentInvocation, report);
+				invocations.put(getInvocationId(owningProcess)
+						+ indexToString(jobEvent.getIndex()), invocation);
+			}
+			// set the invocation inputs
+			try {
+				for (Entry<String, T2Reference> inputInfo : jobEvent.getData()
+						.entrySet()) {
+					invocation.setInput(
+							inputInfo.getKey(),
+							getIntermediate(inputInfo.getValue(),
+									jobEvent.getContext()));
+				}
+			} catch (IOException | URISyntaxException e) {
+				logger.log(WARNING, "Error saving intermediate inputs for "
+						+ jobEvent.getOwningProcess(), e);
+			}
+
+		} else if (dataflowObject instanceof DispatchResultEvent) {
+			DispatchResultEvent resultEvent = (DispatchResultEvent) dataflowObject;
+			StatusReport<?, ?> report = reports.get(getReportId(owningProcess));
+			// find the invocation
+			Invocation invocation;
+			if (report instanceof ActivityReport)
+				invocation = invocations.remove(getInvocationId(owningProcess));
+			else
+				invocation = invocations.remove(getInvocationId(owningProcess)
+						+ indexToString(resultEvent.getIndex()));
+
+			if (invocation == null) {
+				logger.log(SEVERE, "Can't find invocation for owning process "
+						+ owningProcess);
+				return;
+			}
+
+			// set the invocation outputs
+			try {
+				for (Entry<String, T2Reference> outputInfo : resultEvent.getData()
+						.entrySet()) {
+					invocation.setOutput(
+							outputInfo.getKey(),
+							getIntermediate(outputInfo.getValue(),
+									resultEvent.getContext()));
+				}
+			} catch (IOException | URISyntaxException e) {
+				logger.log(WARNING, "Error saving intermediate outputs for "
+						+ resultEvent.getOwningProcess(), e);
+			}
+			invocation.setCompletedDate(new Date());
+		}
+	}
+
+	public void deregisterNode(String[] owningProcess) {
+		StatusReport<?, ?> report = reports.get(getReportId(owningProcess));
+		if (report == null) {
+			return;
+		} else if (report instanceof WorkflowReport) {
+			Invocation invocation = invocations
+					.remove(getInvocationId(owningProcess));
+			invocation.setCompletedDate(new Date());
+			report.setCompletedDate(new Date());
+		} else if (report instanceof LocalProcessorReport) {
+			((LocalProcessorReport) report).saveProperties();
+			report.setCompletedDate(new Date());
+		} else if (report instanceof ActivityReport) {
+			// Invocation may still exist if the activity failed
+			Invocation invocation = invocations
+					.remove(getInvocationId(owningProcess));
+			if (invocation != null) {
+				invocation.setCompletedDate(new Date());
+				report.setFailedDate(new Date());
+			} else
+				report.setCompletedDate(new Date());
+			invocationToActivity
+					.remove(owningProcess[owningProcess.length - 1]);
+		}
+	}
+
+	public void addPropertiesToNode(String[] owningProcess,
+			Set<MonitorableProperty<?>> newProperties) {
+		StatusReport<?, ?> report = reports.get(getReportId(owningProcess));
+		if (report instanceof LocalProcessorReport) {
+			LocalProcessorReport processorReport = (LocalProcessorReport) report;
+			processorReport.addProperties(newProperties);
+		}
+	}
+
+	private String getParentInvocationId(String[] owningProcess) {
+		List<String> id = new ArrayList<>();
+		for (int i = 1; i < owningProcess.length - 1; i++)
+			if (i % 4 != 0)
+				id.add(owningProcess[i]);
+		return toPath(id);
+	}
+
+	private String getInvocationId(String[] owningProcess) {
+		List<String> id = new ArrayList<>();
+		for (int i = 1; i < owningProcess.length; i++)
+			if (i % 4 != 0)
+				id.add(owningProcess[i]);
+		return toPath(id);
+	}
+
+	private String getInvocationName(String[] owningProcess) {
+		return owningProcess[owningProcess.length - 1];
+	}
+
+	private String toPath(List<String> id) {
+		StringBuilder sb = new StringBuilder();
+		String sep = "";
+		for (String string : id) {
+			sb.append(sep).append(string);
+			sep = ID_SEPARATOR;
+		}
+		return sb.toString();
+	}
+
+	private String getReportId(String[] owningProcess) {
+		List<String> id = new ArrayList<>();
+		for (int i = 1, position = 0; i < owningProcess.length; i++) {
+			if (i % 4 == 0)
+				continue;
+			if (position == 2) {
+				id.add(invocationToActivity.get(owningProcess[i]));
+				position = 0;
+			} else {
+				id.add(owningProcess[i]);
+				position++;
+			}
+		}
+		return toPath(id);
+	}
+
+	public String getProcessorId(String[] owningProcess) {
+		StringBuffer sb = new StringBuffer();
+		for (int i = 1, skip = 0; i < owningProcess.length; i++, skip--)
+			if (i <= 2 || skip < 0) {
+				sb.append(owningProcess[i]);
+				skip = 3;
+			}
+		return sb.toString();
+	}
+
+	private String indexToString(int[] index) {
+		StringBuilder indexString = new StringBuilder();
+		for (int i = 0; i < index.length; i++) {
+			if (i != 0)
+				indexString.append(":");
+			indexString.append(index[i] + 1);
+		}
+		return indexString.toString();
+	}
+
+	private Path getIntermediate(T2Reference t2Reference,
+			InvocationContext context) throws IOException, URISyntaxException {
+		if (referenceToPath.containsKey(t2Reference))
+			return referenceToPath.get(t2Reference);
+
+		Path path = referencePath(t2Reference);
+		convertReferenceToPath(path, t2Reference, context);
+		referenceToPath.put(t2Reference, path);
+		return path;
+	}
+
+	private Path referencePath(T2Reference t2Reference) throws IOException {
+		String local = t2Reference.getLocalPart();
+		try {
+			return DataBundles.getIntermediate(dataBundle,
+					UUID.fromString(local));
+		} catch (IllegalArgumentException ex) {
+			return DataBundles.getIntermediates(dataBundle)
+					.resolve(t2Reference.getNamespacePart())
+					.resolve(t2Reference.getLocalPart());
+		}
+	}
+
+	public static String getStackTraceElementString(
+			StackTraceElementBean stackTraceElement) {
+		StringBuilder sb = new StringBuilder();
+		sb.append(stackTraceElement.getClassName()).append('.')
+				.append(stackTraceElement.getMethodName());
+		if (stackTraceElement.getFileName() == null) {
+			sb.append("(unknown file)");
+		} else {
+			sb.append('(').append(stackTraceElement.getFileName()).append(':')
+					.append(stackTraceElement.getLineNumber()).append(')');
+		}
+		return sb.toString();
+	}
+
+	public void convertReferenceToPath(Path path, T2Reference reference,
+			InvocationContext context) throws IOException, URISyntaxException {
+		ReferenceService referenceService = context.getReferenceService();
+		if (reference.getReferenceType() == T2ReferenceType.ReferenceSet) {
+			if (DataBundles.isMissing(path)) {
+				ReferenceSet rs = referenceService.getReferenceSetService()
+						.getReferenceSet(reference);
+				if (rs == null)
+					throw new ReferenceServiceException(
+							"Could not find ReferenceSet " + reference);
+				// Check that there are references in the set
+				if (rs.getExternalReferences().isEmpty())
+					throw new ReferenceServiceException("ReferenceSet "
+							+ reference + " is empty");
+
+				for (ExternalReferenceSPI ers : rs.getExternalReferences()) {
+					if (ers instanceof FileReference) {
+						URI uri = ((FileReference) ers).getFile().toURI();
+						DataBundles.setReference(path, uri);
+					} else if (ers instanceof HttpReference) {
+						URI uri = ((HttpReference) ers).getHttpUrl().toURI();
+						DataBundles.setReference(path, uri);
+					} else {
+						try (InputStream in = ers.openStream(context)) {
+							Files.copy(in, path);
+						}
+					}
+				}
+			}
+		} else if (reference.getReferenceType() == T2ReferenceType.ErrorDocument) {
+			if (DataBundles.isMissing(path)) {
+				ErrorDocument errorDocument = referenceService
+						.getErrorDocumentService().getError(reference);
+				String message = errorDocument.getMessage();
+				StringBuilder trace = new StringBuilder();
+				if (errorDocument.getExceptionMessage() != null
+						&& !errorDocument.getExceptionMessage().isEmpty()) {
+					trace.append(errorDocument.getExceptionMessage());
+					trace.append("\n");
+				}
+				List<StackTraceElementBean> stackTraceStrings = errorDocument
+						.getStackTraceStrings();
+				for (StackTraceElementBean stackTraceElement : stackTraceStrings) {
+					trace.append(getStackTraceElementString(stackTraceElement));
+					trace.append("\n");
+				}
+				List<Path> causes = new ArrayList<>();
+				for (T2Reference errorReference : errorDocument
+						.getErrorReferences())
+					causes.add(getIntermediate(errorReference, context));
+				DataBundles.setError(path, message, trace.toString(),
+						causes.toArray(new Path[causes.size()]));
+			}
+		} else { // it is an IdentifiedList<T2Reference>
+			IdentifiedList<T2Reference> identifiedList = referenceService
+					.getListService().getList(reference);
+			if (!DataBundles.isList(path))
+				DataBundles.createList(path);
+			for (T2Reference ref : identifiedList)
+				convertReferenceToPath(DataBundles.newListItem(path), ref,
+						context);
+		}
+	}
+
+	private class NestedDataflowResultListener implements ResultListener {
+		private final Invocation invocation;
+
+		public NestedDataflowResultListener(Invocation invocation) {
+			this.invocation = invocation;
+		}
+
+		@Override
+		public void resultTokenProduced(WorkflowDataToken token, String portName) {
+			try {
+				if (token.isFinal())
+					invocation
+							.setOutput(
+									portName,
+									getIntermediate(token.getData(),
+											token.getContext()));
+			} catch (IOException | URISyntaxException e) {
+				logger.log(SEVERE, "Unable to convert T2Reference", e);
+			}
+		}
+
+	}
+
+	private class DataflowResultListener implements ResultListener {
+		private Path outputs;
+		private Map<String, Integer> depthSeen = new HashMap<>();
+
+		public DataflowResultListener(Path outputs) {
+			this.outputs = outputs;
+		}
+
+		@Override
+		public void resultTokenProduced(WorkflowDataToken token, String portName) {
+			Integer depth = depthSeen.get(portName);
+			if (depth == null || depth.equals(token.getIndex().length)) {
+				if (depth == null)
+					depthSeen.put(portName, token.getIndex().length);
+				try {
+					Path port = DataBundles.getPort(outputs, portName);
+					Path path = getPath(port, 0, token.getIndex());
+					convertReferenceToPath(path, token.getData(),
+							token.getContext());
+				} catch (IOException | URISyntaxException e) {
+					logger.log(SEVERE, "Unable to convert T2Reference", e);
+				}
+			}
+		}
+
+		private Path getPath(Path path, int depth, int[] index)
+				throws IOException {
+			if (depth == index.length)
+				return path;
+			if (!DataBundles.isList(path))
+				DataBundles.createList(path);
+			return getPath(DataBundles.getListItem(path, index[depth]),
+					depth + 1, index);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/LocalExecutionService.java
----------------------------------------------------------------------
diff --git a/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/LocalExecutionService.java b/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/LocalExecutionService.java
new file mode 100644
index 0000000..436aa12
--- /dev/null
+++ b/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/LocalExecutionService.java
@@ -0,0 +1,148 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.local;
+
+import java.net.URI;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.WeakHashMap;
+
+import org.apache.taverna.reference.ReferenceService;
+import org.apache.taverna.workflowmodel.Dataflow;
+import org.apache.taverna.workflowmodel.Edits;
+
+import org.apache.taverna.robundle.Bundle;
+
+import org.apache.taverna.platform.capability.api.ActivityService;
+import org.apache.taverna.platform.capability.api.DispatchLayerService;
+import org.apache.taverna.platform.execution.api.AbstractExecutionService;
+import org.apache.taverna.platform.execution.api.Execution;
+import org.apache.taverna.platform.execution.api.ExecutionEnvironment;
+import org.apache.taverna.platform.execution.api.InvalidWorkflowException;
+import org.apache.taverna.platform.execution.api.WorkflowCompiler;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+/**
+ * Service for executing Taverna workflows on a local Taverna Dataflow Engine.
+ *
+ * @author David Withers
+ */
+public class LocalExecutionService extends AbstractExecutionService implements
+		WorkflowCompiler {
+	private Edits edits;
+	private ActivityService activityService;
+	private DispatchLayerService dispatchLayerService;
+	private ReferenceService referenceService;
+
+	/**
+	 * Constructs an execution service that executes workflows using the T2
+	 * dataflow engine.
+	 */
+	public LocalExecutionService() {
+		super(
+				LocalExecutionService.class.getName(),
+				"Taverna Local Execution Service",
+				"Execution Service for executing Taverna workflows using a local Taverna Dataflow Engine");
+	}
+
+	@Override
+	public Set<ExecutionEnvironment> getExecutionEnvironments() {
+		Set<ExecutionEnvironment> executionEnvironments = new HashSet<>();
+		executionEnvironments.add(new LocalExecutionEnvironment(this,
+				activityService, dispatchLayerService));
+		return executionEnvironments;
+	}
+
+	@Override
+	protected Execution createExecutionImpl(WorkflowBundle workflowBundle,
+			Workflow workflow, Profile profile, Bundle dataBundle)
+			throws InvalidWorkflowException {
+		return new LocalExecution(workflowBundle, workflow, profile,
+				dataBundle, referenceService, edits, activityService,
+				dispatchLayerService);
+	}
+
+	/**
+	 * Sets the Edits Service for creating Taverna Dataflows.
+	 *
+	 * @param edits
+	 *            the Edits Service for creating Taverna Dataflows
+	 */
+	public void setEdits(Edits edits) {
+		this.edits = edits;
+	}
+
+	/**
+	 * Sets the service for creating activities.
+	 *
+	 * @param activityService
+	 *            the service for creating activities
+	 */
+	public void setActivityService(ActivityService activityService) {
+		this.activityService = activityService;
+	}
+
+	/**
+	 * Sets the service for creating dispatch layers.
+	 *
+	 * @param dispatchLayerService
+	 *            the service for creating dispatch layers
+	 */
+	public void setDispatchLayerService(DispatchLayerService dispatchLayerService) {
+		this.dispatchLayerService = dispatchLayerService;
+	}
+
+	/**
+	 * Sets the reference service.
+	 *
+	 * @param referenceService
+	 *            the reference service
+	 */
+	public void setReferenceService(ReferenceService referenceService) {
+		this.referenceService = referenceService;
+	}
+
+	private WeakHashMap<URI, WorkflowToDataflowMapper> cache = new WeakHashMap<>();
+
+	private synchronized WorkflowToDataflowMapper getMapper(
+			WorkflowBundle bundle) {
+		WorkflowToDataflowMapper m = cache.get(bundle.getIdentifier());
+		if (m == null) {
+			m = new WorkflowToDataflowMapper(bundle, bundle.getMainProfile(),
+					edits, activityService, dispatchLayerService);
+			cache.put(bundle.getIdentifier(), m);
+		}
+		return m;
+	}
+
+	@Override
+	public Dataflow getDataflow(Workflow workflow)
+			throws InvalidWorkflowException {
+		return getMapper(workflow.getParent()).getDataflow(workflow);
+	}
+
+	@Override
+	public synchronized Dataflow getDataflow(WorkflowBundle bundle)
+			throws InvalidWorkflowException {
+		return getMapper(bundle).getDataflow(bundle.getMainWorkflow());
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/LocalProcessorReport.java
----------------------------------------------------------------------
diff --git a/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/LocalProcessorReport.java b/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/LocalProcessorReport.java
new file mode 100644
index 0000000..7ffa31b
--- /dev/null
+++ b/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/LocalProcessorReport.java
@@ -0,0 +1,160 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.local;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.apache.taverna.monitor.MonitorableProperty;
+import org.apache.taverna.monitor.NoSuchPropertyException;
+import org.apache.taverna.monitor.SteerableProperty;
+import org.apache.taverna.platform.report.ProcessorReport;
+import org.apache.taverna.scufl2.api.core.Processor;
+
+/**
+ * ProcessorReport implementation based on MonitorableProperty objects.
+ * 
+ * @author David Withers
+ */
+public class LocalProcessorReport extends ProcessorReport {
+	private static final String DISPATCH_ERRORBOUNCE_TOTAL_TRANSLATED = "dispatch:errorbounce:totalTranslated";
+	private static final String DISPATCH_PARALLELIZE_COMPLETEDJOBS = "dispatch:parallelize:completedjobs";
+	private static final String DISPATCH_PARALLELIZE_SENTJOBS = "dispatch:parallelize:sentjobs";
+	private static final String DISPATCH_PARALLELIZE_QUEUESIZE = "dispatch:parallelize:queuesize";
+
+	private Map<String, MonitorableProperty<?>> propertyMap;
+
+	public LocalProcessorReport(Processor processor) {
+		super(processor);
+		propertyMap = new HashMap<String, MonitorableProperty<?>>();
+	}
+
+	public void addProperties(Set<MonitorableProperty<?>> properties) {
+		for (MonitorableProperty<?> property : properties) {
+			propertyMap.put(getPropertyName(property), property);
+		}
+	}
+
+	public void saveProperties() {
+		for (Entry<String, MonitorableProperty<?>> entry : propertyMap
+				.entrySet())
+			entry.setValue(new StaticProperty(entry.getValue()));
+	}
+
+	@Override
+	public int getJobsQueued() {
+		int result = -1;
+		MonitorableProperty<?> property = propertyMap
+				.get(DISPATCH_PARALLELIZE_QUEUESIZE);
+		try {
+			if (property != null)
+				result = (Integer) property.getValue();
+		} catch (NoSuchPropertyException e) {
+		}
+		return result;
+	}
+
+	@Override
+	public int getJobsStarted() {
+		int result = -1;
+		MonitorableProperty<?> property = propertyMap
+				.get(DISPATCH_PARALLELIZE_SENTJOBS);
+		if (property != null) {
+			try {
+				result = (Integer) property.getValue();
+			} catch (NoSuchPropertyException e) {
+			}
+		}
+		return result;
+	}
+
+	@Override
+	public int getJobsCompleted() {
+		int result = -1;
+		MonitorableProperty<?> property = propertyMap
+				.get(DISPATCH_PARALLELIZE_COMPLETEDJOBS);
+		try {
+			if (property != null)
+				result = (Integer) property.getValue();
+		} catch (NoSuchPropertyException e) {
+		}
+		return result;
+	}
+
+	@Override
+	public int getJobsCompletedWithErrors() {
+		int result = -1;
+		MonitorableProperty<?> property = propertyMap
+				.get(DISPATCH_ERRORBOUNCE_TOTAL_TRANSLATED);
+		try {
+			if (property != null)
+				result = (Integer) property.getValue();
+		} catch (NoSuchPropertyException e) {
+		}
+		return result;
+	}
+
+	@Override
+	public Set<String> getPropertyKeys() {
+		if (!propertyMap.isEmpty())
+			return new HashSet<>(propertyMap.keySet());
+		return super.getPropertyKeys();
+	}
+
+	@Override
+	public Object getProperty(String key) {
+		Object result = null;
+		MonitorableProperty<?> property = propertyMap.get(key);
+		try {
+			if (property != null)
+				result = property.getValue();
+		} catch (NoSuchPropertyException e) {
+		}
+		return result;
+	}
+
+	@Override
+	public void setProperty(String key, Object value) {
+		MonitorableProperty<?> monitorableProperty = propertyMap.get(key);
+		if (monitorableProperty instanceof SteerableProperty<?>) {
+			@SuppressWarnings("unchecked")
+			SteerableProperty<Object> steerableProperty = (SteerableProperty<Object>) monitorableProperty;
+			try {
+				steerableProperty.setProperty(value);
+			} catch (NoSuchPropertyException e) {
+			}
+		}
+	}
+
+	private String getPropertyName(MonitorableProperty<?> property) {
+		StringBuilder sb = new StringBuilder();
+		String[] name = property.getName();
+		for (int i = 0; i < name.length; i++) {
+			if (i > 0)
+				sb.append(':');
+			sb.append(name[i]);
+		}
+		return sb.toString();
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/StaticProperty.java
----------------------------------------------------------------------
diff --git a/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/StaticProperty.java b/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/StaticProperty.java
new file mode 100755
index 0000000..135a008
--- /dev/null
+++ b/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/StaticProperty.java
@@ -0,0 +1,65 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.local;
+
+import java.util.Date;
+
+import org.apache.taverna.monitor.MonitorableProperty;
+import org.apache.taverna.monitor.NoSuchPropertyException;
+
+/**
+ * A MonitorableProperty with fixed values.
+ * 
+ * @author David Withers
+ */
+public class StaticProperty implements MonitorableProperty<Object> {
+	private Object value;
+	private String[] name;
+	private Date lastModified;
+	
+	/**
+	 * Records the state of the MonitorableProperty.
+	 * 
+	 * @param property
+	 */
+	public StaticProperty(MonitorableProperty<?> property) {
+		try {
+			value = property.getValue();
+		} catch (NoSuchPropertyException e) {
+		}
+		name = property.getName();
+		lastModified = property.getLastModified();
+	}
+	
+	@Override
+	public Object getValue() throws NoSuchPropertyException {
+		return value;
+	}
+
+	@Override
+	public String[] getName() {
+		return name;
+	}
+
+	@Override
+	public Date getLastModified() {
+		return lastModified;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/T2ReferenceConverter.java
----------------------------------------------------------------------
diff --git a/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/T2ReferenceConverter.java b/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/T2ReferenceConverter.java
new file mode 100644
index 0000000..69c40b2
--- /dev/null
+++ b/taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/T2ReferenceConverter.java
@@ -0,0 +1,57 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.local;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.taverna.databundle.DataBundles;
+
+/**
+ * @author David Withers
+ */
+public class T2ReferenceConverter {
+	public static Object convertPathToObject(Path path) throws IOException {
+		Object object = null;
+		if (DataBundles.isValue(path)) {
+			object = DataBundles.getStringValue(path);
+		} else if (DataBundles.isReference(path)) {
+			URI reference = DataBundles.getReference(path);
+			String scheme = reference.getScheme();
+			if ("file".equals(scheme)) {
+				object = new File(reference);
+			} else {
+				object = reference.toURL();
+			}
+		} else if (DataBundles.isList(path)) {
+			List<Path> list = DataBundles.getList(path);
+			List<Object> objectList = new ArrayList<Object>(list.size());
+			for (Path pathElement : list) {
+				objectList.add(convertPathToObject(pathElement));
+			}
+			object = objectList;
+		}
+		return object;
+	}
+}


[24/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/ProcessIdentifierException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/ProcessIdentifierException.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/ProcessIdentifierException.java
deleted file mode 100644
index 93cc35a..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/ProcessIdentifierException.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.invocation;
-
-/**
- * Thrown when attempting to create an invalid process identifier, either by
- * popping an empty one (this by definition has no parents) or by pushing a
- * local name including a colon ':' character.
- * 
- * @author Tom Oinn
- */
-public class ProcessIdentifierException extends RuntimeException {
-	private static final long serialVersionUID = -221443591753067425L;
-
-	public ProcessIdentifierException() {
-		super();
-	}
-
-	public ProcessIdentifierException(String message, Throwable cause) {
-		super(message, cause);
-	}
-
-	public ProcessIdentifierException(String message) {
-		super(message);
-	}
-
-	public ProcessIdentifierException(Throwable cause) {
-		super(cause);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/TokenOrderException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/TokenOrderException.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/TokenOrderException.java
deleted file mode 100644
index 2754e03..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/TokenOrderException.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.invocation;
-
-/**
- * Thrown when tokens are supplied in an invalid order. Examples of this are
- * where duplicate indices are supplied in the same token stream or where list
- * items are emitted at a point where the individual members haven't been fully
- * populated.
- * 
- * @author Tom Oinn
- */
-public class TokenOrderException extends Exception {
-	public TokenOrderException() {
-		super();
-	}
-
-	public TokenOrderException(String arg0, Throwable arg1) {
-		super(arg0, arg1);
-	}
-
-	public TokenOrderException(String arg0) {
-		super(arg0);
-	}
-
-	public TokenOrderException(Throwable arg0) {
-		super(arg0);
-	}
-
-	private static final long serialVersionUID = -7870614853928171878L;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/TreeCache.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/TreeCache.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/TreeCache.java
deleted file mode 100644
index 0279bdf..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/TreeCache.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.invocation;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sf.taverna.t2.workflowmodel.processor.activity.Job;
-
-/**
- * Tree cache for jobs waiting to be combined and dispatched down the iteration
- * system
- * 
- * @author Tom Oinn
- */
-public class TreeCache {
-	private NamedNode root = null;
-	private int indexDepth = -1;
-
-	/**
-	 * Show the tree structure, printing each node recursively
-	 */
-	@Override
-	public synchronized String toString() {
-		if (root == null)
-			return "No root node defined.";
-		StringBuilder sb = new StringBuilder();
-		printNode(root, sb, "");
-		return sb.toString();
-	}
-	
-	private synchronized void printNode(NamedNode node, StringBuilder sb, String indent) {
-		sb.append(indent).append("Node (").append(node.contents).append(")\n");
-		String newIndent = indent + "  ";
-		for (NamedNode child : node.children)
-			if (child == null)
-				sb.append(newIndent).append("null\n");
-			else
-				printNode(child, sb, newIndent);
-	}
-	
-	public class NamedNode {
-		public Job contents = null;
-		public List<NamedNode> children = new ArrayList<>();
-
-		public void insertJob(Job j) {
-			insertJobAt(j, j.getIndex());
-		}
-
-		private void insertJobAt(Job j, int[] position) {
-			if (position.length == 0) {
-				this.contents = j;
-				return;
-			}
-			int firstIndex = position[0];
-			if (firstIndex >= children.size())
-				// Pad with blank NamedNode objects
-				for (int i = children.size(); i <= firstIndex; i++)
-					children.add(null);
-			NamedNode child = children.get(firstIndex);
-			if (child == null) {
-				child = new NamedNode();
-				children.set(firstIndex, child);
-			}
-
-			int[] newTarget = new int[position.length - 1];
-			for (int i = 1; i < position.length; i++)
-				newTarget[i - 1] = position[i];
-			child.insertJobAt(j, newTarget);
-		}
-
-		public NamedNode childAt(int i) {
-			if (i >= children.size())
-				return null;
-			return children.get(i);
-		}
-	}
-
-	/**
-	 * The length of index arrays of jobs within the TreeCache. This assumes
-	 * that all jobs have the same index array length, this is true when the
-	 * cache is used by the iteration strategy but may not be in other
-	 * scenarios, use with caution!
-	 * <p>
-	 * If no jobs have been submitted this method returns -1
-	 */
-	public int getIndexLength() {
-		return this.indexDepth;
-	}
-
-	/**
-	 * Add a job to the cache, the job is inserted at a position corresponding
-	 * to its index array property
-	 * 
-	 * @param j
-	 */
-	public synchronized void insertJob(Job j) {
-		if (root == null)
-			root = new NamedNode();
-		indexDepth = j.getIndex().length;
-		root.insertJob(j);
-	}
-
-	protected synchronized NamedNode nodeAt(int[] position) {
-		if (root == null)
-			return null;
-		NamedNode result = root;
-		int index = 0;
-		while (index < position.length && result != null)
-			result = result.childAt(position[index++]);
-		return result;
-	}
-
-	/**
-	 * Chop the cache off at the specified index
-	 * 
-	 * @param indexArray
-	 */
-	public synchronized void cut(int[] indexArray) {
-		if (indexArray.length > 0) {
-			int[] newIndex = tail(indexArray);
-			NamedNode node = nodeAt(newIndex);
-			if (node != null
-					&& node.children.size() >= indexArray[indexArray.length - 1])
-				node.children.set(indexArray[indexArray.length - 1], null);
-		}
-	}
-
-	/**
-	 * Recursively fetch contents of all nodes under the specified index array,
-	 * used by the prefix matching iteration strategy
-	 */
-	public synchronized List<Job> jobsWithPrefix(int[] prefix) {
-		List<Job> jobs = new ArrayList<>();
-		NamedNode prefixNode = nodeAt(prefix);
-		if (prefixNode != null)
-			getJobsUnder(prefixNode, jobs);
-		return jobs;
-	}
-
-	private synchronized void getJobsUnder(NamedNode node, List<Job> jobs) {
-		if (node.contents != null)
-			jobs.add(node.contents);
-		else
-			for (NamedNode child : node.children)
-				getJobsUnder(child, jobs);
-	}
-
-	/**
-	 * Does the location exist?
-	 * 
-	 * @param location
-	 * @return whether the contents of the location are non null
-	 */
-	public synchronized boolean containsLocation(int[] location) {
-		return (get(location) != null);
-	}
-
-	/**
-	 * Get the job object at the specified index array
-	 * 
-	 * @param location
-	 * @return Job at the specified location or null if no such job was found
-	 */
-	public synchronized Job get(int[] location) {
-		NamedNode n = nodeAt(location);
-		return (n == null ? null : n.contents);
-	}
-
-	/**
-	 * Chop the last index off an int[]
-	 * 
-	 * @param arg
-	 * @return
-	 */
-	private static int[] tail(int[] arg) {
-		int result[] = new int[arg.length - 1];
-		for (int i = 0; i < arg.length - 1; i++)
-			result[i] = arg[i];
-		return result;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/WorkflowDataToken.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/WorkflowDataToken.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/WorkflowDataToken.java
deleted file mode 100644
index ca38f0d..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/WorkflowDataToken.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.invocation;
-
-import net.sf.taverna.t2.reference.T2Reference;
-
-/**
- * A single data token passed between processors in a workflow. This is distinct
- * from the Job in that it contains a single (unnamed) data reference whereas
- * the Job holds a map of arbitrarily many named data references in a bundle.
- * 
- * @author Tom Oinn
- */
-public class WorkflowDataToken extends Event<WorkflowDataToken> {
-	private T2Reference dataRef;
-
-	/**
-	 * Construct a new data token with the specified owning process, conceptual
-	 * index array and data reference
-	 * 
-	 * @param owningProcess
-	 * @param index
-	 * @param dataRef
-	 */
-	public WorkflowDataToken(String owningProcess, int[] index,
-			T2Reference dataRef, InvocationContext context) {
-		super(owningProcess, index, context);
-		this.dataRef = dataRef;
-	}
-
-	@Override
-	public WorkflowDataToken popOwningProcess()
-			throws ProcessIdentifierException {
-		return new WorkflowDataToken(popOwner(), index, dataRef, context);
-	}
-
-	@Override
-	public WorkflowDataToken pushOwningProcess(String localProcessName)
-			throws ProcessIdentifierException {
-		return new WorkflowDataToken(pushOwner(localProcessName), index,
-				dataRef, context);
-	}
-
-	/**
-	 * Return the ID of the data this event represents
-	 * 
-	 * @return
-	 */
-	public T2Reference getData() {
-		return this.dataRef;
-	}
-
-	/**
-	 * Show the owner, index array and data map in textual form for debugging
-	 * and any other purpose. Jobs appear in the form :
-	 * 
-	 * <pre>
-	 * Job(Process1)[2,0]{Input2=dataID4,Input1=dataID3}
-	 * </pre>
-	 */
-	@Override
-	public String toString() {
-		StringBuilder sb = new StringBuilder();
-		sb.append("Token(").append(owner).append(")[");
-		String sep = "";
-		for (int idx : index) {
-			sb.append(sep).append(idx);
-			sep = ",";
-		}
-		sb.append("]{").append(dataRef).append("}");
-		return sb.toString();
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/package.html b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/package.html
deleted file mode 100644
index 8b3c49a..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/package.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<body>
-Contains classes supporting workflow invocation. Other packages may have
-dependencies on this one but classes here will only be accessed by
-non-taverna code in an invocation context. Nothing in here should be
-critical to the definition and manipulation of the workflow defintion.
-</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/MonitorManager.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/MonitorManager.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/MonitorManager.java
deleted file mode 100644
index a4e68f4..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/MonitorManager.java
+++ /dev/null
@@ -1,378 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.monitor;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import net.sf.taverna.t2.lang.observer.MultiCaster;
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.lang.observer.Observer;
-import net.sf.taverna.t2.monitor.MonitorManager.MonitorMessage;
-
-/**
- * Manages a list of monitors implementations that get notified to register and
- * deregister nodes (ie. {@link{net.sf.taverna.t2.monitor.MonitorNode}s), in
- * addition to the addition of {@link MonitorableProperty monitorable
- * properties} of such nodes.
- * <p>
- * Nodes are identified by their owning process, which is an array of strings,
- * for instance ["dataflow2", "processor5", "fish"]
- * <p>
- * To notify the (by default 0) monitors, use any of the
- * {@link #addPropertiesToNode(String[], Set)},
- * {@link #registerNode(Object, String[], Set)}, {@link #deregisterNode(String)}
- * methods and variants.
- * <p>
- * To register a monitor, use {@link #addObserver(Observer)}.
- * 
- * @author Stian Soiland-Reyes
- */
-public class MonitorManager implements Observable<MonitorMessage> {
-	private static MonitorManager instance;
-
-	/**
-	 * Get the MonitorManager singleton instance.
-	 * 
-	 * @return The MonitorManager singleton
-	 */
-	public synchronized static MonitorManager getInstance() {
-		if (instance == null)
-			setInstance(new MonitorManager());
-		return instance;
-	}
-
-	/**
-	 * Set the MonitorManager singleton instance. Only to be used by overriding
-	 * super classes at initialisation time.
-	 * 
-	 * @param instance
-	 *            MonitorManager singleton to be returned by
-	 *            {@link #getInstance()}.
-	 */
-	protected synchronized static void setInstance(MonitorManager instance) {
-		MonitorManager.instance = instance;
-	}
-
-	protected MultiCaster<MonitorMessage> multiCaster = new MultiCaster<>(this);
-
-	/**
-	 * Protected constructor, use singleton access
-	 * {@link MonitorManager#getInstance()} instead.
-	 * 
-	 */
-	protected MonitorManager() {
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public void addObserver(Observer<MonitorMessage> observer) {
-		multiCaster.addObserver(observer);
-	}
-
-	/**
-	 * Push new property get / set methods into the specified node. This is used
-	 * for monitor-able activities where we have to create the node in the state
-	 * tree before we have the set of monitor-able properties for it.
-	 * 
-	 * @param owningProcess
-	 *            the node path to add properties, this must already be
-	 *            registered in the state model, if not then this method fails
-	 *            silently and does nothing.
-	 * @param newProperties
-	 *            the set of properties to add to the specified node in the
-	 *            state model
-	 */
-	public void addPropertiesToNode(String[] owningProcess,
-			Set<MonitorableProperty<?>> newProperties) {
-		multiCaster.notify(new AddPropertiesMessage(owningProcess,
-				newProperties));
-	}
-
-	/**
-	 * Remove the specified node from the monitor. This must be called when the
-	 * final data or completion event leaves a boundary of control. The monitor
-	 * is free to delay the actual removal of state, in which case the node may
-	 * choose to throw exceptions when properties are accessed. The monitor
-	 * should eventually release all references to work-flow objects and process
-	 * identifiers - typically this is used to allow a UI a few seconds delay on
-	 * de-registration so that very fast register / de-register cycles are
-	 * visible to a user.
-	 * <p>
-	 * The specified process identifier must exist within the monitor.
-	 * 
-	 * @param owningProcess
-	 *            the identifier of the node to remove as a :-separated string
-	 */
-	public void deregisterNode(String owningProcessIdentifier) {
-		deregisterNode(owningProcessIdentifier.split(":"));
-	}
-
-	/**
-	 * Remove the specified node from the monitor. This must be called when the
-	 * final data or completion event leaves a boundary of control. The monitor
-	 * is free to delay the actual removal of state, in which case the node may
-	 * choose to throw exceptions when properties are accessed. The monitor
-	 * should eventually release all references to work-flow objects and process
-	 * identifiers - typically this is used to allow a UI a few seconds delay on
-	 * de-registration so that very fast register / de-register cycles are
-	 * visible to a user.
-	 * <p>
-	 * The specified process identifier must exist within the monitor.
-	 * 
-	 * @param owningProcess
-	 *            the identifier of the node to remove.
-	 */
-	public void deregisterNode(String[] owningProcess) {
-		multiCaster.notify(new DeregisterNodeMessage(owningProcess));
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public List<Observer<MonitorMessage>> getObservers() {
-		return multiCaster.getObservers();
-	}
-
-	/**
-	 * Register a new node with this monitor. New nodes can only be registered
-	 * when a new process identifier is allocated to data corresponding to entry
-	 * to a boundary of control in the data-flow. For cases where extensions
-	 * such as dispatch layers wish to augment existing state the plug-in point
-	 * is responsible for the aggregation of appropriate properties.
-	 * <p>
-	 * The process identifier must not already exist within the state tree, if
-	 * it does it will be ignored. Similarly the parent of the process
-	 * identifier must exist, you cannot specify orphan nodes with no parent.
-	 * 
-	 * @param workflowObject
-	 *            an object within the work-flow model which has received the
-	 *            data stream and caused this node to be created. This may or
-	 *            may not be a top level work-flow entity such as a processor or
-	 *            data-flow. It may be empty in which case null can be used but
-	 *            this is not recommended (there's almost always something you
-	 *            can put here, in general the code to create a new node is
-	 *            contained within something that's just received a data stream
-	 *            so a default approach would be to use the 'this'
-	 *            meta-variable)
-	 * @param owningProcess
-	 *            the :-separated process identifier as a string which has been
-	 *            assigned to data moving through the workflow object. The list
-	 *            of IDs must contain the new identifier as the last element.
-	 */
-	public void registerNode(Object workflowObject,
-			String owningProcessIdentifier) {
-		registerNode(workflowObject, owningProcessIdentifier.split(":"), null);
-	}
-
-	/**
-	 * Register a new node with this monitor. New nodes can only be registered
-	 * when a new process identifier is allocated to data corresponding to entry
-	 * to a boundary of control in the data-flow. For cases where extensions
-	 * such as dispatch layers wish to augment existing state the plug-in point
-	 * is responsible for the aggregation of appropriate properties.
-	 * <p>
-	 * The process identifier must not already exist within the state tree, if
-	 * it does it will be ignored. Similarly the parent of the process
-	 * identifier must exist, you cannot specify orphan nodes with no parent.
-	 * 
-	 * @param workflowObject
-	 *            an object within the work-flow model which has received the
-	 *            data stream and caused this node to be created. This may or
-	 *            may not be a top level work-flow entity such as a processor or
-	 *            data-flow. It may be empty in which case null can be used but
-	 *            this is not recommended (there's almost always something you
-	 *            can put here, in general the code to create a new node is
-	 *            contained within something that's just received a data stream
-	 *            so a default approach would be to use the 'this'
-	 *            meta-variable)
-	 * @param owningProcess
-	 *            the :-separated process identifier as a string which has been
-	 *            assigned to data moving through the workflow object. The list
-	 *            of IDs must contain the new identifier as the last element. *
-	 * @param properties
-	 *            the set of monitor-able, and potentially steer-able,
-	 *            properties which can be monitored from this node. Properties
-	 *            may cache, may become invalid and may make no guarantee about
-	 *            timely updates.
-	 */
-	public void registerNode(Object workflowObject,
-			String owningProcessIdentifier,
-			Set<MonitorableProperty<?>> properties) {
-		registerNode(workflowObject, owningProcessIdentifier.split(":"),
-				properties);
-	}
-
-	/**
-	 * Register a new node with this monitor. New nodes can only be registered
-	 * when a new process identifier is allocated to data corresponding to entry
-	 * to a boundary of control in the data-flow. For cases where extensions
-	 * such as dispatch layers wish to augment existing state the plug-in point
-	 * is responsible for the aggregation of appropriate properties.
-	 * <p>
-	 * The process identifier must not already exist within the state tree, if
-	 * it does it will be ignored. Similarly the parent of the process
-	 * identifier must exist, you cannot specify orphan nodes with no parent.
-	 * 
-	 * @param workflowObject
-	 *            an object within the work-flow model which has received the
-	 *            data stream and caused this node to be created. This may or
-	 *            may not be a top level work-flow entity such as a processor or
-	 *            data-flow. It may be empty in which case null can be used but
-	 *            this is not recommended (there's almost always something you
-	 *            can put here, in general the code to create a new node is
-	 *            contained within something that's just received a data stream
-	 *            so a default approach would be to use the 'this'
-	 *            meta-variable)
-	 * @param owningProcess
-	 *            the process identifier which has been assigned to data moving
-	 *            through the work-flow object. The list of IDs must contain the
-	 *            new identifier as the last element.
-	 */
-	public void registerNode(Object workflowObject, String[] owningProcess) {
-		registerNode(workflowObject, owningProcess, null);
-	}
-
-	/**
-	 * Register a new node with this monitor. New nodes can only be registered
-	 * when a new process identifier is allocated to data corresponding to entry
-	 * to a boundary of control in the data-flow. For cases where extensions
-	 * such as dispatch layers wish to augment existing state the plug-in point
-	 * is responsible for the aggregation of appropriate properties.
-	 * <p>
-	 * The process identifier must not already exist within the state tree, if
-	 * it does it will be ignored. Similarly the parent of the process
-	 * identifier must exist, you cannot specify orphan nodes with no parent.
-	 * 
-	 * @param workflowObject
-	 *            an object within the work-flow model which has received the
-	 *            data stream and caused this node to be created. This may or
-	 *            may not be a top level work-flow entity such as a processor or
-	 *            data-flow. It may be empty in which case null can be used but
-	 *            this is not recommended (there's almost always something you
-	 *            can put here, in general the code to create a new node is
-	 *            contained within something that's just received a data stream
-	 *            so a default approach would be to use the 'this'
-	 *            meta-variable)
-	 * @param owningProcess
-	 *            the process identifier which has been assigned to data moving
-	 *            through the work-flow object. The list of IDs must contain the
-	 *            new identifier as the last element.
-	 * @param properties
-	 *            the set of monitor-able, and potentially steer-able,
-	 *            properties which can be monitored from this node. Properties
-	 *            may cache, may become invalid and may make no guarantee about
-	 *            timely updates.
-	 */
-	public void registerNode(Object workflowObject, String[] owningProcess,
-			Set<MonitorableProperty<?>> properties) {
-		if (properties == null)
-			properties = new HashSet<>();
-		multiCaster.notify(new RegisterNodeMessage(workflowObject,
-				owningProcess, properties));
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public void removeObserver(Observer<MonitorMessage> observer) {
-		multiCaster.removeObserver(observer);
-	}
-
-	/**
-	 * Message indicating that {@link #getNewProperties() new properties} have
-	 * been added to a node identified by given {@link #getOwningProcess()
-	 * owning process}.
-	 * 
-	 */
-	public class AddPropertiesMessage extends MonitorMessage {
-		private final Set<MonitorableProperty<?>> newProperties;
-
-		public AddPropertiesMessage(String[] owningProcess,
-				Set<MonitorableProperty<?>> newProperties) {
-			super(owningProcess);
-			this.newProperties = newProperties;
-		}
-
-		public Set<MonitorableProperty<?>> getNewProperties() {
-			return newProperties;
-		}
-	}
-
-	/**
-	 * Message indicating that the node of the given {@link #getOwningProcess()
-	 * owning process} is to be deregistered.
-	 * 
-	 */
-	public class DeregisterNodeMessage extends MonitorMessage {
-		public DeregisterNodeMessage(String[] owningProcess) {
-			super(owningProcess);
-		}
-	}
-
-	/**
-	 * Common abstract superclass for all monitor messages. Identifies the
-	 * {@link #getOwningProcess() owning process}.
-	 * 
-	 */
-	public abstract class MonitorMessage {
-		private final String[] owningProcess;
-
-		public MonitorMessage(String[] owningProcess) {
-			this.owningProcess = owningProcess;
-		}
-
-		public String[] getOwningProcess() {
-			return owningProcess;
-		}
-	}
-
-	/**
-	 * Message indicating that the node of the given {@link #getOwningProcess()
-	 * owning process} is to be registered. The node might have
-	 * {@link #getProperties() a set of monitorable properties} and a
-	 * {@link #getWorkflowObject workflow object}.
-	 */
-	public class RegisterNodeMessage extends MonitorMessage {
-		private final Set<MonitorableProperty<?>> properties;
-		private final Object workflowObject;
-
-		public RegisterNodeMessage(Object workflowObject,
-				String[] owningProcess, Set<MonitorableProperty<?>> properties) {
-			super(owningProcess);
-			this.workflowObject = workflowObject;
-			this.properties = properties;
-		}
-
-		public Set<MonitorableProperty<?>> getProperties() {
-			return properties;
-		}
-
-		public Object getWorkflowObject() {
-			return workflowObject;
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/MonitorNode.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/MonitorNode.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/MonitorNode.java
deleted file mode 100644
index 371412c..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/MonitorNode.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.monitor;
-
-import java.util.Date;
-import java.util.Set;
-
-/**
- * A single node in the Monitor tree, containing an optional arbitrary workflow
- * object and a set of properties which may or may not be mutable. For tree
- * traversal operations the top level monitor tree must be used, instances of
- * this class are not aware of the surrounding tree structure.
- * 
- * @author Tom Oinn
- */
-public interface MonitorNode {
-	/**
-	 * Each monitor node can reference zero or one workflow object. This is the
-	 * object which is providing any properties the node exposes, so is likely
-	 * to be a workflow or processor but could be anything.
-	 * 
-	 * @return the workflow object providing this node's properties, or null if
-	 *         there is no directly corresponding workflow object. Note that
-	 *         this workflow object can be anything, and may not be a top level
-	 *         workflow object at all.
-	 */
-	Object getWorkflowObject();
-
-	/**
-	 * Each monitor node has an identity corresponding to the identifier stack
-	 * of the data flowing through the workflow object that created it. This
-	 * string array also defines its position in the monitor tree.
-	 */
-	String[] getOwningProcess();
-
-	/**
-	 * Each monitor node exposes a set of properties, which may or may not be
-	 * mutable
-	 */
-	Set<? extends MonitorableProperty<?>> getProperties();
-
-	/**
-	 * Each node has a creation date
-	 */
-	Date getCreationDate();
-
-	/**
-	 * Properties can be added to the monitor node after creation if required,
-	 * although this should be used only when necessary to avoid race conditions
-	 */
-	void addMonitorableProperty(MonitorableProperty<?> newProperty);
-
-	/**
-	 * Nodes can persist in the tree after they have expired, in which case this
-	 * will return true.
-	 */
-	boolean hasExpired();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/MonitorableProperty.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/MonitorableProperty.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/MonitorableProperty.java
deleted file mode 100644
index 1f55811..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/MonitorableProperty.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.monitor;
-
-import java.util.Date;
-
-/**
- * A single readable property contained by a Monitorable. This is used to
- * express properties that are dynamic with respect to workflow invocation as
- * opposed to static properties defined by the workflow model. A typical example
- * of this might be dispatch stack queue size or number of jobs completed. All
- * properties are defined relative to a particular owning process identifier,
- * this is the same mechanism as used in the workflow model to isolate different
- * data streams.
- * 
- * @author Tom Oinn
- */
-public interface MonitorableProperty<T> {
-	/**
-	 * Return the value of this property
-	 */
-	T getValue() throws NoSuchPropertyException;
-
-	/**
-	 * Return the name of this property, names are heirarchical in nature and
-	 * are defined as an array of String objects. This is to allow e.g. dispatch
-	 * layers to expose a set of related properties under the same root name.
-	 */
-	String[] getName();
-
-	/**
-	 * Get the last update date for this property, if the property is immutable
-	 * then this should be set to the date at which the implementation is
-	 * created.
-	 */
-	Date getLastModified();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/NoSuchPropertyException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/NoSuchPropertyException.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/NoSuchPropertyException.java
deleted file mode 100644
index edb4751..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/NoSuchPropertyException.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.monitor;
-
-/**
- * Thrown when an attempt is made to access a monitorable property which is no
- * longer current. This is quite a common event as the properties can change
- * extremely quickly whereas the logic accessing them is expected not to.
- * Consumers of state data must cope with this disparity by handling this
- * exception where it is thrown.
- * 
- * @author Tom Oinn
- */
-public class NoSuchPropertyException extends Exception {
-	private static final long serialVersionUID = 6320919057517500603L;
-
-	public NoSuchPropertyException() {
-		super();
-	}
-
-	public NoSuchPropertyException(String arg0, Throwable arg1) {
-		super(arg0, arg1);
-	}
-
-	public NoSuchPropertyException(String arg0) {
-		super(arg0);
-	}
-
-	public NoSuchPropertyException(Throwable arg0) {
-		super(arg0);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/SteerableProperty.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/SteerableProperty.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/SteerableProperty.java
deleted file mode 100644
index 44301cc..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/SteerableProperty.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.monitor;
-
-/**
- * Some monitorable properties are mutable and can be written to by steering
- * agents or other clients.
- * 
- * @author Tom Oinn
- */
-public interface SteerableProperty<T> extends MonitorableProperty<T> {
-	/**
-	 * Set the property value
-	 * 
-	 * @param newValue
-	 * @throws NoSuchPropertyException
-	 */
-	void setProperty(T newValue) throws NoSuchPropertyException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/package.html b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/package.html
deleted file mode 100644
index 17ee572..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/monitor/package.html
+++ /dev/null
@@ -1,36 +0,0 @@
-<body>
-Defines the API for the monitoring and steering system. As data flows
-through a workflow it passes through a succession of bounds of control.
-Each of these boundaries corresponds to a workflow, a nested process or
-some other contained entity where a new owning process identifier is
-pushed onto the process identifier stack for that data item. This
-modification to the owning process identifier implicitly creates a tree
-structure where the parent of a particular identifier can be obtained by
-popping the last component off its identifier stack (in general this
-means splitting into a list by the ':' character and removing the last
-item).
-<p>Any entity issuing a new identifier to data in this way must
-implement the Monitorable interface and should register itself with the
-Monitor before or at the point of assigning this new identifier. Some
-cases may register child items rather than delegating to the children
-themselves, for example a workflow definition may register all its
-processors as children and deregister on workflow completion rather than
-the process happening for each processor but however it is accomplished
-the result is the creation within the Monitor of a tree where nodes
-contain references to Monitorable objects within the workflow
-definition.
-<p>The Monitorable interface defines a simple contract - once
-registered the implementing class can return a list of
-MonitorableProperty instances defining the exposed dynamic state at this
-node in the context of a given process identifier. Any of these
-properties may be mutable in which case they will extend
-SteerableProperty, a sub-interface of MonitorableProperty which allows
-for the mutation of the property.
-<p>By design the Monitor is rather powerful - it has the ability to
-modify steerable properties in any running workflow. It is obviously
-desirable to restrict this, passing any given monitoring or steering
-agent a restricted subset of the monitor tree rooted at a specific
-process identifier and preventing direct access to the Monitor class.
-The Monitor interface defines methods to expose subsets of the
-monitorable state for this reason.
-</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/AbstractProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/AbstractProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/AbstractProvenanceItem.java
deleted file mode 100644
index b212e73..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/AbstractProvenanceItem.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package net.sf.taverna.t2.provenance.item;
-
-import net.sf.taverna.t2.provenance.vocabulary.SharedVocabulary;
-
-public abstract class AbstractProvenanceItem implements ProvenanceItem {
-	@Override
-	public abstract SharedVocabulary getEventType();
-
-	private String identifier, parentId, processId, workflowId;
-
-	@Override
-	public final String getIdentifier() {
-		return identifier;
-	}
-
-	@Override
-	public int hashCode() {
-		return 31 + (identifier == null ? 0 : identifier.hashCode());
-	}
-
-	@Override
-	public boolean equals(Object obj) {
-		if (this == obj)
-			return true;
-		if (obj == null)
-			return false;
-		if (getClass() != obj.getClass())
-			return false;
-		AbstractProvenanceItem other = (AbstractProvenanceItem) obj;
-		if (identifier == null) {
-			if (other.identifier != null)
-				return false;
-		} else if (!identifier.equals(other.identifier))
-			return false;
-		return true;
-	}
-
-	@Override
-	public final void setIdentifier(String identifier) {
-		this.identifier = identifier;
-	}
-
-	@Override
-	public final String getParentId() {
-		return parentId;
-	}
-
-	@Override
-	public final void setParentId(String parentId) {
-		this.parentId = parentId;
-	}
-
-	@Override
-	public final String getProcessId() {
-		return processId;
-	}
-
-	@Override
-	public final void setProcessId(String processId) {
-		this.processId = processId;
-	}
-
-	@Override
-	public final String getWorkflowId() {
-		return workflowId;
-	}
-
-	@Override
-	public final void setWorkflowId(String workflowId) {
-		this.workflowId = workflowId;
-	}
-	
-	@Override
-	public String toString() {
-		return getEventType() + " id:" + getIdentifier() + " parent:" + getParentId();
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/ActivityProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/ActivityProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/ActivityProvenanceItem.java
deleted file mode 100644
index d9bda73..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/ActivityProvenanceItem.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.provenance.item;
-
-import net.sf.taverna.t2.provenance.vocabulary.SharedVocabulary;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-
-/**
- * Contains details for an enacted Activity. Parent is a
- * {@link ProcessorProvenanceItem}. Children are {@link IterationProvenanceItem}
- * s. There could be multiple {@link ActivityProvenanceItem}s for each
- * {@link ProcessorProvenanceItem}
- * 
- * @author Ian Dunlop
- * @author Stuart Owen
- * @author Paolo Missier
- */
-public class ActivityProvenanceItem extends AbstractProvenanceItem implements ProvenanceItem  {
-	private Activity<?> activity;
-	private IterationProvenanceItem iterationProvenanceItem;
-	
-	public void setIterationProvenanceItem(
-			IterationProvenanceItem iterationProvenanceItem) {
-		this.iterationProvenanceItem = iterationProvenanceItem;
-	}
-
-	public IterationProvenanceItem getIterationProvenanceItem() {
-		return iterationProvenanceItem;
-	}
-
-	@Override
-	public SharedVocabulary getEventType() {
-		return SharedVocabulary.ACTIVITY_EVENT_TYPE;
-	}
-
-	public Activity<?> getActivity() {
-		return activity;
-	}
-
-	public void setActivity(Activity<?> activity) {
-		this.activity = activity;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/DataProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/DataProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/DataProvenanceItem.java
deleted file mode 100644
index 59dc3fe..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/DataProvenanceItem.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.provenance.item;
-
-import java.util.Map;
-
-import net.sf.taverna.t2.reference.ReferenceService;
-import net.sf.taverna.t2.reference.T2Reference;
-
-/**
- * Contains references to data which a workflow has used or created. Parent is
- * an {@link IterationProvenanceItem}
- * 
- * @author Ian Dunlop
- * @auhor Stuart Owen
- * @author Paolo Missier
- */
-public abstract class DataProvenanceItem extends AbstractProvenanceItem {
-	/** A map of port name to data reference */
-	private Map<String, T2Reference> dataMap;
-	private ReferenceService referenceService;
-
-	/**
-	 * Is this {@link ProvenanceItem} for input or output data
-	 * 
-	 * @return
-	 */
-	protected abstract boolean isInput();
-
-	public Map<String, T2Reference> getDataMap() {
-		return dataMap;
-	}
-
-	public void setDataMap(Map<String, T2Reference> dataMap) {
-		this.dataMap = dataMap;
-	}
-	
-	public void setReferenceService(ReferenceService referenceService) {
-		this.referenceService = referenceService;
-	}
-
-	public ReferenceService getReferenceService() {
-		return referenceService;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/DataflowRunComplete.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/DataflowRunComplete.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/DataflowRunComplete.java
deleted file mode 100644
index d830efb..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/DataflowRunComplete.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.provenance.item;
-
-import java.sql.Timestamp;
-
-import net.sf.taverna.t2.facade.WorkflowInstanceFacade.State;
-import net.sf.taverna.t2.provenance.vocabulary.SharedVocabulary;
-
-/**
- * Informs the {@link ProvenanceConnector} that a workflow has been run to
- * completion. If a {@link ProvenanceConnector} receives this event then it
- * means that there are no further events to come and that the workflow has been
- * enacted to completion
- * 
- * @author Ian Dunlop
- */
-public class DataflowRunComplete extends AbstractProvenanceItem {
-	private SharedVocabulary eventType = SharedVocabulary.END_WORKFLOW_EVENT_TYPE;
-	private Timestamp invocationEnded;
-	private State state;
-
-	public Timestamp getInvocationEnded() {
-		return invocationEnded;
-	}
-
-	@Override
-	public SharedVocabulary getEventType() {
-		return eventType;
-	}
-
-	public void setInvocationEnded(Timestamp invocationEnded) {
-		this.invocationEnded = invocationEnded;
-	}
-
-	public void setState(State state) {
-		this.state = state;
-	}
-
-	public State getState() {
-		return state;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/ErrorProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/ErrorProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/ErrorProvenanceItem.java
deleted file mode 100644
index 6929f55..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/ErrorProvenanceItem.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.provenance.item;
-
-import net.sf.taverna.t2.provenance.vocabulary.SharedVocabulary;
-
-/**
- * When an error is received in the dispatch stack, one of these is created and
- * sent across to the {@link ProvenanceConnector}. Parent is an
- * {@link IterationProvenanceItem}
- * 
- * @author Ian Dunlop
- * @author Stuart Owen
- * @author Paolo Missier
- */
-public class ErrorProvenanceItem extends AbstractProvenanceItem {
-	private Throwable cause;
-	private String message;
-	private String errorType;
-	private SharedVocabulary eventType = SharedVocabulary.ERROR_EVENT_TYPE;
-
-	public ErrorProvenanceItem() {
-	}
-
-	@Override
-	public SharedVocabulary getEventType() {
-		return eventType;
-	}
-
-	public Throwable getCause() {
-		return cause;
-	}
-
-	public void setCause(Throwable cause) {
-		this.cause = cause;
-	}
-
-	public String getMessage() {
-		return message;
-	}
-
-	public void setMessage(String message) {
-		this.message = message;
-	}
-
-	public String getErrorType() {
-		return errorType;
-	}
-
-	public void setErrorType(String errorType) {
-		this.errorType = errorType;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/InputDataProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/InputDataProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/InputDataProvenanceItem.java
deleted file mode 100644
index 238a686..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/InputDataProvenanceItem.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.provenance.item;
-
-import net.sf.taverna.t2.provenance.vocabulary.SharedVocabulary;
-
-/**
- * Contains details of port names and the input data they receive. Parent is an
- * {@link IterationProvenanceItem}
- * 
- * @author Paolo Missier
- * @author Stuart Owen
- * @author Ian Dunlop
- */
-public class InputDataProvenanceItem extends DataProvenanceItem {
-	private SharedVocabulary eventType = SharedVocabulary.INPUTDATA_EVENT_TYPE;
-
-	/**
-	 * Used when generating the xml version by the {@link DataProvenanceItem}.
-	 * Identifies this {@link DataProvenanceItem} as containing input
-	 */
-	@Override
-	protected boolean isInput() {
-		return true;
-	}
-
-	@Override
-	public SharedVocabulary getEventType() {
-		return eventType;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/InvocationStartedProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/InvocationStartedProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/InvocationStartedProvenanceItem.java
deleted file mode 100644
index 6c9228a..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/InvocationStartedProvenanceItem.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package net.sf.taverna.t2.provenance.item;
-
-import java.sql.Date;
-
-import net.sf.taverna.t2.provenance.vocabulary.SharedVocabulary;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-
-public class InvocationStartedProvenanceItem extends AbstractProvenanceItem {
-	private Activity<?> activity;
-	private String invocationProcessId;
-	private Date invocationStarted;
-
-	public final Date getInvocationStarted() {
-		return invocationStarted;
-	}
-
-	@Override
-	public SharedVocabulary getEventType() {
-		return SharedVocabulary.INVOCATION_STARTED_EVENT_TYPE;
-	}
-
-	public void setActivity(Activity<?> activity) {
-		this.activity = activity;
-	}
-
-	public Activity<?> getActivity() {
-		return activity;
-	}
-
-	public void setInvocationProcessId(String invocationProcessId) {
-		this.invocationProcessId = invocationProcessId;
-	}
-
-	public String getInvocationProcessId() {
-		return invocationProcessId;
-	}
-
-	public void setInvocationStarted(Date invocationStarted) {
-		this.invocationStarted = invocationStarted;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/IterationProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/IterationProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/IterationProvenanceItem.java
deleted file mode 100644
index b567d1c..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/IterationProvenanceItem.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.provenance.item;
-
-import java.sql.Timestamp;
-
-import net.sf.taverna.t2.provenance.vocabulary.SharedVocabulary;
-
-/**
- * One of these is created for each iteration inside an enacted activity.
- * Contains both the input and output data and port names contained inside
- * {@link DataProvenanceItem}s. The actual iteration number is contained inside
- * an int array eg [1]
- * 
- * @author Ian Dunlop
- * @author Paolo Missier
- * @author Stuart Owen
- */
-public class IterationProvenanceItem extends AbstractProvenanceItem {
-	private Timestamp enactmentEnded;
-	private Timestamp enactmentStarted;
-	private ErrorProvenanceItem errorItem;
-	private final SharedVocabulary eventType = SharedVocabulary.ITERATION_EVENT_TYPE;
-	private InputDataProvenanceItem inputDataItem;
-	private int[] iteration;
-	private OutputDataProvenanceItem outputDataItem;
-	private IterationProvenanceItem parentIterationItem = null;
-
-	public IterationProvenanceItem getParentIterationItem() {
-		return parentIterationItem;
-	}
-
-	public Timestamp getEnactmentEnded() {
-		return enactmentEnded;
-	}
-
-	public Timestamp getEnactmentStarted() {
-		return enactmentStarted;
-	}
-
-	public ErrorProvenanceItem getErrorItem() {
-		return errorItem;
-	}
-
-	@Override
-	public SharedVocabulary getEventType() {
-		return eventType;
-	}
-
-	public InputDataProvenanceItem getInputDataItem() {
-		return inputDataItem;
-	}
-
-	public int[] getIteration() {
-		return iteration;
-	}
-
-	public OutputDataProvenanceItem getOutputDataItem() {
-		return outputDataItem;
-	}
-
-	public void setEnactmentEnded(Timestamp enactmentEnded) {
-		this.enactmentEnded = enactmentEnded;
-	}
-
-	public void setEnactmentStarted(Timestamp enactmentStarted) {
-		this.enactmentStarted = enactmentStarted;
-	}
-
-	public void setErrorItem(ErrorProvenanceItem errorItem) {
-		this.errorItem = errorItem;
-	}
-
-	public void setInputDataItem(InputDataProvenanceItem inputDataItem) {
-		this.inputDataItem = inputDataItem;
-	}
-
-	public void setIteration(int[] iteration) {
-		this.iteration = iteration;
-	}
-
-	public void setOutputDataItem(OutputDataProvenanceItem outputDataItem) {
-		this.outputDataItem = outputDataItem;
-	}
-
-	public void setParentIterationItem(
-			IterationProvenanceItem parentIterationItem) {
-		this.parentIterationItem = parentIterationItem;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/OutputDataProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/OutputDataProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/OutputDataProvenanceItem.java
deleted file mode 100644
index de8e424..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/OutputDataProvenanceItem.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.provenance.item;
-
-import net.sf.taverna.t2.provenance.vocabulary.SharedVocabulary;
-
-/**
- * Contains details of port names and the output data they receive. Parent is an
- * {@link IterationProvenanceItem}
- * 
- * @author Paolo Missier
- * @author Stuart Owen
- * @author Ian Dunlop
- */
-public class OutputDataProvenanceItem extends DataProvenanceItem {
-	private SharedVocabulary eventType = SharedVocabulary.OUTPUTDATA_EVENT_TYPE;
-
-	/**
-	 * Used when generating the xml version by the {@link DataProvenanceItem}.
-	 * Identifies this {@link DataProvenanceItem} as containing output
-	 */
-	@Override
-	protected boolean isInput() {
-		return false;
-	}
-
-	@Override
-	public SharedVocabulary getEventType() {
-		return eventType;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/ProcessProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/ProcessProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/ProcessProvenanceItem.java
deleted file mode 100644
index 06cb76e..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/ProcessProvenanceItem.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.provenance.item;
-
-import net.sf.taverna.t2.provenance.vocabulary.SharedVocabulary;
-
-/**
- * Each time a job is received by the dispatch stack one of these will be
- * created. It has a {@link ProcessorProvenanceItem} as its child. Its parent is
- * a {@link WorkflowProvenanceItem} which in turn knows the unique id of the
- * workflow the provenance is being stored for. NOTE: May be superfluous since
- * it essentially mimics the behaviour of its child item but may be more hastle
- * than it is worth to remove it
- * 
- * @author Stuart owen
- * @author Paolo Missier
- * @author Ian Dunlop
- */
-public class ProcessProvenanceItem extends AbstractProvenanceItem {
-	private String owningProcess;
-	private ProcessorProvenanceItem processorProvenanceItem;
-	private String facadeID;
-	private String dataflowID;
-	private SharedVocabulary eventType = SharedVocabulary.PROCESS_EVENT_TYPE;
-
-	/**
-	 * As {@link WorkflowInstanceFacade}s are created for a Processor the
-	 * details are appended to the owning process identifier. This is in the
-	 * form facadeX:dataflowY:ProcessorZ etc. This method returns the facadeX
-	 * part.
-	 * 
-	 * @return
-	 */
-	public String getFacadeID() {
-		return facadeID;
-	}
-
-	public void setProcessorProvenanceItem(
-			ProcessorProvenanceItem processorProvenanceItem) {
-		this.processorProvenanceItem = processorProvenanceItem;
-	}
-
-	public ProcessorProvenanceItem getProcessorProvenanceItem() {
-		return processorProvenanceItem;
-	}
-
-	@Override
-	public SharedVocabulary getEventType() {
-		return eventType;
-	}
-
-	public String getOwningProcess() {
-		return owningProcess;
-	}
-
-	public void setOwningProcess(String owningProcess) {
-		this.owningProcess = owningProcess;
-	}
-
-	public void setFacadeID(String facadeID) {
-		this.facadeID = facadeID;
-	}
-
-	public void setDataflowID(String dataflowID) {
-		this.dataflowID = dataflowID;
-	}
-
-	public String getDataflowID() {
-		return dataflowID;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/ProcessorProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/ProcessorProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/ProcessorProvenanceItem.java
deleted file mode 100644
index c82750c..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/ProcessorProvenanceItem.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.provenance.item;
-
-import net.sf.taverna.t2.provenance.vocabulary.SharedVocabulary;
-
-/**
- * Each Processor inside a workflow will have one of these for each provenance
- * run. Its parent is a {@link ProcessProvenanceItem} and child is an
- * {@link ActivityProvenanceItem}. In theory there could be more than one
- * {@link ActivityProvenanceItem} per processor to cope with failover etc
- * 
- * @author Ian Dunlop
- * @author Stuart Owen
- * @author Paolo Missier
- */
-public class ProcessorProvenanceItem extends AbstractProvenanceItem {
-	private ActivityProvenanceItem activityProvenanceItem;
-	private String identifier;
-	private SharedVocabulary eventType = SharedVocabulary.PROCESSOR_EVENT_TYPE;
-
-	public void setActivityProvenanceItem(
-			ActivityProvenanceItem activityProvenanceItem) {
-		this.activityProvenanceItem = activityProvenanceItem;
-	}
-
-	public ActivityProvenanceItem getActivityProvenanceItem() {
-		return activityProvenanceItem;
-	}
-
-	public String getProcessorID() {
-		return identifier;
-	}
-
-	@Override
-	public SharedVocabulary getEventType() {
-		return eventType;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/ProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/ProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/ProvenanceItem.java
deleted file mode 100644
index 97fdc04..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/ProvenanceItem.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.provenance.item;
-
-import net.sf.taverna.t2.provenance.vocabulary.SharedVocabulary;
-
-/**
- * Used to store some enactment information during a workflow run
- * 
- * @see AbstractProvenanceItem
- * @author Ian Dunlop
- */
-public interface ProvenanceItem {
-	/**
-	 * What type of information does the item contain. The
-	 * {@link SharedVocabulary} can be used to identify it
-	 * 
-	 * @return
-	 */
-	SharedVocabulary getEventType();
-
-	/**
-	 * The unique identifier for this item
-	 * 
-	 * @return
-	 */
-	String getIdentifier();
-
-	/**
-	 * A unique id for this event. Any children would use this as their parentId
-	 * 
-	 * @param identifier
-	 */
-	void setIdentifier(String identifier);
-
-	/**
-	 * The workflow model id that is supplied during enactment eg
-	 * facade0:dataflow2:processor1
-	 * 
-	 * @param processId
-	 */
-	void setProcessId(String processId);
-
-	/**
-	 * Get the enactor supplie identifier
-	 * 
-	 * @return
-	 */
-	String getProcessId();
-
-	/**
-	 * The parent of this provenance Item. The model is
-	 * WorkflowProvenanceItem>ProcessProvenanceItem
-	 * >ProcessorProvenanceItem>ActivityProvenanceITem
-	 * >IterationProvenanceItem>DataProvenanceItem
-	 * 
-	 * Additionally there is a WorkflowDataProvenanceItem that is sent when the
-	 * facade receives a completion event and a ErrorProvenanceItem when things
-	 * go wrong
-	 * 
-	 * @param parentId
-	 */
-	void setParentId(String parentId);
-
-	/**
-	 * Who is the parent of this item?
-	 * 
-	 * @return
-	 */
-	String getParentId();
-
-	/**
-	 * The uuid that belongs to the actual dataflow
-	 * 
-	 * @param workflowId
-	 */
-	void setWorkflowId(String workflowId);
-
-	/**
-	 * The uuid that belongs to the actual dataflow
-	 * 
-	 * @return a string representation of a uuid
-	 */
-	String getWorkflowId();
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/WorkflowDataProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/WorkflowDataProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/WorkflowDataProvenanceItem.java
deleted file mode 100644
index 88e0d75..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/WorkflowDataProvenanceItem.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.provenance.item;
-
-import net.sf.taverna.t2.provenance.vocabulary.SharedVocabulary;
-import net.sf.taverna.t2.reference.ReferenceService;
-import net.sf.taverna.t2.reference.T2Reference;
-
-/**
- * When the {@link WorkflowInstanceFacade} for a processor receives a data token
- * one of these is created. This is especially important for data which flows
- * straight through a facade without going into the dispatch stack (a rare event
- * but it can happen)
- * 
- * @author Ian Dunlop
- */
-public class WorkflowDataProvenanceItem extends AbstractProvenanceItem {
-	private ReferenceService referenceService;
-	/** The port name that the data is for */
-	private String portName;
-	/** A reference to the data token received in the facade */
-	private T2Reference data;
-	private SharedVocabulary eventType = SharedVocabulary.WORKFLOW_DATA_EVENT_TYPE;
-	private boolean isFinal;
-	private int[] index;
-	private boolean isInputPort;
-
-	public boolean isInputPort() {
-		return isInputPort;
-	}
-
-	public void setInputPort(boolean isInputPort) {
-		this.isInputPort = isInputPort;
-	}
-
-	public WorkflowDataProvenanceItem() {
-	}
-
-	@Override
-	public SharedVocabulary getEventType() {
-		return eventType;
-	}
-
-	public void setPortName(String portName) {
-		this.portName = portName;
-	}
-
-	public String getPortName() {
-		return portName;
-	}
-
-	public void setData(T2Reference data) {
-		this.data = data;
-	}
-
-	public T2Reference getData() {
-		return data;
-	}
-
-	public void setReferenceService(ReferenceService referenceService) {
-		this.referenceService = referenceService;
-	}
-
-	public ReferenceService getReferenceService() {
-		return referenceService;
-	}
-
-	public void setIndex(int[] index) {
-		this.index = index;
-	}
-
-	public int[] getIndex() {
-		return index;
-	}
-
-	public void setFinal(boolean isFinal) {
-		this.isFinal = isFinal;
-	}
-
-	public boolean isFinal() {
-		return isFinal;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/WorkflowProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/WorkflowProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/WorkflowProvenanceItem.java
deleted file mode 100644
index 5e593d2..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/provenance/item/WorkflowProvenanceItem.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.provenance.item;
-
-import java.sql.Timestamp;
-
-import net.sf.taverna.t2.facade.WorkflowInstanceFacade;
-import net.sf.taverna.t2.provenance.vocabulary.SharedVocabulary;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-
-/**
- * The first {@link ProvenanceItem} that the {@link ProvenanceConnector} will
- * receive for a workflow run. Contains the {@link Dataflow} itself as well as
- * the process id for the {@link WorkflowInstanceFacade} (facadeX:dataflowY).
- * Its child is a {@link ProcessProvenanceItem} and parent is the UUID of the
- * {@link Dataflow} itself
- * 
- * @author Ian Dunlop
- * @author Paolo Missier
- * @author Stuart Owen
- */
-public class WorkflowProvenanceItem extends AbstractProvenanceItem {
-	private Dataflow dataflow;
-	private SharedVocabulary eventType = SharedVocabulary.WORKFLOW_EVENT_TYPE;
-	private int[] index;
-	private boolean isFinal;
-
-	private Timestamp invocationStarted;
-
-	public Timestamp getInvocationStarted() {
-		return invocationStarted;
-	}
-
-	public WorkflowProvenanceItem() {
-	}
-
-	public Dataflow getDataflow() {
-		return dataflow;
-	}
-
-	public void setDataflow(Dataflow dataflow) {
-		this.dataflow = dataflow;
-	}
-
-	@Override
-	public SharedVocabulary getEventType() {
-		return eventType;
-	}
-
-	/**
-	 * @return the index
-	 */
-	public int[] getIndex() {
-		return index;
-	}
-
-	/**
-	 * @param index
-	 *            the index to set
-	 */
-	public void setIndex(int[] index) {
-		this.index = index;
-	}
-
-	/**
-	 * @return the isFinal
-	 */
-	public boolean isFinal() {
-		return isFinal;
-	}
-
-	/**
-	 * @param isFinal
-	 *            the isFinal to set
-	 */
-	public void setFinal(boolean isFinal) {
-		this.isFinal = isFinal;
-	}
-
-	public void setInvocationStarted(Timestamp invocationStarted) {
-		this.invocationStarted = invocationStarted;
-	}
-}


[32/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/BlueReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/BlueReference.java b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/BlueReference.java
new file mode 100644
index 0000000..0f5b372
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/BlueReference.java
@@ -0,0 +1,128 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.t2referencetest;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.taverna.reference.AbstractExternalReference;
+import org.apache.taverna.reference.DereferenceException;
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferencedDataNature;
+
+/**
+ * BlueReferences carry their data as an internal String and have a resolution
+ * cost of 1.0f whatever the value of that string.
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public class BlueReference extends AbstractExternalReference implements
+		ExternalReferenceSPI {
+
+	// Hold the 'value' of this reference, probably the simplest backing store
+	// possible for an ExternalReferenceSPI implementation :)
+	private String contents;
+
+	public BlueReference() {
+		//
+	}
+
+	public BlueReference(String contents) {
+		this.contents = contents;
+	}
+
+	/**
+	 * Set the 'value' of this reference as a string. It's not really a
+	 * reference type in any true sense of the word, but it'll do for testing
+	 * the augmentation system. This method is really here so you can configure
+	 * test beans from spring.
+	 */
+	public void setContents(String contents) {
+		this.contents = contents;
+	}
+
+	/**
+	 * Get the 'value' of this reference as a string, really just returns the
+	 * internal string representation.
+	 */
+	public String getContents() {
+		return this.contents;
+	}
+
+	/**
+	 * Fakes a de-reference operation, returning a byte stream over the string
+	 * data.
+	 */
+	@Override
+	public InputStream openStream(ReferenceContext arg0) {
+		try {
+			return new ByteArrayInputStream(this.contents
+					.getBytes(getCharset()));
+		} catch (UnsupportedEncodingException e) {
+			throw new DereferenceException(e);
+		}
+	}
+
+	/**
+	 * Default resolution cost of 1.0f whatever the contents
+	 */
+	@Override
+	public float getResolutionCost() {
+		return 1.0f;
+	}
+
+	/**
+	 * Data nature set to 'ReferencedDataNature.TEXT'
+	 */
+	@Override
+	public ReferencedDataNature getDataNature() {
+		return ReferencedDataNature.TEXT;
+	}
+
+	/**
+	 * Character encoding set to 'UTF-8'
+	 */
+	@Override
+	public String getCharset() {
+		return "UTF-8";
+	}
+
+	/**
+	 * String representation for testing, returns <code>blue{CONTENTS}</code>
+	 */
+	@Override
+	public String toString() {
+		return "blue{" + contents + "}";
+	}
+
+	@Override
+	public Long getApproximateSizeInBytes() {
+		return new Long(contents.getBytes().length);
+	}
+
+	@Override
+	public ExternalReferenceSPI clone() throws CloneNotSupportedException {
+		return new BlueReference(this.getContents());
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/DummyReferenceSet.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/DummyReferenceSet.java b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/DummyReferenceSet.java
new file mode 100644
index 0000000..13cb9e7
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/DummyReferenceSet.java
@@ -0,0 +1,51 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.t2referencetest;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceSet;
+import org.apache.taverna.reference.T2Reference;
+
+public class DummyReferenceSet implements ReferenceSet {
+	
+	private Set<ExternalReferenceSPI> refs;
+
+	public DummyReferenceSet(ExternalReferenceSPI ref) {
+		refs = Collections.singleton(ref);
+	}
+	
+	@Override
+	public T2Reference getId() {
+		return null;
+	}
+
+	@Override
+	public Set<ExternalReferenceSPI> getExternalReferences() {
+		return refs;
+	}
+
+	@Override
+	public Long getApproximateSizeInBytes() {
+		return null;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenBuilder.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenBuilder.java b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenBuilder.java
new file mode 100644
index 0000000..d14265f
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenBuilder.java
@@ -0,0 +1,106 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.t2referencetest;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.apache.taverna.reference.ExternalReferenceBuilderSPI;
+import org.apache.taverna.reference.ExternalReferenceConstructionException;
+import org.apache.taverna.reference.ReferenceContext;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Trivially build a GreenReference from an InputStream, implementing the
+ * ExternalReferenceBuilderSPI interface. Used in the augmentation test cases.
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public class GreenBuilder implements
+		ExternalReferenceBuilderSPI<GreenReference> {
+
+	private static Logger logger = Logger
+	.getLogger(GreenBuilder.class);
+
+	/**
+	 * Construct a new GreenReference from the given input stream, ignoring the
+	 * otherwise helpful context as we don't need any resources from it. We
+	 * assume UTF-8 encoding as that's what all the test reference types use,
+	 * again, with a real example this might have to be a bit smarter!
+	 * 
+	 * @throws ExternalReferenceConstructionException
+	 *             if there are any issues building the new GreenReference
+	 *             (which there won't be)
+	 */
+	@Override
+	public GreenReference createReference(InputStream is,
+			ReferenceContext context)
+			throws ExternalReferenceConstructionException {
+		GreenReference newReference = new GreenReference();
+		// Read input stream into the 'contents' property of the reference
+		BufferedReader in = new BufferedReader(new InputStreamReader(is));
+		try {
+			newReference.setContents(in.readLine());
+		} catch (IOException e) {
+			throw new ExternalReferenceConstructionException(e);
+		} finally {
+			try {
+				is.close();
+				in.close();
+			} catch (IOException e) {
+				logger.error("Unable to close streams", e);
+			}
+		}
+		return newReference;
+	}
+
+	/**
+	 * Construction cost fixed at 1.5f
+	 * 
+	 * @return <code>1.5f</code>
+	 */
+	@Override
+	public float getConstructionCost() {
+		return 1.5f;
+	}
+
+	/**
+	 * @return <code>{@link org.apache.taverna.t2referencetest.GreenReference GreenReference}.class</code>
+	 */
+	@Override
+	public Class<GreenReference> getReferenceType() {
+		return GreenReference.class;
+	}
+
+	/**
+	 * Doesn't use any context resources so is always enabled
+	 * 
+	 * @return <code>true</code>
+	 */
+	@Override
+	public boolean isEnabled(ReferenceContext arg0) {
+		return true;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenReference.java b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenReference.java
new file mode 100644
index 0000000..edc66a0
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenReference.java
@@ -0,0 +1,128 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.t2referencetest;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.taverna.reference.AbstractExternalReference;
+import org.apache.taverna.reference.DereferenceException;
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferencedDataNature;
+
+/**
+ * GreenReferences carry their data as an internal String and have a resolution
+ * cost of 1.1f whatever the value of that string.
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public class GreenReference extends AbstractExternalReference implements
+		ExternalReferenceSPI {
+
+	// Hold the 'value' of this reference, probably the simplest backing store
+	// possible for an ExternalReferenceSPI implementation :)
+	private String contents;
+
+	public GreenReference() {
+		//
+	}
+	
+	public GreenReference(String contents) {
+		this.contents = contents;
+	}
+	
+	/**
+	 * Set the 'value' of this reference as a string. It's not really a
+	 * reference type in any true sense of the word, but it'll do for testing
+	 * the augmentation system. This method is really here so you can configure
+	 * test beans from spring. 
+	 */
+	public void setContents(String contents) {
+		this.contents = contents;
+	}
+
+	/**
+	 * Get the 'value' of this reference as a string, really just returns the
+	 * internal string representation.
+	 */
+	public String getContents() {
+		return this.contents;
+	}
+
+	/**
+	 * Fakes a de-reference operation, returning a byte stream over the string
+	 * data.
+	 */
+	@Override
+	public InputStream openStream(ReferenceContext arg0) {
+		try {
+			return new ByteArrayInputStream(this.contents
+					.getBytes(getCharset()));
+		} catch (UnsupportedEncodingException e) {
+			throw new DereferenceException(e);
+		}
+	}
+
+	/**
+	 * Default resolution cost of 1.0f whatever the contents
+	 */
+	@Override
+	public float getResolutionCost() {
+		return 1.1f;
+	}
+
+	/**
+	 * Data nature set to 'ReferencedDataNature.TEXT'
+	 */
+	@Override
+	public ReferencedDataNature getDataNature() {
+		return ReferencedDataNature.TEXT;
+	}
+
+	/**
+	 * Character encoding set to 'UTF-8'
+	 */
+	@Override
+	public String getCharset() {
+		return "UTF-8";
+	}
+
+	/**
+	 * String representation for testing, returns <code>green{CONTENTS}</code>
+	 */
+	@Override
+	public String toString() {
+		return "green{" + contents + "}";
+	}
+
+	@Override
+	public Long getApproximateSizeInBytes() {
+		return new Long(contents.getBytes().length);
+	}
+
+	@Override
+	public ExternalReferenceSPI clone() throws CloneNotSupportedException {
+		return new GreenReference(this.getContents());
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenToRed.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenToRed.java b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenToRed.java
new file mode 100644
index 0000000..6c480e9
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenToRed.java
@@ -0,0 +1,64 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.t2referencetest;
+
+import org.apache.taverna.reference.ExternalReferenceTranslatorSPI;
+import org.apache.taverna.reference.ReferenceContext;
+
+public class GreenToRed implements
+		ExternalReferenceTranslatorSPI<GreenReference, RedReference> {
+
+	@Override
+	public RedReference createReference(GreenReference ref,
+			ReferenceContext context) {
+		RedReference newReference = new RedReference();
+		newReference.setContents(ref.getContents());
+		// Insert a two second pause to simulate reference translation and to
+		// test the behaviour of multiple concurrent translations
+		try {
+			Thread.sleep(2000);
+		} catch (InterruptedException ie) {
+			System.out
+					.println("Translation thread was interrupted, probably something wrong.");
+		}
+		return newReference;
+	}
+
+	@Override
+	public Class<GreenReference> getSourceReferenceType() {
+		return GreenReference.class;
+	}
+
+	@Override
+	public Class<RedReference> getTargetReferenceType() {
+		return RedReference.class;
+	}
+
+	@Override
+	public float getTranslationCost() {
+		return 0.4f;
+	}
+
+	@Override
+	public boolean isEnabled(ReferenceContext arg0) {
+		return true;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/RedReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/RedReference.java b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/RedReference.java
new file mode 100644
index 0000000..dd35127
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/RedReference.java
@@ -0,0 +1,128 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.t2referencetest;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.taverna.reference.AbstractExternalReference;
+import org.apache.taverna.reference.DereferenceException;
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferencedDataNature;
+
+/**
+ * RedReferences carry their data as an internal String and have a resolution
+ * cost of 0.9f whatever the value of that string.
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public class RedReference extends AbstractExternalReference implements
+		ExternalReferenceSPI {
+
+	// Hold the 'value' of this reference, probably the simplest backing store
+	// possible for an ExternalReferenceSPI implementation :)
+	private String contents;
+
+	public RedReference() {
+		//
+	}
+
+	public RedReference(String contents) {
+		this.contents = contents;
+	}
+
+	/**
+	 * Set the 'value' of this reference as a string. It's not really a
+	 * reference type in any true sense of the word, but it'll do for testing
+	 * the augmentation system. This method is really here so you can configure
+	 * test beans from spring.
+	 */
+	public void setContents(String contents) {
+		this.contents = contents;
+	}
+
+	/**
+	 * Get the 'value' of this reference as a string, really just returns the
+	 * internal string representation.
+	 */
+	public String getContents() {
+		return this.contents;
+	}
+
+	/**
+	 * Fakes a de-reference operation, returning a byte stream over the string
+	 * data.
+	 */
+	@Override
+	public InputStream openStream(ReferenceContext arg0) {
+		try {
+			return new ByteArrayInputStream(this.contents
+					.getBytes(getCharset()));
+		} catch (UnsupportedEncodingException e) {
+			throw new DereferenceException(e);
+		}
+	}
+
+	/**
+	 * Default resolution cost of 1.0f whatever the contents
+	 */
+	@Override
+	public float getResolutionCost() {
+		return 0.9f;
+	}
+
+	/**
+	 * Data nature set to 'ReferencedDataNature.TEXT'
+	 */
+	@Override
+	public ReferencedDataNature getDataNature() {
+		return ReferencedDataNature.TEXT;
+	}
+
+	/**
+	 * Character encoding set to 'UTF-8'
+	 */
+	@Override
+	public String getCharset() {
+		return "UTF-8";
+	}
+
+	/**
+	 * String representation for testing, returns <code>red{CONTENTS}</code>
+	 */
+	@Override
+	public String toString() {
+		return "red{" + contents + "}";
+	}
+	
+	@Override
+	public Long getApproximateSizeInBytes() {
+		return new Long(contents.getBytes().length);
+	}
+
+	@Override
+	public ExternalReferenceSPI clone() throws CloneNotSupportedException {
+		return new RedReference(this.getContents());
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/YellowReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/YellowReference.java b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/YellowReference.java
new file mode 100644
index 0000000..959a59f
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/YellowReference.java
@@ -0,0 +1,129 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.t2referencetest;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.taverna.reference.AbstractExternalReference;
+import org.apache.taverna.reference.DereferenceException;
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferencedDataNature;
+
+
+/**
+ * YellowReferences carry their data as an internal String and have a resolution
+ * cost of 1.0f whatever the value of that string.
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public class YellowReference extends AbstractExternalReference implements
+		ExternalReferenceSPI {
+
+	// Hold the 'value' of this reference, probably the simplest backing store
+	// possible for an ExternalReferenceSPI implementation :)
+	private String contents;
+
+	public YellowReference() {
+		//
+	}
+	
+	public YellowReference(String contents) {
+		this.contents = contents;
+	}
+	
+	/**
+	 * Set the 'value' of this reference as a string. It's not really a
+	 * reference type in any true sense of the word, but it'll do for testing
+	 * the augmentation system. This method is really here so you can configure
+	 * test beans from spring.
+	 */
+	public void setContents(String contents) {
+		this.contents = contents;
+	}
+
+	/**
+	 * Get the 'value' of this reference as a string, really just returns the
+	 * internal string representation.
+	 */
+	public String getContents() {
+		return this.contents;
+	}
+
+	/**
+	 * Fakes a de-reference operation, returning a byte stream over the string
+	 * data.
+	 */
+	@Override
+	public InputStream openStream(ReferenceContext arg0) {
+		try {
+			return new ByteArrayInputStream(this.contents
+					.getBytes(getCharset()));
+		} catch (UnsupportedEncodingException e) {
+			throw new DereferenceException(e);
+		}
+	}
+
+	/**
+	 * Default resolution cost of 1.0f whatever the contents
+	 */
+	@Override
+	public float getResolutionCost() {
+		return 1.0f;
+	}
+
+	/**
+	 * Data nature set to 'ReferencedDataNature.TEXT'
+	 */
+	@Override
+	public ReferencedDataNature getDataNature() {
+		return ReferencedDataNature.TEXT;
+	}
+
+	/**
+	 * Character encoding set to 'UTF-8'
+	 */
+	@Override
+	public String getCharset() {
+		return "UTF-8";
+	}
+
+	/**
+	 * String representation for testing, returns <code>yellow{CONTENTS}</code>
+	 */
+	@Override
+	public String toString() {
+		return "yellow{" + contents + "}";
+	}
+
+	@Override
+	public Long getApproximateSizeInBytes() {
+		return new Long(contents.getBytes().length);
+	}
+
+	@Override
+	public ExternalReferenceSPI clone() throws CloneNotSupportedException {
+		return new YellowReference(this.getContents());
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI b/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI
deleted file mode 100644
index 3f1a123..0000000
--- a/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI
+++ /dev/null
@@ -1,2 +0,0 @@
-# Implementation classes of ExternalReferenceBuilderSPI go here, one per line
-net.sf.taverna.t2referencetest.GreenBuilder
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceSPI
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceSPI b/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceSPI
deleted file mode 100644
index 20a63d6..0000000
--- a/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceSPI
+++ /dev/null
@@ -1,5 +0,0 @@
-# Implementation classes of ExternalReferenceSPI go here, one per line
-net.sf.taverna.t2referencetest.GreenReference
-net.sf.taverna.t2referencetest.BlueReference
-net.sf.taverna.t2referencetest.RedReference
-net.sf.taverna.t2referencetest.YellowReference
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI b/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI
deleted file mode 100644
index 7fff1a3..0000000
--- a/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI
+++ /dev/null
@@ -1,2 +0,0 @@
-# Implementation classes of ExternalReferenceTranslatorSPI go here, one per line
-net.sf.taverna.t2referencetest.GreenToRed
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceBuilderSPI
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceBuilderSPI b/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceBuilderSPI
new file mode 100644
index 0000000..c896a11
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceBuilderSPI
@@ -0,0 +1,2 @@
+# Implementation classes of ExternalReferenceBuilderSPI go here, one per line
+org.apache.taverna.t2referencetest.GreenBuilder
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceSPI
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceSPI b/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceSPI
new file mode 100644
index 0000000..7e9242c
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceSPI
@@ -0,0 +1,5 @@
+# Implementation classes of ExternalReferenceSPI go here, one per line
+org.apache.taverna.t2referencetest.GreenReference
+org.apache.taverna.t2referencetest.BlueReference
+org.apache.taverna.t2referencetest.RedReference
+org.apache.taverna.t2referencetest.YellowReference
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceTranslatorSPI
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceTranslatorSPI b/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceTranslatorSPI
new file mode 100644
index 0000000..c78a2c5
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceTranslatorSPI
@@ -0,0 +1,2 @@
+# Implementation classes of ExternalReferenceTranslatorSPI go here, one per line
+org.apache.taverna.t2referencetest.GreenToRed
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context-osgi.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context-osgi.xml b/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context-osgi.xml
index dc6c0a4..8250b0d 100644
--- a/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context-osgi.xml
+++ b/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context-osgi.xml
@@ -6,13 +6,13 @@
                                  http://www.springframework.org/schema/osgi 
                                  http://www.springframework.org/schema/osgi/spring-osgi.xsd" >
 
-	<service ref="greenBuilder" interface="net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI" />
+	<service ref="greenBuilder" interface="org.apache.taverna.reference.ExternalReferenceBuilderSPI" />
 
-	<service ref="greenReference" interface="net.sf.taverna.t2.reference.ExternalReferenceSPI" />
-	<service ref="blueReference" interface="net.sf.taverna.t2.reference.ExternalReferenceSPI" />
-	<service ref="redReference" interface="net.sf.taverna.t2.reference.ExternalReferenceSPI" />
-	<service ref="yellowReference" interface="net.sf.taverna.t2.reference.ExternalReferenceSPI" />
+	<service ref="greenReference" interface="org.apache.taverna.reference.ExternalReferenceSPI" />
+	<service ref="blueReference" interface="org.apache.taverna.reference.ExternalReferenceSPI" />
+	<service ref="redReference" interface="org.apache.taverna.reference.ExternalReferenceSPI" />
+	<service ref="yellowReference" interface="org.apache.taverna.reference.ExternalReferenceSPI" />
 		
-	<service ref="greenToRedTranslator" interface="net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI" />
+	<service ref="greenToRedTranslator" interface="org.apache.taverna.reference.ExternalReferenceTranslatorSPI" />
 
 </beans:beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context.xml b/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context.xml
index 8838328..55d1f04 100644
--- a/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context.xml
+++ b/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context.xml
@@ -4,13 +4,13 @@
 	xsi:schemaLocation="http://www.springframework.org/schema/beans 
                            http://www.springframework.org/schema/beans/spring-beans.xsd">
                            
-	<bean id="greenBuilder" class="net.sf.taverna.t2referencetest.GreenBuilder" />
+	<bean id="greenBuilder" class="org.apache.taverna.t2referencetest.GreenBuilder" />
 
-	<bean id="greenReference" class="net.sf.taverna.t2referencetest.GreenReference" />
-	<bean id="blueReference" class="net.sf.taverna.t2referencetest.BlueReference" />
-	<bean id="redReference" class="net.sf.taverna.t2referencetest.RedReference" />
-	<bean id="yellowReference" class="net.sf.taverna.t2referencetest.YellowReference" />
+	<bean id="greenReference" class="org.apache.taverna.t2referencetest.GreenReference" />
+	<bean id="blueReference" class="org.apache.taverna.t2referencetest.BlueReference" />
+	<bean id="redReference" class="org.apache.taverna.t2referencetest.RedReference" />
+	<bean id="yellowReference" class="org.apache.taverna.t2referencetest.YellowReference" />
 
-	<bean id="greenToRedTranslator" class="net.sf.taverna.t2referencetest.GreenToRed" />
+	<bean id="greenToRedTranslator" class="org.apache.taverna.t2referencetest.GreenToRed" />
 
 </beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/BlueReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/BlueReference.hbm.xml b/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/BlueReference.hbm.xml
deleted file mode 100644
index 9483784..0000000
--- a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/BlueReference.hbm.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
-                "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-                "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!-- Hibernate mapping for blue reference bean -->
-<hibernate-mapping>
-	<joined-subclass
-		name="net.sf.taverna.t2referencetest.BlueReference"
-		extends="net.sf.taverna.t2.reference.AbstractExternalReference">
-		<!-- Link to primary key from abstract superclass -->
-		<key column="bean_id" />
-		<!-- Dummy reference specific props -->
-		<property name="contents" type="string" />
-	</joined-subclass>
-</hibernate-mapping>
-

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/GreenReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/GreenReference.hbm.xml b/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/GreenReference.hbm.xml
deleted file mode 100644
index dc65151..0000000
--- a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/GreenReference.hbm.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
-                "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-                "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!-- Hibernate mapping for green reference bean -->
-<hibernate-mapping>
-	<joined-subclass
-		name="net.sf.taverna.t2referencetest.GreenReference"
-		extends="net.sf.taverna.t2.reference.AbstractExternalReference">
-		<!-- Link to primary key from abstract superclass -->
-		<key column="bean_id" />
-		<!-- Dummy reference specific props -->
-		<property name="contents" type="string" />
-	</joined-subclass>
-</hibernate-mapping>
-

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/RedReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/RedReference.hbm.xml b/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/RedReference.hbm.xml
deleted file mode 100644
index 176f60d..0000000
--- a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/RedReference.hbm.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
-                "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-                "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!-- Hibernate mapping for red reference bean -->
-<hibernate-mapping>
-	<joined-subclass
-		name="net.sf.taverna.t2referencetest.RedReference"
-		extends="net.sf.taverna.t2.reference.AbstractExternalReference">
-		<!-- Link to primary key from abstract superclass -->
-		<key column="bean_id" />
-		<!-- Dummy reference specific props -->
-		<property name="contents" type="string" />
-	</joined-subclass>
-</hibernate-mapping>
-

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/YellowReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/YellowReference.hbm.xml b/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/YellowReference.hbm.xml
deleted file mode 100644
index 6f357f8..0000000
--- a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/YellowReference.hbm.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
-                "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-                "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!-- Hibernate mapping for yellow reference bean -->
-<hibernate-mapping>
-	<joined-subclass
-		name="net.sf.taverna.t2referencetest.YellowReference"
-		extends="net.sf.taverna.t2.reference.AbstractExternalReference">
-		<!-- Link to primary key from abstract superclass -->
-		<key column="bean_id" />
-		<!-- Dummy reference specific props -->
-		<property name="contents" type="string" />
-	</joined-subclass>
-</hibernate-mapping>
-

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/BlueReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/BlueReference.hbm.xml b/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/BlueReference.hbm.xml
new file mode 100644
index 0000000..84c0c8b
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/BlueReference.hbm.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Hibernate mapping for blue reference bean -->
+<hibernate-mapping>
+  <joined-subclass extends="org.apache.taverna.reference.AbstractExternalReference" name="org.apache.taverna.t2referencetest.BlueReference">
+    <!-- Link to primary key from abstract superclass -->
+    <key column="bean_id"/>
+    <!-- Dummy reference specific props -->
+    <property name="contents" type="string"/>
+  </joined-subclass>
+</hibernate-mapping>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/GreenReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/GreenReference.hbm.xml b/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/GreenReference.hbm.xml
new file mode 100644
index 0000000..5cc3510
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/GreenReference.hbm.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Hibernate mapping for green reference bean -->
+<hibernate-mapping>
+  <joined-subclass extends="org.apache.taverna.reference.AbstractExternalReference" name="org.apache.taverna.t2referencetest.GreenReference">
+    <!-- Link to primary key from abstract superclass -->
+    <key column="bean_id"/>
+    <!-- Dummy reference specific props -->
+    <property name="contents" type="string"/>
+  </joined-subclass>
+</hibernate-mapping>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/RedReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/RedReference.hbm.xml b/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/RedReference.hbm.xml
new file mode 100644
index 0000000..3e4927c
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/RedReference.hbm.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Hibernate mapping for red reference bean -->
+<hibernate-mapping>
+  <joined-subclass extends="org.apache.taverna.reference.AbstractExternalReference" name="org.apache.taverna.t2referencetest.RedReference">
+    <!-- Link to primary key from abstract superclass -->
+    <key column="bean_id"/>
+    <!-- Dummy reference specific props -->
+    <property name="contents" type="string"/>
+  </joined-subclass>
+</hibernate-mapping>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/YellowReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/YellowReference.hbm.xml b/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/YellowReference.hbm.xml
new file mode 100644
index 0000000..af62328
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/YellowReference.hbm.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Hibernate mapping for yellow reference bean -->
+<hibernate-mapping>
+  <joined-subclass extends="org.apache.taverna.reference.AbstractExternalReference" name="org.apache.taverna.t2referencetest.YellowReference">
+    <!-- Link to primary key from abstract superclass -->
+    <key column="bean_id"/>
+    <!-- Dummy reference specific props -->
+    <property name="contents" type="string"/>
+  </joined-subclass>
+</hibernate-mapping>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/FileReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/FileReference.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/FileReference.java
deleted file mode 100644
index eeca752..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/FileReference.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl.external.file;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-
-import net.sf.taverna.t2.reference.AbstractExternalReference;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferencedDataNature;
-
-/**
- * Implementation of ExternalReference used to refer to data held in a locally
- * accessible file. Inherits from
- * {@link net.sf.taverna.t2.reference.AbstractExternalReference
- * AbstractExternalReference} to enable hibernate based persistence.
- * 
- * @author Tom Oinn
- */
-public class FileReference extends AbstractExternalReference implements
-		ExternalReferenceSPI {
-	private String filePathString = null;
-	private String charset = null;
-	private File file = null;
-	private String dataNatureName = ReferencedDataNature.UNKNOWN.name();
-
-	/**
-	 * Explicitly declare default constructor, will be used by hibernate when
-	 * constructing instances of this bean from the database.
-	 */
-	public FileReference() {
-		super();
-	}
-
-	/**
-	 * Construct a file reference pointed at the specified file and with no
-	 * character set defined.
-	 */
-	public FileReference(File theFile) {
-		super();
-		this.file = theFile.getAbsoluteFile();
-		this.filePathString = this.file.getPath();
-		this.charset = Charset.defaultCharset().name();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public InputStream openStream(ReferenceContext context) {
-		try {
-			return new FileInputStream(file);
-		} catch (FileNotFoundException e) {
-			throw new RuntimeException(e);
-		}
-	}
-
-	/**
-	 * Setter used by hibernate to set the charset property of the file
-	 * reference
-	 */
-	public void setCharset(String charset) {
-		this.charset = charset;
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public String getCharset() {
-		return this.charset;
-	}
-
-	/**
-	 * Setter used by hibernate to set the file path property of the file
-	 * reference
-	 */
-	public void setFilePath(String filePathString) {
-		this.filePathString = filePathString;
-		this.file = new File(filePathString).getAbsoluteFile();
-	}
-
-	/**
-	 * Getter used by hibernate to retrieve the file path string property
-	 */
-	public String getFilePath() {
-		return this.filePathString;
-	}
-
-	/**
-	 * Human readable string form for debugging, should not be regarded as
-	 * stable.
-	 */
-	@Override
-	public String toString() {
-		return "file{" + file.getAbsolutePath() + "}";
-	}
-
-	@Override
-	public int hashCode() {
-		final int prime = 31;
-		int result = 1;
-		result = prime * result + ((file == null) ? 0 : file.hashCode());
-		return result;
-	}
-
-	@Override
-	public boolean equals(Object obj) {
-		if (this == obj)
-			return true;
-		if (obj == null)
-			return false;
-		if (getClass() != obj.getClass())
-			return false;
-		final FileReference other = (FileReference) obj;
-		if (file == null) {
-			if (other.file != null)
-				return false;
-		} else if (!file.equals(other.file))
-			return false;
-		return true;
-	}
-
-	@Override
-	public Long getApproximateSizeInBytes() {
-		return new Long(file.length());
-	}
-
-	/**
-	 * @return the dataNature
-	 */
-	@Override
-	public ReferencedDataNature getDataNature() {
-		return Enum.valueOf(ReferencedDataNature.class, getDataNatureName());
-	}
-
-	/**
-	 * @param dataNature
-	 *            the dataNature to set
-	 */
-	public void setDataNature(ReferencedDataNature dataNature) {
-		setDataNatureName(dataNature.name());
-	}
-
-	/**
-	 * @return the file
-	 */
-	public final File getFile() {
-		return file;
-	}
-
-	@Override
-	public float getResolutionCost() {
-		return (float) 100.0;
-	}
-
-	/**
-	 * @return the dataNatureName
-	 */
-	public String getDataNatureName() {
-		return dataNatureName;
-	}
-
-	/**
-	 * @param dataNatureName
-	 *            the dataNatureName to set
-	 */
-	public void setDataNatureName(String dataNatureName) {
-		this.dataNatureName = dataNatureName;
-	}
-
-	public void deleteData() {
-		try {
-			getFile().delete();
-		} catch (SecurityException e) {
-			// TODO
-		}
-	}
-
-	@Override
-	public FileReference clone() {
-		FileReference result = new FileReference();
-		result.setFilePath(this.getFilePath());
-		result.setCharset(this.getCharset());
-		result.setDataNature(this.getDataNature());
-		return result;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/FileToFileReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/FileToFileReference.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/FileToFileReference.java
deleted file mode 100644
index cde79a5..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/FileToFileReference.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl.external.file;
-
-import java.io.File;
-import java.io.IOException;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ValueToReferenceConversionException;
-import net.sf.taverna.t2.reference.ValueToReferenceConverterSPI;
-
-/**
- * Converts java.lang.File instances to FileReference reference type
- * 
- * @author Tom Oinn
- */
-public class FileToFileReference implements ValueToReferenceConverterSPI {
-	/*
-	 * TODO - should probably do more sophisticated checks such as whether the
-	 * file is a file or directory etc etc, for now just checks whether the
-	 * specified object is a java.io.File
-	 */
-	@Override
-	public boolean canConvert(Object o, ReferenceContext context) {
-		return (o instanceof File);
-	}
-
-	/**
-	 * Return a FileReference
-	 */
-	@Override
-	public ExternalReferenceSPI convert(Object o, ReferenceContext context)
-			throws ValueToReferenceConversionException {
-		FileReference result = new FileReference();
-		try {
-			result.setFilePath(((File) o).getCanonicalPath());
-		} catch (IOException ioe) {
-			throw new ValueToReferenceConversionException(ioe);
-		}
-		return result;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/package.html
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/package.html b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/package.html
deleted file mode 100644
index 8be59b3..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/package.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<body>
-Support for references to a file on a local (or otherwise mounted)
-filesystem
-</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/HttpReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/HttpReference.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/HttpReference.java
deleted file mode 100644
index d72eed6..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/HttpReference.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl.external.http;
-
-import static java.lang.System.currentTimeMillis;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Date;
-
-import net.sf.taverna.t2.reference.AbstractExternalReference;
-import net.sf.taverna.t2.reference.DereferenceException;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ExternalReferenceValidationException;
-import net.sf.taverna.t2.reference.ReferenceContext;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.methods.HeadMethod;
-
-/**
- * Implementation of ExternalReference used to refer to data held in a locally
- * accessible file. Inherits from
- * {@link net.sf.taverna.t2.reference.AbstractExternalReference
- * AbstractExternalReference} to enable hibernate based persistence.
- * 
- * @author Tom Oinn
- */
-public class HttpReference extends AbstractExternalReference implements
-		ExternalReferenceSPI {
-	private String httpUrlString = null;
-	private URL httpUrl = null;
-	private String charsetName = null;
-	private boolean charsetFetched = false;
-	private transient Long cachedLength;
-	private transient Date cacheTime;
-
-	/**
-	 * Explicitly declare default constructor, will be used by hibernate when
-	 * constructing instances of this bean from the database.
-	 */
-	public HttpReference() {
-		super();
-	}
-
-	/**
-	 * Return the data at the {@link URL} represented by this external reference
-	 */
-	@Override
-	public InputStream openStream(ReferenceContext context)
-			throws DereferenceException {
-		try {
-			return httpUrl.openStream();
-		} catch (IOException e) {
-			throw new DereferenceException(e);
-		}
-	}
-
-	@Override
-	public String getCharset() throws DereferenceException {
-		if (charsetFetched)
-			return charsetName;
-		charsetFetched = true;
-		if (!httpUrl.getProtocol().equals("http")
-				&& !httpUrl.getProtocol().equals("https")) {
-			charsetName = null;
-			return null;
-		}
-		HeadMethod method = new HeadMethod(httpUrl.toExternalForm());
-		HttpClient httpClient = new HttpClient();
-		try {
-			httpClient.executeMethod(method);
-			charsetName = method.getResponseCharSet();
-			return charsetName;
-		} catch (HttpException e) {
-			// throw new DereferenceException(e);
-		} catch (IOException e) {
-			// throw new DereferenceException(e);
-		} finally {
-			method.releaseConnection();
-		}
-		charsetName = null;
-		return null;
-	}
-
-	/**
-	 * Setter used by hibernate to set the file path property of the file
-	 * reference
-	 * 
-	 * @throws ExternalReferenceValidationException
-	 *             if there is some problem parsing the supplied string as a URL
-	 */
-	public void setHttpUrlString(String httpUrlString) {
-		try {
-			this.httpUrlString = httpUrlString;
-			this.httpUrl = new URL(httpUrlString);
-		} catch (MalformedURLException e) {
-			throw new ExternalReferenceValidationException(e);
-		}
-	}
-
-	/**
-	 * Getter used by hibernate to retrieve the file path string property
-	 */
-	public String getHttpUrlString() {
-		return this.httpUrlString;
-	}
-
-	/**
-	 * Human readable string form for debugging, should not be regarded as
-	 * stable.
-	 */
-	@Override
-	public String toString() {
-		return "http{" + httpUrl.toExternalForm() + "}";
-	}
-
-	@Override
-	public int hashCode() {
-		final int prime = 31;
-		int result = 1;
-		result = prime * result
-				+ ((httpUrl == null) ? 0 : httpUrl.toExternalForm().hashCode());
-		return result;
-	}
-
-	@Override
-	public boolean equals(Object obj) {
-		if (this == obj)
-			return true;
-		if (obj == null)
-			return false;
-		if (!(obj instanceof HttpReference))
-			return false;
-		final HttpReference other = (HttpReference) obj;
-		if (httpUrl == null) {
-			if (other.httpUrl != null)
-				return false;
-		} else if (!httpUrl.toExternalForm().equals(
-				other.httpUrl.toExternalForm()))
-			return false;
-		return true;
-	}
-
-	// One minute
-	private static final int CACHE_TIMEOUT = 60000;
-
-	@Override
-	public Long getApproximateSizeInBytes() {
-		long now = currentTimeMillis();
-		if (cachedLength != null && cacheTime != null
-				&& cacheTime.getTime() + CACHE_TIMEOUT > now)
-			return cachedLength;
-		try {
-			HttpURLConnection c = (HttpURLConnection) httpUrl.openConnection();
-			c.setRequestMethod("HEAD");
-			c.connect();
-			String lenString = c.getHeaderField("Content-Length");
-			if (lenString != null && !lenString.isEmpty()) {
-				cachedLength = new Long(lenString);
-				cacheTime = new Date(now);
-				return cachedLength;
-			}
-			// there is no Content-Length field so we cannot know the size
-		} catch (Exception e) {
-			// something went wrong, but we don't care what
-		}
-		cachedLength = null;
-		cacheTime = null;
-		return new Long(-1);
-	}
-
-	/**
-	 * @return the httpUrl
-	 */
-	public final URL getHttpUrl() {
-		return httpUrl;
-	}
-
-	@Override
-	public float getResolutionCost() {
-		return (float) 200.0;
-	}
-
-	public void deleteData() {
-		throw new UnsupportedOperationException(
-				"Cannot delete data referenced by a URL");
-	}
-
-	@Override
-	public HttpReference clone() {
-		HttpReference result = new HttpReference();
-		result.setHttpUrlString(this.getHttpUrlString());
-		return result;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/UrlToHttpReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/UrlToHttpReference.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/UrlToHttpReference.java
deleted file mode 100644
index 67c3fc8..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/UrlToHttpReference.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl.external.http;
-
-import java.net.URL;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ValueToReferenceConversionException;
-import net.sf.taverna.t2.reference.ValueToReferenceConverterSPI;
-
-/**
- * Convert a URL with http protocol to a HttpReference reference type
- * 
- * @author Tom Oinn
- * 
- */
-public class UrlToHttpReference implements ValueToReferenceConverterSPI {
-	/**
-	 * Can convert if the object is an instance of java.net.URL and the protocol
-	 * is HTTP
-	 */
-	@Override
-	public boolean canConvert(Object o, ReferenceContext context) {
-		if (o instanceof URL) {
-			String protocol = ((URL) o).getProtocol();
-			if (protocol.equalsIgnoreCase("http") || protocol.equals("https"))
-				return true;
-		}
-		return false;
-	}
-
-	/**
-	 * Return a new HttpReference constructed from
-	 * <code>((URL)o).toExternalForm()</code>
-	 */
-	@Override
-	public ExternalReferenceSPI convert(Object o, ReferenceContext context)
-			throws ValueToReferenceConversionException {
-		HttpReference result = new HttpReference();
-		result.setHttpUrlString(((URL) o).toExternalForm());
-		return result;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/package.html
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/package.html b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/package.html
deleted file mode 100644
index 49d1d32..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/package.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<body>
-Support for references to a URL with the HTTP protocol
-</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/BooleanToStringReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/BooleanToStringReference.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/BooleanToStringReference.java
deleted file mode 100644
index 77d54fb..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/BooleanToStringReference.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl.external.object;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ValueToReferenceConversionException;
-import net.sf.taverna.t2.reference.ValueToReferenceConverterSPI;
-
-/**
- * Convert a java.lang.Boolean to a StringReference.
- * 
- * @author Alan R Williams
- */
-public class BooleanToStringReference implements ValueToReferenceConverterSPI {
-	/**
-	 * Can convert if the object is an instance of java.lang.Boolean
-	 */
-	@Override
-	public boolean canConvert(Object o, ReferenceContext context) {
-		return o instanceof Boolean;
-	}
-
-	/**
-	 * Return a new InlineStringReference wrapping the supplied String
-	 */
-	@Override
-	public ExternalReferenceSPI convert(Object o, ReferenceContext context)
-			throws ValueToReferenceConversionException {
-		InlineStringReference result = new InlineStringReference();
-		String stringValue = ((Boolean) o).toString();
-		result.setContents(stringValue);
-		return result;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/ByteArrayToByteArrayReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/ByteArrayToByteArrayReference.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/ByteArrayToByteArrayReference.java
deleted file mode 100644
index 41e60ea..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/ByteArrayToByteArrayReference.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl.external.object;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ValueToReferenceConversionException;
-import net.sf.taverna.t2.reference.ValueToReferenceConverterSPI;
-
-/**
- * Convert a byte[] to a ByteArrayReference
- * 
- * @author Tom Oinn
- */
-public class ByteArrayToByteArrayReference implements
-		ValueToReferenceConverterSPI {
-	/**
-	 * Can convert if the object is an instance of byte[]
-	 */
-	@Override
-	public boolean canConvert(Object o, ReferenceContext context) {
-		return (o instanceof byte[]);
-	}
-
-	/**
-	 * Return a new InlineByteArrayReference wrapping the supplied byte[]
-	 */
-	@Override
-	public ExternalReferenceSPI convert(Object o, ReferenceContext context)
-			throws ValueToReferenceConversionException {
-		InlineByteArrayReference result = new InlineByteArrayReference();
-		result.setValue((byte[]) o);
-		return result;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/CharacterToStringReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/CharacterToStringReference.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/CharacterToStringReference.java
deleted file mode 100644
index c5d6c66..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/CharacterToStringReference.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl.external.object;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ValueToReferenceConversionException;
-import net.sf.taverna.t2.reference.ValueToReferenceConverterSPI;
-
-/**
- * Convert a {@link Character} to a StringReference.
- * 
- * @author Alan R Williams
- */
-public class CharacterToStringReference implements ValueToReferenceConverterSPI {
-	/**
-	 * Can convert if the object is an instance of java.lang.Character
-	 */
-	@Override
-	public boolean canConvert(Object o, ReferenceContext context) {
-		return (o instanceof Character);
-	}
-
-	/**
-	 * Return a new {@link InlineStringReference} wrapping the supplied String
-	 */
-	@Override
-	public ExternalReferenceSPI convert(Object o, ReferenceContext context)
-			throws ValueToReferenceConversionException {
-		InlineStringReference result = new InlineStringReference();
-		String stringValue = ((Character) o).toString();
-		result.setContents(stringValue);
-		return result;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteArrayReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteArrayReference.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteArrayReference.java
deleted file mode 100644
index fac9f02..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteArrayReference.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl.external.object;
-
-import static org.apache.commons.codec.binary.Base64.decodeBase64;
-import static org.apache.commons.codec.binary.Base64.encodeBase64;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-
-import net.sf.taverna.t2.reference.AbstractExternalReference;
-import net.sf.taverna.t2.reference.DereferenceException;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ValueCarryingExternalReference;
-
-/**
- * A reference implementation that inlines an array of bytes. Rather
- * unpleasantly this currently exposes the byte array to Hibernate through a
- * textual value, as Derby allows long textual values but not long binary ones
- * (yuck). As it uses a fixed character set (UTF-8) to store and load I believe
- * this doesn't break things.
- * <p>
- * Unfortunately this does break things (binaries get corrupted) so I've added
- * base64 encoding of the value as a workaround.
- * 
- * @author Tom Oinn
- * @author David Withers
- */
-public class InlineByteArrayReference extends AbstractExternalReference
-		implements ValueCarryingExternalReference<byte[]> {
-	private byte[] bytes = new byte[0];
-
-	public void setValue(byte[] newBytes) {
-		this.bytes = newBytes;
-	}
-
-	@Override
-	public byte[] getValue() {
-		return bytes;
-	}
-
-	@Override
-	public Class<byte[]> getValueType() {
-		return byte[].class;
-	}
-
-	@Override
-	public InputStream openStream(ReferenceContext context)
-			throws DereferenceException {
-		return new ByteArrayInputStream(bytes);
-	}
-
-	private static final Charset charset = Charset.forName("UTF-8");
-
-	public String getContents() {
-		return new String(encodeBase64(bytes), charset);
-	}
-
-	public void setContents(String contentsAsString) {
-		this.bytes = decodeBase64(contentsAsString.getBytes(charset));
-	}
-
-	@Override
-	public Long getApproximateSizeInBytes() {
-		return new Long(bytes.length);
-	}
-
-	@Override
-	public InlineByteArrayReference clone() {
-		InlineByteArrayReference result = new InlineByteArrayReference();
-		result.setValue(this.getValue().clone());
-		return result;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteArrayReferenceBuilder.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteArrayReferenceBuilder.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteArrayReferenceBuilder.java
deleted file mode 100644
index f58f77b..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteArrayReferenceBuilder.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl.external.object;
-
-import static net.sf.taverna.t2.reference.impl.external.object.StreamToByteArrayConverter.readFile;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI;
-import net.sf.taverna.t2.reference.ExternalReferenceConstructionException;
-import net.sf.taverna.t2.reference.ReferenceContext;
-
-/**
- * Build an InlineByteArrayReference from an InputStream
- * 
- * @author Tom Oinn
- * 
- */
-public class InlineByteArrayReferenceBuilder implements
-		ExternalReferenceBuilderSPI<InlineByteArrayReference> {
-	@Override
-	public InlineByteArrayReference createReference(InputStream byteStream,
-			ReferenceContext context) {
-		try {
-			byte[] contents = readFile(byteStream);
-			InlineByteArrayReference ref = new InlineByteArrayReference();
-			ref.setValue(contents);
-			return ref;
-		} catch (IOException e) {
-			throw new ExternalReferenceConstructionException(e);
-		}
-	}
-
-	@Override
-	public float getConstructionCost() {
-		return 0.1f;
-	}
-
-	@Override
-	public Class<InlineByteArrayReference> getReferenceType() {
-		return InlineByteArrayReference.class;
-	}
-
-	@Override
-	public boolean isEnabled(ReferenceContext context) {
-		return true;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteToInlineStringTranslator.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteToInlineStringTranslator.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteToInlineStringTranslator.java
deleted file mode 100644
index b9aa66c..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteToInlineStringTranslator.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package net.sf.taverna.t2.reference.impl.external.object;
-
-import java.io.UnsupportedEncodingException;
-
-import net.sf.taverna.t2.reference.ExternalReferenceConstructionException;
-import net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-
-public class InlineByteToInlineStringTranslator
-		implements
-		ExternalReferenceTranslatorSPI<InlineByteArrayReference, InlineStringReference> {
-	@Override
-	public InlineStringReference createReference(
-			InlineByteArrayReference sourceReference, ReferenceContext context) {
-		String contents;
-		try {
-			String charset = sourceReference.getCharset();
-			if (charset == null)
-				// usual fallback:
-				charset = "UTF-8";
-			contents = new String(sourceReference.getValue(), charset);
-		} catch (UnsupportedEncodingException e) {
-			String msg = "Unknown character set "
-					+ sourceReference.getCharset();
-			throw new ExternalReferenceConstructionException(msg, e);
-		}
-		InlineStringReference ref = new InlineStringReference();
-		ref.setContents(contents);
-		return ref;
-	}
-
-	@Override
-	public Class<InlineByteArrayReference> getSourceReferenceType() {
-		return InlineByteArrayReference.class;
-	}
-
-	@Override
-	public Class<InlineStringReference> getTargetReferenceType() {
-		return InlineStringReference.class;
-	}
-
-	@Override
-	public boolean isEnabled(ReferenceContext context) {
-		return true;
-	}
-
-	@Override
-	public float getTranslationCost() {
-		return 0.001f;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineStringReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineStringReference.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineStringReference.java
deleted file mode 100644
index cf3de46..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineStringReference.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl.external.object;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-
-import net.sf.taverna.t2.reference.AbstractExternalReference;
-import net.sf.taverna.t2.reference.DereferenceException;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferencedDataNature;
-import net.sf.taverna.t2.reference.ValueCarryingExternalReference;
-
-/**
- * Contains and references a String value
- * 
- * @author Tom Oinn
- */
-public class InlineStringReference extends AbstractExternalReference implements
-		ValueCarryingExternalReference<String> {
-	/**
-	 * Hold the 'value' of this reference, probably the simplest backing store
-	 * possible for an ExternalReferenceSPI implementation :)
-	 */
-	private String contents;
-	private transient Long length;
-
-	/**
-	 * Set the 'value' of this reference as a string. It's not really a
-	 * reference type in any true sense of the word, but it'll do for testing
-	 * the augmentation system. This method is really here so you can configure
-	 * test beans from spring.
-	 */
-	public void setContents(String contents) {
-		this.contents = contents;
-	}
-
-	/**
-	 * Get the 'value' of this reference as a string, really just returns the
-	 * internal string representation.
-	 */
-	public String getContents() {
-		return this.contents;
-	}
-
-	/**
-	 * Fakes a de-reference operation, returning a byte stream over the string
-	 * data.
-	 */
-	@Override
-	public InputStream openStream(ReferenceContext arg0) {
-		try {
-			return new ByteArrayInputStream(contents.getBytes(getCharset()));
-		} catch (UnsupportedEncodingException e) {
-			throw new DereferenceException(e);
-		}
-	}
-
-	/**
-	 * Default resolution cost of 0.0f whatever the contents
-	 */
-	@Override
-	public float getResolutionCost() {
-		return 0.0f;
-	}
-
-	/**
-	 * Data nature set to 'ReferencedDataNature.TEXT'
-	 */
-	@Override
-	public ReferencedDataNature getDataNature() {
-		return ReferencedDataNature.TEXT;
-	}
-
-	/**
-	 * Character encoding set to 'UTF-8' by default
-	 */
-	@Override
-	public String getCharset() {
-		return "UTF-8";
-	}
-
-	/**
-	 * String representation for testing, returns <code>string{CONTENTS}</code>
-	 */
-	@Override
-	public String toString() {
-		return "string{" + contents + "}";
-	}
-
-	@Override
-	public String getValue() {
-		return getContents();
-	}
-
-	@Override
-	public Class<String> getValueType() {
-		return String.class;
-	}
-
-	@Override
-	public Long getApproximateSizeInBytes() {
-		if (length == null)
-			length = new Long(contents.getBytes().length);
-		return length;
-	}
-
-	@Override
-	public InlineStringReference clone() {
-		InlineStringReference result = new InlineStringReference();
-		result.setContents(this.getContents());
-		return result;
-	}
-}


[18/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/PrefixDotProduct.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/PrefixDotProduct.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/PrefixDotProduct.java
deleted file mode 100644
index 549ddf1..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/PrefixDotProduct.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.iteration;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import net.sf.taverna.t2.invocation.TreeCache;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Job;
-
-/**
- * Matches jobs where the index array of the job on index 0 is the prefix of the
- * index array of the job on index 1. This node can only ever have exactly two
- * child nodes!
- * 
- * @author Tom Oinn
- */
-@SuppressWarnings("serial")
-public class PrefixDotProduct extends DotProduct {
-	@Override
-	protected synchronized final void cleanUp(String owningProcess) {
-		ownerToCache.remove(owningProcess);
-	}
-
-	@Override
-	public void innerReceiveJob(int inputIndex, Job newJob) {
-		String owningProcess = newJob.getOwningProcess();
-		TreeCache[] caches;
-		synchronized (ownerToCache) {
-			caches = ownerToCache.get(owningProcess);
-			// Create the caches if not already initialized
-			if (caches == null) {
-				caches = new TreeCache[getChildCount()];
-				for (int i = 0; i < getChildCount(); i++)
-					caches[i] = new TreeCache();
-				ownerToCache.put(owningProcess, caches);
-			}
-		}
-
-		// Store the job
-		caches[inputIndex].insertJob(newJob);
-
-		/*
-		 * If this job came in on index 0 we have to find all jobs in the cache
-		 * for index 1 which have the index array as a prefix. Fortunately this
-		 * is quite easy due to the tree structure of the cache, we can just ask
-		 * for all nodes in the cache with that index.
-		 */
-		if (inputIndex == 0) {
-			int[] prefixIndexArray = newJob.getIndex();
-			List<Job> matchingJobs;
-			synchronized (caches[1]) {
-				// Match all jobs and remove them so other calls can't produce
-				// duplicates
-				matchingJobs = caches[1].jobsWithPrefix(prefixIndexArray);
-				caches[1].cut(prefixIndexArray);
-			}
-			for (Job job : matchingJobs) {
-				Map<String, T2Reference> newDataMap = new HashMap<>();
-				newDataMap.putAll(newJob.getData());
-				newDataMap.putAll(job.getData());
-				Job mergedJob = new Job(owningProcess, job.getIndex(),
-						newDataMap, newJob.getContext());
-				pushJob(mergedJob);
-			}
-		}
-
-		/*
-		 * If the job came in on index 1 we have to find the job on index 0 that
-		 * matches the first 'n' indices, where 'n' is determined by the depth
-		 * of jobs on the cache for index 0.
-		 */
-		else if (inputIndex == 1) {
-			// Only act if we've received jobs on the cache at index 0
-			if (caches[0].getIndexLength() > 0) {
-				int[] prefix = new int[caches[0].getIndexLength()];
-				for (int i = 0; i < prefix.length; i++)
-					prefix[i] = newJob.getIndex()[i];
-				Job j = caches[0].get(prefix);
-				if (j != null) {
-					Map<String, T2Reference> newDataMap = new HashMap<>();
-					newDataMap.putAll(j.getData());
-					newDataMap.putAll(newJob.getData());
-					Job mergedJob = new Job(owningProcess, newJob.getIndex(),
-							newDataMap, newJob.getContext());
-					pushJob(mergedJob);
-				}
-			}
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/TerminalNode.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/TerminalNode.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/TerminalNode.java
deleted file mode 100644
index eee01aa..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/TerminalNode.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.iteration;
-
-import javax.swing.tree.MutableTreeNode;
-
-/**
- * The terminal node is the root of the iteration strategy tree, it is
- * responsible for forwarding all events up to the iteration strategy itself
- * which can then propogate them to the strategy stack.
- */
-@SuppressWarnings("serial")
-public abstract class TerminalNode extends AbstractIterationStrategyNode {
-	@Override
-	public synchronized void insert(MutableTreeNode child, int index) {
-		if (getChildCount() > 0 && getChildAt(0) != child)
-			throw new IllegalStateException(
-					"The terminal node can have maximum one child");
-		super.insert(child, index);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/package.html b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/package.html
deleted file mode 100644
index 65f2a61..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/package.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<body>
-Object model and enactment logic for the iteration strategy component of
-a Processor
-</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/serialization/DeserializationException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/serialization/DeserializationException.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/serialization/DeserializationException.java
deleted file mode 100644
index 397fd40..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/serialization/DeserializationException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.serialization;
-
-public class DeserializationException extends Exception {
-	public DeserializationException(String msg) {
-		super(msg);
-	}
-
-	public DeserializationException(String msg, Exception cause) {
-		super(msg, cause);
-	}
-
-	private static final long serialVersionUID = -5905705659863088259L;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/serialization/SerializationException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/serialization/SerializationException.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/serialization/SerializationException.java
deleted file mode 100644
index 4fc1732..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/serialization/SerializationException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.serialization;
-
-public class SerializationException extends Exception {
-	public SerializationException(String msg, Exception cause) {
-		super(msg, cause);
-	}
-
-	public SerializationException(String msg) {
-		super(msg);
-	}
-
-	private static final long serialVersionUID = -218787623524401819L;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/utils/AnnotationTools.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/utils/AnnotationTools.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/utils/AnnotationTools.java
deleted file mode 100644
index 2754aff..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/utils/AnnotationTools.java
+++ /dev/null
@@ -1,151 +0,0 @@
-package net.sf.taverna.t2.workflowmodel.utils;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import net.sf.taverna.t2.annotation.Annotated;
-import net.sf.taverna.t2.annotation.AnnotationAssertion;
-import net.sf.taverna.t2.annotation.AnnotationBeanSPI;
-import net.sf.taverna.t2.annotation.AnnotationChain;
-import net.sf.taverna.t2.annotation.AppliesTo;
-import net.sf.taverna.t2.annotation.annotationbeans.AbstractTextualValueAssertion;
-import net.sf.taverna.t2.workflowmodel.Edit;
-import net.sf.taverna.t2.workflowmodel.EditException;
-import net.sf.taverna.t2.workflowmodel.Edits;
-
-import org.apache.log4j.Logger;
-
-public class AnnotationTools {
-	private static Logger logger = Logger.getLogger(AnnotationTools.class);
-	// private Iterable<Class<?>> annotationBeanRegistry;
-
-	public static Edit<?> addAnnotation(Annotated<?> annotated,
-			AnnotationBeanSPI a, Edits edits) {
-		return edits.getAddAnnotationChainEdit(annotated, a);
-	}
-
-	public static AnnotationBeanSPI getAnnotation(Annotated<?> annotated,
-			Class<?> annotationClass) {
-		AnnotationBeanSPI result = null;
-		Date latestDate = null;
-		for (AnnotationChain chain : annotated.getAnnotations())
-			for (AnnotationAssertion<?> assertion : chain.getAssertions()) {
-				AnnotationBeanSPI detail = assertion.getDetail();
-				if (annotationClass.isInstance(detail)) {
-					Date assertionDate = assertion.getCreationDate();
-					if ((latestDate == null)
-							|| latestDate.before(assertionDate)) {
-						result = detail;
-						latestDate = assertionDate;
-					}
-				}
-			}
-		return result;
-	}
-
-	@SuppressWarnings("unchecked")
-	public <T> List<Class<? extends T>> getAnnotationBeanClasses(
-			List<AnnotationBeanSPI> annotations, Class<T> superClass) {
-		List<Class<? extends T>> results = new ArrayList<>();
-		for (AnnotationBeanSPI annotation : annotations) {
-			Class<? extends AnnotationBeanSPI> annotationBeanClass = annotation
-					.getClass();
-			if (superClass.isAssignableFrom(annotationBeanClass))
-				results.add((Class<? extends T>) annotationBeanClass);
-		}
-		return results;
-	}
-
-	public List<Class<?>> getAnnotatingClasses(
-			List<AnnotationBeanSPI> annotations, Annotated<?> annotated) {
-		List<Class<?>> result = new ArrayList<>();
-		for (Class<? extends AbstractTextualValueAssertion> c : getAnnotationBeanClasses(
-				annotations, AbstractTextualValueAssertion.class)) {
-			AppliesTo appliesToAnnotation = (AppliesTo) c
-					.getAnnotation(AppliesTo.class);
-			if (appliesToAnnotation == null)
-				continue;
-			for (Class<?> target : appliesToAnnotation.targetObjectType())
-				if (target.isInstance(annotated))
-					result.add(c);
-		}
-		return result;
-	}
-
-	public static Edit<?> setAnnotationString(Annotated<?> annotated,
-			Class<?> c, String value, Edits edits) {
-		AbstractTextualValueAssertion a = null;
-		try {
-			logger.info("Setting " + c.getCanonicalName() + " to " + value);
-			a = (AbstractTextualValueAssertion) c.newInstance();
-		} catch (InstantiationException | IllegalAccessException e) {
-			logger.error(e);
-			throw new RuntimeException(e);
-		}
-		a.setText(value);
-		return addAnnotation(annotated, a, edits);
-	}
-
-	public static String getAnnotationString(Annotated<?> annotated,
-			Class<?> annotationClass, String missingValue) {
-		AbstractTextualValueAssertion a = (AbstractTextualValueAssertion) getAnnotation(
-				annotated, annotationClass);
-		if (a == null)
-			return missingValue;
-		return a.getText();
-	}
-
-	/**
-	 * Remove out of date annotations unless many of that class are allowed, or
-	 * it is explicitly not pruned
-	 */
-	@SuppressWarnings("rawtypes")
-	public static void pruneAnnotations(Annotated<?> annotated, Edits edits) {
-		Map<Class<? extends AnnotationBeanSPI>, AnnotationAssertion> remainder = new HashMap<>();
-		Set<AnnotationChain> newChains = new HashSet<AnnotationChain>();
-		for (AnnotationChain chain : annotated.getAnnotations()) {
-			AnnotationChain newChain = edits.createAnnotationChain();
-			for (AnnotationAssertion assertion : chain.getAssertions()) {
-				AnnotationBeanSPI annotation = assertion.getDetail();
-				Class<? extends AnnotationBeanSPI> annotationClass = annotation
-						.getClass();
-				AppliesTo appliesToAnnotation = (AppliesTo) annotationClass
-						.getAnnotation(AppliesTo.class);
-				if ((appliesToAnnotation == null) || appliesToAnnotation.many()
-						|| !appliesToAnnotation.pruned())
-					try {
-						edits.getAddAnnotationAssertionEdit(newChain, assertion)
-								.doEdit();
-					} catch (EditException e) {
-						logger.error("Error while pruning annotations", e);
-					}
-				else if (remainder.containsKey(annotationClass)) {
-					AnnotationAssertion currentAssertion = remainder
-							.get(annotationClass);
-					if (assertion.getCreationDate().compareTo(
-							currentAssertion.getCreationDate()) > 0)
-						remainder.put(annotationClass, assertion);
-				} else
-					remainder.put(annotationClass, assertion);
-			}
-			if (!newChain.getAssertions().isEmpty())
-				newChains.add(newChain);
-		}
-		for (AnnotationAssertion assertion : remainder.values()) {
-			AnnotationChain newChain = edits.createAnnotationChain();
-			try {
-				edits.getAddAnnotationAssertionEdit(newChain, assertion)
-						.doEdit();
-			} catch (EditException e) {
-				logger.error("Error while pruning annotations", e);
-			}
-			newChains.add(newChain);
-		}
-		annotated.setAnnotations(newChains);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/utils/NamedWorkflowEntityComparator.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/utils/NamedWorkflowEntityComparator.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/utils/NamedWorkflowEntityComparator.java
deleted file mode 100644
index 6656e17..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/utils/NamedWorkflowEntityComparator.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**********************************************************************
- * Copyright (C) 2009 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- **********************************************************************/
-package net.sf.taverna.t2.workflowmodel.utils;
-
-import java.util.Comparator;
-
-import net.sf.taverna.t2.workflowmodel.NamedWorkflowEntity;
-
-/**
- * Compare two named workflow entities (such as a Processor) by their local
- * name.
- * 
- * @author Stian Soiland-Reyes
- */
-public class NamedWorkflowEntityComparator implements
-		Comparator<NamedWorkflowEntity> {
-	@Override
-	public int compare(NamedWorkflowEntity o1, NamedWorkflowEntity o2) {
-		return o1.getLocalName().compareToIgnoreCase(o2.getLocalName());
-	}
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/utils/PortComparator.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/utils/PortComparator.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/utils/PortComparator.java
deleted file mode 100644
index 0124c2b..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/utils/PortComparator.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**********************************************************************
- * Copyright (C) 2009 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- **********************************************************************/
-package net.sf.taverna.t2.workflowmodel.utils;
-
-import java.util.Comparator;
-
-import net.sf.taverna.t2.workflowmodel.Port;
-
-/**
- * Compare two workflow ports by their name.
- * 
- * @author Stian Soiland-Reyes
- */
-public class PortComparator implements Comparator<Port> {
-	@Override
-	public int compare(Port o1, Port o2) {
-		return o1.getName().compareToIgnoreCase(o2.getName());
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/utils/Tools.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/utils/Tools.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/utils/Tools.java
deleted file mode 100644
index f5f0f30..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/utils/Tools.java
+++ /dev/null
@@ -1,795 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.utils;
-
-import static java.lang.Character.isLetterOrDigit;
-import static net.sf.taverna.t2.workflowmodel.utils.AnnotationTools.addAnnotation;
-import static net.sf.taverna.t2.workflowmodel.utils.AnnotationTools.getAnnotation;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.regex.Pattern;
-
-import net.sf.taverna.t2.annotation.annotationbeans.IdentificationAssertion;
-import net.sf.taverna.t2.workflowmodel.CompoundEdit;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import net.sf.taverna.t2.workflowmodel.DataflowInputPort;
-import net.sf.taverna.t2.workflowmodel.DataflowOutputPort;
-import net.sf.taverna.t2.workflowmodel.Datalink;
-import net.sf.taverna.t2.workflowmodel.Edit;
-import net.sf.taverna.t2.workflowmodel.EditException;
-import net.sf.taverna.t2.workflowmodel.Edits;
-import net.sf.taverna.t2.workflowmodel.EventForwardingOutputPort;
-import net.sf.taverna.t2.workflowmodel.EventHandlingInputPort;
-import net.sf.taverna.t2.workflowmodel.InputPort;
-import net.sf.taverna.t2.workflowmodel.Merge;
-import net.sf.taverna.t2.workflowmodel.MergeInputPort;
-import net.sf.taverna.t2.workflowmodel.MergeOutputPort;
-import net.sf.taverna.t2.workflowmodel.NamedWorkflowEntity;
-import net.sf.taverna.t2.workflowmodel.OutputPort;
-import net.sf.taverna.t2.workflowmodel.Port;
-import net.sf.taverna.t2.workflowmodel.Processor;
-import net.sf.taverna.t2.workflowmodel.ProcessorInputPort;
-import net.sf.taverna.t2.workflowmodel.ProcessorOutputPort;
-import net.sf.taverna.t2.workflowmodel.TokenProcessingEntity;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityConfigurationException;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityInputPort;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityOutputPort;
-import net.sf.taverna.t2.workflowmodel.processor.activity.DisabledActivity;
-import net.sf.taverna.t2.workflowmodel.processor.activity.NestedDataflow;
-
-import org.apache.log4j.Logger;
-
-/**
- * Various workflow model tools that can be helpful when constructing a
- * dataflow.
- * <p>
- * Not to be confused with the @deprecated
- * {@link net.sf.taverna.t2.workflowmodel.impl.Tools}
- * 
- * @author David Withers
- * @author Stian Soiland-Reyes
- */
-public class Tools {
-	private static Logger logger = Logger.getLogger(Tools.class);
-
-	// private static Edits edits = new EditsImpl();
-
-	/**
-	 * Find (and possibly create) an EventHandlingInputPort.
-	 * <p>
-	 * If the given inputPort is an instance of {@link EventHandlingInputPort},
-	 * it is returned directly. If it is an ActivityInputPort - the owning
-	 * processors (found by searching the dataflow) will be searced for a mapped
-	 * input port. If this cannot be found, one will be created and mapped. The
-	 * edits for this will be added to the editList and needs to be executed by
-	 * the caller.
-	 * 
-	 * @see #findEventHandlingOutputPort(List, Dataflow, OutputPort)
-	 * @param editList
-	 *            List of {@link Edit}s to append any required edits (yet to be
-	 *            performed) to
-	 * @param dataflow
-	 *            Dataflow containing the processors
-	 * @param inputPort
-	 *            An EventHandlingInputPort or ActivityInputPort
-	 * @return The found or created EventHandlingInputPort
-	 */
-	protected static EventHandlingInputPort findEventHandlingInputPort(
-			List<Edit<?>> editList, Dataflow dataflow, InputPort inputPort,
-			Edits edits) {
-		if (inputPort instanceof EventHandlingInputPort)
-			return (EventHandlingInputPort) inputPort;
-		else if (!(inputPort instanceof ActivityInputPort))
-			throw new IllegalArgumentException("Unknown input port type for "
-					+ inputPort);
-
-		ActivityInputPort activityInput = (ActivityInputPort) inputPort;
-		Collection<Processor> processors = getProcessorsWithActivityInputPort(
-				dataflow, activityInput);
-		if (processors.isEmpty())
-			throw new IllegalArgumentException("Can't find ActivityInputPort "
-					+ activityInput.getName() + " in workflow " + dataflow);
-
-		// FIXME: Assumes only one matching processor
-		Processor processor = processors.iterator().next();
-		Activity<?> activity = null;
-		for (Activity<?> checkActivity : processor.getActivityList())
-			if (checkActivity.getInputPorts().contains(activityInput)) {
-				activity = checkActivity;
-				break;
-			}
-		if (activity == null)
-			throw new IllegalArgumentException("Can't find activity for port "
-					+ activityInput.getName() + "within processor " + processor);
-
-		ProcessorInputPort input = getProcessorInputPort(processor, activity,
-				activityInput);
-		if (input != null)
-			return input;
-		// port doesn't exist so create a processor port and map it
-		String processorPortName = uniquePortName(activityInput.getName(),
-				processor.getInputPorts());
-		ProcessorInputPort processorInputPort = edits.createProcessorInputPort(
-				processor, processorPortName, activityInput.getDepth());
-		editList.add(edits.getAddProcessorInputPortEdit(processor,
-				processorInputPort));
-		editList.add(edits.getAddActivityInputPortMappingEdit(activity,
-				processorPortName, activityInput.getName()));
-		return processorInputPort;
-	}
-
-	/**
-	 * Find (and possibly create) an EventForwardingOutputPort.
-	 * <p>
-	 * If the given outputPort is an instance of
-	 * {@link EventForwardingOutputPort}, it is returned directly. If it is an
-	 * ActivityOutputPort - the owning processors (found by searching the
-	 * dataflow) will be searced for a mapped output port. If this cannot be
-	 * found, one will be created and mapped. The edits for this will be added
-	 * to the editList and needs to be executed by the caller.
-	 * 
-	 * @see #findEventHandlingInputPort(List, Dataflow, InputPort)
-	 * @param editList
-	 *            List of {@link Edit}s to append any required edits (yet to be
-	 *            performed) to
-	 * @param dataflow
-	 *            Dataflow containing the processors
-	 * @param outputPort
-	 *            An EventForwardingOutputPort or ActivityOutputPort
-	 * @return The found or created EventForwardingOutputPort
-	 */
-	protected static EventForwardingOutputPort findEventHandlingOutputPort(
-			List<Edit<?>> editList, Dataflow dataflow, OutputPort outputPort,
-			Edits edits) {
-		if (outputPort instanceof EventForwardingOutputPort)
-			return (EventForwardingOutputPort) outputPort;
-		else if (!(outputPort instanceof ActivityOutputPort))
-			throw new IllegalArgumentException("Unknown output port type for "
-					+ outputPort);
-
-		ActivityOutputPort activityOutput = (ActivityOutputPort) outputPort;
-		Collection<Processor> processors = getProcessorsWithActivityOutputPort(
-				dataflow, activityOutput);
-		if (processors.isEmpty())
-			throw new IllegalArgumentException("Can't find ActivityOutputPort "
-					+ activityOutput.getName() + " in workflow " + dataflow);
-
-		// FIXME: Assumes only one matching processor
-		Processor processor = processors.iterator().next();
-		Activity<?> activity = null;
-		for (Activity<?> checkActivity : processor.getActivityList())
-			if (checkActivity.getOutputPorts().contains(activityOutput)) {
-				activity = checkActivity;
-				break;
-			}
-		if (activity == null)
-			throw new IllegalArgumentException("Can't find activity for port "
-					+ activityOutput.getName() + "within processor "
-					+ processor);
-
-		ProcessorOutputPort processorOutputPort = Tools.getProcessorOutputPort(
-				processor, activity, activityOutput);
-		if (processorOutputPort != null)
-			return processorOutputPort;
-
-		// port doesn't exist so create a processor port and map it
-		String processorPortName = uniquePortName(activityOutput.getName(),
-				processor.getOutputPorts());
-		processorOutputPort = edits.createProcessorOutputPort(processor,
-				processorPortName, activityOutput.getDepth(),
-				activityOutput.getGranularDepth());
-		editList.add(edits.getAddProcessorOutputPortEdit(processor,
-				processorOutputPort));
-		editList.add(edits.getAddActivityOutputPortMappingEdit(activity,
-				processorPortName, activityOutput.getName()));
-
-		return processorOutputPort;
-	}
-
-	/**
-	 * Creates an Edit that creates a Datalink between a source and sink port
-	 * and connects the Datalink.
-	 * 
-	 * If the sink port already has a Datalink connected this method checks if a
-	 * new Merge is required and creates and connects the required Datalinks.
-	 * 
-	 * @param dataflow
-	 *            the Dataflow to add the Datalink to
-	 * @param source
-	 *            the source of the Datalink
-	 * @param sink
-	 *            the source of the Datalink
-	 * @return an Edit that creates a Datalink between a source and sink port
-	 *         and connects the Datalink
-	 */
-	public static Edit<?> getCreateAndConnectDatalinkEdit(Dataflow dataflow,
-			EventForwardingOutputPort source, EventHandlingInputPort sink,
-			Edits edits) {
-		Edit<?> edit = null;
-
-		Datalink incomingLink = sink.getIncomingLink();
-		if (incomingLink == null) {
-			Datalink datalink = edits.createDatalink(source, sink);
-			edit = edits.getConnectDatalinkEdit(datalink);
-		} else {
-			List<Edit<?>> editList = new ArrayList<>();
-
-			Merge merge = null;
-			int counter = 0; // counter for merge input port names
-			if (incomingLink.getSource() instanceof MergeOutputPort)
-				merge = ((MergeOutputPort) incomingLink.getSource()).getMerge();
-			else {
-				merge = edits.createMerge(dataflow);
-				editList.add(edits.getAddMergeEdit(dataflow, merge));
-				editList.add(edits.getDisconnectDatalinkEdit(incomingLink));
-				MergeInputPort mergeInputPort = edits.createMergeInputPort(
-						merge,
-						getUniqueMergeInputPortName(merge,
-								incomingLink.getSource().getName() + "To"
-										+ merge.getLocalName() + "_input",
-								counter++), incomingLink.getSink().getDepth());
-				editList.add(edits.getAddMergeInputPortEdit(merge,
-						mergeInputPort));
-				Datalink datalink = edits.createDatalink(
-						incomingLink.getSource(), mergeInputPort);
-				editList.add(edits.getConnectDatalinkEdit(datalink));
-				datalink = edits.createDatalink(merge.getOutputPort(),
-						incomingLink.getSink());
-				editList.add(edits.getConnectDatalinkEdit(datalink));
-			}
-			MergeInputPort mergeInputPort = edits.createMergeInputPort(
-					merge,
-					getUniqueMergeInputPortName(merge, source.getName() + "To"
-							+ merge.getLocalName() + "_input", counter),
-					sink.getDepth());
-			editList.add(edits.getAddMergeInputPortEdit(merge, mergeInputPort));
-			Datalink datalink = edits.createDatalink(source, mergeInputPort);
-			editList.add(edits.getConnectDatalinkEdit(datalink));
-
-			edit = new CompoundEdit(editList);
-		}
-
-		return edit;
-	}
-
-	/**
-	 * Get an {@link Edit} that will link the given output port to the given
-	 * input port.
-	 * <p>
-	 * The output port can be an {@link EventForwardingOutputPort} (such as an
-	 * {@link ProcessorOutputPort}, or an {@link ActivityOutputPort}. The input
-	 * port can be an {@link EventHandlingInputPort} (such as an
-	 * {@link ProcessorInputPort}, or an {@link ActivityInputPort}.
-	 * <p>
-	 * If an input and/or output port is an activity port, processors in the
-	 * given dataflow will be searched for matching mappings, create the
-	 * processor port and mapping if needed, before constructing the edits for
-	 * adding the datalink.
-	 * 
-	 * @param dataflow
-	 *            Dataflow (indirectly) containing ports
-	 * @param outputPort
-	 *            An {@link EventForwardingOutputPort} or an
-	 *            {@link ActivityOutputPort}
-	 * @param inputPort
-	 *            An {@link EventHandlingInputPort} or an
-	 *            {@link ActivityInputPort}
-	 * @return A compound edit for creating and connecting the datalink and any
-	 *         neccessary processor ports and mappings
-	 */
-	public static Edit<?> getCreateAndConnectDatalinkEdit(Dataflow dataflow,
-			OutputPort outputPort, InputPort inputPort, Edits edits) {
-		List<Edit<?>> editList = new ArrayList<>();
-		EventHandlingInputPort sink = findEventHandlingInputPort(editList,
-				dataflow, inputPort, edits);
-		EventForwardingOutputPort source = findEventHandlingOutputPort(
-				editList, dataflow, outputPort, edits);
-		editList.add(getCreateAndConnectDatalinkEdit(dataflow, source, sink,
-				edits));
-		return new CompoundEdit(editList);
-	}
-
-	/**
-	 * Find a unique port name given a list of existing ports.
-	 * <p>
-	 * If needed, the returned port name will be prefixed with an underscore and
-	 * a number, starting from 2. (The original being 'number 1')
-	 * <p>
-	 * Although not strictly needed by Taverna, for added user friendliness the
-	 * case of the existing port names are ignored when checking for uniqueness.
-	 * 
-	 * @see #uniqueProcessorName(String, Dataflow)
-	 * 
-	 * @param suggestedPortName
-	 *            Port name suggested for new port
-	 * @param existingPorts
-	 *            Collection of existing {@link Port}s
-	 * @return A port name unique for the given collection of port
-	 */
-	public static String uniquePortName(String suggestedPortName,
-			Collection<? extends Port> existingPorts) {
-		// Make sure we have a unique port name
-		Set<String> existingNames = new HashSet<>();
-		for (Port existingPort : existingPorts)
-			existingNames.add(existingPort.getName().toLowerCase());
-		String candidateName = suggestedPortName;
-		long counter = 2;
-		while (existingNames.contains(candidateName.toLowerCase()))
-			candidateName = suggestedPortName + "_" + counter++;
-		return candidateName;
-	}
-
-	public static Edit<?> getMoveDatalinkSinkEdit(Dataflow dataflow,
-			Datalink datalink, EventHandlingInputPort sink, Edits edits) {
-		List<Edit<?>> editList = new ArrayList<>();
-		editList.add(edits.getDisconnectDatalinkEdit(datalink));
-		if (datalink.getSink() instanceof ProcessorInputPort)
-			editList.add(getRemoveProcessorInputPortEdit(
-					(ProcessorInputPort) datalink.getSink(), edits));
-		editList.add(getCreateAndConnectDatalinkEdit(dataflow,
-				datalink.getSource(), sink, edits));
-		return new CompoundEdit(editList);
-	}
-
-	public static Edit<?> getDisconnectDatalinkAndRemovePortsEdit(
-			Datalink datalink, Edits edits) {
-		List<Edit<?>> editList = new ArrayList<>();
-		editList.add(edits.getDisconnectDatalinkEdit(datalink));
-		if (datalink.getSource() instanceof ProcessorOutputPort) {
-			ProcessorOutputPort processorOutputPort = (ProcessorOutputPort) datalink
-					.getSource();
-			if (processorOutputPort.getOutgoingLinks().size() == 1)
-				editList.add(getRemoveProcessorOutputPortEdit(
-						processorOutputPort, edits));
-		}
-		if (datalink.getSink() instanceof ProcessorInputPort)
-			editList.add(getRemoveProcessorInputPortEdit(
-					(ProcessorInputPort) datalink.getSink(), edits));
-		return new CompoundEdit(editList);
-	}
-
-	public static Edit<?> getRemoveProcessorOutputPortEdit(
-			ProcessorOutputPort port, Edits edits) {
-		List<Edit<?>> editList = new ArrayList<>();
-		Processor processor = port.getProcessor();
-		editList.add(edits.getRemoveProcessorOutputPortEdit(
-				port.getProcessor(), port));
-		for (Activity<?> activity : processor.getActivityList())
-			editList.add(edits.getRemoveActivityOutputPortMappingEdit(activity,
-					port.getName()));
-		return new CompoundEdit(editList);
-	}
-
-	public static Edit<?> getRemoveProcessorInputPortEdit(
-			ProcessorInputPort port, Edits edits) {
-		List<Edit<?>> editList = new ArrayList<>();
-		Processor processor = port.getProcessor();
-		editList.add(edits.getRemoveProcessorInputPortEdit(port.getProcessor(),
-				port));
-		for (Activity<?> activity : processor.getActivityList())
-			editList.add(edits.getRemoveActivityInputPortMappingEdit(activity,
-					port.getName()));
-		return new CompoundEdit(editList);
-	}
-
-	public static Edit<?> getEnableDisabledActivityEdit(Processor processor,
-			DisabledActivity disabledActivity, Edits edits) {
-		List<Edit<?>> editList = new ArrayList<>();
-		Activity<?> brokenActivity = disabledActivity.getActivity();
-		try {
-			@SuppressWarnings("unchecked")
-			Activity<Object> ra = brokenActivity.getClass().newInstance();
-			Object lastConfig = disabledActivity.getLastWorkingConfiguration();
-			if (lastConfig == null)
-				lastConfig = disabledActivity.getActivityConfiguration();
-			ra.configure(lastConfig);
-
-			Map<String, String> portMapping = ra.getInputPortMapping();
-			Set<String> portNames = new HashSet<>();
-			portNames.addAll(portMapping.keySet());
-			for (String portName : portNames)
-				editList.add(edits.getRemoveActivityInputPortMappingEdit(ra,
-						portName));
-			portMapping = ra.getOutputPortMapping();
-			portNames.clear();
-			portNames.addAll(portMapping.keySet());
-			for (String portName : portNames)
-				editList.add(edits.getRemoveActivityOutputPortMappingEdit(ra,
-						portName));
-
-			portMapping = disabledActivity.getInputPortMapping();
-			for (String portName : portMapping.keySet())
-				editList.add(edits.getAddActivityInputPortMappingEdit(ra,
-						portName, portMapping.get(portName)));
-			portMapping = disabledActivity.getOutputPortMapping();
-			for (String portName : portMapping.keySet())
-				editList.add(edits.getAddActivityOutputPortMappingEdit(ra,
-						portName, portMapping.get(portName)));
-
-			editList.add(edits.getRemoveActivityEdit(processor,
-					disabledActivity));
-			editList.add(edits.getAddActivityEdit(processor, ra));
-		} catch (ActivityConfigurationException ex) {
-			logger.error("Configuration exception ", ex);
-			return null;
-		} catch (InstantiationException | IllegalAccessException e) {
-			return null;
-		}
-		return new CompoundEdit(editList);
-	}
-
-	public static ProcessorInputPort getProcessorInputPort(Processor processor,
-			Activity<?> activity, InputPort activityInputPort) {
-		ProcessorInputPort result = null;
-		for (Entry<String, String> mapEntry : activity.getInputPortMapping()
-				.entrySet())
-			if (mapEntry.getValue().equals(activityInputPort.getName())) {
-				for (ProcessorInputPort processorInputPort : processor
-						.getInputPorts())
-					if (processorInputPort.getName().equals(mapEntry.getKey())) {
-						result = processorInputPort;
-						break;
-					}
-				break;
-			}
-		return result;
-	}
-
-	public static ProcessorOutputPort getProcessorOutputPort(
-			Processor processor, Activity<?> activity,
-			OutputPort activityOutputPort) {
-		ProcessorOutputPort result = null;
-		for (Entry<String, String> mapEntry : activity.getOutputPortMapping()
-				.entrySet())
-			if (mapEntry.getValue().equals(activityOutputPort.getName())) {
-				for (ProcessorOutputPort processorOutputPort : processor
-						.getOutputPorts())
-					if (processorOutputPort.getName().equals(mapEntry.getKey())) {
-						result = processorOutputPort;
-						break;
-					}
-				break;
-			}
-		return result;
-	}
-
-	public static ActivityInputPort getActivityInputPort(Activity<?> activity,
-			String portName) {
-		ActivityInputPort activityInputPort = null;
-		for (ActivityInputPort inputPort : activity.getInputPorts())
-			if (inputPort.getName().equals(portName)) {
-				activityInputPort = inputPort;
-				break;
-			}
-		return activityInputPort;
-	}
-
-	public static OutputPort getActivityOutputPort(Activity<?> activity,
-			String portName) {
-		OutputPort activityOutputPort = null;
-		for (OutputPort outputPort : activity.getOutputPorts())
-			if (outputPort.getName().equals(portName)) {
-				activityOutputPort = outputPort;
-				break;
-			}
-		return activityOutputPort;
-	}
-
-	public static String getUniqueMergeInputPortName(Merge merge, String name,
-			int count) {
-		String uniqueName = name + count;
-		for (MergeInputPort mergeInputPort : merge.getInputPorts())
-			if (mergeInputPort.getName().equals(uniqueName))
-				return getUniqueMergeInputPortName(merge, name, ++count);
-		return uniqueName;
-	}
-
-	public static Collection<Processor> getProcessorsWithActivity(
-			Dataflow dataflow, Activity<?> activity) {
-		Set<Processor> processors = new HashSet<>();
-		for (Processor processor : dataflow.getProcessors())
-			if (processor.getActivityList().contains(activity))
-				processors.add(processor);
-		return processors;
-	}
-
-	public static Collection<Processor> getProcessorsWithActivityInputPort(
-			Dataflow dataflow, ActivityInputPort inputPort) {
-		Set<Processor> processors = new HashSet<>();
-		for (Processor processor : dataflow.getProcessors()) {
-			// Does it contain a nested workflow?
-			if (containsNestedWorkflow(processor))
-				// Get the nested workflow and check all its nested processors
-				processors.addAll(getProcessorsWithActivityInputPort(
-						getNestedWorkflow(processor), inputPort));
-
-			/*
-			 * Check all processor's activities (even if the processor contained
-			 * a nested workflow, as its dataflow activity still contains input
-			 * and output ports)
-			 */
-			for (Activity<?> activity : processor.getActivityList())
-				if (activity.getInputPorts().contains(inputPort))
-					processors.add(processor);
-		}
-		return processors;
-	}
-
-	public static Collection<Processor> getProcessorsWithActivityOutputPort(
-			Dataflow dataflow, OutputPort outputPort) {
-		Set<Processor> processors = new HashSet<>();
-		for (Processor processor : dataflow.getProcessors()) {
-			// Does it contain a nested workflow?
-			if (containsNestedWorkflow(processor))
-				// Get the nested workflow and check all its nested processors
-				processors.addAll(getProcessorsWithActivityOutputPort(
-						getNestedWorkflow(processor), outputPort));
-
-			/*
-			 * Check all processor's activities (even if the processor contained
-			 * a nested workflow, as its dataflow activity still contains input
-			 * and output ports)
-			 */
-			for (Activity<?> activity : processor.getActivityList())
-				if (activity.getOutputPorts().contains(outputPort))
-					processors.add(processor);
-		}
-		return processors;
-	}
-
-	/**
-	 * Get the TokenProcessingEntity (Processor, Merge or Dataflow) from the
-	 * workflow that contains the given EventForwardingOutputPort. This can be
-	 * an output port of a Processor or a Merge or an input port of a Dataflow
-	 * that has an internal EventForwardingOutputPort attached to it.
-	 * 
-	 * @param port
-	 * @param workflow
-	 * @return
-	 */
-	public static TokenProcessingEntity getTokenProcessingEntityWithEventForwardingOutputPort(
-			EventForwardingOutputPort port, Dataflow workflow) {
-		// First check the workflow's inputs
-		for (DataflowInputPort input : workflow.getInputPorts())
-			if (input.getInternalOutputPort().equals(port))
-				return workflow;
-
-		// Check workflow's merges
-		for (Merge merge : workflow.getMerges())
-			if (merge.getOutputPort().equals(port))
-				return merge;
-
-		// Check workflow's processors
-		for (Processor processor : workflow.getProcessors()) {
-			for (OutputPort output : processor.getOutputPorts())
-				if (output.equals(port))
-					return processor;
-
-			// If processor contains a nested workflow - descend into it
-			if (containsNestedWorkflow(processor)) {
-				TokenProcessingEntity entity = getTokenProcessingEntityWithEventForwardingOutputPort(
-						port, getNestedWorkflow(processor));
-				if (entity != null)
-					return entity;
-			}
-		}
-
-		return null;
-	}
-
-	/**
-	 * Get the TokenProcessingEntity (Processor, Merge or Dataflow) from the
-	 * workflow that contains the given target EventHandlingInputPort. This can
-	 * be an input port of a Processor or a Merge or an output port of a
-	 * Dataflow that has an internal EventHandlingInputPort attached to it.
-	 * 
-	 * @param port
-	 * @param workflow
-	 * @return
-	 */
-	public static TokenProcessingEntity getTokenProcessingEntityWithEventHandlingInputPort(
-			EventHandlingInputPort port, Dataflow workflow) {
-		// First check the workflow's outputs
-		for (DataflowOutputPort output : workflow.getOutputPorts())
-			if (output.getInternalInputPort().equals(port))
-				return workflow;
-
-		// Check workflow's merges
-		for (Merge merge : workflow.getMerges())
-			for (EventHandlingInputPort input : merge.getInputPorts())
-				if (input.equals(port))
-					return merge;
-
-		// Check workflow's processors
-		for (Processor processor : workflow.getProcessors()) {
-			for (EventHandlingInputPort output : processor.getInputPorts())
-				if (output.equals(port))
-					return processor;
-
-			// If processor contains a nested workflow - descend into it
-			if (containsNestedWorkflow(processor)) {
-				TokenProcessingEntity entity = getTokenProcessingEntityWithEventHandlingInputPort(
-						port, getNestedWorkflow(processor));
-				if (entity != null)
-					return entity;
-			}
-		}
-
-		return null;
-	}
-
-	/**
-	 * Returns true if processor contains a nested workflow.
-	 */
-	public static boolean containsNestedWorkflow(Processor processor) {
-		List<?> activities = processor.getActivityList();
-		return !activities.isEmpty()
-				&& activities.get(0) instanceof NestedDataflow;
-	}
-
-	/**
-	 * Get the workflow that is nested inside. Only call this if
-	 * {@link #containsNestedWorkflow()} returns true.
-	 */
-	private static Dataflow getNestedWorkflow(Processor processor) {
-		return ((NestedDataflow) processor.getActivityList().get(0))
-				.getNestedDataflow();
-	}
-
-	/**
-	 * Find the first processor that contains an activity that has the given
-	 * activity input port. See #get
-	 * 
-	 * @param dataflow
-	 * @param targetPort
-	 * @return
-	 */
-	public static Processor getFirstProcessorWithActivityInputPort(
-			Dataflow dataflow, ActivityInputPort targetPort) {
-		for (Processor processor : getProcessorsWithActivityInputPort(
-				dataflow, targetPort))
-			return processor;
-		return null;
-	}
-
-	public static Processor getFirstProcessorWithActivityOutputPort(
-			Dataflow dataflow, ActivityOutputPort targetPort) {
-		for (Processor processor : getProcessorsWithActivityOutputPort(
-				dataflow, targetPort))
-			return processor;
-		return null;
-	}
-
-	/**
-	 * Find a unique processor name for the supplied Dataflow, based upon the
-	 * preferred name. If needed, an underscore and a numeric suffix is added to
-	 * the preferred name, and incremented until it is unique, starting from 2.
-	 * (The original being 'number 1')
-	 * <p>
-	 * Note that this method checks the uniqueness against the names of all
-	 * {@link NamedWorkflowEntity}s, including {@link Merge}s.
-	 * <p>
-	 * Although not strictly needed by Taverna, for added user friendliness the
-	 * case of the existing port names are ignored when checking for uniqueness.
-	 * 
-	 * @param preferredName
-	 *            the preferred name for the Processor
-	 * @param dataflow
-	 *            the dataflow for which the Processor name needs to be unique
-	 * @return A unique processor name
-	 */
-	public static String uniqueProcessorName(String preferredName,
-			Dataflow dataflow) {
-		Set<String> existingNames = new HashSet<>();
-		for (NamedWorkflowEntity entity : dataflow
-				.getEntities(NamedWorkflowEntity.class))
-			existingNames.add(entity.getLocalName().toLowerCase());
-		return uniqueObjectName(preferredName, existingNames);
-	}
-
-	/**
-	 * Checks that the name does not have any characters that are invalid for a
-	 * Taverna name.
-	 * 
-	 * The name must contain only the chars[A-Za-z_0-9].
-	 * 
-	 * @param name
-	 *            the original name
-	 * @return the sanitised name
-	 */
-	public static String sanitiseName(String name) {
-		if (Pattern.matches("\\w++", name) == false) {
-			StringBuilder result = new StringBuilder(name.length());
-			for (char c : name.toCharArray())
-				result.append(isLetterOrDigit(c) || c == '_' ? c : "_");
-			return result.toString();
-		}
-		return name;
-	}
-
-	public static String uniqueObjectName(String preferredName,
-			Set<String> existingNames) {
-		String uniqueName = preferredName;
-		long suffix = 2;
-		while (existingNames.contains(uniqueName.toLowerCase()))
-			uniqueName = preferredName + "_" + suffix++;
-		return uniqueName;
-
-	}
-
-	/**
-	 * Add the identification of a Dataflow into its identification annotation
-	 * chain (if necessary)
-	 * 
-	 * @return Whether an identification needed to be added
-	 */
-	public static boolean addDataflowIdentification(Dataflow dataflow,
-			String internalId, Edits edits) {
-		IdentificationAssertion ia = (IdentificationAssertion) getAnnotation(
-				dataflow, IdentificationAssertion.class);
-		if (ia != null && ia.getIdentification().equals(internalId))
-			return false;
-		IdentificationAssertion newIa = new IdentificationAssertion();
-		newIa.setIdentification(internalId);
-		try {
-			addAnnotation(dataflow, newIa, edits).doEdit();
-			return true;
-		} catch (EditException e) {
-			return false;
-		}
-	}
-
-	/**
-	 * Return a path of processors where the last element is this processor and
-	 * previous ones are nested processors that contain this one all the way to
-	 * the top but excluding the top level workflow as this is only a list of
-	 * processors.
-	 */
-	public static List<Processor> getNestedPathForProcessor(
-			Processor processor, Dataflow dataflow) {
-		for (Processor proc : dataflow.getProcessors())
-			if (proc == processor) { // found it
-				List<Processor> list = new ArrayList<>();
-				list.add(processor);
-				return list;
-			} else if (containsNestedWorkflow(proc)) {
-				/*
-				 * check inside this nested processor
-				 */
-				List<Processor> nestedList = getNestedPathForProcessor(
-						processor, getNestedWorkflow(proc));
-				if (nestedList == null)
-					// processor not found in this nested workflow
-					continue;
-				// add this nested processor to the list
-				nestedList.add(0, proc);
-				return nestedList;
-			}
-		return null;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AbstractAnnotatedThing.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AbstractAnnotatedThing.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AbstractAnnotatedThing.java
new file mode 100644
index 0000000..a29d4cf
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AbstractAnnotatedThing.java
@@ -0,0 +1,163 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation;
+
+import static java.util.Collections.unmodifiableSet;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.taverna.workflowmodel.Edit;
+import org.apache.taverna.workflowmodel.EditException;
+
+/**
+ * Convenient abstract superclass for annotated things, manages edits.
+ * Subclasses of this must implement the Annotated interface with their own
+ * interface type as the parameter, so for example Processor subclasses would
+ * implement Annotated&lt;Processor&gt;
+ * 
+ * @author Tom Oinn
+ * @author Alan R Williams
+ */
+public abstract class AbstractAnnotatedThing<T> implements Annotated<T> {
+	private Set<AnnotationChain> annotations = new HashSet<>();
+
+	/**
+	 * Return the set of annotations bound to this annotated object, the set
+	 * returned is an unmodifiable copy of the internal annotation set, if you
+	 * need to modify the annotations you should use the get methods for Edit
+	 * objects to do so.
+	 * 
+	 * @see org.apache.taverna.annotation.Annotated#getAnnotations()
+	 */
+	@Override
+	public final Set<AnnotationChain> getAnnotations() {
+		return unmodifiableSet(annotations);
+	}
+
+	/**
+	 * Set the annotation chains associated with this annotated object. This is
+	 * only needed for deserialization and could almost certainly be done in a
+	 * better way.
+	 * 
+	 * @param annotations
+	 */
+	@Override
+	public final void setAnnotations(Set<AnnotationChain> annotations) {
+		this.annotations = annotations;
+	}
+
+	/**
+	 * Superclass of edits to remove, add and replace annotations on instances
+	 * of the enclosing AbstractAnnotatedThing class
+	 * 
+	 * @author Tom
+	 * @param <TargetType>
+	 */
+	private static abstract class AbstractAnnotationEdit<TargetType> implements
+			Edit<TargetType> {
+		private AbstractAnnotatedThing<TargetType> subject;
+		private boolean applied = false;
+
+		protected AbstractAnnotationEdit(
+				AbstractAnnotatedThing<TargetType> subject) {
+			this.subject = subject;
+		}
+
+		@Override
+		@SuppressWarnings("unchecked")
+		public final TargetType doEdit() throws EditException {
+			synchronized (subject) {
+				if (applied)
+					throw new EditException("Edit already applied!");
+				doEditAction(subject);
+				this.applied = true;
+				return (TargetType) subject;
+			}
+		}
+
+		protected abstract void doEditAction(AbstractAnnotatedThing<?> subject)
+				throws EditException;
+
+		protected abstract void undoEditAction(AbstractAnnotatedThing<?> subject);
+
+		@Override
+		@SuppressWarnings("unchecked")
+		public final TargetType getSubject() {
+			return (TargetType) subject;
+		}
+
+		@Override
+		public final boolean isApplied() {
+			return this.applied;
+		}
+
+		@Override
+		public final void undo() {
+			synchronized (subject) {
+				if (!applied)
+					throw new RuntimeException(
+							"Attempt to undo edit that was never applied");
+				undoEditAction(subject);
+				applied = false;
+			}
+		}
+	}
+
+	/**
+	 * @see net.sf.taverna.t2.annotation.Annotated#getAddAnnotationEdit(net.sf.taverna.t2.annotation.WorkflowAnnotation)
+	 */
+	@Override
+	public final Edit<T> getAddAnnotationEdit(
+			final AnnotationChain newAnnotation) {
+		return new AbstractAnnotationEdit<T>(this) {
+			@Override
+			protected void doEditAction(AbstractAnnotatedThing<?> subject)
+					throws EditException {
+				annotations.add(newAnnotation);
+			}
+
+			@Override
+			protected void undoEditAction(AbstractAnnotatedThing<?> subject) {
+				annotations.remove(newAnnotation);
+			}
+		};
+	}
+
+	/**
+	 * @see net.sf.taverna.t2.annotation.Annotated#getRemoveAnnotationEdit(net.sf.taverna.t2.annotation.WorkflowAnnotation)
+	 */
+	@Override
+	public final Edit<T> getRemoveAnnotationEdit(
+			final AnnotationChain annotationToRemove) {
+		return new AbstractAnnotationEdit<T>(this) {
+			@Override
+			protected void doEditAction(AbstractAnnotatedThing<?> subject)
+					throws EditException {
+				annotations.remove(annotationToRemove);
+			}
+
+			@Override
+			protected void undoEditAction(AbstractAnnotatedThing<?> subject) {
+				annotations.add(annotationToRemove);
+			}
+		};
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/Annotated.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/Annotated.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/Annotated.java
new file mode 100644
index 0000000..9cb4978
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/Annotated.java
@@ -0,0 +1,78 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation;
+
+import java.util.Set;
+
+import org.apache.taverna.workflowmodel.Edit;
+
+/**
+ * Denotes that the object carries workflow object level annotation. Rather than
+ * defining specific annotation types for each workflow entity we work on the
+ * basis that multiple annotations of different types may apply, so free text
+ * description is one example, semantic annotation of the internal function of a
+ * processor might be another.
+ * <p>
+ * Where annotations are conceptually editable such as free text descriptions
+ * the editing framework should internally remove the original annotation and
+ * add the replacement rather than modifying the previous annotation in place.
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public interface Annotated<TargetType> {
+
+	/**
+	 * Each annotated object contains a bag of metadata object instances
+	 * 
+	 * @return set of metadata objects that apply to the annotated object
+	 */
+	Set<? extends AnnotationChain> getAnnotations();
+	
+	void setAnnotations(Set<AnnotationChain> annotations);
+
+	/**
+	 * Add new workflow object metadata to this annotated entity
+	 * 
+	 * @param <TargetType>
+	 *            the type of the object being annotated
+	 * @param newAnnotation
+	 *            metadata object to add to the annotated object
+	 * @return edit object to perform and undo the metadata assignment
+	 */
+	public Edit<? extends TargetType> getAddAnnotationEdit(
+			AnnotationChain newAnnotation);
+
+	/**
+	 * Remove an annotation object from the this annotated entity
+	 * 
+	 * @param <TargetType>
+	 *            type of the workflow object from which the annotation is
+	 *            removed
+	 * @param annotationToRemove
+	 *            metadata object to remove
+	 * @param objectToAnnotate
+	 *            object from which the metadata is removed
+	 * @return edit object to perform and undo the metadata removal
+	 */
+	public Edit<? extends TargetType> getRemoveAnnotationEdit(
+			AnnotationChain annotationToRemove);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationAssertion.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationAssertion.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationAssertion.java
new file mode 100644
index 0000000..ffddd3b
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationAssertion.java
@@ -0,0 +1,51 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation;
+
+/**
+ * Represents a single assertion of information, providing access to a bean
+ * containing the information in the assertion and one specifying the source of
+ * the information contained.
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public interface AnnotationAssertion<AnnotationBeanType extends AnnotationBeanSPI>
+		extends Curateable {
+
+	/**
+	 * Each annotation assertion contains a bean specifying the actual
+	 * annotation, varying from a simple string for a free text description to
+	 * more sophisticated semantic annotations or controlled vocabularies.
+	 * 
+	 * @return the annotation bean specifying this annotation assertion
+	 */
+	public AnnotationBeanType getDetail();
+
+	/**
+	 * The annotation assertion plays one of several roles within the annotation
+	 * chain, either an initial assertion, a refinement of a previous assertion
+	 * or a replacement of a previous assertion.
+	 * 
+	 * @return the annotation role of this annotation
+	 */
+	public AnnotationRole getRole();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationBeanSPI.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationBeanSPI.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationBeanSPI.java
new file mode 100644
index 0000000..932873d
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationBeanSPI.java
@@ -0,0 +1,31 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation;
+
+/**
+ * Marker interface to denote that a bean class is a container for the
+ * information encapsulated by an InformationAssertion object
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public interface AnnotationBeanSPI {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationChain.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationChain.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationChain.java
new file mode 100644
index 0000000..b9dbcec
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationChain.java
@@ -0,0 +1,50 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation;
+
+import java.util.List;
+
+/**
+ * A fact about an annotated entity is expressed in terms of an annotation
+ * chain. The annotation chain contains one or more information assertions in a
+ * list ordered by the creation date of each assertion. Annotation chains are
+ * then interpreted by an AnnotationPerspective which is responsible for
+ * reasoning over the information in the chain and extracting the set of
+ * information assertions that are valid according to the rules in the
+ * particular AnnotationPerspective.
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public interface AnnotationChain {
+
+	/**
+	 * Returns the ordered list of AnnotationAssertions. This is the 'raw' set
+	 * of annotations in creation order - this order is not necessarily the
+	 * order they were curated, and may include refuted or otherwise wrong
+	 * annotations. Consumers of this API are recommended to use an
+	 * AnnotationPerspective to resolve any such conflicts appropriately.
+	 * 
+	 * @return read only copy of the ordered list of AnnotationAssertion
+	 *         instances
+	 */
+	List<AnnotationAssertion<?>> getAssertions();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationPerspective.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationPerspective.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationPerspective.java
new file mode 100644
index 0000000..e03e16e
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationPerspective.java
@@ -0,0 +1,61 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation;
+
+import java.util.List;
+
+/**
+ * Responsible for the interpretation of an AnnotationChain (which may contain
+ * conflicting or disputed information) into a set of AnnotationAssertion
+ * instances from that chain which are valid given the chain and some
+ * interpretation rule.
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public interface AnnotationPerspective {
+
+	/**
+	 * Evaluate the annotations and their curation events in the specified
+	 * chain, resolve conflicts if possible and return the resultant set of
+	 * annotations
+	 * 
+	 * @param chain
+	 *            the annotation chain to evaluate
+	 * @return the set of annotations which are valid within this chain
+	 */
+	public List<? extends AnnotationAssertion<?>> getAnnotations(
+			AnnotationChain chain);
+
+	/**
+	 * Annotation chains may be in a disputed state if there are conflicting
+	 * mutually exclusive events within them under the interpretation imposed by
+	 * the annotation perspective and the perspective is unable to sensibly
+	 * reconcile them. For example, if the perspective is configured to trust
+	 * two parties equally and they disagree.
+	 * 
+	 * @param chain
+	 *            the annotation chain to check for conflict
+	 * @return true if there are conflicts under the interpretation of this
+	 *         annotation perspective
+	 */
+	public boolean isDisputed(AnnotationChain chain);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationRole.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationRole.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationRole.java
new file mode 100644
index 0000000..c1449d2
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationRole.java
@@ -0,0 +1,50 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation;
+
+/**
+ * Specifies the role of an AnnotationAssertion within an AnnotationChain
+ * 
+ * @author Tom Oinn
+ */
+public enum AnnotationRole {
+
+	/**
+	 * The information assertion is the first in the chain (if this is applied
+	 * to an annotation that isn't the earliest in its chain it should be
+	 * treated as a validation failure)
+	 */
+	INITIAL_ASSERTION,
+
+	/**
+	 * The information assertion was added to the chain to refine the existing
+	 * annotation assertion or assertions, such as cases where a generic
+	 * description exists which can be specialized in a particular instance but
+	 * where the original more generic form is still correct
+	 */
+	REFINEMENT,
+
+	/**
+	 * The information assertion was added to the chain in order to override an
+	 * earlier information assertion which was regarded as incorrect.
+	 */
+	REPLACEMENT;
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationSourceSPI.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationSourceSPI.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationSourceSPI.java
new file mode 100644
index 0000000..e97f9bc
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AnnotationSourceSPI.java
@@ -0,0 +1,34 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation;
+
+/**
+ * A marker interface that specified that the implementation is a bean
+ * containing information about a source of annotations. These might be
+ * publications, web URIs, a free text container, a person (etc). We should be
+ * able to use existing schemes for identification of sources, publications etc
+ * here.
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public interface AnnotationSourceSPI {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AppliesTo.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AppliesTo.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AppliesTo.java
new file mode 100644
index 0000000..e56ca25
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/AppliesTo.java
@@ -0,0 +1,52 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * Annotation to be used on metadata objects to denote which workflow objects
+ * they apply to
+ * 
+ * @author Tom Oinn
+ * 
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@Documented
+public @interface AppliesTo {
+
+	/**
+	 * The class of the metadata object allowed by this annotation
+	 */
+	Class<?>[] targetObjectType();
+
+	/**
+	 * Can you have more than one of these metadata objects in the resolved set?
+	 */
+	boolean many() default true;
+	
+   /**
+     * Should the annotation be pruned, i.e. only most recent kept, when saving?
+     */
+    boolean pruned() default true;
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/Curateable.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/Curateable.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/Curateable.java
new file mode 100644
index 0000000..8fcbbd7
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/Curateable.java
@@ -0,0 +1,71 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Implemented by objects which can have curation assertions attached to them.
+ * In our model this includes the AnnotationAssertion but also includes the
+ * CurationEvent itself, in this way we allow curation of curation assertions
+ * and thence a conversational model of annotation.
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public interface Curateable {
+
+	/**
+	 * Curateable instances have a list of curation events which are used to
+	 * determine whether the implementing object is valid given a particular
+	 * interpretive context. If this list is empty the event is unchallenged.
+	 * 
+	 * @return
+	 */
+	public List<CurationEvent<?>> getCurationAssertions();
+
+	/**
+	 * All curation events are marked with their creation date, this is the date
+	 * at which the curation event was associated with its target.
+	 * 
+	 * @return
+	 */
+	public Date getCreationDate();
+
+	/**
+	 * Each curateable has a list of people associated with it, frequently one
+	 * person and in some cases none, although this should be avoided if
+	 * possible.
+	 * 
+	 * @return
+	 */
+	public List<? extends Person> getCreators();
+
+	/**
+	 * Each annotation or curation has a resource from which the event is
+	 * inherently derived, for example if the annotation was created manually
+	 * after reading a paper the source would unambiguously specify the
+	 * publication.
+	 * 
+	 * @return
+	 */
+	public AnnotationSourceSPI getSource();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/CurationEvent.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/CurationEvent.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/CurationEvent.java
new file mode 100644
index 0000000..b2914ec
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/CurationEvent.java
@@ -0,0 +1,51 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation;
+
+/**
+ * Represents a single act of curation, parameterized on a bean encapsulating
+ * the necessary and sufficient information to describe the specifics of the
+ * curation event.
+ * 
+ * @author Tom Oinn
+ * 
+ * @param <T>
+ */
+public interface CurationEvent<CurationType extends CurationEventBeanSPI> {
+
+	public CurationType getDetail();
+
+	/**
+	 * The curation event type specifies whether this curation event is a
+	 * validation, repudiation or neither of its target.
+	 * 
+	 * @return
+	 */
+	public CurationEventType getType();
+
+	/**
+	 * The curation event applies to a specific other event, either another
+	 * curation event or an annotation assertion.
+	 * 
+	 * @return the event which this event is curating
+	 */
+	public Curateable getTarget();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/CurationEventBeanSPI.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/CurationEventBeanSPI.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/CurationEventBeanSPI.java
new file mode 100644
index 0000000..dc8cdb2
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/CurationEventBeanSPI.java
@@ -0,0 +1,34 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation;
+
+/**
+ * Contains the detail for a single curation event. In many cases this will be a
+ * plain base curation object with very little information but it allows for us
+ * to specify additional parameters to the curation event which can then be used
+ * by the AnnotationPerspective instance to determine whether it believes the
+ * curator.
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public interface CurationEventBeanSPI {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/CurationEventType.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/CurationEventType.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/CurationEventType.java
new file mode 100644
index 0000000..110f151
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/annotation/CurationEventType.java
@@ -0,0 +1,42 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation;
+
+public enum CurationEventType {
+
+	/**
+	 * The curation event asserts that the event it is attached to was correct,
+	 * effectively signing off an approval on the attached event.
+	 */
+	VALIDATION,
+
+	/**
+	 * The curation event repudiates the information in the attached event,
+	 * denying its validity.
+	 */
+	REPUDIATION,
+
+	/**
+	 * The curation event neither validates nor repudiates the information in
+	 * the attached event.
+	 */
+	NEUTRAL;
+
+}


[47/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaMapper.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaMapper.java b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaMapper.java
new file mode 100644
index 0000000..132af05
--- /dev/null
+++ b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaMapper.java
@@ -0,0 +1,94 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.hadoop;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.hadoop.fs.FSDataInputStream;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.mapreduce.Reducer.Context;
+
+public class TavernaMapper extends org.apache.hadoop.mapreduce.Mapper<int[], Map<String, Path>, Object, Object> {
+
+	private org.apache.hadoop.mapreduce.Mapper.Context context;
+
+	@Override
+	protected void setup(Context context) throws IOException,
+			InterruptedException {
+		this.context = context;
+	}
+	
+	@Override
+	protected void map(int[] key, Map<String, Path> value, 
+              Context context) throws IOException, InterruptedException {
+		
+		// Value contains a map of input ports to data values on those ports 
+		// (i.e. file paths to data on the input ports) 
+
+		
+		// Get the activity and invoke it with the passed inputs per port
+//		
+//		String activityClassName = context.getConfiguration().get("taverna.activity.class");
+//		String activityConfigurationXML = context.getConfiguration().get("taverna.activity.configuration");
+//	
+//	    ClassLoader classLoader = this.getClass().getClassLoader();
+//	    Class<?> activityClass = null;
+//	    AbstractAsynchronousActivity<?> activity = null;
+//	    try {
+//	        activityClass = classLoader.loadClass(activityClassName);
+//	        activity = (AbstractAsynchronousActivity<?>) activityClass.newInstance();
+//	    } catch (ClassNotFoundException e) {
+//			// TODO Auto-generated catch block
+//	        e.printStackTrace();
+//	    } catch (InstantiationException e) {
+//			// TODO Auto-generated catch block
+//			e.printStackTrace();
+//		} catch (IllegalAccessException e) {
+//			// TODO Auto-generated catch block
+//			e.printStackTrace();
+//		}
+//	    
+//	    activity.configure(activityConfigurationXML);
+//	    activity.executeAsynch(data, callback);
+
+		System.out.println("Index: " + key);
+
+		// Input port names
+		Iterator<String> iterator = value.keySet().iterator();
+		while(iterator.hasNext()){
+			String inputPortName = iterator.next();
+			// Simply read values from input files and concatenate them
+			Path inputFilePath = value.get(inputPortName);
+			FSDataInputStream fileInputStream = inputFilePath.getFileSystem(null).open(inputFilePath);
+			//fileInputStream.
+			System.out.println("Input port: " + inputPortName + ". Input value: "+ inputFilePath +".");
+		}
+		
+		// Map of output ports to data values on those ports 
+		// (i.e. file paths to data on the output ports)
+		Map<String, Path> outputValue = new HashMap<String, Path>();
+		context.write(key, outputValue);
+	}
+	  
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaRecordReader.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaRecordReader.java b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaRecordReader.java
new file mode 100644
index 0000000..613f944
--- /dev/null
+++ b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaRecordReader.java
@@ -0,0 +1,105 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.hadoop;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.MapWritable;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapreduce.InputSplit;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.hadoop.mapreduce.TaskAttemptContext;
+import org.apache.hadoop.mapreduce.lib.input.FileSplit;
+
+/**
+ *
+ *
+ * @author David Withers
+ */
+public class TavernaRecordReader extends RecordReader<LongWritable, MapWritable> {
+
+	private FileSplit fileSplit;
+	private String recordName;
+	private FileStatus[] files;
+	private int index = -1;
+	private Map<String, String> datalinks;
+
+	@Override
+	public void initialize(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException {
+		fileSplit = (FileSplit) split;
+		Path path = fileSplit.getPath();
+		recordName = path.getName();
+		files = path.getFileSystem(context.getConfiguration()).listStatus(path);
+		setDatalinks(context);
+	}
+
+	/**
+	 * @param context
+	 */
+	private void setDatalinks(TaskAttemptContext context) {
+		datalinks = new HashMap<String, String>();
+		String datalinkConfig = context.getConfiguration().get("taverna.datalinks");
+		if (datalinkConfig != null) {
+			String[] datalinksSplit = datalinkConfig.split(",");
+			for (String datalink : datalinksSplit) {
+				String[] split = datalink.split("\\|");
+				if (split.length == 2) {
+					datalinks.put(split[0], split[1]);
+				}
+			}
+		}
+	}
+
+	@Override
+	public boolean nextKeyValue() throws IOException, InterruptedException {
+		index++;
+		return index < files.length;
+	}
+
+	@Override
+	public LongWritable getCurrentKey() throws IOException, InterruptedException {
+		return new LongWritable(Long.valueOf(files[index].getPath().getName()));
+	}
+
+	@Override
+	public MapWritable getCurrentValue() throws IOException, InterruptedException {
+		MapWritable mapWritable = new MapWritable();
+		mapWritable.put(new Text("tag"), new Text(datalinks.get(recordName)));
+		mapWritable.put(new Text("record"), new Text(files[index].getPath().toString()));
+		return mapWritable;
+	}
+
+	@Override
+	public float getProgress() throws IOException, InterruptedException {
+		return files.length == 0 ? 1 : (index + 1) / files.length;
+	}
+
+	@Override
+	public void close() throws IOException {
+
+	}
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaReducer.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaReducer.java b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaReducer.java
new file mode 100644
index 0000000..bf489db
--- /dev/null
+++ b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaReducer.java
@@ -0,0 +1,43 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.hadoop;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.hadoop.fs.Path;
+
+public class TavernaReducer extends
+		org.apache.hadoop.mapreduce.Reducer<int[], Map<String, Path>, Object, Object> {
+
+	private Context context;
+
+	@Override
+	protected void setup(Context context) throws IOException,
+			InterruptedException {
+		this.context = context;
+	}
+
+	@Override
+	protected void reduce(int[] key, Iterable<Map<String, Path>> values,
+			Context context) throws IOException, InterruptedException {
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/Test.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/Test.java b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/Test.java
new file mode 100644
index 0000000..a23be06
--- /dev/null
+++ b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/Test.java
@@ -0,0 +1,68 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.hadoop;
+
+import java.util.Map;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.mapreduce.Job;
+import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
+import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
+import org.apache.hadoop.util.Tool;
+import org.apache.hadoop.util.ToolRunner;
+
+/**
+ *
+ *
+ * @author David Withers
+ */
+public class Test extends Configured implements Tool {
+
+	@Override
+	public int run(String[] args) throws Exception {
+		Configuration configuration = getConf();
+		Job job = new Job(configuration);
+		job.setJarByClass(Test.class);
+		job.setJobName("wordcount");
+
+		job.setOutputKeyClass(int[].class);
+		job.setOutputValueClass(Map.class);
+
+		job.setMapperClass(TavernaMapper.class);
+//		job.setCombinerClass(Reduce.class);
+		job.setReducerClass(TavernaReducer.class);
+
+		job.setInputFormatClass(TavernaInputFormat.class);
+		job.setOutputFormatClass(TextOutputFormat.class);
+
+		TavernaInputFormat.setInputPaths(job, new Path(args[0]));
+		FileOutputFormat.setOutputPath(job, new Path(args[1]));
+
+		boolean success = job.waitForCompletion(true);
+		return success ? 0 : 1;
+	}
+
+	public static void main(String[] args) throws Exception {
+		int ret = ToolRunner.run(new Test(), args);
+		System.exit(ret);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TextArrayWritable.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TextArrayWritable.java b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TextArrayWritable.java
new file mode 100644
index 0000000..4c5c115
--- /dev/null
+++ b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TextArrayWritable.java
@@ -0,0 +1,30 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.hadoop;
+
+import org.apache.hadoop.io.ArrayWritable;
+import org.apache.hadoop.io.Text;
+
+public class TextArrayWritable extends ArrayWritable {
+	public TextArrayWritable() {
+		super(Text.class);
+	}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/CrossProductInputFormat.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/CrossProductInputFormat.java b/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/CrossProductInputFormat.java
deleted file mode 100644
index 122b473..0000000
--- a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/CrossProductInputFormat.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.impl.hadoop;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.fs.BlockLocation;
-import org.apache.hadoop.fs.FileStatus;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.PathFilter;
-import org.apache.hadoop.io.ArrayWritable;
-import org.apache.hadoop.io.MapWritable;
-import org.apache.hadoop.io.Text;
-import org.apache.hadoop.mapreduce.InputSplit;
-import org.apache.hadoop.mapreduce.JobContext;
-import org.apache.hadoop.mapreduce.RecordReader;
-import org.apache.hadoop.mapreduce.TaskAttemptContext;
-import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
-
-/**
- * An input format that receives an input directory containing a number of directories with input files 
- * for each input port to a Taverna processor/activity that will be executed as part of this
- * MapReduce job. Mapping between directory name -> Taverna processor/activity input port name
- * is carried in the job's Context.
- * 
- * @author Alex Nenadic
- *
- */
-public class CrossProductInputFormat extends
-		FileInputFormat<Text, TextArrayWritable> {
-
-	private static final Log Logger = LogFactory.getLog(CrossProductInputFormat.class);
-
-	// Do not split files into blocks
-	@Override
-	protected boolean isSplitable(JobContext context, Path filename) {
-		return false;
-	}
-
-	@Override
-	public RecordReader<Text, TextArrayWritable> createRecordReader(
-			InputSplit split, TaskAttemptContext context) {
-		return new CrossProductRecordReader();
-	}
-
-	@Override
-	public List<InputSplit> getSplits(JobContext job) throws IOException {
-
-	    // Generate splits. Split is a list of directories where each directory 
-		// contains inputs for one input port of the Taverna processor/activity we 
-		// are invoking. 
-		// We will have only one split for cross product that will know about all
-		// the files in all input directories and will generate RecordReaders 
-		// for every combination of files inside these directories.
-//	    CrossProductInputSplit split = new CrossProductInputSplit();
-	    
-	    // List the input port directories contained in the input directory passed 
-	    // in from the command line.
-	    List<FileStatus> inputPortDirectories = listStatus(job); 
-	    
-		final FileSystem fs = job.getWorkingDirectory().getFileSystem(job.getConfiguration());
-		Path workingDirectory = job.getWorkingDirectory();
-		System.out.println("Working directory: " + workingDirectory);
-		System.out.println("Adding directories to the cross product split:");
-		ArrayList<Path> inputPortDirectoriesPaths = new ArrayList<Path>();
-    	for (FileStatus inputPortDirectory : inputPortDirectories){
-    		// TODO input port directories need to be ordered in the order of the 
-    		// input ports of the Taverna processor/activity they are going into
-            
-    		//inputPortDirectoriesPaths.add(new Text(inputPortDirectory.getPath().toString()));
-    		inputPortDirectoriesPaths.add(inputPortDirectory.getPath());
-    		System.out.println(inputPortDirectory.getPath());
-
-    	}
-	    CrossProductInputSplit split = new CrossProductInputSplit(workingDirectory, inputPortDirectoriesPaths);
-	    
-
-	    List<InputSplit> splits = new ArrayList<InputSplit>();
-	    splits.add(split);
-		
-	    return splits;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/CrossProductInputSplit.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/CrossProductInputSplit.java b/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/CrossProductInputSplit.java
deleted file mode 100644
index 2ff9113..0000000
--- a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/CrossProductInputSplit.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.impl.hadoop;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.io.Text;
-import org.apache.hadoop.mapreduce.lib.input.FileSplit;
-
-/**
- *
- *
- * @author Alex Nenadic
- */
-public class CrossProductInputSplit extends FileSplit {
-	//
-	// private long length = 0;
-	// private String[] hosts;
-	private List<Path> inputPortDirectories;
-	private Path workingDirectory;
-
-	public CrossProductInputSplit() {
-		super(null,0,0,null);
-		inputPortDirectories = new ArrayList<Path>();
-		System.out.println("Calling default constructor for cross product split");
-	}
-
-	public CrossProductInputSplit(Path workingDirectory, List<Path> inputPortDirectories) {
-		// this.length = length;
-		// this.hosts = hosts;
-		super(workingDirectory, 0, 0, new String[0]);
-		this.workingDirectory = workingDirectory;
-		this.inputPortDirectories = inputPortDirectories;
-		System.out.println("Calling non-default constructor for cross product split");
-	}
-
-	public void addInputPortDirectory(Path path) {
-		inputPortDirectories.add(path);
-	}
-
-	public List<Path> getInputPortDirectories() {
-		return inputPortDirectories;
-	}
-
-	@Override
-	public void write(DataOutput out) throws IOException {
-		super.write(out);
-		Text.writeString(out, workingDirectory.toString());
-		out.writeInt(inputPortDirectories.size());
-		for (Path path : inputPortDirectories) {
-			Text.writeString(out, path.toString());
-		}
-	}
-
-	@Override
-	public void readFields(DataInput in) throws IOException {
-		super.readFields(in);
-		workingDirectory = new Path(Text.readString(in));
-		int length = in.readInt();
-		for (int i = 0; i < length; i++) {
-			inputPortDirectories.add(new Path(Text.readString(in)));
-		}
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/CrossProductRecordReader.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/CrossProductRecordReader.java b/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/CrossProductRecordReader.java
deleted file mode 100644
index 6602f55..0000000
--- a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/CrossProductRecordReader.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package uk.org.taverna.platform.execution.impl.hadoop;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.fs.FileStatus;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.io.Text;
-import org.apache.hadoop.mapreduce.InputSplit;
-import org.apache.hadoop.mapreduce.RecordReader;
-import org.apache.hadoop.mapreduce.TaskAttemptContext;
-import org.pingel.util.CrossProduct;
-
-public class CrossProductRecordReader extends RecordReader<Text, TextArrayWritable>{
-
-	private static final Log Logger = LogFactory.getLog(CrossProductRecordReader.class);
-
-	// Input directories (one for each port) containing files that are used 
-	// as inputs to Taverna processor/activity
-	private List<Path> inputPortDirectories;
-	
-	private CrossProduct<String> crossProduct ;
-
-	private Iterator<List<String>> crossProductIterator;
-
-	private List<String> currentIndexes;
-
-	@Override
-	public void initialize(InputSplit split, TaskAttemptContext context)
-			throws IOException, InterruptedException {
-
-		System.out.println("Inside record reader's initialize");
-		
-		CrossProductInputSplit crossProductSplit = (CrossProductInputSplit)split;
-		inputPortDirectories = crossProductSplit.getInputPortDirectories();
-		System.out.println("Record reader received " + +inputPortDirectories.size() + " input port directories");
-
-		List<List<String>> iterables = new ArrayList<List<String>>();
-		for (int i=0; i<inputPortDirectories.size();i++ ){
-	
-			Path inputPortDirectory = inputPortDirectories.get(i);
-			//Path inputPortDirectory = inputPortDirectories.get(i);
-			FileStatus[] files = inputPortDirectory.getFileSystem(context.getConfiguration()).listStatus(inputPortDirectory);
-			List<String> fileNames = new ArrayList<String>();
-			for (FileStatus file : files){
-				fileNames.add(file.getPath().getName());
-			}
-			iterables.add(fileNames);
-		}
-
-		crossProduct = new CrossProduct<String>(iterables);
-		crossProductIterator = crossProduct.iterator();
-		
-	}
-
-	@Override
-	public boolean nextKeyValue(){
-
-		boolean hasNextKey = crossProductIterator.hasNext();
-		System.out.println("Has record reader next key value? " + hasNextKey);
-		if (hasNextKey){
-			currentIndexes = crossProductIterator.next();
-		}
-		return hasNextKey;
-	}
-
-	@Override
-	public Text getCurrentKey() throws IOException, InterruptedException {
-	
-		StringBuffer sb = new StringBuffer();
-		for (String index : currentIndexes){
-			sb.append(index + ".");
-		}
-		// Remove last "."
-		String indexesString = sb.toString();
-		System.out.println("Get current key: " + indexesString);
-		if (indexesString.contains(".")){
-			indexesString = indexesString.substring(0, indexesString.length() - 1);
-		}
-		return new Text(indexesString);
-	}
-
-	@Override
-	public TextArrayWritable getCurrentValue() {
-				
-		TextArrayWritable arrayWritable = new TextArrayWritable();
-		Text[] array = new Text[currentIndexes.size()];
-		for(int i= 0; i< currentIndexes.size(); i++){
-			Path file = new Path(inputPortDirectories.get(i).toString(), currentIndexes.get(i));
-			array[i] = new Text(file.toString());
-		}
-		arrayWritable.set(array);
-		return arrayWritable;
-	}
-
-	@Override
-	public float getProgress() throws IOException, InterruptedException {
-		// TODO Auto-generated method stub
-		return 0;
-	}
-
-	@Override
-	public void close() throws IOException {
-		// TODO Auto-generated method stub
-		
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/CrossProductTest.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/CrossProductTest.java b/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/CrossProductTest.java
deleted file mode 100644
index e5dc063..0000000
--- a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/CrossProductTest.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 1 of
- *  the License, or (at your option) any later version.
- *
- *  This program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.impl.hadoop;
-
-import java.io.IOException;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.conf.Configured;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.io.ArrayWritable;
-import org.apache.hadoop.io.LongWritable;
-import org.apache.hadoop.io.MapWritable;
-import org.apache.hadoop.io.Text;
-import org.apache.hadoop.mapreduce.Job;
-import org.apache.hadoop.mapreduce.Mapper;
-import org.apache.hadoop.mapreduce.Reducer;
-import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
-import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
-import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
-import org.apache.hadoop.util.Tool;
-import org.apache.hadoop.util.ToolRunner;
-
-public class CrossProductTest extends Configured implements Tool {
-
-	public static class Map extends Mapper<Text, TextArrayWritable, Text, TextArrayWritable> {
-		public void map(Text key, TextArrayWritable value, Context context) throws IOException,
-				InterruptedException {
-			System.out.println("Map key = " + key);
-			System.out.println("Map value = " );
-
-			for (int i = 0; i < value.get().length; i++){
-				System.out.println("  " + value.get()[i]);
-			}
-
-			context.write(key, value);
-		}
-	}
-
-	public static class Reduce extends Reducer<Text, TextArrayWritable, Text, Text> {
-		public void reduce(Text key, Iterable<TextArrayWritable> values, Context context)
-				throws IOException, InterruptedException {
-
-			System.out.println("Reduce key = " + key);
-			context.write(key, f(values));
-		}
-
-		private Text f(Iterable<TextArrayWritable> values) {
-			StringBuilder sb = new StringBuilder();
-
-			// There should be only one array
-			TextArrayWritable arrayValue = values.iterator().next();
-
-			for (int i = 0; i < arrayValue.get().length; i++){
-				sb.append(arrayValue.get()[i] + "\nx");
-			}
-			String str = sb.toString();
-			if (str.contains("\nx")){
-				str = str.substring(0, sb.lastIndexOf("\nx") -1);
-			}
-			System.out.println("Result of function f(): " + str);
-
-			return new Text(str);
-		}
-	}
-
-	public int run(String[] args) throws Exception {
-
-		Configuration configuration = getConf();
-		configuration.set("taverna.datalinks", "A|X,B|Y");
-		System.out.println(configuration);
-		Job job = new Job(configuration);
-		job.setJarByClass(CrossProductTest.class);
-		job.setJobName("crossproduct");
-
-		job.setOutputKeyClass(Text.class);
-		job.setOutputValueClass(TextArrayWritable.class);
-
-		job.setMapperClass(Map.class);
-//		job.setCombinerClass(Reduce.class);
-		job.setReducerClass(Reduce.class);
-
-		job.setInputFormatClass(CrossProductInputFormat.class);
-		job.setOutputFormatClass(TextOutputFormat.class);
-
-		FileInputFormat.setInputPaths(job, new Path(args[0]));
-		System.out.println("Input dir: " + args[0]);
-		FileOutputFormat.setOutputPath(job, new Path(args[1]));
-		System.out.println("Output dir: " + args[1]);
-
-		boolean success = job.waitForCompletion(true);
-		return success ? 0 : 1;
-	}
-
-	public static void main(String[] args) throws Exception {
-		int ret = ToolRunner.run(new CrossProductTest(), args);
-		System.exit(ret);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/DotProductTest.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/DotProductTest.java b/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/DotProductTest.java
deleted file mode 100644
index 2fa38e4..0000000
--- a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/DotProductTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 1 of
- *  the License, or (at your option) any later version.
- *
- *  This program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.impl.hadoop;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.conf.Configured;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.io.LongWritable;
-import org.apache.hadoop.io.MapWritable;
-import org.apache.hadoop.io.Text;
-import org.apache.hadoop.mapreduce.Job;
-import org.apache.hadoop.mapreduce.Mapper;
-import org.apache.hadoop.mapreduce.Reducer;
-import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
-import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
-import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
-import org.apache.hadoop.util.Tool;
-import org.apache.hadoop.util.ToolRunner;
-
-public class DotProductTest extends Configured implements Tool {
-
-	public static class Map extends Mapper<LongWritable, MapWritable, LongWritable, MapWritable> {
-		public void map(LongWritable key, MapWritable value, Context context) throws IOException,
-				InterruptedException {
-			System.out.println("Map key = " + key);
-			System.out.println("Map value tag = " + value.get(new Text("tag")));
-			System.out.println("Map value record = " + value.get(new Text("record")));
-			context.write(key, value);
-		}
-	}
-
-	public static class Reduce extends Reducer<LongWritable, MapWritable, LongWritable, Text> {
-		public void reduce(LongWritable key, Iterable<MapWritable> values, Context context)
-				throws IOException, InterruptedException {
-
-			System.out.println("Reduce key = " + key);
-			context.write(key, f(values));
-			context.write(key, f(values));
-		}
-
-		private Text f(Iterable<MapWritable> values) {
-			StringBuilder sb = new StringBuilder();
-			for (MapWritable value : values) {
-				System.out.println("Reduce tag = " + value.get(new Text("tag")));
-				System.out.println("Reduce value = " + value.get(new Text("record")));
-				sb.append(value.get(new Text("record")) + " ");
-			}
-			return new Text(sb.toString());
-		}
-	}
-
-	public int run(String[] args) throws Exception {
-		java.util.Map datalinks = new HashMap();
-
-
-		Configuration configuration = getConf();
-		configuration.set("taverna.datalinks", "A|X,B|Y");
-		System.out.println(configuration);
-		Job job = new Job(configuration);
-		job.setJarByClass(DotProductTest.class);
-		job.setJobName("dotproduct");
-
-		job.setOutputKeyClass(LongWritable.class);
-		job.setOutputValueClass(MapWritable.class);
-
-		job.setMapperClass(Map.class);
-//		job.setCombinerClass(Reduce.class);
-		job.setReducerClass(Reduce.class);
-
-		job.setInputFormatClass(TavernaInputFormat.class);
-		job.setOutputFormatClass(TextOutputFormat.class);
-
-		FileInputFormat.setInputPaths(job, new Path(args[0]));
-		FileOutputFormat.setOutputPath(job, new Path(args[1]));
-
-		boolean success = job.waitForCompletion(true);
-		return success ? 0 : 1;
-	}
-
-	public static void main(String[] args) throws Exception {
-		int ret = ToolRunner.run(new DotProductTest(), args);
-		System.exit(ret);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TavernaInputFormat.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TavernaInputFormat.java b/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TavernaInputFormat.java
deleted file mode 100644
index 57b41c5..0000000
--- a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TavernaInputFormat.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.impl.hadoop;
-
-import java.io.IOException;
-
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.io.LongWritable;
-import org.apache.hadoop.io.MapWritable;
-import org.apache.hadoop.mapreduce.InputSplit;
-import org.apache.hadoop.mapreduce.JobContext;
-import org.apache.hadoop.mapreduce.RecordReader;
-import org.apache.hadoop.mapreduce.TaskAttemptContext;
-import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
-
-/**
- *
- *
- * @author David Withers
- */
-public class TavernaInputFormat extends FileInputFormat<LongWritable, MapWritable> {
-
-	@Override
-	public RecordReader<LongWritable, MapWritable> createRecordReader(InputSplit split,
-			TaskAttemptContext context) throws IOException, InterruptedException {
-		return new TavernaRecordReader();
-	}
-
-	@Override
-	protected boolean isSplitable(JobContext context, Path filename) {
-		return false;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TavernaInputSplit.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TavernaInputSplit.java b/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TavernaInputSplit.java
deleted file mode 100644
index d1bf0b3..0000000
--- a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TavernaInputSplit.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.impl.hadoop;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.mapreduce.InputSplit;
-
-/**
- *
- *
- * @author David Withers
- */
-public class TavernaInputSplit extends InputSplit {
-	private int[] index;
-	private Map<String, Path> inputs;
-	private long length;
-	private String[] hosts;
-
-	public TavernaInputSplit(int[] index, Map<String, Path> inputs, long length, String[] hosts) {
-		this.index = index;
-		this.inputs = inputs;
-		this.length = length;
-		this.hosts = hosts;
-	}
-
-	public int[] getIndex() {
-		return index;
-	}
-
-	public Map<String, Path> getInputs() {
-		return inputs;
-	}
-
-	@Override
-	public long getLength() throws IOException, InterruptedException {
-		return length;
-	}
-
-	@Override
-	public String[] getLocations() throws IOException, InterruptedException {
-		if (hosts == null) {
-			return new String[] {};
-		} else {
-			return this.hosts;
-		}
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TavernaMapper.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TavernaMapper.java b/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TavernaMapper.java
deleted file mode 100644
index fa5d1dc..0000000
--- a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TavernaMapper.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package uk.org.taverna.platform.execution.impl.hadoop;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.hadoop.fs.FSDataInputStream;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.mapreduce.Reducer.Context;
-
-public class TavernaMapper extends org.apache.hadoop.mapreduce.Mapper<int[], Map<String, Path>, Object, Object> {
-
-	private org.apache.hadoop.mapreduce.Mapper.Context context;
-
-	@Override
-	protected void setup(Context context) throws IOException,
-			InterruptedException {
-		this.context = context;
-	}
-	
-	@Override
-	protected void map(int[] key, Map<String, Path> value, 
-              Context context) throws IOException, InterruptedException {
-		
-		// Value contains a map of input ports to data values on those ports 
-		// (i.e. file paths to data on the input ports) 
-
-		
-		// Get the activity and invoke it with the passed inputs per port
-//		
-//		String activityClassName = context.getConfiguration().get("taverna.activity.class");
-//		String activityConfigurationXML = context.getConfiguration().get("taverna.activity.configuration");
-//	
-//	    ClassLoader classLoader = this.getClass().getClassLoader();
-//	    Class<?> activityClass = null;
-//	    AbstractAsynchronousActivity<?> activity = null;
-//	    try {
-//	        activityClass = classLoader.loadClass(activityClassName);
-//	        activity = (AbstractAsynchronousActivity<?>) activityClass.newInstance();
-//	    } catch (ClassNotFoundException e) {
-//			// TODO Auto-generated catch block
-//	        e.printStackTrace();
-//	    } catch (InstantiationException e) {
-//			// TODO Auto-generated catch block
-//			e.printStackTrace();
-//		} catch (IllegalAccessException e) {
-//			// TODO Auto-generated catch block
-//			e.printStackTrace();
-//		}
-//	    
-//	    activity.configure(activityConfigurationXML);
-//	    activity.executeAsynch(data, callback);
-
-		System.out.println("Index: " + key);
-
-		// Input port names
-		Iterator<String> iterator = value.keySet().iterator();
-		while(iterator.hasNext()){
-			String inputPortName = iterator.next();
-			// Simply read values from input files and concatenate them
-			Path inputFilePath = value.get(inputPortName);
-			FSDataInputStream fileInputStream = inputFilePath.getFileSystem(null).open(inputFilePath);
-			//fileInputStream.
-			System.out.println("Input port: " + inputPortName + ". Input value: "+ inputFilePath +".");
-		}
-		
-		// Map of output ports to data values on those ports 
-		// (i.e. file paths to data on the output ports)
-		Map<String, Path> outputValue = new HashMap<String, Path>();
-		context.write(key, outputValue);
-	}
-	  
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TavernaRecordReader.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TavernaRecordReader.java b/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TavernaRecordReader.java
deleted file mode 100644
index 190d91a..0000000
--- a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TavernaRecordReader.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.impl.hadoop;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.hadoop.fs.FileStatus;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.io.LongWritable;
-import org.apache.hadoop.io.MapWritable;
-import org.apache.hadoop.io.Text;
-import org.apache.hadoop.mapreduce.InputSplit;
-import org.apache.hadoop.mapreduce.RecordReader;
-import org.apache.hadoop.mapreduce.TaskAttemptContext;
-import org.apache.hadoop.mapreduce.lib.input.FileSplit;
-
-/**
- *
- *
- * @author David Withers
- */
-public class TavernaRecordReader extends RecordReader<LongWritable, MapWritable> {
-
-	private FileSplit fileSplit;
-	private String recordName;
-	private FileStatus[] files;
-	private int index = -1;
-	private Map<String, String> datalinks;
-
-	@Override
-	public void initialize(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException {
-		fileSplit = (FileSplit) split;
-		Path path = fileSplit.getPath();
-		recordName = path.getName();
-		files = path.getFileSystem(context.getConfiguration()).listStatus(path);
-		setDatalinks(context);
-	}
-
-	/**
-	 * @param context
-	 */
-	private void setDatalinks(TaskAttemptContext context) {
-		datalinks = new HashMap<String, String>();
-		String datalinkConfig = context.getConfiguration().get("taverna.datalinks");
-		if (datalinkConfig != null) {
-			String[] datalinksSplit = datalinkConfig.split(",");
-			for (String datalink : datalinksSplit) {
-				String[] split = datalink.split("\\|");
-				if (split.length == 2) {
-					datalinks.put(split[0], split[1]);
-				}
-			}
-		}
-	}
-
-	@Override
-	public boolean nextKeyValue() throws IOException, InterruptedException {
-		index++;
-		return index < files.length;
-	}
-
-	@Override
-	public LongWritable getCurrentKey() throws IOException, InterruptedException {
-		return new LongWritable(Long.valueOf(files[index].getPath().getName()));
-	}
-
-	@Override
-	public MapWritable getCurrentValue() throws IOException, InterruptedException {
-		MapWritable mapWritable = new MapWritable();
-		mapWritable.put(new Text("tag"), new Text(datalinks.get(recordName)));
-		mapWritable.put(new Text("record"), new Text(files[index].getPath().toString()));
-		return mapWritable;
-	}
-
-	@Override
-	public float getProgress() throws IOException, InterruptedException {
-		return files.length == 0 ? 1 : (index + 1) / files.length;
-	}
-
-	@Override
-	public void close() throws IOException {
-
-	}
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TavernaReducer.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TavernaReducer.java b/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TavernaReducer.java
deleted file mode 100644
index 11f85dd..0000000
--- a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TavernaReducer.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package uk.org.taverna.platform.execution.impl.hadoop;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.hadoop.fs.Path;
-
-public class TavernaReducer extends
-		org.apache.hadoop.mapreduce.Reducer<int[], Map<String, Path>, Object, Object> {
-
-	private Context context;
-
-	@Override
-	protected void setup(Context context) throws IOException,
-			InterruptedException {
-		this.context = context;
-	}
-
-	@Override
-	protected void reduce(int[] key, Iterable<Map<String, Path>> values,
-			Context context) throws IOException, InterruptedException {
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/Test.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/Test.java b/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/Test.java
deleted file mode 100644
index 65a75d8..0000000
--- a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/Test.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.impl.hadoop;
-
-import java.util.Map;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.conf.Configured;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.mapreduce.Job;
-import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
-import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
-import org.apache.hadoop.util.Tool;
-import org.apache.hadoop.util.ToolRunner;
-
-/**
- *
- *
- * @author David Withers
- */
-public class Test extends Configured implements Tool {
-
-	@Override
-	public int run(String[] args) throws Exception {
-		Configuration configuration = getConf();
-		Job job = new Job(configuration);
-		job.setJarByClass(Test.class);
-		job.setJobName("wordcount");
-
-		job.setOutputKeyClass(int[].class);
-		job.setOutputValueClass(Map.class);
-
-		job.setMapperClass(TavernaMapper.class);
-//		job.setCombinerClass(Reduce.class);
-		job.setReducerClass(TavernaReducer.class);
-
-		job.setInputFormatClass(TavernaInputFormat.class);
-		job.setOutputFormatClass(TextOutputFormat.class);
-
-		TavernaInputFormat.setInputPaths(job, new Path(args[0]));
-		FileOutputFormat.setOutputPath(job, new Path(args[1]));
-
-		boolean success = job.waitForCompletion(true);
-		return success ? 0 : 1;
-	}
-
-	public static void main(String[] args) throws Exception {
-		int ret = ToolRunner.run(new Test(), args);
-		System.exit(ret);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TextArrayWritable.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TextArrayWritable.java b/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TextArrayWritable.java
deleted file mode 100644
index 1b64c77..0000000
--- a/taverna-execution-hadoop/src/main/java/uk/org/taverna/platform/execution/impl/hadoop/TextArrayWritable.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 1 of
- *  the License, or (at your option) any later version.
- *
- *  This program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.impl.hadoop;
-
-import org.apache.hadoop.io.ArrayWritable;
-import org.apache.hadoop.io.Text;
-
-public class TextArrayWritable extends ArrayWritable {
-	public TextArrayWritable() {
-		super(Text.class);
-	}
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-impl/src/main/java/org/apache/taverna/platform/execution/impl/ExecutionEnvironmentServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-execution-impl/src/main/java/org/apache/taverna/platform/execution/impl/ExecutionEnvironmentServiceImpl.java b/taverna-execution-impl/src/main/java/org/apache/taverna/platform/execution/impl/ExecutionEnvironmentServiceImpl.java
new file mode 100644
index 0000000..d9bfbf1
--- /dev/null
+++ b/taverna-execution-impl/src/main/java/org/apache/taverna/platform/execution/impl/ExecutionEnvironmentServiceImpl.java
@@ -0,0 +1,353 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl;
+
+import java.net.URI;
+import java.text.MessageFormat;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import org.apache.taverna.platform.capability.api.ActivityConfigurationException;
+import org.apache.taverna.platform.capability.api.ActivityNotFoundException;
+import org.apache.taverna.platform.capability.api.DispatchLayerConfigurationException;
+import org.apache.taverna.platform.capability.api.DispatchLayerNotFoundException;
+import org.apache.taverna.platform.execution.api.ExecutionEnvironment;
+import org.apache.taverna.platform.execution.api.ExecutionEnvironmentService;
+import org.apache.taverna.platform.execution.api.ExecutionService;
+import org.apache.taverna.scufl2.api.activity.Activity;
+import org.apache.taverna.scufl2.api.common.NamedSet;
+import org.apache.taverna.scufl2.api.common.Scufl2Tools;
+import org.apache.taverna.scufl2.api.configurations.Configuration;
+import org.apache.taverna.scufl2.api.core.Processor;
+import org.apache.taverna.scufl2.api.profiles.ProcessorBinding;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * Implementation of the ExecutionEnvironmentService.
+ *
+ * @author David Withers
+ */
+public class ExecutionEnvironmentServiceImpl implements ExecutionEnvironmentService {
+	private static final Logger logger = Logger.getLogger(ExecutionEnvironmentServiceImpl.class.getName());
+
+	@SuppressWarnings("unused")
+	private final Scufl2Tools scufl2Tools = new Scufl2Tools();
+	private Set<ExecutionService> executionServices;
+
+	@Override
+	public Set<ExecutionEnvironment> getExecutionEnvironments() {
+		Set<ExecutionEnvironment> executionEnvironments = new HashSet<>();
+		for (ExecutionService executionService : executionServices)
+			executionEnvironments.addAll(executionService
+					.getExecutionEnvironments());
+		return executionEnvironments;
+	}
+
+	@Override
+	public Set<ExecutionEnvironment> getExecutionEnvironments(Profile profile) {
+		Set<ExecutionEnvironment> validExecutionEnvironments = new HashSet<>();
+		for (ExecutionEnvironment executionEnvironment : getExecutionEnvironments())
+			if (isValidExecutionEnvironment(executionEnvironment, profile))
+				validExecutionEnvironments.add(executionEnvironment);
+		return validExecutionEnvironments;
+	}
+
+	/**
+	 * Sets the ExecutionServices that will be used to find ExecutionEnvironments.
+	 *
+	 * @param executionServices
+	 *            the ExecutionServices that will be used to find ExecutionEnvironments
+	 */
+	public void setExecutionServices(Set<ExecutionService> executionServices) {
+		this.executionServices = executionServices;
+	}
+
+	/**
+	 * @param executionEnvironment
+	 * @param profile
+	 * @return
+	 */
+	private boolean isValidExecutionEnvironment(ExecutionEnvironment executionEnvironment,
+			Profile profile) {
+		NamedSet<ProcessorBinding> processorBindings = profile.getProcessorBindings();
+		for (ProcessorBinding processorBinding : processorBindings) {
+			Activity activity = processorBinding.getBoundActivity();
+			if (!executionEnvironment.activityExists(activity.getType())) {
+				logger.fine(MessageFormat.format("{0} does not contain activity {1}",
+						executionEnvironment.getName(), activity.getType()));
+				return false;
+			}
+			Configuration activityConfiguration = activity.getConfiguration();
+			if (!isValidActivityConfiguration(executionEnvironment, activityConfiguration, activity)) {
+				logger.fine(MessageFormat.format("Invalid activity configuration for {1} in {0}",
+						executionEnvironment.getName(), activity.getType()));
+				return false;
+			}
+			@SuppressWarnings("unused")
+			Processor processor = processorBinding.getBoundProcessor();
+			// TODO check that environment has required dispatch layers for processor configuration
+//			for (DispatchStackLayer dispatchStackLayer : processor.getDispatchStack()) {
+//				if (!executionEnvironment.dispatchLayerExists(dispatchStackLayer
+//						.getType())) {
+//					logger.fine(MessageFormat.format("{0} does not contain dispatch layer {1}",
+//							executionEnvironment.getName(),
+//							dispatchStackLayer.getType()));
+//					return false;
+//				}
+//
+//				List<Configuration> dispatchLayerConfigurations = scufl2Tools.configurationsFor(dispatchStackLayer, profile);
+//				if (dispatchLayerConfigurations.size() > 1) {
+//					logger.fine(MessageFormat.format("{0} contains multiple configurations for dispatch layer {1}",
+//							executionEnvironment.getName(),
+//							dispatchStackLayer.getType()));
+//				} else if (dispatchLayerConfigurations.size() == 1) {
+//					if (!isValidDispatchLayerConfiguration(executionEnvironment, dispatchLayerConfigurations.get(0), dispatchStackLayer)) {
+//						logger.fine(MessageFormat.format("Invalid dispatch layer configuration for {1} in {0}",
+//								executionEnvironment.getName(), dispatchStackLayer.getType()));
+//						return false;
+//					}
+//				}
+//			}
+		}
+		return true;
+	}
+
+	private boolean isValidActivityConfiguration(ExecutionEnvironment executionEnvironment,
+			Configuration configuration, Activity activity) {
+		try {
+			configuration.getJson();
+			configuration.getJsonSchema();
+			@SuppressWarnings("unused")
+			JsonNode environmentSchema = executionEnvironment.getActivityConfigurationSchema(activity.getType());
+			// TODO validate against schema
+		} catch (ActivityNotFoundException e) {
+			logger.fine(MessageFormat.format("{0} does not contain activity {1}",
+					executionEnvironment.getName(), activity.getType()));
+			return false;
+		} catch (ActivityConfigurationException e) {
+			logger.fine(MessageFormat.format("Configuration for {1} is incorrect in {0}",
+					executionEnvironment.getName(), activity.getType()));
+			return false;
+		}
+		return true;
+	}
+
+	@SuppressWarnings("unused")
+	private boolean isValidDispatchLayerConfiguration(ExecutionEnvironment executionEnvironment,
+			Configuration configuration, URI dispatchLayerType) {
+		try {
+			JsonNode environmentSchema = executionEnvironment.getDispatchLayerConfigurationSchema(dispatchLayerType);
+			// TODO validate against schema
+		} catch (DispatchLayerNotFoundException e) {
+			logger.fine(MessageFormat.format("{0} does not contain dispatch layer {1}",
+					executionEnvironment.getName(), dispatchLayerType));
+			return false;
+		} catch (DispatchLayerConfigurationException e) {
+			logger.fine(MessageFormat.format("Configuration for {1} is incorrect in {0}",
+					executionEnvironment.getName(), dispatchLayerType));
+			return false;
+		}
+		return true;
+	}
+
+//	/**
+//	 * @param propertyResourceDefinition
+//	 * @param propertyResource
+//	 * @return
+//	 */
+//	private boolean isValidPropertyResource(Configuration configuration,
+//			PropertyResourceDefinition propertyResourceDefinition, PropertyResource propertyResource) {
+//		if (!propertyResourceDefinition.getTypeURI().equals(propertyResource.getTypeURI())) {
+//			logger.fine(MessageFormat.format(
+//					"Property type {0} does not equal property definition type {1}",
+//					propertyResource.getTypeURI(), propertyResourceDefinition.getTypeURI()));
+//			return false;
+//		}
+//		List<PropertyDefinition> propertyDefinitions = propertyResourceDefinition
+//				.getPropertyDefinitions();
+//		Map<URI, SortedSet<PropertyObject>> properties = propertyResource.getProperties();
+//		for (PropertyDefinition propertyDefinition : propertyDefinitions) {
+//			SortedSet<PropertyObject> propertySet = properties.get(propertyDefinition
+//					.getPredicate());
+//			if (propertySet == null) {
+//				if (propertyDefinition.isRequired()) {
+//					logger.fine(MessageFormat.format("Required property {0} is missing",
+//							propertyDefinition.getPredicate()));
+//					return false;
+//				}
+//			} else {
+//				if (propertySet.size() == 0 && propertyDefinition.isRequired()) {
+//					logger.fine(MessageFormat.format("Required property {0} is missing",
+//							propertyDefinition.getPredicate()));
+//					return false;
+//				}
+//				if (propertySet.size() > 1 && !propertyDefinition.isMultiple()) {
+//					logger.fine(MessageFormat.format(
+//							"{0} properties found for singleton property {1}", propertySet.size(),
+//							propertyDefinition.getPredicate()));
+//					return false;
+//				}
+//				if (propertySet.size() > 1 && propertyDefinition.isMultiple() && propertyDefinition.isOrdered()) {
+//					logger.fine(MessageFormat.format(
+//							"{0} property lists found for property {1}", propertySet.size(),
+//							propertyDefinition.getPredicate()));
+//					return false;
+//				}
+//				for (PropertyObject property : propertySet) {
+//					if (propertyDefinition.isMultiple() && propertyDefinition.isOrdered()) {
+//						if (property instanceof PropertyList) {
+//							PropertyList propertyList = (PropertyList) property;
+//							for (PropertyObject propertyObject : propertyList) {
+//								if (!isValidProperty(configuration, propertyDefinition, propertyObject)) {
+//									logger.fine(MessageFormat.format("Property {0} is invalid",
+//											propertyDefinition.getPredicate()));
+//									return false;
+//								}
+//							}
+//						}
+//
+//					} else if (!isValidProperty(configuration, propertyDefinition, property)) {
+//						logger.fine(MessageFormat.format("Property {0} is invalid",
+//								propertyDefinition.getPredicate()));
+//						return false;
+//					}
+//				}
+//			}
+//		}
+//		return true;
+//	}
+//
+//	/**
+//	 * @param propertyDefinition
+//	 * @param property
+//	 * @return
+//	 */
+//	private boolean isValidProperty(Configuration configuration,
+//			PropertyDefinition propertyDefinition, PropertyObject property) {
+//		if (propertyDefinition instanceof PropertyLiteralDefinition) {
+//			if (property instanceof PropertyLiteral) {
+//				PropertyLiteralDefinition propertyLiteralDefinition = (PropertyLiteralDefinition) propertyDefinition;
+//				PropertyLiteral propertyLiteral = (PropertyLiteral) property;
+//				if (!propertyLiteral.getLiteralType().equals(
+//						propertyLiteralDefinition.getLiteralType())) {
+//					logger.fine(MessageFormat.format(
+//							"Property type {0} does not equal property definition type {1}",
+//							propertyLiteral.getLiteralType(),
+//							propertyLiteralDefinition.getLiteralType()));
+//					return false;
+//				}
+//				LinkedHashSet<String> options = propertyLiteralDefinition.getOptions();
+//				if (options != null && options.size() > 0) {
+//					if (!options.contains(propertyLiteral.getLiteralValue())) {
+//						logger.fine(MessageFormat.format("Property value {0} is not permitted",
+//								propertyLiteral.getLiteralValue()));
+//						return false;
+//					}
+//				}
+//			} else {
+//				logger.fine(MessageFormat.format("Expected a PropertyLiteral but got a {0}",
+//						property.getClass().getSimpleName()));
+//				return false;
+//			}
+//		} else if (propertyDefinition instanceof PropertyReferenceDefinition) {
+//			if (property instanceof PropertyReference) {
+//				PropertyReferenceDefinition propertyReferenceDefinition = (PropertyReferenceDefinition) propertyDefinition;
+//				PropertyReference propertyReference = (PropertyReference) property;
+//				LinkedHashSet<URI> options = propertyReferenceDefinition.getOptions();
+//				if (options != null && options.size() > 0) {
+//					if (!options.contains(propertyReference.getResourceURI())) {
+//						logger.fine(MessageFormat.format("Property value {0} is not permitted",
+//								propertyReference.getResourceURI()));
+//						return false;
+//					}
+//				}
+//			} else {
+//				logger.fine(MessageFormat.format("Expected a PropertyReference but got a {0}",
+//						property.getClass().getSimpleName()));
+//				return false;
+//			}
+//		} else if (propertyDefinition instanceof PropertyResourceDefinition) {
+//			if (property instanceof PropertyResource) {
+//				PropertyResourceDefinition propertyResourceDefinition = (PropertyResourceDefinition) propertyDefinition;
+//				PropertyResource propertyResource = (PropertyResource) property;
+//				return isValidPropertyResource(configuration, propertyResourceDefinition,
+//						propertyResource);
+//			} else if (property instanceof PropertyReference) {
+//				// special cases where a PropertyResource is actually a reference to a WorkflowBundle component
+//				PropertyReference propertyReference = (PropertyReference) property;
+//				WorkflowBundle workflowBundle = scufl2Tools.findParent(WorkflowBundle.class,
+//						configuration);
+//				URI configUri = uriTools.uriForBean(configuration);
+//				URI referenceUri = configUri.resolve(propertyReference.getResourceURI());
+//				if (workflowBundle != null) {
+//					URI predicate = propertyDefinition.getPredicate();
+//					WorkflowBean workflowBean = uriTools.resolveUri(referenceUri, workflowBundle);
+//					if (workflowBean == null) {
+//						logger.fine(MessageFormat.format(
+//								"Cannot resolve {0} in WorkflowBundle {1}",
+//								propertyReference.getResourceURI(), workflowBundle.getName()));
+//					}
+//					if (predicate.equals(SCUFL2.resolve("#definesInputPort"))) {
+//						if (workflowBean == null) {
+//							return false;
+//						}
+//						if (!(workflowBean instanceof InputActivityPort)) {
+//							logger.fine(MessageFormat.format(
+//									"{0} resolved to a {1}, expected a InputActivityPort",
+//									propertyReference.getResourceURI(), workflowBean.getClass()
+//											.getSimpleName()));
+//							return false;
+//						}
+//					} else if (predicate.equals(SCUFL2.resolve("#definesOutputPort"))) {
+//						if (workflowBean == null) {
+//							return false;
+//						}
+//						if (!(workflowBean instanceof OutputActivityPort)) {
+//							logger.fine(MessageFormat.format(
+//									"{0} resolved to a {1}, expected a OutputActivityPort",
+//									propertyReference.getResourceURI(), workflowBean.getClass()
+//											.getSimpleName()));
+//							return false;
+//						}
+//					} else {
+//						logger.fine(MessageFormat.format("Unexpected reference to {0}", predicate));
+//					}
+//				} else {
+//					logger.fine(MessageFormat
+//							.format("Cannot resolve reference to {0} because Configuration {1} not contained within a WorkflowBundle",
+//									referenceUri, configuration.getName()));
+//				}
+//			} else {
+//				logger.fine(MessageFormat.format("Expected a PropertyResource or PropertyReference but got a {0}",
+//						property.getClass().getSimpleName()));
+//				return false;
+//			}
+//		} else {
+//			logger.fine(MessageFormat.format("Unknown propery definition class {0}",
+//					propertyDefinition.getClass().getSimpleName()));
+//			return false;
+//		}
+//		return true;
+//	}
+
+}


[50/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-activity-test-utils/src/main/java/net/sf/taverna/t2/activities/testutils/LocationConstants.java
----------------------------------------------------------------------
diff --git a/taverna-activity-test-utils/src/main/java/net/sf/taverna/t2/activities/testutils/LocationConstants.java b/taverna-activity-test-utils/src/main/java/net/sf/taverna/t2/activities/testutils/LocationConstants.java
deleted file mode 100644
index c2c214d..0000000
--- a/taverna-activity-test-utils/src/main/java/net/sf/taverna/t2/activities/testutils/LocationConstants.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.testutils;
-
-/**
- * A definition of constants for base locations of external resources used for testing.
- * 
- * @author Stuart Owen
- *
- */
-public interface LocationConstants {
-	public static final String WSDL_TEST_BASE="http://www.mygrid.org.uk/taverna-tests/testwsdls/";
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-activity-test-utils/src/main/java/org/apache/taverna/activities/testutils/ActivityInvoker.java
----------------------------------------------------------------------
diff --git a/taverna-activity-test-utils/src/main/java/org/apache/taverna/activities/testutils/ActivityInvoker.java b/taverna-activity-test-utils/src/main/java/org/apache/taverna/activities/testutils/ActivityInvoker.java
new file mode 100644
index 0000000..c097896
--- /dev/null
+++ b/taverna-activity-test-utils/src/main/java/org/apache/taverna/activities/testutils/ActivityInvoker.java
@@ -0,0 +1,249 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.activities.testutils;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ServiceLoader;
+
+import org.apache.taverna.reference.ExternalReferenceBuilderSPI;
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ExternalReferenceTranslatorSPI;
+import org.apache.taverna.reference.ReferenceService;
+import org.apache.taverna.reference.StreamToValueConverterSPI;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.ValueToReferenceConverterSPI;
+import org.apache.taverna.reference.impl.ErrorDocumentServiceImpl;
+import org.apache.taverna.reference.impl.InMemoryErrorDocumentDao;
+import org.apache.taverna.reference.impl.InMemoryListDao;
+import org.apache.taverna.reference.impl.InMemoryReferenceSetDao;
+import org.apache.taverna.reference.impl.ListServiceImpl;
+import org.apache.taverna.reference.impl.ReferenceServiceImpl;
+import org.apache.taverna.reference.impl.ReferenceSetAugmentorImpl;
+import org.apache.taverna.reference.impl.ReferenceSetServiceImpl;
+import org.apache.taverna.reference.impl.SimpleT2ReferenceGenerator;
+import org.apache.taverna.workflowmodel.processor.activity.AbstractAsynchronousActivity;
+import org.apache.taverna.workflowmodel.processor.activity.AsynchronousActivity;
+
+/**
+ * Helper class to facilitate in executing Activities in isolation.
+ * 
+ * @author Stuart Owen
+ * @author Alex Nenadic
+ * @author Stian Soiland-Reyes
+ * @author David Withers
+ */
+public class ActivityInvoker {
+
+	/**
+	 * Timeout in seconds
+	 */
+	public static long TIMEOUT = 30;
+
+	
+	/**
+	 * Invokes an {@link AsynchronousActivity} with a given set of input Objects
+	 * and returns a Map<String,Object> of requested output values.
+	 * 
+	 * @param activity
+	 *            the activity to be tested
+	 * @param inputs
+	 *            a Map<String,Object> of input Objects
+	 * @param requestedOutputs
+	 *            a List<String> of outputs to be examined
+	 * 
+	 * @return a Map<String,Object> of the outputs requested by requestedOutput
+	 *         or <code>null</code> if a failure occurs
+	 * @throws InterruptedException 
+	 * @throws Throwable 
+	 */
+/*	public static Map<String, Object> invokeAsyncActivity(
+			AbstractAsynchronousActivity<?> activity,
+			Map<String, Object> inputs, Map<String, Class<?>> requestedOutputs)
+			throws Exception {
+		Map<String, Object> results = new HashMap<String, Object>();
+
+		ApplicationContext context = new RavenAwareClassPathXmlApplicationContext(
+		"inMemoryActivityTestsContext.xml");
+		ReferenceService referenceService = (ReferenceService) context.getBean("t2reference.service.referenceService");
+
+		DummyCallback callback = new DummyCallback(referenceService);
+		Map<String, T2Reference> inputEntities = new HashMap<String, T2Reference>();
+		for (String inputName : inputs.keySet()) {
+			Object val = inputs.get(inputName);
+			if (val instanceof List) {
+				inputEntities.put(inputName, referenceService.register(val, 1, true, callback.getContext()));
+			} else {
+				inputEntities.put(inputName, referenceService.register(val, 0, true, callback.getContext()));
+			}
+		}
+
+		activity.executeAsynch(inputEntities, callback);
+		callback.thread.join();
+
+		if (callback.failed) {
+			results = null;
+		} else {
+			for (Map.Entry<String, Class<?>> output : requestedOutputs.entrySet()) {
+				T2Reference id = callback.data.get(output.getKey());
+				if (id != null) {
+					Object result;
+					result = referenceService.renderIdentifier(id, output.getValue(), callback.getContext());
+					results.put(output.getKey(), result);
+				}
+			}
+		}
+		return results;
+	}
+	*/
+
+	// Changed this method to render the T2Reference to an object only if the type of the object in 
+	// requestedOutputs is not an instance of ExternalReferenceSPI. Otherwise, the calling test method 
+	// should get activity ReferenceSet and render the object itself. This was needed for API consumer activity 
+	// testing - see ApiConsumerActivityTest.
+	// Also added support for multi-dimensional lists.
+	public static Map<String, Object> invokeAsyncActivity(
+			AbstractAsynchronousActivity<?> activity,
+			Map<String, Object> inputs, Map<String, Class<?>> requestedOutputs) throws InterruptedException
+			 {
+		
+		Map<String, Object> results = new HashMap<String, Object>();
+
+		ReferenceService referenceService = createReferenceService();
+		
+		DummyCallback callback = new DummyCallback(referenceService);
+		Map<String, T2Reference> inputEntities = new HashMap<String, T2Reference>();
+		for (String inputName : inputs.keySet()) {
+			Object val = inputs.get(inputName);
+			int depth = getDepth(val);
+			inputEntities.put(inputName, referenceService.register(val, depth, true, callback.getContext()));
+		}
+
+		activity.executeAsynch(inputEntities, callback);
+		callback.thread.join(TIMEOUT*1000);
+
+		
+		if (callback.failed) {
+			throw callback.failures.get(0);
+		} else {
+			for (Map.Entry<String, Class<?>> output : requestedOutputs.entrySet()) {
+				T2Reference id = callback.data.get(output.getKey());
+				if (ExternalReferenceSPI.class.isAssignableFrom(output.getValue())){
+					// Do not render the object - just resolve the T2Reference
+					Object result;
+					result = referenceService.resolveIdentifier(id, null, callback.getContext());
+					results.put(output.getKey(), result);
+				}
+				else{
+					// Try to render the object behind the reference
+					Object result;
+					result = referenceService.renderIdentifier(id, output.getValue(), callback.getContext());
+					results.put(output.getKey(), result);
+				}
+			}
+		}
+		return results;
+	}
+
+	private static ReferenceService createReferenceService() {
+		SimpleT2ReferenceGenerator referenceGenerator = new SimpleT2ReferenceGenerator();
+		ReferenceSetAugmentorImpl referenceSetAugmentor = new ReferenceSetAugmentorImpl();
+		referenceSetAugmentor.setBuilders((List<ExternalReferenceBuilderSPI<?>>) getBuilders());
+		referenceSetAugmentor.setTranslators(getTranslators());
+		
+		ReferenceSetServiceImpl referenceSetService = new ReferenceSetServiceImpl();
+		referenceSetService.setT2ReferenceGenerator(referenceGenerator);
+		referenceSetService.setReferenceSetDao(new InMemoryReferenceSetDao());
+		referenceSetService.setReferenceSetAugmentor(referenceSetAugmentor);
+		
+		ListServiceImpl listService = new ListServiceImpl();
+		listService.setT2ReferenceGenerator(referenceGenerator);
+		listService.setListDao(new InMemoryListDao());
+		
+		ErrorDocumentServiceImpl errorDocumentService = new ErrorDocumentServiceImpl();
+		errorDocumentService.setT2ReferenceGenerator(referenceGenerator);
+		errorDocumentService.setErrorDao(new InMemoryErrorDocumentDao());
+		
+		ReferenceServiceImpl referenceService = new ReferenceServiceImpl();
+		referenceService.setReferenceSetService(referenceSetService);
+		referenceService.setListService(listService);
+		referenceService.setErrorDocumentService(errorDocumentService);
+		referenceService.setConverters(getConverters());
+		referenceService.setValueBuilders(getValueBuilders());
+		
+		return referenceService;
+	}
+	
+	private static <T> List<T> getImplementations(Class<T> api) {
+		List<T> implementations = new ArrayList<T>();
+		ServiceLoader<T> serviceLoader = ServiceLoader.load(api);
+		for (T implementation : serviceLoader) {
+			implementations.add(implementation);
+		}
+		return implementations;
+	}
+	
+	private static List<StreamToValueConverterSPI> getValueBuilders() {
+		return getImplementations(StreamToValueConverterSPI.class);
+	}
+
+	private static List<ValueToReferenceConverterSPI> getConverters() {
+		return getImplementations(ValueToReferenceConverterSPI.class);
+	}
+
+	private static List<ExternalReferenceTranslatorSPI<?, ?>> getTranslators() {
+		List<ExternalReferenceTranslatorSPI<?, ?>> implementations = new ArrayList<ExternalReferenceTranslatorSPI<?, ?>>();
+		ServiceLoader<ExternalReferenceTranslatorSPI> serviceLoader = ServiceLoader.load(ExternalReferenceTranslatorSPI.class);
+		for (ExternalReferenceTranslatorSPI implementation : serviceLoader) {
+			implementations.add(implementation);
+		}
+		return implementations;
+	}
+
+	private static List<ExternalReferenceBuilderSPI<?>> getBuilders() {
+		List<ExternalReferenceBuilderSPI<?>> implementations = new ArrayList<ExternalReferenceBuilderSPI<?>>();
+		ServiceLoader<ExternalReferenceBuilderSPI> serviceLoader = ServiceLoader.load(ExternalReferenceBuilderSPI.class);
+		for (ExternalReferenceBuilderSPI implementation : serviceLoader) {
+			implementations.add(implementation);
+		}
+		return implementations;
+	}
+
+	/**
+	 * If an object is activity list - returns its depth, 0 otherwise (for single objects).
+	 * @param obj
+	 * @return
+	 */
+	private static int getDepth(Object obj){
+
+		if (obj instanceof List) {
+			// Assumes all sub-lists are of the same depth,
+			// so just uses the first sub-list to calculate it.
+			Object[] sublists = ((List<?>)obj).toArray();
+			int depth = 1;
+			depth = getDepth(sublists[0]) + 1;
+			return depth;
+		} else {
+			return 0;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-activity-test-utils/src/main/java/org/apache/taverna/activities/testutils/DummyCallback.java
----------------------------------------------------------------------
diff --git a/taverna-activity-test-utils/src/main/java/org/apache/taverna/activities/testutils/DummyCallback.java b/taverna-activity-test-utils/src/main/java/org/apache/taverna/activities/testutils/DummyCallback.java
new file mode 100644
index 0000000..6797ff3
--- /dev/null
+++ b/taverna-activity-test-utils/src/main/java/org/apache/taverna/activities/testutils/DummyCallback.java
@@ -0,0 +1,105 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.activities.testutils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.invocation.impl.InvocationContextImpl;
+import org.apache.taverna.reference.ReferenceService;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.workflowmodel.processor.activity.AsynchronousActivityCallback;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchErrorType;
+
+import org.apache.log4j.Logger;
+
+/**
+ * A DummyCallback to aid with testing Activities.
+ * 
+ * @author Stuart Owen
+ * @author David Withers
+ * @author Stian Soiland-Reyes
+ *
+ */
+public class DummyCallback implements AsynchronousActivityCallback {
+	
+	private static Logger logger = Logger
+	.getLogger(DummyCallback.class);
+
+	public ReferenceService referenceService;
+	public InvocationContext invocationContext;
+	public Map<String, T2Reference> data;
+	public Thread thread;
+
+	public boolean failed = false;
+	
+	public List<RuntimeException> failures = new ArrayList<RuntimeException>();
+	
+	public DummyCallback(ReferenceService referenceService) {
+		this.referenceService = referenceService;
+		this.invocationContext = new InvocationContextImpl(referenceService, null);
+	}
+
+	public void fail(String message, Throwable t) {
+		fail(message, t, null);
+	}
+
+	public void fail(String message) {
+		fail(message, null, null);
+	}
+
+	public void fail(String message, Throwable t, DispatchErrorType arg2) {
+		failed = true;
+		failures.add(new RuntimeException(arg2+message, t));
+		logger.error("", t);
+	}
+	
+	/*public SecurityAgentManager getLocalSecurityManager() {
+		// TODO Auto-generated method stub
+		return null;
+	}*/
+
+	public void receiveCompletion(int[] completionIndex) {
+		// TODO Auto-generated method stub
+
+	}
+
+	public void receiveResult(Map<String, T2Reference> data,
+			int[] index) {
+		this.data = data;
+	}
+
+	public void requestRun(Runnable runMe) {
+		thread = new Thread(runMe);
+		thread.start();
+	}
+
+	public InvocationContext getContext() {
+		return invocationContext;
+	}
+
+	public String getParentProcessIdentifier() {
+		// TODO Auto-generated method stub
+		return "";
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-activity-test-utils/src/main/java/org/apache/taverna/activities/testutils/LocationConstants.java
----------------------------------------------------------------------
diff --git a/taverna-activity-test-utils/src/main/java/org/apache/taverna/activities/testutils/LocationConstants.java b/taverna-activity-test-utils/src/main/java/org/apache/taverna/activities/testutils/LocationConstants.java
new file mode 100644
index 0000000..21f7e33
--- /dev/null
+++ b/taverna-activity-test-utils/src/main/java/org/apache/taverna/activities/testutils/LocationConstants.java
@@ -0,0 +1,30 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.activities.testutils;
+
+/**
+ * A definition of constants for base locations of external resources used for testing.
+ * 
+ * @author Stuart Owen
+ *
+ */
+public interface LocationConstants {
+	public static final String WSDL_TEST_BASE="http://www.mygrid.org.uk/taverna-tests/testwsdls/";
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-activity-test-utils/src/main/resources/context-parts/componentservices.xml
----------------------------------------------------------------------
diff --git a/taverna-activity-test-utils/src/main/resources/context-parts/componentservices.xml b/taverna-activity-test-utils/src/main/resources/context-parts/componentservices.xml
index 36ac3e3..bf2b595 100644
--- a/taverna-activity-test-utils/src/main/resources/context-parts/componentservices.xml
+++ b/taverna-activity-test-utils/src/main/resources/context-parts/componentservices.xml
@@ -11,17 +11,17 @@
 
 	<!-- t2 reference generator -->
 	<bean id="t2reference.referenceGenerator"
-		raven:artifact="net.sf.taverna.t2.core:reference-impl:2.0.1-SNAPSHOT"
+		raven:artifact="org.apache.taverna.core:reference-impl:2.0.1-SNAPSHOT"
 		raven:repository="raven.repository"
-		class="net.sf.taverna.t2.reference.impl.SimpleT2ReferenceGenerator">
+		class="org.apache.taverna.reference.impl.SimpleT2ReferenceGenerator">
 		<property name="namespace" value="testNamespace" />
 	</bean>
 
 	<!-- reference set service -->
 	<bean id="t2reference.service.referenceSetService"
-		raven:artifact="net.sf.taverna.t2.core:reference-impl:2.0.1-SNAPSHOT"
+		raven:artifact="org.apache.taverna.core:reference-impl:2.0.1-SNAPSHOT"
 		raven:repository="raven.repository"
-		class="net.sf.taverna.t2.reference.impl.ReferenceSetServiceImpl">
+		class="org.apache.taverna.reference.impl.ReferenceSetServiceImpl">
 		<property name="referenceSetDao">
 			<ref bean="t2reference.dao.referenceSetDao" />
 		</property>
@@ -34,35 +34,35 @@
 	</bean>
 
 	<bean id="t2reference.augmentor"
-		class="net.sf.taverna.t2.reference.impl.ReferenceSetAugmentorImpl"
-		raven:artifact="net.sf.taverna.t2.core:reference-impl:2.0.1-SNAPSHOT"
+		class="org.apache.taverna.reference.impl.ReferenceSetAugmentorImpl"
+		raven:artifact="org.apache.taverna.core:reference-impl:2.0.1-SNAPSHOT"
 		raven:repository="raven.repository">
 		<property name="builderRegistry">
 			<bean
-				class="net.sf.taverna.platform.spring.InstanceRegistryFactoryBean">
+				class="org.apache.taverna.platform.spring.InstanceRegistryFactoryBean">
 				<property name="spiRegistry">
 					<bean
-						class="net.sf.taverna.platform.spring.SpiRegistryFactoryBean">
+						class="org.apache.taverna.platform.spring.SpiRegistryFactoryBean">
 						<property name="repository">
 							<ref bean="raven.repository" />
 						</property>
 						<property name="spiClassName"
-							value="net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI" />
+							value="org.apache.taverna.reference.ExternalReferenceBuilderSPI" />
 					</bean>
 				</property>
 			</bean>
 		</property>
 		<property name="translatorRegistry">
 			<bean
-				class="net.sf.taverna.platform.spring.InstanceRegistryFactoryBean">
+				class="org.apache.taverna.platform.spring.InstanceRegistryFactoryBean">
 				<property name="spiRegistry">
 					<bean
-						class="net.sf.taverna.platform.spring.SpiRegistryFactoryBean">
+						class="org.apache.taverna.platform.spring.SpiRegistryFactoryBean">
 						<property name="repository">
 							<ref bean="raven.repository" />
 						</property>
 						<property name="spiClassName"
-							value="net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI" />
+							value="org.apache.taverna.reference.ExternalReferenceTranslatorSPI" />
 					</bean>
 				</property>
 			</bean>
@@ -71,9 +71,9 @@
 
 	<!-- error document service -->
 	<bean id="t2reference.service.errorDocumentService"
-		raven:artifact="net.sf.taverna.t2.core:reference-impl:2.0.1-SNAPSHOT"
+		raven:artifact="org.apache.taverna.core:reference-impl:2.0.1-SNAPSHOT"
 		raven:repository="raven.repository"
-		class="net.sf.taverna.t2.reference.impl.ErrorDocumentServiceImpl">
+		class="org.apache.taverna.reference.impl.ErrorDocumentServiceImpl">
 		<property name="errorDao">
 			<ref bean="t2reference.dao.errorDocumentDao" />
 		</property>
@@ -84,9 +84,9 @@
 
 	<!-- list service -->
 	<bean id="t2reference.service.listService"
-		raven:artifact="net.sf.taverna.t2.core:reference-impl:2.0.1-SNAPSHOT"
+		raven:artifact="org.apache.taverna.core:reference-impl:2.0.1-SNAPSHOT"
 		raven:repository="raven.repository"
-		class="net.sf.taverna.t2.reference.impl.ListServiceImpl">
+		class="org.apache.taverna.reference.impl.ListServiceImpl">
 		<property name="listDao">
 			<ref bean="t2reference.dao.listDao" />
 		</property>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-activity-test-utils/src/main/resources/context-parts/dao_hibernate.xml
----------------------------------------------------------------------
diff --git a/taverna-activity-test-utils/src/main/resources/context-parts/dao_hibernate.xml b/taverna-activity-test-utils/src/main/resources/context-parts/dao_hibernate.xml
index 563eb96..8d6c845 100644
--- a/taverna-activity-test-utils/src/main/resources/context-parts/dao_hibernate.xml
+++ b/taverna-activity-test-utils/src/main/resources/context-parts/dao_hibernate.xml
@@ -11,7 +11,7 @@
 
 	<!-- An SPI-enabled hibernate session factory -->
 	<bean id="t2reference.orm.h3.sessionFactory"
-		class="net.sf.taverna.platform.spring.orm.hibernate3.SpiRegistryAwareLocalSessionFactoryBean">
+		class="org.apache.taverna.platform.spring.orm.hibernate3.SpiRegistryAwareLocalSessionFactoryBean">
 		<property name="dataSource">
 			<ref bean="t2reference.jdbc.datasource" />
 		</property>
@@ -27,7 +27,7 @@
 		<property name="mappingResources">
 			<list>
 				<value>
-					net/sf/taverna/t2/reference/AbstractExternalReference.hbm.xml
+					org/apache/taverna/reference/AbstractExternalReference.hbm.xml
 				</value>
 			</list>
 		</property>
@@ -40,60 +40,60 @@
 				<!-- This *must* go before the external reference SPI bean or   -->
 				<!-- those beans won't find the mapping for their superclasses  -->
 				<bean
-					class="net.sf.taverna.platform.spring.SpiRegistryFactoryBean">
+					class="org.apache.taverna.platform.spring.SpiRegistryFactoryBean">
 					<property name="repository">
 						<ref bean="raven.repository" />
 					</property>
 					<property name="spiClassName"
-						value="net.sf.taverna.t2.reference.h3.HibernateMappedEntity" />
+						value="org.apache.taverna.reference.h3.HibernateMappedEntity" />
 				</bean>
 				<!-- SPI used by the raven-aware hibernate session factory bean -->
 				<bean
-					class="net.sf.taverna.platform.spring.SpiRegistryFactoryBean">
+					class="org.apache.taverna.platform.spring.SpiRegistryFactoryBean">
 					<property name="repository">
 						<ref bean="raven.repository" />
 					</property>
 					<property name="spiClassName"
-						value="net.sf.taverna.t2.reference.ExternalReferenceSPI" />
+						value="org.apache.taverna.reference.ExternalReferenceSPI" />
 				</bean>
 			</list>
 		</property>
 		<property name="preloadRegistries">
 			<list>
 				<bean
-					class="net.sf.taverna.platform.spring.SpiRegistryFactoryBean">
+					class="org.apache.taverna.platform.spring.SpiRegistryFactoryBean">
 					<property name="repository">
 						<ref bean="raven.repository" />
 					</property>
 					<property name="spiClassName"
-						value="net.sf.taverna.t2.reference.h3.HibernateComponentClass" />
+						value="org.apache.taverna.reference.h3.HibernateComponentClass" />
 				</bean>
 			</list>
 		</property>
 	</bean>
 
 	<bean id="t2reference.dao.referenceSetDao"
-		raven:artifact="net.sf.taverna.t2.core:reference-impl:2.0.1-SNAPSHOT"
+		raven:artifact="org.apache.taverna.core:reference-impl:2.0.1-SNAPSHOT"
 		raven:repository="raven.repository"
-		class="net.sf.taverna.t2.reference.impl.HibernateReferenceSetDao">
+		class="org.apache.taverna.reference.impl.HibernateReferenceSetDao">
 		<property name="sessionFactory">
 			<ref local="t2reference.orm.h3.sessionFactory" />
 		</property>
 	</bean>
 
 	<bean id="t2reference.dao.errorDocumentDao"
-		raven:artifact="net.sf.taverna.t2.core:reference-impl:2.0.1-SNAPSHOT"
+		raven:artifact="org.apache.taverna.core:reference-impl:2.0.1-SNAPSHOT"
 		raven:repository="raven.repository"
-		class="net.sf.taverna.t2.reference.impl.HibernateErrorDocumentDao">
+		class="org.apache.taverna.reference.impl.HibernateErrorDocumentDao">
 		<property name="sessionFactory">
 			<ref local="t2reference.orm.h3.sessionFactory" />
 		</property>
 	</bean>
 
 	<bean id="t2reference.dao.listDao"
-		raven:artifact="net.sf.taverna.t2.core:reference-impl:2.0.1-SNAPSHOT"
+		raven:artifact="org.apache.taverna.core:reference-impl:2.0.1-SNAPSHOT"
 		raven:repository="raven.repository"
-		class="net.sf.taverna.t2.reference.impl.HibernateListDao">
+		class="org.apache.taverna.reference.impl.HibernateListDao">
 		<property name="sessionFactory">
 			<ref local="t2reference.orm.h3.sessionFactory" />
 		</property>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-activity-test-utils/src/main/resources/context-parts/dao_hibernate_transactional.xml
----------------------------------------------------------------------
diff --git a/taverna-activity-test-utils/src/main/resources/context-parts/dao_hibernate_transactional.xml b/taverna-activity-test-utils/src/main/resources/context-parts/dao_hibernate_transactional.xml
index 4823cf8..5336775 100644
--- a/taverna-activity-test-utils/src/main/resources/context-parts/dao_hibernate_transactional.xml
+++ b/taverna-activity-test-utils/src/main/resources/context-parts/dao_hibernate_transactional.xml
@@ -29,7 +29,7 @@
 
 	<!-- An SPI-enabled hibernate session factory -->
 	<bean id="t2reference.orm.h3.sessionFactory"
-		class="net.sf.taverna.platform.spring.orm.hibernate3.SpiRegistryAwareLocalSessionFactoryBean">
+		class="org.apache.taverna.platform.spring.orm.hibernate3.SpiRegistryAwareLocalSessionFactoryBean">
 		<property name="dataSource">
 			<ref bean="t2reference.jdbc.datasource" />
 		</property>
@@ -45,7 +45,7 @@
 		<property name="mappingResources">
 			<list>
 				<value>
-					net/sf/taverna/t2/reference/AbstractExternalReference.hbm.xml
+					org/apache/taverna/reference/AbstractExternalReference.hbm.xml
 				</value>
 			</list>
 		</property>
@@ -58,60 +58,60 @@
 				<!-- This *must* go before the external reference SPI bean or   -->
 				<!-- those beans won't find the mapping for their superclasses  -->
 				<bean
-					class="net.sf.taverna.platform.spring.SpiRegistryFactoryBean">
+					class="org.apache.taverna.platform.spring.SpiRegistryFactoryBean">
 					<property name="repository">
 						<ref bean="raven.repository" />
 					</property>
 					<property name="spiClassName"
-						value="net.sf.taverna.t2.reference.h3.HibernateMappedEntity" />
+						value="org.apache.taverna.reference.h3.HibernateMappedEntity" />
 				</bean>
 				<!-- SPI used by the raven-aware hibernate session factory bean -->
 				<bean
-					class="net.sf.taverna.platform.spring.SpiRegistryFactoryBean">
+					class="org.apache.taverna.platform.spring.SpiRegistryFactoryBean">
 					<property name="repository">
 						<ref bean="raven.repository" />
 					</property>
 					<property name="spiClassName"
-						value="net.sf.taverna.t2.reference.ExternalReferenceSPI" />
+						value="org.apache.taverna.reference.ExternalReferenceSPI" />
 				</bean>
 			</list>
 		</property>
 		<property name="preloadRegistries">
 			<list>
 				<bean
-					class="net.sf.taverna.platform.spring.SpiRegistryFactoryBean">
+					class="org.apache.taverna.platform.spring.SpiRegistryFactoryBean">
 					<property name="repository">
 						<ref bean="raven.repository" />
 					</property>
 					<property name="spiClassName"
-						value="net.sf.taverna.t2.reference.h3.HibernateComponentClass" />
+						value="org.apache.taverna.reference.h3.HibernateComponentClass" />
 				</bean>
 			</list>
 		</property>
 	</bean>
 
 	<bean id="t2reference.dao.referenceSetDao"
-		raven:artifact="net.sf.taverna.t2.core:reference-impl:2.0.1-SNAPSHOT"
+		raven:artifact="org.apache.taverna.core:reference-impl:2.0.1-SNAPSHOT"
 		raven:repository="raven.repository"
-		class="net.sf.taverna.t2.reference.impl.TransactionalHibernateReferenceSetDao">
+		class="org.apache.taverna.reference.impl.TransactionalHibernateReferenceSetDao">
 		<property name="sessionFactory">
 			<ref local="t2reference.orm.h3.sessionFactory" />
 		</property>
 	</bean>
 
 	<bean id="t2reference.dao.errorDocumentDao"
-		raven:artifact="net.sf.taverna.t2.core:reference-impl:2.0.1-SNAPSHOT"
+		raven:artifact="org.apache.taverna.core:reference-impl:2.0.1-SNAPSHOT"
 		raven:repository="raven.repository"
-		class="net.sf.taverna.t2.reference.impl.TransactionalHibernateErrorDocumentDao">
+		class="org.apache.taverna.reference.impl.TransactionalHibernateErrorDocumentDao">
 		<property name="sessionFactory">
 			<ref local="t2reference.orm.h3.sessionFactory" />
 		</property>
 	</bean>
 
 	<bean id="t2reference.dao.listDao"
-		raven:artifact="net.sf.taverna.t2.core:reference-impl:2.0.1-SNAPSHOT"
+		raven:artifact="org.apache.taverna.core:reference-impl:2.0.1-SNAPSHOT"
 		raven:repository="raven.repository"
-		class="net.sf.taverna.t2.reference.impl.TransactionalHibernateListDao">
+		class="org.apache.taverna.reference.impl.TransactionalHibernateListDao">
 		<property name="sessionFactory">
 			<ref local="t2reference.orm.h3.sessionFactory" />
 		</property>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-activity-test-utils/src/main/resources/context-parts/dao_inmemory.xml
----------------------------------------------------------------------
diff --git a/taverna-activity-test-utils/src/main/resources/context-parts/dao_inmemory.xml b/taverna-activity-test-utils/src/main/resources/context-parts/dao_inmemory.xml
index bb1a790..20aabd2 100644
--- a/taverna-activity-test-utils/src/main/resources/context-parts/dao_inmemory.xml
+++ b/taverna-activity-test-utils/src/main/resources/context-parts/dao_inmemory.xml
@@ -10,21 +10,21 @@
 	http://taverna.sf.net/schema/artifact-support/artifact-support.xsd">
 
 	<bean id="t2reference.dao.referenceSetDao"
-		raven:artifact="net.sf.taverna.t2.core:reference-impl:2.0.1-SNAPSHOT"
+		raven:artifact="org.apache.taverna.core:reference-impl:2.0.1-SNAPSHOT"
 		raven:repository="raven.repository"
-		class="net.sf.taverna.t2.reference.impl.InMemoryReferenceSetDao">
+		class="org.apache.taverna.reference.impl.InMemoryReferenceSetDao">
 	</bean>
 
 	<bean id="t2reference.dao.errorDocumentDao"
-		raven:artifact="net.sf.taverna.t2.core:reference-impl:2.0.1-SNAPSHOT"
+		raven:artifact="org.apache.taverna.core:reference-impl:2.0.1-SNAPSHOT"
 		raven:repository="raven.repository"
-		class="net.sf.taverna.t2.reference.impl.InMemoryErrorDocumentDao">
+		class="org.apache.taverna.reference.impl.InMemoryErrorDocumentDao">
 	</bean>
 
 	<bean id="t2reference.dao.listDao"
-		raven:artifact="net.sf.taverna.t2.core:reference-impl:2.0.1-SNAPSHOT"
+		raven:artifact="org.apache.taverna.core:reference-impl:2.0.1-SNAPSHOT"
 		raven:repository="raven.repository"
-		class="net.sf.taverna.t2.reference.impl.InMemoryListDao">
+		class="org.apache.taverna.reference.impl.InMemoryListDao">
 	</bean>
 
 </beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-activity-test-utils/src/main/resources/context-parts/hibernateprops_derby.xml
----------------------------------------------------------------------
diff --git a/taverna-activity-test-utils/src/main/resources/context-parts/hibernateprops_derby.xml b/taverna-activity-test-utils/src/main/resources/context-parts/hibernateprops_derby.xml
index 39e812c..8230f26 100644
--- a/taverna-activity-test-utils/src/main/resources/context-parts/hibernateprops_derby.xml
+++ b/taverna-activity-test-utils/src/main/resources/context-parts/hibernateprops_derby.xml
@@ -12,13 +12,13 @@
 
 	<!-- Apache Derby rooted at a temporary directory -->
 	<bean id="t2reference.jdbc.temporaryjdbc"
-		class="net.sf.taverna.platform.spring.jdbc.TemporaryJDBC">
+		class="org.apache.taverna.platform.spring.jdbc.TemporaryJDBC">
 	</bean>
 	<bean id="t2reference.jdbc.url" class="java.lang.String"
 		factory-bean="t2reference.jdbc.temporaryjdbc"
 		factory-method="getTemporaryDerbyJDBC" />
 	<bean id="t2reference.jdbc.datasource"
-		class="net.sf.taverna.platform.spring.jdbc.InterpolatingDriverManagerDataSource">
+		class="org.apache.taverna.platform.spring.jdbc.InterpolatingDriverManagerDataSource">
 		<property name="driverClassName">
 			<value>org.apache.derby.jdbc.EmbeddedDriver</value>
 		</property>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-activity-test-utils/src/main/resources/context-parts/raven_local.xml
----------------------------------------------------------------------
diff --git a/taverna-activity-test-utils/src/main/resources/context-parts/raven_local.xml b/taverna-activity-test-utils/src/main/resources/context-parts/raven_local.xml
index 94238a0..1462c26 100644
--- a/taverna-activity-test-utils/src/main/resources/context-parts/raven_local.xml
+++ b/taverna-activity-test-utils/src/main/resources/context-parts/raven_local.xml
@@ -16,10 +16,10 @@
 		<system>
 			<!-- T2Reference API -->
 			<sys
-				artifact="net.sf.taverna.t2.core:reference-api:0.8" />
+				artifact="org.apache.taverna.core:reference-api:0.8" />
 
 			<!-- T2Platform -->
-			<sys artifact="net.sf.taverna.t2:platform:0.1" />
+			<sys artifact="org.apache.taverna:platform:0.1" />
 			<sys artifact="commons-logging:commons-logging:1.1.1" />
 
 			<!-- Raven -->

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-activity-test-utils/src/main/resources/context-parts/referenceservice.xml
----------------------------------------------------------------------
diff --git a/taverna-activity-test-utils/src/main/resources/context-parts/referenceservice.xml b/taverna-activity-test-utils/src/main/resources/context-parts/referenceservice.xml
index 3a37d1b..7f50c5b 100644
--- a/taverna-activity-test-utils/src/main/resources/context-parts/referenceservice.xml
+++ b/taverna-activity-test-utils/src/main/resources/context-parts/referenceservice.xml
@@ -11,9 +11,9 @@
 
 	<!-- Reference service bean -->
 	<bean id="t2reference.service.referenceService"
-		raven:artifact="net.sf.taverna.t2.core:reference-impl:2.0.1-SNAPSHOT"
+		raven:artifact="org.apache.taverna.core:reference-impl:2.0.1-SNAPSHOT"
 		raven:repository="raven.repository"
-		class="net.sf.taverna.t2.reference.impl.ReferenceServiceImpl">
+		class="org.apache.taverna.reference.impl.ReferenceServiceImpl">
 		<property name="referenceSetService">
 			<ref bean="t2reference.service.referenceSetService" />
 		</property>
@@ -25,30 +25,30 @@
 		</property>
 		<property name="converterRegistry">
 			<bean id="converterRegistry"
-				class="net.sf.taverna.platform.spring.InstanceRegistryFactoryBean">
+				class="org.apache.taverna.platform.spring.InstanceRegistryFactoryBean">
 				<property name="spiRegistry">
 					<bean
-						class="net.sf.taverna.platform.spring.SpiRegistryFactoryBean">
+						class="org.apache.taverna.platform.spring.SpiRegistryFactoryBean">
 						<property name="repository">
 							<ref bean="raven.repository" />
 						</property>
 						<property name="spiClassName"
-							value="net.sf.taverna.t2.reference.ValueToReferenceConverterSPI" />
+							value="org.apache.taverna.reference.ValueToReferenceConverterSPI" />
 					</bean>
 				</property>
 			</bean>
 		</property>
 		<property name="valueBuilderRegistry">
 			<bean
-				class="net.sf.taverna.platform.spring.InstanceRegistryFactoryBean">
+				class="org.apache.taverna.platform.spring.InstanceRegistryFactoryBean">
 				<property name="spiRegistry">
 					<bean
-						class="net.sf.taverna.platform.spring.SpiRegistryFactoryBean">
+						class="org.apache.taverna.platform.spring.SpiRegistryFactoryBean">
 						<property name="repository">
 							<ref bean="raven.repository" />
 						</property>
 						<property name="spiClassName"
-							value="net.sf.taverna.t2.reference.StreamToValueConverterSPI" />
+							value="org.apache.taverna.reference.StreamToValueConverterSPI" />
 					</bean>
 				</property>
 			</bean>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-capability-api/src/main/java/org/apache/taverna/platform/capability/api/ActivityService.java
----------------------------------------------------------------------
diff --git a/taverna-capability-api/src/main/java/org/apache/taverna/platform/capability/api/ActivityService.java b/taverna-capability-api/src/main/java/org/apache/taverna/platform/capability/api/ActivityService.java
index fe8adac..42a355d 100644
--- a/taverna-capability-api/src/main/java/org/apache/taverna/platform/capability/api/ActivityService.java
+++ b/taverna-capability-api/src/main/java/org/apache/taverna/platform/capability/api/ActivityService.java
@@ -22,7 +22,7 @@ package org.apache.taverna.platform.capability.api;
 import java.net.URI;
 import java.util.Set;
 
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
 import org.apache.taverna.scufl2.api.port.InputActivityPort;
 import org.apache.taverna.scufl2.api.port.OutputActivityPort;
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-capability-api/src/main/java/org/apache/taverna/platform/capability/api/DispatchLayerService.java
----------------------------------------------------------------------
diff --git a/taverna-capability-api/src/main/java/org/apache/taverna/platform/capability/api/DispatchLayerService.java b/taverna-capability-api/src/main/java/org/apache/taverna/platform/capability/api/DispatchLayerService.java
index a6cfb53..e8db2b9 100644
--- a/taverna-capability-api/src/main/java/org/apache/taverna/platform/capability/api/DispatchLayerService.java
+++ b/taverna-capability-api/src/main/java/org/apache/taverna/platform/capability/api/DispatchLayerService.java
@@ -22,7 +22,7 @@ package org.apache.taverna.platform.capability.api;
 import java.net.URI;
 import java.util.Set;
 
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchLayer;
+import org.apache.taverna.workflowmodel.processor.dispatch.DispatchLayer;
 
 import com.fasterxml.jackson.databind.JsonNode;
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-capability-impl/src/main/java/org/apache/taverna/platform/capability/activity/impl/ActivityServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-capability-impl/src/main/java/org/apache/taverna/platform/capability/activity/impl/ActivityServiceImpl.java b/taverna-capability-impl/src/main/java/org/apache/taverna/platform/capability/activity/impl/ActivityServiceImpl.java
index 685b2bd..d5e5eab 100644
--- a/taverna-capability-impl/src/main/java/org/apache/taverna/platform/capability/activity/impl/ActivityServiceImpl.java
+++ b/taverna-capability-impl/src/main/java/org/apache/taverna/platform/capability/activity/impl/ActivityServiceImpl.java
@@ -24,10 +24,10 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityFactory;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityInputPort;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityOutputPort;
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+import org.apache.taverna.workflowmodel.processor.activity.ActivityFactory;
+import org.apache.taverna.workflowmodel.processor.activity.ActivityInputPort;
+import org.apache.taverna.workflowmodel.processor.activity.ActivityOutputPort;
 import org.apache.taverna.platform.capability.api.ActivityConfigurationException;
 import org.apache.taverna.platform.capability.api.ActivityNotFoundException;
 import org.apache.taverna.platform.capability.api.ActivityService;
@@ -72,7 +72,7 @@ public class ActivityServiceImpl implements ActivityService {
 		try {
 			if (configuration != null)
 				activity.configure(configuration);
-		} catch (net.sf.taverna.t2.workflowmodel.processor.activity.ActivityConfigurationException e) {
+		} catch (org.apache.taverna.workflowmodel.processor.activity.ActivityConfigurationException e) {
 			throw new ActivityConfigurationException(e);
 		}
 		return activity;
@@ -92,7 +92,7 @@ public class ActivityServiceImpl implements ActivityService {
 				inputPorts.add(inputActivityPort);
 			}
 			return inputPorts;
-		} catch (net.sf.taverna.t2.workflowmodel.processor.activity.ActivityConfigurationException e) {
+		} catch (org.apache.taverna.workflowmodel.processor.activity.ActivityConfigurationException e) {
 			throw new ActivityConfigurationException(e);
 		}
 	}
@@ -111,7 +111,7 @@ public class ActivityServiceImpl implements ActivityService {
 				outputActivityPort.setGranularDepth(port.getGranularDepth());
 				outputPorts.add(outputActivityPort);
 			}
-		} catch (net.sf.taverna.t2.workflowmodel.processor.activity.ActivityConfigurationException e) {
+		} catch (org.apache.taverna.workflowmodel.processor.activity.ActivityConfigurationException e) {
 			throw new ActivityConfigurationException(e);
 		}
 		return outputPorts;

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-capability-impl/src/main/java/org/apache/taverna/platform/capability/dispatch/impl/DispatchLayerServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-capability-impl/src/main/java/org/apache/taverna/platform/capability/dispatch/impl/DispatchLayerServiceImpl.java b/taverna-capability-impl/src/main/java/org/apache/taverna/platform/capability/dispatch/impl/DispatchLayerServiceImpl.java
index ddad1e5..7057ba4 100644
--- a/taverna-capability-impl/src/main/java/org/apache/taverna/platform/capability/dispatch/impl/DispatchLayerServiceImpl.java
+++ b/taverna-capability-impl/src/main/java/org/apache/taverna/platform/capability/dispatch/impl/DispatchLayerServiceImpl.java
@@ -25,8 +25,8 @@ import java.util.List;
 import java.util.Set;
 import java.util.logging.Logger;
 
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchLayerFactory;
+import org.apache.taverna.workflowmodel.processor.dispatch.DispatchLayer;
+import org.apache.taverna.workflowmodel.processor.dispatch.DispatchLayerFactory;
 import org.apache.taverna.platform.capability.api.DispatchLayerConfigurationException;
 import org.apache.taverna.platform.capability.api.DispatchLayerNotFoundException;
 import org.apache.taverna.platform.capability.api.DispatchLayerService;
@@ -80,7 +80,7 @@ public class DispatchLayerServiceImpl implements DispatchLayerService {
 		try {
 			if (configuration != null)
 				dispatchLayer.configure(configuration);
-		} catch (net.sf.taverna.t2.workflowmodel.ConfigurationException e) {
+		} catch (org.apache.taverna.workflowmodel.ConfigurationException e) {
 			throw new DispatchLayerConfigurationException(e);
 		}
 		return dispatchLayer;

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-capability-impl/src/main/resources/META-INF/spring/taverna-capability-context-osgi.xml
----------------------------------------------------------------------
diff --git a/taverna-capability-impl/src/main/resources/META-INF/spring/taverna-capability-context-osgi.xml b/taverna-capability-impl/src/main/resources/META-INF/spring/taverna-capability-context-osgi.xml
index 8aa5619..fac253f 100644
--- a/taverna-capability-impl/src/main/resources/META-INF/spring/taverna-capability-context-osgi.xml
+++ b/taverna-capability-impl/src/main/resources/META-INF/spring/taverna-capability-context-osgi.xml
@@ -6,12 +6,12 @@
                                  http://www.springframework.org/schema/osgi
                                  http://www.springframework.org/schema/osgi/spring-osgi.xsd">
 
-	<service ref="activityService" interface="uk.org.taverna.platform.capability.api.ActivityService" />
+	<service ref="activityService" interface="org.apache.taverna.platform.capability.api.ActivityService" />
 
-	<list id="activityFactories" interface="net.sf.taverna.t2.workflowmodel.processor.activity.ActivityFactory" cardinality="0..N" />
+	<list id="activityFactories" interface="org.apache.taverna.workflowmodel.processor.activity.ActivityFactory" cardinality="0..N" />
 
-	<service ref="dispatchLayerService" interface="uk.org.taverna.platform.capability.api.DispatchLayerService" />
+	<service ref="dispatchLayerService" interface="org.apache.taverna.platform.capability.api.DispatchLayerService" />
 
-	<list id="dispatchLayerFactories" interface="net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchLayerFactory" cardinality="0..N" />
+	<list id="dispatchLayerFactories" interface="org.apache.taverna.workflowmodel.processor.dispatch.DispatchLayerFactory" cardinality="0..N" />
 
 </beans:beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-credential-manager-impl/src/main/java/org/apache/taverna/security/credentialmanager/impl/CredentialManagerImpl.java
----------------------------------------------------------------------
diff --git a/taverna-credential-manager-impl/src/main/java/org/apache/taverna/security/credentialmanager/impl/CredentialManagerImpl.java b/taverna-credential-manager-impl/src/main/java/org/apache/taverna/security/credentialmanager/impl/CredentialManagerImpl.java
index b0ada7c..e9a4052 100644
--- a/taverna-credential-manager-impl/src/main/java/org/apache/taverna/security/credentialmanager/impl/CredentialManagerImpl.java
+++ b/taverna-credential-manager-impl/src/main/java/org/apache/taverna/security/credentialmanager/impl/CredentialManagerImpl.java
@@ -65,9 +65,9 @@ import javax.net.ssl.X509ExtendedKeyManager;
 import javax.net.ssl.X509KeyManager;
 import javax.net.ssl.X509TrustManager;
 import static javax.security.auth.x500.X500Principal.RFC2253;
-import net.sf.taverna.t2.lang.observer.MultiCaster;
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.lang.observer.Observer;
+import org.apache.taverna.lang.observer.MultiCaster;
+import org.apache.taverna.lang.observer.Observable;
+import org.apache.taverna.lang.observer.Observer;
 import org.apache.taverna.security.credentialmanager.CMException;
 import org.apache.taverna.security.credentialmanager.CredentialManager;
 import static org.apache.taverna.security.credentialmanager.CredentialManager.KeystoreType.KEYSTORE;

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-credential-manager-impl/src/main/resources/META-INF/spring/credential-manager-impl-context.xml
----------------------------------------------------------------------
diff --git a/taverna-credential-manager-impl/src/main/resources/META-INF/spring/credential-manager-impl-context.xml b/taverna-credential-manager-impl/src/main/resources/META-INF/spring/credential-manager-impl-context.xml
index 170c3ca..3351526 100644
--- a/taverna-credential-manager-impl/src/main/resources/META-INF/spring/credential-manager-impl-context.xml
+++ b/taverna-credential-manager-impl/src/main/resources/META-INF/spring/credential-manager-impl-context.xml
@@ -5,7 +5,7 @@
                            http://www.springframework.org/schema/beans/spring-beans.xsd">
 
 	<bean id="credentialManager" init-method="installAuthenticator"
-		class="net.sf.taverna.t2.security.credentialmanager.impl.CredentialManagerImpl">
+		class="org.apache.taverna.security.credentialmanager.impl.CredentialManagerImpl">
 		<property name="masterPasswordProviders" ref="masterPasswordProviders" />
 		<property name="javaTruststorePasswordProviders" ref="javaTruststorePasswordProviders" />
 		<property name="serviceUsernameAndPasswordProviders" ref="serviceUsernameAndPasswordProviders" />

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-credential-manager-impl/src/test/java/org/apache/taverna/security/credentialmanager/impl/CredentialManagerImplIT.java
----------------------------------------------------------------------
diff --git a/taverna-credential-manager-impl/src/test/java/org/apache/taverna/security/credentialmanager/impl/CredentialManagerImplIT.java b/taverna-credential-manager-impl/src/test/java/org/apache/taverna/security/credentialmanager/impl/CredentialManagerImplIT.java
index 01b224b..6ef1e91 100644
--- a/taverna-credential-manager-impl/src/test/java/org/apache/taverna/security/credentialmanager/impl/CredentialManagerImplIT.java
+++ b/taverna-credential-manager-impl/src/test/java/org/apache/taverna/security/credentialmanager/impl/CredentialManagerImplIT.java
@@ -41,8 +41,8 @@ import java.util.Random;
 
 import javax.net.ssl.HttpsURLConnection;
 
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.lang.observer.Observer;
+import org.apache.taverna.lang.observer.Observable;
+import org.apache.taverna.lang.observer.Observer;
 import org.apache.taverna.security.credentialmanager.CMException;
 import org.apache.taverna.security.credentialmanager.KeystoreChangedEvent;
 import org.apache.taverna.security.credentialmanager.MasterPasswordProvider;

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-credential-manager-impl/src/test/java/org/apache/taverna/security/credentialmanager/impl/CredentialManagerImplTest.java
----------------------------------------------------------------------
diff --git a/taverna-credential-manager-impl/src/test/java/org/apache/taverna/security/credentialmanager/impl/CredentialManagerImplTest.java b/taverna-credential-manager-impl/src/test/java/org/apache/taverna/security/credentialmanager/impl/CredentialManagerImplTest.java
index b0a3246..4662fd1 100644
--- a/taverna-credential-manager-impl/src/test/java/org/apache/taverna/security/credentialmanager/impl/CredentialManagerImplTest.java
+++ b/taverna-credential-manager-impl/src/test/java/org/apache/taverna/security/credentialmanager/impl/CredentialManagerImplTest.java
@@ -46,8 +46,8 @@ import java.util.Random;
 
 import javax.net.ssl.SSLSocketFactory;
 
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.lang.observer.Observer;
+import org.apache.taverna.lang.observer.Observable;
+import org.apache.taverna.lang.observer.Observer;
 import org.apache.taverna.security.credentialmanager.CMException;
 import org.apache.taverna.security.credentialmanager.CredentialManager;
 import org.apache.taverna.security.credentialmanager.CredentialManager.KeystoreType;
@@ -225,7 +225,7 @@ public class CredentialManagerImplTest {
 	}
 	
 	/**
-	 * Test method for {@link net.sf.taverna.t2.security.credentialmanager.impl.CredentialManagerImpl#CredentialManagerImpl()}.
+	 * Test method for {@link org.apache.taverna.security.credentialmanager.impl.CredentialManagerImpl#CredentialManagerImpl()}.
 	 * @throws CMException 
 	 */
 	@Test
@@ -234,7 +234,7 @@ public class CredentialManagerImplTest {
 	}
 
 	/**
-	 * Test method for {@link net.sf.taverna.t2.security.credentialmanager.impl.CredentialManagerImpl#getUsernameAndPasswordForService(java.net.URI, boolean, java.lang.String)}.
+	 * Test method for {@link org.apache.taverna.security.credentialmanager.impl.CredentialManagerImpl#getUsernameAndPasswordForService(java.net.URI, boolean, java.lang.String)}.
 	 * @throws URISyntaxException 
 	 * @throws CMException 
 	 */
@@ -252,7 +252,7 @@ public class CredentialManagerImplTest {
 	}
 
 	/**
-	 * Test method for {@link net.sf.taverna.t2.security.credentialmanager.impl.CredentialManagerImpl#addUsernameAndPasswordForService(net.sf.taverna.t2.security.credentialmanager.UsernamePassword, java.net.URI)}.
+	 * Test method for {@link org.apache.taverna.security.credentialmanager.impl.CredentialManagerImpl#addUsernameAndPasswordForService(net.sf.taverna.t2.security.credentialmanager.UsernamePassword, java.net.URI)}.
 	 * @throws URISyntaxException 
 	 * @throws CMException 
 	 */
@@ -269,7 +269,7 @@ public class CredentialManagerImplTest {
 	}
 
 	/**
-	 * Test method for {@link net.sf.taverna.t2.security.credentialmanager.impl.CredentialManagerImpl#hasUsernamePasswordForService(java.net.URI)}.
+	 * Test method for {@link org.apache.taverna.security.credentialmanager.impl.CredentialManagerImpl#hasUsernamePasswordForService(java.net.URI)}.
 	 * @throws CMException 
 	 */
 	@Test
@@ -287,7 +287,7 @@ public class CredentialManagerImplTest {
 	}
 	
 	/**
-	 * Test method for {@link net.sf.taverna.t2.security.credentialmanager.impl.CredentialManagerImpl#deleteUsernameAndPasswordForService(java.net.URI)}.
+	 * Test method for {@link org.apache.taverna.security.credentialmanager.impl.CredentialManagerImpl#deleteUsernameAndPasswordForService(java.net.URI)}.
 	 * @throws URISyntaxException 
 	 * @throws CMException 
 	 */
@@ -305,7 +305,7 @@ public class CredentialManagerImplTest {
 	}
 
 	/**
-	 * Test method for {@link net.sf.taverna.t2.security.credentialmanager.impl.CredentialManagerImpl#addKeyPair(java.security.Key, java.security.cert.Certificate[])}.
+	 * Test method for {@link org.apache.taverna.security.credentialmanager.impl.CredentialManagerImpl#addKeyPair(java.security.Key, java.security.cert.Certificate[])}.
 	 * @throws CMException 
 	 * @throws KeyStoreException 
 	 * @throws NoSuchAlgorithmException 
@@ -327,7 +327,7 @@ public class CredentialManagerImplTest {
 	}
 
 	/**
-	 * Test method for {@link net.sf.taverna.t2.security.credentialmanager.impl.CredentialManagerImpl#hasKeyPair(java.security.Key, java.security.cert.Certificate[])}.
+	 * Test method for {@link org.apache.taverna.security.credentialmanager.impl.CredentialManagerImpl#hasKeyPair(java.security.Key, java.security.cert.Certificate[])}.
 	 * @throws CMException 
 	 * @throws KeyStoreException 
 	 * @throws NoSuchAlgorithmException 
@@ -344,7 +344,7 @@ public class CredentialManagerImplTest {
 	}
 
 	/**
-	 * Test method for {@link net.sf.taverna.t2.security.credentialmanager.impl.CredentialManagerImpl#deleteKeyPair(java.lang.String)}.
+	 * Test method for {@link org.apache.taverna.security.credentialmanager.impl.CredentialManagerImpl#deleteKeyPair(java.lang.String)}.
 	 * @throws CMException 
 	 * @throws KeyStoreException 
 	 * @throws NoSuchAlgorithmException 
@@ -365,7 +365,7 @@ public class CredentialManagerImplTest {
 	}
 	
 	/**
-	 * Test method for {@link net.sf.taverna.t2.security.credentialmanager.impl.CredentialManagerImpl#deleteKeyPair(Key, Certificate[])}.
+	 * Test method for {@link org.apache.taverna.security.credentialmanager.impl.CredentialManagerImpl#deleteKeyPair(Key, Certificate[])}.
 	 * @throws CMException 
 	 */
 	@Test
@@ -377,7 +377,7 @@ public class CredentialManagerImplTest {
 	}
 
 	/**
-	 * Test method for {@link net.sf.taverna.t2.security.credentialmanager.impl.CredentialManagerImpl#exportKeyPair(java.lang.String, java.io.File, java.lang.String)}.
+	 * Test method for {@link org.apache.taverna.security.credentialmanager.impl.CredentialManagerImpl#exportKeyPair(java.lang.String, java.io.File, java.lang.String)}.
 	 * @throws CMException 
 	 * @throws KeyStoreException 
 	 * @throws NoSuchAlgorithmException 
@@ -413,7 +413,7 @@ public class CredentialManagerImplTest {
 	}
 
 	/**
-	 * Test method for {@link net.sf.taverna.t2.security.credentialmanager.impl.CredentialManagerImpl#getCertificate(java.lang.String, java.lang.String)}.
+	 * Test method for {@link org.apache.taverna.security.credentialmanager.impl.CredentialManagerImpl#getCertificate(java.lang.String, java.lang.String)}.
 	 * @throws CMException 
 	 */
 	@Test
@@ -434,7 +434,7 @@ public class CredentialManagerImplTest {
 	}
 
 	/**
-	 * Test method for {@link net.sf.taverna.t2.security.credentialmanager.impl.CredentialManagerImpl#getKeyPairsCertificateChain(java.lang.String)}.
+	 * Test method for {@link org.apache.taverna.security.credentialmanager.impl.CredentialManagerImpl#getKeyPairsCertificateChain(java.lang.String)}.
 	 * @throws CMException 
 	 */
 	@Test
@@ -446,7 +446,7 @@ public class CredentialManagerImplTest {
 	}
 	
 	/**
-	 * Test method for {@link net.sf.taverna.t2.security.credentialmanager.impl.CredentialManagerImpl#getKeyPairsPrivateKey(java.lang.String)}.
+	 * Test method for {@link org.apache.taverna.security.credentialmanager.impl.CredentialManagerImpl#getKeyPairsPrivateKey(java.lang.String)}.
 	 * @throws CMException 
 	 */
 	@Test

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-credential-manager-impl/src/test/java/org/apache/taverna/security/credentialmanager/impl/HTTPAuthenticatorIT.java
----------------------------------------------------------------------
diff --git a/taverna-credential-manager-impl/src/test/java/org/apache/taverna/security/credentialmanager/impl/HTTPAuthenticatorIT.java b/taverna-credential-manager-impl/src/test/java/org/apache/taverna/security/credentialmanager/impl/HTTPAuthenticatorIT.java
index 1cf7c33..ac8e695 100644
--- a/taverna-credential-manager-impl/src/test/java/org/apache/taverna/security/credentialmanager/impl/HTTPAuthenticatorIT.java
+++ b/taverna-credential-manager-impl/src/test/java/org/apache/taverna/security/credentialmanager/impl/HTTPAuthenticatorIT.java
@@ -62,7 +62,7 @@ import org.mortbay.jetty.webapp.WebAppContext;
 
 /**
  * 
- * Based on net.sf.tavenra.security.credentialmanager.FixedPasswordProvider from the
+ * Based on org.apache.tavenra.security.credentialmanager.FixedPasswordProvider from the
  * Taverna 2 codebase. 
  * 
  * @author Stian Soiland-Reyes

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-credential-manager/src/main/java/org/apache/taverna/security/credentialmanager/CredentialManager.java
----------------------------------------------------------------------
diff --git a/taverna-credential-manager/src/main/java/org/apache/taverna/security/credentialmanager/CredentialManager.java b/taverna-credential-manager/src/main/java/org/apache/taverna/security/credentialmanager/CredentialManager.java
index 3a6ec78..6099606 100644
--- a/taverna-credential-manager/src/main/java/org/apache/taverna/security/credentialmanager/CredentialManager.java
+++ b/taverna-credential-manager/src/main/java/org/apache/taverna/security/credentialmanager/CredentialManager.java
@@ -31,7 +31,7 @@ import java.util.List;
 
 import javax.net.ssl.SSLSocketFactory;
 
-import net.sf.taverna.t2.lang.observer.Observer;
+import org.apache.taverna.lang.observer.Observer;
 
 /**
  * Provides a wrapper for Taverna's Keystore and Truststore and implements

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-credential-manager/src/main/java/org/apache/taverna/security/credentialmanager/KeystoreChangedEvent.java
----------------------------------------------------------------------
diff --git a/taverna-credential-manager/src/main/java/org/apache/taverna/security/credentialmanager/KeystoreChangedEvent.java b/taverna-credential-manager/src/main/java/org/apache/taverna/security/credentialmanager/KeystoreChangedEvent.java
index 0a55930..6c74f59 100644
--- a/taverna-credential-manager/src/main/java/org/apache/taverna/security/credentialmanager/KeystoreChangedEvent.java
+++ b/taverna-credential-manager/src/main/java/org/apache/taverna/security/credentialmanager/KeystoreChangedEvent.java
@@ -23,7 +23,7 @@ import org.apache.taverna.security.credentialmanager.CredentialManager.KeystoreT
 
 /**
  * An event given to {@link CredentialManagerOld} observers registered using
- * {@link Observable#addObserver(net.sf.taverna.t2.lang.observer.Observer)} to
+ * {@link Observable#addObserver(org.apache.taverna.lang.observer.Observer)} to
  * let them know the Keystore or Truststore have been changed.
  * 
  * @author Alex Nenadic

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-credential-manager/src/main/resources/META-INF/services/net.sf.taverna.t2.security.credentialmanager.CredentialProviderSPI
----------------------------------------------------------------------
diff --git a/taverna-credential-manager/src/main/resources/META-INF/services/net.sf.taverna.t2.security.credentialmanager.CredentialProviderSPI b/taverna-credential-manager/src/main/resources/META-INF/services/net.sf.taverna.t2.security.credentialmanager.CredentialProviderSPI
deleted file mode 100644
index a6b03b4..0000000
--- a/taverna-credential-manager/src/main/resources/META-INF/services/net.sf.taverna.t2.security.credentialmanager.CredentialProviderSPI
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.taverna.security.credentialmanager.DefaultMasterPasswordProvider
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-credential-manager/src/main/resources/META-INF/services/org.apache.taverna.security.credentialmanager.CredentialProviderSPI
----------------------------------------------------------------------
diff --git a/taverna-credential-manager/src/main/resources/META-INF/services/org.apache.taverna.security.credentialmanager.CredentialProviderSPI b/taverna-credential-manager/src/main/resources/META-INF/services/org.apache.taverna.security.credentialmanager.CredentialProviderSPI
new file mode 100644
index 0000000..a6b03b4
--- /dev/null
+++ b/taverna-credential-manager/src/main/resources/META-INF/services/org.apache.taverna.security.credentialmanager.CredentialProviderSPI
@@ -0,0 +1 @@
+org.apache.taverna.security.credentialmanager.DefaultMasterPasswordProvider
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-database-configuration-api/src/main/java/org/apache/taverna/configuration/database/DatabaseConfiguration.java
----------------------------------------------------------------------
diff --git a/taverna-database-configuration-api/src/main/java/org/apache/taverna/configuration/database/DatabaseConfiguration.java b/taverna-database-configuration-api/src/main/java/org/apache/taverna/configuration/database/DatabaseConfiguration.java
new file mode 100644
index 0000000..48e70e0
--- /dev/null
+++ b/taverna-database-configuration-api/src/main/java/org/apache/taverna/configuration/database/DatabaseConfiguration.java
@@ -0,0 +1,123 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.configuration.database;
+
+import java.util.Map;
+
+import uk.org.taverna.configuration.Configurable;
+
+/**
+ *
+ *
+ * @author David Withers
+ */
+public interface DatabaseConfiguration extends Configurable {
+
+	public static final String IN_MEMORY = "in_memory";
+	public static final String ENABLE_PROVENANCE = "provenance";
+	public static final String CONNECTOR_TYPE = "connector";
+	public static final String PORT = "port";
+	public static final String CURRENT_PORT = "current_port";
+	public static final String REFERENCE_SERVICE_CONTEXT = "referenceService.context";
+	public static final String IN_MEMORY_CONTEXT = "inMemoryReferenceServiceContext.xml";
+	public static final String HIBERNATE_CONTEXT = "hibernateReferenceServiceContext.xml";
+	public static final String HIBERNATE_DIALECT = "dialect";
+	public static final String START_INTERNAL_DERBY = "start_derby";
+	public static final String POOL_MAX_ACTIVE = "pool_max_active";
+	public static final String POOL_MIN_IDLE = "pool_min_idle";
+	public static final String POOL_MAX_IDLE = "pool_max_idle";
+	public static final String DRIVER_CLASS_NAME = "driver";
+	public static final String JDBC_URI = "jdbcuri";
+	public static final String USERNAME = "username";
+	public static final String PASSWORD = "password";
+	public static final String EXPOSE_DATANATURE = "taverna.exposedatanature";
+	// FIXME: these should me just mysql & derby - but build & dependency issues
+	// is causing the provenance to expect these values:
+	public static final String CONNECTOR_MYSQL = "mysql";
+	public static final String CONNECTOR_DERBY = "derby";
+	public static final String JNDI_NAME = "jdbc/taverna";
+
+	public boolean isAutoSave();
+
+	public void enableAutoSave();
+
+	public void disableAutoSave();
+
+	public boolean isInMemory();
+
+	public void setInMemory(boolean value);
+
+	public boolean isExposeDatanature();
+
+	public void setExposeDatanature(boolean exposeDatanature);
+
+	public String getDatabaseContext();
+
+	public void setPort(int port);
+
+	public void setPort(String port);
+
+	public void setDriverClassName(String driverClassName);
+
+	public String getDriverClassName();
+
+	public boolean isProvenanceEnabled();
+
+	public void setProvenanceEnabled(boolean value);
+
+	public void setStartInternalDerbyServer(boolean value);
+
+	public boolean getStartInternalDerbyServer();
+
+	public int getPort();
+
+	public void setCurrentPort(int port);
+
+	public int getCurrentPort();
+
+	public int getPoolMaxActive();
+
+	public int getPoolMinIdle();
+
+	public int getPoolMaxIdle();
+
+	public String getCategory();
+
+	public Map<String, String> getDefaultPropertyMap();
+
+	public String getHibernateDialect();
+
+	public String getDisplayName();
+
+	public String getFilePrefix();
+
+	public String getUUID();
+
+	public String getConnectorType();
+
+	public String getJDBCUri();
+
+	public void setJDBCUri(String uri);
+
+	public String getUsername();
+
+	public String getPassword();
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-database-configuration-api/src/main/java/org/apache/taverna/configuration/database/DatabaseManager.java
----------------------------------------------------------------------
diff --git a/taverna-database-configuration-api/src/main/java/org/apache/taverna/configuration/database/DatabaseManager.java b/taverna-database-configuration-api/src/main/java/org/apache/taverna/configuration/database/DatabaseManager.java
new file mode 100644
index 0000000..e1bdf89
--- /dev/null
+++ b/taverna-database-configuration-api/src/main/java/org/apache/taverna/configuration/database/DatabaseManager.java
@@ -0,0 +1,44 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.configuration.database;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import javax.sql.DataSource;
+
+/**
+ *
+ *
+ * @author David Withers
+ */
+public interface DatabaseManager {
+
+	public Connection getConnection() throws SQLException;
+
+	public DataSource getDataSource();
+
+	public void startDerbyNetworkServer();
+
+	public void stopDerbyNetworkServer();
+
+	public boolean isRunning();
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-database-configuration-api/src/main/java/uk/org/taverna/configuration/database/DatabaseConfiguration.java
----------------------------------------------------------------------
diff --git a/taverna-database-configuration-api/src/main/java/uk/org/taverna/configuration/database/DatabaseConfiguration.java b/taverna-database-configuration-api/src/main/java/uk/org/taverna/configuration/database/DatabaseConfiguration.java
deleted file mode 100644
index ba3ebd2..0000000
--- a/taverna-database-configuration-api/src/main/java/uk/org/taverna/configuration/database/DatabaseConfiguration.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2012 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.configuration.database;
-
-import java.util.Map;
-
-import uk.org.taverna.configuration.Configurable;
-
-/**
- *
- *
- * @author David Withers
- */
-public interface DatabaseConfiguration extends Configurable {
-
-	public static final String IN_MEMORY = "in_memory";
-	public static final String ENABLE_PROVENANCE = "provenance";
-	public static final String CONNECTOR_TYPE = "connector";
-	public static final String PORT = "port";
-	public static final String CURRENT_PORT = "current_port";
-	public static final String REFERENCE_SERVICE_CONTEXT = "referenceService.context";
-	public static final String IN_MEMORY_CONTEXT = "inMemoryReferenceServiceContext.xml";
-	public static final String HIBERNATE_CONTEXT = "hibernateReferenceServiceContext.xml";
-	public static final String HIBERNATE_DIALECT = "dialect";
-	public static final String START_INTERNAL_DERBY = "start_derby";
-	public static final String POOL_MAX_ACTIVE = "pool_max_active";
-	public static final String POOL_MIN_IDLE = "pool_min_idle";
-	public static final String POOL_MAX_IDLE = "pool_max_idle";
-	public static final String DRIVER_CLASS_NAME = "driver";
-	public static final String JDBC_URI = "jdbcuri";
-	public static final String USERNAME = "username";
-	public static final String PASSWORD = "password";
-	public static final String EXPOSE_DATANATURE = "taverna.exposedatanature";
-	// FIXME: these should me just mysql & derby - but build & dependency issues
-	// is causing the provenance to expect these values:
-	public static final String CONNECTOR_MYSQL = "mysql";
-	public static final String CONNECTOR_DERBY = "derby";
-	public static final String JNDI_NAME = "jdbc/taverna";
-
-	public boolean isAutoSave();
-
-	public void enableAutoSave();
-
-	public void disableAutoSave();
-
-	public boolean isInMemory();
-
-	public void setInMemory(boolean value);
-
-	public boolean isExposeDatanature();
-
-	public void setExposeDatanature(boolean exposeDatanature);
-
-	public String getDatabaseContext();
-
-	public void setPort(int port);
-
-	public void setPort(String port);
-
-	public void setDriverClassName(String driverClassName);
-
-	public String getDriverClassName();
-
-	public boolean isProvenanceEnabled();
-
-	public void setProvenanceEnabled(boolean value);
-
-	public void setStartInternalDerbyServer(boolean value);
-
-	public boolean getStartInternalDerbyServer();
-
-	public int getPort();
-
-	public void setCurrentPort(int port);
-
-	public int getCurrentPort();
-
-	public int getPoolMaxActive();
-
-	public int getPoolMinIdle();
-
-	public int getPoolMaxIdle();
-
-	public String getCategory();
-
-	public Map<String, String> getDefaultPropertyMap();
-
-	public String getHibernateDialect();
-
-	public String getDisplayName();
-
-	public String getFilePrefix();
-
-	public String getUUID();
-
-	public String getConnectorType();
-
-	public String getJDBCUri();
-
-	public void setJDBCUri(String uri);
-
-	public String getUsername();
-
-	public String getPassword();
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-database-configuration-api/src/main/java/uk/org/taverna/configuration/database/DatabaseManager.java
----------------------------------------------------------------------
diff --git a/taverna-database-configuration-api/src/main/java/uk/org/taverna/configuration/database/DatabaseManager.java b/taverna-database-configuration-api/src/main/java/uk/org/taverna/configuration/database/DatabaseManager.java
deleted file mode 100644
index c7e6641..0000000
--- a/taverna-database-configuration-api/src/main/java/uk/org/taverna/configuration/database/DatabaseManager.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2012 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.configuration.database;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-
-import javax.sql.DataSource;
-
-/**
- *
- *
- * @author David Withers
- */
-public interface DatabaseManager {
-
-	public Connection getConnection() throws SQLException;
-
-	public DataSource getDataSource();
-
-	public void startDerbyNetworkServer();
-
-	public void stopDerbyNetworkServer();
-
-	public boolean isRunning();
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-database-configuration-impl/src/main/java/org/apache/taverna/configuration/database/impl/DatabaseConfigurationImpl.java
----------------------------------------------------------------------
diff --git a/taverna-database-configuration-impl/src/main/java/org/apache/taverna/configuration/database/impl/DatabaseConfigurationImpl.java b/taverna-database-configuration-impl/src/main/java/org/apache/taverna/configuration/database/impl/DatabaseConfigurationImpl.java
new file mode 100644
index 0000000..e401e75
--- /dev/null
+++ b/taverna-database-configuration-impl/src/main/java/org/apache/taverna/configuration/database/impl/DatabaseConfigurationImpl.java
@@ -0,0 +1,251 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.configuration.database.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.taverna.configuration.database.DatabaseConfiguration;
+import uk.org.taverna.configuration.AbstractConfigurable;
+import uk.org.taverna.configuration.ConfigurationManager;
+
+/**
+ * Configuration for the reference service and provenance.
+ *
+ * @author David Withers
+ * @author Stuart Owen
+ */
+
+public class DatabaseConfigurationImpl extends AbstractConfigurable implements DatabaseConfiguration {
+
+	private Map<String, String> defaultPropertyMap;
+
+	private boolean autoSave = true;
+
+	public DatabaseConfigurationImpl(ConfigurationManager configurationManager) {
+		super(configurationManager);
+	}
+
+	@Override
+	public boolean isAutoSave() {
+		return autoSave;
+	}
+
+	@Override
+	public void enableAutoSave() {
+		autoSave = true;
+	}
+
+	@Override
+	public void disableAutoSave() {
+		autoSave = false;
+	}
+
+	@Override
+	protected void store() {
+		if (autoSave) {
+			super.store();
+		}
+	}
+
+	@Override
+	public boolean isInMemory() {
+		return getProperty(IN_MEMORY).equalsIgnoreCase("true");
+	}
+
+	@Override
+	public void setInMemory(boolean value) {
+		setProperty(IN_MEMORY, String.valueOf(value));
+	}
+
+	@Override
+	public boolean isExposeDatanature() {
+		return getProperty(EXPOSE_DATANATURE).equalsIgnoreCase("true");
+	}
+
+	@Override
+	public void setExposeDatanature(boolean exposeDatanature) {
+		setProperty(EXPOSE_DATANATURE, String.valueOf(exposeDatanature));
+	}
+
+	@Override
+	public String getDatabaseContext() {
+		if (getProperty(IN_MEMORY).equalsIgnoreCase("true")) {
+			return IN_MEMORY_CONTEXT;
+		} else {
+			return HIBERNATE_CONTEXT;
+		}
+	}
+
+	@Override
+	public void setPort(int port) {
+		setPort(String.valueOf(port));
+	}
+
+	@Override
+	public void setPort(String port) {
+		setProperty(PORT, port);
+	}
+
+	@Override
+	public void setDriverClassName(String driverClassName) {
+		setProperty(DRIVER_CLASS_NAME, driverClassName);
+	}
+
+	@Override
+	public String getDriverClassName() {
+		return getProperty(DRIVER_CLASS_NAME);
+	}
+
+	@Override
+	public boolean isProvenanceEnabled() {
+		return getProperty(ENABLE_PROVENANCE).equalsIgnoreCase("true");
+	}
+
+	@Override
+	public void setProvenanceEnabled(boolean value) {
+		setProperty(ENABLE_PROVENANCE, String.valueOf(value));
+	}
+
+	@Override
+	public void setStartInternalDerbyServer(boolean value) {
+		setProperty(START_INTERNAL_DERBY, String.valueOf(value));
+	}
+
+	@Override
+	public boolean getStartInternalDerbyServer() {
+		return getProperty(START_INTERNAL_DERBY).equalsIgnoreCase("true");
+	}
+
+	@Override
+	public int getPort() {
+		return Integer.valueOf(getProperty(PORT));
+	}
+
+	@Override
+	public void setCurrentPort(int port) {
+		setProperty(CURRENT_PORT, String.valueOf(port));
+	}
+
+	@Override
+	public int getCurrentPort() {
+		return Integer.valueOf(getProperty(CURRENT_PORT));
+	}
+
+	@Override
+	public int getPoolMaxActive() {
+		return Integer.valueOf(getProperty(POOL_MAX_ACTIVE));
+	}
+
+	@Override
+	public int getPoolMinIdle() {
+		return Integer.valueOf(getProperty(POOL_MIN_IDLE));
+	}
+
+	@Override
+	public int getPoolMaxIdle() {
+		return Integer.valueOf(getProperty(POOL_MAX_IDLE));
+	}
+
+	@Override
+	public String getCategory() {
+		return "general";
+	}
+
+	@Override
+	public Map<String, String> getDefaultPropertyMap() {
+
+		if (defaultPropertyMap == null) {
+			defaultPropertyMap = new HashMap<String, String>();
+			defaultPropertyMap.put(IN_MEMORY, "true");
+			defaultPropertyMap.put(ENABLE_PROVENANCE, "true");
+			defaultPropertyMap.put(PORT, "1527");
+			// defaultPropertyMap.put(DRIVER_CLASS_NAME,
+			// "org.apache.derby.jdbc.ClientDriver");
+			defaultPropertyMap.put(DRIVER_CLASS_NAME,
+					"org.apache.derby.jdbc.EmbeddedDriver");
+			defaultPropertyMap.put(HIBERNATE_DIALECT,
+					"org.hibernate.dialect.DerbyDialect");
+			defaultPropertyMap.put(POOL_MAX_ACTIVE, "50");
+			defaultPropertyMap.put(POOL_MAX_IDLE, "50");
+			defaultPropertyMap.put(POOL_MIN_IDLE, "10");
+			defaultPropertyMap.put(USERNAME, "");
+			defaultPropertyMap.put(PASSWORD, "");
+			defaultPropertyMap.put(JDBC_URI,
+					"jdbc:derby:t2-database;create=true;upgrade=true");
+			defaultPropertyMap.put(START_INTERNAL_DERBY, "false");
+
+			defaultPropertyMap.put(CONNECTOR_TYPE, CONNECTOR_DERBY);
+			defaultPropertyMap.put(EXPOSE_DATANATURE, "false");
+		}
+		return defaultPropertyMap;
+	}
+
+	@Override
+	public String getHibernateDialect() {
+		return getProperty(HIBERNATE_DIALECT);
+	}
+
+	@Override
+	public String getDisplayName() {
+		return "Data and provenance";
+	}
+
+	@Override
+	public String getFilePrefix() {
+		return "DataAndProvenance";
+	}
+
+	@Override
+	public String getUUID() {
+		return "6BD3F5C1-C68D-4893-8D9B-2F46FA1DDB19";
+	}
+
+	@Override
+	public String getConnectorType() {
+		return getProperty(CONNECTOR_TYPE);
+	}
+
+	@Override
+	public String getJDBCUri() {
+		if (CONNECTOR_DERBY.equals(getConnectorType())
+				&& getStartInternalDerbyServer()) {
+			return "jdbc:derby://localhost:" + getCurrentPort()
+					+ "/t2-database;create=true;upgrade=true";
+		} else {
+			return getProperty(JDBC_URI);
+		}
+	}
+
+	@Override
+	public void setJDBCUri(String uri) {
+		setProperty(JDBC_URI, uri);
+	}
+
+	@Override
+	public String getUsername() {
+		return getProperty(USERNAME);
+	}
+
+	@Override
+	public String getPassword() {
+		return getProperty(PASSWORD);
+	}
+}


[21/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ProcessorInputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ProcessorInputPort.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ProcessorInputPort.java
deleted file mode 100644
index ebd8d86..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ProcessorInputPort.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-/**
- * Input port on a Processor, is both a filtering input port and a processor
- * port
- * 
- * @author Tom Oinn
- */
-public interface ProcessorInputPort extends FilteringInputPort, ProcessorPort {
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ProcessorOutputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ProcessorOutputPort.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ProcessorOutputPort.java
deleted file mode 100644
index fda5d01..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ProcessorOutputPort.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-/**
- * Input port on a Processor, is both an event forwarding output port and a
- * processor port
- * 
- * @author Tom Oinn
- */
-public interface ProcessorOutputPort extends EventForwardingOutputPort,
-		ProcessorPort {
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ProcessorPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ProcessorPort.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ProcessorPort.java
deleted file mode 100644
index 2491159..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/ProcessorPort.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-/**
- * An {@link ProcessorInputPort} or {@link ProcessorOutputPort} belonging to a
- * {@link Processor}.
- */
-public interface ProcessorPort extends Port {
-	/**
-	 * Get the Processor to which this port belongs
-	 */
-	public Processor getProcessor();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/RunDeletionListener.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/RunDeletionListener.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/RunDeletionListener.java
deleted file mode 100644
index f595d50..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/RunDeletionListener.java
+++ /dev/null
@@ -1,15 +0,0 @@
-/**
- * 
- */
-package net.sf.taverna.t2.workflowmodel;
-
-/**
- * A RunDeletionListener is notified when a run is deleted. It is then able to
- * take any specific action needed to deal with the deletion of the run, for
- * example deleting data that is not held within Taverna.
- * 
- * @author alanrw
- */
-public interface RunDeletionListener {
-	void deleteRun(String runToDelete);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/TokenProcessingEntity.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/TokenProcessingEntity.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/TokenProcessingEntity.java
deleted file mode 100644
index 777ca63..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/TokenProcessingEntity.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-import static net.sf.taverna.t2.annotation.HierarchyRole.CHILD;
-
-import java.util.List;
-
-import net.sf.taverna.t2.annotation.HierarchyTraversal;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.IterationTypeMismatchException;
-
-/**
- * Superinterface for all classes within the workflow model which consume and
- * emit workflow data tokens.
- * 
- * @author Tom Oinn
- */
-public interface TokenProcessingEntity extends NamedWorkflowEntity {
-	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
-	List<? extends EventHandlingInputPort> getInputPorts();
-
-	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
-	List<? extends EventForwardingOutputPort> getOutputPorts();
-
-	/**
-	 * Run a collection level based type check on the token processing entity
-	 * 
-	 * @return true if the typecheck was successful or false if the check failed
-	 *         because there were preconditions missing such as unsatisfied
-	 *         input types
-	 * @throws IterationTypeMismatchException
-	 *             if the typing occurred but didn't match because of an
-	 *             iteration mismatch
-	 * @throws InvalidDataflowException
-	 *             if the entity depended on a dataflow that was not valid
-	 */
-	boolean doTypeCheck() throws IterationTypeMismatchException,
-			InvalidDataflowException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/WorkflowItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/WorkflowItem.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/WorkflowItem.java
deleted file mode 100644
index c50e50f..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/WorkflowItem.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package net.sf.taverna.t2.workflowmodel;
-
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchStack;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.IterationStrategy;
-
-/**
- * An item that forms a structural part of a Workflow.
- * 
- * Workflow item are {@link Dataflow}, its {@link Processor} and {@link Port}
- * s, and other deeper structural parts like {@link DispatchStack} and
- * {@link IterationStrategy}.
- * 
- * @author Stian Soiland-Reyes
- */
-public interface WorkflowItem {
-	// FIXME: Should this be deleted?
-    // TODO: Implement this for every WorkflowItem
-    
-//    /**
-//     * Mark this item (and its child WorkflowItems) as immutable.
-//     * 
-//     * Subsequent edits to its structural components will
-//     * throw a RuntimeException like UnsupportedOperationException.
-//     * 
-//     */
-//    public void setImmutable();
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/WorkflowStructureException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/WorkflowStructureException.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/WorkflowStructureException.java
deleted file mode 100644
index 2cbbfbc..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/WorkflowStructureException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel;
-
-/**
- * Thrown predominantly at runtime under circumstances that suggest an
- * inconsistancy in the workflow model. This might include attempting to feed
- * data into a port that doesn't exist or has an unknown name or similar errors.
- * 
- * @author Tom OInn
- */
-public class WorkflowStructureException extends RuntimeException {
-	private static final long serialVersionUID = 1L;
-
-	public WorkflowStructureException(String string) {
-		super(string);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/DisabledActivityHealthChecker.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/DisabledActivityHealthChecker.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/DisabledActivityHealthChecker.java
deleted file mode 100644
index 2946a9d..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/DisabledActivityHealthChecker.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * 
- */
-package net.sf.taverna.t2.workflowmodel.health;
-
-import static net.sf.taverna.t2.visit.VisitReport.Status.SEVERE;
-import static net.sf.taverna.t2.workflowmodel.health.HealthCheck.DISABLED;
-
-import java.util.List;
-
-import net.sf.taverna.t2.visit.VisitReport;
-import net.sf.taverna.t2.workflowmodel.processor.activity.DisabledActivity;
-
-/**
- * Check on the health of a DisabledActivity
- * 
- * @author alanrw
- * 
- */
-public class DisabledActivityHealthChecker implements
-		HealthChecker<DisabledActivity> {
-
-	/**
-	 * The visitor can visit DisabledActivitys.
-	 */
-	@Override
-	public boolean canVisit(Object o) {
-		return ((o != null) && (o instanceof DisabledActivity));
-	}
-
-	/**
-	 * The check is not time consuming as it simply constructs a VisitReport
-	 */
-	@Override
-	public boolean isTimeConsuming() {
-		return false;
-	}
-
-	/**
-	 * The result of the visit is simply a VisitReport to state that the service
-	 * is not available.
-	 */
-	@Override
-	public VisitReport visit(DisabledActivity o, List<Object> ancestry) {
-		return new VisitReport(HealthCheck.getInstance(), o,
-				"Service is not available", DISABLED, SEVERE);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/HealthCheck.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/HealthCheck.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/HealthCheck.java
deleted file mode 100644
index 75b10d1..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/HealthCheck.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * 
- */
-package net.sf.taverna.t2.workflowmodel.health;
-
-import net.sf.taverna.t2.visit.VisitKind;
-import net.sf.taverna.t2.visit.Visitor;
-
-/**
- * A HealthCheck is a kind of visit that determines if the corresponding object
- * in a workflow (normally an Activity) will work during a workflow run.
- * 
- * @author alanrw
- * 
- */
-public class HealthCheck extends VisitKind {
-	/*
-	 * The following values indicate the type of results that can be associated
-	 * with a VisitReport generated by a health-checking visitor.
-	 */
-
-	public static final int NO_PROBLEM = 0;
-	public static final int NOT_IMPLEMENTED = 1;
-	public static final int CONNECTION_PROBLEM = 2;
-	public static final int INVALID_URL = 3;
-	public static final int TIME_OUT = 4;
-	public static final int IO_PROBLEM = 5;
-	public static final int MISSING_CLASS = 6;
-	public static final int MISSING_DEPENDENCY = 7;
-	public static final int INVALID_SCRIPT = 8;
-	public static final int NO_CONFIGURATION = 9;
-	public static final int NULL_VALUE = 10;
-	public static final int DEFAULT_VALUE = 11;
-	public static final int BAD_WSDL = 12;
-	public static final int NOT_HTTP = 13;
-	public static final int UNSUPPORTED_STYLE = 14;
-	public static final int UNKNOWN_OPERATION = 15;
-	public static final int NO_ENDPOINTS = 16;
-	public static final int INVALID_CONFIGURATION = 17;
-	public static final int NULL_DATATYPE = 18;
-	public static final int DISABLED = 19;
-	public static final int DATATYPE_SOURCE = 20;
-	public static final int UNRECOGNIZED = 21;
-    public static final int LOOP_CONNECTION = 22;
-    public static final int UNMANAGED_LOCATION = 23;
-    public static final int INCOMPATIBLE_MIMETYPES = 24;
-    public static final int HIGH_PORT_DEPTH = 25;
-
-    @SuppressWarnings("rawtypes")
-	private static final Class healthCheckerClass = HealthChecker.class;
-
-    /**
-	 * Sub-classes of HealthChecker are used to perform HealthCheck visits.
-	 */
-	@Override
-	@SuppressWarnings("unchecked")
-	public Class<? extends Visitor<?>> getVisitorClass() {
-		return healthCheckerClass;
-	}
-
-	private static class Singleton {
-		private static HealthCheck instance = new HealthCheck();
-	}
-
-	public static HealthCheck getInstance() {
-		return Singleton.instance;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/HealthChecker.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/HealthChecker.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/HealthChecker.java
deleted file mode 100644
index 589766a..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/HealthChecker.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.health;
-
-import net.sf.taverna.t2.visit.Visitor;
-
-/**
- * An SPI interface whose implementation performs a health check on an arbitrary
- * instance.
- * 
- * @author Stuart Owen
- * @author David Withers
- * 
- * @param <Type>
- *            the type of the item being checked
- */
-public interface HealthChecker<T> extends Visitor<T> {
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/RemoteHealthChecker.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/RemoteHealthChecker.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/RemoteHealthChecker.java
deleted file mode 100644
index 725dd96..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/RemoteHealthChecker.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/**
- * 
- */
-package net.sf.taverna.t2.workflowmodel.health;
-
-import static java.lang.System.currentTimeMillis;
-import static java.net.HttpURLConnection.HTTP_GONE;
-import static java.net.HttpURLConnection.HTTP_INTERNAL_ERROR;
-import static java.net.HttpURLConnection.HTTP_NOT_FOUND;
-import static java.net.HttpURLConnection.HTTP_OK;
-import static net.sf.taverna.t2.visit.VisitReport.Status.SEVERE;
-import static net.sf.taverna.t2.visit.VisitReport.Status.WARNING;
-import static net.sf.taverna.t2.workflowmodel.health.HealthCheck.CONNECTION_PROBLEM;
-import static net.sf.taverna.t2.workflowmodel.health.HealthCheck.INVALID_URL;
-import static net.sf.taverna.t2.workflowmodel.health.HealthCheck.IO_PROBLEM;
-import static net.sf.taverna.t2.workflowmodel.health.HealthCheck.NOT_HTTP;
-import static net.sf.taverna.t2.workflowmodel.health.HealthCheck.NO_PROBLEM;
-import static net.sf.taverna.t2.workflowmodel.health.HealthCheck.TIME_OUT;
-
-import java.io.IOException;
-import java.lang.ref.WeakReference;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.SocketTimeoutException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.net.ssl.SSLException;
-
-import net.sf.taverna.t2.visit.VisitReport;
-import net.sf.taverna.t2.visit.VisitReport.Status;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-
-import org.apache.log4j.Logger;
-
-/**
- * A RemoteHealthChecker performs a visit to an Activity by trying to contact a
- * specific endpoint
- * 
- * @author alanrw
- */
-public abstract class RemoteHealthChecker implements HealthChecker<Object> {
-	public static final long ENDPOINT_EXPIRY_MILLIS = 30 * 1000; // 30 seconds
-	private static final Logger logger = Logger.getLogger(RemoteHealthChecker.class);
-	private static int timeout = 10000; // TODO Manage via bean?
-	private static long endpointExpiryMillis = ENDPOINT_EXPIRY_MILLIS;
-
-	public static int getTimeoutInSeconds() {
-		return timeout / 1000;
-	}
-
-	public static void setTimeoutInSeconds(int timeout) {
-		RemoteHealthChecker.timeout = timeout * 1000;
-	}
-
-	public static long getEndpointExpiryInMilliseconds() {
-		return endpointExpiryMillis;
-	}
-
-	public static void setEndpointExpiryInMilliseconds(int endpointExpiry) {
-		endpointExpiryMillis = endpointExpiry;
-	}
-
-	/**
-	 * Clear the cached endpoint statuses. Normally {@link RemoteHealthChecker}
-	 * will only check an endpoint again if it has been more than
-	 * {@link #getEndpointExpiryInMilliseconds()} milliseconds since last check,
-	 * by default 30 seconds.
-	 */
-	public static void clearCachedEndpointStatus() {
-		visitReportsByEndpoint.clear();
-	}
-
-	private static Map<String, WeakReference<VisitReport>> visitReportsByEndpoint = new ConcurrentHashMap<>();
-
-	/**
-	 * Try to contact the specified endpoint as part of the health-checking of
-	 * the Activity.
-	 * 
-	 * @param activity
-	 *            The activity that is being checked
-	 * @param endpoint
-	 *            The String corresponding to the URL of the endpoint
-	 * 
-	 * @return
-	 */
-	public static VisitReport contactEndpoint(Activity<?> activity,
-			String endpoint) {
-		WeakReference<VisitReport> cachedReportRef = visitReportsByEndpoint
-				.get(endpoint);
-		VisitReport cachedReport = null;
-		if (cachedReportRef != null)
-			cachedReport = cachedReportRef.get();
-		if (cachedReport != null) {
-			long now = currentTimeMillis();
-			long age = now - cachedReport.getCheckTime();
-			if (age < getEndpointExpiryInMilliseconds()) {
-				VisitReport newReport;
-				try {
-					// Make a copy
-					newReport = cachedReport.clone();
-					// But changed the subject
-					newReport.setSubject(activity);
-					logger.info("Returning cached report for endpoint "
-							+ endpoint + ": " + newReport);
-					return newReport;
-				} catch (CloneNotSupportedException e) {
-					logger.warn("Could not clone VisitReport " + cachedReport,
-							e);
-				}
-			}
-		}
-		
-		Status status = Status.OK;
-		String message = "Responded OK";
-		int resultId = NO_PROBLEM;
-		URLConnection connection = null;
-		int responseCode = HTTP_OK;
-		Exception ex = null;
-		try {
-			URL url = new URL(endpoint);
-			connection = url.openConnection();
-			connection.setReadTimeout(timeout);
-			connection.setConnectTimeout(timeout);
-			if (connection instanceof HttpURLConnection) {
-				HttpURLConnection httpConnection = (HttpURLConnection) connection;
-				httpConnection.setRequestMethod("HEAD");
-				httpConnection.connect();
-				responseCode = httpConnection.getResponseCode();
-				if (responseCode != HTTP_OK) {
-					try {
-						if ((connection != null)
-								&& (connection.getInputStream() != null))
-							connection.getInputStream().close();
-					} catch (IOException e) {
-						logger.info(
-								"Unable to close connection to " + endpoint, e);
-					}
-					connection = url.openConnection();
-					connection.setReadTimeout(timeout);
-					connection.setConnectTimeout(timeout);
-					httpConnection = (HttpURLConnection) connection;
-					httpConnection.setRequestMethod("GET");
-					httpConnection.connect();
-					responseCode = httpConnection.getResponseCode();
-				}
-				if (responseCode != HTTP_OK) {
-					if ((responseCode > HTTP_INTERNAL_ERROR)) {
-						status = WARNING;
-						message = "Unexpected response";
-						resultId = CONNECTION_PROBLEM;
-					} else if ((responseCode == HTTP_NOT_FOUND)
-							|| (responseCode == HTTP_GONE)) {
-						status = WARNING;
-						message = "Bad response";
-						resultId = CONNECTION_PROBLEM;
-					}
-				}
-			} else {
-			    connection.connect();
-				status = WARNING;
-				message = "Not HTTP";
-				resultId = NOT_HTTP;
-			}
-		} catch (MalformedURLException e) {
-			status = SEVERE;
-			message = "Invalid URL";
-			resultId = INVALID_URL;
-			ex = e;
-		} catch (SocketTimeoutException e) {
-			status = SEVERE;
-			message = "Timed out";
-			resultId = TIME_OUT;
-			ex = e;
-		} catch (SSLException e){
-			// Some kind of error when trying to establish an HTTPS connection to the endpoint
-			status = SEVERE;
-			message = "HTTPS connection problem";
-			resultId = IO_PROBLEM; // SSLException is an IOException
-			ex = e;
-		} catch (IOException e) {
-			status = SEVERE;
-			message = "Read problem";
-			resultId = IO_PROBLEM;
-			ex = e;
-		} finally {
-			try {
-				if ((connection != null)
-						&& (connection.getInputStream() != null))
-					connection.getInputStream().close();
-			} catch (IOException e) {
-				logger.info("Unable to close connection to " + endpoint, e);
-			}
-		}
-		
-		VisitReport vr = new VisitReport(HealthCheck.getInstance(), activity, message,
-				resultId, status);
-		vr.setProperty("endpoint", endpoint);
-		if (ex != null)
-		    vr.setProperty("exception", ex);
-		if (responseCode != HTTP_OK)
-			vr.setProperty("responseCode", Integer.toString(responseCode));
-		if (resultId == TIME_OUT)
-			vr.setProperty("timeOut", Integer.toString(timeout));
-		visitReportsByEndpoint.put(endpoint, new WeakReference<>(vr));
-		return vr;
-	}
-
-	/**
-	 * A remote health-check is time consuming as it tries to contact an
-	 * external resource.
-	 */
-	@Override
-	public boolean isTimeConsuming() {
-		return true;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/UnrecognizedActivityHealthChecker.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/UnrecognizedActivityHealthChecker.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/UnrecognizedActivityHealthChecker.java
deleted file mode 100644
index 478603d..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/UnrecognizedActivityHealthChecker.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * 
- */
-package net.sf.taverna.t2.workflowmodel.health;
-
-import static net.sf.taverna.t2.visit.VisitReport.Status.SEVERE;
-import static net.sf.taverna.t2.workflowmodel.health.HealthCheck.UNRECOGNIZED;
-
-import java.util.List;
-
-import net.sf.taverna.t2.visit.VisitReport;
-import net.sf.taverna.t2.workflowmodel.processor.activity.UnrecognizedActivity;
-
-/**
- * Check on the health of a UnrecognizedActivity
- * 
- * @author alanrw
- * 
- */
-public class UnrecognizedActivityHealthChecker implements
-		HealthChecker<UnrecognizedActivity> {
-
-	/**
-	 * The visitor can visit {@link UnrecognizedActivity}s.
-	 */
-	@Override
-	public boolean canVisit(Object o) {
-		return ((o != null) && (o instanceof UnrecognizedActivity));
-	}
-
-	/**
-	 * The check is not time consuming as it simply constructs a VisitReport
-	 */
-	@Override
-	public boolean isTimeConsuming() {
-		return false;
-	}
-
-	/**
-	 * The result of the visit is simply a VisitReport to state that the service
-	 * is not available.
-	 */
-	@Override
-	public VisitReport visit(UnrecognizedActivity o, List<Object> ancestry) {
-		return new VisitReport(HealthCheck.getInstance(), o,
-				"Service is unrecognized", UNRECOGNIZED, SEVERE);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/package.html b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/package.html
deleted file mode 100644
index 6cbc3b5..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/health/package.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<body>
-
-A package that contains a set of classes to be used in testing a Dataflow prior to invocation.<br>
-These can carry our various tests such as a service endpoint being accessible. HealthChecker provides an
-SPI extension point to allow 3rd party developers to implement their own Activity checkers.
-</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/package.html b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/package.html
deleted file mode 100644
index abaa693..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/package.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<body>
-Defines classes and interfaces for workflow level entities and events.
-</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/AbstractActivity.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/AbstractActivity.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/AbstractActivity.java
deleted file mode 100644
index 3a13c1b..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/AbstractActivity.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.activity;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import net.sf.taverna.t2.annotation.AbstractAnnotatedThing;
-import net.sf.taverna.t2.annotation.annotationbeans.MimeType;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.workflowmodel.EditException;
-import net.sf.taverna.t2.workflowmodel.Edits;
-import net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean;
-import net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityOutputPortDefinitionBean;
-import net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityPortsDefinitionBean;
-
-import org.apache.log4j.Logger;
-
-/**
- * Convenience abstract superclass for generic Activity instances. Parameterised
- * on the configuration type used by the Activity implementation - when this
- * object is serialised the getConfiguration method is used to store specific
- * details of the activity, this is then used immediately after a call to the
- * default constructor when deserialising from XML on a workflow load.
- * <p>
- * This class holds port sets and mappings, and returns references directly to
- * them rather than copies thereof.
- * <p>
- * If you're writing an abstract activity (one that cannot be directly invoked)
- * you should extend this class for convenience. This can be useful when you
- * wish to specify some kind of abstract definition of a process which will be
- * bound at workflow invocation time to a particular concrete activity through
- * the action of a custom dispatch stack layer (which you will also provide)
- *
- * @author Tom Oinn
- * @author Stuart Owen
- *
- * @param <ConfigType>
- *            type of configuration object to be used to hold configuration
- *            information
- */
-public abstract class AbstractActivity<ConfigType> extends
-		AbstractAnnotatedThing<Activity<?>> implements Activity<ConfigType> {
-	private static Logger logger = Logger.getLogger(AbstractActivity.class);
-
-	private Edits edits;
-
-	protected Map<String, String> inputPortMapping = new HashMap<>();
-	protected Map<String, String> outputPortMapping = new HashMap<>();
-	protected Set<ActivityOutputPort> outputPorts = new HashSet<>();
-	protected Set<ActivityInputPort> inputPorts = new HashSet<>();
-
-	@Override
-	public void setEdits(Edits edits) {
-		if (edits == null)
-			throw new IllegalArgumentException("Edits can not be null.");
-		this.edits = edits;
-	}
-
-	/**
-	 * @return the edits
-	 */
-	public Edits getEdits() {
-		if (edits == null)
-			throw new IllegalStateException(
-					"Unable to run this meathod until setEdits has been called");
-		return edits;
-	}
-
-	/**
-	 * @see net.sf.taverna.t2.workflowmodel.processor.activity.Activity#configure(java.lang.Object)
-	 */
-	@Override
-	public abstract void configure(ConfigType conf)
-			throws ActivityConfigurationException;
-
-	/**
-	 * @see net.sf.taverna.t2.workflowmodel.processor.activity.Activity#getConfiguration()
-	 */
-	@Override
-	public abstract ConfigType getConfiguration();
-
-	/*
-	 * (non-Javadoc)
-	 *
-	 * @see net.sf.taverna.t2.workflowmodel.processor.activity.Activity#getInputPortMapping()
-	 */
-	@Override
-	public final Map<String, String> getInputPortMapping() {
-		return this.inputPortMapping;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 *
-	 * @see net.sf.taverna.t2.workflowmodel.processor.activity.Activity#getInputPorts()
-	 */
-	@Override
-	public final Set<ActivityInputPort> getInputPorts() {
-		return inputPorts;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 *
-	 * @see net.sf.taverna.t2.workflowmodel.processor.activity.Activity#getOutputPortMapping()
-	 */
-	@Override
-	public final Map<String, String> getOutputPortMapping() {
-		return this.outputPortMapping;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 *
-	 * @see net.sf.taverna.t2.workflowmodel.processor.activity.Activity#getOutputPorts()
-	 */
-	@Override
-	public final Set<ActivityOutputPort> getOutputPorts() {
-		return outputPorts;
-	}
-
-	/**
-	 * Creates and adds a new input port with the provided properties.
-	 *
-	 * @see #removeInputs()
-	 * @param portName -
-	 *            the name of the port to be created.
-	 * @param portDepth -
-	 *            the depth of the port to be created.
-	 */
-	protected void addInput(
-			String portName,
-			int portDepth,
-			boolean allowsLiteralValues,
-			List<Class<? extends ExternalReferenceSPI>> handledReferenceSchemes,
-			Class<?> translatedElementClass) {
-		if (handledReferenceSchemes == null)
-			handledReferenceSchemes = Collections.emptyList();
-		inputPorts.add(getEdits().createActivityInputPort(portName, portDepth,
-				allowsLiteralValues, handledReferenceSchemes,
-				translatedElementClass));
-	}
-
-	/**
-	 * Creates and adds a new output port with the provided properties.
-	 *
-	 * @see #removeOutputs()
-	 * @param portName -
-	 *            the name of the port to be created.
-	 * @param portDepth -
-	 *            the depth of the port to be created
-	 * @param granularDepth -
-	 *            the granular depth of the port to be created
-	 * @param mimeTypes -
-	 *            a List of String representations of the MIME type this port
-	 *            will emit as outputs.
-	 */
-	protected void addOutput(String portName, int portDepth, int granularDepth) {
-		outputPorts.add(getEdits().createActivityOutputPort(
-				portName, portDepth, granularDepth));
-	}
-
-	/**
-	 * Convenience method, creates a new output port with depth and granular
-	 * depth both set to the value for depth, i.e. no streaming behaviour.
-	 * <p>
-	 *
-	 * @see #removeOutputs()
-	 * @param portName
-	 * @param portDepth
-	 */
-	protected void addOutput(String portName, int portDepth) {
-		addOutput(portName, portDepth, portDepth);
-	}
-
-	/**
-	 * <p>
-	 * Simplifies configuring the Activity input and output ports if its
-	 * ConfigType is an implementation of {@link ActivityPortsDefinitionBean}
-	 * </p>
-	 * <p>
-	 * For an Activity that has ports that are defined dynamically it is natural
-	 * that is ConfigType will not implement this interface.
-	 * </p>
-	 *
-	 * @param configBean
-	 */
-	protected void configurePorts(ActivityPortsDefinitionBean configBean) {
-		removeInputs();
-		for (ActivityInputPortDefinitionBean inputDef : configBean
-				.getInputPortDefinitions()) {
-			addInput(inputDef.getName(), inputDef.getDepth(), inputDef
-					.getAllowsLiteralValues(), inputDef
-					.getHandledReferenceSchemes(), inputDef
-					.getTranslatedElementType());
-			// TODO - use the mime types from the config bean if required,
-			// probably best handled elsewhere though
-		}
-		removeOutputs();
-
-		for (ActivityOutputPortDefinitionBean outputDef : configBean
-				.getOutputPortDefinitions()) {
-			ActivityOutputPort createActivityOutputPort = getEdits()
-					.createActivityOutputPort(outputDef.getName(),
-							outputDef.getDepth(), outputDef.getGranularDepth());
-//			addOutput(outputDef.getName(), outputDef.getDepth(), outputDef
-//					.getGranularDepth());
-			outputPorts.add(createActivityOutputPort);
-			// add the mime types as annotations
-			for (String mimeType : outputDef.getMimeTypes())
-				setMimeType(createActivityOutputPort, mimeType);
-		}
-	}
-
-	private void setMimeType(ActivityOutputPort outputPort, String mimeType) {
-		MimeType mimeTypeAnnotation = new MimeType();
-		mimeTypeAnnotation.setText(mimeType);
-		try {
-			getEdits()
-					.getAddAnnotationChainEdit(outputPort, mimeTypeAnnotation)
-					.doEdit();
-		} catch (EditException e) {
-			logger.error(e);
-		}
-	}
-
-	/**
-	 * Remove existing output ports.
-	 */
-	protected void removeOutputs() {
-		outputPorts.clear();
-	}
-
-	/**
-	 * Remove existing input ports
-	 *
-	 */
-	protected void removeInputs() {
-		inputPorts.clear();
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/AbstractAsynchronousActivity.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/AbstractAsynchronousActivity.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/AbstractAsynchronousActivity.java
deleted file mode 100644
index 4dd0409..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/AbstractAsynchronousActivity.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.activity;
-
-import java.util.Map;
-
-import net.sf.taverna.t2.reference.T2Reference;
-
-/**
- * Abstract superclass for asynchronous activities. Activity providers should only
- * have to implement the configuration and invocation methods to have a fully
- * functional activity - serialisation and deserialisation are handled
- * automatically.
- * 
- * @author Tom Oinn
- * 
- * @param <ConfigType>
- *            the configuration type used for this activity
- */
-public abstract class AbstractAsynchronousActivity<ConfigType> extends
-		AbstractActivity<ConfigType> implements AsynchronousActivity<ConfigType> {
-
-	/**
-	 * Called immediately after object construction by the deserialisation
-	 * framework with a configuration bean built from the auto-generated XML.
-	 * <p>
-	 * This method is responsible for the creation of input and output ports,
-	 * something that is currently done in the constructor of the Taverna 1
-	 * Processor class.
-	 */
-	@Override
-	public abstract void configure(ConfigType conf)
-			throws ActivityConfigurationException;
-
-	/**
-	 * Get a configuration bean representing the definition of the activity. This
-	 * bean should contain enough information to rebuild the input and output
-	 * port sets, mappings are explicitly handled by the serialisation framework
-	 * but the ports are assumed to be generated during the configuration stage
-	 * rather than explicitly stored.
-	 */
-	@Override
-	public abstract ConfigType getConfiguration();
-
-	/**
-	 * Request an asynchronous invocation of the activity on the specified data.
-	 * The data items are named relative to the input port names of the activity
-	 * (as opposed to the parent processor), the invocation layer is responsible
-	 * for translating these appropriately before this method is called. The
-	 * callback object provides access to a DataManager instance that can be
-	 * used to resolve the entity identifiers in the data map, push results up
-	 * and signal failure conditions.
-	 * <p>
-	 * This method must not block! However it happens this method must return
-	 * immediately after creating the new activity invocation. Do not do any
-	 * heavy lifting in the body of this method without creating a new thread
-	 * specifically for it.
-	 */
-	@Override
-	public abstract void executeAsynch(Map<String, T2Reference> data,
-			AsynchronousActivityCallback callback);
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/Activity.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/Activity.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/Activity.java
deleted file mode 100644
index 4bec988..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/Activity.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007-2008 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.activity;
-
-import static net.sf.taverna.t2.annotation.HierarchyRole.CHILD;
-
-import java.util.Map;
-import java.util.Set;
-
-import net.sf.taverna.t2.annotation.Annotated;
-import net.sf.taverna.t2.annotation.HierarchyTraversal;
-import net.sf.taverna.t2.workflowmodel.Configurable;
-import net.sf.taverna.t2.workflowmodel.Edits;
-
-/**
- * Defines a single abstract or concrete invokable activity. Each Processor
- * contains at least one of these and may contain many, similarly the dispatch
- * stack may create new Activity instances from e.g. dynamic lookup or
- * resolution of an abstract activity to a concrete activity or set of
- * activities.
- * 
- * @param <ConfigurationType>
- *            the ConfigurationType associated with the Activity. This is an
- *            arbitrary java class that provides details on how the Activity is
- *            configured..
- * @author Tom Oinn
- * @author David Withers
- */
-public interface Activity<ConfigurationType> extends Annotated<Activity<?>>,
-		Configurable<ConfigurationType> {
-	/**
-	 * An Activity contains a set of named input ports. Names must be unique
-	 * within this set.
-	 *
-	 * @return the set of input ports for this activity
-	 */
-	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
-	Set<ActivityInputPort> getInputPorts();
-
-	/**
-	 * A processor may have different input port names to the activity or
-	 * activities it contains. This map is keyed on the processor input port
-	 * names with the corresponding value being the activity port name.
-	 * 
-	 * @return mapping from processor input port names to activity input port
-	 *         names
-	 */
-	Map<String, String> getInputPortMapping();
-
-	/**
-	 * An Activity contains a set of named output ports. As with input ports
-	 * names must be unique within the set.
-	 * 
-	 * @return
-	 */
-	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
-	Set<ActivityOutputPort> getOutputPorts();
-
-	/**
-	 * Outputs of the activity may be named differently to those of the
-	 * processor. This map is keyed on an activity output port name with each
-	 * corresponding value being the processor output port name to which the
-	 * activity output is bound.
-	 * 
-	 * @return mapping from activity output port name to processor output port
-	 *         name
-	 */
-	Map<String, String> getOutputPortMapping();
-
-	@Override
-	abstract void configure(ConfigurationType conf)
-			throws ActivityConfigurationException;
-
-	void setEdits(Edits edits);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityAndBeanWrapper.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityAndBeanWrapper.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityAndBeanWrapper.java
deleted file mode 100644
index e5a619e..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityAndBeanWrapper.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.activity;
-
-import java.awt.datatransfer.Transferable;
-
-/**
- * Used when dragging activities from the palette onto "something". Place it
- * inside a {@link Transferable} when doing a drag operation. Contains an
- * {@link Activity} and its configuration bean.
- * 
- * @author Ian Dunlop
- */
-public class ActivityAndBeanWrapper {
-	/** The Activity being dragged */
-	private Activity<?> activity;
-	/** The bean used to configure the activity */
-	private Object bean;
-	private String name;
-
-	public Activity<?> getActivity() {
-		return activity;
-	}
-
-	public void setActivity(Activity<?> activity) {
-		this.activity = activity;
-	}
-
-	public Object getBean() {
-		return bean;
-	}
-
-	public void setBean(Object bean) {
-		this.bean = bean;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityConfigurationException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityConfigurationException.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityConfigurationException.java
deleted file mode 100644
index 0774b40..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityConfigurationException.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007-2008 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.activity;
-
-import net.sf.taverna.t2.workflowmodel.ConfigurationException;
-
-/**
- * Thrown when attempting to configure an Activity instance with an invalid
- * configuration. Causes may include actual configuration errors, unavailable
- * activities etc.
- * 
- * @author Tom Oinn
- */
-public class ActivityConfigurationException extends ConfigurationException {
-	private static final long serialVersionUID = 6940385954331153900L;
-
-	/**
-	 * @param msg
-	 *            a message describing the reason for the exception.
-	 */
-	public ActivityConfigurationException(String msg) {
-		super(msg);
-	}
-
-	/**
-	 * @param cause
-	 *            a previous exception that caused this
-	 *            ActivityConfigurationException to be thrown.
-	 */
-	public ActivityConfigurationException(Throwable cause) {
-		super(cause);
-	}
-
-	/**
-	 * @param msg
-	 *            a message describing the reason for the exception.
-	 * @param cause
-	 *            a previous exception that caused this
-	 *            ActivityConfigurationException to be thrown.
-	 */
-	public ActivityConfigurationException(String msg, Throwable cause) {
-		super(msg, cause);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityFactory.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityFactory.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityFactory.java
deleted file mode 100644
index 49eaff4..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityFactory.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.activity;
-
-import java.net.URI;
-import java.util.Set;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * Factory for creating {@link Activity} instances.
- * 
- * @author David Withers
- */
-public interface ActivityFactory {
-	/**
-	 * Creates a new <code>Activity</code> instance.
-	 * 
-	 * @return the new <code>Activity</code> instance
-	 */
-	Activity<?> createActivity();
-
-	/**
-	 * What type of <code>Activity</code>s can this factory create?
-	 * 
-	 * @return the type of the <code>Activity</code>s that this factory can
-	 *         create
-	 */
-	URI getActivityType();
-
-	/**
-	 * Returns the JSON Schema for the configuration required by the
-	 * <code>Activity</code>.
-	 * 
-	 * @return the JSON Schema for the configuration required by the
-	 *         <code>Activity</code>
-	 */
-	JsonNode getActivityConfigurationSchema();
-
-	/**
-	 * Returns the <code>ActivityInputPort</code>s that the
-	 * <code>Activity</code> requires to be present in order to execute with the
-	 * specified configuration.
-	 * <p>
-	 * If the <code>Activity</code> does not require any input port for the
-	 * configuration then an empty set is returned.
-	 * 
-	 * @param configuration
-	 *            the configuration
-	 * @return the <code>ActivityInputPort</code>s that the
-	 *         <code>Activity</code> requires to be present in order to execute
-	 */
-	Set<ActivityInputPort> getInputPorts(JsonNode configuration)
-			throws ActivityConfigurationException;
-
-	/**
-	 * Returns the <code>ActivityOutputPort</code>s that the
-	 * <code>Activity</code> requires to be present in order to execute with the
-	 * specified configuration.
-	 * <p>
-	 * If the <code>Activity</code> does not require any output ports for the
-	 * configuration then an empty set is returned.
-	 * 
-	 * @param configuration
-	 *            the configuration
-	 * @return the <code>ActivityOutputPort</code>s that the
-	 *         <code>Activity</code> requires to be present in order to execute
-	 */
-	Set<ActivityOutputPort> getOutputPorts(JsonNode configuration)
-			throws ActivityConfigurationException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityInputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityInputPort.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityInputPort.java
deleted file mode 100644
index 93e4cc8..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityInputPort.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007-2009 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.activity;
-
-import java.util.List;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.workflowmodel.InputPort;
-
-/**
- * Specialisation of InputPort to capture the extra information required by
- * Activity instances.
- * 
- * @author Tom Oinn
- */
-public interface ActivityInputPort extends InputPort, ActivityPort {
-	/**
-	 * Declares that the DataDocument instances fed as input data (either
-	 * directly or as elements of a collection) to this input port must contain
-	 * at least one of the specified ReferenceScheme types. This is used to
-	 * specify that e.g. an activity can only accept URLs, values or similar.
-	 * 
-	 * @return Class objects representing the reference scheme types which this
-	 *         input can handle
-	 */
-	List<Class<? extends ExternalReferenceSPI>> getHandledReferenceSchemes();
-
-	/**
-	 * Literal values are a special case as they are not represented by
-	 * reference schemes - in rare cases activities may choose to deny literal
-	 * values, forcing *all* their inputs to be in a particular reference
-	 * scheme. If this is the case then this method should return false, if the
-	 * activity is capable of handling literal types without any upconversion to
-	 * references (please do implement this!) then it returns false
-	 * 
-	 * @return true if the activity can cope with literal values, false if it
-	 *         requires them to be converted to an instance of a reference
-	 *         scheme class (as defined by getHandledReferenceSchemes)
-	 */
-	boolean allowsLiteralValues();
-
-	/**
-	 * The Java object type desired when the input data reference is converted
-	 * to an object. This is only used by the parent Activity when invoking the
-	 * data facade. Where the input data is a list this returns the type of leaf
-	 * nodes within the collection structure - the instances of this type will
-	 * always be wrapped up in a Java collection rather than an array type
-	 * <p>
-	 * Note that this is not intended to allow activities to consume arbitrary
-	 * java classes, activities such as the API consumer should handle this
-	 * through the reference scheme mechanism backed by an appropriate store
-	 * (most likely an in-memory hash of active objects)
-	 * 
-	 * @return the desired class of the object returned by the data facade when
-	 *         converting the input data reference into a java object. This will
-	 *         almost always be String.class or byte[].class but other cases may
-	 *         exist.
-	 */
-	Class<?> getTranslatedElementClass();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityOutputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityOutputPort.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityOutputPort.java
deleted file mode 100644
index 8b82939..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityOutputPort.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.activity;
-
-import net.sf.taverna.t2.workflowmodel.OutputPort;
-
-/**
- * The output port of an {@link Activity}.
- * 
- * @author Stian Soiland-Reyes
- */
-public interface ActivityOutputPort extends OutputPort, ActivityPort {
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityPort.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityPort.java
deleted file mode 100644
index 3a1208c..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/ActivityPort.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.activity;
-
-import net.sf.taverna.t2.workflowmodel.Port;
-
-/**
- * The input or output port of an {@link Activity}.
- * 
- * @see ActivityInputPort
- * @see ActivityOutputPort
- * @author Stian Soiland-Reyes
- */
-public interface ActivityPort extends Port {
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/AsynchronousActivity.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/AsynchronousActivity.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/AsynchronousActivity.java
deleted file mode 100644
index dfcb326..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/AsynchronousActivity.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.activity;
-
-import java.util.Map;
-
-import net.sf.taverna.t2.reference.T2Reference;
-
-/**
- * A concrete invokable activity with an asynchronous invocation API and no
- * knowledge of invocation context. This is the most common concrete activity
- * type in Taverna 2, it has no knowledge of any enclosing iteration or other
- * handling process. The activity may stream results in the sense that it can
- * use the AsynchronousActivityCallback object to push multiple results followed
- * by a completion event. If a completion event is received by the callback
- * before any data events the callback will insert a data event containing empty
- * collections of the appropriate depth.
- * 
- * @param <ConfigurationType>
- *            the ConfigurationType associated with the Activity.
- * @author Tom Oinn
- */
-public interface AsynchronousActivity<ConfigurationType> extends
-		Activity<ConfigurationType> {
-	/**
-	 * Invoke the activity in an asynchronous manner. The activity uses the
-	 * specified ActivityCallback object to push results, errors and completion
-	 * events back to the dispatch stack.
-	 */
-	void executeAsynch(Map<String, T2Reference> data,
-			AsynchronousActivityCallback callback);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/AsynchronousActivityCallback.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/AsynchronousActivityCallback.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/AsynchronousActivityCallback.java
deleted file mode 100644
index f8522f6..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/AsynchronousActivityCallback.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.activity;
-
-import java.util.Map;
-
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchErrorType;
-
-/**
- * The callback interface used by instances of AsynchronousActivity to push
- * results and failure messages back to the invocation layer.
- * 
- * @author Tom Oinn
- */
-public interface AsynchronousActivityCallback {
-	/**
-	 * The invocation context contains resources such as data managers, security
-	 * agents and provenance consumers to be used by the Activity as it runs.
-	 * This replaces the getLocalDataManager and getLocalSecurityManager calls.
-	 */
-	InvocationContext getContext();
-
-	/**
-	 * If an activity proxy wants to create a new thread of activity it should
-	 * use this method unless there is a very good reason not to. This allows
-	 * the workflow framework to control its own thread usage, possibly
-	 * implementing per user, per workflow or per processor thread limit
-	 * policies. Exceptions to this principle might include cases where the
-	 * activity proxy is capable of managing thread usage across all instances
-	 * of that activity type and therefore more efficiently (fewer threads) than
-	 * if it let the workflow manager perform this function.
-	 * 
-	 * @param runMe
-	 *            a Runnable to implement the activity proxy logic.
-	 */
-	void requestRun(Runnable runMe);
-
-	/**
-	 * Push a map of named identifiers out to the invocation layer which is then
-	 * responsible for wrapping them up into an appropriate Job object and
-	 * sending it up the dispatch stack. The keys of the map are names local to
-	 * the activity, the callback object is responsible for rewriting them
-	 * according to the activity mapping rules (i.e. Activity.getXXXPortMapping)
-	 * 
-	 * @param data
-	 *            a single result data packet
-	 * @param index
-	 *            the index of the result in the context of this single process
-	 *            invocation. If there's no streaming involved this should be a
-	 *            zero length int[].
-	 */
-	void receiveResult(Map<String, T2Reference> data, int[] index);
-
-	/**
-	 * If (and only if) the activity is streaming data then this method can be
-	 * called to signal a (possibly partial) completion of the stream. If this
-	 * is a total completion event, i.e. one with a zero length index array and
-	 * there have been no result data sent the callback object will create a
-	 * single job containing empty lists and send that instead otherwise it will
-	 * be passed straight through. The index array is relative to this
-	 * particular activity invocation as the invocation has no contextual
-	 * awareness.
-	 * 
-	 * @param completionIndex
-	 */
-	void receiveCompletion(int[] completionIndex);
-
-	/**
-	 * If the job fails (as opposed to succeeding and sending an error for which
-	 * the receiveResult method is used) this method will cause an error to be
-	 * sent up the dispatch stack, triggering any appropriate handling methods
-	 * such as retry, failover etc. This particular method accepts both a free
-	 * text message and an instance of Throwable for additional information, in
-	 * addition to which it sends an error type which allows upstream layers to
-	 * determine whether they can handle the error or whether it should be
-	 * passed directly upwards.
-	 * 
-	 * @param message
-	 * @param t
-	 */
-	void fail(String message, Throwable t, DispatchErrorType errorType);
-
-	/**
-	 * If the job fails (as opposed to succeeding and sending an error for which
-	 * the receiveResult method is used) this method will cause an error to be
-	 * sent up the dispatch stack, triggering any appropriate handling methods
-	 * such as retry, failover etc. This particular method accepts both a free
-	 * text message and an instance of Throwable for additional information.
-	 * 
-	 * @param message
-	 * @param t
-	 */
-	void fail(String message, Throwable t);
-
-	/**
-	 * If the job fails (as opposed to succeeding and sending an error for which
-	 * the receiveResult method is used) this method will cause an error to be
-	 * sent up the dispatch stack, triggering any appropriate handling methods
-	 * such as retry, failover etc. This method just takes a free text message
-	 * for cases where a failure is properly described by an instance of
-	 * Throwable
-	 * 
-	 * @param message
-	 */
-	void fail(String message);
-
-	/**
-	 * For activities which are going to establish state below the invoke node
-	 * in the monitor tree this method returns the owning process identifier
-	 * allocated to the invoke node. This is particularly necessary for nested
-	 * workflow activities.
-	 * <p>
-	 * Any calls to Monitor.register... must establish a state tree rooted at
-	 * this node, they may assume that this node already exists.
-	 */
-	String getParentProcessIdentifier();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/DisabledActivity.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/DisabledActivity.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/DisabledActivity.java
deleted file mode 100644
index e219635..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/DisabledActivity.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007-2011 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.activity;
-
-import java.util.HashSet;
-import java.util.Map;
-
-import net.sf.taverna.t2.workflowmodel.OutputPort;
-
-import org.apache.log4j.Logger;
-
-/**
- * A disabled activity is a wrapper for an Activity that is offline or similarly
- * disabled. This cannot be done just by setting a flag on the corresponding
- * activity as special code needs to be used to create the ports of the disabled
- * activity that, obviously, cannot be done by confighuring the offline
- * activity.
- *
- * @author alanrw
- */
-public final class DisabledActivity extends
-		NonExecutableActivity<ActivityAndBeanWrapper> {
-	public static final String URI = "http://ns.taverna.org.uk/2010/activity/disabled";
-	private static final Logger logger = Logger
-			.getLogger(DisabledActivity.class);
-
-	/**
-	 * Conf holds the offline Activity and its configuration.
-	 */
-	private ActivityAndBeanWrapper conf;
-	private Object lastWorkingConfiguration;
-
-	/**
-	 * It is not possible to create a "naked" DisabledActivity.
-	 */
-	private DisabledActivity() {
-		super();
-		lastWorkingConfiguration = null;
-	}
-
-	/**
-	 * Create a DisabledActivity that represents an offline activity of the
-	 * specified class with the specified configuration. This constructor is
-	 * commonly used when reading in an Activity which cannot be initially
-	 * configured because it is offline.
-	 *
-	 * @param activityClass
-	 *            The class of Activity that is offline.
-	 * @param config
-	 *            The configuration of the offline Activity.
-	 * @throws InstantiationException
-	 * @throws IllegalAccessException
-	 * @throws ActivityConfigurationException
-	 */
-	public DisabledActivity(Class<? extends Activity<?>> activityClass,
-			Object config) throws InstantiationException,
-			IllegalAccessException, ActivityConfigurationException {
-		this(activityClass.newInstance(), config);
-	}
-
-	/**
-	 * Create a DisabledActivity that represents a specific Activity with its
-	 * configuration.
-	 *
-	 * @param activity
-	 *            The Activity that is offline
-	 * @param config
-	 *            The configuration of the activity.
-	 */
-	public DisabledActivity(Activity<?> activity, Object config) {
-		this();
-		ActivityAndBeanWrapper disabledConfig = new ActivityAndBeanWrapper();
-		disabledConfig.setActivity(activity);
-		disabledConfig.setBean(config);
-		try {
-			configure(disabledConfig);
-		} catch (ActivityConfigurationException e) {
-			logger.error(e);
-		}
-	}
-
-	/**
-	 * Create a DisabledActivity that represents a specific Activity that is now
-	 * disabled e.g. by its remote endpoint going offline. Note that in this
-	 * case, the ports of the DisabledActivity and their mapping to the
-	 * containing Processor's ports can be inherited from the Activity that is
-	 * now disabled.
-	 * 
-	 * @param activity
-	 *            The Activity that is now disabled.
-	 */
-	public DisabledActivity(Activity<?> activity) {
-		this(activity, activity.getConfiguration());
-		for (ActivityInputPort aip : activity.getInputPorts())
-			addInput(aip.getName(), aip.getDepth(), aip.allowsLiteralValues(),
-					aip.getHandledReferenceSchemes(),
-					aip.getTranslatedElementClass());
-		for (OutputPort op : activity.getOutputPorts())
-			addOutput(op.getName(), op.getDepth(), op.getGranularDepth());
-		getInputPortMapping().clear();
-		getInputPortMapping().putAll(activity.getInputPortMapping());
-		getOutputPortMapping().clear();
-		getOutputPortMapping().putAll(activity.getOutputPortMapping());
-	}
-
-	@Override
-	public void configure(ActivityAndBeanWrapper conf)
-			throws ActivityConfigurationException {
-		this.conf = conf;
-	}
-
-	@Override
-	public ActivityAndBeanWrapper getConfiguration() {
-		return conf;
-	}
-
-	/**
-	 * @return The Activity that has been disabled
-	 */
-	public Activity<?> getActivity() {
-		return getConfiguration().getActivity();
-	}
-
-	/**
-	 * @return The configuration of the Activity that has been disabled
-	 */
-	public Object getActivityConfiguration() {
-		return getConfiguration().getBean();
-	}
-
-	public boolean configurationWouldWork() {
-		return configurationWouldWork(conf.getBean());
-	}
-
-	public boolean configurationWouldWork(Object newConfig) {
-		boolean result = true;
-		lastWorkingConfiguration = null;
-		try {
-			@SuppressWarnings("unchecked")
-			Activity<Object> aa = conf.getActivity().getClass().newInstance();
-			aa.configure(newConfig);
-			boolean unknownPort = false;
-			Map<String, String> currentInputPortMap = getInputPortMapping();
-			HashSet<String> currentInputNames = new HashSet<>();
-			currentInputNames.addAll(currentInputPortMap.values()) ;
-			for (ActivityInputPort aip : aa.getInputPorts())
-				currentInputNames.remove(aip.getName());
-			unknownPort = !currentInputNames.isEmpty();
-
-			if (!unknownPort) {
-				Map<String, String> currentOutputPortMap = getOutputPortMapping();
-				HashSet<String> currentOutputNames = new HashSet<>();
-				currentOutputNames.addAll(currentOutputPortMap.values());
-				for (OutputPort aop : aa.getOutputPorts())
-					currentOutputNames.remove(aop.getName());
-				unknownPort = !currentOutputNames.isEmpty();
-			}
-			if (unknownPort)
-				result = false;
-		} catch (ActivityConfigurationException ex) {
-			result = false;
-		} catch (InstantiationException|IllegalAccessException e) {
-			return false;
-		}
-		if (result)
-		    lastWorkingConfiguration = newConfig;
-		return result;
-	}
-
-	public Object getLastWorkingConfiguration() {
-	    return lastWorkingConfiguration;
-	}
-}


[43/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-observer/src/main/java/net/sf/taverna/t2/lang/observer/SwingAwareObserver.java
----------------------------------------------------------------------
diff --git a/taverna-observer/src/main/java/net/sf/taverna/t2/lang/observer/SwingAwareObserver.java b/taverna-observer/src/main/java/net/sf/taverna/t2/lang/observer/SwingAwareObserver.java
deleted file mode 100644
index 39435d7..0000000
--- a/taverna-observer/src/main/java/net/sf/taverna/t2/lang/observer/SwingAwareObserver.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2012 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.lang.observer;
-
-import javax.swing.SwingUtilities;
-
-/**
- * Implementation of an {@link Observer} that adds calls to notify to the AWT event dispatching
- * thread.
- *
- * @author David Withers
- */
-public abstract class SwingAwareObserver<Message> implements Observer<Message> {
-
-	@Override
-	public void notify(final Observable<Message> sender, final Message message) throws Exception {
-	    Runnable runnable = new Runnable() {
-			@Override
-			public void run() {
-				notifySwing(sender, message);
-			}
-	    };
-		if (SwingUtilities.isEventDispatchThread()) {
-			runnable.run();
-		} else {
-			// T2-971
-			SwingUtilities.invokeLater(runnable);
-		}
-	}
-
-	public abstract void notifySwing(Observable<Message> sender, Message message);
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-observer/src/main/java/net/sf/taverna/t2/lang/observer/package-info.java
----------------------------------------------------------------------
diff --git a/taverna-observer/src/main/java/net/sf/taverna/t2/lang/observer/package-info.java b/taverna-observer/src/main/java/net/sf/taverna/t2/lang/observer/package-info.java
deleted file mode 100644
index e9d3ff2..0000000
--- a/taverna-observer/src/main/java/net/sf/taverna/t2/lang/observer/package-info.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-/**
- * Implementation of the observer pattern.  {@link Observer}s registers with an 
- * {@link Observable} using {@link Observable#addObserver(Observer)}, and will receive 
- * notifications as a call to {@link Observer#notify(Observable, Object)}. 
- * <p>
- * Typical implementations of {@link Observable} will be delegating to a 
- * {@link MultiCaster} to do the boring observer registration and message 
- * dispatching.
- * </p>
- * <p>
- * Example of Observable:
- * <pre>
- * public class MyObservable implements Observable<MyEvent> {
- * 	 public static class MyEvent {
- * 		// ..
- * 	 }
- * 	 private MultiCaster&lt:MyEvent&gt; multiCaster = new MultiCaster&lt:MyEvent&gt;(this);
- * 
- *	 public void doStuff() {
- *		multiCaster.notify(new MyEvent());
- *	 }
- * 
- * 	 public void addObserver(Observer<MyEvent> observer) {
- * 		multiCaster.addObserver(observer);
- * 	 }
- * 
- * 	 public List<Observer<MyEvent>> getObservers() {
- * 		return multiCaster.getObservers();
- * 	 }
- * 
- * 	 public void removeObserver(Observer<MyEvent> observer) {
- * 		multiCaster.removeObserver(observer);
- * 	 }
- * }
- * </pre>
- * And an observer that is notified when MyObservable.doStuff() is called:
- * <pre>
- * public class MyObserver implements Observer<MyEvent> {
- *	 public void notify(Observable<MyEvent> sender, MyEvent message) {
- *		System.out.println("Receieved " + message + " from " + sender);
- * 	 }
- * }
- * </pre>
- * Example of usage:
- * <pre>
- * 		MyObservable observable = new MyObservable();
- *		MyObserver observer = new MyObserver();
- *		observable.addObserver(observer);
- *		observable.doStuff();
- *	</pre>
- */
-package net.sf.taverna.t2.lang.observer;
-

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-observer/src/main/java/org/apache/taverna/lang/observer/MultiCaster.java
----------------------------------------------------------------------
diff --git a/taverna-observer/src/main/java/org/apache/taverna/lang/observer/MultiCaster.java b/taverna-observer/src/main/java/org/apache/taverna/lang/observer/MultiCaster.java
new file mode 100644
index 0000000..553ed0f
--- /dev/null
+++ b/taverna-observer/src/main/java/org/apache/taverna/lang/observer/MultiCaster.java
@@ -0,0 +1,92 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.lang.observer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Send notifications to registered observers about changes to models
+ * 
+ * @author Ian Dunlop
+ * @author Stian Soiland
+ * 
+ * @param <Message>
+ */
+public class MultiCaster<Message> implements Observable<Message> {
+
+	private static Logger logger = Logger.getLogger(MultiCaster.class);
+
+	private Observable<Message> observable;
+
+	protected List<Observer<Message>> observers = new ArrayList<Observer<Message>>();
+
+	/**
+	 * Set the {@link #observable} ie. the class that changes are happening to
+	 * and it's Message for this {@link MultiCaster}
+	 * 
+	 * @param observable
+	 */
+	public MultiCaster(Observable<Message> observable) {
+		this.observable = observable;
+	}
+
+	/**
+	 * Tell all the registered observers about the change to the model
+	 * 
+	 * @param message
+	 */
+	@SuppressWarnings("unchecked")
+	public void notify(Message message) {
+		// Use a copy that can be iterated even if register/remove is called
+		for (Observer<Message> observer : getObservers()) {
+			try {
+				observer.notify(observable, message);
+			} catch (Exception ex) {
+				logger.warn("Could not notify " + observer, ex);
+			}
+		}
+	}
+
+	/**
+	 * Register an observer ie. someone who wants informed about changes
+	 */
+	public synchronized void addObserver(Observer<Message> observer) {
+		observers.add(observer);
+	}
+
+	/**
+	 * Remove the observer and no longer send out any notifications about it
+	 */
+	public synchronized void removeObserver(Observer<Message> observer) {
+		observers.remove(observer);
+	}
+
+	/**
+	 * A list of all the classes currently registered with this
+	 * {@link MultiCaster}
+	 */
+	public synchronized List<Observer<Message>> getObservers() {
+		return new ArrayList<Observer<Message>>(observers);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-observer/src/main/java/org/apache/taverna/lang/observer/Observable.java
----------------------------------------------------------------------
diff --git a/taverna-observer/src/main/java/org/apache/taverna/lang/observer/Observable.java b/taverna-observer/src/main/java/org/apache/taverna/lang/observer/Observable.java
new file mode 100644
index 0000000..d80a91b
--- /dev/null
+++ b/taverna-observer/src/main/java/org/apache/taverna/lang/observer/Observable.java
@@ -0,0 +1,55 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.lang.observer;
+
+import java.util.List;
+
+/**
+ * Implements this if you want to notify other classes about changes
+ * 
+ * @author Ian Dunlop
+ * @author Stian Soiland
+ * 
+ * @param <Message>
+ */
+public interface Observable<Message> {
+	/**
+	 * Register an {@link Observer}
+	 * 
+	 * @param observer
+	 *            the class who wants notified of changes
+	 */
+	public void addObserver(Observer<Message> observer);
+
+	/**
+	 * Remove a class who is currently observing
+	 * 
+	 * @param observer
+	 *            the class who no longer wants notified
+	 */
+	public void removeObserver(Observer<Message> observer);
+
+	/**
+	 * A list of all the currently registered {@link Observer}s
+	 * 
+	 * @return
+	 */
+	public List<Observer<Message>> getObservers();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-observer/src/main/java/org/apache/taverna/lang/observer/Observer.java
----------------------------------------------------------------------
diff --git a/taverna-observer/src/main/java/org/apache/taverna/lang/observer/Observer.java b/taverna-observer/src/main/java/org/apache/taverna/lang/observer/Observer.java
new file mode 100644
index 0000000..df51cf8
--- /dev/null
+++ b/taverna-observer/src/main/java/org/apache/taverna/lang/observer/Observer.java
@@ -0,0 +1,43 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.lang.observer;
+
+/**
+ * Implement if you want to register with an {@link Observable}
+ * 
+ * @author Ian Dunlop
+ * @author Stian Soiland
+ * 
+ * @param <Message>
+ */
+public interface Observer<Message> {
+	/**
+	 * Called by the {@link Observable} to notify the implementing class of
+	 * changes
+	 * 
+	 * @param sender
+	 *            the class where the changes have happened
+	 * @param message
+	 *            what has changed
+	 * @throws Exception
+	 */
+	public void notify(Observable<Message> sender, Message message)
+			throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-observer/src/main/java/org/apache/taverna/lang/observer/SwingAwareObserver.java
----------------------------------------------------------------------
diff --git a/taverna-observer/src/main/java/org/apache/taverna/lang/observer/SwingAwareObserver.java b/taverna-observer/src/main/java/org/apache/taverna/lang/observer/SwingAwareObserver.java
new file mode 100644
index 0000000..45dd21f
--- /dev/null
+++ b/taverna-observer/src/main/java/org/apache/taverna/lang/observer/SwingAwareObserver.java
@@ -0,0 +1,50 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.lang.observer;
+
+import javax.swing.SwingUtilities;
+
+/**
+ * Implementation of an {@link Observer} that adds calls to notify to the AWT event dispatching
+ * thread.
+ *
+ * @author David Withers
+ */
+public abstract class SwingAwareObserver<Message> implements Observer<Message> {
+
+	@Override
+	public void notify(final Observable<Message> sender, final Message message) throws Exception {
+	    Runnable runnable = new Runnable() {
+			@Override
+			public void run() {
+				notifySwing(sender, message);
+			}
+	    };
+		if (SwingUtilities.isEventDispatchThread()) {
+			runnable.run();
+		} else {
+			// T2-971
+			SwingUtilities.invokeLater(runnable);
+		}
+	}
+
+	public abstract void notifySwing(Observable<Message> sender, Message message);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-observer/src/main/java/org/apache/taverna/lang/observer/package-info.java
----------------------------------------------------------------------
diff --git a/taverna-observer/src/main/java/org/apache/taverna/lang/observer/package-info.java b/taverna-observer/src/main/java/org/apache/taverna/lang/observer/package-info.java
new file mode 100644
index 0000000..3cf0002
--- /dev/null
+++ b/taverna-observer/src/main/java/org/apache/taverna/lang/observer/package-info.java
@@ -0,0 +1,72 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+/**
+ * Implementation of the observer pattern.  {@link Observer}s registers with an 
+ * {@link Observable} using {@link Observable#addObserver(Observer)}, and will receive 
+ * notifications as a call to {@link Observer#notify(Observable, Object)}. 
+ * <p>
+ * Typical implementations of {@link Observable} will be delegating to a 
+ * {@link MultiCaster} to do the boring observer registration and message 
+ * dispatching.
+ * </p>
+ * <p>
+ * Example of Observable:
+ * <pre>
+ * public class MyObservable implements Observable<MyEvent> {
+ * 	 public static class MyEvent {
+ * 		// ..
+ * 	 }
+ * 	 private MultiCaster&lt:MyEvent&gt; multiCaster = new MultiCaster&lt:MyEvent&gt;(this);
+ * 
+ *	 public void doStuff() {
+ *		multiCaster.notify(new MyEvent());
+ *	 }
+ * 
+ * 	 public void addObserver(Observer<MyEvent> observer) {
+ * 		multiCaster.addObserver(observer);
+ * 	 }
+ * 
+ * 	 public List<Observer<MyEvent>> getObservers() {
+ * 		return multiCaster.getObservers();
+ * 	 }
+ * 
+ * 	 public void removeObserver(Observer<MyEvent> observer) {
+ * 		multiCaster.removeObserver(observer);
+ * 	 }
+ * }
+ * </pre>
+ * And an observer that is notified when MyObservable.doStuff() is called:
+ * <pre>
+ * public class MyObserver implements Observer<MyEvent> {
+ *	 public void notify(Observable<MyEvent> sender, MyEvent message) {
+ *		System.out.println("Receieved " + message + " from " + sender);
+ * 	 }
+ * }
+ * </pre>
+ * Example of usage:
+ * <pre>
+ * 		MyObservable observable = new MyObservable();
+ *		MyObserver observer = new MyObserver();
+ *		observable.addObserver(observer);
+ *		observable.doStuff();
+ *	</pre>
+ */
+package org.apache.taverna.lang.observer;
+

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-observer/src/test/java/net/sf/taverna/t2/lang/observer/ObserverTest.java
----------------------------------------------------------------------
diff --git a/taverna-observer/src/test/java/net/sf/taverna/t2/lang/observer/ObserverTest.java b/taverna-observer/src/test/java/net/sf/taverna/t2/lang/observer/ObserverTest.java
deleted file mode 100644
index 661cbbc..0000000
--- a/taverna-observer/src/test/java/net/sf/taverna/t2/lang/observer/ObserverTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.lang.observer;
-
-import static org.junit.Assert.*;
-
-import java.util.List;
-
-import net.sf.taverna.t2.lang.observer.MultiCaster;
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.lang.observer.Observer;
-
-import org.junit.Test;
-
-public class ObserverTest {
-
-	@Test
-	public void registerObserver() throws Exception {
-		MyObservable observable = new MyObservable();
-		MyObserver observer1 = new MyObserver();
-		MyObserver observer2 = new MyObserver();
-
-		observable.triggerEvent(); // don't notify, but increase count
-		assertNull(observer1.lastMessage);
-		observable.addObserver(observer1);
-		assertNull(observer1.lastMessage);
-		assertNull(observer2.lastMessage);
-		assertNull(observer1.lastSender);
-		assertNull(observer2.lastSender);
-		observable.triggerEvent();
-		assertEquals("This is message 1", observer1.lastMessage);
-		assertSame(observable, observer1.lastSender);
-		assertNull(observer2.lastSender);
-
-		observable.addObserver(observer2);
-		assertNull(observer2.lastMessage);
-		observable.triggerEvent();
-		assertEquals("This is message 2", observer1.lastMessage);
-		assertEquals("This is message 2", observer2.lastMessage);
-		assertSame(observable, observer1.lastSender);
-		assertSame(observable, observer2.lastSender);
-
-		MyObservable otherObservable = new MyObservable();
-		otherObservable.addObserver(observer2);
-		otherObservable.triggerEvent();
-		// New instance, should start from 0
-		assertEquals("This is message 0", observer2.lastMessage);
-		assertSame(otherObservable, observer2.lastSender);
-
-		// observer1 unchanged
-		assertEquals("This is message 2", observer1.lastMessage);
-		assertSame(observable, observer1.lastSender);
-
-	}
-
-	@Test
-	public void concurrencyTest() {
-		MyObservable observable = new MyObservable();
-		MyObserver dummyObserver = new MyObserver();
-		SelvRemovingObserver selfRemoving = new SelvRemovingObserver();
-		observable.addObserver(dummyObserver);
-		observable.addObserver(selfRemoving);
-		assertEquals(2, observable.getObservers().size());
-		observable.triggerEvent();
-		
-		
-	}
-	
-	public class MyObservable implements Observable<String> {
-
-		private int counter = 0;
-		MultiCaster<String> multiCaster = new MultiCaster<String>(this);
-
-		public void addObserver(Observer<String> observer) {
-			multiCaster.addObserver(observer);
-		}
-
-		public void removeObserver(Observer<String> observer) {
-			multiCaster.removeObserver(observer);
-		}
-
-		public void triggerEvent() {
-			multiCaster.notify("This is message " + counter++);
-		}
-
-		public List<Observer<String>> getObservers() {
-			return multiCaster.getObservers();
-		}
-	}
-
-	public class MyObserver implements Observer<String> {
-		String lastMessage = null;
-		Observable<String> lastSender = null;
-
-		public void notify(Observable<String> sender, String message) {
-			lastSender = sender;
-			lastMessage = message;
-		}
-	}
-	
-	public class SelvRemovingObserver implements Observer<String> {
-
-		public int called=0;
-		
-		public void notify(Observable<String> sender, String message) {
-			called++;
-			if (called > 1) {
-				fail("Did not remove itself");
-			}
-			sender.removeObserver(this);
-		}
-		
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-observer/src/test/java/org/apache/taverna/lang/observer/ObserverTest.java
----------------------------------------------------------------------
diff --git a/taverna-observer/src/test/java/org/apache/taverna/lang/observer/ObserverTest.java b/taverna-observer/src/test/java/org/apache/taverna/lang/observer/ObserverTest.java
new file mode 100644
index 0000000..7b4874c
--- /dev/null
+++ b/taverna-observer/src/test/java/org/apache/taverna/lang/observer/ObserverTest.java
@@ -0,0 +1,128 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.lang.observer;
+
+import static org.junit.Assert.*;
+
+import java.util.List;
+
+import org.junit.Test;
+
+public class ObserverTest {
+
+	@Test
+	public void registerObserver() throws Exception {
+		MyObservable observable = new MyObservable();
+		MyObserver observer1 = new MyObserver();
+		MyObserver observer2 = new MyObserver();
+
+		observable.triggerEvent(); // don't notify, but increase count
+		assertNull(observer1.lastMessage);
+		observable.addObserver(observer1);
+		assertNull(observer1.lastMessage);
+		assertNull(observer2.lastMessage);
+		assertNull(observer1.lastSender);
+		assertNull(observer2.lastSender);
+		observable.triggerEvent();
+		assertEquals("This is message 1", observer1.lastMessage);
+		assertSame(observable, observer1.lastSender);
+		assertNull(observer2.lastSender);
+
+		observable.addObserver(observer2);
+		assertNull(observer2.lastMessage);
+		observable.triggerEvent();
+		assertEquals("This is message 2", observer1.lastMessage);
+		assertEquals("This is message 2", observer2.lastMessage);
+		assertSame(observable, observer1.lastSender);
+		assertSame(observable, observer2.lastSender);
+
+		MyObservable otherObservable = new MyObservable();
+		otherObservable.addObserver(observer2);
+		otherObservable.triggerEvent();
+		// New instance, should start from 0
+		assertEquals("This is message 0", observer2.lastMessage);
+		assertSame(otherObservable, observer2.lastSender);
+
+		// observer1 unchanged
+		assertEquals("This is message 2", observer1.lastMessage);
+		assertSame(observable, observer1.lastSender);
+
+	}
+
+	@Test
+	public void concurrencyTest() {
+		MyObservable observable = new MyObservable();
+		MyObserver dummyObserver = new MyObserver();
+		SelvRemovingObserver selfRemoving = new SelvRemovingObserver();
+		observable.addObserver(dummyObserver);
+		observable.addObserver(selfRemoving);
+		assertEquals(2, observable.getObservers().size());
+		observable.triggerEvent();
+		
+		
+	}
+	
+	public class MyObservable implements Observable<String> {
+
+		private int counter = 0;
+		MultiCaster<String> multiCaster = new MultiCaster<String>(this);
+
+		public void addObserver(Observer<String> observer) {
+			multiCaster.addObserver(observer);
+		}
+
+		public void removeObserver(Observer<String> observer) {
+			multiCaster.removeObserver(observer);
+		}
+
+		public void triggerEvent() {
+			multiCaster.notify("This is message " + counter++);
+		}
+
+		public List<Observer<String>> getObservers() {
+			return multiCaster.getObservers();
+		}
+	}
+
+	public class MyObserver implements Observer<String> {
+		String lastMessage = null;
+		Observable<String> lastSender = null;
+
+		public void notify(Observable<String> sender, String message) {
+			lastSender = sender;
+			lastMessage = message;
+		}
+	}
+	
+	public class SelvRemovingObserver implements Observer<String> {
+
+		public int called=0;
+		
+		public void notify(Observable<String> sender, String message) {
+			called++;
+			if (called > 1) {
+				fail("Did not remove itself");
+			}
+			sender.removeObserver(this);
+		}
+		
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/AbstractExternalReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/AbstractExternalReference.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/AbstractExternalReference.java
deleted file mode 100644
index 599d0bb..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/AbstractExternalReference.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-import static net.sf.taverna.t2.reference.ReferencedDataNature.*;
-
-/**
- * A trivial implementation of ExternalReference. This abstract class should be
- * used as the superclass of any ExternalReference implementations as it
- * provides base metadata for the hibernate-based persistence system used by the
- * main reference manager implementation. While the interface contract cannot
- * require this your extensions will likely not work properly unless you use
- * this class.
- * 
- * @author Tom Oinn
- */
-public abstract class AbstractExternalReference implements ExternalReferenceSPI {
-	// Used internally by Hibernate for this class and subclasses
-	private int primaryKey;
-
-	/**
-	 * Used by Hibernate internally to establish a foreign key relationship
-	 * between this abstract superclass and tables corresponding to
-	 * implementations of the ExternalReference interface. Has no impact on any
-	 * application level code, this method is only ever used by the internals of
-	 * the hibernate framework.
-	 */
-	public final void setPrimaryKey(int newKey) {
-		this.primaryKey = newKey;
-	}
-
-	/**
-	 * Used by Hibernate internally to establish a foreign key relationship
-	 * between this abstract superclass and tables corresponding to
-	 * implementations of the ExternalReference interface. Has no impact on any
-	 * application level code, this method is only ever used by the internals of
-	 * the hibernate framework.
-	 */
-	public final int getPrimaryKey() {
-		return this.primaryKey;
-	}
-
-	/**
-	 * Default to returning DataReferenceNature.UNKNOWN
-	 */
-	@Override
-	public ReferencedDataNature getDataNature() {
-		return UNKNOWN;
-	}
-
-	/**
-	 * Default to returning null for charset
-	 */
-	@Override
-	public String getCharset() {
-		return null;
-	}
-
-	/**
-	 * Default to a value of 0.0f for the resolution cost, but implementations
-	 * should at least attempt to set this to a more sensible level!
-	 */
-	@Override
-	public float getResolutionCost() {
-		return 0.0f;
-	}
-
-	@Override
-	public abstract ExternalReferenceSPI clone()
-			throws CloneNotSupportedException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ContextualizedT2Reference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ContextualizedT2Reference.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ContextualizedT2Reference.java
deleted file mode 100644
index a5699b0..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ContextualizedT2Reference.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * Used by the {@link ReferenceService#traverseFrom(T2Reference, int)} when
- * traversing a collection structure. Each contextualized t2reference contains
- * the {@link T2Reference} along with an integer array index representing the
- * position of that reference within the traversal structure. The index
- * [i<sub>0</sub>,i<sub>1</sub>,i<sub>2</sub> ... i<sub>n</sub>] is interpreted
- * such that the reference is located at
- * parent.get(i<sub>0</sub>).get(i<sub>1</sub
- * >).get(i<sub>2</sub>)....get(i<sub>n</sub>). If the index is empty then the
- * T2Reference <em>is</em> the original reference supplied to the
- * {@link ReferenceService#traverseFrom(T2Reference, int) traverseFrom} method.
- * 
- * @author Tom Oinn
- */
-public interface ContextualizedT2Reference {
-	/**
-	 * @return the T2Reference to which the associated index applies.
-	 */
-	T2Reference getReference();
-
-	/**
-	 * @return the index of this T2Reference
-	 */
-	int[] getIndex();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/DaoException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/DaoException.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/DaoException.java
deleted file mode 100644
index 7de38df..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/DaoException.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * Thrown by the Data Access Object interface methods, wrapping any underlying
- * exception.
- * 
- * @author Tom Oinn
- */
-public class DaoException extends RuntimeException {
-	static final long serialVersionUID = 8496141798637577803L;
-
-	public DaoException() {
-		super();
-	}
-
-	public DaoException(String message) {
-		super(message);
-	}
-
-	public DaoException(Throwable cause) {
-		super(cause);
-	}
-
-	public DaoException(String message, Throwable cause) {
-		super(message, cause);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/DereferenceException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/DereferenceException.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/DereferenceException.java
deleted file mode 100644
index d2f814f..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/DereferenceException.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * Thrown when a problem occurs during de-reference of an ExternalReferenceSPI
- * implementation. This include operations which implicitly de-reference the
- * reference such as those infering character set or data natures.
- * 
- * @author Tom Oinn
- */
-public class DereferenceException extends RuntimeException {
-	private static final long serialVersionUID = 8054381613840005541L;
-
-	public DereferenceException() {
-		//
-	}
-
-	public DereferenceException(String message) {
-		super(message);
-	}
-
-	public DereferenceException(Throwable cause) {
-		super(cause);
-	}
-
-	public DereferenceException(String message, Throwable cause) {
-		super(message, cause);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocument.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocument.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocument.java
deleted file mode 100644
index 06a20e3..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocument.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * Contains the definition of an error token within the workflow system.
- * 
- * @author Tom Oinn
- * @author David Withers
- */
-public interface ErrorDocument extends Identified {
-	/**
-	 * If the error document is created from a {@link Throwable} it will have a
-	 * stack trace, in this case the stack trace is represented as a list of
-	 * {@link StackTraceElement} beans
-	 */
-	List<StackTraceElementBean> getStackTraceStrings();
-
-	/**
-	 * If the error document is created from a {@link Throwable}, this contains
-	 * the message part of the {@link Throwable}.
-	 */
-	String getExceptionMessage();
-
-	/**
-	 * Error documents can carry an arbitrary string message, this returns it.
-	 */
-	String getMessage();
-
-	/**
-	 * If the error document is created from set of references that contain
-	 * error documents, this method returns them.
-	 */
-	Set<T2Reference> getErrorReferences();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentDao.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentDao.java
deleted file mode 100644
index 72fabf1..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentDao.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-import static org.springframework.transaction.annotation.Propagation.REQUIRED;
-import static org.springframework.transaction.annotation.Propagation.SUPPORTS;
-
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * Data access object handling ErrorDocument instances.
- * 
- * @author Tom Oinn
- */
-public interface ErrorDocumentDao {
-	/**
-	 * Store a named ErrorDocument to the database.
-	 * 
-	 * @param errorDoc
-	 *            error document to store
-	 * @throws DaoException
-	 *             if any exception is thrown when connecting to the underlying
-	 *             store or when storing the error document
-	 */
-	@Transactional(propagation = REQUIRED, readOnly = false)
-	void store(ErrorDocument errorDoc) throws DaoException;
-
-	/**
-	 * Retrieves a named and populated ErrorDocument
-	 * 
-	 * @param reference
-	 *            id of the error document to retrieve
-	 * @return a previously stored ErrorDocument instance
-	 * @throws DaoException
-	 *             if any exception is thrown when connecting to the underlying
-	 *             data store or when attempting retrieval of the error document
-	 */
-	@Transactional(propagation = SUPPORTS, readOnly = true)
-	ErrorDocument get(T2Reference reference) throws DaoException;
-
-	@Transactional(propagation = SUPPORTS, readOnly = false)
-	boolean delete(ErrorDocument errorDoc) throws DaoException;
-
-	@Transactional(propagation = SUPPORTS, readOnly = false)
-	void deleteErrorDocumentsForWFRun(String workflowRunId) throws DaoException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentService.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentService.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentService.java
deleted file mode 100644
index 6eee715..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentService.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-import java.util.Set;
-
-import org.springframework.transaction.annotation.Propagation;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * Provides facilities to register list of T2References, register empty lists at
- * any given depth and to resolve appropriate T2Reference instances back to
- * these lists. Registration operations assign names and lock the list contents
- * as a result. This service operates strictly on T2References, it neither tries
- * to nor is capable of any form of reference resolution, so aspects such as
- * collection traversal are not handled here (these are performed by the top
- * level reference service)
- * 
- * @author Tom Oinn
- */
-@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
-public interface ErrorDocumentService {
-	/**
-	 * Register a new error document.
-	 * <p>
-	 * The created reference will be related with a workflow run id passed
-	 * through ReferenceContext so we can track all data referenced by a
-	 * specific run.
-	 * 
-	 * @param message
-	 *            a free text message describing the error, if available. If
-	 *            there is no message use the empty string here.
-	 * @param t
-	 *            a Throwable describing the underlying fault causing this error
-	 *            document to be registered, if any. If there is no Throwable
-	 *            associated use null.
-	 * @param depth
-	 *            depth of the error, used when returning an error document
-	 *            instead of an identified list.
-	 * @return a new ErrorDocument instance, constructed fully and stored in the
-	 *         underlying storage system
-	 */
-	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
-	ErrorDocument registerError(String message, Throwable t, int depth,
-			ReferenceContext context) throws ErrorDocumentServiceException;
-
-	/**
-	 * Equivalent to <code>registerError(message, null, depth, context)</code>.
-	 */
-	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
-	ErrorDocument registerError(String message, int depth,
-			ReferenceContext context) throws ErrorDocumentServiceException;
-
-	/**
-	 * Equivalent to <code>registerError("", t, depth, context)</code>.
-	 */
-	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
-	ErrorDocument registerError(Throwable t, int depth, ReferenceContext context)
-			throws ErrorDocumentServiceException;
-
-	/**
-	 * Register a new error document.
-	 * <p>
-	 * The created reference will be related with a workflow run id passed
-	 * through ReferenceContext so we can track all data referenced by a
-	 * specific run.
-	 * 
-	 * @param message
-	 *            a free text message describing the error, if available. If
-	 *            there is no message use the empty string here.
-	 * @param errors
-	 *            a set of references that contain error documents.
-	 * @param depth
-	 *            depth of the error, used when returning an error document
-	 *            instead of an identified list.
-	 * @return a new ErrorDocument instance, constructed fully and stored in the
-	 *         underlying storage system
-	 */
-	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
-	ErrorDocument registerError(String message, Set<T2Reference> errors,
-			int depth, ReferenceContext context)
-			throws ErrorDocumentServiceException;
-
-	/**
-	 * Retrieve a previously named and registered ErrorDocument from the backing
-	 * store
-	 * 
-	 * @param id
-	 *            identifier of the error document to retrieve
-	 * @return an ErrorDocument
-	 * @throws ErrorDocumentServiceException
-	 *             if anything goes wrong with the retrieval process or if there
-	 *             is something wrong with the reference (such as it being of
-	 *             the wrong reference type).
-	 */
-	ErrorDocument getError(T2Reference id) throws ErrorDocumentServiceException;
-
-	/**
-	 * Functionality the same as {@link #getError(T2Reference) getError} but in
-	 * asynchronous mode, returning immediately and using the supplied callback
-	 * to communicate its results.
-	 * 
-	 * @param id
-	 *            a {@link T2Reference} identifying an {@link ErrorDocument} to
-	 *            retrieve
-	 * @param callback
-	 *            a {@link ErrorDocumentServiceCallback} used to convey the
-	 *            results of the asynchronous call
-	 * @throws ErrorDocumentServiceException
-	 *             if the reference set service is not correctly configured.
-	 *             Exceptions encountered when performing the asynchronous call
-	 *             are not returned here, for obvious reasons, and are instead
-	 *             messaged through the callback interface.
-	 */
-	void getErrorAsynch(T2Reference id, ErrorDocumentServiceCallback callback)
-			throws ErrorDocumentServiceException;
-
-	/**
-	 * Return the T2Reference for the sole child of an error document
-	 * identifier.
-	 */
-	T2Reference getChild(T2Reference errorId)
-			throws ErrorDocumentServiceException;
-
-	@Transactional(propagation = Propagation.SUPPORTS, readOnly = false)
-	boolean delete(T2Reference reference) throws ReferenceServiceException;
-
-	/**
-	 * Delete all {@link ErrorDocument}S used by the specific workflow run.
-	 */
-	@Transactional(propagation = Propagation.SUPPORTS, readOnly = false)
-	void deleteErrorDocumentsForWorkflowRun(String workflowRunId)
-			throws ReferenceServiceException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentServiceCallback.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentServiceCallback.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentServiceCallback.java
deleted file mode 100644
index 5e55672..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentServiceCallback.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * Callback interface used by asynchronous methods in the
- * {@link ErrorDocumentService} interface
- * 
- * @author Tom Oinn
- */
-public interface ErrorDocumentServiceCallback {
-	/**
-	 * Called when the requested {@link ReferenceSet} has been successfully
-	 * retrieved.
-	 * 
-	 * @param errorDoc
-	 *            the ErrorDocument requested
-	 */
-	void errorRetrieved(ErrorDocument errorDoc);
-
-	/**
-	 * Called if the retrieval failed for some reason
-	 * 
-	 * @param cause
-	 *            an ErrorDocumentServiceException explaining the retrieval
-	 *            failure
-	 */
-	void errorRetrievalFailed(ErrorDocumentServiceException cause);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentServiceException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentServiceException.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentServiceException.java
deleted file mode 100644
index 3959c6a..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentServiceException.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * RuntimeException subclass thrown by the error document service layer
- * interfaces. All underlying exceptions are either handled by the service layer
- * or wrapped in this exception (or a subclass) and rethrown.
- * 
- * @author Tom Oinn
- */
-public class ErrorDocumentServiceException extends RuntimeException {
-	private static final long serialVersionUID = 5556399589785258956L;
-
-	public ErrorDocumentServiceException() {
-		super();
-	}
-
-	public ErrorDocumentServiceException(String message, Throwable cause) {
-		super(message, cause);
-	}
-
-	public ErrorDocumentServiceException(String message) {
-		super(message);
-	}
-
-	public ErrorDocumentServiceException(Throwable cause) {
-		super(cause);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceBuilderSPI.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceBuilderSPI.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceBuilderSPI.java
deleted file mode 100644
index 2dfb340..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceBuilderSPI.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-import java.io.InputStream;
-
-/**
- * Constructs an ExternalReferenceSPI instance from a byte stream. Used by the
- * {@link ReferenceSetAugmentor} when there isn't a direct reference to
- * reference translation path available for a desired target type, but available
- * for external use wherever this functionality is needed.
- * <p>
- * Where an underlying resource is required this is extracted from the supplied
- * ReferenceContext, this implies that all methods in implementations of this
- * interface should be thread safe, allowing multiple concurrent threads
- * cleanly. For SPI purposes implementations should be java beans with default
- * constructors.
- * 
- * @author Tom Oinn
- */
-public interface ExternalReferenceBuilderSPI<TargetType extends ExternalReferenceSPI> {
-	/**
-	 * Given a stream of bytes, build the appropriate target
-	 * ExternalReferenceSPI implementation which would de-reference to the value
-	 * of that stream and return it.
-	 * 
-	 * @param byteStream
-	 *            the bytestream to read target from.
-	 * @param context
-	 *            a reference resolution context, needed potentially to
-	 *            construct the new ExternalReferenceSchemeSPI, especially in
-	 *            cases where the context contains security agents giving access
-	 *            to a remote data staging system *
-	 * @throws ExternalReferenceConstructionException
-	 *             if an error occurs instantiating the new reference.
-	 * @return the newly constructed ExternalReferenceSPI instance.
-	 */
-	TargetType createReference(InputStream byteStream, ReferenceContext context);
-
-	/**
-	 * Expose the type of the ExternalReferenceSPI that this builder can
-	 * construct
-	 * 
-	 * @return the class of ExternalReferenceSPI returned by the create
-	 *         reference methods.
-	 */
-	Class<TargetType> getReferenceType();
-
-	/**
-	 * Because the reference builder may rely on facilities provided to it
-	 * through the context this method is available to check whether these
-	 * facilities are sufficient.
-	 * 
-	 * @param context
-	 *            the reference context that will be used to construct new
-	 *            references
-	 * @return whether the context contains necessary resources for the
-	 *         reference construction process
-	 */
-	boolean isEnabled(ReferenceContext context);
-
-	/**
-	 * Return an approximate complexity cost of the reference construction. In
-	 * general we can't make any guarantees about this because the complexity of
-	 * the construction depends on more than just the type involved - it can
-	 * depend on local configuration, network location relative to the data
-	 * stores referenced and in some cases on the data themselves. For now
-	 * though we assign an approximation, the default value is 1.0f and lower
-	 * values represent less costly operations.
-	 */
-	float getConstructionCost();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceConstructionException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceConstructionException.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceConstructionException.java
deleted file mode 100644
index 0892ecc..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceConstructionException.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * Thrown when an exception occurs during construction of an
- * ExternalReferenceSPI instance. This includes construction through direct
- * method invocation, through the ExternalReferenceBuilderSPI interface and
- * through the ExternalReferenceTranslatorSPI interface.
- * 
- * @author Tom Oinn
- */
-public class ExternalReferenceConstructionException extends RuntimeException {
-	private static final long serialVersionUID = 8334725795238353354L;
-
-	public ExternalReferenceConstructionException() {
-		super();
-	}
-
-	public ExternalReferenceConstructionException(String message) {
-		super(message);
-	}
-
-	public ExternalReferenceConstructionException(Throwable cause) {
-		super(cause);
-	}
-
-	public ExternalReferenceConstructionException(String message,
-			Throwable cause) {
-		super(message, cause);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceSPI.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceSPI.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceSPI.java
deleted file mode 100644
index 4d6a047..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceSPI.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-import java.io.InputStream;
-
-/**
- * A reference to a single piece of data. This may or may not be within the
- * enactment infrastructure, it could refer to data held in a file, a URL, a
- * grid storage system or anything of that nature. Ideally the data this
- * reference points to should not change - we'd like to say 'must not change' at
- * this point but this isn't always possible, implementations should aim to
- * provide the appearance that data are immutable.
- * <p>
- * When used within the workflow engine implementations of this interface are
- * always contained in a ReferenceSet instance.
- * <p>
- * Implementors of this interface are strongly advised to use the
- * AbstractExternalReference superclass - this provides the necessary primary
- * key information used by hibernate-based implementations of the reference
- * manager. Technically we don't require it as it's possible that other backend
- * stores may exist, but the core store used by T2 is based on hibernate so it's
- * a very good idea to follow this! Basically if you don't your code won't work
- * in the current system.
- * <p>
- * This interface is an SPI - while implementations are never constructed based
- * on the SPI registry it is used to discover all implementing classes and
- * automatically register their hibernate mapping files. Implementors should add
- * their implementation class name to a
- * META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceSPI file in
- * the implementation artifact. For examples please refer to the
- * t2reference-core-extensions module, this contains implementations of this
- * interface for common basic reference types.
- * <p>
- * Note - if your implementation class has a complex hibernate mapping that uses
- * components which are themselves mapped into the database (perfectly legal to
- * do) then you must mark those components as instances of HibernateMappedEntity
- * so their corresponding mapping and class definitions are loaded by the
- * Hibernate backed reference set dao. If your implementation class uses inline
- * compound keys or other component types where you reference another class but
- * the other class is not mapped itself in hibernate you must instead make the
- * component class an instance of HibernateComponentClass - a marker interface -
- * for the same reason. Both of these are SPIs themselves, and require the
- * appropriate entries to be added to their service metadata files in your
- * extension jar.
- * 
- * @author Tom Oinn
- */
-public interface ExternalReferenceSPI extends Cloneable {
-	/**
-	 * Determine, if possible, whether the data this reference refers to is
-	 * textual or binary in nature. If this determination is impossible, either
-	 * because the ExternalReference implementation does not know or because the
-	 * data is not accessible for some reason then this should return
-	 * ReferenceDataNature.UNKNOWN
-	 * 
-	 * @return the nature of the referenced data
-	 */
-	ReferencedDataNature getDataNature();
-
-	/**
-	 * For textual data return the character set that should be used to pull
-	 * data into a java String object. Callers must deal with a null return
-	 * value in the event of either unknown charset or unknown or binary data
-	 * types.
-	 * 
-	 * @return string character set, for example 'utf-8', or <code>null</code>
-	 *         if binary or unknown type.
-	 */
-	String getCharset();
-
-	/**
-	 * Open and return an InputStream to the data referenced using, if required,
-	 * any facilities within the supplied context.
-	 * 
-	 * @param context
-	 *            the ReferenceContext object used to obtain e.g. security
-	 *            agents or other facilities required when de-referencing this
-	 *            reference.
-	 * @return an InputStream providing access to the referenced data
-	 * @throws DereferenceException
-	 *             if the reference cannot be de-referenced. This may be because
-	 *             of problems with the context such as security failures, or it
-	 *             may be because the reference is inherently not possible to
-	 *             de-reference (as in the case of a non-serializable API
-	 *             consumer reference).
-	 */
-	InputStream openStream(ReferenceContext context)
-			throws DereferenceException;
-
-	/**
-	 * Approximate size of the stored data or -1 if we do not know.
-	 */
-	Long getApproximateSizeInBytes();
-
-	/**
-	 * Resolution cost is an informal guide to how costly the process of
-	 * de-referencing this reference would be. It's used when assessing which
-	 * out of a set of ExternalReferenceSPI implementations to use to get the
-	 * value of the reference(s), in particular when rendering to POJOs or when
-	 * translating throught the de-reference / construct from stream route. As
-	 * this property is highly complex and potentially expensive in itself to
-	 * evaluate there's no requirement for it to be absolutely correct, it's
-	 * just used as a guide that, for example, it is easier to get bytes from a
-	 * file on the local disk than to get them from a resource held on a grid on
-	 * the other side of the planet.
-	 * 
-	 * @return a float representing some notion of resolution cost, lower values
-	 *         represent cheaper de-reference paths.
-	 */
-	float getResolutionCost();
-
-	ExternalReferenceSPI clone() throws CloneNotSupportedException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceTranslatorSPI.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceTranslatorSPI.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceTranslatorSPI.java
deleted file mode 100644
index bc46dce..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceTranslatorSPI.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * Constructs an ExternalReference instance from an existing ExternalReference,
- * most usually of a different type. Used by the {@link ReferenceSetAugmentor}.
- * This SPI should not be used for cases where an ExternalReferenceSPI is
- * constructed from a stream of bytes, this is intended for direct reference to
- * reference translation with the assumption that this is more efficient for
- * whatever reason. For cases where the reference is constructed from a byte
- * stream you should implement {@link ExternalReferenceBuilder} instead.
- * <p>
- * For SPI purposes implementations should be java beans with default
- * constructors, any required state such as the location of remote repositories
- * to which data can be staged will be passed in in the ReferenceContext.
- * 
- * @author Tom Oinn
- */
-public interface ExternalReferenceTranslatorSPI<SourceType extends ExternalReferenceSPI, TargetType extends ExternalReferenceSPI> {
-	/**
-	 * Given an existing ExternalReferenceSPI, build the appropriate target
-	 * ExternalReferenceSPI implementation and return it.
-	 * 
-	 * @param sourceReference
-	 *            the reference to be used as source for the translation.
-	 * @param context
-	 *            a reference resolution context, needed potentially to access
-	 *            the existing external references or to construct the new one,
-	 *            especially in cases where the context contains security agents
-	 *            giving access to a remote data staging system
-	 * @throws ExternalReferenceConstructionException
-	 *             if an error occurs instantiating the new reference.
-	 * @return the newly constructed ExternalReferenceSPI instance.
-	 */
-	TargetType createReference(SourceType sourceReference,
-			ReferenceContext context);
-
-	/**
-	 * Return the type of external reference that this translator consumes.
-	 * 
-	 * @return ExternalReferenceSPI class corresponding to the reference type
-	 *         used as a source by this translator.
-	 */
-	Class<SourceType> getSourceReferenceType();
-
-	/**
-	 * Return the type of external reference this translator constructs.
-	 * 
-	 * @return ExternalReferenceSPI class corresponding to the reference type
-	 *         emitted by this translator.
-	 */
-	Class<TargetType> getTargetReferenceType();
-
-	/**
-	 * Because the reference translator may rely on facilities provided to it
-	 * through the context this method is available to check whether these
-	 * facilities are sufficient.
-	 * 
-	 * @param context
-	 *            the reference context that will be used to construct new
-	 *            references during the translation process
-	 * @return whether the context contains necessary resources for the
-	 *         reference construction process
-	 */
-	boolean isEnabled(ReferenceContext context);
-
-	/**
-	 * Return an approximate complexity cost of the translation. In general we
-	 * can't make any guarantees about this because the complexity of the
-	 * translation depends on more than just the types involved - it can depend
-	 * on local configuration, network location relative to the data stores
-	 * referenced and in some cases on the data themselves. For now though we
-	 * assign an approximation, the default value is 1.0f and lower values
-	 * represent less costly operations.
-	 */
-	float getTranslationCost();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceValidationException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceValidationException.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceValidationException.java
deleted file mode 100644
index c8b540d..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceValidationException.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * Thrown by setter methods and constructors of ExternalReferenceSPI
- * implementations when fed parameters which cause some kind of format or
- * validation error. These might include badly formed URL or file paths or any
- * other property that fails to validate against some reference type specific
- * scheme.
- * 
- * @author Tom Oinn
- */
-public class ExternalReferenceValidationException extends RuntimeException {
-	private static final long serialVersionUID = 3031393671457773057L;
-
-	public ExternalReferenceValidationException() {
-		//
-	}
-
-	public ExternalReferenceValidationException(String message) {
-		super(message);
-	}
-
-	public ExternalReferenceValidationException(Throwable cause) {
-		super(cause);
-	}
-
-	public ExternalReferenceValidationException(String message, Throwable cause) {
-		super(message, cause);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/Identified.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/Identified.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/Identified.java
deleted file mode 100644
index 8e9c5fd..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/Identified.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * Interface for any object that has an associated {@link T2Reference}
- * 
- * @author Tom Oinn
- */
-public interface Identified {
-	/**
-	 * Return an appropriately configured instance of T2Reference for this
-	 * identified object.
-	 * 
-	 * @return the id of this object in the form of a T2Reference
-	 */
-	T2Reference getId();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/IdentifiedList.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/IdentifiedList.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/IdentifiedList.java
deleted file mode 100644
index 032906f..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/IdentifiedList.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-import java.util.List;
-
-/**
- * An identified list is a list which is identified by a T2Reference. Lists are
- * immutable once named - if getId() returns a non null value all list methods
- * modifying the underlying list data will throw {@link IllegalStateException}.
- * In the reference management API this list sub-interface is used to represent
- * both collections of identifiers (i.e. 'raw' stored lists) and more fully
- * resolved structures where the types in the list can be reference sets, error
- * documents and other lists of such. The {@link ListDao} interface uses only
- * the 'raw' form consisting of flat lists of identifiers.
- * <p>
- * The IdentifiedList has a unique T2Reference associated with it. If this is
- * null the contents of the list may be modified, otherwise all modification
- * operations throw {@link IllegalStateException}. Lists in T2, once named, are
- * immutable.
- * 
- * @author Tom Oinn
- * 
- * @param <T>
- */
-public interface IdentifiedList<T> extends List<T>, Identified {
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListDao.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListDao.java
deleted file mode 100644
index 7e064be..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListDao.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-import static org.springframework.transaction.annotation.Propagation.REQUIRED;
-import static org.springframework.transaction.annotation.Propagation.SUPPORTS;
-
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * Data access object handling NamedLists of T2Reference instances.
- * 
- * @author Tom Oinn
- */
-public interface ListDao {
-	/**
-	 * Store a named and populated IdentifiedList of T2Reference to the
-	 * database.
-	 * 
-	 * @param theList
-	 *            list to store
-	 * @throws DaoException
-	 *             if any exception is thrown when connecting to the underlying
-	 *             store or when storing the list
-	 */
-	@Transactional(propagation = REQUIRED, readOnly = false)
-	void store(IdentifiedList<T2Reference> theList) throws DaoException;
-
-	/**
-	 * Retrieves a named and populated IdentifiedList of T2Reference from the
-	 * database by T2Reference
-	 * 
-	 * @param reference
-	 *            id of the list to retrieve
-	 * @return a previously stored list of T2References
-	 * @throws DaoException
-	 *             if any exception is thrown when connecting to the underlying
-	 *             data store or when attempting retrieval of the list
-	 */
-	@Transactional(propagation = SUPPORTS, readOnly = true)
-	IdentifiedList<T2Reference> get(T2Reference reference) throws DaoException;
-
-	@Transactional(propagation = SUPPORTS, readOnly = false)
-	boolean delete(IdentifiedList<T2Reference> theList) throws DaoException;
-
-	@Transactional(propagation = SUPPORTS, readOnly = false)
-	void deleteIdentifiedListsForWFRun(String workflowRunId)
-			throws DaoException;
-}


[03/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/impl/ActivityOutputPortImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/impl/ActivityOutputPortImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/impl/ActivityOutputPortImpl.java
deleted file mode 100644
index 530d81c..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/impl/ActivityOutputPortImpl.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.activity.impl;
-
-import java.util.Set;
-
-import net.sf.taverna.t2.annotation.AnnotationChain;
-import net.sf.taverna.t2.workflowmodel.AbstractOutputPort;
-import net.sf.taverna.t2.workflowmodel.EditException;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityOutputPort;
-
-import org.apache.log4j.Logger;
-
-/**
- * An output port on an Activity instance, used as a bean to hold port name,
- * depth and granular depth properties.
- * 
- * @author Tom Oinn
- */
-public class ActivityOutputPortImpl extends AbstractOutputPort implements ActivityOutputPort {
-	private static Logger logger = Logger.getLogger(ActivityOutputPortImpl.class);
-
-	/**
-	 * Constructs an Activity output port instance with the provided name,depth
-	 * and granular depth.
-	 * 
-	 * @param portName
-	 * @param portDepth
-	 * @param granularDepth
-	 */
-	public ActivityOutputPortImpl(String portName, int portDepth,
-			int granularDepth) {
-		super(portName, portDepth, granularDepth);
-	}
-
-	/**
-	 * Constructs an Activity input port with the provided name, depth and
-	 * granularDepth together with a list of predetermined annotations.
-	 * 
-	 * @param portName
-	 * @param portDepth
-	 * @param granularDepth
-	 * @param annotations
-	 */
-	public ActivityOutputPortImpl(String portName, int portDepth,
-			int granularDepth, Set<AnnotationChain> annotations) {
-		this(portName, portDepth, granularDepth);
-		for (AnnotationChain newAnnotation : annotations)
-			try {
-				getAddAnnotationEdit(newAnnotation).doEdit();
-			} catch (EditException e) {
-				// TODO Auto-generated catch block
-				logger.error(e);
-			}
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/impl/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/impl/package.html b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/impl/package.html
deleted file mode 100644
index c985eee..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/impl/package.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<body>
-Contains specific implementations of the Activity Ports, together with an implementation of ActivityPortBuilder which is responsible for building them.
-</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/impl/AbstractDispatchLayerEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/impl/AbstractDispatchLayerEdit.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/impl/AbstractDispatchLayerEdit.java
deleted file mode 100644
index bd46611..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/impl/AbstractDispatchLayerEdit.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.impl;
-
-import net.sf.taverna.t2.workflowmodel.Edit;
-import net.sf.taverna.t2.workflowmodel.EditException;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchStack;
-
-/**
- * Abstraction of an edit acting on a DispatchLayer instance. Handles the check to
- * see that the DispatchLayer supplied is really a DispatchLayerImpl.
- * 
- * @author Tom Oinn
- * 
- */
-public abstract class AbstractDispatchLayerEdit implements Edit<DispatchStack> {
-	private boolean applied = false;
-	private DispatchStackImpl stack;
-
-	protected AbstractDispatchLayerEdit(DispatchStack s) {
-		if (s == null)
-			throw new RuntimeException(
-					"Cannot construct a dispatch stack edit with null dispatch stack");
-		if (!(s instanceof DispatchStackImpl))
-			throw new RuntimeException(
-					"Edit cannot be applied to a DispatchStack which isn't "
-					+ "an instance of DispatchStackImpl");
-		stack = (DispatchStackImpl) s;
-	}
-
-	@Override
-	public final DispatchStack doEdit() throws EditException {
-		if (applied)
-			throw new EditException("Edit has already been applied!");
-		synchronized (stack) {
-			doEditAction(stack);
-			applied = true;
-			return stack;
-		}
-	}
-
-	/**
-	 * Do the actual edit here
-	 * 
-	 * @param processor
-	 *            The ProcessorImpl to which the edit applies
-	 * @throws EditException
-	 */
-	protected abstract void doEditAction(DispatchStackImpl stack)
-			throws EditException;
-
-	/**
-	 * Undo any edit effects here
-	 */
-	protected void undoEditAction(DispatchStackImpl stack) {
-		throw new RuntimeException("undo not supported in the t2 model in T3");
-	}
-
-	@Override
-	public final DispatchStack getSubject() {
-		return stack;
-	}
-
-	@Override
-	public final boolean isApplied() {
-		return this.applied;
-	}
-
-	@Override
-	public final void undo() {
-		if (!applied)
-			throw new RuntimeException(
-					"Attempt to undo edit that was never applied");
-		synchronized (stack) {
-			undoEditAction(stack);
-			applied = false;
-		}
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/impl/DispatchStackImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/impl/DispatchStackImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/impl/DispatchStackImpl.java
deleted file mode 100644
index 527e2cc..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/impl/DispatchStackImpl.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.impl;
-
-import static java.util.Collections.unmodifiableList;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-
-import net.sf.taverna.t2.annotation.AbstractAnnotatedThing;
-import net.sf.taverna.t2.invocation.Completion;
-import net.sf.taverna.t2.invocation.IterationInternalEvent;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Job;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.AbstractDispatchLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchStack;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.NotifiableLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchCompletionEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchErrorEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchJobQueueEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchResultEvent;
-
-import org.apache.log4j.Logger;
-
-/**
- * The dispatch stack is responsible for consuming a queue of jobs from the
- * iteration strategy and dispatching those jobs through a stack based control
- * flow to an appropriate invocation target. Conceptually the queue and
- * description of activities enter the stack at the top, travel down to an
- * invocation layer at the bottom from which results, errors and completion
- * events rise back up to the top layer. Dispatch stack layers are stored as an
- * ordered list with index 0 being the top of the stack.
- * 
- * @author Tom Oinn
- * @author Stian Soiland-Reyes
- * @author David Withers
- */
-public abstract class DispatchStackImpl extends
-		AbstractAnnotatedThing<DispatchStack> implements DispatchStack {
-	private static Logger logger = Logger.getLogger(DispatchStackImpl.class);
-	private Map<String, BlockingQueue<IterationInternalEvent<? extends IterationInternalEvent<?>>>> queues = new HashMap<>();
-	private List<DispatchLayer<?>> dispatchLayers = new ArrayList<>();
-
-	/**
-	 * Override to return the list of activities to be used by this dispatch
-	 * stack.
-	 * 
-	 * @return list of activities to be used by jobs in this dispatch stack
-	 */
-	protected abstract List<? extends Activity<?>> getActivities();
-
-	/**
-	 * Called when an event (Completion or Job) hits the top of the dispatch
-	 * stack and needs to be pushed out of the processor
-	 * 
-	 * @param e
-	 */
-	protected abstract void pushEvent(
-			IterationInternalEvent<? extends IterationInternalEvent<?>> e);
-
-	/**
-	 * Called to determine whether all the preconditions for this dispatch stack
-	 * are satisfied. Jobs with the given owningProcess are not processed by the
-	 * dispatch stack until this returns true. Once it has returned true for a
-	 * given owning process it must always return true, the precondition is not
-	 * allowed to change from true back to false.
-	 * 
-	 * @param owningProcess
-	 * @return whether all preconditions to invocation are satisfied.
-	 */
-	protected abstract boolean conditionsSatisfied(String owningProcess);
-
-	/**
-	 * Called when the specified owning process is finished with, that is to say
-	 * all invocation has been performed and any layer state caches have been
-	 * purged.
-	 * 
-	 * @param owningProcess
-	 */
-	protected abstract void finishedWith(String owningProcess);
-
-	/**
-	 * Defines the enclosing process name, usually Processor.getName() on the
-	 * parent
-	 */
-	protected abstract String getProcessName();
-
-	private DispatchLayer<Object> topLayer = new TopLayer();
-
-	/**
-	 * Receive an event to be fed into the top layer of the dispatch stack for
-	 * processing. This has the effect of creating a queue if there isn't one
-	 * already, honouring any conditions that may be defined by an enclosing
-	 * processor through the conditionsSatisfied() check method.
-	 * <p>
-	 * Because the condition checking logic must check against the enclosing
-	 * process any attempt to call this method with an owning process without a
-	 * colon in will fail with an index array out of bounds error. All owning
-	 * process identifiers must resemble 'enclosingProcess:processorName' at the
-	 * minimum.
-	 * 
-	 * @param event
-	 */
-	@SuppressWarnings({ "unchecked", "rawtypes" })
-	public void receiveEvent(IterationInternalEvent event) {
-		BlockingQueue<IterationInternalEvent<? extends IterationInternalEvent<?>>> queue = null;
-		String owningProcess = event.getOwningProcess();
-		String enclosingProcess = owningProcess.substring(0, owningProcess
-				.lastIndexOf(':'));
-		synchronized (queues) {
-			queue = queues.get(owningProcess);
-			if (queue == null) {
-				queue = new LinkedBlockingQueue<>();
-				queues.put(owningProcess, queue);
-				queue.add(event);
-
-				/*
-				 * If all preconditions are satisfied push the queue to the
-				 * dispatch layer
-				 */
-				if (conditionsSatisfied(enclosingProcess))
-					firstLayer().receiveJobQueue(
-							new DispatchJobQueueEvent(owningProcess, event
-									.getContext(), queue, getActivities()));
-			} else {
-				queue.add(event);
-
-				/*
-				 * If all preconditions are satisfied then notify the queue
-				 * addition to any NotifiableLayer instances. If the
-				 * preconditions are not satisfied the queue isn't visible to
-				 * the dispatch stack yet so do nothing.
-				 */
-				if (conditionsSatisfied(enclosingProcess))
-					for (DispatchLayer layer : dispatchLayers)
-						if (layer instanceof NotifiableLayer)
-							((NotifiableLayer) layer).eventAdded(owningProcess);
-			}
-		}
-	}
-
-
-
-	/**
-	 * Called when a set of conditions which were unsatisfied in the context of
-	 * a given owning process become satisfied. At this point any jobs in the
-	 * queue for that owning process identifier should be pushed through to the
-	 * dispatch mechanism. As the queue itself will not have been pushed through
-	 * at this point this just consists of messaging the first layer with the
-	 * queue and activity set.
-	 * 
-	 * @param owningProcess
-	 */
-	public void satisfyConditions(String enclosingProcess) {
-		if (conditionsSatisfied(enclosingProcess)) {
-			String owningProcess = enclosingProcess + ":" + getProcessName();
-			synchronized (queues) {
-				if (queues.containsKey(owningProcess)) {
-					/*
-					 * At least one event has been received with this process ID
-					 * and a queue exists for it.
-					 */
-					firstLayer()
-							.receiveJobQueue(
-									new DispatchJobQueueEvent(owningProcess,
-											queues.get(owningProcess).peek()
-													.getContext(), queues
-													.get(owningProcess),
-											getActivities()));
-				} else {
-					/*
-					 * Do nothing, if the conditions are satisfied before any
-					 * jobs are received this mechanism is effectively redundant
-					 * and the normal notification system for the events will
-					 * let everything work through as per usual
-					 */
-				}
-			}
-		}
-	}
-
-	@Override
-	public List<DispatchLayer<?>> getLayers() {
-		return unmodifiableList(this.dispatchLayers);
-	}
-
-	public void addLayer(DispatchLayer<?> newLayer) {
-		dispatchLayers.add(newLayer);
-		newLayer.setDispatchStack(this);
-	}
-
-	public void addLayer(DispatchLayer<?> newLayer, int index) {
-		dispatchLayers.add(index, newLayer);
-		newLayer.setDispatchStack(this);
-	}
-
-	public int removeLayer(DispatchLayer<?> layer) {
-		int priorIndex = dispatchLayers.indexOf(layer);
-		dispatchLayers.remove(layer);
-		return priorIndex;
-	}
-
-	/**
-	 * Return the layer above (lower index!) the specified layer, or a reference
-	 * to the internal top layer dispatch layer if there is no layer above the
-	 * specified one. Remember - input data and activities go down, results,
-	 * errors and completion events bubble back up the dispatch stack.
-	 * <p>
-	 * The top layer within the dispatch stack is always invisible and is held
-	 * within the DispatchStackImpl object itself, being used to route data out
-	 * of the entire stack
-	 * 
-	 * @param layer
-	 * @return
-	 */
-	@Override
-	public DispatchLayer<?> layerAbove(DispatchLayer<?> layer) {
-		int layerIndex = dispatchLayers.indexOf(layer);
-		if (layerIndex > 0)
-			return dispatchLayers.get(layerIndex - 1);
-		if (layerIndex == 0)
-			return topLayer;
-		return null;
-	}
-
-	/**
-	 * Return the layer below (higher index) the specified layer, or null if
-	 * there are no layers below this one
-	 */
-	@Override
-	public DispatchLayer<?> layerBelow(DispatchLayer<?> layer) {
-		int layerIndex = dispatchLayers.indexOf(layer) + 1;
-		if (layerIndex >= dispatchLayers.size())
-			return null;
-		return dispatchLayers.get(layerIndex);
-	}
-	
-	protected DispatchLayer<?> firstLayer() {
-		return dispatchLayers.get(0);
-	}
-
-	protected class TopLayer extends AbstractDispatchLayer<Object> {
-		@Override
-		public void receiveResult(DispatchResultEvent resultEvent) {
-			DispatchStackImpl.this.pushEvent(new Job(resultEvent
-					.getOwningProcess(), resultEvent.getIndex(), resultEvent
-					.getData(), resultEvent.getContext()));
-			if (resultEvent.getIndex().length == 0)
-				sendCachePurge(resultEvent.getOwningProcess());
-		}
-
-		/*
-		 * TODO - implement top level error handling, if an error bubbles up to
-		 * the top layer of the dispatch stack it's trouble and probably fails
-		 * this process
-		 */
-		@Override
-		public void receiveError(DispatchErrorEvent errorEvent) {
-			logger.error("Error received in dispatch stack on owningProcess:"
-					+ errorEvent.getOwningProcess() + ", msg:"
-					+ errorEvent.getMessage(), errorEvent.getCause());
-			if (errorEvent.getIndex().length == 0)
-				sendCachePurge(errorEvent.getOwningProcess());
-		}
-
-		@Override
-		public void receiveResultCompletion(
-				DispatchCompletionEvent completionEvent) {
-			Completion c = new Completion(completionEvent.getOwningProcess(),
-					completionEvent.getIndex(), completionEvent.getContext());
-			DispatchStackImpl.this.pushEvent(c);
-			if (c.isFinal())
-				sendCachePurge(c.getOwningProcess());
-		}
-
-		private void sendCachePurge(String owningProcess) {
-			for (DispatchLayer<?> layer : dispatchLayers)
-				layer.finishedWith(owningProcess);
-			DispatchStackImpl.this.finishedWith(owningProcess);
-			queues.remove(owningProcess);
-		}
-
-		@Override
-		public void configure(Object config) {
-			// TODO Auto-generated method stub
-		}
-
-		@Override
-		public Object getConfiguration() {
-			// TODO Auto-generated method stub
-			return null;
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/impl/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/impl/package.html b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/impl/package.html
deleted file mode 100644
index 52dcb5a..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/impl/package.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<body>
-Implementation package for the dispatch stack interfaces. Contains
-DispatchStack implementation and edit objects to modify it, actual
-dispatch layer implementations are held elsewhere (in third party
-plugins and in the
-net.sf.taverna.t2.workflowmodel.processor.dispatch.layers package for
-internal layers)
-</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/impl/IterationStrategyImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/impl/IterationStrategyImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/impl/IterationStrategyImpl.java
deleted file mode 100644
index b734cc2..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/impl/IterationStrategyImpl.java
+++ /dev/null
@@ -1,345 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.iteration.impl;
-
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import net.sf.taverna.t2.invocation.Completion;
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.invocation.IterationInternalEvent;
-import net.sf.taverna.t2.reference.ContextualizedT2Reference;
-import net.sf.taverna.t2.reference.ReferenceService;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.WorkflowStructureException;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Job;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.AbstractIterationStrategyNode;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.CrossProduct;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.DotProduct;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.IterationStrategy;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.IterationTypeMismatchException;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.NamedInputPortNode;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.PrefixDotProduct;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.TerminalNode;
-
-import org.jdom.Element;
-
-/**
- * A single layer of iteration strategy, consuming individual named inputs and
- * combining these into Job objects to be consumed by the dispatch stack
- * 
- * @author Tom Oinn
- * @author Stian Soiland-Reyes
- * 
- */
-public class IterationStrategyImpl implements IterationStrategy {
-	Set<NamedInputPortNode> inputs;
-	private boolean wrapping = false;
-	protected IterationStrategyStackImpl stack = null;
-	private TerminalNodeImpl terminal = new TerminalNodeImpl();
-
-	private void pushEvent(IterationInternalEvent<?> e) {
-		if (stack == null)
-			return;
-		IterationStrategyImpl below = stack
-				.layerBelow(IterationStrategyImpl.this);
-		if (below == null)
-			stack.receiveEventFromStrategy(e);
-		else
-			below.receiveEvent(e);
-	}
-
-	/**
-	 * The terminal node is used internally as the root of the iteration
-	 * strategy tree, it is responsible for forwarding all events up to the
-	 * iteration strategy itself which can then propogate them to the strategy
-	 * stack.
-	 */
-	@SuppressWarnings("serial")
-	public class TerminalNodeImpl extends TerminalNode {
-		private IterationInternalEvent<?> unwrap(IterationInternalEvent<?> completion) {
-			return (wrapping ? completion.popIndex() : completion);
-		}
-
-		@Override
-		public void receiveCompletion(int inputIndex, Completion completion) {
-			pushEvent(unwrap(completion));
-		}
-
-		@Override
-		public void receiveJob(int inputIndex, Job newJob) {
-			pushEvent(unwrap(newJob));
-		}
-
-		public void receiveBypassCompletion(Completion completion) {
-			pushEvent(completion);
-		}
-
-		@Override
-		public int getIterationDepth(Map<String, Integer> inputDepths)
-				throws IterationTypeMismatchException {
-			if (getChildCount() == 0)
-				return -1;
-			return getChildAt(0).getIterationDepth(inputDepths);
-		}
-	}
-
-	public IterationStrategyImpl() {
-		inputs = new HashSet<>();
-	}
-
-	@Override
-	public TerminalNode getTerminalNode() {
-		return terminal;
-	}
-
-	/**
-	 * Configure from an XML element
-	 * 
-	 * @param strategyElement
-	 */
-	@SuppressWarnings("unchecked")
-	protected void configureFromXML(Element strategyElement) {
-		inputs.clear();
-		terminal.clear();
-		if (!strategyElement.getChildren().isEmpty())
-			for (Element childElement : (List<Element>) strategyElement
-					.getChildren())
-				nodeForElement(childElement).setParent(terminal);
-	}
-
-	private AbstractIterationStrategyNode nodeForElement(Element e) {
-		AbstractIterationStrategyNode node = null;
-		String eName = e.getName();
-		if (eName.equals("dot"))
-			node = new DotProduct();
-		else if (eName.equals("cross"))
-			node = new CrossProduct();
-		else if (eName.equals("prefix"))
-			node = new PrefixDotProduct();
-		else if (eName.equals("port")) {
-			NamedInputPortNode nipn = new NamedInputPortNode(
-					e.getAttributeValue("name"), Integer.parseInt(e
-							.getAttributeValue("depth")));
-			node = nipn;
-			addInput(nipn);
-		}
-		for (Object child : e.getChildren())
-			nodeForElement((Element) child).setParent(node);
-		return node;
-	}
-
-	/**
-	 * Receive a single job from an upstream IterationStrategyImpl in the stack.
-	 * This job will have one or more data parts where the cardinality doesn't
-	 * match that defined by the NamedInputPortNode and will need to be split up
-	 * appropriately
-	 * 
-	 * @param j
-	 */
-	protected void receiveEvent(IterationInternalEvent<?> e) {
-		/*
-		 * If we ever get this method called we know we're not the top layer in
-		 * the dispatch stack and that we need to perform wrap / unwrap of data
-		 * as it comes in. This boolean flag informs the behaviour of the
-		 * terminal node in the strategy.
-		 */
-		wrapping = true;
-		/*
-		 * If this is a Job object then we'll need to split it up and push it
-		 * through the iteration system to get multiple child jobs followed by a
-		 * completion event otherwise we can just push the completion event all
-		 * the way through the system.
-		 */
-		if (e instanceof Job) {
-			Job j = ((Job) e).pushIndex();
-			// Now have to split this job up into a number of distinct events!
-			String owningProcess = j.getOwningProcess();
-			for (String portName : j.getData().keySet()) {
-				T2Reference dataRef = j.getData().get(portName);
-				ReferenceService rs = e.getContext().getReferenceService();
-				NamedInputPortNode ipn = nodeForName(portName);
-				int desiredDepth = ipn.getCardinality();
-				Iterator<ContextualizedT2Reference> ids = rs.traverseFrom(
-						dataRef, desiredDepth);
-				while (ids.hasNext()) {
-					ContextualizedT2Reference ci = ids.next();
-					int[] indexArray = ci.getIndex();
-					T2Reference childDataRef = ci.getReference();
-					receiveData(portName, owningProcess, indexArray,
-							childDataRef, e.getContext());
-				}
-				receiveCompletion(portName, owningProcess, new int[] {}, e
-						.getContext());
-			}
-		} else {
-			/*
-			 * Event was a completion event, push it through unmodified to the
-			 * terminal node. Intermediate completion events from the split of
-			 * an input Job into multiple events through data structure
-			 * traversal are unwrapped but as this one is never wrapped in the
-			 * first place we need a way to mark it as such, the call to the
-			 * bypass method achieves this
-			 */
-			terminal.receiveBypassCompletion((Completion) e);
-		}
-	}
-
-	/**
-	 * Receive a single data event from an upstream process. This method is only
-	 * ever called on the first layer in the IterationStrategyStackImpl, other
-	 * layers are passed entire Job objects
-	 * 
-	 * @param inputPortName
-	 * @param owningProcess
-	 * @param indexArray
-	 * @param dataReference
-	 * @throws WorkflowStructureException
-	 */
-	public void receiveData(String inputPortName, String owningProcess,
-			int[] indexArray, T2Reference dataReference,
-			InvocationContext context) throws WorkflowStructureException {
-		Map<String, T2Reference> dataMap = new HashMap<>();
-		dataMap.put(inputPortName, dataReference);
-		Job newJob = new Job(owningProcess, indexArray, dataMap, context);
-		nodeForName(inputPortName).receiveJob(0, newJob);
-	}
-
-	public void receiveCompletion(String inputPortName, String owningProcess,
-			int[] completionArray, InvocationContext context)
-			throws WorkflowStructureException {
-		nodeForName(inputPortName).receiveCompletion(0,
-				new Completion(owningProcess, completionArray, context));
-	}
-
-	public void addInput(NamedInputPortNode nipn) {
-		synchronized (inputs) {
-			inputs.add(nipn);
-		}
-	}
-
-	public void removeInput(NamedInputPortNode nipn) {
-		synchronized (inputs) {
-			inputs.remove(nipn);
-		}
-	}
-
-	public void removeInputByName(String name) {
-		synchronized (inputs) {
-			NamedInputPortNode removeMe = null;
-			for (NamedInputPortNode nipn : inputs)
-				if (nipn.getPortName().equals(name))
-					removeMe = nipn;
-			if (removeMe != null) {
-				inputs.remove(removeMe);
-				removeMe.removeFromParent();
-			}
-		}
-	}
-
-	private NamedInputPortNode nodeForName(String portName)
-			throws WorkflowStructureException {
-		for (NamedInputPortNode node : inputs)
-			if (node.getPortName().equals(portName))
-				return node;
-		throw new WorkflowStructureException("No port found with name '"
-				+ portName + "'");
-	}
-
-	public void setIterationStrategyStack(IterationStrategyStackImpl stack) {
-		this.stack = stack;
-	}
-
-	/**
-	 * Connect up a new named input port node to the first child of the terminal
-	 * node. If the terminal node doesn't have any children then create a new
-	 * cross product node, connect it to the terminal and connect the new input
-	 * port node to the cross product (saneish default behaviour)
-	 * 
-	 * @param nipn
-	 */
-	public synchronized void connectDefault(NamedInputPortNode nipn) {
-		if (terminal.getChildCount() == 0) {
-			CrossProduct cp = new CrossProduct();
-			cp.setParent(terminal);
-			nipn.setParent(cp);
-		} else
-			nipn.setParent((AbstractIterationStrategyNode) terminal
-					.getChildAt(0));
-	}
-
-	@Override
-	public int getIterationDepth(Map<String, Integer> inputDepths)
-			throws IterationTypeMismatchException {
-		return getTerminalNode().getIterationDepth(inputDepths);
-	}
-
-	@Override
-	public Map<String, Integer> getDesiredCardinalities() {
-		Map<String, Integer> result = new HashMap<>();
-		for (NamedInputPortNode nipn : inputs)
-			result.put(nipn.getPortName(), nipn.getCardinality());
-		return result;
-	}
-
-	@Override
-	public void normalize() {
-		boolean finished = false;
-		do {
-			finished = true;
-			@SuppressWarnings("unchecked")
-			Enumeration<AbstractIterationStrategyNode> e = getTerminalNode()
-					.breadthFirstEnumeration();
-			while (e.hasMoreElements() && finished == true) {
-				AbstractIterationStrategyNode n = e.nextElement();
-				AbstractIterationStrategyNode parent = (AbstractIterationStrategyNode) n
-						.getParent();
-				// Check whether anything needs doing
-
-				// Check for collation nodes with no children
-				if (!(n instanceof NamedInputPortNode) && parent != null
-						&& n.getChildCount() == 0) {
-					// Remove the node from its parent and set finished to false
-					parent.remove(n);
-					finished = false;
-				} else if (!(n.isLeaf()) && parent != null
-						&& n.getChildCount() == 1) {
-					/*
-					 * Is a collation node with a single child, and therefore
-					 * pointless. Replace it with the child node
-					 */
-					AbstractIterationStrategyNode child = (AbstractIterationStrategyNode) n
-							.getChildAt(0);
-					// Find the index of the collation node in its parent
-					int oldIndex = parent.getIndex(n);
-					parent.remove(n);
-					parent.insert(child, oldIndex);
-					finished = false;
-				}
-			}
-		} while (!finished);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/impl/IterationStrategyStackImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/impl/IterationStrategyStackImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/impl/IterationStrategyStackImpl.java
deleted file mode 100644
index 407c3de..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/impl/IterationStrategyStackImpl.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.iteration.impl;
-
-import static java.util.Collections.unmodifiableList;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.invocation.IterationInternalEvent;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.WorkflowStructureException;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.IterationStrategy;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.IterationStrategyStack;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.IterationTypeMismatchException;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.MissingIterationInputException;
-
-/**
- * Contains an ordered list of IterationStrategyImpl objects. The top of the
- * list is fed data directly, all other nodes are fed complete Job objects and
- * Completion events from the layer above. The bottom layer pushes events onto
- * the processor event queue to be consumed by the dispatch stack.
- * 
- * @author Tom Oinn
- * 
- */
-public class IterationStrategyStackImpl implements IterationStrategyStack {
-	private List<IterationStrategyImpl> strategies = new ArrayList<>();
-
-	/**
-	 * The iteration depth here is calculated by taking first the top iteration
-	 * strategy and applying the actual input types to it, then for each
-	 * subsequent strategy in the stack using the 'desired cardinality' of the
-	 * input nodes for each layer to work out the increase in index array
-	 * length.
-	 * 
-	 * @param inputDepths
-	 * @return
-	 * @throws IterationTypeMismatchException
-	 */
-	@Override
-	public int getIterationDepth(Map<String, Integer> inputDepths)
-			throws IterationTypeMismatchException,
-			MissingIterationInputException {
-		/*
-		 * If there are no iteration strategies or no inputs then by definition
-		 * there's no iteration, no wrapping and the depth of wrapping must be
-		 * zero
-		 */
-		if (strategies.isEmpty())
-			return 0;
-		if (strategies.get(0).inputs.isEmpty())
-			return 0;
-
-		IterationStrategyImpl strategy = strategies.get(0);
-		int depth = strategy.getIterationDepth(inputDepths);
-		for (int index = 1; index < strategies.size(); index++) {
-			/*
-			 * Construct the input depths for the staged iteration strategies
-			 * after the first one by looking at the previous iteration
-			 * strategy's desired cardinalities on its input ports.
-			 */
-			Map<String, Integer> stagedInputDepths = strategy
-					.getDesiredCardinalities();
-			strategy = strategies.get(index);
-			depth += strategy.getIterationDepth(stagedInputDepths);
-		}
-		return depth;
-	}
-
-	public void addStrategy(IterationStrategy is) {
-		if (!(is instanceof IterationStrategyImpl))
-			throw new WorkflowStructureException(
-					"IterationStrategyStackImpl can only hold IterationStrategyImpl objects");
-		IterationStrategyImpl isi = (IterationStrategyImpl) is;
-		strategies.add(isi);
-		isi.setIterationStrategyStack(this);
-	}
-
-	public void removeStrategy(IterationStrategy is) {
-		if (!(is instanceof IterationStrategyImpl))
-			throw new WorkflowStructureException(
-					"IterationStrategyStackImpl can only hold IterationStrategyImpl objects");
-		IterationStrategyImpl isi = (IterationStrategyImpl) is;
-		strategies.remove(isi);
-		isi.setIterationStrategyStack(null);
-	}
-
-	@Override
-	public List<IterationStrategyImpl> getStrategies() {
-		return unmodifiableList(this.strategies);
-	}
-
-	public void clear() {
-		strategies.clear();		
-	}
-	
-	public void receiveData(String inputPortName, String owningProcess,
-			int[] indexArray, T2Reference dataReference, InvocationContext context) {
-		if (!strategies.isEmpty())
-			strategies.get(0).receiveData(inputPortName, owningProcess,
-					indexArray, dataReference, context);
-	}
-
-	public void receiveCompletion(String inputPortName, String owningProcess,
-			int[] completionArray, InvocationContext context) {
-		if (!strategies.isEmpty())
-			strategies.get(0).receiveCompletion(inputPortName, owningProcess,
-					completionArray, context);
-	}
-
-	/**
-	 * Return the layer below the specified one, or null if there is no lower
-	 * layer
-	 * 
-	 * @return
-	 */
-	protected IterationStrategyImpl layerBelow(IterationStrategyImpl that) {
-		int index = strategies.indexOf(that) + 1;
-		if (index == strategies.size())
-			return null;
-		return strategies.get(index);
-	}
-
-	/**
-	 * Called by the final iteration strategy to push events onto the
-	 * dispatcher's queue
-	 * 
-	 * @param e
-	 */
-	protected void receiveEventFromStrategy(IterationInternalEvent<? extends IterationInternalEvent<?>> e) {
-		// TODO - push events onto dispatch queue
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/impl/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/impl/package.html b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/impl/package.html
deleted file mode 100644
index 86a65ae..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/iteration/impl/package.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<body>
-Implementation logic for the iteration system.
-</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/AnnotationAssertionImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/AnnotationAssertionImpl.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/AnnotationAssertionImpl.java
new file mode 100644
index 0000000..aed31f1
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/AnnotationAssertionImpl.java
@@ -0,0 +1,134 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation.impl;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.taverna.annotation.AnnotationAssertion;
+import org.apache.taverna.annotation.AnnotationBeanSPI;
+import org.apache.taverna.annotation.AnnotationRole;
+import org.apache.taverna.annotation.AnnotationSourceSPI;
+import org.apache.taverna.annotation.CurationEvent;
+import org.apache.taverna.annotation.Person;
+
+public class AnnotationAssertionImpl implements AnnotationAssertion<AnnotationBeanSPI> {
+	
+	private AnnotationBeanSPI annotationBean;
+	private AnnotationRole annotationRole;
+	private Date date;
+	private List<Person> creators;
+	private AnnotationSourceSPI annotationSource;
+	private List<CurationEvent<?>> curationEventList;
+
+	public AnnotationAssertionImpl(){
+		date = new Date();
+		curationEventList = new ArrayList<CurationEvent<?>>();
+		creators = new ArrayList<Person>();
+		
+	}
+	
+	public AnnotationAssertionImpl(AnnotationBeanSPI freeTextDescription, AnnotationRole annotationRole, List<Person> creators, AnnotationSourceSPI annotationSource) {
+		this.annotationBean = freeTextDescription;
+		this.annotationRole = annotationRole;
+		this.creators = creators;
+		this.annotationSource = annotationSource;
+	}
+
+	@Override
+	public AnnotationBeanSPI getDetail() {
+		return annotationBean;
+	}
+
+	@Override
+	public AnnotationRole getRole() {
+		return annotationRole;
+	}
+
+	@Override
+	public Date getCreationDate() {
+		return date;
+	}
+
+	@Override
+	public List<? extends Person> getCreators() {
+		return creators;
+	}
+	
+	public void addCreator(Person person) {
+		creators.add(person);
+	}
+	
+	public void removeCreator(Person person) {
+		creators.remove(person);
+	}
+
+	@Override
+	public List<CurationEvent<?>> getCurationAssertions() {
+		return curationEventList;
+	}
+
+	@Override
+	public AnnotationSourceSPI getSource() {
+		return annotationSource;
+	}
+
+	public void setAnnotationBean(AnnotationBeanSPI annotationBean) {
+		this.annotationBean = annotationBean;
+	}
+
+	public void setAnnotationRole(AnnotationRole annotationRole) {
+		this.annotationRole = annotationRole;
+	}
+	
+	public void removeAnnotationRole() {
+		this.annotationRole = null;
+	}
+
+	public void setDate(Date date) {
+		this.date = date;
+	}
+
+	public void setCreators(List<Person> creators) {
+		this.creators = creators;
+	}
+
+	public void setAnnotationSource(AnnotationSourceSPI annotationSource) {
+		this.annotationSource = annotationSource;
+	}
+	
+	public void removeAnnotationSource() {
+		this.annotationSource = null;
+	}
+
+	public void removeAnnotationBean() {
+		annotationBean = null;
+	}
+	
+	public void addCurationEvent(CurationEvent<?> curationEvent) {
+		curationEventList.add(curationEvent);
+	}
+
+	public void removeCurationEvent(CurationEvent<?> curationEvent) {
+		curationEventList.remove(curationEvent);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/AnnotationChainImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/AnnotationChainImpl.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/AnnotationChainImpl.java
new file mode 100644
index 0000000..21f8d74
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/AnnotationChainImpl.java
@@ -0,0 +1,49 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.taverna.annotation.AnnotationAssertion;
+import org.apache.taverna.annotation.AnnotationChain;
+
+public class AnnotationChainImpl implements AnnotationChain{
+	private List<AnnotationAssertion<?>> annotationAssertions = new ArrayList<>();
+
+	@Override
+	public List<AnnotationAssertion<?>> getAssertions() {
+		return new ArrayList<>(annotationAssertions);
+	}
+	
+	/**
+	 * Add an annotation to the chain Added because without the edits stuff how
+	 * else can we do it?
+	 * 
+	 * @param annotationAssertion
+	 */
+	public void addAnnotationAssertion(AnnotationAssertion<?> annotationAssertion) {
+		annotationAssertions.add(annotationAssertion);
+	}
+	
+	public void removeAnnotationAssertion(AnnotationAssertion<?> annotationAssertion) {
+		annotationAssertions.remove(annotationAssertion);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/DisputeEvent.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/DisputeEvent.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/DisputeEvent.java
new file mode 100644
index 0000000..3896515
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/DisputeEvent.java
@@ -0,0 +1,73 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation.impl;
+
+import org.apache.taverna.annotation.Curateable;
+import org.apache.taverna.annotation.CurationEvent;
+import org.apache.taverna.annotation.CurationEventType;
+
+public class DisputeEvent implements CurationEvent<DisputeEventDetails> {
+	private DisputeEventDetails disputeEventDetails;
+	private CurationEventType curationEventType;
+	private Curateable targetEvent;
+
+	public DisputeEvent() {
+	}
+
+	public DisputeEvent(DisputeEventDetails disputeEventDetails,
+			CurationEventType curationEventType, Curateable targetEvent) {
+		this.disputeEventDetails = disputeEventDetails;
+		this.curationEventType = curationEventType;
+		this.targetEvent = targetEvent;
+	}
+
+	@Override
+	public DisputeEventDetails getDetail() {
+		return disputeEventDetails;
+	}
+
+	@Override
+	public Curateable getTarget() {
+		return targetEvent;
+	}
+
+	@Override
+	public CurationEventType getType() {
+		return curationEventType;
+	}
+
+	public void setDisputeEventDetails(DisputeEventDetails disputeEventDetails) {
+//		if (disputeEventDetails != null)
+//			throw new RuntimeException("Dispute event details have already been set");
+		this.disputeEventDetails = disputeEventDetails;
+	}
+
+	public void setCurationEventType(CurationEventType curationEventType) {
+//		if (curationEventType != null)
+//			throw new RuntimeException("Curation event details have already been set");
+		this.curationEventType = curationEventType;
+	}
+
+	public void setTargetEvent(Curateable targetEvent) {
+//		if (targetEvent!= null)
+//			throw new RuntimeException("Target event details have already been set");
+		this.targetEvent = targetEvent;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/DisputeEventDetails.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/DisputeEventDetails.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/DisputeEventDetails.java
new file mode 100644
index 0000000..3e06028
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/DisputeEventDetails.java
@@ -0,0 +1,27 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation.impl;
+
+import org.apache.taverna.annotation.CurationEventBeanSPI;
+
+public class DisputeEventDetails implements CurationEventBeanSPI {
+	public DisputeEventDetails() {
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/PersonImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/PersonImpl.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/PersonImpl.java
new file mode 100644
index 0000000..942732c
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/PersonImpl.java
@@ -0,0 +1,31 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation.impl;
+
+import org.apache.taverna.annotation.Person;
+
+public class PersonImpl implements Person {
+	@SuppressWarnings("unused")
+	private String name;
+
+	public PersonImpl(String name) {
+		this.name = name;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/URISource.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/URISource.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/URISource.java
new file mode 100644
index 0000000..282817c
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/annotation/impl/URISource.java
@@ -0,0 +1,45 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.annotation.impl;
+
+import java.net.URI;
+
+import org.apache.taverna.annotation.AnnotationSourceSPI;
+
+public class URISource implements AnnotationSourceSPI{
+	private URI uri;
+
+	public URISource() {
+	}
+
+	public URISource(URI uri) {
+		this.uri = uri;
+	}
+
+	public void setUri(URI uri) {
+//		if (uri != null)
+//			throw new RuntimeException("URI has already been set");
+		this.uri = uri;
+	}
+
+	public URI getUri() {
+		return uri;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/facade/impl/WorkflowInstanceFacadeImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/facade/impl/WorkflowInstanceFacadeImpl.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/facade/impl/WorkflowInstanceFacadeImpl.java
new file mode 100644
index 0000000..923ae41
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/facade/impl/WorkflowInstanceFacadeImpl.java
@@ -0,0 +1,630 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.facade.impl;
+
+import static java.lang.System.currentTimeMillis;
+import static java.util.Collections.synchronizedList;
+import static java.util.UUID.randomUUID;
+
+import java.lang.ref.WeakReference;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.UUID;
+import java.util.WeakHashMap;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.taverna.facade.FacadeListener;
+import org.apache.taverna.facade.ResultListener;
+import org.apache.taverna.facade.WorkflowInstanceFacade;
+import org.apache.taverna.facade.WorkflowRunCancellation;
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.invocation.TokenOrderException;
+import org.apache.taverna.invocation.WorkflowDataToken;
+import org.apache.taverna.lang.observer.Observable;
+import org.apache.taverna.lang.observer.Observer;
+import org.apache.taverna.monitor.MonitorManager;
+import org.apache.taverna.monitor.MonitorNode;
+import org.apache.taverna.monitor.MonitorableProperty;
+import org.apache.taverna.monitor.NoSuchPropertyException;
+import org.apache.taverna.provenance.item.DataflowRunComplete;
+import org.apache.taverna.provenance.item.WorkflowDataProvenanceItem;
+import org.apache.taverna.provenance.item.WorkflowProvenanceItem;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.WorkflowRunIdEntity;
+import org.apache.taverna.utility.TypedTreeModel;
+import org.apache.taverna.workflowmodel.Dataflow;
+import org.apache.taverna.workflowmodel.DataflowInputPort;
+import org.apache.taverna.workflowmodel.DataflowOutputPort;
+import org.apache.taverna.workflowmodel.DataflowValidationReport;
+import org.apache.taverna.workflowmodel.EditException;
+import org.apache.taverna.workflowmodel.Edits;
+import org.apache.taverna.workflowmodel.InvalidDataflowException;
+import org.apache.taverna.workflowmodel.Processor;
+import org.apache.taverna.workflowmodel.ProcessorFinishedEvent;
+import org.apache.taverna.workflowmodel.impl.EditsImpl;
+import org.apache.taverna.workflowmodel.impl.ProcessorImpl;
+import org.apache.taverna.workflowmodel.processor.dispatch.DispatchLayer;
+import org.apache.taverna.workflowmodel.processor.dispatch.DispatchStack;
+import org.apache.taverna.workflowmodel.processor.dispatch.layers.ErrorBounce;
+import org.apache.taverna.workflowmodel.processor.dispatch.layers.IntermediateProvenance;
+import org.apache.taverna.workflowmodel.processor.dispatch.layers.Parallelize;
+import org.apache.taverna.workflowmodel.processor.dispatch.layers.Stop;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Implementation of {@link WorkflowInstanceFacade}
+ * 
+ * @author Tom Oinn
+ * @author Stian Soiland-Reyes
+ * @author Ian Dunlop
+ * @author Alex Nenadic
+ */
+public class WorkflowInstanceFacadeImpl implements WorkflowInstanceFacade {
+	private static Logger logger = Logger
+			.getLogger(WorkflowInstanceFacadeImpl.class);
+
+	protected static AtomicLong owningProcessId = new AtomicLong(0);
+	private InvocationContext context;	
+	private State state = State.prepared;
+	public Date stateLastModified = new Date();
+
+	@Override
+	public InvocationContext getContext() {
+		return context;
+	}
+
+	private Dataflow dataflow;
+	private FacadeResultListener facadeResultListener;
+	/** How many processors have finished so far */
+	private int processorsToComplete;
+	private String instanceOwningProcessId;
+	private String localName;
+	private MonitorManager monitorManager = MonitorManager.getInstance();
+	protected List<FacadeListener> facadeListeners = synchronizedList(new ArrayList<FacadeListener>());
+	protected List<ResultListener> resultListeners = synchronizedList(new ArrayList<ResultListener>());
+	private boolean provEnabled = false;
+	private WeakHashMap<String, T2Reference> pushedDataMap = new WeakHashMap<>();
+	/** Id of this run */
+	private String workflowRunId;
+	private Timestamp workflowStarted;
+	private WorkflowProvenanceItem workflowItem = null;
+	private int portsToComplete;
+	
+	private enum WorkflowInstanceFacadeChange {
+		CANCELLATION, PORT_DECREMENT, PROCESSOR_DECREMENT
+	};
+
+	public WorkflowInstanceFacadeImpl(Dataflow dataflow,
+			InvocationContext context, String parentProcess)
+			throws InvalidDataflowException {
+		if (dataflow == null) {
+			logger.error("Dataflow is null");
+			throw new IllegalArgumentException("Dataflow is null");
+		}
+		DataflowValidationReport report = dataflow.checkValidity();
+		if (!report.isValid())
+			throw new InvalidDataflowException(dataflow, report);
+
+		this.dataflow = dataflow;
+		this.context = context;
+		this.portsToComplete = dataflow.getOutputPorts().size();
+		this.processorsToComplete = dataflow.getProcessors().size();
+		this.localName = "facade" + owningProcessId.getAndIncrement();
+		// Set the wf run id
+		workflowRunId = UUID.randomUUID().toString();
+		if (parentProcess.isEmpty()) {
+			// Top-level workflow
+			
+			/*
+			 * add top level workflow run so that reference service can generate
+			 * identifiers linked to our run
+			 */
+			context.addEntity(new WorkflowRunIdEntity(workflowRunId));
+			this.instanceOwningProcessId = localName;
+			
+			/*
+			 * Add this WorkflowInstanceFacade to the map of all workflow run
+			 * IDs against the corresponding WorkflowInstanceFacadeS/ - to be
+			 * used by DependencyActivity's such as API consumer and Beanshell
+			 */
+			workflowRunFacades.put(localName, new WeakReference<WorkflowInstanceFacade>(this));
+			/*
+			 * Note that we do not put the IDs for nested workflows, just for
+			 * the main ones!
+			 */
+		} else {
+			// Nested workflow
+			this.instanceOwningProcessId = parentProcess + ":" + localName;
+		}		
+				
+		if (context.getProvenanceReporter() != null) {
+			provEnabled = true;
+			workflowItem = new WorkflowProvenanceItem();
+			workflowItem.setDataflow(dataflow);
+			workflowItem.setProcessId(instanceOwningProcessId);
+			workflowItem.setIdentifier(workflowRunId);
+			workflowItem.setParentId(dataflow.getIdentifier());
+			workflowItem.setWorkflowId(dataflow.getIdentifier());
+			
+			/*
+			 * FIXME: workflowItem is local to each instanceOwningProcessId, but
+			 * might be added to the Processor within different concurrent runs.
+			 * (T3-930)
+			 */
+			addProvenanceLayerToProcessors(workflowItem);
+			context.getProvenanceReporter().setSessionID(workflowRunId);
+		}
+		facadeResultListener = new FacadeResultListener(dataflow, workflowItem);
+		
+		// Register an observer with each of the processors
+		for (Processor processor : dataflow.getProcessors()) {
+			String expectedProcessId = instanceOwningProcessId + ":"
+					+ dataflow.getLocalName() + ":" + processor.getLocalName();
+			ProcessorFinishedObserver observer = new ProcessorFinishedObserver(
+					workflowItem, expectedProcessId);
+			((ProcessorImpl) processor).addObserver(observer);
+		}
+	}
+
+	private void addProvenanceLayerToProcessors(WorkflowProvenanceItem workflowItem) {
+		// TODO Shouldn't we use a bean for this? 
+		Edits edits = new EditsImpl();
+		for (Processor processor : dataflow.getProcessors())
+			/*
+			 * Synchronized per processor as we might be modifying its dispatch
+			 * stack (fixes T3-929)
+			 */
+		    synchronized (processor) {               
+		        DispatchStack dispatchStack = processor.getDispatchStack();
+    			List<DispatchLayer<?>> layers = dispatchStack.getLayers();
+    			if (isProvenanceAlreadyAdded(layers))
+    				continue;
+    			IntermediateProvenance provenance = new IntermediateProvenance();
+				provenance.setWorkflow(workflowItem);
+				provenance.setReporter(context.getProvenanceReporter());
+
+				try {
+					edits.getAddDispatchLayerEdit(dispatchStack, provenance,
+					        provenancePosition(layers)).doEdit();
+					break;
+				} catch (EditException e) {
+					logger.warn("adding provenance layer to dispatch stack failed "
+									+ e.toString());
+				}
+		    }
+	}
+
+    private boolean isProvenanceAlreadyAdded(List<DispatchLayer<?>> layers) {
+        for (DispatchLayer<?> layer : layers)
+        	if (layer instanceof IntermediateProvenance)
+        		return true;
+        return false;
+    }
+
+    private int provenancePosition(List<DispatchLayer<?>> layers) {
+        int position=0; // fallback - beginning of list
+        for (int i = 0; i < layers.size(); i++) {
+            DispatchLayer<?> layer = layers.get(i);
+        	if (layer instanceof Parallelize)
+        	    // Below Parallelize (should be there!)
+        	    position = i+1;
+        	else if (layer instanceof ErrorBounce)
+        	    // and inserted just above ErrorBounce (if it's there)
+        		position = i;
+        }
+        return position;
+    }
+
+	@Override
+	public void addFacadeListener(FacadeListener listener) {
+		facadeListeners.add(listener);
+	}
+
+	@Override
+	public void addResultListener(ResultListener listener) {
+		synchronized (resultListeners) {
+			if (resultListeners.isEmpty())
+				for (DataflowOutputPort port : dataflow.getOutputPorts())
+					port.addResultListener(facadeResultListener);
+			resultListeners.add(listener); 
+		}		
+	}
+
+	@Override
+	public synchronized void fire() throws IllegalStateException {
+		if (getState().equals(State.running))
+			throw new IllegalStateException("Workflow is already running!");
+		workflowStarted = new Timestamp(currentTimeMillis());
+		setState(State.running);
+		if (provEnabled) {
+			workflowItem.setInvocationStarted(workflowStarted);
+			context.getProvenanceReporter().addProvenanceItem(workflowItem);
+		}
+		
+		HashSet<MonitorableProperty<?>> properties = new HashSet<>();
+		properties.add(new StateProperty());
+		monitorManager.registerNode(this, instanceOwningProcessId.split(":"),				
+				properties);
+		dataflow.fire(instanceOwningProcessId, context);		
+	}
+
+	public final class StateProperty implements MonitorableProperty<State> {
+		@Override
+		public Date getLastModified() {
+			return stateLastModified;
+		}
+
+		@Override
+		public String[] getName() {
+			return new String[] { "facade", "state" };
+		}
+
+		@Override
+		public State getValue() throws NoSuchPropertyException {
+			return getState();
+		}
+	}
+	
+	@Override
+	public Dataflow getDataflow() {
+		return dataflow;
+	}
+
+	@Override
+	public TypedTreeModel<MonitorNode> getStateModel() {
+		// TODO WorkflowInstanceFacade.getStateModel not yet implemented
+		return null;
+	}
+
+	@Override
+	public void pushData(WorkflowDataToken token, String portName)
+			throws TokenOrderException {
+		State currentState = getState();
+		if (! currentState.equals(State.running))
+			throw new IllegalStateException(
+					"Can't push data, current state is not running, but "
+							+ currentState);
+		/*
+		 * TODO: throw TokenOrderException when token stream is violates order
+		 * constraints.
+		 */
+		for (DataflowInputPort port : dataflow.getInputPorts()) {
+			if (!portName.equals(port.getName()))
+				continue;
+			if (token.getIndex().length == 0) {
+				if (pushedDataMap.containsKey(portName))
+					throw new IllegalStateException("Already pushed for port " + portName);
+				pushedDataMap.put(portName, token.getData());					
+			}
+			if (provEnabled) {
+				WorkflowDataProvenanceItem provItem = new WorkflowDataProvenanceItem();
+				provItem.setPortName(portName);
+				provItem.setInputPort(true);
+				provItem.setData(token.getData());
+				provItem.setReferenceService(context.getReferenceService());
+				provItem.setParentId(workflowItem.getIdentifier());
+				provItem.setWorkflowId(workflowItem.getParentId());
+				provItem.setIdentifier(randomUUID().toString());
+				provItem.setParentId(instanceOwningProcessId);
+				provItem.setProcessId(instanceOwningProcessId);
+				provItem.setIndex(token.getIndex());
+				provItem.setFinal(token.isFinal());
+				context.getProvenanceReporter().addProvenanceItem(provItem);
+			}
+			port.receiveEvent(token.pushOwningProcess(localName));
+		}
+	}
+
+	@Override
+	public void removeFacadeListener(FacadeListener listener) {
+		facadeListeners.remove(listener);
+	}
+
+	private <T> ArrayList<T> copyList(List<T> listenerList) {
+		synchronized (listenerList) {
+			return new ArrayList<>(listenerList);
+		}
+	}
+
+	@Override
+	public void removeResultListener(ResultListener listener) {
+		synchronized (resultListeners) {
+			resultListeners.remove(listener);
+			if (resultListeners.isEmpty())
+				for (DataflowOutputPort port : dataflow.getOutputPorts())
+					port.removeResultListener(facadeResultListener);
+		}
+	}
+
+	protected class FacadeResultListener implements ResultListener {
+		private final WorkflowProvenanceItem workflowItem;
+
+		public FacadeResultListener(Dataflow dataflow,
+				WorkflowProvenanceItem workflowItem) {
+			this.workflowItem = workflowItem;
+		}
+
+		@Override
+		public void resultTokenProduced(WorkflowDataToken token, String portName) {			
+			if (!instanceOwningProcessId.equals(token.getOwningProcess()))
+				return;
+			if (getState().equals(State.cancelled))
+				// Throw the token away
+				return;
+
+			if (provEnabled) {
+				WorkflowDataProvenanceItem provItem = new WorkflowDataProvenanceItem();
+				provItem.setPortName(portName);
+				provItem.setInputPort(false);
+				provItem.setData(token.getData());
+				provItem.setReferenceService(context.getReferenceService());
+				provItem.setParentId(workflowItem.getIdentifier());
+				provItem.setWorkflowId(workflowItem.getParentId());
+				provItem.setIdentifier(randomUUID().toString());
+				provItem.setParentId(instanceOwningProcessId);
+				provItem.setProcessId(instanceOwningProcessId);
+				provItem.setIndex(token.getIndex());
+				provItem.setFinal(token.isFinal());
+				context.getProvenanceReporter().addProvenanceItem(provItem);
+			}
+			
+			for (ResultListener resultListener : copyList(resultListeners))
+				try {
+					resultListener.resultTokenProduced(
+							token.popOwningProcess(), portName);
+				} catch (RuntimeException ex) {
+					logger.warn("Could not notify result listener "
+							+ resultListener, ex);
+				}
+			if (token.getIndex().length == 0)
+				checkWorkflowFinished(WorkflowInstanceFacadeChange.PORT_DECREMENT);
+		}
+	}
+	
+
+	/**
+	 * An observer of events that occur when a processor finishes with execution.
+	 *
+	 */
+	private class ProcessorFinishedObserver implements Observer<ProcessorFinishedEvent>{
+		private final String expectedProcessId;
+
+		public ProcessorFinishedObserver(WorkflowProvenanceItem workflowItem, String expectedProcessId) {
+			this.expectedProcessId = expectedProcessId;
+		}
+
+		@Override
+		public void notify(Observable<ProcessorFinishedEvent> sender,
+				ProcessorFinishedEvent message) throws Exception {
+			if (! message.getOwningProcess().equals(expectedProcessId))
+				return;
+			
+			// De-register the processor node from the monitor as it has finished
+			monitorManager.deregisterNode(message.getOwningProcess());
+			
+			// De-register this observer from the processor
+			message.getProcessor().removeObserver(this);
+			
+			// All processors have finished => the workflow run has finished
+			checkWorkflowFinished(WorkflowInstanceFacadeChange.PROCESSOR_DECREMENT);
+		}
+	}
+
+	private void applyChange(WorkflowInstanceFacadeChange change) {
+		switch (change) {
+		case CANCELLATION:
+			processorsToComplete = 0;
+			portsToComplete = 0;
+			break;
+		case PORT_DECREMENT:
+			portsToComplete--;
+			break;
+		case PROCESSOR_DECREMENT:
+			processorsToComplete--;
+			break;
+		}
+	}
+	protected void checkWorkflowFinished(WorkflowInstanceFacadeChange change) {
+		synchronized (this) {
+			applyChange(change);
+			if (getState().equals(State.cancelled) && processorsToComplete < 0) {
+				logger.error("Already cancelled workflow run "
+						+ instanceOwningProcessId);
+				return;
+			}
+			if (getState().equals(State.completed)) {
+				logger.error("Already finished workflow run "
+						+ instanceOwningProcessId, new IllegalStateException());
+				return;
+			}
+			if (processorsToComplete > 0 || portsToComplete > 0)
+				// Not yet finished
+				return;
+			if (processorsToComplete < 0 || portsToComplete < 0) {
+				logger.error("Already finished workflow run "
+						+ instanceOwningProcessId, new IllegalStateException());
+				return;
+			}
+			if (!getState().equals(State.cancelled))
+				setState(State.completed);
+			processorsToComplete = -1;
+			portsToComplete = -1;
+		}	
+		// De-register the workflow node from the monitor
+		monitorManager.deregisterNode(instanceOwningProcessId + ":" + dataflow.getLocalName());
+
+		/*
+		 * De-register this facade node from the monitor - this will effectively
+		 * tell the monitor that the workflow run has finished
+		 */
+		monitorManager.deregisterNode(instanceOwningProcessId);
+
+		if (provEnabled) {
+			DataflowRunComplete provItem = new DataflowRunComplete();
+			provItem.setInvocationEnded(new Timestamp(currentTimeMillis()));
+			provItem.setParentId(workflowItem.getIdentifier());
+			provItem.setWorkflowId(workflowItem.getParentId());
+			provItem.setProcessId(instanceOwningProcessId);
+			provItem.setIdentifier(randomUUID().toString());
+			provItem.setState(getState());
+			context.getProvenanceReporter().addProvenanceItem(provItem);
+		}
+	}
+
+	@Override
+	public WeakHashMap<String, T2Reference> getPushedDataMap() {
+		return pushedDataMap;
+	}
+
+	public void setWorkflowRunId(String workflowRunId) {
+		this.workflowRunId = workflowRunId;
+	}
+
+	@Override
+	public String getWorkflowRunId() {
+		return workflowRunId;
+	}
+	
+	@Override
+	public synchronized State getState() {
+		return state;
+	}
+	
+	public synchronized void setState(State newState) throws IllegalStateException {
+		State oldState = state;
+		if (newState.equals(state))
+			return;
+		switch (newState) {
+		case running:
+			switch (state) {
+			case prepared:
+			case paused:
+				stateLastModified = new Date();
+				state = newState;
+				notifyFacadeListeners(oldState, newState);
+				return;
+			default:
+				throw new IllegalStateException("Can't change state from "
+						+ state + " to " + newState);
+			}
+		case paused:
+			switch (state) {
+			case running:
+				stateLastModified = new Date();
+				state = newState;
+				notifyFacadeListeners(oldState, newState);
+				return;
+			default:
+				throw new IllegalStateException("Can't change state from "
+						+ state + " to " + newState);
+			}
+		case completed:
+			switch (state) {
+			case running:
+				stateLastModified = new Date();
+				state = newState;
+				notifyFacadeListeners(oldState, newState);
+				return;
+			case cancelled:
+				// Keep as cancelled
+				return;
+			default:
+				throw new IllegalStateException("Can't change state from "
+						+ state + " to " + newState);
+			}
+		case cancelled:
+			switch (state) {
+			case completed:
+				throw new IllegalStateException("Can't change state from "
+						+ state + " to " + newState);
+			default:
+				stateLastModified = new Date();
+				state = newState;
+				notifyFacadeListeners(oldState, newState);
+				return;
+			}
+		default:
+			throw new IllegalStateException("Can't change state from " + state  + " to " + newState);		
+		}		
+	}
+
+	private void notifyFacadeListeners(State oldState, State newState) {
+		for (FacadeListener facadeListener : copyList(facadeListeners))
+			try {
+				facadeListener.stateChange(this, oldState, newState);
+			} catch (RuntimeException ex) {
+				logger.warn("Could not notify facade listener "
+						+ facadeListener, ex);
+			}
+	}
+
+	@Override
+	public synchronized boolean cancelWorkflowRun() {
+		if (getState().equals(State.completed))
+			return false;
+		boolean result = Stop.cancelWorkflow(getWorkflowRunId());
+		if (result) {
+			setState(State.cancelled);
+			logger.info("Cancelled workflow runId=" + getWorkflowRunId()
+					+ " processId=" + instanceOwningProcessId);
+			for (FacadeListener facadeListener : copyList(facadeListeners))
+				try {
+					facadeListener.workflowFailed(this, "Workflow was cancelled",
+							new WorkflowRunCancellation(getWorkflowRunId()));
+				} catch (RuntimeException ex) {
+					logger.warn("Could not notify failure listener "
+							+ facadeListener, ex);
+				}
+			checkWorkflowFinished(WorkflowInstanceFacadeChange.CANCELLATION);		
+		}
+		return result;
+	}
+
+	@Override
+	public boolean pauseWorkflowRun() {
+		setState(State.paused);
+		if (Stop.pauseWorkflow(getWorkflowRunId())) {
+			logger.info("Paused workflow runId=" + getWorkflowRunId()
+					+ " processId=" + instanceOwningProcessId);
+			return true;
+		}
+		return false;
+	}
+
+	@Override
+	public boolean resumeWorkflowRun() {
+		setState(State.running);
+		if (Stop.resumeWorkflow(getWorkflowRunId())) {
+			logger.info("Resumed paused workflow runId=" + getWorkflowRunId()
+					+ " processId=" + instanceOwningProcessId);
+			return true;
+		}
+		return false;
+	}
+
+	@Override
+	public String getIdentifier() {
+		return localName;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/invocation/impl/InvocationContextImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/invocation/impl/InvocationContextImpl.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/invocation/impl/InvocationContextImpl.java
new file mode 100644
index 0000000..8b45a47
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/invocation/impl/InvocationContextImpl.java
@@ -0,0 +1,71 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.invocation.impl;
+
+import static java.util.Collections.synchronizedList;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.provenance.reporter.ProvenanceReporter;
+import org.apache.taverna.reference.ReferenceService;
+
+public class InvocationContextImpl implements InvocationContext {
+	private final ReferenceService referenceService;
+	private final ProvenanceReporter provenanceReporter;
+	private List<Object> entities = synchronizedList(new ArrayList<Object>());
+
+	public InvocationContextImpl(ReferenceService referenceService,
+			ProvenanceReporter provenanceReporter) {
+		this.referenceService = referenceService;
+		this.provenanceReporter = provenanceReporter;
+	}
+
+	@Override
+	public ReferenceService getReferenceService() {
+		return referenceService;
+	}
+
+	@Override
+	public ProvenanceReporter getProvenanceReporter() {
+		return provenanceReporter;
+	}
+
+	@Override
+	public <T extends Object> List<T> getEntities(Class<T> entityType) {
+		List<T> entitiesOfType = new ArrayList<>();
+		synchronized (entities) {
+			for (Object entity : entities)
+				if (entityType.isInstance(entity))
+					entitiesOfType.add(entityType.cast(entity));
+		}
+		return entitiesOfType;
+	}
+
+	@Override
+	public void addEntity(Object entity) {
+		entities.add(entity);
+	}
+
+	public void removeEntity(Object entity) {
+		entities.remove(entity);
+	}
+}


[04/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/EditsImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/EditsImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/EditsImpl.java
deleted file mode 100644
index 8873951..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/EditsImpl.java
+++ /dev/null
@@ -1,1251 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007-2014 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import static java.lang.Integer.parseInt;
-import static net.sf.taverna.t2.workflowmodel.utils.Tools.getUniqueMergeInputPortName;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import net.sf.taverna.t2.annotation.Annotated;
-import net.sf.taverna.t2.annotation.AnnotationAssertion;
-import net.sf.taverna.t2.annotation.AnnotationBeanSPI;
-import net.sf.taverna.t2.annotation.AnnotationChain;
-import net.sf.taverna.t2.annotation.AnnotationRole;
-import net.sf.taverna.t2.annotation.AnnotationSourceSPI;
-import net.sf.taverna.t2.annotation.CurationEvent;
-import net.sf.taverna.t2.annotation.Person;
-import net.sf.taverna.t2.annotation.impl.AnnotationAssertionImpl;
-import net.sf.taverna.t2.annotation.impl.AnnotationChainImpl;
-import net.sf.taverna.t2.facade.WorkflowInstanceFacade;
-import net.sf.taverna.t2.facade.impl.WorkflowInstanceFacadeImpl;
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.workflowmodel.CompoundEdit;
-import net.sf.taverna.t2.workflowmodel.Condition;
-import net.sf.taverna.t2.workflowmodel.Configurable;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import net.sf.taverna.t2.workflowmodel.DataflowInputPort;
-import net.sf.taverna.t2.workflowmodel.DataflowOutputPort;
-import net.sf.taverna.t2.workflowmodel.Datalink;
-import net.sf.taverna.t2.workflowmodel.Edit;
-import net.sf.taverna.t2.workflowmodel.EditException;
-import net.sf.taverna.t2.workflowmodel.Edits;
-import net.sf.taverna.t2.workflowmodel.EventForwardingOutputPort;
-import net.sf.taverna.t2.workflowmodel.EventHandlingInputPort;
-import net.sf.taverna.t2.workflowmodel.InvalidDataflowException;
-import net.sf.taverna.t2.workflowmodel.Merge;
-import net.sf.taverna.t2.workflowmodel.MergeInputPort;
-import net.sf.taverna.t2.workflowmodel.OrderedPair;
-import net.sf.taverna.t2.workflowmodel.OutputPort;
-import net.sf.taverna.t2.workflowmodel.Processor;
-import net.sf.taverna.t2.workflowmodel.ProcessorInputPort;
-import net.sf.taverna.t2.workflowmodel.ProcessorOutputPort;
-import net.sf.taverna.t2.workflowmodel.processor.activity.AbstractActivity;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityInputPort;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityOutputPort;
-import net.sf.taverna.t2.workflowmodel.processor.activity.impl.ActivityInputPortImpl;
-import net.sf.taverna.t2.workflowmodel.processor.activity.impl.ActivityOutputPortImpl;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchStack;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.impl.AbstractDispatchLayerEdit;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.impl.DispatchStackImpl;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.ErrorBounce;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.Failover;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.Invoke;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.Parallelize;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.Retry;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.Stop;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.IterationStrategy;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.IterationStrategyStack;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.NamedInputPortNode;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.impl.IterationStrategyImpl;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.impl.IterationStrategyStackImpl;
-
-/**
- * Implementation of {@link Edits}
- * @author Donal Fellows (et al)
- */
-public class EditsImpl implements Edits {
-	// ----------------------------------------------------------------
-	// Basic factory methods
-
-	@Override
-	public Dataflow createDataflow() {
-		return new DataflowImpl();
-	}
-
-	@Override
-	public Datalink createDatalink(EventForwardingOutputPort source,
-			EventHandlingInputPort sink) {
-		return new DatalinkImpl(source, sink);
-	}
-
-	@Override
-	public DataflowInputPort createDataflowInputPort(String name, int depth,
-			int granularDepth, Dataflow dataflow) {
-		return new DataflowInputPortImpl(name, depth, granularDepth, dataflow);
-	}
-
-	@Override
-	public DataflowOutputPort createDataflowOutputPort(String name,
-			Dataflow dataflow) {
-		return new DataflowOutputPortImpl(name, dataflow);
-	}
-
-	@Override
-	public MergeInputPort createMergeInputPort(Merge merge, String name,
-			int depth) {
-		if (merge instanceof MergeImpl)
-			return new MergeInputPortImpl((MergeImpl) merge, name, depth);
-		return null;
-	}
-
-	@Override
-	public ProcessorOutputPort createProcessorOutputPort(Processor processor,
-			String name, int depth, int granularDepth) {
-		return new ProcessorOutputPortImpl((ProcessorImpl) processor, name,
-				depth, granularDepth);
-	}
-
-	@Override
-	public ProcessorInputPort createProcessorInputPort(Processor processor,
-			String name, int depth) {
-		return new ProcessorInputPortImpl((ProcessorImpl) processor, name,
-				depth);
-	}
-
-	@Override
-	public AnnotationChain createAnnotationChain() {
-		return new AnnotationChainImpl();
-	}
-
-	/**
-	 * Creates a MergeImpl instance. Merge names are generated as 'Merge0',
-	 * 'Merge1', 'Merge2', etc. The next merge to be added always gets the name
-	 * as the previous merge in the list with its index incremented by one. If a
-	 * merge is deleted, that is not taken into account when generating merges'
-	 * names.
-	 */
-	@Override
-	public Merge createMerge(Dataflow dataflow) {
-		String mergeName;
-
-		// Work out what the name of the merge should be.
-		List<? extends Merge> merges = dataflow.getMerges();
-		if (merges.isEmpty())
-			mergeName = "Merge0"; // the first merge to be added to the list
-		else
-			mergeName = "Merge"
-					+ String.valueOf(parseInt(merges.get(merges.size() - 1)
-							.getLocalName().substring(5)) + 1);
-
-		return new MergeImpl(mergeName);
-	}
-
-	@Override
-	public Processor createProcessor(String name) {
-		ProcessorImpl processor = new ProcessorImpl();
-		processor.setName(name);
-		return processor;
-	}
-
-	@Override
-	public IterationStrategy createIterationStrategy() {
-		return new IterationStrategyImpl();
-	}
-
-	/**
-	 * Builds an instance of {@link ActivityInputPortImpl}
-	 */
-	@Override
-	public ActivityInputPort createActivityInputPort(
-			String portName,
-			int portDepth,
-			boolean allowsLiteralValues,
-			List<Class<? extends ExternalReferenceSPI>> handledReferenceSchemes,
-			Class<?> translatedElementClass) {
-		return new ActivityInputPortImpl(portName, portDepth,
-				allowsLiteralValues, handledReferenceSchemes,
-				translatedElementClass);
-	}
-
-	/**
-	 * Builds an instance of {@link ActivityOutputPortImpl}
-	 */
-	@Override
-	public ActivityOutputPort createActivityOutputPort(String portName, int portDepth,
-			int portGranularDepth) {
-		return new ActivityOutputPortImpl(portName, portDepth,
-				portGranularDepth);
-	}
-
-	@Override
-	public WorkflowInstanceFacade createWorkflowInstanceFacade(
-			Dataflow dataflow, InvocationContext context, String parentProcess)
-			throws InvalidDataflowException {
-		return new WorkflowInstanceFacadeImpl(dataflow, context, parentProcess);
-	}
-
-	// ----------------------------------------------------------------
-	// Edits (structured transformation) factory methods
-
-	@Override
-	public Edit<Dataflow> getAddProcessorEdit(Dataflow dataflow,
-			Processor processor) {
-		if (!(processor instanceof ProcessorImpl))
-			throw new RuntimeException(
-					"The Processor is of the wrong implmentation,"
-							+ " it should be of type ProcessorImpl");
-		final ProcessorImpl p = (ProcessorImpl) processor;
-		return new AbstractDataflowEdit(dataflow) {
-			@Override
-			protected void doEditAction(DataflowImpl dataflow)
-					throws EditException {
-				dataflow.addProcessor(p);
-			}
-		};
-	}
-
-	@Override
-	public Edit<Dataflow> getAddMergeEdit(Dataflow dataflow, Merge merge) {
-		if (!(merge instanceof MergeImpl))
-			throw new RuntimeException(
-					"The Merge is of the wrong implmentation, "
-							+ "it should be of type MergeImpl");
-		final MergeImpl m = (MergeImpl) merge;
-		return new AbstractDataflowEdit(dataflow) {
-			@Override
-			protected void doEditAction(DataflowImpl dataflow)
-					throws EditException {
-				dataflow.addMerge(m);
-			}
-		};
-	}
-
-	@Override
-	public Edit<DispatchStack> getAddDispatchLayerEdit(DispatchStack stack,
-			final DispatchLayer<?> layer, final int position) {
-		return new AbstractDispatchLayerEdit(stack) {
-			@Override
-			protected void doEditAction(DispatchStackImpl stack) throws EditException {
-				stack.addLayer(layer, position);
-			}
-
-			@Override
-			protected void undoEditAction(DispatchStackImpl stack) {
-				stack.removeLayer(layer);
-			}
-		};
-	}
-
-	@Override
-	public Edit<Processor> getAddActivityEdit(Processor processor,
-			final Activity<?> activity) {
-		return new AbstractProcessorEdit(processor) {
-			@Override
-			protected void doEditAction(ProcessorImpl processor)
-					throws EditException {
-				List<Activity<?>> activities = processor.activityList;
-				if (activities.contains(activity))
-					throw new EditException(
-							"Cannot add a duplicate activity to processor");
-				activities.add(activity);
-			}
-		};
-	}
-
-	@Override
-	public Edit<Processor> getAddProcessorInputPortEdit(Processor processor,
-			final ProcessorInputPort port) {
-		return new AbstractProcessorEdit(processor) {
-			@Override
-			protected void doEditAction(ProcessorImpl processor)
-					throws EditException {
-				/*
-				 * Add a new InputPort object to the processor and also create
-				 * an appropriate NamedInputPortNode in any iteration
-				 * strategies. By default set the desired drill depth on each
-				 * iteration strategy node to the same as the input port, so
-				 * this won't automatically trigger iteration staging unless the
-				 * depth is altered on the iteration strategy itself.)
-				 */
-				if (processor.getInputPortWithName(port.getName()) != null)
-					throw new EditException(
-							"Attempt to create duplicate input port with name '"
-									+ port.getName() + "'");
-				processor.inputPorts.add((ProcessorInputPortImpl) port);
-				for (IterationStrategyImpl is : processor.iterationStack
-						.getStrategies()) {
-					NamedInputPortNode nipn = new NamedInputPortNode(
-							port.getName(), port.getDepth());
-					is.addInput(nipn);
-					is.connectDefault(nipn);
-				}
-			}
-		};
-	}
-
-	@Override
-	public Edit<Processor> getAddProcessorOutputPortEdit(Processor processor,
-			final ProcessorOutputPort port) {
-		return new AbstractProcessorEdit(processor) {
-			@Override
-			protected void doEditAction(ProcessorImpl processor)
-					throws EditException {
-				if (processor.getOutputPortWithName(port.getName()) != null)
-					throw new EditException("Duplicate output port name");
-				processor.outputPorts.add((ProcessorOutputPortImpl) port);
-			}
-		};
-	}
-
-	@Override
-	public Edit<Dataflow> getCreateDataflowInputPortEdit(Dataflow dataflow,
-			final String portName, final int portDepth, final int granularDepth) {
-		return new AbstractDataflowEdit(dataflow) {
-			@Override
-			protected void doEditAction(DataflowImpl dataflow)
-					throws EditException {
-				dataflow.createInputPort(portName, portDepth, granularDepth);
-			}
-		};
-	}
-
-	@Override
-	public Edit<Dataflow> getCreateDataflowOutputPortEdit(Dataflow dataflow,
-			final String portName) {
-		return new AbstractDataflowEdit(dataflow) {
-			@Override
-			protected void doEditAction(DataflowImpl dataflow)
-					throws EditException {
-				dataflow.createOutputPort(portName);
-			}
-		};
-	}
-
-	@Override
-	public Edit<DispatchStack> getDeleteDispatchLayerEdit(DispatchStack stack,
-			final DispatchLayer<?> layer) {
-		return new AbstractDispatchLayerEdit(stack) {
-			private int index;
-
-			@Override
-			protected void doEditAction(DispatchStackImpl stack) {
-				index = stack.removeLayer(layer);
-			}
-
-			@Override
-			protected void undoEditAction(DispatchStackImpl stack) {
-				stack.addLayer(layer, index);
-			}
-		};
-	}
-
-	@Override
-	public Edit<Merge> getRenameMergeEdit(Merge merge, final String newName) {
-		return new AbstractMergeEdit(merge) {
-			@Override
-			protected void doEditAction(MergeImpl merge) {
-				merge.setName(newName);
-			}
-		};
-	}
-
-	@Override
-	public Edit<Processor> getRenameProcessorEdit(Processor processor,
-			final String newName) {
-		return new AbstractProcessorEdit(processor) {
-			@Override
-			protected void doEditAction(ProcessorImpl processor) {
-				processor.setName(newName);
-			}
-		};
-	}
-
-	@Override
-	public Edit<DataflowInputPort> getRenameDataflowInputPortEdit(
-			DataflowInputPort dataflowInputPort, final String newName) {
-		return new AbstractDataflowInputPortEdit(dataflowInputPort) {
-			@Override
-			protected void doEditAction(DataflowInputPortImpl inputPort) {
-				inputPort.setName(newName);
-			}
-		};
-	}
-
-	@Override
-	public Edit<DataflowOutputPort> getRenameDataflowOutputPortEdit(
-			DataflowOutputPort dataflowOutputPort, final String newName) {
-		return new AbstractDataflowOutputPortEdit(dataflowOutputPort) {
-			@Override
-			protected void doEditAction(DataflowOutputPortImpl outputPort) {
-				outputPort.setName(newName);
-			}
-		};
-	}
-
-	@Override
-	public Edit<DataflowInputPort> getChangeDataflowInputPortDepthEdit(
-			DataflowInputPort dataflowInputPort, final int depth) {
-		return new AbstractDataflowInputPortEdit(dataflowInputPort) {
-			@Override
-			protected void doEditAction(DataflowInputPortImpl port) {
-				port.setDepth(depth);
-			}
-		};
-	}
-
-	@Override
-	public Edit<DataflowInputPort> getChangeDataflowInputPortGranularDepthEdit(
-			DataflowInputPort dataflowInputPort, final int granularDepth) {
-		return new AbstractDataflowInputPortEdit(dataflowInputPort) {
-			@Override
-			protected void doEditAction(DataflowInputPortImpl port) {
-				port.setGranularDepth(granularDepth);
-			}
-		};
-	}
-
-	@Override
-	public Edit<Processor> getConnectProcessorOutputEdit(Processor processor,
-			final String outputPortName, final EventHandlingInputPort targetPort) {
-		return new AbstractProcessorEdit(processor) {
-			@Override
-			protected void doEditAction(ProcessorImpl processor) throws EditException {
-				for (BasicEventForwardingOutputPort popi : processor.outputPorts)
-					if (popi.getName().equals(outputPortName)) {
-						addOutgoingLink(popi);
-						return;
-					}
-				throw new EditException("Cannot locate output port with name '"
-						+ outputPortName + "'");
-			}
-
-			private void addOutgoingLink(BasicEventForwardingOutputPort popi) {
-				DatalinkImpl newLink = new DatalinkImpl(popi, targetPort);
-				popi.addOutgoingLink(newLink);
-				if (targetPort instanceof AbstractEventHandlingInputPort)
-					((AbstractEventHandlingInputPort) targetPort)
-							.setIncomingLink(newLink);
-			}
-		};
-	}
-
-	@Override
-	public Edit<Datalink> getConnectDatalinkEdit(Datalink datalink) {
-		return new AbstractDatalinkEdit(datalink) {
-			@Override
-			protected void doEditAction(DatalinkImpl datalink) throws EditException {
-				EventForwardingOutputPort source = datalink.getSource();
-				EventHandlingInputPort sink = datalink.getSink();
-				if (source instanceof BasicEventForwardingOutputPort)
-					((BasicEventForwardingOutputPort) source).addOutgoingLink(datalink);
-				if (sink instanceof AbstractEventHandlingInputPort)
-					((AbstractEventHandlingInputPort) sink).setIncomingLink(datalink);
-			}
-		};
-	}
-
-	@Override
-	public Edit<AnnotationChain> getAddAnnotationAssertionEdit(
-			AnnotationChain annotationChain,
-			final AnnotationAssertion<?> annotationAssertion) {
-		if (!(annotationChain instanceof AnnotationChainImpl))
-			throw new RuntimeException(
-					"Object being edited must be instance of AnnotationChainImpl");
-		final AnnotationChainImpl chain = (AnnotationChainImpl) annotationChain;
-		return new EditSupport<AnnotationChain>() {
-			@Override
-			public AnnotationChain applyEdit() {
-				synchronized (chain) {
-					chain.addAnnotationAssertion(annotationAssertion);
-				}
-				return chain;
-			}
-
-			@Override
-			public Object getSubject() {
-				return chain;
-			}
-		};
-	}
-
-	/**
-	 * @return a new instance of ConnectMergedDatalinkEdit constructed from the
-	 *         provided parameters.
-	 *
-	 * @param merge
-	 *            a Merge instance
-	 * @param sourcePort
-	 *            the source port from which a link is to be created.
-	 * @param sinkPort
-	 *            the sink port to which the link is to be created.
-	 */
-	@Override
-	public Edit<Merge> getConnectMergedDatalinkEdit(Merge merge,
-			final EventForwardingOutputPort sourcePort,
-			final EventHandlingInputPort sinkPort) {
-		if (sourcePort == null)
-			throw new RuntimeException("The sourceport cannot be null");
-		if (sinkPort == null)
-			throw new RuntimeException("The sinkport cannot be null");
-		return new AbstractMergeEdit(merge) {
-			private boolean needToCreateDatalink(MergeImpl mergeImpl)
-					throws EditException {
-				Collection<? extends Datalink> outgoing = mergeImpl.getOutputPort()
-						.getOutgoingLinks();
-				if (outgoing.size() == 0) {
-					return true;
-				} else if (outgoing.size() != 1)
-					throw new EditException(
-							"The merge instance cannot have more that 1 outgoing Datalink");
-				if (outgoing.iterator().next().getSink() != sinkPort)
-					throw new EditException(
-							"Cannot add a different sinkPort to a Merge that already has one defined");
-				return false;
-			}
-
-			@Override
-			protected void doEditAction(MergeImpl merge) throws EditException {
-				boolean linkOut = needToCreateDatalink(merge);
-				String name = getUniqueMergeInputPortName(merge,
-						sourcePort.getName() + "To" + merge.getLocalName()
-								+ "_input", 0);
-				MergeInputPortImpl mergeInputPort = new MergeInputPortImpl(
-						merge, name, sinkPort.getDepth());
-				merge.addInputPort(mergeInputPort);
-				getConnectDatalinkEdit(
-						createDatalink(sourcePort, mergeInputPort)).doEdit();
-				if (linkOut)
-					getConnectDatalinkEdit(
-							createDatalink(merge.getOutputPort(), sinkPort))
-							.doEdit();
-			}
-		};
-	}
-
-	@Override
-	public Edit<OrderedPair<Processor>> getCreateConditionEdit(
-			Processor control, Processor target) {
-		return new AbstractBinaryProcessorEdit(control, target) {
-			@Override
-			protected void doEditAction(ProcessorImpl control,
-					ProcessorImpl target) throws EditException {
-				ConditionImpl condition = new ConditionImpl(control, target);
-				// Check for duplicates
-				for (Condition c : control.controlledConditions)
-					if (c.getTarget() == target)
-						throw new EditException(
-								"Attempt to create duplicate control link");
-				control.controlledConditions.add(condition);
-				target.conditions.add(condition);
-			}
-		};
-	}
-
-	@Override
-	public Edit<OrderedPair<Processor>> getRemoveConditionEdit(
-			Processor control, Processor target) {
-		return new AbstractBinaryProcessorEdit(control, target) {
-			@Override
-			protected void doEditAction(ProcessorImpl control, ProcessorImpl target)
-					throws EditException {
-				for (ConditionImpl c : control.controlledConditions)
-					if (c.getTarget() == target) {
-						control.controlledConditions.remove(c);
-						target.conditions.remove(c);
-						return;
-					}
-				throw new EditException(
-						"Can't remove a control link as it doesn't exist");
-			}
-		};
-	}
-
-	@Override
-	@SuppressWarnings({ "rawtypes", "unchecked" })
-	public Edit<AnnotationAssertion<AnnotationBeanSPI>> getAddAnnotationBean(
-			AnnotationAssertion annotationAssertion,
-			final AnnotationBeanSPI bean) {
-		return new AbstractAnnotationEdit(annotationAssertion) {
-			@Override
-			protected void doEditAction(AnnotationAssertionImpl assertion)
-					throws EditException {
-				assertion.setAnnotationBean(bean);
-			}
-		};
-	}
-
-	@Override
-	@SuppressWarnings({ "rawtypes", "unchecked" })
-	public Edit<AnnotationAssertion<AnnotationBeanSPI>> getAddCurationEvent(
-			AnnotationAssertion annotationAssertion,
-			final CurationEvent curationEvent) {
-		return new AbstractAnnotationEdit(annotationAssertion) {
-			@Override
-			protected void doEditAction(AnnotationAssertionImpl assertion)
-					throws EditException {
-				assertion.addCurationEvent(curationEvent);
-			}
-		};
-	}
-
-	@Override
-	@SuppressWarnings({ "rawtypes", "unchecked" })
-	public Edit<AnnotationAssertion<AnnotationBeanSPI>> getAddAnnotationRole(
-			AnnotationAssertion annotationAssertion,
-			final AnnotationRole role) {
-		return new AbstractAnnotationEdit(annotationAssertion) {
-			@Override
-			protected void doEditAction(AnnotationAssertionImpl assertion)
-					throws EditException {
-				assertion.setAnnotationRole(role);
-			}
-		};
-	}
-
-	@Override
-	@SuppressWarnings({ "rawtypes", "unchecked" })
-	public Edit<AnnotationAssertion<AnnotationBeanSPI>> getAddAnnotationSource(
-			AnnotationAssertion annotationAssertion,
-			final AnnotationSourceSPI source) {
-		return new AbstractAnnotationEdit(annotationAssertion) {
-			@Override
-			protected void doEditAction(AnnotationAssertionImpl assertion)
-					throws EditException {
-				assertion.setAnnotationSource(source);
-			}
-		};
-	}
-
-	@Override
-	@SuppressWarnings({ "rawtypes", "unchecked" })
-	public Edit<AnnotationAssertion<AnnotationBeanSPI>> getAddCreator(
-			AnnotationAssertion annotationAssertion, final Person person) {
-		return new AbstractAnnotationEdit(annotationAssertion) {
-			@Override
-			protected void doEditAction(AnnotationAssertionImpl assertion)
-					throws EditException {
-				assertion.addCreator(person);
-			}
-		};
-	}
-
-	@Override
-	public Edit<?> getAddAnnotationChainEdit(Annotated<?> annotated,
-			AnnotationBeanSPI annotation) {
-		List<Edit<?>> editList = new ArrayList<>();
-
-		AnnotationAssertion<?> assertion = new AnnotationAssertionImpl();
-		AnnotationChain chain = new AnnotationChainImpl();
-		editList.add(getAddAnnotationBean(assertion, annotation));
-		editList.add(getAddAnnotationAssertionEdit(chain, assertion));
-		editList.add(annotated.getAddAnnotationEdit(chain));
-
-		return new CompoundEdit(editList);
-	}
-
-	@Override
-	public Edit<Dataflow> getUpdateDataflowNameEdit(Dataflow dataflow,
-			final String newName) {
-		return new AbstractDataflowEdit(dataflow) {
-			@Override
-			protected void doEditAction(DataflowImpl dataflow) {
-				dataflow.setLocalName(newName);
-			}
-		};
-	}
-
-	@Override
-	public Edit<Dataflow> getUpdateDataflowInternalIdentifierEdit(
-			Dataflow dataflow, final String newId) {
-		return new AbstractDataflowEdit(dataflow) {
-			@Override
-			protected void doEditAction(DataflowImpl dataflow) {
-				dataflow.setIdentifier(newId);
-			}
-		};
-	}
-
-	@Override
-	public Edit<Datalink> getDisconnectDatalinkEdit(Datalink datalink) {
-		return new AbstractDatalinkEdit(datalink) {
-			@Override
-			protected void doEditAction(DatalinkImpl datalink) throws EditException {
-				EventForwardingOutputPort source = datalink.getSource();
-				EventHandlingInputPort sink = datalink.getSink();
-
-				if (source instanceof BasicEventForwardingOutputPort)
-					((BasicEventForwardingOutputPort) source)
-							.removeOutgoingLink(datalink);
-
-				if (sink instanceof AbstractEventHandlingInputPort)
-					((AbstractEventHandlingInputPort) sink).setIncomingLink(null);
-				if (sink instanceof MergeInputPortImpl) {
-					MergeInputPortImpl mip = (MergeInputPortImpl) sink;
-					((MergeImpl) mip.getMerge()).removeInputPort(mip);
-				}
-			}
-		};
-	}
-
-	@Override
-	public Edit<Dataflow> getRemoveDataflowInputPortEdit(Dataflow dataflow,
-			final DataflowInputPort dataflowInputPort) {
-		return new AbstractDataflowEdit(dataflow) {
-			@Override
-			protected void doEditAction(DataflowImpl dataflow) throws EditException {
-				dataflow.removeDataflowInputPort(dataflowInputPort);
-			}
-		};
-	}
-
-	@Override
-	public Edit<Dataflow> getRemoveDataflowOutputPortEdit(Dataflow dataflow,
-			final DataflowOutputPort dataflowOutputPort) {
-		return new AbstractDataflowEdit(dataflow) {
-			@Override
-			protected void doEditAction(DataflowImpl dataflow) throws EditException {
-				dataflow.removeDataflowOutputPort(dataflowOutputPort);
-			}
-		};
-	}
-
-	@Override
-	public Edit<Dataflow> getRemoveProcessorEdit(Dataflow dataflow,
-			final Processor processor) {
-		return new AbstractDataflowEdit(dataflow) {
-			@Override
-			protected void doEditAction(DataflowImpl dataflow) {
-				dataflow.removeProcessor(processor);
-			}
-		};
-	}
-
-	@Override
-	public Edit<Dataflow> getRemoveMergeEdit(Dataflow dataflow, final Merge merge) {
-		return new AbstractDataflowEdit(dataflow) {
-			@Override
-			protected void doEditAction(DataflowImpl dataflow) {
-				dataflow.removeMerge(merge);
-			}
-		};
-	}
-
-	@Override
-	public Edit<Dataflow> getAddDataflowInputPortEdit(Dataflow dataflow,
-			DataflowInputPort dataflowInputPort) {
-		if (!(dataflowInputPort instanceof DataflowInputPortImpl))
-			throw new RuntimeException(
-					"The DataflowInputPort is of the wrong implmentation, "
-							+ "it should be of type DataflowInputPortImpl");
-		final DataflowInputPortImpl port = (DataflowInputPortImpl) dataflowInputPort;
-		return new AbstractDataflowEdit(dataflow) {
-			@Override
-			protected void doEditAction(DataflowImpl dataflow)
-					throws EditException {
-				dataflow.addInputPort(port);
-			}
-		};
-	}
-
-	@Override
-	public Edit<Dataflow> getAddDataflowOutputPortEdit(Dataflow dataflow,
-			final DataflowOutputPort dataflowOutputPort) {
-		if (!(dataflowOutputPort instanceof DataflowOutputPortImpl))
-			throw new RuntimeException(
-					"The DataflowOutputPort is of the wrong implmentation, "
-							+ "it should be of type DataflowOutputPortImpl");
-		return new AbstractDataflowEdit(dataflow) {
-			@Override
-			protected void doEditAction(DataflowImpl dataflow)
-					throws EditException {
-				dataflow.addOutputPort((DataflowOutputPortImpl) dataflowOutputPort);
-			}
-		};
-	}
-
-	@Override
-	@SuppressWarnings({ "unchecked", "rawtypes" })
-	public Edit<Activity<?>> getAddActivityInputPortEdit(Activity<?> activity,
-			final ActivityInputPort activityInputPort) {
-		return new AbstractActivityEdit(activity) {
-			@Override
-			protected void doEditAction(AbstractActivity activity) {
-				activity.getInputPorts().add(activityInputPort);
-			}
-		};
-	}
-
-	@Override
-	@SuppressWarnings({ "unchecked", "rawtypes" })
-	public Edit<Activity<?>> getAddActivityInputPortMappingEdit(
-			Activity<?> activity, final String processorPortName,
-			final String activityPortName) {
-		return new AbstractActivityEdit(activity) {
-			@Override
-			protected void doEditAction(AbstractActivity activity)
-					throws EditException {
-				if (activity.getInputPortMapping().containsKey(
-						processorPortName))
-					throw new EditException(
-							"The output mapping for processor name:"
-									+ processorPortName + " already exists");
-				/*
-				 * Note javadoc of getOutputPortMapping - the mapping is
-				 * processorPort -> activityPort -- opposite of the
-				 * outputPortMapping
-				 */
-				activity.getInputPortMapping().put(processorPortName,
-						activityPortName);
-			}
-		};
-	}
-
-	@Override
-	@SuppressWarnings({ "unchecked", "rawtypes" })
-	public Edit<Activity<?>> getAddActivityOutputPortEdit(Activity<?> activity,
-			final ActivityOutputPort activityOutputPort) {
-		return new AbstractActivityEdit(activity) {
-			@Override
-			protected void doEditAction(AbstractActivity activity) {
-				activity.getOutputPorts().add(activityOutputPort);
-			}
-		};
-	}
-
-	@Override
-	@SuppressWarnings({ "unchecked", "rawtypes" })
-	public Edit<Activity<?>> getAddActivityOutputPortMappingEdit(
-			Activity<?> activity, final String processorPortName,
-			final String activityPortName) {
-		return new AbstractActivityEdit(activity) {
-			@Override
-			protected void doEditAction(AbstractActivity activity)
-					throws EditException {
-				Map<String, String> opm = activity.getOutputPortMapping();
-				if (opm.containsKey(activityPortName))
-					throw new EditException("The mapping starting with:"
-							+ activityPortName + " already exists");
-				/*
-				 * Note javadoc of getOutputPortMapping - the mapping is
-				 * activityPort -> processorPort -- opposite of the
-				 * outputPortMapping
-				 */
-				opm.put(activityPortName, processorPortName);
-			}
-		};
-	}
-
-	@Override
-	@SuppressWarnings({ "unchecked", "rawtypes" })
-	public Edit<Activity<?>> getRemoveActivityInputPortEdit(
-			Activity<?> activity, final ActivityInputPort activityInputPort) {
-		return new AbstractActivityEdit(activity) {
-			@Override
-			protected void doEditAction(AbstractActivity activity)
-					throws EditException {
-				activity.getInputPorts().remove(activityInputPort);
-			}
-		};
-	}
-
-	@Override
-	@SuppressWarnings({ "unchecked", "rawtypes" })
-	public Edit<Activity<?>> getRemoveActivityInputPortMappingEdit(
-			Activity<?> activity, final String processorPortName) {
-		return new AbstractActivityEdit(activity) {
-			@Override
-			protected void doEditAction(AbstractActivity activity)
-					throws EditException {
-				if (!activity.getInputPortMapping().containsKey(processorPortName))
-					throw new EditException(
-							"The input port mapping for the processor port name:"
-									+ processorPortName + " doesn't exist");
-				activity.getInputPortMapping().remove(processorPortName);
-			}
-		};
-	}
-
-	@Override
-	@SuppressWarnings({ "unchecked", "rawtypes" })
-	public Edit<Activity<?>> getRemoveActivityOutputPortEdit(
-			Activity<?> activity, final ActivityOutputPort activityOutputPort) {
-		return new AbstractActivityEdit(activity) {
-			@Override
-			protected void doEditAction(AbstractActivity activity)
-					throws EditException {
-				activity.getOutputPorts().remove(activityOutputPort);
-			}
-		};
-	}
-
-	@Override
-	@SuppressWarnings({ "unchecked", "rawtypes" })
-	public Edit<Activity<?>> getRemoveActivityOutputPortMappingEdit(
-			Activity<?> activity, final String processorPortName) {
-		return new AbstractActivityEdit(activity) {
-			@Override
-			protected void doEditAction(AbstractActivity activity)
-					throws EditException {
-				if (!activity.getOutputPortMapping().containsKey(processorPortName))
-					throw new EditException(
-							"The output port mapping for the processor port name:"
-									+ processorPortName + " doesn't exist");
-				activity.getOutputPortMapping().remove(processorPortName);
-			}
-		};
-	}
-
-	@Override
-	public Edit<Merge> getAddMergeInputPortEdit(Merge merge,
-			MergeInputPort mergeInputPort) {
-		if (!(mergeInputPort instanceof MergeInputPortImpl))
-			throw new RuntimeException(
-					"The MergeInputPort is of the wrong implmentation,"
-							+ " it should be of type MergeInputPortImpl");
-		final MergeInputPortImpl port = (MergeInputPortImpl) mergeInputPort;
-		return new AbstractMergeEdit(merge) {
-			@Override
-			protected void doEditAction(MergeImpl mergeImpl) {
-				mergeImpl.addInputPort(port);
-			}
-		};
-	}
-
-	@Override
-	@SuppressWarnings({ "rawtypes", "unchecked" })
-	public <T> Edit<Activity<?>> getConfigureActivityEdit(Activity<T> activity,
-			T configurationBean) {
-		return new ConfigureEdit(Activity.class, activity, configurationBean);
-	}
-
-	@Override
-	public Edit<Processor> getRemoveProcessorInputPortEdit(Processor processor,
-			final ProcessorInputPort port) {
-		return new AbstractProcessorEdit(processor) {
-			@Override
-			protected void doEditAction(ProcessorImpl processor) throws EditException {
-				if (processor.getInputPortWithName(port.getName()) == null)
-					throw new EditException("The processor doesn't have a port named:"
-							+ port.getName());
-				for (IterationStrategyImpl is : processor.iterationStack
-						.getStrategies())
-					is.removeInputByName(port.getName());
-				processor.inputPorts.remove(port);
-			}
-		};
-	}
-
-	@Override
-	public Edit<Processor> getRemoveProcessorOutputPortEdit(
-			Processor processor, final ProcessorOutputPort port) {
-		return new AbstractProcessorEdit(processor) {
-			@Override
-			protected void doEditAction(ProcessorImpl processor) throws EditException {
-				if (processor.getOutputPortWithName(port.getName()) == null)
-					throw new EditException("The processor doesn't have a port named:"
-							+ port.getName());
-				processor.outputPorts.remove(port);
-			}
-		};
-	}
-
-	@Override
-	public Edit<Processor> getMapProcessorPortsForActivityEdit(
-			final Processor processor) {
-		return new EditSupport<Processor>() {
-			@Override
-			public Processor applyEdit() throws EditException {
-				List<Edit<?>> edits = new ArrayList<>();
-				Activity<?> a = processor.getActivityList().get(0);
-
-				List<ProcessorInputPort> inputPortsForRemoval = determineInputPortsForRemoval(
-						processor, a);
-				List<ProcessorOutputPort> outputPortsForRemoval = determineOutputPortsForRemoval(
-						processor, a);
-				Map<ProcessorInputPort, ActivityInputPort> changedInputPorts = determineChangedInputPorts(
-						processor, a);
-				Map<ProcessorOutputPort, ActivityOutputPort> changedOutputPorts = determineChangedOutputPorts(
-						processor, a);
-
-				for (ProcessorInputPort ip : inputPortsForRemoval) {
-					if (ip.getIncomingLink() != null)
-						edits.add(getDisconnectDatalinkEdit(ip
-								.getIncomingLink()));
-					edits.add(getRemoveProcessorInputPortEdit(processor, ip));
-					if (a.getInputPortMapping().containsKey(ip.getName()))
-						edits.add(getRemoveActivityInputPortMappingEdit(a, ip
-								.getName()));
-				}
-				
-				for (ProcessorOutputPort op : outputPortsForRemoval) {
-					if (!op.getOutgoingLinks().isEmpty())
-						for (Datalink link : op.getOutgoingLinks())
-							edits.add(getDisconnectDatalinkEdit(link));
-					edits.add(getRemoveProcessorOutputPortEdit(processor, op));
-					if (a.getOutputPortMapping().containsKey(op.getName()))
-						edits.add(getRemoveActivityOutputPortMappingEdit(a, op
-								.getName()));
-				}
-
-				for (ProcessorInputPort ip : changedInputPorts.keySet()) {
-					Datalink incomingLink = ip.getIncomingLink();
-					if (incomingLink != null)
-						edits.add(getDisconnectDatalinkEdit(incomingLink));
-					edits.add(getRemoveProcessorInputPortEdit(processor, ip));
-					
-					if (incomingLink != null) {
-						ActivityInputPort aip = changedInputPorts.get(ip);
-						ProcessorInputPort pip = createProcessorInputPort(processor,
-								aip.getName(), aip.getDepth());
-						edits.add(getAddProcessorInputPortEdit(processor, pip));
-						edits.add(getConnectDatalinkEdit(new DatalinkImpl(
-								incomingLink.getSource(), pip)));
-					}
-				}
-				
-				for (ProcessorOutputPort op : changedOutputPorts.keySet()) {
-					Set<? extends Datalink> outgoingLinks = op.getOutgoingLinks();
-					for (Datalink link : outgoingLinks)
-						edits.add(getDisconnectDatalinkEdit(link));
-					edits.add(getRemoveProcessorOutputPortEdit(processor, op));
-					
-					if (!outgoingLinks.isEmpty()) {
-						ActivityOutputPort aop = changedOutputPorts.get(op);
-						ProcessorOutputPort pop = createProcessorOutputPort(
-								processor, aop.getName(), aop.getDepth(),
-								aop.getGranularDepth());
-						edits.add(getAddProcessorOutputPortEdit(processor,
-								pop));
-						for (Datalink link : outgoingLinks)
-							edits.add(getConnectDatalinkEdit(createDatalink(
-									pop, link.getSink())));
-					}
-				}
-
-				new CompoundEdit(edits).doEdit();
-				return processor;
-			}
-
-			@Override
-			public Object getSubject() {
-				return processor;
-			}
-
-			private List<ProcessorInputPort> determineInputPortsForRemoval(Processor p,
-					Activity<?> a) {
-				List<ProcessorInputPort> result = new ArrayList<>();
-				processorPorts: for (ProcessorInputPort pPort : p.getInputPorts()) {
-					for (ActivityInputPort aPort : a.getInputPorts())
-						if (aPort.getName().equals(pPort.getName()))
-							continue processorPorts;
-					result.add(pPort);
-				}
-				return result;
-			}
-			
-			private List<ProcessorOutputPort> determineOutputPortsForRemoval(
-					Processor p, Activity<?> a) {
-				List<ProcessorOutputPort> result = new ArrayList<>();
-				processorPorts: for (ProcessorOutputPort pPort : p.getOutputPorts()) {
-					for (OutputPort aPort : a.getOutputPorts())
-						if (aPort.getName().equals(pPort.getName()))
-							continue processorPorts;
-					result.add(pPort);
-				}
-				return result;
-			}
-			
-			private Map<ProcessorInputPort, ActivityInputPort> determineChangedInputPorts(
-					Processor p, Activity<?> a) {
-				Map<ProcessorInputPort, ActivityInputPort> result = new HashMap<>();
-				for (ProcessorInputPort pPort : p.getInputPorts())
-					for (ActivityInputPort aPort : a.getInputPorts())
-						if (aPort.getName().equals(pPort.getName())) {
-							if (pPort.getDepth() != aPort.getDepth())
-								result.put(pPort, aPort);
-							break;
-						}
-				return result;
-			}
-			
-			private Map<ProcessorOutputPort, ActivityOutputPort> determineChangedOutputPorts(
-					Processor p, Activity<?> a) {
-				Map<ProcessorOutputPort, ActivityOutputPort> result = new HashMap<>();
-				for (ProcessorOutputPort pPort : p.getOutputPorts())
-					for (OutputPort aPort : a.getOutputPorts())
-						if (aPort.getName().equals(pPort.getName())) {
-							if ((pPort.getDepth() != aPort.getDepth())
-									|| (pPort.getGranularDepth() != aPort
-											.getGranularDepth()))
-								result.put(pPort, (ActivityOutputPort) aPort);
-							break;
-						}
-				return result;
-			}
-		};
-	}
-
-	private static final int DEFAULT_MAX_JOBS = 1;
-
-	@Override
-	public Edit<Processor> getDefaultDispatchStackEdit(Processor processor) {
-		DispatchStackImpl stack = ((ProcessorImpl) processor)
-				.getDispatchStack();
-		// Top level parallelise layer
-		int layer = 0;
-		List<Edit<?>> edits = new ArrayList<>();
-		edits.add(getAddDispatchLayerEdit(stack, new Parallelize(DEFAULT_MAX_JOBS),
-				layer++));
-		edits.add(getAddDispatchLayerEdit(stack, new ErrorBounce(), layer++));
-		edits.add(getAddDispatchLayerEdit(stack, new Failover(), layer++));
-		edits.add(getAddDispatchLayerEdit(stack, new Retry(), layer++));
-		edits.add(getAddDispatchLayerEdit(stack, new Stop(), layer++));
-		edits.add(getAddDispatchLayerEdit(stack, new Invoke(), layer++));
-
-		final Edit<?> compoundEdit = new CompoundEdit(edits);
-		return new AbstractProcessorEdit(processor) {
-			@Override
-			protected void doEditAction(ProcessorImpl processor)
-					throws EditException {
-				compoundEdit.doEdit();
-			}
-		};
-	}
-
-	@Override
-	public Edit<Processor> getSetIterationStrategyStackEdit(
-			Processor processor,
-			final IterationStrategyStack iterationStrategyStack) {
-		if (!(iterationStrategyStack instanceof IterationStrategyStackImpl))
-			throw new RuntimeException(
-					"Unknown implementation of iteration strategy "
-							+ iterationStrategyStack);
-		return new AbstractProcessorEdit(processor) {
-			@Override
-			protected void doEditAction(ProcessorImpl processor)
-					throws EditException {
-				processor.iterationStack = (IterationStrategyStackImpl) iterationStrategyStack;
-			}
-		};
-	}
-
-	@Override
-	@SuppressWarnings({ "unchecked", "rawtypes" })
-	public <T> Edit<? extends Configurable<T>> getConfigureEdit(
-			Configurable<T> configurable, T configBean) {
-		return new ConfigureEdit(Configurable.class, configurable, configBean);
-	}
-
-	@Override
-	public Edit<Merge> getReorderMergeInputPortsEdit(Merge merge,
-			final List<MergeInputPort> reorderedMergeInputPortList) {
-		return new AbstractMergeEdit(merge) {
-			@Override
-			protected void doEditAction(MergeImpl mergeImpl) {
-				mergeImpl.reorderInputPorts(reorderedMergeInputPortList);
-			}
-		};
-	}
-
-	@Override
-	public Edit<Processor> getRemoveActivityEdit(Processor processor,
-			final Activity<?> activity) {
-		return new AbstractProcessorEdit(processor) {
-			@Override
-			protected void doEditAction(ProcessorImpl processor) {
-				processor.activityList.remove(activity);
-			}
-		};
-	}
-
-	@Override
-	public Edit<IterationStrategyStack> getAddIterationStrategyEdit(
-			IterationStrategyStack iterationStrategyStack,
-			final IterationStrategy strategy) {
-		if (!(iterationStrategyStack instanceof IterationStrategyStackImpl))
-			throw new RuntimeException(
-					"Object being edited must be instance of IterationStrategyStackImpl");
-		final IterationStrategyStackImpl stack = (IterationStrategyStackImpl) iterationStrategyStack;
-		return new EditSupport<IterationStrategyStack>() {
-			@Override
-			public IterationStrategyStack applyEdit() {
-				stack.addStrategy(strategy);
-				return stack;
-			}
-
-			@Override
-			public IterationStrategyStack getSubject() {
-				return stack;
-			}
-		};
-	}
-
-	@Override
-	public Edit<IterationStrategy> getAddIterationStrategyInputNodeEdit(
-			IterationStrategy iterationStrategy,
-			final NamedInputPortNode namedInputPortNode) {
-		if (!(iterationStrategy instanceof IterationStrategyImpl))
-			throw new RuntimeException(
-					"Object being edited must be instance of IterationStrategyImpl");
-		final IterationStrategyImpl strategy = (IterationStrategyImpl) iterationStrategy;
-		return new EditSupport<IterationStrategy>() {
-			@Override
-			public IterationStrategy applyEdit() throws EditException {
-				strategy.addInput(namedInputPortNode);
-				return strategy;
-			}
-
-			@Override
-			public IterationStrategy getSubject() {
-				return strategy;
-			}
-		};
-	}
-
-	@Override
-	public Edit<IterationStrategyStack> getClearIterationStrategyStackEdit(
-			final IterationStrategyStack iterationStrategyStack) {
-		if (!(iterationStrategyStack instanceof IterationStrategyStackImpl))
-			throw new RuntimeException(
-					"Object being edited must be instance of IterationStrategyStackImpl");
-		return new EditSupport<IterationStrategyStack>() {
-			@Override
-			public IterationStrategyStack applyEdit() throws EditException {
-				((IterationStrategyStackImpl) iterationStrategyStack).clear();
-				return iterationStrategyStack;
-			}
-
-			@Override
-			public IterationStrategyStack getSubject() {
-				return iterationStrategyStack;
-			}
-		};
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/MergeImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/MergeImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/MergeImpl.java
deleted file mode 100644
index aba722a..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/MergeImpl.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007-2008 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import static java.lang.System.arraycopy;
-import static java.util.Collections.nCopies;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.invocation.WorkflowDataToken;
-import net.sf.taverna.t2.reference.IdentifiedList;
-import net.sf.taverna.t2.reference.ListService;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.EventForwardingOutputPort;
-import net.sf.taverna.t2.workflowmodel.InputPort;
-import net.sf.taverna.t2.workflowmodel.Merge;
-import net.sf.taverna.t2.workflowmodel.MergeInputPort;
-import net.sf.taverna.t2.workflowmodel.WorkflowStructureException;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.IterationTypeMismatchException;
-
-import org.apache.log4j.Logger;
-
-/**
- * Implementation of {@link Merge}
- * 
- * @author Tom Oinn
- * @author Stian Soiland-Reyes
- *
- */
-class MergeImpl implements Merge {
-	@SuppressWarnings("unused")
-	private static Logger logger = Logger.getLogger(MergeImpl.class);
-	
-	private List<MergeInputPortImpl> inputs = new ArrayList<>();
-	private String name;
-	private BasicEventForwardingOutputPort output;
-	private Map<String, List<T2Reference>> partialOutputsByProcess = new HashMap<>();
-
-	public MergeImpl(String mergeName) {
-		super();
-		this.name = mergeName;
-		this.output = new MergeOutputPortImpl(this, name + "_output", 0, 0);
-	}
-
-	@Override
-	public String getLocalName() {
-		return this.name;
-	}
-	
-	protected void setName(String name) {
-		this.name = name;
-	}
-
-	/**
-	 * Adds a new input port to the internal list of ports.
-	 * 
-	 * @param inputPort
-	 *            the MergeInputPortImpl
-	 */
-	public void addInputPort(MergeInputPortImpl inputPort) {
-		inputs.add(inputPort);
-	}
-
-	/**
-	 * Removes an input port from the internal list of ports.
-	 * 
-	 * @param inputPort
-	 */
-	public void removeInputPort(MergeInputPortImpl inputPort) {
-		inputs.remove(inputPort);
-	}
-
-	@Override
-	public List<? extends MergeInputPort> getInputPorts() {
-		return inputs;
-	}
-
-	@Override
-	public EventForwardingOutputPort getOutputPort() {
-		return this.output;
-	}
-
-	/**
-	 * Return the index of the port with the specified name, or -1 if the port
-	 * can't be found (this is a bad thing!)
-	 * 
-	 * @param portName
-	 * @return
-	 */
-	private int inputPortNameToIndex(String portName) {
-		int i = 0;
-		for (InputPort ip : inputs) {
-			if (ip.getName().equals(portName))
-				return i;
-			i++;
-		}
-		return -1; // FIXME: as the javadoc states, this is a bad thing!
-	}
-
-	protected void receiveEvent(WorkflowDataToken token, String portName) {
-		List<T2Reference> outputList;
-		String owningProcess = token.getOwningProcess();
-		synchronized (partialOutputsByProcess) {
-			outputList = partialOutputsByProcess.get(owningProcess);
-			if (outputList == null) {
-				int numPorts = getInputPorts().size();
-				outputList = new ArrayList<>(nCopies(numPorts, (T2Reference) null));
-				partialOutputsByProcess.put(owningProcess, outputList);
-			}
-		}
-		int portIndex = inputPortNameToIndex(portName);
-		if (portIndex == -1)
-			throw new WorkflowStructureException(
-					"Received event on unknown port " + portName);
-		int[] currentIndex = token.getIndex();
-		int[] newIndex = new int[currentIndex.length + 1];
-		newIndex[0] = portIndex;
-		arraycopy(currentIndex, 0, newIndex, 1, currentIndex.length);
-		InvocationContext context = token.getContext();
-		output.sendEvent(new WorkflowDataToken(owningProcess,
-				newIndex, token.getData(), context));
-		if (token.getIndex().length == 0)
-			// Add to completion list
-			synchronized (outputList) {
-				if (outputList.size() <= portIndex)
-					// Ports changed after initiating running as our list is
-					// smaller than portIndex
-					throw new WorkflowStructureException(
-							"Unexpected addition of output port " + portName
-									+ " at " + portIndex);
-				if (outputList.get(portIndex) != null)
-					throw new WorkflowStructureException(
-							"Already received completion for port " + portName
-									+ " " + outputList.get(portIndex));
-
-				outputList.set(portIndex, token.getData());
-				if (!outputList.contains(null)) {
-					// We're finished, let's register and send out the list
-					ListService listService = context.getReferenceService()
-							.getListService();
-					IdentifiedList<T2Reference> registeredList = listService
-							.registerList(outputList, context);
-					WorkflowDataToken workflowDataToken = new WorkflowDataToken(
-							owningProcess, new int[0], registeredList.getId(),
-							context);
-					synchronized (partialOutputsByProcess) {
-						partialOutputsByProcess.remove(owningProcess);
-					}
-					output.sendEvent(workflowDataToken);
-				}
-			}
-	}
-
-	/**
-	 * There is only ever a single output from a merge node but the token
-	 * processing entity interface defines a list, in this case it always
-	 * contains exactly one item.
-	 */
-	@Override
-	public List<? extends EventForwardingOutputPort> getOutputPorts() {
-		List<EventForwardingOutputPort> result = new ArrayList<>();
-		result.add(output);
-		return result;
-	}
-
-	@Override
-	public boolean doTypeCheck() throws IterationTypeMismatchException {
-		if (inputs.size() == 0)
-			/*
-			 * Arguable, but technically a merge with no inputs is valid, it may
-			 * make more sense to throw an exception here though as it has no
-			 * actual meaning.
-			 */
-			return true;
-		/*
-		 * Return false if we have unbound input ports or bound ports where the
-		 * resolved depth hasn't been calculated yet
-		 */
-		for (MergeInputPort ip : inputs)
-			if (ip.getIncomingLink() == null
-					|| ip.getIncomingLink().getResolvedDepth() == -1)
-				return false;
-
-		// Got all input ports, now scan for input depths
-		int inputDepth = inputs.get(0).getIncomingLink().getResolvedDepth();
-		for (MergeInputPort ip : inputs)
-			if (ip.getIncomingLink().getResolvedDepth() != inputDepth)
-				throw new IterationTypeMismatchException();
-
-		// Set the granular depth to be the input depth as this will be the granularity of the output
-		output.setGranularDepth(inputDepth);
-		/*
-		 * Got to here so all the input resolved depths match, push depth+1 to
-		 * all outgoing links and return true
-		 */
-		for (DatalinkImpl dli : output.outgoingLinks)
-			dli.setResolvedDepth(inputDepth+1);
-		return true;
-	}
-
-	@SuppressWarnings("unchecked")
-	public void reorderInputPorts(
-			List<? extends MergeInputPort> reorderedInputPortList) {
-		// Just set the inputs to the already reordered list of ports
-		inputs = (List<MergeInputPortImpl>) reorderedInputPortList;	
-	}
-	
-	@Override
-	public String toString() {
-		return "Merge " + getLocalName();
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/MergeInputPortImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/MergeInputPortImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/MergeInputPortImpl.java
deleted file mode 100644
index a56a710..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/MergeInputPortImpl.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import net.sf.taverna.t2.invocation.WorkflowDataToken;
-import net.sf.taverna.t2.workflowmodel.Merge;
-import net.sf.taverna.t2.workflowmodel.MergeInputPort;
-
-class MergeInputPortImpl extends AbstractEventHandlingInputPort implements
-		MergeInputPort {
-	private MergeImpl parent;
-
-	protected MergeInputPortImpl(MergeImpl merge, String name, int depth) {
-		super(name, depth);
-		this.parent = merge;
-	}
-
-	@Override
-	public void receiveEvent(WorkflowDataToken t) {
-		parent.receiveEvent(t, this.name);
-	}
-
-	@Override
-	public Merge getMerge() {
-		return parent;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/MergeOutputPortImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/MergeOutputPortImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/MergeOutputPortImpl.java
deleted file mode 100644
index 6ef19b2..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/MergeOutputPortImpl.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import net.sf.taverna.t2.workflowmodel.Merge;
-import net.sf.taverna.t2.workflowmodel.MergeOutputPort;
-
-class MergeOutputPortImpl extends BasicEventForwardingOutputPort
-		implements MergeOutputPort {
-	private Merge merge;
-
-	public MergeOutputPortImpl(Merge merge, String portName, int portDepth,
-			int granularDepth) {
-		super(portName, portDepth, granularDepth);
-		this.merge = merge;
-	}
-
-	@Override
-	public Merge getMerge() {
-		return merge;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ProcessorCrystalizerImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ProcessorCrystalizerImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ProcessorCrystalizerImpl.java
deleted file mode 100644
index 90debf0..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ProcessorCrystalizerImpl.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import net.sf.taverna.t2.invocation.Completion;
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.invocation.WorkflowDataToken;
-import net.sf.taverna.t2.reference.ReferenceService;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.OutputPort;
-import net.sf.taverna.t2.workflowmodel.WorkflowStructureException;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Job;
-
-/**
- * AbstractCrystalizer bound to a specific ProcessorImpl
- * 
- * @author Tom Oinn
- */
-public class ProcessorCrystalizerImpl extends AbstractCrystalizer {
-	private ProcessorImpl parent;
-
-	/**
-	 * Create and bind to the specified ProcessorImpl
-	 * 
-	 * @param parent
-	 */
-	protected ProcessorCrystalizerImpl(ProcessorImpl parent) {
-		this.parent = parent;
-	}
-
-	@Override
-	public void completionCreated(Completion completion) {
-		throw new WorkflowStructureException(
-				"Should never see this if everything is working,"
-						+ "if this occurs it is likely that the internal "
-						+ "logic is broken, talk to Tom");
-	}
-
-	@Override
-	public void jobCreated(Job outputJob) {
-		for (String outputPortName : outputJob.getData().keySet()) {
-			WorkflowDataToken token = new WorkflowDataToken(
-					outputJob.getOwningProcess(), outputJob.getIndex(),
-					outputJob.getData().get(outputPortName),
-					outputJob.getContext());
-			parent.getOutputPortWithName(outputPortName).receiveEvent(token);
-		}
-	}
-
-	@Override
-	/**
-	 * Used to construct a Job of empty lists at the appropriate depth in the
-	 * event of a completion hitting the crystalizer before it sees a child
-	 * node, i.e. the result of iterating over an empty collection structure of
-	 * some kind.
-	 */
-	public Job getEmptyJob(String owningProcess, int[] index,
-			InvocationContext context) {
-		int wrappingDepth = parent.resultWrappingDepth;
-		if (wrappingDepth < 0)
-			throw new RuntimeException("Processor [" + owningProcess
-					+ "] hasn't been configured, cannot emit empty job");
-		/*
-		 * The wrapping depth is the length of index array that would be used if
-		 * a single item of the output port type were returned. We can examine
-		 * the index array for the node we're trying to create and use this to
-		 * work out how much we need to add to the output port depth to create
-		 * empty lists of the right type given the index array.
-		 */
-		int depth = wrappingDepth - index.length;
-		// TODO - why was this incrementing?
-		// depth++;
-
-		ReferenceService rs = context.getReferenceService();
-		Map<String, T2Reference> emptyJobMap = new HashMap<>();
-		for (OutputPort op : parent.getOutputPorts())
-			emptyJobMap.put(op.getName(), rs.getListService()
-					.registerEmptyList(depth + op.getDepth(), context).getId());
-		return new Job(owningProcess, index, emptyJobMap, context);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ProcessorImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ProcessorImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ProcessorImpl.java
deleted file mode 100644
index d4ecd28..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ProcessorImpl.java
+++ /dev/null
@@ -1,426 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import static java.util.Collections.unmodifiableList;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import net.sf.taverna.t2.annotation.AbstractAnnotatedThing;
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.invocation.IterationInternalEvent;
-import net.sf.taverna.t2.lang.observer.MultiCaster;
-import net.sf.taverna.t2.lang.observer.Observer;
-import net.sf.taverna.t2.monitor.MonitorManager;
-import net.sf.taverna.t2.monitor.MonitorableProperty;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.Condition;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import net.sf.taverna.t2.workflowmodel.DataflowValidationReport;
-import net.sf.taverna.t2.workflowmodel.InvalidDataflowException;
-import net.sf.taverna.t2.workflowmodel.Processor;
-import net.sf.taverna.t2.workflowmodel.ProcessorFinishedEvent;
-import net.sf.taverna.t2.workflowmodel.ProcessorInputPort;
-import net.sf.taverna.t2.workflowmodel.ProcessorOutputPort;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Job;
-import net.sf.taverna.t2.workflowmodel.processor.activity.NestedDataflow;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.PropertyContributingDispatchLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.impl.DispatchStackImpl;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.IterationTypeMismatchException;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.MissingIterationInputException;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.impl.IterationStrategyImpl;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.impl.IterationStrategyStackImpl;
-
-import org.apache.log4j.Logger;
-
-/**
- * Implementation of Processor
- * 
- * @author Tom Oinn
- * @author Stuart Owen
- * @author Alex Nenadic
- * 
- */
-public final class ProcessorImpl extends AbstractAnnotatedThing<Processor>
-		implements Processor {
-	private static int pNameCounter = 0;
-	private static Logger logger = Logger.getLogger(ProcessorImpl.class);
-
-	protected List<ConditionImpl> conditions = new ArrayList<>();
-	protected List<ConditionImpl> controlledConditions = new ArrayList<>();
-	protected List<ProcessorInputPortImpl> inputPorts = new ArrayList<>();
-	protected List<ProcessorOutputPortImpl> outputPorts = new ArrayList<>();
-	protected List<Activity<?>> activityList = new ArrayList<>();
-	protected AbstractCrystalizer crystalizer;
-	protected DispatchStackImpl dispatchStack;
-	protected IterationStrategyStackImpl iterationStack;
-	protected String name;
-	public transient int resultWrappingDepth = -1;
-	protected transient Map<String, Set<MonitorableProperty<?>>> monitorables = new HashMap<>();
-	private MultiCaster<ProcessorFinishedEvent> processorFinishedMultiCaster = new MultiCaster<>(
-			this);
-
-	/**
-	 * <p>
-	 * Create a new processor implementation with default blank iteration
-	 * strategy and dispatch stack.
-	 * </p>
-	 * <p>
-	 * This constructor is protected to enforce that an instance can only be
-	 * created via the {@link EditsImpl#createProcessor(String)} method.
-	 * </p>
-	 */
-
-	protected ProcessorImpl() {
-		// Set a default name
-		name = "UnnamedProcessor" + (pNameCounter++);
-
-		/*
-		 * Create iteration stack, configure it to send jobs and completion
-		 * events to the dispatch stack.
-		 */
-		iterationStack = new IterationStrategyStackImpl() {
-			@Override
-			protected void receiveEventFromStrategy(IterationInternalEvent<?> e) {
-				dispatchStack.receiveEvent(e);
-			}
-		};
-		iterationStack.addStrategy(new IterationStrategyImpl());
-
-		// Configure dispatch stack to push output events to the crystalizer
-		dispatchStack = new DispatchStackImpl() {
-			@Override
-			protected String getProcessName() {
-				return ProcessorImpl.this.name;
-			}
-
-			@Override
-			public Processor getProcessor() {
-				return ProcessorImpl.this;
-			}
-
-			/**
-			 * Called when an event bubbles out of the top of the dispatch
-			 * stack. In this case we pass it into the crystalizer.
-			 */
-			@Override
-			protected void pushEvent(IterationInternalEvent<?> e) {
-				crystalizer.receiveEvent(e);
-			}
-
-			/**
-			 * Iterate over all the preconditions and return true if and only if
-			 * all are satisfied for the given process identifier.
-			 */
-			@Override
-			protected boolean conditionsSatisfied(String owningProcess) {
-				for (Condition c : conditions)
-					if (c.isSatisfied(owningProcess) == false)
-						return false;
-				return true;
-			}
-
-			@Override
-			protected List<? extends Activity<?>> getActivities() {
-				return ProcessorImpl.this.getActivityList();
-			}
-
-			/**
-			 * We've finished here, set the satisfied property on any controlled
-			 * condition objects to true and notify the targets.
-			 */
-			@Override
-			protected void finishedWith(String owningProcess) {
-				if (!controlledConditions.isEmpty()) {
-					String enclosingProcess = owningProcess.substring(0,
-							owningProcess.lastIndexOf(':'));
-					for (ConditionImpl ci : controlledConditions) {
-						ci.satisfy(enclosingProcess);
-						ci.getTarget().getDispatchStack()
-								.satisfyConditions(enclosingProcess);
-					}
-				}
-				/*
-				 * Tell whoever is interested that the processor has finished
-				 * executing
-				 */
-				processorFinishedMultiCaster.notify(new ProcessorFinishedEvent(
-						this.getProcessor(), owningProcess));
-			}
-
-			@Override
-			public void receiveMonitorableProperty(MonitorableProperty<?> prop,
-					String processID) {
-				synchronized (monitorables) {
-					Set<MonitorableProperty<?>> props = monitorables
-							.get(processID);
-					if (props == null) {
-						props = new HashSet<>();
-						monitorables.put(processID, props);
-					}
-					props.add(prop);
-				}
-			}
-		};
-
-		// Configure crystalizer to send realized events to the output ports
-		crystalizer = new ProcessorCrystalizerImpl(this);
-	}
-
-	/**
-	 * When called this method configures input port filters and the
-	 * crystalizer, pushing cardinality information into outgoing datalinks.
-	 * 
-	 * @return true if the typecheck was successful or false if the check failed
-	 *         because there were preconditions missing such as unsatisfied
-	 *         input types
-	 * @throws IterationTypeMismatchException
-	 *             if the typing occured but didn't match because of an
-	 *             iteration mismatch
-	 * @throws InvalidDataflowException
-	 *             if the entity depended on a dataflow that was not valid
-	 */
-	@Override
-	public boolean doTypeCheck() throws IterationTypeMismatchException,
-			InvalidDataflowException {
-		// Check for any nested dataflows, they should all be valid
-		for (Activity<?> activity : getActivityList())
-			if (activity instanceof NestedDataflow) {
-				NestedDataflow nestedDataflowActivity = (NestedDataflow) activity;
-				Dataflow nestedDataflow = nestedDataflowActivity
-						.getNestedDataflow();
-				DataflowValidationReport validity = nestedDataflow
-						.checkValidity();
-				if (!validity.isValid())
-					throw new InvalidDataflowException(nestedDataflow, validity);
-			}
-
-		/*
-		 * Check whether all our input ports have inbound links
-		 */
-
-		Map<String, Integer> inputDepths = new HashMap<>();
-		for (ProcessorInputPortImpl input : inputPorts) {
-			if (input.getIncomingLink() == null)
-				return false;
-			if (input.getIncomingLink().getResolvedDepth() == -1)
-				/*
-				 * Incoming link hasn't been resolved yet, can't do this
-				 * processor at the moment
-				 */
-				return false;
-
-			// Get the conceptual resolved depth of the datalink
-			inputDepths.put(input.getName(), input.getIncomingLink()
-					.getResolvedDepth());
-			/*
-			 * Configure the filter with the finest grained item from the link
-			 * source
-			 */
-			input.setFilterDepth(input.getIncomingLink().getSource()
-					.getGranularDepth());
-		}
-
-		/*
-		 * Got here so we have all the inputs, now test whether the iteration
-		 * strategy typechecks correctly
-		 */
-
-		try {
-			this.resultWrappingDepth = iterationStack
-					.getIterationDepth(inputDepths);
-			for (BasicEventForwardingOutputPort output : outputPorts)
-				for (DatalinkImpl outgoingLink : output.outgoingLinks)
-					// Set the resolved depth on each output edge
-					outgoingLink.setResolvedDepth(this.resultWrappingDepth
-							+ output.getDepth());
-		} catch (MissingIterationInputException e) {
-			/*
-			 * This should never happen as we only get here if we've already
-			 * checked that all the inputs have been provided. If it does happen
-			 * we've got some deeper issues.
-			 */
-			logger.error(e);
-			return false;
-		}
-
-		// If we get to here everything has been configured appropriately
-		return true;
-	}
-
-	/* Utility methods */
-
-	protected ProcessorInputPortImpl getInputPortWithName(String name) {
-		for (ProcessorInputPortImpl p : inputPorts) {
-			String portName = p.getName();
-			if (portName.equals(name))
-				return p;
-		}
-		return null;
-	}
-
-	protected ProcessorOutputPortImpl getOutputPortWithName(String name) {
-		for (ProcessorOutputPortImpl p : outputPorts) {
-			String portName = p.getName();
-			if (portName.equals(name))
-				return p;
-		}
-		return null;
-	}
-
-	/* Implementations of Processor interface */
-
-	@Override
-	public void fire(String enclosingProcess, InvocationContext context) {
-		Job newJob = new Job(enclosingProcess + ":" + this.name, new int[0],
-				new HashMap<String, T2Reference>(), context);
-		dispatchStack.receiveEvent(newJob);
-	}
-
-	@Override
-	public List<? extends Condition> getPreconditionList() {
-		return unmodifiableList(conditions);
-	}
-
-	@Override
-	public List<? extends Condition> getControlledPreconditionList() {
-		return unmodifiableList(controlledConditions);
-	}
-
-	@Override
-	public DispatchStackImpl getDispatchStack() {
-		return dispatchStack;
-	}
-
-	@Override
-	public IterationStrategyStackImpl getIterationStrategy() {
-		return iterationStack;
-	}
-
-	@Override
-	public List<? extends ProcessorInputPort> getInputPorts() {
-		return unmodifiableList(inputPorts);
-	}
-
-	@Override
-	public List<? extends ProcessorOutputPort> getOutputPorts() {
-		return unmodifiableList(outputPorts);
-	}
-
-	@Override
-	public List<? extends Activity<?>> getActivityList() {
-		return unmodifiableList(activityList);
-	}
-
-	protected void setName(String newName) {
-		this.name = newName;
-	}
-
-	@Override
-	public String getLocalName() {
-		return this.name;
-	}
-
-	/**
-	 * Called by the DataflowImpl containing this processor requesting that it
-	 * register itself with the monitor tree under the specified process
-	 * identifier.
-	 * 
-	 * @param dataflowOwningProcess
-	 *            the process identifier of the parent dataflow, the processor
-	 *            must register with this as the base path plus the local name
-	 */
-	void registerWithMonitor(String dataflowOwningProcess) {
-		/*
-		 * Given the dataflow process identifier, so append local name to get
-		 * the process identifier that will be applied to incoming data tokens
-		 */
-		String processID = dataflowOwningProcess + ":" + getLocalName();
-
-		/*
-		 * The set of monitorable (and steerable) properties for this processor
-		 * level monitor node
-		 */
-		Set<MonitorableProperty<?>> properties = new HashSet<>();
-
-		/*
-		 * If any dispatch layers implement PropertyContributingDispatchLayer
-		 * then message them to push their properties into the property store
-		 * within the dispatch stack. In this case the anonymous inner class
-		 * implements this by storing them in a protected map within
-		 * ProcessoImpl from where they can be recovered after the iteration has
-		 * finished.
-		 */
-		for (DispatchLayer<?> layer : dispatchStack.getLayers())
-			if (layer instanceof PropertyContributingDispatchLayer)
-				((PropertyContributingDispatchLayer<?>) layer)
-						.injectPropertiesFor(processID);
-		/*
-		 * All layers have now injected properties into the parent dispatch
-		 * stack, which has responded by building an entry in the monitorables
-		 * map in this class. We can pull everything out of it and remove the
-		 * entry quite safely at this point.
-		 */
-		synchronized (monitorables) {
-			Set<MonitorableProperty<?>> layerProps = monitorables
-					.get(processID);
-			if (layerProps != null) {
-				for (MonitorableProperty<?> prop : layerProps)
-					properties.add(prop);
-				monitorables.remove(processID);
-			}
-		}
-
-		/*
-		 * Register the node with the monitor tree, including any aggregated
-		 * properties from layers.
-		 */
-		MonitorManager.getInstance().registerNode(this,
-				dataflowOwningProcess + ":" + getLocalName(), properties);
-	}
-
-	@Override
-	public void addObserver(Observer<ProcessorFinishedEvent> observer) {
-		processorFinishedMultiCaster.addObserver(observer);
-	}
-
-	@Override
-	public List<Observer<ProcessorFinishedEvent>> getObservers() {
-		return processorFinishedMultiCaster.getObservers();
-	}
-
-	@Override
-	public void removeObserver(Observer<ProcessorFinishedEvent> observer) {
-		processorFinishedMultiCaster.removeObserver(observer);
-	}
-
-	@Override
-	public String toString() {
-		return "Processor " + getLocalName();
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ProcessorInputPortImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ProcessorInputPortImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ProcessorInputPortImpl.java
deleted file mode 100644
index d0a23eb..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ProcessorInputPortImpl.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.Processor;
-import net.sf.taverna.t2.workflowmodel.ProcessorInputPort;
-
-/**
- * An implementation of the filtering input port interface used as an input for
- * a ProcessorImpl. If the filter level is undefined this input port will always
- * throw workflow structure exceptions when you push data into it. This port
- * must be linked to a crystalizer or something which offers the same
- * operational contract, it requires a full hierarchy of data tokens (i.e. if
- * you push something in with an index you must at some point subsequent to that
- * push at least a single list in with the empty index)
- * 
- * @author Tom Oinn
- */
-class ProcessorInputPortImpl extends AbstractFilteringInputPort implements
-		ProcessorInputPort {
-	private ProcessorImpl parent;
-
-	protected ProcessorInputPortImpl(ProcessorImpl parent, String name,
-			int depth) {
-		super(name, depth);
-		this.parent = parent;
-	}
-
-	@Override
-	public String transformOwningProcess(String oldOwner) {
-		return oldOwner + ":" + parent.getLocalName();
-	}
-
-	@Override
-	protected void pushCompletion(String portName, String owningProcess,
-			int[] index, InvocationContext context) {
-		parent.iterationStack.receiveCompletion(portName, owningProcess, index,
-				context);
-	}
-
-	@Override
-	protected void pushData(String portName, String owningProcess, int[] index,
-			T2Reference data, InvocationContext context) {
-		parent.iterationStack.receiveData(portName, owningProcess, index, data,
-				context);
-	}
-
-	@Override
-	public Processor getProcessor() {
-		return this.parent;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ProcessorOutputPortImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ProcessorOutputPortImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ProcessorOutputPortImpl.java
deleted file mode 100644
index 86817a0..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/ProcessorOutputPortImpl.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import net.sf.taverna.t2.invocation.WorkflowDataToken;
-import net.sf.taverna.t2.workflowmodel.Processor;
-import net.sf.taverna.t2.workflowmodel.ProcessorOutputPort;
-
-/**
- * Extension of AbstractOutputPort for use as the output port on a
- * ProcessorImpl. Contains additional logic to relay workflow data tokens from
- * the internal crystalizer to each in a set of target FilteringInputPort
- * instances.
- * 
- * @author Tom Oinn
- * @author Stuart Owen
- */
-class ProcessorOutputPortImpl extends BasicEventForwardingOutputPort implements
-		ProcessorOutputPort {
-	private ProcessorImpl parent;
-
-	protected ProcessorOutputPortImpl(ProcessorImpl parent, String portName,
-			int portDepth, int granularDepth) {
-		super(portName, portDepth, granularDepth);
-		this.parent = parent;
-	}
-
-	/**
-	 * Strip off the last id in the owning process stack (as this will have been
-	 * pushed onto the stack on entry to the processor) and relay the event to
-	 * the targets.
-	 */
-	protected void receiveEvent(WorkflowDataToken token) {
-		sendEvent(token.popOwningProcess());
-	}
-
-	@Override
-	public Processor getProcessor() {
-		return this.parent;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/package.html b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/package.html
deleted file mode 100644
index 46b9fee..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/package.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<body>
-Implementation package for workflow entities
-</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/impl/ActivityInputPortImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/impl/ActivityInputPortImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/impl/ActivityInputPortImpl.java
deleted file mode 100644
index 0d261a2..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/processor/activity/impl/ActivityInputPortImpl.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.activity.impl;
-
-import static java.util.Collections.unmodifiableList;
-
-import java.util.List;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.workflowmodel.AbstractPort;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityInputPort;
-
-/**
- * An input port on an Activity instance. Simply used as a bean to hold port
- * name and depth properties.
- * 
- * @author Tom Oinn
- * @author Stuart Owen
- */
-public class ActivityInputPortImpl extends AbstractPort implements
-		ActivityInputPort {
-	private Class<?> translatedElementClass;
-	private List<Class<? extends ExternalReferenceSPI>> handledReferenceSchemes;
-	boolean allowsLiteralValues;
-
-	/**
-	 * Constructs an Activity input port instance with the provided name and
-	 * depth.
-	 * 
-	 * @param portName
-	 * @param portDepth
-	 */
-	public ActivityInputPortImpl(String portName, int portDepth) {
-		super(portName, portDepth);
-	}
-
-	/**
-	 * Constructs an Activity input port with the provided name and depth,
-	 * together with a list of predetermined annotations.
-	 * 
-	 * @param portName
-	 * @param portDepth
-	 */
-	public ActivityInputPortImpl(
-			String portName,
-			int portDepth,
-			boolean allowsLiteralValues,
-			List<Class<? extends ExternalReferenceSPI>> handledReferenceSchemes,
-			Class<?> translatedElementClass) {
-		this(portName, portDepth);
-		this.allowsLiteralValues = allowsLiteralValues;
-		this.handledReferenceSchemes = handledReferenceSchemes;
-		this.translatedElementClass = translatedElementClass;
-	}
-
-	@Override
-	public boolean allowsLiteralValues() {
-		return this.allowsLiteralValues;
-	}
-
-	@Override
-	public List<Class<? extends ExternalReferenceSPI>> getHandledReferenceSchemes() {
-		return unmodifiableList(this.handledReferenceSchemes);
-	}
-
-	@Override
-	public Class<?> getTranslatedElementClass() {
-		return this.translatedElementClass;
-	}
-}


[09/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/processor/iteration/TestIterationStrategyNodes.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/processor/iteration/TestIterationStrategyNodes.java b/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/processor/iteration/TestIterationStrategyNodes.java
new file mode 100644
index 0000000..b6a7b19
--- /dev/null
+++ b/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/processor/iteration/TestIterationStrategyNodes.java
@@ -0,0 +1,211 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.iteration;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.Map;
+
+import javax.swing.tree.TreeNode;
+
+import org.apache.taverna.invocation.Completion;
+import org.apache.taverna.workflowmodel.processor.activity.Job;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test {@link AbstractIterationStrategyNode} implementations for
+ * {@link TreeNode} behaviour.
+ * 
+ * @author Stian Soiland-Reyes
+ * 
+ */
+public class TestIterationStrategyNodes {
+
+	TerminalNode root;
+	private NamedInputPortNode input1;
+	private NamedInputPortNode input2;
+	private CrossProduct crossProduct1;
+	private CrossProduct crossProduct2;
+	private DotProduct dotProduct1;
+	private DotProduct dotProduct2;
+
+	@Test
+	public void addSingleChildToTerminal() throws Exception {
+		assertNull(input1.getParent());
+		assertEquals(0, root.getChildCount());
+		root.insert(input1);
+		assertEquals(root, input1.getParent());
+		assertEquals(1, root.getChildCount());
+		assertEquals(input1, root.getChildAt(0));
+		assertEquals(Arrays.asList(input1), root.getChildren());
+
+		root.insert(input1);
+		assertEquals(1, root.getChildCount());
+
+		root.insert(input1, 0);
+		assertEquals(1, root.getChildCount());
+	}
+
+	@Test(expected = IllegalStateException.class)
+	public void cantAddSeveralChildrenToTerminal() throws Exception {
+		root.insert(input1);
+		root.insert(input2);
+	}
+
+	@Test
+	public void addCrossProduct() throws Exception {
+		assertNull(crossProduct1.getParent());
+		crossProduct1.setParent(root);
+		assertEquals(root, crossProduct1.getParent());
+		assertEquals(1, root.getChildCount());
+		assertEquals(crossProduct1, root.getChildAt(0));
+		assertEquals(Arrays.asList(crossProduct1), root.getChildren());
+		assertEquals(0, crossProduct1.getChildCount());
+
+		crossProduct1.insert(input1);
+		assertEquals(input1, crossProduct1.getChildAt(0));
+		crossProduct1.insert(input2, 0);
+		assertEquals(input2, crossProduct1.getChildAt(0));
+		assertEquals(input1, crossProduct1.getChildAt(1));
+		assertEquals(2, crossProduct1.getChildCount());
+		assertEquals(Arrays.asList(input2, input1), crossProduct1.getChildren());
+
+		// A re-insert should move it
+		crossProduct1.insert(input2, 2);
+		assertEquals(2, crossProduct1.getChildCount());
+		assertEquals(Arrays.asList(input1, input2), crossProduct1.getChildren());
+
+		crossProduct1.insert(input2, 0);
+		assertEquals(Arrays.asList(input2, input1), crossProduct1.getChildren());
+
+		crossProduct1.insert(input1, 1);
+		assertEquals(Arrays.asList(input2, input1), crossProduct1.getChildren());
+	}
+
+	@Test
+	public void addCrossProductMany() {
+		crossProduct1.insert(dotProduct1);
+		crossProduct1.insert(dotProduct2);
+		crossProduct1.insert(input1);
+		crossProduct1.insert(input2);
+		crossProduct1.insert(crossProduct2);
+		assertEquals(5, crossProduct1.getChildCount());
+		assertEquals(Arrays.asList(dotProduct1, dotProduct2, input1, input2,
+				crossProduct2), crossProduct1.getChildren());
+		Enumeration<IterationStrategyNode> enumeration = crossProduct1
+				.children();
+		assertTrue(enumeration.hasMoreElements());
+		assertEquals(dotProduct1, enumeration.nextElement());
+		assertEquals(dotProduct2, enumeration.nextElement());
+		assertEquals(input1, enumeration.nextElement());
+		assertEquals(input2, enumeration.nextElement());
+		assertEquals(crossProduct2, enumeration.nextElement());
+		assertFalse(enumeration.hasMoreElements());
+	}
+
+	@Test
+	public void moveNodeToDifferentParent() {
+		crossProduct1.setParent(root);
+		crossProduct1.insert(input1);
+		crossProduct1.insert(dotProduct1);
+		dotProduct1.insert(input2);
+		dotProduct1.insert(crossProduct2);
+
+		// Check tree
+		assertEquals(crossProduct2, root.getChildAt(0).getChildAt(1)
+				.getChildAt(1));
+		assertEquals(Arrays.asList(input2, crossProduct2), dotProduct1
+				.getChildren());
+
+		crossProduct1.insert(crossProduct2, 1);
+		assertEquals(Arrays.asList(input1, crossProduct2, dotProduct1),
+				crossProduct1.getChildren());
+		assertEquals(crossProduct1, crossProduct2.getParent());
+		// Should no longer be in dotProduct1
+		assertEquals(Arrays.asList(input2), dotProduct1.getChildren());
+	}
+
+	@Test(expected = IllegalStateException.class)
+	public void cantAddToNamedInput() throws Exception {
+		input1.insert(dotProduct1);
+	}
+
+	@Test
+	public void cantAddSelf() throws Exception {
+		dotProduct1.setParent(crossProduct1);
+		try {
+			dotProduct1.insert(dotProduct1);
+			fail("Didn't throw IllegalArgumentException");
+		} catch (IllegalArgumentException ex) {
+			// Make sure we didn't loose our old parent and
+			// ended up in a funny state
+			assertEquals(crossProduct1, dotProduct1.getParent());
+			assertEquals(dotProduct1, crossProduct1.getChildAt(0));
+		}
+	}
+
+	@Test
+	public void cantSetSelfParent() throws Exception {
+		crossProduct1.insert(dotProduct1);
+		try {
+			dotProduct1.setParent(dotProduct1);
+			fail("Didn't throw IllegalArgumentException");
+		} catch (IllegalArgumentException ex) {
+			// Make sure we didn't loose our old parent and
+			// ended up in a funny state
+			assertEquals(crossProduct1, dotProduct1.getParent());
+			assertEquals(dotProduct1, crossProduct1.getChildAt(0));
+		}
+	}
+
+	@Before
+	public void makeNodes() throws Exception {
+		root = new DummyTerminalNode();
+		input1 = new NamedInputPortNode("input1", 1);
+		input2 = new NamedInputPortNode("input2", 2);
+		crossProduct1 = new CrossProduct();
+		crossProduct2 = new CrossProduct();
+		dotProduct1 = new DotProduct();
+		dotProduct2 = new DotProduct();
+	}
+
+	@SuppressWarnings("serial")
+	protected final class DummyTerminalNode extends TerminalNode {
+
+		@Override
+		public int getIterationDepth(Map<String, Integer> inputDepths)
+				throws IterationTypeMismatchException {
+			return 0;
+		}
+
+		@Override
+		public void receiveCompletion(int inputIndex, Completion completion) {
+		}
+
+		@Override
+		public void receiveJob(int inputIndex, Job newJob) {
+		}
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/test/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/test/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker b/taverna-workflowmodel-api/src/test/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
deleted file mode 100644
index 63bb2e4..0000000
--- a/taverna-workflowmodel-api/src/test/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
+++ /dev/null
@@ -1,3 +0,0 @@
-net.sf.taverna.t2.workflowmodel.health.StringHealthChecker
-net.sf.taverna.t2.workflowmodel.health.FloatHealthChecker
-net.sf.taverna.t2.workflowmodel.health.FloatHealthChecker2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/test/resources/META-INF/services/org.apache.taverna.workflowmodel.health.HealthChecker
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/test/resources/META-INF/services/org.apache.taverna.workflowmodel.health.HealthChecker b/taverna-workflowmodel-api/src/test/resources/META-INF/services/org.apache.taverna.workflowmodel.health.HealthChecker
new file mode 100644
index 0000000..1e0484d
--- /dev/null
+++ b/taverna-workflowmodel-api/src/test/resources/META-INF/services/org.apache.taverna.workflowmodel.health.HealthChecker
@@ -0,0 +1,3 @@
+org.apache.taverna.workflowmodel.health.StringHealthChecker
+org.apache.taverna.workflowmodel.health.FloatHealthChecker
+org.apache.taverna.workflowmodel.health.FloatHealthChecker2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/CoreDispatchLayerFactory.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/CoreDispatchLayerFactory.java b/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/CoreDispatchLayerFactory.java
deleted file mode 100644
index 0b11627..0000000
--- a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/CoreDispatchLayerFactory.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.layers;
-
-import java.net.URI;
-import java.util.HashSet;
-import java.util.Set;
-
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchLayerFactory;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * Factory for creating core dispatch layers.
- *
- * The core dispatch layers are :
- * <ul>
- * <li>ErrorBounce</li>
- * <li>Parallelize</li>
- * <li>Failover</li>
- * <li>Retry</li>
- * <li>Stop</li>
- * <li>Invoke</li>
- * <li>Loop</li>
- * <li>IntermediateProvenance</li>
- * </ul>
- *
- * @author David Withers
- */
-public class CoreDispatchLayerFactory implements DispatchLayerFactory {
-	private static final URI parallelizeLayer = URI.create(Parallelize.URI);
-	private static final URI errorBounceLayer = URI.create(ErrorBounce.URI);
-	private static final URI failoverLayer = URI.create(Failover.URI);
-	private static final URI retryLayer = URI.create(Retry.URI);
-	private static final URI invokeLayer = URI.create(Invoke.URI);
-	private static final URI loopLayer = URI.create(Loop.URI);
-	private static final URI intermediateProvenanceLayer = URI.create(IntermediateProvenance.URI);
-	private static final URI stopLayer = URI.create(Stop.URI);
-
-	private final static Set<URI> dispatchLayerURIs = new HashSet<URI>();
-
-	static {
-		dispatchLayerURIs.add(parallelizeLayer);
-		dispatchLayerURIs.add(errorBounceLayer);
-		dispatchLayerURIs.add(failoverLayer);
-		dispatchLayerURIs.add(retryLayer);
-		dispatchLayerURIs.add(invokeLayer);
-		dispatchLayerURIs.add(loopLayer);
-		dispatchLayerURIs.add(intermediateProvenanceLayer);
-		dispatchLayerURIs.add(stopLayer);
-	}
-
-	@Override
-	public DispatchLayer<?> createDispatchLayer(URI uri) {
-		if (parallelizeLayer.equals(uri))
-			return new Parallelize();
-		else if (errorBounceLayer.equals(uri))
-			return new ErrorBounce();
-		else if (failoverLayer.equals(uri))
-			return new Failover();
-		else if (retryLayer.equals(uri))
-			return new Retry();
-		else if (invokeLayer.equals(uri))
-			return new Invoke();
-		else if (loopLayer.equals(uri))
-			return new Loop();
-		else if (intermediateProvenanceLayer.equals(uri))
-			return new IntermediateProvenance();
-		else if (stopLayer.equals(uri))
-			return new Stop();
-		return null;
-	}
-
-	@Override
-	public JsonNode getDispatchLayerConfigurationSchema(URI uri) {
-		// TODO
-		return null;
-	}
-
-	@Override
-	public Set<URI> getDispatchLayerTypes() {
-		return dispatchLayerURIs;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/ErrorBounce.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/ErrorBounce.java b/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/ErrorBounce.java
deleted file mode 100644
index dfde240..0000000
--- a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/ErrorBounce.java
+++ /dev/null
@@ -1,324 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.layers;
-
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.CREATE_PROCESS_STATE;
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.NO_EFFECT;
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.UPDATE_PROCESS_STATE;
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchMessageType.RESULT;
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.TimerTask;
-import java.util.concurrent.ConcurrentHashMap;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-import net.sf.taverna.t2.invocation.Event;
-import net.sf.taverna.t2.monitor.MonitorableProperty;
-import net.sf.taverna.t2.monitor.NoSuchPropertyException;
-import net.sf.taverna.t2.reference.ErrorDocument;
-import net.sf.taverna.t2.reference.ReferenceService;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.OutputPort;
-import net.sf.taverna.t2.workflowmodel.Processor;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.AbstractDispatchLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.PropertyContributingDispatchLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerErrorReaction;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerJobReaction;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerResultCompletionReaction;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerResultReaction;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.SupportsStreamedResult;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchErrorEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchJobEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchResultEvent;
-
-/**
- * Receives job events, checks to see whether any parameters in the job are
- * error tokens or collections which contain errors. If so then sends a
- * corresponding result message back where all outputs are error tokens having
- * registered such with the invocation context's data manager. It also re-writes
- * any failure messages as result messages containing error tokens at the
- * appropriate depth - this means that it must be placed above any error
- * handling layers in order for those to have an effect at all. In general this
- * layer should be placed immediately below the parallelize layer in most
- * default cases (this will guarantee the processor never sees a failure message
- * though, which may or may not be desirable)
- * 
- * @author Tom Oinn
- * 
- */
-@DispatchLayerErrorReaction(emits = { RESULT }, relaysUnmodified = false, stateEffects = {
-		CREATE_PROCESS_STATE, UPDATE_PROCESS_STATE })
-@DispatchLayerJobReaction(emits = { RESULT }, relaysUnmodified = true, stateEffects = {
-		CREATE_PROCESS_STATE, UPDATE_PROCESS_STATE, NO_EFFECT })
-@DispatchLayerResultReaction(emits = {}, relaysUnmodified = true, stateEffects = {})
-@DispatchLayerResultCompletionReaction(emits = {}, relaysUnmodified = true, stateEffects = {})
-@SupportsStreamedResult
-public class ErrorBounce extends AbstractDispatchLayer<JsonNode> implements
-		PropertyContributingDispatchLayer<JsonNode> {
-	public static final String URI = "http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/ErrorBounce";
-
-	/**
-	 * Track the number of reflected and translated errors handled by this error
-	 * bounce instance
-	 */
-	private Map<String, ErrorBounceState> state = new ConcurrentHashMap<>();
-
-	private int totalTranslatedErrors = 0;
-	private int totalReflectedErrors = 0;
-
-	private synchronized ErrorBounceState getState(String owningProcess) {
-		if (state.containsKey(owningProcess))
-			return state.get(owningProcess);
-		ErrorBounceState ebs = new ErrorBounceState();
-		state.put(owningProcess, ebs);
-		return ebs;
-	}
-
-	/**
-	 * If the job contains errors, or collections which contain errors
-	 * themselves then bounce a result message with error documents in back up
-	 * to the layer above
-	 */
-	@Override
-	public void receiveJob(DispatchJobEvent jobEvent) {
-		Set<T2Reference> errorReferences = new HashSet<>();
-		for (T2Reference ei : jobEvent.getData().values())
-			if (ei.containsErrors())
-				errorReferences.add(ei);
-		if (errorReferences.isEmpty())
-			// relay the message down...
-			getBelow().receiveJob(jobEvent);
-		else {
-			getState(jobEvent.getOwningProcess()).incrementErrorsReflected();
-			sendErrorOutput(jobEvent, null, errorReferences);
-		}
-	}
-
-	/**
-	 * Always send the error document job result on receiving a failure, at
-	 * least for now! This should be configurable, in effect this is the part
-	 * that ensures the processor never sees a top level failure.
-	 */
-	@Override
-	public void receiveError(DispatchErrorEvent errorEvent) {
-		getState(errorEvent.getOwningProcess()).incrementErrorsTranslated();
-		sendErrorOutput(errorEvent, errorEvent.getCause(), null);
-	}
-
-	/**
-	 * Construct and send a new result message with error documents in place of
-	 * all outputs at the appropriate depth
-	 * 
-	 * @param event
-	 * @param cause
-	 * @param errorReferences
-	 */
-	private void sendErrorOutput(Event<?> event, Throwable cause,
-			Set<T2Reference> errorReferences) {
-		ReferenceService rs = event.getContext().getReferenceService();
-
-		Processor p = dispatchStack.getProcessor();
-		Map<String, T2Reference> outputDataMap = new HashMap<>();
-		String[] owningProcessArray = event.getOwningProcess().split(":");
-		String processor = owningProcessArray[owningProcessArray.length - 1];
-		for (OutputPort op : p.getOutputPorts()) {
-			String message = "Processor '" + processor + "' - Port '"
-					+ op.getName() + "'";
-			if (event instanceof DispatchErrorEvent)
-				message += ": " + ((DispatchErrorEvent) event).getMessage();
-			ErrorDocument ed;
-			if (cause != null)
-				ed = rs.getErrorDocumentService().registerError(message, cause,
-						op.getDepth(), event.getContext());
-			else
-				ed = rs.getErrorDocumentService().registerError(message,
-						errorReferences, op.getDepth(), event.getContext());
-			outputDataMap.put(op.getName(), ed.getId());
-		}
-		DispatchResultEvent dre = new DispatchResultEvent(
-				event.getOwningProcess(), event.getIndex(), event.getContext(),
-				outputDataMap, false);
-		getAbove().receiveResult(dre);
-	}
-
-	@Override
-	public void configure(JsonNode config) {
-		// Do nothing - no configuration required
-	}
-
-	@Override
-	public JsonNode getConfiguration() {
-		// Layer has no configuration associated
-		return null;
-	}
-
-	@Override
-	public void finishedWith(final String owningProcess) {
-		/*
-		 * Delay the removal of the state to give the monitor a chance to poll
-		 */
-		cleanupTimer.schedule(new TimerTask() {
-			@Override
-			public void run() {
-				state.remove(owningProcess);
-			}
-		}, CLEANUP_DELAY_MS);
-	}
-
-	/**
-	 * Two properties, dispatch.errorbounce.reflected(integer) is the number of
-	 * incoming jobs which have been bounced back as results with errors,
-	 * dispatch.errorbounce.translated(integer) is the number of failures from
-	 * downstream in the stack that have been re-written as complete results
-	 * containing error documents.
-	 */
-	@Override
-	public void injectPropertiesFor(final String owningProcess) {
-		MonitorableProperty<Integer> errorsReflectedProperty = new MonitorableProperty<Integer>() {
-			@Override
-			public Date getLastModified() {
-				return new Date();
-			}
-
-			@Override
-			public String[] getName() {
-				return new String[] { "dispatch", "errorbounce", "reflected" };
-			}
-
-			@Override
-			public Integer getValue() throws NoSuchPropertyException {
-				ErrorBounceState ebs = state.get(owningProcess);
-				if (ebs == null)
-					return 0;
-				return ebs.getErrorsReflected();
-			}
-		};
-		dispatchStack.receiveMonitorableProperty(errorsReflectedProperty,
-				owningProcess);
-
-		MonitorableProperty<Integer> errorsTranslatedProperty = new MonitorableProperty<Integer>() {
-			@Override
-			public Date getLastModified() {
-				return new Date();
-			}
-
-			@Override
-			public String[] getName() {
-				return new String[] { "dispatch", "errorbounce", "translated" };
-			}
-
-			@Override
-			public Integer getValue() throws NoSuchPropertyException {
-				ErrorBounceState ebs = state.get(owningProcess);
-				if (ebs == null)
-					return 0;
-				return ebs.getErrorsTranslated();
-			}
-		};
-		dispatchStack.receiveMonitorableProperty(errorsTranslatedProperty,
-				owningProcess);
-
-		MonitorableProperty<Integer> totalTranslatedTranslatedProperty = new MonitorableProperty<Integer>() {
-			@Override
-			public Date getLastModified() {
-				return new Date();
-			}
-
-			@Override
-			public String[] getName() {
-				return new String[] { "dispatch", "errorbounce",
-						"totalTranslated" };
-			}
-
-			@Override
-			public Integer getValue() throws NoSuchPropertyException {
-				return totalTranslatedErrors;
-			}
-		};
-		dispatchStack.receiveMonitorableProperty(
-				totalTranslatedTranslatedProperty, owningProcess);
-
-		MonitorableProperty<Integer> totalReflectedTranslatedProperty = new MonitorableProperty<Integer>() {
-			@Override
-			public Date getLastModified() {
-				return new Date();
-			}
-
-			@Override
-			public String[] getName() {
-				return new String[] { "dispatch", "errorbounce",
-						"totalReflected" };
-			}
-
-			@Override
-			public Integer getValue() throws NoSuchPropertyException {
-				return totalReflectedErrors;
-			}
-		};
-		dispatchStack.receiveMonitorableProperty(
-				totalReflectedTranslatedProperty, owningProcess);
-	}
-
-	public class ErrorBounceState {
-		private int errorsReflected = 0;
-		private int errorsTranslated = 0;
-
-		/**
-		 * Number of times the bounce layer has converted an incoming job event
-		 * where the input data contained error tokens into a result event
-		 * containing all errors.
-		 */
-		int getErrorsReflected() {
-			return this.errorsReflected;
-		}
-
-		/**
-		 * Number of times the bounce layer has converted an incoming failure
-		 * event into a result containing error tokens
-		 */
-		int getErrorsTranslated() {
-			return errorsTranslated;
-		}
-
-		void incrementErrorsReflected() {
-			synchronized (this) {
-				errorsReflected++;
-			}
-			synchronized (ErrorBounce.this) {
-				totalReflectedErrors++;
-			}
-		}
-
-		void incrementErrorsTranslated() {
-			synchronized (this) {
-				errorsTranslated++;
-			}
-			synchronized (ErrorBounce.this) {
-				totalTranslatedErrors++;
-			}
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Failover.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Failover.java b/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Failover.java
deleted file mode 100644
index 1c5ef03..0000000
--- a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Failover.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.layers;
-
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.CREATE_LOCAL_STATE;
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.REMOVE_LOCAL_STATE;
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerStateEffect.UPDATE_LOCAL_STATE;
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchMessageType.JOB;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.AbstractErrorHandlerLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerErrorReaction;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerJobReaction;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerResultReaction;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchJobEvent;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * Failure handling dispatch layer, consumes job events with multiple activities
- * and emits the same job but with only the first activity. On failures the job
- * is resent to the layer below with a new activity list containing the second
- * in the original list and so on. If a failure is received and there are no
- * further activities to use the job fails and the failure is sent back up to
- * the layer above.
- * 
- * @author Tom Oinn
- * @author Stian Soiland-Reyes
- */
-@DispatchLayerErrorReaction(emits = { JOB }, relaysUnmodified = true, stateEffects = {
-		UPDATE_LOCAL_STATE, REMOVE_LOCAL_STATE })
-@DispatchLayerJobReaction(emits = {}, relaysUnmodified = true, stateEffects = { CREATE_LOCAL_STATE })
-@DispatchLayerResultReaction(emits = {}, relaysUnmodified = true, stateEffects = { REMOVE_LOCAL_STATE })
-public class Failover extends AbstractErrorHandlerLayer<JsonNode> {
-	public static final String URI = "http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/Failover";
-
-	@Override
-	protected JobState getStateObject(DispatchJobEvent jobEvent) {
-		return new FailoverState(jobEvent);
-	}
-
-	/**
-	 * Receive a job from the layer above, store it in the state map then relay
-	 * it to the layer below with a modified activity list containing only the
-	 * activity at index 0
-	 */
-	@Override
-	public void receiveJob(DispatchJobEvent jobEvent) {
-		addJobToStateList(jobEvent);
-		List<Activity<?>> newActivityList = new ArrayList<>();
-		newActivityList.add(jobEvent.getActivities().get(0));
-		getBelow().receiveJob(
-				new DispatchJobEvent(jobEvent.getOwningProcess(), jobEvent
-						.getIndex(), jobEvent.getContext(), jobEvent.getData(),
-						newActivityList));
-	}
-
-	class FailoverState extends JobState {
-		int currentActivityIndex = 0;
-
-		public FailoverState(DispatchJobEvent jobEvent) {
-			super(jobEvent);
-		}
-
-		@Override
-		public boolean handleError() {
-			currentActivityIndex++;
-			if (currentActivityIndex == jobEvent.getActivities().size())
-				return false;
-			List<Activity<?>> newActivityList = new ArrayList<>();
-			newActivityList.add(jobEvent.getActivities().get(
-					currentActivityIndex));
-			getBelow().receiveJob(
-					new DispatchJobEvent(jobEvent.getOwningProcess(), jobEvent
-							.getIndex(), jobEvent.getContext(), jobEvent
-							.getData(), newActivityList));
-			return true;
-		}
-	}
-
-	@Override
-	public void configure(JsonNode config) {
-		// Do nothing - there is no configuration to do
-	}
-
-	@Override
-	public JsonNode getConfiguration() {
-		return null;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/IntermediateProvenance.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/IntermediateProvenance.java b/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/IntermediateProvenance.java
deleted file mode 100644
index 718079a..0000000
--- a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/IntermediateProvenance.java
+++ /dev/null
@@ -1,508 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.layers;
-
-import static java.lang.System.currentTimeMillis;
-
-import java.beans.XMLDecoder;
-import java.beans.XMLEncoder;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import net.sf.taverna.t2.invocation.Event;
-import net.sf.taverna.t2.provenance.item.ActivityProvenanceItem;
-import net.sf.taverna.t2.provenance.item.ErrorProvenanceItem;
-import net.sf.taverna.t2.provenance.item.InputDataProvenanceItem;
-import net.sf.taverna.t2.provenance.item.IterationProvenanceItem;
-import net.sf.taverna.t2.provenance.item.OutputDataProvenanceItem;
-import net.sf.taverna.t2.provenance.item.ProcessProvenanceItem;
-import net.sf.taverna.t2.provenance.item.ProcessorProvenanceItem;
-import net.sf.taverna.t2.provenance.item.ProvenanceItem;
-import net.sf.taverna.t2.provenance.item.WorkflowProvenanceItem;
-import net.sf.taverna.t2.provenance.reporter.ProvenanceReporter;
-import net.sf.taverna.t2.reference.ReferenceService;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivity;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.AbstractDispatchLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchCompletionEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchErrorEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchJobEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchJobQueueEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchResultEvent;
-
-import org.apache.log4j.Logger;
-
-/**
- * Sits above the {@link Invoke} layer and collects information about the
- * current workflow run to be stored by the {@link ProvenanceConnector}.
- * 
- * @author Ian Dunlop
- * @author Stian Soiland-Reyes
- * 
- */
-public class IntermediateProvenance extends AbstractDispatchLayer<String> {
-	public static final String URI = "http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/IntermediateProvenance";
-	private static final Logger logger = Logger.getLogger(IntermediateProvenance.class);
-
-	private ProvenanceReporter reporter;
-	private Map<String, Map<String, IterationProvenanceItem>> processToIndexes = new HashMap<>();
-	private Map<ActivityProvenanceItem, List<Object>> activityProvenanceItemMap = new HashMap<>();
-	private Map<InputDataProvenanceItem, List<Object>> inputDataProvenanceItemMap = new HashMap<>();
-
-	// private List<ActivityProvenanceItem> activityProvenanceItemList = new ArrayList<>();
-	// private List<InputDataProvenanceItem> inputDataProvenanceItemList = new ArrayList<>();
-
-	private WorkflowProvenanceItem workflowItem;
-
-	@Override
-	public void configure(String o) {
-	}
-
-	/**
-	 * A set of provenance events for a particular owning process has been
-	 * finished with so you can remove all the {@link IterationProvenanceItem}s
-	 * from the map
-	 */
-	@Override
-	public void finishedWith(String owningProcess) {
-		processToIndexes.remove(owningProcess);
-	}
-
-	@Override
-	public String getConfiguration() {
-		return null;
-	}
-
-	protected Map<String, IterationProvenanceItem> getIndexesByProcess(
-			String owningProcess) {
-		synchronized (processToIndexes) {
-			Map<String, IterationProvenanceItem> indexes = processToIndexes
-					.get(owningProcess);
-			if (indexes == null) {
-				indexes = new HashMap<>();
-				processToIndexes.put(owningProcess, indexes);
-			}
-			return indexes;
-		}
-	}
-
-	protected IterationProvenanceItem getIterationProvItem(Event<?> event) {
-		String owningProcess = event.getOwningProcess();
-		int[] originalIndex = event.getIndex();
-		int[] index = event.getIndex();
-		String indexStr = indexStr(index);
-		Map<String, IterationProvenanceItem> indexes = getIndexesByProcess(owningProcess);
-		IterationProvenanceItem iterationProvenanceItem = null;
-		synchronized (indexes) {
-			// find the iteration item for the int index eg [1]
-			iterationProvenanceItem = indexes.get(indexStr);
-			// if it is null then strip the index and look again
-
-			while (iterationProvenanceItem == null) {
-				try {
-					index = removeLastIndex(index);
-					iterationProvenanceItem = indexes.get(indexStr(index));
-					/*
-					 * if we have a 'parent' iteration then create a new
-					 * iteration for the original index and link it to the
-					 * activity and the input data
-					 * 
-					 * FIXME should this be linked to the parent iteration
-					 * instead?
-					 */
-					if (iterationProvenanceItem != null) {
-						// set the index to the one from the event
-						IterationProvenanceItem iterationProvenanceItem1 = new IterationProvenanceItem();
-						iterationProvenanceItem1.setIteration(originalIndex);
-						iterationProvenanceItem1.setProcessId(owningProcess);
-						iterationProvenanceItem1.setIdentifier(UUID
-								.randomUUID().toString());
-						iterationProvenanceItem1.setWorkflowId(workflowItem.getParentId());
-						iterationProvenanceItem1.setParentIterationItem(iterationProvenanceItem);
-						iterationProvenanceItem1.setParentId(iterationProvenanceItem.getParentId());
-						iterationProvenanceItem1.setInputDataItem(iterationProvenanceItem.getInputDataItem());
-
-//						for (Entry<ActivityProvenanceItem, List<Object>> entrySet : activityProvenanceItemMap
-//								.entrySet()) {
-//							List<Object> value = entrySet.getValue();
-//							int[] newIndex = (int[]) value.get(0);
-//							String owner = (String) value.get(1);
-//							String indexString = indexStr(newIndex);
-//							String indexString2 = indexStr(index);
-//
-//							if (owningProcess.equalsIgnoreCase(owner)
-//									&& indexString
-//											.equalsIgnoreCase(indexString2))
-//								iterationProvenanceItem1.setParentId(entrySet
-//										.getKey().getIdentifier());
-//						}
-//						for (Entry<InputDataProvenanceItem, List<Object>> entrySet : inputDataProvenanceItemMap
-//								.entrySet()) {
-//							List<Object> value = entrySet.getValue();
-//							int[] newIndex = (int[]) value.get(0);
-//							String owner = (String) value.get(1);
-//							String indexString = indexStr(newIndex);
-//							String indexString2 = indexStr(index);
-//							if (owningProcess.equalsIgnoreCase(owner)
-//									&& indexString
-//											.equalsIgnoreCase(indexString2))
-//								iterationProvenanceItem1
-//										.setInputDataItem(entrySet.getKey());
-//						}
-
-						// for (ActivityProvenanceItem item :
-						// activityProvenanceItemList) {
-						// if (owningProcess.equalsIgnoreCase(item
-						// .getProcessId())) {
-						// iterationProvenanceItem1.setParentId(item
-						// .getIdentifier());
-						// }
-						// }
-						// for (InputDataProvenanceItem item :
-						// inputDataProvenanceItemList) {
-						// if (owningProcess.equalsIgnoreCase(item
-						// .getProcessId())) {
-						// iterationProvenanceItem1.setInputDataItem(item);
-						// }
-						// indexes.put(indexStr, iterationProvenanceItem1);
-						// return iterationProvenanceItem1;
-						// // }
-						// }
-
-						// add this new iteration item to the map
-						getIndexesByProcess(event.getOwningProcess()).put(
-								indexStr(event.getIndex()),
-								iterationProvenanceItem1);
-						return iterationProvenanceItem1;
-					}
-					/*
-					 * if we have not found an iteration items and the index is
-					 * [] then something is wrong remove the last index in the
-					 * int array before we go back through the while
-					 */
-				} catch (IllegalStateException e) {
-					logger
-							.warn("Cannot find a parent iteration with index [] for owning process: "
-									+ owningProcess
-									+ "Workflow invocation is in an illegal state");
-					throw e;
-				}
-			}
-
-			// if (iterationProvenanceItem == null) {
-			// logger.info("Iteration item was null for: "
-			// + event.getOwningProcess() + " " + event.getIndex());
-			// System.out.println("Iteration item was null for: "
-			// + event.getOwningProcess() + " " + event.getIndex());
-			// iterationProvenanceItem = new IterationProvenanceItem(index);
-			// iterationProvenanceItem.setProcessId(owningProcess);
-			// iterationProvenanceItem.setIdentifier(UUID.randomUUID()
-			// .toString());
-			// // for (ActivityProvenanceItem
-			// item:activityProvenanceItemList)
-			// // {
-			// // if (owningProcess.equalsIgnoreCase(item.getProcessId())) {
-			// // iterationProvenanceItem.setParentId(item.getIdentifier());
-			// // }
-			// // }
-			// // for (InputDataProvenanceItem item:
-			// // inputDataProvenanceItemList) {
-			// // if (owningProcess.equalsIgnoreCase(item.getProcessId())) {
-			// // iterationProvenanceItem.setInputDataItem(item);
-			// // }
-			// // }
-			// indexes.put(indexStr, iterationProvenanceItem);
-
-		}
-		return iterationProvenanceItem;
-	}
-
-	private String indexStr(int[] index) {
-		StringBuilder indexStr = new StringBuilder();
-		for (int ind : index)
-			indexStr.append(":").append(ind);
-		return indexStr.toString();
-	}
-
-	/**
-	 * Remove the last index of the int array in the form 1:2:3 etc
-	 * 
-	 * @param index
-	 * @return
-	 */
-	@SuppressWarnings("unused")
-	private String[] stripLastIndex(int[] index) {
-		// will be in form :1:2:3
-		return indexStr(index).split(":");
-	}
-
-	/**
-	 * Remove the last value in the int array
-	 * 
-	 * @param index
-	 * @return
-	 */
-	private int[] removeLastIndex(int[] index) {
-		if (index.length == 0)
-			throw new IllegalStateException(
-					"There is no parent iteration of index [] for this result");
-		int[] newIntArray = new int[index.length - 1];
-		for (int i = 0; i < index.length - 1; i++)
-			newIntArray[i] = index[i];
-		return newIntArray;
-	}
-
-	private static String uuid() {
-		return UUID.randomUUID().toString();
-	}
-
-	/**
-	 * Create an {@link ErrorProvenanceItem} and send across to the
-	 * {@link ProvenanceConnector}
-	 */
-	@Override
-	public void receiveError(DispatchErrorEvent errorEvent) {
-		IterationProvenanceItem iterationProvItem = getIterationProvItem(errorEvent);
-		// get using errorEvent.getOwningProcess();
-		
-		ErrorProvenanceItem errorItem = new ErrorProvenanceItem();
-		errorItem.setCause(errorEvent
-				.getCause());
-		errorItem.setErrorType(errorEvent
-				.getFailureType().toString());
-		errorItem.setMessage(errorEvent.getMessage());
-		
-		errorItem.setProcessId(errorEvent.getOwningProcess());
-		errorItem.setIdentifier(uuid());
-		errorItem.setParentId(iterationProvItem.getIdentifier());
-		// iterationProvItem.setErrorItem(errorItem);
-		// FIXME don't need to add to the processor item earlier
-		getReporter().addProvenanceItem(errorItem);
-		super.receiveError(errorEvent);
-	}
-
-	/**
-	 * Create the {@link ProvenanceItem}s and send them all across to the
-	 * {@link ProvenanceConnector} except for the
-	 * {@link IterationProvenanceItem}, this one is told what it's inputs are
-	 * but has to wait until the results are received before being sent across.
-	 * Each item has a unique identifier and also knows who its parent item is
-	 */
-	@Override
-	public void receiveJob(DispatchJobEvent jobEvent) {
-			try {
-			// FIXME do we need this ProcessProvenanceItem?
-			ProcessProvenanceItem provenanceItem;
-			String[] split = jobEvent.getOwningProcess().split(":");
-			provenanceItem = new ProcessProvenanceItem();
-			String parentDataflowId = workflowItem.getParentId();
-			provenanceItem.setWorkflowId(parentDataflowId);
-			provenanceItem.setFacadeID(split[0]);
-			provenanceItem.setDataflowID(split[1]);
-			provenanceItem.setProcessId(jobEvent.getOwningProcess());
-			provenanceItem.setIdentifier(uuid());
-			provenanceItem.setParentId(workflowItem.getIdentifier());
-			ProcessorProvenanceItem processorProvItem;
-			processorProvItem = new ProcessorProvenanceItem();
-			processorProvItem.setWorkflowId(parentDataflowId);
-			processorProvItem.setProcessId(jobEvent
-					.getOwningProcess());
-			processorProvItem.setIdentifier(uuid());
-			processorProvItem.setParentId(provenanceItem.getIdentifier());
-			provenanceItem.setProcessId(jobEvent.getOwningProcess());
-			getReporter().addProvenanceItem(provenanceItem);
-			getReporter().addProvenanceItem(processorProvItem);
-	
-			IterationProvenanceItem iterationProvItem = null;
-			iterationProvItem = new IterationProvenanceItem();
-			iterationProvItem.setWorkflowId(parentDataflowId);
-			iterationProvItem.setIteration(jobEvent.getIndex());
-			iterationProvItem.setIdentifier(uuid());
-			
-			ReferenceService referenceService = jobEvent.getContext()
-					.getReferenceService();
-	
-			InputDataProvenanceItem inputDataItem = new InputDataProvenanceItem();
-			inputDataItem.setDataMap(jobEvent.getData());
-			inputDataItem.setReferenceService(referenceService);
-			inputDataItem.setIdentifier(uuid());
-			inputDataItem.setParentId(iterationProvItem.getIdentifier());
-			inputDataItem.setProcessId(jobEvent.getOwningProcess());
-	
-			List<Object> inputIndexOwnerList = new ArrayList<>();
-			inputIndexOwnerList.add(jobEvent.getIndex());
-			inputIndexOwnerList.add(jobEvent.getOwningProcess());
-			inputDataProvenanceItemMap.put(inputDataItem, inputIndexOwnerList);
-	
-			// inputDataProvenanceItemList.add(inputDataItem);
-			iterationProvItem.setInputDataItem(inputDataItem);
-			iterationProvItem.setIteration(jobEvent.getIndex());
-			iterationProvItem.setProcessId(jobEvent.getOwningProcess());
-	
-			for (Activity<?> activity : jobEvent.getActivities())
-				if (activity instanceof AsynchronousActivity) {
-					ActivityProvenanceItem activityProvItem = new ActivityProvenanceItem();
-					activityProvItem.setWorkflowId(parentDataflowId);
-					activityProvItem.setIdentifier(uuid());
-					iterationProvItem.setParentId(activityProvItem.getIdentifier());
-					// getConnector().addProvenanceItem(iterationProvItem);
-					activityProvItem.setParentId(processorProvItem.getIdentifier());
-					// processorProvItem.setActivityProvenanceItem(activityProvItem);
-					activityProvItem.setProcessId(jobEvent.getOwningProcess());
-					List<Object> activityIndexOwnerList = new ArrayList<>();
-					activityIndexOwnerList.add(jobEvent.getOwningProcess());
-					activityIndexOwnerList.add(jobEvent.getIndex());
-					activityProvenanceItemMap.put(activityProvItem,
-							inputIndexOwnerList);
-					// activityProvenanceItemList.add(activityProvItem);
-					// activityProvItem.setIterationProvenanceItem(iterationProvItem);
-					getReporter().addProvenanceItem(activityProvItem);
-					break;
-				}
-			getIndexesByProcess(jobEvent.getOwningProcess()).put(
-					indexStr(jobEvent.getIndex()), iterationProvItem);
-			iterationProvItem.setEnactmentStarted(new Timestamp(currentTimeMillis()));
-			getReporter().addProvenanceItem(iterationProvItem);
-		} catch (RuntimeException ex) {
-			logger.error("Could not store provenance for " + jobEvent, ex);
-		}
-		
-		super.receiveJob(jobEvent);
-	}
-
-	@Override
-	public void receiveJobQueue(DispatchJobQueueEvent jobQueueEvent) {
-		super.receiveJobQueue(jobQueueEvent);
-	}
-
-	/**
-	 * Populate an {@link OutputDataProvenanceItem} with the results and attach
-	 * it to the appropriate {@link IterationProvenanceItem}. Then send the
-	 * {@link IterationProvenanceItem} across to the {@link ProvenanceConnector}
-	 */
-	@Override
-	public void receiveResult(DispatchResultEvent resultEvent) {
-		try {
-			// FIXME use the connector from the result event context
-			IterationProvenanceItem iterationProvItem = getIterationProvItem(resultEvent);
-			iterationProvItem.setEnactmentEnded(new Timestamp(currentTimeMillis()));
-			
-			ReferenceService referenceService = resultEvent.getContext()
-					.getReferenceService();
-
-			OutputDataProvenanceItem outputDataItem = new OutputDataProvenanceItem();
-			outputDataItem.setDataMap(resultEvent.getData());
-			outputDataItem.setReferenceService(referenceService);
-			outputDataItem.setIdentifier(uuid());
-			outputDataItem.setProcessId(resultEvent.getOwningProcess());
-			outputDataItem.setParentId(iterationProvItem.getIdentifier());
-			iterationProvItem.setOutputDataItem(outputDataItem);
-			
-			getReporter().addProvenanceItem(iterationProvItem);
-			// getConnector().addProvenanceItem(outputDataItem);
-	
-			// PM -- testing
-			// add xencoding of data value here??
-	//		Map<String, T2Reference> inputDataMap = iterationProvItem.getInputDataItem().getDataMap();
-	//		for(Map.Entry<String, T2Reference> entry:inputDataMap.entrySet()) {
-	//			// create a simpler bean that we can serialize?
-	//			
-	//			T2Reference ref = entry.getValue();
-	//			
-	//			SimplerT2Reference t2RefBean = new SimplerT2Reference();
-	//			t2RefBean.setReferenceType(ref.getReferenceType());
-	//			t2RefBean.setDepth(ref.getDepth());
-	//			t2RefBean.setLocalPart(ref.getLocalPart());
-	//			t2RefBean.setNamespacePart(ref.getNamespacePart());
-	//						
-	//			System.out.println("data ref: "+ref);
-	//			String serializedInput = SerializeParam(t2RefBean);
-	//			System.out.println("serialized reference:" + serializedInput);
-	//			
-	//			System.out.println(referenceService.renderIdentifier(entry.getValue(), String.class, resultEvent.getContext()));
-//		}
-		} catch (Exception ex) {
-			logger.error("Could not store provenance for "
-					+ resultEvent.getOwningProcess() + " "
-					+ Arrays.toString(resultEvent.getIndex()), ex);
-			// But don't break super.receiveResult() !!
-		}
-		super.receiveResult(resultEvent);
-	}
-
-	@Override
-	public void receiveResultCompletion(DispatchCompletionEvent completionEvent) {
-		super.receiveResultCompletion(completionEvent);
-	}
-
-	/**
-	 * Tell this layer what {@link ProvenanceConnector} implementation is being
-	 * used to capture the {@link ProvenanceItem}s. NOTE: should probably use
-	 * the connector from the result events context where possible
-	 * 
-	 * @param connector
-	 */
-	public void setReporter(ProvenanceReporter connector) {
-		this.reporter = connector;
-	}
-
-	public ProvenanceReporter getReporter() {
-		return reporter;
-	}
-
-	/**
-	 * So that the {@link ProvenanceItem}s know which {@link Dataflow} has been
-	 * enacted this layer has to know about the {@link WorkflowProvenanceItem}
-	 * 
-	 * @param workflowItem
-	 */
-	public void setWorkflow(WorkflowProvenanceItem workflowItem) {
-		this.workflowItem = workflowItem;
-	}
-
-	// TODO is this unused?
-	public static String SerializeParam(Object ParamValue) {
-		ByteArrayOutputStream BStream = new ByteArrayOutputStream();
-		XMLEncoder encoder = new XMLEncoder(BStream);
-		encoder.writeObject(ParamValue);
-		encoder.close();
-		return BStream.toString();
-	}
-
-	// TODO is this unused?
-	public static Object DeserializeParam(String SerializedParam) {
-		InputStream IStream = new ByteArrayInputStream(
-				SerializedParam.getBytes());
-		XMLDecoder decoder = new XMLDecoder(IStream);
-		Object output = decoder.readObject();
-		decoder.close();
-		return output;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Invoke.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Invoke.java b/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Invoke.java
deleted file mode 100644
index f8403df..0000000
--- a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Invoke.java
+++ /dev/null
@@ -1,369 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.layers;
-
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchMessageType.ERROR;
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchMessageType.RESULT;
-import static net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchMessageType.RESULT_COMPLETION;
-
-import java.lang.Thread.UncaughtExceptionHandler;
-import java.sql.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.monitor.MonitorManager;
-import net.sf.taverna.t2.monitor.MonitorableProperty;
-import net.sf.taverna.t2.provenance.item.InvocationStartedProvenanceItem;
-import net.sf.taverna.t2.provenance.item.IterationProvenanceItem;
-import net.sf.taverna.t2.provenance.reporter.ProvenanceReporter;
-import net.sf.taverna.t2.reference.ReferenceService;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.ControlBoundary;
-import net.sf.taverna.t2.workflowmodel.OutputPort;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivity;
-import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback;
-import net.sf.taverna.t2.workflowmodel.processor.activity.MonitorableAsynchronousActivity;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.AbstractDispatchLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.description.DispatchLayerJobReaction;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchCompletionEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchErrorEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchErrorType;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchJobEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchResultEvent;
-
-import org.apache.log4j.Logger;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * Context free invoker layer, does not pass index arrays of jobs into activity
- * instances.
- * <p>
- * This layer will invoke the first invokable activity in the activity list, so
- * any sane dispatch stack will have narrowed this down to a single item list by
- * this point, i.e. by the insertion of a failover layer.
- * <p>
- * Currently only handles activities implementing {@link AsynchronousActivity}.
- *
- * @author Tom Oinn
- * @author Stian Soiland-Reyes
- *
- */
-@DispatchLayerJobReaction(emits = { ERROR, RESULT_COMPLETION, RESULT }, relaysUnmodified = false, stateEffects = {})
-@ControlBoundary
-public class Invoke extends AbstractDispatchLayer<JsonNode> {
-	public static final String URI = "http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/Invoke";
-	private static Logger logger = Logger.getLogger(Invoke.class);
-	private static Long invocationCount = 0L;
-
-	private MonitorManager monMan;
-
-	private static String getNextProcessID() {
-		long count;
-		synchronized (invocationCount) {
-			count = ++invocationCount;
-		}
-		return "invocation" + count;
-	}
-
-	public Invoke() {
-		super();
-		monMan = MonitorManager.getInstance();
-	}
-
-	@Override
-	public void configure(JsonNode config) {
-		// No configuration, do nothing
-	}
-
-	@Override
-	public JsonNode getConfiguration() {
-		return null;
-	}
-
-	/**
-	 * Receive a job from the layer above and pick the first concrete activity
-	 * from the list to invoke. Invoke this activity, creating a callback which
-	 * will wrap up the result messages in the appropriate collection depth
-	 * before sending them on (in general activities are not aware of their
-	 * invocation context and should not be responsible for providing correct
-	 * index arrays for results)
-	 * <p>
-	 * This layer will invoke the first invokable activity in the activity list,
-	 * so any sane dispatch stack will have narrowed this down to a single item
-	 * list by this point, i.e. by the insertion of a failover layer.
-	 */
-	@Override
-	public void receiveJob(final DispatchJobEvent jobEvent) {
-		for (Activity<?> activity : jobEvent.getActivities())
-			if (activity instanceof AsynchronousActivity) {
-				invoke(jobEvent, (AsynchronousActivity<?>) activity);
-				break;
-			}
-	}
-
-	protected void invoke(final DispatchJobEvent jobEvent, final AsynchronousActivity<?> activity) {
-		// Register with the monitor
-		final String invocationProcessIdentifier = jobEvent.pushOwningProcess(
-				getNextProcessID()).getOwningProcess();
-		monMan.registerNode(activity, invocationProcessIdentifier,
-				new HashSet<MonitorableProperty<?>>());
-		monMan.registerNode(jobEvent, invocationProcessIdentifier,
-				new HashSet<MonitorableProperty<?>>());
-
-		/*
-		 * The activity is an AsynchronousActivity so we invoke it with an
-		 * AsynchronousActivityCallback object containing appropriate callback
-		 * methods to push results, completions and failures back to the
-		 * invocation layer.
-		 * 
-		 * Get the registered DataManager for this process. In most cases this
-		 * will just be a single DataManager for the entire workflow system but
-		 * it never hurts to generalize
-		 */
-
-		InvocationContext context = jobEvent.getContext();
-		final ReferenceService refService = context.getReferenceService();
-
-		InvocationStartedProvenanceItem invocationItem = null;
-		ProvenanceReporter provenanceReporter = context.getProvenanceReporter();
-		if (provenanceReporter != null) {
-			IntermediateProvenance intermediateProvenance = findIntermediateProvenance();
-			if (intermediateProvenance != null) {
-				invocationItem = new InvocationStartedProvenanceItem();
-				IterationProvenanceItem parentItem = intermediateProvenance.getIterationProvItem(jobEvent);
-				invocationItem.setIdentifier(UUID.randomUUID().toString());
-				invocationItem.setActivity(activity);
-				invocationItem.setProcessId(jobEvent.getOwningProcess());
-				invocationItem.setInvocationProcessId(invocationProcessIdentifier);
-				invocationItem.setParentId(parentItem.getIdentifier());
-				invocationItem.setWorkflowId(parentItem.getWorkflowId());
-				invocationItem.setInvocationStarted(new Date(System.currentTimeMillis()));
-				provenanceReporter.addProvenanceItem(invocationItem);
-			}
-		}
-
-		/*
-		 * Create a Map of EntityIdentifiers named appropriately given the
-		 * activity mapping
-		 */
-		Map<String, T2Reference> inputData = new HashMap<>();
-		for (String inputName : jobEvent.getData().keySet()) {
-			String activityInputName = activity
-					.getInputPortMapping().get(inputName);
-			if (activityInputName != null)
-				inputData.put(activityInputName, jobEvent.getData()
-						.get(inputName));
-		}
-
-		/*
-		 * Create a callback object to receive events, completions and failure
-		 * notifications from the activity
-		 */
-		AsynchronousActivityCallback callback = new InvokeCallBack(
-				jobEvent, refService, invocationProcessIdentifier,
-				activity);
-
-		if (activity instanceof MonitorableAsynchronousActivity<?>) {
-			/*
-			 * Monitorable activity so get the monitorable properties and push
-			 * them into the state tree after launching the job
-			 */
-			MonitorableAsynchronousActivity<?> maa = (MonitorableAsynchronousActivity<?>) activity;
-			Set<MonitorableProperty<?>> props = maa
-					.executeAsynchWithMonitoring(inputData, callback);
-			monMan.addPropertiesToNode(invocationProcessIdentifier.split(":"), props);
-		} else {
-			/*
-			 * Run the job, passing in the callback we've just created along
-			 * with the (possibly renamed) input data map
-			 */
-			activity.executeAsynch(inputData, callback);
-		}
-	}
-
-	protected IntermediateProvenance findIntermediateProvenance() {
-		for (DispatchLayer<?> layer : getProcessor().getDispatchStack()
-				.getLayers())
-			if (layer instanceof IntermediateProvenance)
-				return (IntermediateProvenance) layer;
-		return null;
-	}
-
-	protected class InvokeCallBack implements AsynchronousActivityCallback {
-		protected final AsynchronousActivity<?> activity;
-		protected final String invocationProcessIdentifier;
-		protected final DispatchJobEvent jobEvent;
-		protected final ReferenceService refService;
-		protected boolean sentJob = false;
-
-		protected InvokeCallBack(DispatchJobEvent jobEvent,
-				ReferenceService refService,
-				String invocationProcessIdentifier,
-				AsynchronousActivity<?> asyncActivity) {
-			this.jobEvent = jobEvent;
-			this.refService = refService;
-			this.invocationProcessIdentifier = invocationProcessIdentifier;
-			this.activity = asyncActivity;
-		}
-
-		@Override
-		public void fail(String message) {
-			fail(message, null);
-		}
-
-		@Override
-		public void fail(String message, Throwable t) {
-			fail(message, t, DispatchErrorType.INVOCATION);
-		}
-
-		@Override
-		public void fail(String message, Throwable t,
-				DispatchErrorType errorType) {
-			logger.warn("Failed (" + errorType + ") invoking " + activity
-					+ " for job " + jobEvent + ": " + message, t);
-			monMan.deregisterNode(
-					invocationProcessIdentifier);
-			getAbove().receiveError(
-					new DispatchErrorEvent(jobEvent.getOwningProcess(),
-							jobEvent.getIndex(), jobEvent.getContext(),
-							message, t, errorType, activity));
-		}
-
-		@Override
-		public InvocationContext getContext() {
-			return jobEvent.getContext();
-		}
-
-		@Override
-		public String getParentProcessIdentifier() {
-			return invocationProcessIdentifier;
-		}
-
-		@Override
-		public void receiveCompletion(int[] completionIndex) {
-			if (completionIndex.length == 0)
-				// Final result, clean up monitor state
-				monMan.deregisterNode(invocationProcessIdentifier);
-			if (sentJob) {
-				int[] newIndex;
-				if (completionIndex.length == 0)
-					newIndex = jobEvent.getIndex();
-				else {
-					newIndex = new int[jobEvent.getIndex().length
-							+ completionIndex.length];
-					int i = 0;
-					for (int indexValue : jobEvent.getIndex())
-						newIndex[i++] = indexValue;
-					for (int indexValue : completionIndex)
-						newIndex[i++] = indexValue;
-				}
-				DispatchCompletionEvent c = new DispatchCompletionEvent(
-						jobEvent.getOwningProcess(), newIndex, jobEvent
-								.getContext());
-				getAbove().receiveResultCompletion(c);
-			} else {
-				/*
-				 * We haven't sent any 'real' data prior to completing a stream.
-				 * This in effect means we're sending an empty top level
-				 * collection so we need to register empty collections for each
-				 * output port with appropriate depth (by definition if we're
-				 * streaming all outputs are collection types of some kind)
-				 */
-				Map<String, T2Reference> emptyListMap = new HashMap<>();
-				for (OutputPort op : activity.getOutputPorts()) {
-					String portName = op.getName();
-					int portDepth = op.getDepth();
-					emptyListMap.put(portName, refService.getListService()
-							.registerEmptyList(portDepth, jobEvent.getContext()).getId());
-				}
-				receiveResult(emptyListMap, new int[0]);
-			}
-		}
-
-		@Override
-		public void receiveResult(Map<String, T2Reference> data, int[] index) {
-			/*
-			 * Construct a new result map using the activity mapping (activity
-			 * output name to processor output name)
-			 */
-			Map<String, T2Reference> resultMap = new HashMap<>();
-			for (String outputName : data.keySet()) {
-				String processorOutputName = activity
-						.getOutputPortMapping().get(outputName);
-				if (processorOutputName != null)
-					resultMap.put(processorOutputName, data.get(outputName));
-			}
-			/*
-			 * Construct a new index array if the specified index is non zero
-			 * length, otherwise just use the original job's index array (means
-			 * we're not streaming)
-			 */
-			int[] newIndex;
-			boolean streaming = false;
-			if (index.length == 0)
-				newIndex = jobEvent.getIndex();
-			else {
-				streaming = true;
-				newIndex = new int[jobEvent.getIndex().length + index.length];
-				int i = 0;
-				for (int indexValue : jobEvent.getIndex())
-					newIndex[i++] = indexValue;
-				for (int indexValue : index)
-					newIndex[i++] = indexValue;
-			}
-			DispatchResultEvent resultEvent = new DispatchResultEvent(jobEvent
-					.getOwningProcess(), newIndex, jobEvent.getContext(),
-					resultMap, streaming);
-			if (!streaming) {
-				monMan.registerNode(resultEvent, invocationProcessIdentifier,
-						new HashSet<MonitorableProperty<?>>());
-				// Final result, clean up monitor state
-				monMan.deregisterNode(invocationProcessIdentifier);
-			}
-			// Push the modified data to the layer above in the dispatch stack
-			getAbove().receiveResult(resultEvent);
-
-			sentJob = true;
-		}
-
-		@Override
-		public void requestRun(Runnable runMe) {
-			String newThreadName = jobEvent.toString();
-			Thread thread = new Thread(runMe, newThreadName);
-			thread.setContextClassLoader(activity.getClass()
-					.getClassLoader());
-			thread.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
-				@Override
-				public void uncaughtException(Thread t, Throwable e) {
-					fail("Uncaught exception while invoking " + activity, e);
-				}
-			});
-			thread.start();
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Loop.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Loop.java b/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Loop.java
deleted file mode 100644
index d5077a4..0000000
--- a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/Loop.java
+++ /dev/null
@@ -1,424 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2008 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.layers;
-
-import java.lang.Thread.UncaughtExceptionHandler;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.reference.ReferenceService;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.Processor;
-import net.sf.taverna.t2.workflowmodel.processor.activity.AbstractAsynchronousActivity;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityInputPort;
-import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.AbstractDispatchLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.AbstractDispatchEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchCompletionEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchErrorEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchErrorType;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchJobEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchJobQueueEvent;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchResultEvent;
-
-import org.apache.log4j.Logger;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-
-/**
- * A layer that allows while-style loops.
- * <p>
- * The layer is configured with a {@link LoopConfiguration}, where an activity
- * has been set as the
- * {@link LoopConfiguration#setCondition(net.sf.taverna.t2.workflowmodel.processor.activity.Activity)
- * condition}.
- * <p>
- * After a job has been successful further down the dispatch stack, the loop
- * layer will invoke the conditional activity to determine if the job will be
- * invoked again. If {@link LoopConfiguration#isRunFirst()} is false, this test
- * will be performed even before the first invocation. (The default
- * runFirst=true is equivalent to a do..while construct, while runFirst=false is
- * equivalent to a while.. construct.)
- * <p>
- * A job will be resent down the dispatch stack only if the conditional activity
- * returns a reference to a string equal to "true" on its output port "loop".
- * <p>
- * If a job or the conditional activity fails, the while-loop is interrupted and
- * the error is sent further up.
- * <p>
- * Note that the LoopLayer will be invoked for each item in an iteration, if you
- * want to do the loop for the whole collection (ie. re-iterating if the
- * loop-condition fails after processing the full list) - create a nested
- * workflow with the desired depths on it's input ports and insert this
- * LoopLayer in the stack of the nested workflow's processor in parent workflow.
- * <p>
- * It is recommended that the LoopLayer is to be inserted after the
- * {@link ErrorBounce} layer, as this layer is needed for registering errors
- * produced by the LoopLayer. If the user requires {@link Retry retries} and
- * {@link Failover failovers} before checking the while condition, such layers
- * should be below LoopLayer.
- *
- * @author Stian Soiland-Reyes
- */
-// FIXME Doesn't work
-@SuppressWarnings({"unchecked","rawtypes"})
-public class Loop extends AbstractDispatchLayer<JsonNode> {
-	public static final String URI = "http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/Loop";
-	private static Logger logger = Logger.getLogger(Loop.class);
-
-	private JsonNode config = JsonNodeFactory.instance.objectNode();
-
-	protected Map<String, AbstractDispatchEvent> incomingJobs = new HashMap<>();
-	protected Map<String, AbstractDispatchEvent> outgoingJobs = new HashMap<>();
-
-	@Override
-	public void configure(JsonNode config) {
-		this.config = config;
-	}
-
-	@Override
-	public void finishedWith(String owningProcess) {
-		String prefix = owningProcess + "[";
-		synchronized (outgoingJobs) {
-			for (String key : new ArrayList<>(outgoingJobs.keySet()))
-				if (key.startsWith(prefix))
-					outgoingJobs.remove(key);
-		}
-		synchronized (incomingJobs) {
-			for (String key : new ArrayList<>(incomingJobs.keySet()))
-				if (key.startsWith(prefix))
-					incomingJobs.remove(key);
-		}
-	}
-
-	@Override
-	public JsonNode getConfiguration() {
-		return config;
-	}
-
-	@Override
-	public void receiveJob(DispatchJobEvent jobEvent) {
-		synchronized (incomingJobs) {
-			incomingJobs.put(jobIdentifier(jobEvent), jobEvent);
-		}
-		if (config.get("runFirst").asBoolean()) {
-			// We'll do the conditional in receiveResult instead
-			super.receiveJob(jobEvent);
-			return;
-		}
-		checkCondition(jobEvent);
-	}
-
-	@Override
-	public void receiveJobQueue(DispatchJobQueueEvent jobQueueEvent) {
-		synchronized (incomingJobs) {
-			incomingJobs.put(jobIdentifier(jobQueueEvent), jobQueueEvent);
-		}
-		if (config.get("runFirst").asBoolean()) {
-			// We'll do the conditional in receiveResult instead
-			super.receiveJobQueue(jobQueueEvent);
-			return;
-		}
-		checkCondition(jobQueueEvent);
-	}
-	
-	private Activity<?> getCondition() {
-		//return config.getCondition();
-		return null;
-	}
-
-	@Override
-	public void receiveResult(DispatchResultEvent resultEvent) {
-		Activity<?> condition = getCondition();
-		if (condition == null) {
-			super.receiveResult(resultEvent);
-			return;
-		}
-		synchronized (outgoingJobs) {
-			outgoingJobs.put(jobIdentifier(resultEvent), resultEvent);
-		}
-		checkCondition(resultEvent);
-	}
-
-	@Override
-	public void receiveResultCompletion(DispatchCompletionEvent completionEvent) {
-		Activity<?> condition = getCondition();
-		if (condition == null) {
-			super.receiveResultCompletion(completionEvent);
-			return;
-		}
-		synchronized (outgoingJobs) {
-			outgoingJobs.put(jobIdentifier(completionEvent), completionEvent);
-		}
-		checkCondition(completionEvent);
-	}
-
-	private void checkCondition(AbstractDispatchEvent event) {
-		Activity<?> condition = getCondition();
-		if (condition == null) {
-			super.receiveError(new DispatchErrorEvent(event.getOwningProcess(),
-					event.getIndex(), event.getContext(),
-					"Can't invoke condition service: null", null,
-					DispatchErrorType.INVOCATION, condition));
-			return;
-		}
-		if (!(condition instanceof AbstractAsynchronousActivity)) {
-			DispatchErrorEvent errorEvent = new DispatchErrorEvent(
-					event.getOwningProcess(),
-					event.getIndex(),
-					event.getContext(),
-					"Can't invoke condition service "
-							+ condition
-							+ " is not an instance of AbstractAsynchronousActivity",
-					null, DispatchErrorType.INVOCATION, condition);
-			super.receiveError(errorEvent);
-			return;
-		}
-		AbstractAsynchronousActivity asyncCondition = (AbstractAsynchronousActivity) condition;
-		String jobIdentifier = jobIdentifier(event);
-		Map<String, T2Reference> inputs = prepareInputs(asyncCondition,
-				jobIdentifier);
-		AsynchronousActivityCallback callback = new ConditionCallBack(
-				jobIdentifier);
-		asyncCondition.executeAsynch(inputs, callback);
-	}
-
-	private Map<String, T2Reference> prepareInputs(
-			AbstractAsynchronousActivity asyncCondition, String jobIdentifier) {
-		Map<String, T2Reference> inputs = new HashMap<>();
-		Map<String, T2Reference> inData = getInData(jobIdentifier);
-		Map<String, T2Reference> outData = getOutData(jobIdentifier);
-
-		Set<ActivityInputPort> inputPorts = asyncCondition.getInputPorts();
-		for (ActivityInputPort conditionIn : inputPorts) {
-			String conditionPort = conditionIn.getName();
-			if (outData.containsKey(conditionPort))
-				// Copy from previous output
-				inputs.put(conditionPort, outData.get(conditionPort));
-			else if (inData.containsKey(conditionPort))
-				// Copy from original input
-				inputs.put(conditionPort, inData.get(conditionPort));
-		}
-		return inputs;
-	}
-
-	private Map<String, T2Reference> getInData(String jobIdentifier) {
-		AbstractDispatchEvent inEvent;
-		synchronized (incomingJobs) {
-			inEvent = incomingJobs.get(jobIdentifier);
-		}
-		Map<String, T2Reference> inData = new HashMap<>();
-		if (inEvent instanceof DispatchJobEvent)
-			inData = ((DispatchJobEvent) inEvent).getData();
-		return inData;
-	}
-
-	private Map<String, T2Reference> getOutData(String jobIdentifier) {
-		AbstractDispatchEvent outEvent;
-		synchronized (outgoingJobs) {
-			outEvent = outgoingJobs.get(jobIdentifier);
-		}
-		Map<String, T2Reference> outData = new HashMap<>();
-		if (outEvent instanceof DispatchResultEvent)
-			outData = ((DispatchResultEvent) outEvent).getData();
-		return outData;
-	}
-
-	private String jobIdentifier(AbstractDispatchEvent event) {
-		String jobId = event.getOwningProcess()
-				+ Arrays.toString(event.getIndex());
-		return jobId;
-	}
-
-	public static final String LOOP_PORT = "loop";
-
-	public class ConditionCallBack implements AsynchronousActivityCallback {
-		private InvocationContext context;
-		private final String jobIdentifier;
-		private String processId;
-
-		public ConditionCallBack(String jobIdentifier) {
-			this.jobIdentifier = jobIdentifier;
-			AbstractDispatchEvent originalEvent;
-			synchronized (incomingJobs) {
-				originalEvent = incomingJobs.get(jobIdentifier);
-			}
-			context = originalEvent.getContext();
-			processId = originalEvent.getOwningProcess() + ":condition";
-		}
-
-		@Override
-		public void fail(String message) {
-			fail(message, null, DispatchErrorType.INVOCATION);
-		}
-
-		@Override
-		public void fail(String message, Throwable t) {
-			fail(message, t, DispatchErrorType.INVOCATION);
-		}
-
-		@Override
-		public void fail(String message, Throwable t,
-				DispatchErrorType errorType) {
-			logger.warn("Failed (" + errorType + ") invoking condition service "
-					+ jobIdentifier + ":" + message, t);
-
-			AbstractDispatchEvent originalEvent;
-			synchronized (incomingJobs) {
-				originalEvent = incomingJobs.get(jobIdentifier);
-			}
-			receiveError(new DispatchErrorEvent(originalEvent
-					.getOwningProcess(), originalEvent.getIndex(),
-					originalEvent.getContext(),
-					"Can't invoke condition service ", t,
-					DispatchErrorType.INVOCATION, null));
-		}
-
-		@Override
-		public InvocationContext getContext() {
-			return context;
-		}
-
-		@Override
-		public String getParentProcessIdentifier() {
-			return processId;
-		}
-
-		@Override
-		public void receiveCompletion(int[] completionIndex) {
-			// Ignore streaming
-		}
-
-		@Override
-		public void receiveResult(Map<String, T2Reference> data, int[] index) {
-			if (index.length > 0) {
-				// Ignore streaming
-				return;
-			}
-			T2Reference loopRef = data.get(LOOP_PORT);
-			if (loopRef == null) {
-				fail("Condition service didn't contain output port " + LOOP_PORT);
-				return;
-			}
-			if (loopRef.containsErrors()) {
-				fail("Condition service failed: " + loopRef);
-				return;
-			}
-			if (loopRef.getDepth() != 0) {
-				fail("Condition service output " + LOOP_PORT
-						+ " depth is not 0, but " + loopRef.getDepth());
-			}
-			ReferenceService referenceService = context.getReferenceService();
-			String loop = (String) referenceService.renderIdentifier(loopRef,
-					String.class, context);
-
-			if (Boolean.parseBoolean(loop)) {
-				// Push it down again
-				AbstractDispatchEvent dispatchEvent;
-				synchronized (incomingJobs) {
-					dispatchEvent = incomingJobs.get(jobIdentifier);
-				}
-				if (dispatchEvent == null) {
-					fail("Unknown job identifier " + jobIdentifier);
-				}
-				if (dispatchEvent instanceof DispatchJobEvent) {
-					DispatchJobEvent newJobEvent = prepareNewJobEvent(data,
-							dispatchEvent);
-					getBelow().receiveJob(newJobEvent);
-				} else if (dispatchEvent instanceof DispatchJobQueueEvent) {
-					getBelow().receiveJobQueue(
-							(DispatchJobQueueEvent) dispatchEvent);
-				} else {
-					fail("Unknown type of incoming event " + dispatchEvent);
-				}
-				return;
-
-			} else {
-				// We'll push it up, end of loop for now
-
-				AbstractDispatchEvent outgoingEvent;
-				synchronized (outgoingJobs) {
-					outgoingEvent = outgoingJobs.get(jobIdentifier);
-				}
-				if (outgoingEvent == null && !config.get("runFirst").asBoolean()) {
-					fail("Initial loop condition failed");
-				}
-				if (outgoingEvent instanceof DispatchCompletionEvent) {
-					getAbove().receiveResultCompletion(
-							(DispatchCompletionEvent) outgoingEvent);
-				} else if (outgoingEvent instanceof DispatchResultEvent) {
-					getAbove().receiveResult(
-							(DispatchResultEvent) outgoingEvent);
-				} else {
-					fail("Unknown type of outgoing event " + outgoingEvent);
-				}
-			}
-
-		}
-
-		private DispatchJobEvent prepareNewJobEvent(
-				Map<String, T2Reference> data,
-				AbstractDispatchEvent dispatchEvent) {
-			DispatchJobEvent dispatchJobEvent = (DispatchJobEvent) dispatchEvent;
-			Map<String, T2Reference> newInputs = new HashMap<String, T2Reference>(
-					dispatchJobEvent.getData());
-			newInputs.putAll(data);
-			DispatchJobEvent newJobEvent = new DispatchJobEvent(dispatchEvent
-					.getOwningProcess(), dispatchEvent.getIndex(),
-					dispatchEvent.getContext(), newInputs,
-					((DispatchJobEvent) dispatchEvent).getActivities());
-			/*
-			 * TODO: Should this be registered as an incomingJobs? If so the
-			 * conditional could even feed to itself, and we should also keep a
-			 * list of originalJobs.
-			 */
-			return newJobEvent;
-		}
-
-		@Override
-		public void requestRun(Runnable runMe) {
-			String newThreadName = "Condition service "
-					+ getParentProcessIdentifier();
-			Thread thread = new Thread(runMe, newThreadName);
-			thread.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
-				@Override
-				public void uncaughtException(Thread t, Throwable e) {
-					fail("Uncaught exception while invoking " + jobIdentifier,
-							e);
-				}
-			});
-			thread.start();
-		}
-	}
-
-	@Override
-	public Processor getProcessor() {
-		if (dispatchStack == null)
-			return null;
-		return dispatchStack.getProcessor();
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/LoopConfiguration.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/LoopConfiguration.java b/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/LoopConfiguration.java
deleted file mode 100644
index 7cfa2a5..0000000
--- a/taverna-workflowmodel-extensions/src/main/java/net/sf/taverna/t2/workflowmodel/processor/dispatch/layers/LoopConfiguration.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package net.sf.taverna.t2.workflowmodel.processor.dispatch.layers;
-
-import java.util.Properties;
-
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationBean;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationProperty;
-
-/**
- * Configuration bean for the {@link Loop}.
- * <p>
- * Set the {@link #setCondition(Activity)} for an activity with an output port
- * called "loop". The LoopLayer will re-send a job only if this port exist and
- * it's output can be dereferenced to a string equal to "true".
- * </p>
- * <p>
- * If {@link #isRunFirst()} is false, the loop layer will check the condition
- * before invoking the job for the first time, otherwise the condition will be
- * invoked after the job has come back with successful results.
- * </p>
- * 
- * @author Stian Soiland-Reyes
- * 
- */
-@ConfigurationBean(uri = Loop.URI + "#Config")
-public class LoopConfiguration implements Cloneable {
-	private Activity<?> condition = null;
-	private Boolean runFirst;
-	private Properties properties;
-
-	public Properties getProperties() {
-		synchronized (this) {
-			if (properties == null)
-				properties = new Properties();
-		}
-		return properties;
-	}
-
-	public void setProperties(Properties properties) {
-		this.properties = properties;
-	}
-
-	@Override
-	public LoopConfiguration clone() {
-		LoopConfiguration clone;
-		try {
-			clone = (LoopConfiguration) super.clone();
-			clone.condition = null;
-		} catch (CloneNotSupportedException e) {
-			throw new RuntimeException("Unexpected CloneNotSupportedException",
-					e);
-		}
-		return clone;
-	}
-
-	public Activity<?> getCondition() {
-		return condition;
-	}
-
-	public boolean isRunFirst() {
-		if (runFirst == null)
-			return true;
-		return runFirst;
-	}
-
-	@ConfigurationProperty(name = "condition", label = "Condition Activity", description = "The condition activity with an output port called \"loop\"", required = false)
-	public void setCondition(Activity<?> activity) {
-		this.condition = activity;
-	}
-
-	@ConfigurationProperty(name = "runFirst", label = "Check Condition On Run First", description = "Whether to check the condition before invoking the job for the first time", required = false)
-	public void setRunFirst(boolean runFirst) {
-		this.runFirst = runFirst;
-	}
-}


[44/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/WorkflowToDataflowMapper.java
----------------------------------------------------------------------
diff --git a/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/WorkflowToDataflowMapper.java b/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/WorkflowToDataflowMapper.java
deleted file mode 100644
index 1ffd5ca..0000000
--- a/taverna-execution-local/src/main/java/uk/org/taverna/platform/execution/impl/local/WorkflowToDataflowMapper.java
+++ /dev/null
@@ -1,527 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.impl.local;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.IdentityHashMap;
-import java.util.List;
-import java.util.Map;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import net.sf.taverna.t2.workflowmodel.DataflowInputPort;
-import net.sf.taverna.t2.workflowmodel.DataflowOutputPort;
-import net.sf.taverna.t2.workflowmodel.Datalink;
-import net.sf.taverna.t2.workflowmodel.EditException;
-import net.sf.taverna.t2.workflowmodel.Edits;
-import net.sf.taverna.t2.workflowmodel.EventForwardingOutputPort;
-import net.sf.taverna.t2.workflowmodel.EventHandlingInputPort;
-import net.sf.taverna.t2.workflowmodel.Merge;
-import net.sf.taverna.t2.workflowmodel.MergeInputPort;
-import net.sf.taverna.t2.workflowmodel.ProcessorInputPort;
-import net.sf.taverna.t2.workflowmodel.ProcessorOutputPort;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityInputPort;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityOutputPort;
-import net.sf.taverna.t2.workflowmodel.processor.activity.NestedDataflow;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchStack;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.IterationStrategy;
-import net.sf.taverna.t2.workflowmodel.processor.iteration.NamedInputPortNode;
-import org.apache.taverna.platform.capability.api.ActivityConfigurationException;
-import org.apache.taverna.platform.capability.api.ActivityNotFoundException;
-import org.apache.taverna.platform.capability.api.ActivityService;
-import org.apache.taverna.platform.capability.api.DispatchLayerConfigurationException;
-import org.apache.taverna.platform.capability.api.DispatchLayerNotFoundException;
-import org.apache.taverna.platform.capability.api.DispatchLayerService;
-import uk.org.taverna.platform.execution.api.InvalidWorkflowException;
-import org.apache.taverna.scufl2.api.activity.Activity;
-import org.apache.taverna.scufl2.api.common.Scufl2Tools;
-import org.apache.taverna.scufl2.api.configurations.Configuration;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.BlockingControlLink;
-import org.apache.taverna.scufl2.api.core.ControlLink;
-import org.apache.taverna.scufl2.api.core.DataLink;
-import org.apache.taverna.scufl2.api.core.Processor;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.iterationstrategy.CrossProduct;
-import org.apache.taverna.scufl2.api.iterationstrategy.DotProduct;
-import org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyNode;
-import org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyStack;
-import org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyTopNode;
-import org.apache.taverna.scufl2.api.iterationstrategy.PortNode;
-import org.apache.taverna.scufl2.api.port.InputActivityPort;
-import org.apache.taverna.scufl2.api.port.InputProcessorPort;
-import org.apache.taverna.scufl2.api.port.InputWorkflowPort;
-import org.apache.taverna.scufl2.api.port.OutputActivityPort;
-import org.apache.taverna.scufl2.api.port.OutputProcessorPort;
-import org.apache.taverna.scufl2.api.port.OutputWorkflowPort;
-import org.apache.taverna.scufl2.api.port.Port;
-import org.apache.taverna.scufl2.api.port.ReceiverPort;
-import org.apache.taverna.scufl2.api.port.SenderPort;
-import org.apache.taverna.scufl2.api.profiles.ProcessorBinding;
-import org.apache.taverna.scufl2.api.profiles.ProcessorInputPortBinding;
-import org.apache.taverna.scufl2.api.profiles.ProcessorOutputPortBinding;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * Translates a scufl2 {@link Workflow} into a {@link Dataflow}.
- * 
- * @author David Withers
- */
-public class WorkflowToDataflowMapper {
-	private static final URI NESTED_WORKFLOW_URI = URI
-			.create("http://ns.taverna.org.uk/2010/activity/nested-workflow");
-
-	private Edits edits;
-	private final Scufl2Tools scufl2Tools = new Scufl2Tools();
-	private final Map<Port, EventHandlingInputPort> inputPorts;
-	private final Map<Port, EventForwardingOutputPort> outputPorts;
-	private final Map<Port, Merge> merges;
-	private final Map<Workflow, Dataflow> workflowToDataflow;
-	private final Map<Dataflow, Workflow> dataflowToWorkflow;
-	private final Map<Processor, net.sf.taverna.t2.workflowmodel.Processor> workflowToDataflowProcessors;
-	private final Map<net.sf.taverna.t2.workflowmodel.Processor, Processor> dataflowToWorkflowProcessors;
-	private final Map<Activity, net.sf.taverna.t2.workflowmodel.processor.activity.Activity<?>> workflowToDataflowActivities;
-	private final Map<net.sf.taverna.t2.workflowmodel.processor.activity.Activity<?>, Activity> dataflowToWorkflowActivities;
-	@SuppressWarnings("unused")
-	private final WorkflowBundle workflowBundle;
-	private final Profile profile;
-	private final ActivityService activityService;
-	private final DispatchLayerService dispatchLayerService;
-
-	public WorkflowToDataflowMapper(WorkflowBundle workflowBundle,
-			Profile profile, Edits edits, ActivityService activityService,
-			DispatchLayerService dispatchLayerService) {
-		this.workflowBundle = workflowBundle;
-		this.profile = profile;
-		this.edits = edits;
-		this.activityService = activityService;
-		this.dispatchLayerService = dispatchLayerService;
-		inputPorts = new IdentityHashMap<>();
-		outputPorts = new IdentityHashMap<>();
-		merges = new IdentityHashMap<>();
-		workflowToDataflow = new IdentityHashMap<>();
-		dataflowToWorkflow = new HashMap<>();
-		workflowToDataflowProcessors = new IdentityHashMap<>();
-		dataflowToWorkflowProcessors = new HashMap<>();
-		workflowToDataflowActivities = new IdentityHashMap<>();
-		dataflowToWorkflowActivities = new HashMap<>();
-	}
-
-	public Workflow getWorkflow(Dataflow dataflow) {
-		return dataflowToWorkflow.get(dataflow);
-	}
-
-	public Dataflow getDataflow(Workflow workflow)
-			throws InvalidWorkflowException {
-		if (!workflowToDataflow.containsKey(workflow)) {
-			try {
-				Dataflow dataflow = createDataflow(workflow);
-				workflowToDataflow.put(workflow, dataflow);
-				dataflowToWorkflow.put(dataflow, workflow);
-			} catch (EditException | ActivityConfigurationException
-					| DispatchLayerConfigurationException
-					| ActivityNotFoundException
-					| DispatchLayerNotFoundException e) {
-				throw new InvalidWorkflowException(e);
-			}
-		}
-		return workflowToDataflow.get(workflow);
-	}
-
-	public Processor getWorkflowProcessor(
-			net.sf.taverna.t2.workflowmodel.Processor dataflowProcessor) {
-		return dataflowToWorkflowProcessors.get(dataflowProcessor);
-	}
-
-	public net.sf.taverna.t2.workflowmodel.Processor getDataflowProcessor(
-			Processor workflowProcessor) {
-		return workflowToDataflowProcessors.get(workflowProcessor);
-	}
-
-	public Activity getWorkflowActivity(
-			net.sf.taverna.t2.workflowmodel.processor.activity.Activity<?> dataflowActiviy) {
-		return dataflowToWorkflowActivities.get(dataflowActiviy);
-	}
-
-	public net.sf.taverna.t2.workflowmodel.processor.activity.Activity<?> getDataflowActivity(
-			Activity workflowActivity) {
-		return workflowToDataflowActivities.get(workflowActivity);
-	}
-
-	protected Dataflow createDataflow(Workflow workflow) throws EditException,
-			ActivityNotFoundException, ActivityConfigurationException,
-			InvalidWorkflowException, DispatchLayerNotFoundException,
-			DispatchLayerConfigurationException {
-		// create the dataflow
-		Dataflow dataflow = edits.createDataflow();
-		// set the dataflow name
-		edits.getUpdateDataflowNameEdit(dataflow, workflow.getName()).doEdit();
-
-		addInputPorts(workflow, dataflow);
-		addOutputPorts(workflow, dataflow);
-		addProcessors(workflow, dataflow);
-		addDataLinks(workflow, dataflow);
-		addControlLinks(workflow);
-
-		return dataflow;
-	}
-
-	private void addProcessors(Workflow workflow, Dataflow dataflow)
-			throws EditException, ActivityNotFoundException,
-			ActivityConfigurationException, InvalidWorkflowException,
-			DispatchLayerNotFoundException, DispatchLayerConfigurationException {
-		for (Processor processor : workflow.getProcessors()) {
-			net.sf.taverna.t2.workflowmodel.Processor dataflowProcessor = edits
-					.createProcessor(processor.getName());
-			edits.getAddProcessorEdit(dataflow, dataflowProcessor).doEdit();
-			// map the processor
-			workflowToDataflowProcessors.put(processor, dataflowProcessor);
-			dataflowToWorkflowProcessors.put(dataflowProcessor, processor);
-			// add input ports
-			for (InputProcessorPort inputProcessorPort : processor
-					.getInputPorts()) {
-				if (inputProcessorPort.getDatalinksTo().isEmpty())
-					continue;
-				ProcessorInputPort processorInputPort = edits
-						.createProcessorInputPort(dataflowProcessor,
-								inputProcessorPort.getName(),
-								inputProcessorPort.getDepth());
-				edits.getAddProcessorInputPortEdit(dataflowProcessor,
-						processorInputPort).doEdit();
-				inputPorts.put(inputProcessorPort, processorInputPort);
-			}
-			// add output ports
-			for (OutputProcessorPort outputProcessorPort : processor
-					.getOutputPorts()) {
-				ProcessorOutputPort processorOutputPort = edits
-						.createProcessorOutputPort(dataflowProcessor,
-								outputProcessorPort.getName(),
-								outputProcessorPort.getDepth(),
-								outputProcessorPort.getGranularDepth());
-				edits.getAddProcessorOutputPortEdit(dataflowProcessor,
-						processorOutputPort).doEdit();
-				outputPorts.put(outputProcessorPort, processorOutputPort);
-			}
-
-			// add dispatch stack
-			addDispatchStack(processor, dataflowProcessor);
-
-			addIterationStrategy(processor, dataflowProcessor);
-
-			// add bound activities
-			for (ProcessorBinding processorBinding : scufl2Tools
-					.processorBindingsForProcessor(processor, profile))
-				addActivity(processorBinding);
-		}
-	}
-
-	private void addDispatchStack(Processor processor,
-			net.sf.taverna.t2.workflowmodel.Processor dataflowProcessor)
-			throws DispatchLayerNotFoundException,
-			DispatchLayerConfigurationException, EditException {
-		DispatchStack dispatchStack = dataflowProcessor.getDispatchStack();
-
-		JsonNode json = null;
-		try {
-			json = processor.getConfiguration(profile).getJson();
-		} catch (IndexOutOfBoundsException e) {
-			// no configuration for processor
-		}
-
-		int layer = 0;
-		addDispatchLayer(
-				dispatchStack,
-				URI.create("http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/Parallelize"),
-				layer++, json == null ? null : json.get("parallelize"));
-		addDispatchLayer(
-				dispatchStack,
-				URI.create("http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/ErrorBounce"),
-				layer++, null);
-		addDispatchLayer(
-				dispatchStack,
-				URI.create("http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/Failover"),
-				layer++, null);
-		addDispatchLayer(
-				dispatchStack,
-				URI.create("http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/Retry"),
-				layer++, json == null ? null : json.get("retry"));
-		addDispatchLayer(
-				dispatchStack,
-				URI.create("http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/Stop"),
-				layer++, null);
-		addDispatchLayer(
-				dispatchStack,
-				URI.create("http://ns.taverna.org.uk/2010/scufl2/taverna/dispatchlayer/Invoke"),
-				layer++, null);
-
-	}
-
-	private void addDispatchLayer(DispatchStack dispatchStack,
-			URI dispatchLayerType, int layer, JsonNode json)
-			throws DispatchLayerConfigurationException,
-			DispatchLayerNotFoundException, EditException {
-		// create the dispatch layer
-		DispatchLayer<?> dispatchLayer = dispatchLayerService
-				.createDispatchLayer(dispatchLayerType, json);
-		// add the dispatch layer to the dispatch layer stack
-		edits.getAddDispatchLayerEdit(dispatchStack, dispatchLayer, layer)
-				.doEdit();
-	}
-
-	private void addIterationStrategy(Processor processor,
-			net.sf.taverna.t2.workflowmodel.Processor dataflowProcessor)
-			throws EditException, InvalidWorkflowException {
-		// get the iteration strategy from the processor
-		net.sf.taverna.t2.workflowmodel.processor.iteration.IterationStrategyStack dataflowIterationStrategyStack = dataflowProcessor
-				.getIterationStrategy();
-		// clear the iteration strategy
-		edits.getClearIterationStrategyStackEdit(dataflowIterationStrategyStack)
-				.doEdit();
-		IterationStrategyStack iterationStrategyStack = processor
-				.getIterationStrategyStack();
-		for (IterationStrategyTopNode iterationStrategyTopNode : iterationStrategyStack) {
-			// create iteration strategy
-			IterationStrategy dataflowIterationStrategy = edits
-					.createIterationStrategy();
-			// add iteration strategy to the stack
-			edits.getAddIterationStrategyEdit(dataflowIterationStrategyStack,
-					dataflowIterationStrategy).doEdit();
-			// add the node to the iteration strategy
-			addIterationStrategyNode(dataflowIterationStrategy,
-					dataflowIterationStrategy.getTerminalNode(),
-					iterationStrategyTopNode);
-		}
-	}
-
-	private void addIterationStrategyNode(
-			IterationStrategy dataflowIterationStrategy,
-			net.sf.taverna.t2.workflowmodel.processor.iteration.IterationStrategyNode dataflowIterationStrategyNode,
-			IterationStrategyNode iterationStrategyNode) throws EditException,
-			InvalidWorkflowException {
-		net.sf.taverna.t2.workflowmodel.processor.iteration.IterationStrategyNode childDataflowIterationStrategyNode = null;
-		if (iterationStrategyNode instanceof CrossProduct) {
-			CrossProduct crossProduct = (CrossProduct) iterationStrategyNode;
-			childDataflowIterationStrategyNode = new net.sf.taverna.t2.workflowmodel.processor.iteration.CrossProduct();
-			for (IterationStrategyNode iterationStrategyNode2 : crossProduct)
-				addIterationStrategyNode(dataflowIterationStrategy,
-						childDataflowIterationStrategyNode,
-						iterationStrategyNode2);
-		} else if (iterationStrategyNode instanceof DotProduct) {
-			DotProduct dotProduct = (DotProduct) iterationStrategyNode;
-			childDataflowIterationStrategyNode = new net.sf.taverna.t2.workflowmodel.processor.iteration.DotProduct();
-			for (IterationStrategyNode iterationStrategyNode2 : dotProduct)
-				addIterationStrategyNode(dataflowIterationStrategy,
-						childDataflowIterationStrategyNode,
-						iterationStrategyNode2);
-		} else if (iterationStrategyNode instanceof PortNode) {
-			PortNode portNode = (PortNode) iterationStrategyNode;
-			Integer desiredDepth = portNode.getDesiredDepth();
-			if (desiredDepth == null)
-				desiredDepth = portNode.getInputProcessorPort().getDepth();
-			NamedInputPortNode namedInputPortNode = new NamedInputPortNode(
-					portNode.getInputProcessorPort().getName(), desiredDepth);
-			edits.getAddIterationStrategyInputNodeEdit(
-					dataflowIterationStrategy, namedInputPortNode).doEdit();
-			childDataflowIterationStrategyNode = namedInputPortNode;
-		} else {
-			throw new InvalidWorkflowException(
-					"Unknown IterationStrategyNode type : "
-							+ iterationStrategyNode.getClass().getName());
-		}
-		childDataflowIterationStrategyNode
-				.setParent(dataflowIterationStrategyNode);
-	}
-
-	private void addActivity(ProcessorBinding processorBinding)
-			throws EditException, ActivityNotFoundException,
-			ActivityConfigurationException, InvalidWorkflowException {
-		net.sf.taverna.t2.workflowmodel.Processor processor = workflowToDataflowProcessors
-				.get(processorBinding.getBoundProcessor());
-		Activity scufl2Activity = processorBinding.getBoundActivity();
-		URI activityType = scufl2Activity.getType();
-		if (!activityService.activityExists(activityType))
-			throw new ActivityNotFoundException("No activity exists for "
-					+ activityType);
-		Configuration configuration = scufl2Activity.getConfiguration();
-
-		// create the activity
-		net.sf.taverna.t2.workflowmodel.processor.activity.Activity<?> activity = activityService
-				.createActivity(activityType, configuration.getJson());
-		// check if we have a nested workflow
-		if (activityType.equals(NESTED_WORKFLOW_URI)) {
-			if (activity instanceof NestedDataflow) {
-				Workflow nestedWorkflow = scufl2Tools
-						.nestedWorkflowForProcessor(
-								processorBinding.getBoundProcessor(), profile);
-				((NestedDataflow) activity)
-						.setNestedDataflow(getDataflow(nestedWorkflow));
-			} else
-				throw new ActivityConfigurationException(
-						"Activity is not an instance of NestedDataflow");
-		}
-
-		// add the activity to the processor
-		edits.getAddActivityEdit(processor, activity).doEdit();
-
-		// add input ports
-		for (InputActivityPort inputActivityPort : scufl2Activity
-				.getInputPorts()) {
-			ActivityInputPort activityInputPort = edits
-					.createActivityInputPort(
-							inputActivityPort.getName(),
-							inputActivityPort.getDepth(),
-							false,
-							new ArrayList<Class<? extends ExternalReferenceSPI>>(),
-							String.class);
-			edits.getAddActivityInputPortEdit(activity, activityInputPort)
-					.doEdit();
-		}
-		// add output ports
-		for (OutputActivityPort outputActivityPort : scufl2Activity
-				.getOutputPorts()) {
-			ActivityOutputPort activitytOutputPort = edits
-					.createActivityOutputPort(outputActivityPort.getName(),
-							outputActivityPort.getDepth(),
-							outputActivityPort.getGranularDepth());
-			edits.getAddActivityOutputPortEdit(activity, activitytOutputPort)
-					.doEdit();
-		}
-		// map input ports
-		for (ProcessorInputPortBinding portBinding : processorBinding
-				.getInputPortBindings()) {
-			InputProcessorPort processorPort = portBinding
-					.getBoundProcessorPort();
-			InputActivityPort activityPort = portBinding.getBoundActivityPort();
-			edits.getAddActivityInputPortMappingEdit(activity,
-					processorPort.getName(), activityPort.getName()).doEdit();
-		}
-		// map output ports
-		for (ProcessorOutputPortBinding portBinding : processorBinding
-				.getOutputPortBindings()) {
-			OutputProcessorPort processorPort = portBinding
-					.getBoundProcessorPort();
-			OutputActivityPort activityPort = portBinding
-					.getBoundActivityPort();
-			edits.getAddActivityOutputPortMappingEdit(activity,
-					processorPort.getName(), activityPort.getName()).doEdit();
-		}
-		workflowToDataflowActivities.put(scufl2Activity, activity);
-		dataflowToWorkflowActivities.put(activity, scufl2Activity);
-	}
-
-	private void addDataLinks(Workflow workflow, Dataflow dataflow)
-			throws EditException {
-		for (DataLink dataLink : workflow.getDataLinks()) {
-			ReceiverPort receiverPort = dataLink.getSendsTo();
-			SenderPort senderPort = dataLink.getReceivesFrom();
-			EventForwardingOutputPort source = outputPorts.get(senderPort);
-			EventHandlingInputPort sink = inputPorts.get(receiverPort);
-			Integer mergePosition = dataLink.getMergePosition();
-			if (mergePosition != null) {
-				if (!merges.containsKey(receiverPort)) {
-					Merge merge = edits.createMerge(dataflow);
-					edits.getAddMergeEdit(dataflow, merge).doEdit();
-					merges.put(receiverPort, merge);
-				}
-				Merge merge = merges.get(receiverPort);
-				// create merge input port
-				MergeInputPort mergeInputPort = edits.createMergeInputPort(
-						merge, "input" + mergePosition, sink.getDepth());
-				// add it to the correct position in the merge
-				@SuppressWarnings("unchecked")
-				List<MergeInputPort> mergeInputPorts = (List<MergeInputPort>) merge
-						.getInputPorts();
-				if (mergePosition > mergeInputPorts.size())
-					mergeInputPorts.add(mergeInputPort);
-				else
-					mergeInputPorts.add(mergePosition, mergeInputPort);
-				// connect a datalink into the merge
-				Datalink datalinkIn = edits.createDatalink(source,
-						mergeInputPort);
-				edits.getConnectDatalinkEdit(datalinkIn).doEdit();
-				// check if the merge output has been connected
-				EventForwardingOutputPort mergeOutputPort = merge
-						.getOutputPort();
-				if (mergeOutputPort.getOutgoingLinks().isEmpty()) {
-					Datalink datalinkOut = edits.createDatalink(
-							merge.getOutputPort(), sink);
-					edits.getConnectDatalinkEdit(datalinkOut).doEdit();
-				} else if (mergeOutputPort.getOutgoingLinks().size() == 1) {
-					if (mergeOutputPort.getOutgoingLinks().iterator().next()
-							.getSink() != sink)
-						throw new EditException(
-								"Cannot add a different sinkPort to a Merge that already has one defined");
-				} else
-					throw new EditException(
-							"The merge instance cannot have more that 1 outgoing Datalink");
-			} else {
-				Datalink datalink = edits.createDatalink(source, sink);
-				edits.getConnectDatalinkEdit(datalink).doEdit();
-			}
-		}
-	}
-
-	private void addControlLinks(Workflow workflow) throws EditException {
-		for (ControlLink controlLink : workflow.getControlLinks()) {
-			if (controlLink instanceof BlockingControlLink) {
-				BlockingControlLink blockingControlLink = (BlockingControlLink) controlLink;
-				Processor untilFinished = blockingControlLink
-						.getUntilFinished();
-				Processor block = blockingControlLink.getBlock();
-				edits.getCreateConditionEdit(
-						workflowToDataflowProcessors.get(untilFinished),
-						workflowToDataflowProcessors.get(block)).doEdit();
-			}
-		}
-	}
-
-	private void addOutputPorts(Workflow workflow, Dataflow dataflow)
-			throws EditException {
-		for (OutputWorkflowPort outputWorkflowPort : workflow.getOutputPorts()) {
-			DataflowOutputPort dataflowOutputPort = edits
-					.createDataflowOutputPort(outputWorkflowPort.getName(),
-							dataflow);
-			edits.getAddDataflowOutputPortEdit(dataflow, dataflowOutputPort)
-					.doEdit();
-			inputPorts.put(outputWorkflowPort,
-					dataflowOutputPort.getInternalInputPort());
-		}
-	}
-
-	private void addInputPorts(Workflow workflow, Dataflow dataflow)
-			throws EditException {
-		for (InputWorkflowPort inputWorkflowPort : workflow.getInputPorts()) {
-			DataflowInputPort dataflowInputPort = edits
-					.createDataflowInputPort(inputWorkflowPort.getName(),
-							inputWorkflowPort.getDepth(),
-							inputWorkflowPort.getDepth(), dataflow);
-			edits.getAddDataflowInputPortEdit(dataflow, dataflowInputPort)
-					.doEdit();
-			outputPorts.put(inputWorkflowPort,
-					dataflowInputPort.getInternalOutputPort());
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-local/src/main/resources/META-INF/spring/execution-local-context-osgi.xml
----------------------------------------------------------------------
diff --git a/taverna-execution-local/src/main/resources/META-INF/spring/execution-local-context-osgi.xml b/taverna-execution-local/src/main/resources/META-INF/spring/execution-local-context-osgi.xml
index 21a07c4..9ed6854 100644
--- a/taverna-execution-local/src/main/resources/META-INF/spring/execution-local-context-osgi.xml
+++ b/taverna-execution-local/src/main/resources/META-INF/spring/execution-local-context-osgi.xml
@@ -16,8 +16,8 @@
 		</service-properties>
 	</service>
 
-	<reference id="workflowModelEdits" interface="net.sf.taverna.t2.workflowmodel.Edits" />
-	<reference id="activityService" interface="uk.org.taverna.platform.capability.api.ActivityService" />
-	<reference id="dispatchLayerService" interface="uk.org.taverna.platform.capability.api.DispatchLayerService" />
-	<reference id="referenceService" interface="net.sf.taverna.t2.reference.ReferenceService" />
+	<reference id="workflowModelEdits" interface="org.apache.taverna.workflowmodel.Edits" />
+	<reference id="activityService" interface="org.apache.taverna.platform.capability.api.ActivityService" />
+	<reference id="dispatchLayerService" interface="org.apache.taverna.platform.capability.api.DispatchLayerService" />
+	<reference id="referenceService" interface="org.apache.taverna.reference.ReferenceService" />
 </beans:beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-local/src/main/resources/META-INF/spring/execution-local-context.xml
----------------------------------------------------------------------
diff --git a/taverna-execution-local/src/main/resources/META-INF/spring/execution-local-context.xml b/taverna-execution-local/src/main/resources/META-INF/spring/execution-local-context.xml
index bf9a146..4f4c660 100644
--- a/taverna-execution-local/src/main/resources/META-INF/spring/execution-local-context.xml
+++ b/taverna-execution-local/src/main/resources/META-INF/spring/execution-local-context.xml
@@ -3,7 +3,7 @@
 	xsi:schemaLocation="http://www.springframework.org/schema/beans
                            http://www.springframework.org/schema/beans/spring-beans.xsd">
 
-	<bean id="localExecution" class="uk.org.taverna.platform.execution.impl.local.LocalExecutionService">
+	<bean id="localExecution" class="org.apache.taverna.platform.execution.impl.local.LocalExecutionService">
 		<property name="edits" ref="workflowModelEdits" />
 		<property name="activityService" ref="activityService" />
 		<property name="dispatchLayerService" ref="dispatchLayerService" />

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-local/src/test/java/org/apache/taverna/platform/execution/impl/local/LocalExecutionTest.java
----------------------------------------------------------------------
diff --git a/taverna-execution-local/src/test/java/org/apache/taverna/platform/execution/impl/local/LocalExecutionTest.java b/taverna-execution-local/src/test/java/org/apache/taverna/platform/execution/impl/local/LocalExecutionTest.java
new file mode 100644
index 0000000..207847d
--- /dev/null
+++ b/taverna-execution-local/src/test/java/org/apache/taverna/platform/execution/impl/local/LocalExecutionTest.java
@@ -0,0 +1,165 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.local;
+
+import java.util.Map;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import org.apache.taverna.platform.report.WorkflowReport;
+
+/**
+ * 
+ * @author David Withers
+ */
+public class LocalExecutionTest {
+	
+	/**
+	 * Test method for {@link uk.org.taverna.platform.execution.impl.local.LocalExecution#start()}.
+	 */
+	@Test
+	@Ignore
+	public void testStart() {
+		// fail("Not yet implemented");
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.execution.impl.local.LocalExecution#pause()}.
+	 */
+	@Test
+	@Ignore
+	public void testPause() {
+		// fail("Not yet implemented");
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.execution.impl.local.LocalExecution#resume()}.
+	 */
+	@Test
+	@Ignore
+	public void testResume() {
+		// fail("Not yet implemented");
+	}
+
+	/**
+	 * Test method for {@link uk.org.taverna.platform.execution.impl.local.LocalExecution#cancel()}.
+	 */
+	@Test
+	@Ignore
+	public void testCancel() {
+		// fail("Not yet implemented");
+	}
+
+	/**
+	 * Test method for
+	 * {@link uk.org.taverna.platform.execution.impl.local.LocalExecution#DataflowExecution(org.apache.taverna.scufl2.api.core.Workflow, java.util.Map, net.sf.taverna.t2.reference.ReferenceService)}
+	 * .
+	 * 
+	 * @throws Exception
+	 */
+	@Test
+	@Ignore
+	public void testDataflowExecution() throws Exception {
+		// URL wfResource = getClass().getResource("/t2flow/in-out.t2flow");
+		// assertNotNull(wfResource);
+		// TavernaResearchObject researchObject = new
+		// T2FlowParser().parseT2Flow(wfResource.openStream());
+		// Workflow workflow = researchObject.getMainWorkflow();
+		// Profile profile = researchObject.getProfiles().iterator().next();
+		//
+		// T2Reference reference = context.getReferenceService().register("test-input", 0, true,
+		// context);
+		// Map<String, T2Reference> inputs = new HashMap<String, T2Reference>();
+		// inputs.put("in", reference);
+		//
+		// DataflowExecution execution = new DataflowExecution(workflow, profile, inputs,
+		// context.getReferenceService());
+		// WorkflowReport report = execution.getWorkflowReport();
+		// assertEquals(State.CREATED, report.getState());
+		// execution.start();
+		//
+		// Map<String, Object> results = execution.getResults();
+		// waitForResult(results, "out", report);
+		//
+		// String result = (String) context.getReferenceService().renderIdentifier((T2Reference)
+		// results.get("out"), String.class, context);
+		// assertEquals("test-input", result);
+		// assertEquals(State.COMPLETED, report.getState());
+		// System.out.println(report);
+	}
+
+	// @Test
+	// // @Ignore
+	// public void testDataflowExecution2() throws Exception {
+	// URL wfResource = getClass().getResource("/t2flow/beanshell.t2flow");
+	// assertNotNull(wfResource);
+	// T2FlowParser t2FlowParser = new T2FlowParser();
+	// t2FlowParser.setStrict(true);
+	// WorkflowBundle researchObject = t2FlowParser.parseT2Flow(wfResource.openStream());
+	// Workflow workflow = researchObject.getMainWorkflow();
+	// Profile profile = researchObject.getProfiles().iterator().next();
+	//
+	// InvocationContext context = null;
+	// T2Reference reference = context.getReferenceService().register("test-input", 0, true,
+	// context);
+	// Map<String, T2Reference> inputs = new HashMap<String, T2Reference>();
+	// inputs.put("in", reference);
+	//
+	// LocalExecution execution = new LocalExecution(workflow, profile, inputs,
+	// context.getReferenceService(), new EditsImpl());
+	// WorkflowReport report = execution.getWorkflowReport();
+	// System.out.println(report);
+	// assertEquals(State.CREATED, report.getState());
+	// execution.start();
+	// System.out.println(report);
+	//
+	// Map<String, Object> results = execution.getResults();
+	// waitForResult(results, "out", report);
+	//
+	// List<String> result = (List<String>) context.getReferenceService().renderIdentifier(
+	// (T2Reference) results.get("out"), String.class, context);
+	// assertEquals(1000, result.size());
+	// assertEquals("test-input:0", result.get(0));
+	// assertEquals(State.COMPLETED, report.getState());
+	// System.out.println(report);
+	// }
+
+	@SuppressWarnings("unused")
+	private void waitForResult(Map<String, Object> results, String port, WorkflowReport report)
+			throws InterruptedException {
+		int wait = 0;
+		while (!results.containsKey(port) && wait++ < 10) {
+			System.out.println(report);
+			Thread.sleep(500);
+		}
+	}
+
+	/**
+	 * Test method for
+	 * {@link uk.org.taverna.platform.execution.impl.local.LocalExecution#resultTokenProduced(net.sf.taverna.t2.invocation.WorkflowDataToken, java.lang.String)}
+	 * .
+	 */
+	@Test
+	public void testResultTokenProduced() {
+		// fail("Not yet implemented");
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-local/src/test/java/uk/org/taverna/platform/execution/impl/local/LocalExecutionTest.java
----------------------------------------------------------------------
diff --git a/taverna-execution-local/src/test/java/uk/org/taverna/platform/execution/impl/local/LocalExecutionTest.java b/taverna-execution-local/src/test/java/uk/org/taverna/platform/execution/impl/local/LocalExecutionTest.java
deleted file mode 100644
index 80b4d65..0000000
--- a/taverna-execution-local/src/test/java/uk/org/taverna/platform/execution/impl/local/LocalExecutionTest.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.impl.local;
-
-import java.util.Map;
-
-import org.junit.Ignore;
-import org.junit.Test;
-
-import uk.org.taverna.platform.report.WorkflowReport;
-
-/**
- * 
- * @author David Withers
- */
-public class LocalExecutionTest {
-	
-	/**
-	 * Test method for {@link uk.org.taverna.platform.execution.impl.local.LocalExecution#start()}.
-	 */
-	@Test
-	@Ignore
-	public void testStart() {
-		// fail("Not yet implemented");
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.execution.impl.local.LocalExecution#pause()}.
-	 */
-	@Test
-	@Ignore
-	public void testPause() {
-		// fail("Not yet implemented");
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.execution.impl.local.LocalExecution#resume()}.
-	 */
-	@Test
-	@Ignore
-	public void testResume() {
-		// fail("Not yet implemented");
-	}
-
-	/**
-	 * Test method for {@link uk.org.taverna.platform.execution.impl.local.LocalExecution#cancel()}.
-	 */
-	@Test
-	@Ignore
-	public void testCancel() {
-		// fail("Not yet implemented");
-	}
-
-	/**
-	 * Test method for
-	 * {@link uk.org.taverna.platform.execution.impl.local.LocalExecution#DataflowExecution(org.apache.taverna.scufl2.api.core.Workflow, java.util.Map, net.sf.taverna.t2.reference.ReferenceService)}
-	 * .
-	 * 
-	 * @throws Exception
-	 */
-	@Test
-	@Ignore
-	public void testDataflowExecution() throws Exception {
-		// URL wfResource = getClass().getResource("/t2flow/in-out.t2flow");
-		// assertNotNull(wfResource);
-		// TavernaResearchObject researchObject = new
-		// T2FlowParser().parseT2Flow(wfResource.openStream());
-		// Workflow workflow = researchObject.getMainWorkflow();
-		// Profile profile = researchObject.getProfiles().iterator().next();
-		//
-		// T2Reference reference = context.getReferenceService().register("test-input", 0, true,
-		// context);
-		// Map<String, T2Reference> inputs = new HashMap<String, T2Reference>();
-		// inputs.put("in", reference);
-		//
-		// DataflowExecution execution = new DataflowExecution(workflow, profile, inputs,
-		// context.getReferenceService());
-		// WorkflowReport report = execution.getWorkflowReport();
-		// assertEquals(State.CREATED, report.getState());
-		// execution.start();
-		//
-		// Map<String, Object> results = execution.getResults();
-		// waitForResult(results, "out", report);
-		//
-		// String result = (String) context.getReferenceService().renderIdentifier((T2Reference)
-		// results.get("out"), String.class, context);
-		// assertEquals("test-input", result);
-		// assertEquals(State.COMPLETED, report.getState());
-		// System.out.println(report);
-	}
-
-	// @Test
-	// // @Ignore
-	// public void testDataflowExecution2() throws Exception {
-	// URL wfResource = getClass().getResource("/t2flow/beanshell.t2flow");
-	// assertNotNull(wfResource);
-	// T2FlowParser t2FlowParser = new T2FlowParser();
-	// t2FlowParser.setStrict(true);
-	// WorkflowBundle researchObject = t2FlowParser.parseT2Flow(wfResource.openStream());
-	// Workflow workflow = researchObject.getMainWorkflow();
-	// Profile profile = researchObject.getProfiles().iterator().next();
-	//
-	// InvocationContext context = null;
-	// T2Reference reference = context.getReferenceService().register("test-input", 0, true,
-	// context);
-	// Map<String, T2Reference> inputs = new HashMap<String, T2Reference>();
-	// inputs.put("in", reference);
-	//
-	// LocalExecution execution = new LocalExecution(workflow, profile, inputs,
-	// context.getReferenceService(), new EditsImpl());
-	// WorkflowReport report = execution.getWorkflowReport();
-	// System.out.println(report);
-	// assertEquals(State.CREATED, report.getState());
-	// execution.start();
-	// System.out.println(report);
-	//
-	// Map<String, Object> results = execution.getResults();
-	// waitForResult(results, "out", report);
-	//
-	// List<String> result = (List<String>) context.getReferenceService().renderIdentifier(
-	// (T2Reference) results.get("out"), String.class, context);
-	// assertEquals(1000, result.size());
-	// assertEquals("test-input:0", result.get(0));
-	// assertEquals(State.COMPLETED, report.getState());
-	// System.out.println(report);
-	// }
-
-	@SuppressWarnings("unused")
-	private void waitForResult(Map<String, Object> results, String port, WorkflowReport report)
-			throws InterruptedException {
-		int wait = 0;
-		while (!results.containsKey(port) && wait++ < 10) {
-			System.out.println(report);
-			Thread.sleep(500);
-		}
-	}
-
-	/**
-	 * Test method for
-	 * {@link uk.org.taverna.platform.execution.impl.local.LocalExecution#resultTokenProduced(net.sf.taverna.t2.invocation.WorkflowDataToken, java.lang.String)}
-	 * .
-	 */
-	@Test
-	public void testResultTokenProduced() {
-		// fail("Not yet implemented");
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-local/src/test/resources/t2flow/beanshell.t2flow
----------------------------------------------------------------------
diff --git a/taverna-execution-local/src/test/resources/t2flow/beanshell.t2flow b/taverna-execution-local/src/test/resources/t2flow/beanshell.t2flow
index 59fa307..e763771 100644
--- a/taverna-execution-local/src/test/resources/t2flow/beanshell.t2flow
+++ b/taverna-execution-local/src/test/resources/t2flow/beanshell.t2flow
@@ -5,7 +5,7 @@
   <localDependencies />
   <artifactDependencies />
   <inputs>
-    <net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean>
+    <org.apache.taverna.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean>
       <handledReferenceSchemes />
       <translatedElementType>java.lang.String</translatedElementType>
       <allowsLiteralValues>true</allowsLiteralValues>
@@ -14,24 +14,24 @@
       <mimeTypes>
         <string>text/plain</string>
       </mimeTypes>
-    </net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean>
+    </org.apache.taverna.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean>
   </inputs>
   <outputs>
-    <net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityOutputPortDefinitionBean>
+    <org.apache.taverna.workflowmodel.processor.activity.config.ActivityOutputPortDefinitionBean>
       <granularDepth>0</granularDepth>
       <name>out</name>
       <depth>0</depth>
       <mimeTypes />
-    </net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityOutputPortDefinitionBean>
+    </org.apache.taverna.workflowmodel.processor.activity.config.ActivityOutputPortDefinitionBean>
   </outputs>
-</net.sf.taverna.t2.activities.beanshell.BeanshellActivityConfigurationBean></configBean><annotations /></activity></activities><dispatchStack><dispatchLayer><raven><group>net.sf.taverna.t2.core</group><artifact>workflowmodel-impl</artifact><version>1.2</version></raven><class>net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.Parallelize</class><configBean encoding="xstream"><net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.ParallelizeConfig xmlns="">
+</org.apache.taverna.activities.beanshell.BeanshellActivityConfigurationBean></configBean><annotations /></activity></activities><dispatchStack><dispatchLayer><raven><group>org.apache.taverna.core</group><artifact>workflowmodel-impl</artifact><version>1.2</version></raven><class>org.apache.taverna.workflowmodel.processor.dispatch.layers.Parallelize</class><configBean encoding="xstream"><org.apache.taverna.workflowmodel.processor.dispatch.layers.ParallelizeConfig xmlns="">
   <maxJobs>1</maxJobs>
-</net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.ParallelizeConfig></configBean></dispatchLayer><dispatchLayer><raven><group>net.sf.taverna.t2.core</group><artifact>workflowmodel-impl</artifact><version>1.2</version></raven><class>net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.ErrorBounce</class><configBean encoding="xstream"><null xmlns="" /></configBean></dispatchLayer><dispatchLayer><raven><group>net.sf.taverna.t2.core</group><artifact>workflowmodel-impl</artifact><version>1.2</version></raven><class>net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.Failover</class><configBean encoding="xstream"><null xmlns="" /></configBean></dispatchLayer><dispatchLayer><raven><group>net.sf.taverna.t2.core</group><artifact>workflowmodel-impl</artifact><version>1.2</version></raven><class>net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.Retry</class><configBean encoding="xstream"><net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.RetryConfig xmlns="
 ">
+</org.apache.taverna.workflowmodel.processor.dispatch.layers.ParallelizeConfig></configBean></dispatchLayer><dispatchLayer><raven><group>org.apache.taverna.core</group><artifact>workflowmodel-impl</artifact><version>1.2</version></raven><class>org.apache.taverna.workflowmodel.processor.dispatch.layers.ErrorBounce</class><configBean encoding="xstream"><null xmlns="" /></configBean></dispatchLayer><dispatchLayer><raven><group>org.apache.taverna.core</group><artifact>workflowmodel-impl</artifact><version>1.2</version></raven><class>org.apache.taverna.workflowmodel.processor.dispatch.layers.Failover</class><configBean encoding="xstream"><null xmlns="" /></configBean></dispatchLayer><dispatchLayer><raven><group>org.apache.taverna.core</group><artifact>workflowmodel-impl</artifact><version>1.2</version></raven><class>org.apache.taverna.workflowmodel.processor.dispatch.layers.Retry</class><configBean encoding="xstream"><org.apache.taverna.workflowmodel.processor.dispatch.layers.RetryConfig
  xmlns="">
   <backoffFactor>1.0</backoffFactor>
   <initialDelay>1000</initialDelay>
   <maxDelay>5000</maxDelay>
   <maxRetries>0</maxRetries>
-</net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.RetryConfig></configBean></dispatchLayer><dispatchLayer><raven><group>net.sf.taverna.t2.core</group><artifact>workflowmodel-impl</artifact><version>1.2</version></raven><class>net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.Invoke</class><configBean encoding="xstream"><null xmlns="" /></configBean></dispatchLayer></dispatchStack><iterationStrategyStack><iteration><strategy><cross><port name="in" depth="0" /></cross></strategy></iteration></iterationStrategyStack></processor><processor><name>ListGenerator</name><inputPorts><port><name>in</name><depth>0</depth></port></inputPorts><outputPorts><port><name>out</name><depth>1</depth><granularDepth>1</granularDepth></port></outputPorts><annotations /><activities><activity><raven><group>net.sf.taverna.t2.activities</group><artifact>beanshell-activity</artifact><version>1.2</version></raven><class>net.sf.taverna.t2.activities.beanshell.BeanshellActivity</class><inputMap><
 map from="in" to="in" /></inputMap><outputMap><map from="out" to="out" /></outputMap><configBean encoding="xstream"><net.sf.taverna.t2.activities.beanshell.BeanshellActivityConfigurationBean xmlns="">
+</org.apache.taverna.workflowmodel.processor.dispatch.layers.RetryConfig></configBean></dispatchLayer><dispatchLayer><raven><group>org.apache.taverna.core</group><artifact>workflowmodel-impl</artifact><version>1.2</version></raven><class>org.apache.taverna.workflowmodel.processor.dispatch.layers.Invoke</class><configBean encoding="xstream"><null xmlns="" /></configBean></dispatchLayer></dispatchStack><iterationStrategyStack><iteration><strategy><cross><port name="in" depth="0" /></cross></strategy></iteration></iterationStrategyStack></processor><processor><name>ListGenerator</name><inputPorts><port><name>in</name><depth>0</depth></port></inputPorts><outputPorts><port><name>out</name><depth>1</depth><granularDepth>1</granularDepth></port></outputPorts><annotations /><activities><activity><raven><group>org.apache.taverna.activities</group><artifact>beanshell-activity</artifact><version>1.2</version></raven><class>org.apache.taverna.activities.beanshell.BeanshellActivity</class><input
 Map><map from="in" to="in" /></inputMap><outputMap><map from="out" to="out" /></outputMap><configBean encoding="xstream"><org.apache.taverna.activities.beanshell.BeanshellActivityConfigurationBean xmlns="">
   <script>out = new ArrayList();
 
 for (int i = 0; i &lt; 1000; i++) {
@@ -42,7 +42,7 @@ for (int i = 0; i &lt; 1000; i++) {
   <localDependencies />
   <artifactDependencies />
   <inputs>
-    <net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean>
+    <org.apache.taverna.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean>
       <handledReferenceSchemes />
       <translatedElementType>java.lang.String</translatedElementType>
       <allowsLiteralValues>true</allowsLiteralValues>
@@ -51,87 +51,87 @@ for (int i = 0; i &lt; 1000; i++) {
       <mimeTypes>
         <string>text/plain</string>
       </mimeTypes>
-    </net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean>
+    </org.apache.taverna.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean>
   </inputs>
   <outputs>
-    <net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityOutputPortDefinitionBean>
+    <org.apache.taverna.workflowmodel.processor.activity.config.ActivityOutputPortDefinitionBean>
       <granularDepth>1</granularDepth>
       <name>out</name>
       <depth>1</depth>
       <mimeTypes />
-    </net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityOutputPortDefinitionBean>
+    </org.apache.taverna.workflowmodel.processor.activity.config.ActivityOutputPortDefinitionBean>
   </outputs>
-</net.sf.taverna.t2.activities.beanshell.BeanshellActivityConfigurationBean></configBean><annotations /></activity></activities><dispatchStack><dispatchLayer><raven><group>net.sf.taverna.t2.core</group><artifact>workflowmodel-impl</artifact><version>1.2</version></raven><class>net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.Parallelize</class><configBean encoding="xstream"><net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.ParallelizeConfig xmlns="">
+</org.apache.taverna.activities.beanshell.BeanshellActivityConfigurationBean></configBean><annotations /></activity></activities><dispatchStack><dispatchLayer><raven><group>org.apache.taverna.core</group><artifact>workflowmodel-impl</artifact><version>1.2</version></raven><class>org.apache.taverna.workflowmodel.processor.dispatch.layers.Parallelize</class><configBean encoding="xstream"><org.apache.taverna.workflowmodel.processor.dispatch.layers.ParallelizeConfig xmlns="">
   <maxJobs>1</maxJobs>
-</net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.ParallelizeConfig></configBean></dispatchLayer><dispatchLayer><raven><group>net.sf.taverna.t2.core</group><artifact>workflowmodel-impl</artifact><version>1.2</version></raven><class>net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.ErrorBounce</class><configBean encoding="xstream"><null xmlns="" /></configBean></dispatchLayer><dispatchLayer><raven><group>net.sf.taverna.t2.core</group><artifact>workflowmodel-impl</artifact><version>1.2</version></raven><class>net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.Failover</class><configBean encoding="xstream"><null xmlns="" /></configBean></dispatchLayer><dispatchLayer><raven><group>net.sf.taverna.t2.core</group><artifact>workflowmodel-impl</artifact><version>1.2</version></raven><class>net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.Retry</class><configBean encoding="xstream"><net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.RetryConfig xmlns="
 ">
+</org.apache.taverna.workflowmodel.processor.dispatch.layers.ParallelizeConfig></configBean></dispatchLayer><dispatchLayer><raven><group>org.apache.taverna.core</group><artifact>workflowmodel-impl</artifact><version>1.2</version></raven><class>org.apache.taverna.workflowmodel.processor.dispatch.layers.ErrorBounce</class><configBean encoding="xstream"><null xmlns="" /></configBean></dispatchLayer><dispatchLayer><raven><group>org.apache.taverna.core</group><artifact>workflowmodel-impl</artifact><version>1.2</version></raven><class>org.apache.taverna.workflowmodel.processor.dispatch.layers.Failover</class><configBean encoding="xstream"><null xmlns="" /></configBean></dispatchLayer><dispatchLayer><raven><group>org.apache.taverna.core</group><artifact>workflowmodel-impl</artifact><version>1.2</version></raven><class>org.apache.taverna.workflowmodel.processor.dispatch.layers.Retry</class><configBean encoding="xstream"><org.apache.taverna.workflowmodel.processor.dispatch.layers.RetryConfig
  xmlns="">
   <backoffFactor>1.0</backoffFactor>
   <initialDelay>1000</initialDelay>
   <maxDelay>5000</maxDelay>
   <maxRetries>0</maxRetries>
-</net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.RetryConfig></configBean></dispatchLayer><dispatchLayer><raven><group>net.sf.taverna.t2.core</group><artifact>workflowmodel-impl</artifact><version>1.2</version></raven><class>net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.Invoke</class><configBean encoding="xstream"><null xmlns="" /></configBean></dispatchLayer></dispatchStack><iterationStrategyStack><iteration><strategy><cross><port name="in" depth="0" /></cross></strategy></iteration></iterationStrategyStack></processor></processors><conditions /><datalinks><datalink><sink type="processor"><processor>Echo</processor><port>in</port></sink><source type="processor"><processor>ListGenerator</processor><port>out</port></source></datalink><datalink><sink type="processor"><processor>ListGenerator</processor><port>in</port></sink><source type="dataflow"><port>in</port></source></datalink><datalink><sink type="dataflow"><port>out</port></sink><source type="processor"><
 processor>Echo</processor><port>out</port></source></datalink></datalinks><annotations><annotation_chain_2_2 encoding="xstream"><net.sf.taverna.t2.annotation.impl.AnnotationChainImpl xmlns="">
+</org.apache.taverna.workflowmodel.processor.dispatch.layers.RetryConfig></configBean></dispatchLayer><dispatchLayer><raven><group>org.apache.taverna.core</group><artifact>workflowmodel-impl</artifact><version>1.2</version></raven><class>org.apache.taverna.workflowmodel.processor.dispatch.layers.Invoke</class><configBean encoding="xstream"><null xmlns="" /></configBean></dispatchLayer></dispatchStack><iterationStrategyStack><iteration><strategy><cross><port name="in" depth="0" /></cross></strategy></iteration></iterationStrategyStack></processor></processors><conditions /><datalinks><datalink><sink type="processor"><processor>Echo</processor><port>in</port></sink><source type="processor"><processor>ListGenerator</processor><port>out</port></source></datalink><datalink><sink type="processor"><processor>ListGenerator</processor><port>in</port></sink><source type="dataflow"><port>in</port></source></datalink><datalink><sink type="dataflow"><port>out</port></sink><source type="processor
 "><processor>Echo</processor><port>out</port></source></datalink></datalinks><annotations><annotation_chain_2_2 encoding="xstream"><org.apache.taverna.annotation.impl.AnnotationChainImpl xmlns="">
   <annotationAssertions>
-    <net.sf.taverna.t2.annotation.impl.AnnotationAssertionImpl>
-      <annotationBean class="net.sf.taverna.t2.annotation.impl.annotationbeans.IdentificationAssertion">
+    <org.apache.taverna.annotation.impl.AnnotationAssertionImpl>
+      <annotationBean class="org.apache.taverna.annotation.impl.annotationbeans.IdentificationAssertion">
         <identification>13c70169-dfaa-4ea6-b6ab-3551dae7fa84</identification>
       </annotationBean>
       <date>2010-08-19 12:28:57.881 BST</date>
       <creators />
       <curationEventList />
-    </net.sf.taverna.t2.annotation.impl.AnnotationAssertionImpl>
+    </org.apache.taverna.annotation.impl.AnnotationAssertionImpl>
   </annotationAssertions>
-</net.sf.taverna.t2.annotation.impl.AnnotationChainImpl></annotation_chain_2_2><annotation_chain_2_2 encoding="xstream"><net.sf.taverna.t2.annotation.impl.AnnotationChainImpl xmlns="">
+</org.apache.taverna.annotation.impl.AnnotationChainImpl></annotation_chain_2_2><annotation_chain_2_2 encoding="xstream"><org.apache.taverna.annotation.impl.AnnotationChainImpl xmlns="">
   <annotationAssertions>
-    <net.sf.taverna.t2.annotation.impl.AnnotationAssertionImpl>
-      <annotationBean class="net.sf.taverna.t2.annotation.impl.annotationbeans.IdentificationAssertion">
+    <org.apache.taverna.annotation.impl.AnnotationAssertionImpl>
+      <annotationBean class="org.apache.taverna.annotation.impl.annotationbeans.IdentificationAssertion">
         <identification>7ef10e93-7376-41a9-9255-552149094142</identification>
       </annotationBean>
       <date>2010-08-31 13:06:57.536 BST</date>
       <creators />
       <curationEventList />
-    </net.sf.taverna.t2.annotation.impl.AnnotationAssertionImpl>
+    </org.apache.taverna.annotation.impl.AnnotationAssertionImpl>
   </annotationAssertions>
-</net.sf.taverna.t2.annotation.impl.AnnotationChainImpl></annotation_chain_2_2><annotation_chain_2_2 encoding="xstream"><net.sf.taverna.t2.annotation.impl.AnnotationChainImpl xmlns="">
+</org.apache.taverna.annotation.impl.AnnotationChainImpl></annotation_chain_2_2><annotation_chain_2_2 encoding="xstream"><org.apache.taverna.annotation.impl.AnnotationChainImpl xmlns="">
   <annotationAssertions>
-    <net.sf.taverna.t2.annotation.impl.AnnotationAssertionImpl>
-      <annotationBean class="net.sf.taverna.t2.annotation.impl.annotationbeans.IdentificationAssertion">
+    <org.apache.taverna.annotation.impl.AnnotationAssertionImpl>
+      <annotationBean class="org.apache.taverna.annotation.impl.annotationbeans.IdentificationAssertion">
         <identification>3b7c0b9c-572d-466b-af6d-0fb40699e8a5</identification>
       </annotationBean>
       <date>2010-08-31 12:50:40.306 BST</date>
       <creators />
       <curationEventList />
-    </net.sf.taverna.t2.annotation.impl.AnnotationAssertionImpl>
+    </org.apache.taverna.annotation.impl.AnnotationAssertionImpl>
   </annotationAssertions>
-</net.sf.taverna.t2.annotation.impl.AnnotationChainImpl></annotation_chain_2_2><annotation_chain_2_2 encoding="xstream"><net.sf.taverna.t2.annotation.impl.AnnotationChainImpl xmlns="">
+</org.apache.taverna.annotation.impl.AnnotationChainImpl></annotation_chain_2_2><annotation_chain_2_2 encoding="xstream"><org.apache.taverna.annotation.impl.AnnotationChainImpl xmlns="">
   <annotationAssertions>
-    <net.sf.taverna.t2.annotation.impl.AnnotationAssertionImpl>
-      <annotationBean class="net.sf.taverna.t2.annotation.impl.annotationbeans.IdentificationAssertion">
+    <org.apache.taverna.annotation.impl.AnnotationAssertionImpl>
+      <annotationBean class="org.apache.taverna.annotation.impl.annotationbeans.IdentificationAssertion">
         <identification>eb6a550d-f34e-4de9-b0fc-1b3df8ab36c4</identification>
       </annotationBean>
       <date>2010-08-31 14:32:44.634 BST</date>
       <creators />
       <curationEventList />
-    </net.sf.taverna.t2.annotation.impl.AnnotationAssertionImpl>
+    </org.apache.taverna.annotation.impl.AnnotationAssertionImpl>
   </annotationAssertions>
-</net.sf.taverna.t2.annotation.impl.AnnotationChainImpl></annotation_chain_2_2><annotation_chain_2_2 encoding="xstream"><net.sf.taverna.t2.annotation.impl.AnnotationChainImpl xmlns="">
+</org.apache.taverna.annotation.impl.AnnotationChainImpl></annotation_chain_2_2><annotation_chain_2_2 encoding="xstream"><org.apache.taverna.annotation.impl.AnnotationChainImpl xmlns="">
   <annotationAssertions>
-    <net.sf.taverna.t2.annotation.impl.AnnotationAssertionImpl>
-      <annotationBean class="net.sf.taverna.t2.annotation.impl.annotationbeans.IdentificationAssertion">
+    <org.apache.taverna.annotation.impl.AnnotationAssertionImpl>
+      <annotationBean class="org.apache.taverna.annotation.impl.annotationbeans.IdentificationAssertion">
         <identification>78cb1427-d57f-42c2-a385-1d20c1580f3b</identification>
       </annotationBean>
       <date>2010-08-31 14:36:00.297 BST</date>
       <creators />
       <curationEventList />
-    </net.sf.taverna.t2.annotation.impl.AnnotationAssertionImpl>
+    </org.apache.taverna.annotation.impl.AnnotationAssertionImpl>
   </annotationAssertions>
-</net.sf.taverna.t2.annotation.impl.AnnotationChainImpl></annotation_chain_2_2><annotation_chain_2_2 encoding="xstream"><net.sf.taverna.t2.annotation.impl.AnnotationChainImpl xmlns="">
+</org.apache.taverna.annotation.impl.AnnotationChainImpl></annotation_chain_2_2><annotation_chain_2_2 encoding="xstream"><org.apache.taverna.annotation.impl.AnnotationChainImpl xmlns="">
   <annotationAssertions>
-    <net.sf.taverna.t2.annotation.impl.AnnotationAssertionImpl>
-      <annotationBean class="net.sf.taverna.t2.annotation.impl.annotationbeans.IdentificationAssertion">
+    <org.apache.taverna.annotation.impl.AnnotationAssertionImpl>
+      <annotationBean class="org.apache.taverna.annotation.impl.annotationbeans.IdentificationAssertion">
         <identification>ad638364-a6e0-4852-abca-9f609c9553d2</identification>
       </annotationBean>
       <date>2010-08-19 13:43:43.797 BST</date>
       <creators />
       <curationEventList />
-    </net.sf.taverna.t2.annotation.impl.AnnotationAssertionImpl>
+    </org.apache.taverna.annotation.impl.AnnotationAssertionImpl>
   </annotationAssertions>
-</net.sf.taverna.t2.annotation.impl.AnnotationChainImpl></annotation_chain_2_2></annotations></dataflow></workflow>
\ No newline at end of file
+</org.apache.taverna.annotation.impl.AnnotationChainImpl></annotation_chain_2_2></annotations></dataflow></workflow>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-local/src/test/resources/t2flow/in-out.t2flow
----------------------------------------------------------------------
diff --git a/taverna-execution-local/src/test/resources/t2flow/in-out.t2flow b/taverna-execution-local/src/test/resources/t2flow/in-out.t2flow
index 8901a8d..fdccdf9 100644
--- a/taverna-execution-local/src/test/resources/t2flow/in-out.t2flow
+++ b/taverna-execution-local/src/test/resources/t2flow/in-out.t2flow
@@ -1,23 +1,23 @@
-<workflow xmlns="http://taverna.sf.net/2008/xml/t2flow" version="1" producedBy="taverna-2.3-SNAPSHOT-20100817"><dataflow id="ad638364-a6e0-4852-abca-9f609c9553d2" role="top"><name>Workflow13</name><inputPorts><port><name>in</name><depth>0</depth><granularDepth>0</granularDepth><annotations /></port></inputPorts><outputPorts><port><name>out</name><annotations /></port></outputPorts><processors /><conditions /><datalinks><datalink><sink type="dataflow"><port>out</port></sink><source type="dataflow"><port>in</port></source></datalink></datalinks><annotations><annotation_chain_2_2 encoding="xstream"><net.sf.taverna.t2.annotation.impl.AnnotationChainImpl xmlns="">
+<workflow xmlns="http://taverna.sf.net/2008/xml/t2flow" version="1" producedBy="taverna-2.3-SNAPSHOT-20100817"><dataflow id="ad638364-a6e0-4852-abca-9f609c9553d2" role="top"><name>Workflow13</name><inputPorts><port><name>in</name><depth>0</depth><granularDepth>0</granularDepth><annotations /></port></inputPorts><outputPorts><port><name>out</name><annotations /></port></outputPorts><processors /><conditions /><datalinks><datalink><sink type="dataflow"><port>out</port></sink><source type="dataflow"><port>in</port></source></datalink></datalinks><annotations><annotation_chain_2_2 encoding="xstream"><org.apache.taverna.annotation.impl.AnnotationChainImpl xmlns="">
   <annotationAssertions>
-    <net.sf.taverna.t2.annotation.impl.AnnotationAssertionImpl>
-      <annotationBean class="net.sf.taverna.t2.annotation.impl.annotationbeans.IdentificationAssertion">
+    <org.apache.taverna.annotation.impl.AnnotationAssertionImpl>
+      <annotationBean class="org.apache.taverna.annotation.impl.annotationbeans.IdentificationAssertion">
         <identification>13c70169-dfaa-4ea6-b6ab-3551dae7fa84</identification>
       </annotationBean>
       <date>2010-08-19 12:28:57.881 BST</date>
       <creators />
       <curationEventList />
-    </net.sf.taverna.t2.annotation.impl.AnnotationAssertionImpl>
+    </org.apache.taverna.annotation.impl.AnnotationAssertionImpl>
   </annotationAssertions>
-</net.sf.taverna.t2.annotation.impl.AnnotationChainImpl></annotation_chain_2_2><annotation_chain_2_2 encoding="xstream"><net.sf.taverna.t2.annotation.impl.AnnotationChainImpl xmlns="">
+</org.apache.taverna.annotation.impl.AnnotationChainImpl></annotation_chain_2_2><annotation_chain_2_2 encoding="xstream"><org.apache.taverna.annotation.impl.AnnotationChainImpl xmlns="">
   <annotationAssertions>
-    <net.sf.taverna.t2.annotation.impl.AnnotationAssertionImpl>
-      <annotationBean class="net.sf.taverna.t2.annotation.impl.annotationbeans.IdentificationAssertion">
+    <org.apache.taverna.annotation.impl.AnnotationAssertionImpl>
+      <annotationBean class="org.apache.taverna.annotation.impl.annotationbeans.IdentificationAssertion">
         <identification>ad638364-a6e0-4852-abca-9f609c9553d2</identification>
       </annotationBean>
       <date>2010-08-19 13:43:43.797 BST</date>
       <creators />
       <curationEventList />
-    </net.sf.taverna.t2.annotation.impl.AnnotationAssertionImpl>
+    </org.apache.taverna.annotation.impl.AnnotationAssertionImpl>
   </annotationAssertions>
-</net.sf.taverna.t2.annotation.impl.AnnotationChainImpl></annotation_chain_2_2></annotations></dataflow></workflow>
\ No newline at end of file
+</org.apache.taverna.annotation.impl.AnnotationChainImpl></annotation_chain_2_2></annotations></dataflow></workflow>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-remote/src/main/java/org/apache/taverna/platform/execution/impl/remote/RemoteExecution.java
----------------------------------------------------------------------
diff --git a/taverna-execution-remote/src/main/java/org/apache/taverna/platform/execution/impl/remote/RemoteExecution.java b/taverna-execution-remote/src/main/java/org/apache/taverna/platform/execution/impl/remote/RemoteExecution.java
new file mode 100644
index 0000000..c40f87f
--- /dev/null
+++ b/taverna-execution-remote/src/main/java/org/apache/taverna/platform/execution/impl/remote/RemoteExecution.java
@@ -0,0 +1,95 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.remote;
+
+import org.apache.taverna.robundle.Bundle;
+
+import org.apache.taverna.platform.execution.api.AbstractExecution;
+import org.apache.taverna.platform.report.ActivityReport;
+import org.apache.taverna.platform.report.ProcessorReport;
+import org.apache.taverna.platform.report.WorkflowReport;
+import org.apache.taverna.scufl2.api.activity.Activity;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.Processor;
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+/**
+ * An {@link org.apache.taverna.platform.execution.api.Execution Execution} for executing a Taverna workflow on a Taverna Server.
+ *
+ * @author David Withers
+ */
+public class RemoteExecution extends AbstractExecution {
+
+	public RemoteExecution(WorkflowBundle workflowBundle, Workflow workflow, Profile profile,
+			Bundle inputs) {
+		super(workflowBundle, workflow, profile, inputs);
+		// TODO Auto-generated constructor stub
+	}
+
+	@Override
+	protected WorkflowReport createWorkflowReport(Workflow workflow) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	protected ProcessorReport createProcessorReport(Processor processor) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	protected ActivityReport createActivityReport(Activity activity) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public void start() {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void pause() {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void resume() {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void cancel() {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void delete() {
+		// TODO Auto-generated method stub
+
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-remote/src/main/java/org/apache/taverna/platform/execution/impl/remote/RemoteExecutionService.java
----------------------------------------------------------------------
diff --git a/taverna-execution-remote/src/main/java/org/apache/taverna/platform/execution/impl/remote/RemoteExecutionService.java b/taverna-execution-remote/src/main/java/org/apache/taverna/platform/execution/impl/remote/RemoteExecutionService.java
new file mode 100644
index 0000000..7e4f143
--- /dev/null
+++ b/taverna-execution-remote/src/main/java/org/apache/taverna/platform/execution/impl/remote/RemoteExecutionService.java
@@ -0,0 +1,59 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.impl.remote;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.apache.taverna.robundle.Bundle;
+
+import org.apache.taverna.platform.execution.api.AbstractExecutionService;
+import org.apache.taverna.platform.execution.api.Execution;
+import org.apache.taverna.platform.execution.api.ExecutionEnvironment;
+import org.apache.taverna.platform.execution.api.InvalidWorkflowException;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+/**
+ * Service for executing Taverna workflows on a Taverna Server.
+ *
+ * @author David Withers
+ */
+public class RemoteExecutionService extends AbstractExecutionService {
+
+	public RemoteExecutionService() {
+		super(RemoteExecutionService.class.getName(), "Taverna Remote Execution Service",
+				"Execution Service for executing Taverna workflows on a Taverna Server");
+	}
+
+	@Override
+	protected Execution createExecutionImpl(WorkflowBundle workflowBundle, Workflow workflow,
+			Profile profile, Bundle inputs)
+			throws InvalidWorkflowException {
+		return new RemoteExecution(workflowBundle, workflow, profile, inputs);
+	}
+
+	@Override
+	public Set<ExecutionEnvironment> getExecutionEnvironments() {
+		return Collections.<ExecutionEnvironment>emptySet();
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-remote/src/main/java/uk/org/taverna/platform/execution/impl/remote/RemoteExecution.java
----------------------------------------------------------------------
diff --git a/taverna-execution-remote/src/main/java/uk/org/taverna/platform/execution/impl/remote/RemoteExecution.java b/taverna-execution-remote/src/main/java/uk/org/taverna/platform/execution/impl/remote/RemoteExecution.java
deleted file mode 100644
index eb33287..0000000
--- a/taverna-execution-remote/src/main/java/uk/org/taverna/platform/execution/impl/remote/RemoteExecution.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.impl.remote;
-
-import org.apache.taverna.robundle.Bundle;
-
-import uk.org.taverna.platform.execution.api.AbstractExecution;
-import uk.org.taverna.platform.report.ActivityReport;
-import uk.org.taverna.platform.report.ProcessorReport;
-import uk.org.taverna.platform.report.WorkflowReport;
-import org.apache.taverna.scufl2.api.activity.Activity;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Processor;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/**
- * An {@link uk.org.taverna.platform.execution.api.Execution Execution} for executing a Taverna workflow on a Taverna Server.
- *
- * @author David Withers
- */
-public class RemoteExecution extends AbstractExecution {
-
-	public RemoteExecution(WorkflowBundle workflowBundle, Workflow workflow, Profile profile,
-			Bundle inputs) {
-		super(workflowBundle, workflow, profile, inputs);
-		// TODO Auto-generated constructor stub
-	}
-
-	@Override
-	protected WorkflowReport createWorkflowReport(Workflow workflow) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	protected ProcessorReport createProcessorReport(Processor processor) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	protected ActivityReport createActivityReport(Activity activity) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public void start() {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void pause() {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void resume() {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void cancel() {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void delete() {
-		// TODO Auto-generated method stub
-
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-remote/src/main/java/uk/org/taverna/platform/execution/impl/remote/RemoteExecutionService.java
----------------------------------------------------------------------
diff --git a/taverna-execution-remote/src/main/java/uk/org/taverna/platform/execution/impl/remote/RemoteExecutionService.java b/taverna-execution-remote/src/main/java/uk/org/taverna/platform/execution/impl/remote/RemoteExecutionService.java
deleted file mode 100644
index 3e4b030..0000000
--- a/taverna-execution-remote/src/main/java/uk/org/taverna/platform/execution/impl/remote/RemoteExecutionService.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.impl.remote;
-
-import java.util.Collections;
-import java.util.Set;
-
-import org.apache.taverna.robundle.Bundle;
-
-import uk.org.taverna.platform.execution.api.AbstractExecutionService;
-import uk.org.taverna.platform.execution.api.Execution;
-import uk.org.taverna.platform.execution.api.ExecutionEnvironment;
-import uk.org.taverna.platform.execution.api.InvalidWorkflowException;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/**
- * Service for executing Taverna workflows on a Taverna Server.
- *
- * @author David Withers
- */
-public class RemoteExecutionService extends AbstractExecutionService {
-
-	public RemoteExecutionService() {
-		super(RemoteExecutionService.class.getName(), "Taverna Remote Execution Service",
-				"Execution Service for executing Taverna workflows on a Taverna Server");
-	}
-
-	@Override
-	protected Execution createExecutionImpl(WorkflowBundle workflowBundle, Workflow workflow,
-			Profile profile, Bundle inputs)
-			throws InvalidWorkflowException {
-		return new RemoteExecution(workflowBundle, workflow, profile, inputs);
-	}
-
-	@Override
-	public Set<ExecutionEnvironment> getExecutionEnvironments() {
-		return Collections.<ExecutionEnvironment>emptySet();
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-remote/src/main/resources/META-INF/spring/execution-remote-context-osgi.xml
----------------------------------------------------------------------
diff --git a/taverna-execution-remote/src/main/resources/META-INF/spring/execution-remote-context-osgi.xml b/taverna-execution-remote/src/main/resources/META-INF/spring/execution-remote-context-osgi.xml
index 2bce13d..974e855 100644
--- a/taverna-execution-remote/src/main/resources/META-INF/spring/execution-remote-context-osgi.xml
+++ b/taverna-execution-remote/src/main/resources/META-INF/spring/execution-remote-context-osgi.xml
@@ -7,6 +7,6 @@
                                  http://www.springframework.org/schema/osgi 
                                  http://www.springframework.org/schema/osgi/spring-osgi.xsd">
 
-    <service ref="remoteExecution" interface="uk.org.taverna.platform.execution.api.ExecutionService" />
+    <service ref="remoteExecution" interface="org.apache.taverna.platform.execution.api.ExecutionService" />
       
 </beans:beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-remote/src/main/resources/META-INF/spring/execution-remote-context.xml
----------------------------------------------------------------------
diff --git a/taverna-execution-remote/src/main/resources/META-INF/spring/execution-remote-context.xml b/taverna-execution-remote/src/main/resources/META-INF/spring/execution-remote-context.xml
index 70f9f9d..1fee78b 100644
--- a/taverna-execution-remote/src/main/resources/META-INF/spring/execution-remote-context.xml
+++ b/taverna-execution-remote/src/main/resources/META-INF/spring/execution-remote-context.xml
@@ -3,6 +3,6 @@
 	xsi:schemaLocation="http://www.springframework.org/schema/beans 
                            http://www.springframework.org/schema/beans/spring-beans.xsd">
 
-	<bean id="remoteExecution" class="uk.org.taverna.platform.execution.impl.remote.RemoteExecutionService" />
+	<bean id="remoteExecution" class="org.apache.taverna.platform.execution.impl.remote.RemoteExecutionService" />
 
 </beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-observer/src/main/java/net/sf/taverna/t2/lang/observer/MultiCaster.java
----------------------------------------------------------------------
diff --git a/taverna-observer/src/main/java/net/sf/taverna/t2/lang/observer/MultiCaster.java b/taverna-observer/src/main/java/net/sf/taverna/t2/lang/observer/MultiCaster.java
deleted file mode 100644
index d563e39..0000000
--- a/taverna-observer/src/main/java/net/sf/taverna/t2/lang/observer/MultiCaster.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.lang.observer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-/**
- * Send notifications to registered observers about changes to models
- * 
- * @author Ian Dunlop
- * @author Stian Soiland
- * 
- * @param <Message>
- */
-public class MultiCaster<Message> implements Observable<Message> {
-
-	private static Logger logger = Logger.getLogger(MultiCaster.class);
-
-	private Observable<Message> observable;
-
-	protected List<Observer<Message>> observers = new ArrayList<Observer<Message>>();
-
-	/**
-	 * Set the {@link #observable} ie. the class that changes are happening to
-	 * and it's Message for this {@link MultiCaster}
-	 * 
-	 * @param observable
-	 */
-	public MultiCaster(Observable<Message> observable) {
-		this.observable = observable;
-	}
-
-	/**
-	 * Tell all the registered observers about the change to the model
-	 * 
-	 * @param message
-	 */
-	@SuppressWarnings("unchecked")
-	public void notify(Message message) {
-		// Use a copy that can be iterated even if register/remove is called
-		for (Observer<Message> observer : getObservers()) {
-			try {
-				observer.notify(observable, message);
-			} catch (Exception ex) {
-				logger.warn("Could not notify " + observer, ex);
-			}
-		}
-	}
-
-	/**
-	 * Register an observer ie. someone who wants informed about changes
-	 */
-	public synchronized void addObserver(Observer<Message> observer) {
-		observers.add(observer);
-	}
-
-	/**
-	 * Remove the observer and no longer send out any notifications about it
-	 */
-	public synchronized void removeObserver(Observer<Message> observer) {
-		observers.remove(observer);
-	}
-
-	/**
-	 * A list of all the classes currently registered with this
-	 * {@link MultiCaster}
-	 */
-	public synchronized List<Observer<Message>> getObservers() {
-		return new ArrayList<Observer<Message>>(observers);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-observer/src/main/java/net/sf/taverna/t2/lang/observer/Observable.java
----------------------------------------------------------------------
diff --git a/taverna-observer/src/main/java/net/sf/taverna/t2/lang/observer/Observable.java b/taverna-observer/src/main/java/net/sf/taverna/t2/lang/observer/Observable.java
deleted file mode 100644
index 1fa7425..0000000
--- a/taverna-observer/src/main/java/net/sf/taverna/t2/lang/observer/Observable.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.lang.observer;
-
-import java.util.List;
-
-/**
- * Implements this if you want to notify other classes about changes
- * 
- * @author Ian Dunlop
- * @author Stian Soiland
- * 
- * @param <Message>
- */
-public interface Observable<Message> {
-	/**
-	 * Register an {@link Observer}
-	 * 
-	 * @param observer
-	 *            the class who wants notified of changes
-	 */
-	public void addObserver(Observer<Message> observer);
-
-	/**
-	 * Remove a class who is currently observing
-	 * 
-	 * @param observer
-	 *            the class who no longer wants notified
-	 */
-	public void removeObserver(Observer<Message> observer);
-
-	/**
-	 * A list of all the currently registered {@link Observer}s
-	 * 
-	 * @return
-	 */
-	public List<Observer<Message>> getObservers();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-observer/src/main/java/net/sf/taverna/t2/lang/observer/Observer.java
----------------------------------------------------------------------
diff --git a/taverna-observer/src/main/java/net/sf/taverna/t2/lang/observer/Observer.java b/taverna-observer/src/main/java/net/sf/taverna/t2/lang/observer/Observer.java
deleted file mode 100644
index 81b7c85..0000000
--- a/taverna-observer/src/main/java/net/sf/taverna/t2/lang/observer/Observer.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.lang.observer;
-
-/**
- * Implement if you want to register with an {@link Observable}
- * 
- * @author Ian Dunlop
- * @author Stian Soiland
- * 
- * @param <Message>
- */
-public interface Observer<Message> {
-	/**
-	 * Called by the {@link Observable} to notify the implementing class of
-	 * changes
-	 * 
-	 * @param sender
-	 *            the class where the changes have happened
-	 * @param message
-	 *            what has changed
-	 * @throws Exception
-	 */
-	public void notify(Observable<Message> sender, Message message)
-			throws Exception;
-}


[38/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/HibernateListDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/HibernateListDao.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/HibernateListDao.java
deleted file mode 100644
index 62ba83f..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/HibernateListDao.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import static net.sf.taverna.t2.reference.T2ReferenceType.IdentifiedList;
-
-import java.util.List;
-
-import net.sf.taverna.t2.reference.DaoException;
-import net.sf.taverna.t2.reference.IdentifiedList;
-import net.sf.taverna.t2.reference.ListDao;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.annotations.DeleteIdentifiedOperation;
-import net.sf.taverna.t2.reference.annotations.GetIdentifiedOperation;
-import net.sf.taverna.t2.reference.annotations.PutIdentifiedOperation;
-
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
-
-/**
- * An implementation of ListDao based on Spring's HibernateDaoSupport. To use
- * this in spring inject a property 'sessionFactory' with either a
- * {@link org.springframework.orm.hibernate3.LocalSessionFactoryBean
- * LocalSessionFactoryBean} or the equivalent class from the T2Platform module
- * to add SPI based implementation discovery and mapping. To use outside of
- * Spring ensure you call the setSessionFactory(..) method before using this
- * (but really, use it from Spring, so much easier).
- * 
- * @author Tom Oinn
- */
-public class HibernateListDao extends HibernateDaoSupport implements ListDao {
-	private static final String GET_LISTS_FOR_RUN = "FROM T2ReferenceListImpl WHERE namespacePart = :workflow_run_id";
-
-	/**
-	 * Fetch a t2reference list by id
-	 * 
-	 * @param ref
-	 *            the T2Reference to fetch
-	 * @return a retrieved identified list of T2 references
-	 * @throws DaoException
-	 *             if the supplied reference is of the wrong type or if
-	 *             something goes wrong fetching the data or connecting to the
-	 *             database
-	 */
-	@Override
-	@GetIdentifiedOperation
-	public IdentifiedList<T2Reference> get(T2Reference ref) throws DaoException {
-		if (ref == null)
-			throw new DaoException(
-					"Supplied reference is null, can't retrieve.");
-		if (!ref.getReferenceType().equals(IdentifiedList))
-			throw new DaoException(
-					"This dao can only retrieve reference of type T2Reference.IdentifiedList");
-		if (!(ref instanceof T2ReferenceImpl))
-			throw new DaoException(
-					"Reference must be an instance of T2ReferenceImpl");
-
-		try {
-			return (T2ReferenceListImpl) getHibernateTemplate().get(
-					T2ReferenceListImpl.class,
-					((T2ReferenceImpl) ref).getCompactForm());
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-
-	@Override
-	@PutIdentifiedOperation
-	public void store(IdentifiedList<T2Reference> theList) throws DaoException {
-		if (theList.getId() == null)
-			throw new DaoException("Supplied list set has a null ID, allocate "
-					+ "an ID before calling the store method in the dao.");
-		if (!theList.getId().getReferenceType().equals(IdentifiedList))
-			throw new DaoException("Strangely the list ID doesn't have type "
-					+ "T2ReferenceType.IdentifiedList, something has probably "
-					+ "gone badly wrong somewhere earlier!");
-		if (!(theList instanceof T2ReferenceListImpl))
-			throw new DaoException(
-					"Supplied identifier list not an instance of T2ReferenceList");
-
-		try {
-			getHibernateTemplate().save(theList);
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-
-	@Override
-	public boolean delete(IdentifiedList<T2Reference> theList)
-			throws DaoException {
-		if (theList.getId() == null)
-			throw new DaoException("Supplied list set has a null ID, allocate "
-					+ "an ID before calling the store method in the dao.");
-		if (!theList.getId().getReferenceType().equals(IdentifiedList))
-			throw new DaoException("Strangely the list ID doesn't have type "
-					+ "T2ReferenceType.IdentifiedList, something has probably "
-					+ "gone badly wrong somewhere earlier!");
-		if (!(theList instanceof T2ReferenceListImpl))
-			throw new DaoException(
-					"Supplied identifier list not an instance of T2ReferenceList");
-
-		try {
-			getHibernateTemplate().delete(theList);
-			return true;
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-
-	@Override
-	@SuppressWarnings("unchecked")
-	@DeleteIdentifiedOperation
-	public synchronized void deleteIdentifiedListsForWFRun(String workflowRunId)
-			throws DaoException {
-		try {
-			// Select all T2Reference lists for this wf run
-			Session session = getSession();
-			Query selectQuery = session.createQuery(GET_LISTS_FOR_RUN);
-			selectQuery.setString("workflow_run_id", workflowRunId);
-			List<IdentifiedList<T2Reference>> identifiedLists = selectQuery
-					.list();
-			session.close();
-			/*
-			 * need to close before we do delete otherwise hibernate complains
-			 * that two sessions are accessing collection
-			 */
-			getHibernateTemplate().deleteAll(identifiedLists);
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/HibernateReferenceSetDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/HibernateReferenceSetDao.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/HibernateReferenceSetDao.java
deleted file mode 100644
index 06791a6..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/HibernateReferenceSetDao.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import static net.sf.taverna.t2.reference.T2ReferenceType.ReferenceSet;
-
-import java.util.List;
-
-import net.sf.taverna.t2.reference.DaoException;
-import net.sf.taverna.t2.reference.ReferenceSet;
-import net.sf.taverna.t2.reference.ReferenceSetDao;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.annotations.DeleteIdentifiedOperation;
-import net.sf.taverna.t2.reference.annotations.GetIdentifiedOperation;
-import net.sf.taverna.t2.reference.annotations.PutIdentifiedOperation;
-
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
-
-/**
- * An implementation of ReferenceSetDao based on Spring's HibernateDaoSupport.
- * To use this in spring inject a property 'sessionFactory' with either a
- * {@link org.springframework.orm.hibernate3.LocalSessionFactoryBean
- * LocalSessionFactoryBean} or the equivalent class from the T2Platform module
- * to add SPI based implementation discovery and mapping. To use outside of
- * Spring ensure you call the setSessionFactory(..) method before using this
- * (but really, use it from Spring, so much easier).
- * 
- * @author Tom Oinn
- */
-public class HibernateReferenceSetDao extends HibernateDaoSupport implements
-		ReferenceSetDao {
-	private static final String GET_REFSETS_FOR_RUN = "FROM ReferenceSetImpl WHERE namespacePart = :workflow_run_id";
-
-	/**
-	 * Store the specified new reference set
-	 * 
-	 * @param rs
-	 *            a reference set, must not already exist in the database.
-	 * @throws DaoException
-	 *             if the entry already exists in the database, if the supplied
-	 *             reference set isn't an instance of ReferenceSetImpl or if
-	 *             something else goes wrong connecting to the database
-	 */
-	@Override
-	@PutIdentifiedOperation
-	public void store(ReferenceSet rs) throws DaoException {
-		if (rs.getId() == null)
-			throw new DaoException(
-					"Supplied reference set has a null ID, allocate "
-							+ "an ID before calling the store method in the dao.");
-		if (!rs.getId().getReferenceType().equals(ReferenceSet))
-			throw new DaoException(
-					"Strangely the reference set ID doesn't have type "
-							+ "T2ReferenceType.ReferenceSet, something has probably "
-							+ "gone badly wrong somewhere earlier!");
-		if (!(rs instanceof ReferenceSetImpl))
-			throw new DaoException(
-					"Supplied reference set not an instance of ReferenceSetImpl");
-
-		try {
-			getHibernateTemplate().save(rs);
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-
-	/**
-	 * Update a pre-existing entry in the database
-	 * 
-	 * @param rs
-	 *            the reference set to update. This must already exist in the
-	 *            database
-	 * @throws DaoException
-	 */
-	@Override
-	@PutIdentifiedOperation
-	public void update(ReferenceSet rs) throws DaoException {
-		if (rs.getId() == null)
-			throw new DaoException(
-					"Supplied reference set has a null ID, allocate "
-							+ "an ID before calling the store method in the dao.");
-		if (!rs.getId().getReferenceType().equals(ReferenceSet))
-			throw new DaoException(
-					"Strangely the reference set ID doesn't have type "
-							+ "T2ReferenceType.ReferenceSet, something has probably "
-							+ "gone badly wrong somewhere earlier!");
-		if (!(rs instanceof ReferenceSetImpl))
-			throw new DaoException(
-					"Supplied reference set not an instance of ReferenceSetImpl");
-
-		try {
-			getHibernateTemplate().update(rs);
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-
-	/**
-	 * Fetch a reference set by id
-	 * 
-	 * @param ref
-	 *            the ReferenceSetT2ReferenceImpl to fetch
-	 * @return a retrieved ReferenceSetImpl
-	 * @throws DaoException
-	 *             if the supplied reference is of the wrong type or if
-	 *             something goes wrong fetching the data or connecting to the
-	 *             database
-	 */
-	@Override
-	@GetIdentifiedOperation
-	public ReferenceSetImpl get(T2Reference ref) throws DaoException {
-		if (ref == null)
-			throw new DaoException(
-					"Supplied reference is null, can't retrieve.");
-		if (!ref.getReferenceType().equals(ReferenceSet))
-			throw new DaoException(
-					"This dao can only retrieve reference of type T2Reference.ReferenceSet");
-		if (!(ref instanceof T2ReferenceImpl))
-			throw new DaoException(
-					"Reference must be an instance of T2ReferenceImpl");
-
-		try {
-			return (ReferenceSetImpl) getHibernateTemplate().get(
-					ReferenceSetImpl.class,
-					((T2ReferenceImpl) ref).getCompactForm());
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-
-	@Override
-	@DeleteIdentifiedOperation
-	public boolean delete(ReferenceSet rs) throws DaoException {
-		if (rs.getId() == null)
-			throw new DaoException(
-					"Supplied reference set has a null ID, allocate "
-							+ "an ID before calling the store method in the dao.");
-		if (!rs.getId().getReferenceType().equals(ReferenceSet))
-			throw new DaoException(
-					"Strangely the reference set ID doesn't have type "
-							+ "T2ReferenceType.ReferenceSet, something has probably "
-							+ "gone badly wrong somewhere earlier!");
-		if (!(rs instanceof ReferenceSetImpl))
-			throw new DaoException(
-					"Supplied reference set not an instance of ReferenceSetImpl");
-
-		try {
-			getHibernateTemplate().delete(rs);
-			return true;
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-
-	@Override
-	@SuppressWarnings("unchecked")
-	@DeleteIdentifiedOperation
-	public synchronized void deleteReferenceSetsForWFRun(String workflowRunId)
-			throws DaoException {
-		try {
-			// Select all ReferenceSets for this wf run
-			Session session = getSession();
-			Query selectQuery = session
-					.createQuery(GET_REFSETS_FOR_RUN);
-			selectQuery.setString("workflow_run_id", workflowRunId);
-			List<ReferenceSet> referenceSets = selectQuery.list();
-			session.close();
-			/*
-			 * need to close before we do delete otherwise hibernate complains
-			 * that two sessions are accessing collection
-			 */
-			getHibernateTemplate().deleteAll(referenceSets);
-		} catch (Exception ex) {
-			throw new DaoException(ex);
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/IdentifiedArrayList.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/IdentifiedArrayList.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/IdentifiedArrayList.java
deleted file mode 100644
index e1bbe5c..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/IdentifiedArrayList.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import net.sf.taverna.t2.reference.IdentifiedList;
-
-/**
- * Implementation of IdentifiedList which delegates to an ArrayList for its
- * storage functionality.
- * 
- * @author Tom Oinn
- * 
- * @param <T>
- */
-public class IdentifiedArrayList<T> extends AbstractEntityImpl implements
-		IdentifiedList<T> {
-	protected List<T> listDelegate = null;
-
-	// Constructors copied from ArrayList for convenience
-	public IdentifiedArrayList() {
-		super();
-		this.listDelegate = new ArrayList<>();
-	}
-
-	public IdentifiedArrayList(Collection<T> c) {
-		super();
-		this.listDelegate = new ArrayList<>(c);
-	}
-
-	public IdentifiedArrayList(int initialCapacity) {
-		super();
-		this.listDelegate = new ArrayList<>(initialCapacity);
-	}
-
-	private void checkUndefinedId() {
-		if (this.getId() != null)
-			throw new IllegalStateException(
-					"Attempt made to modify a list which has already been named");
-	}
-
-	@Override
-	public boolean add(T e) {
-		checkUndefinedId();
-		return listDelegate.add(e);
-	}
-
-	@Override
-	public void add(int index, T element) {
-		checkUndefinedId();
-		listDelegate.add(index, element);
-	}
-
-	@Override
-	public boolean addAll(Collection<? extends T> c) {
-		checkUndefinedId();
-		return listDelegate.addAll(c);
-	}
-
-	@Override
-	public boolean addAll(int index, Collection<? extends T> c) {
-		checkUndefinedId();
-		return listDelegate.addAll(index, c);
-	}
-
-	@Override
-	public void clear() {
-		checkUndefinedId();
-		listDelegate.clear();
-	}
-
-	@Override
-	public boolean contains(Object o) {
-		return listDelegate.contains(o);
-	}
-
-	@Override
-	public boolean containsAll(Collection<?> c) {
-		return listDelegate.containsAll(c);
-	}
-
-	@Override
-	public T get(int index) {
-		return listDelegate.get(index);
-	}
-
-	@Override
-	public int indexOf(Object o) {
-		return listDelegate.indexOf(o);
-	}
-
-	@Override
-	public boolean isEmpty() {
-		return listDelegate.isEmpty();
-	}
-
-	@Override
-	public Iterator<T> iterator() {
-		return listDelegate.iterator();
-	}
-
-	@Override
-	public int lastIndexOf(Object o) {
-		return listDelegate.lastIndexOf(o);
-	}
-
-	/**
-	 * The ListIterator can modify the list contents, so wrap the delegate's
-	 * list iterator and use as a delegate itself, checking for null ID on
-	 * operations which set list properties.
-	 * 
-	 * @param iteratorDelegate
-	 *            ListIterator to wrap.
-	 * @return wrapped ListIterator which throws IllegalStateException on calls
-	 *         which modify the list if the ID has been set to a non-null value
-	 */
-	private ListIterator<T> getCheckedListIterator(
-			final ListIterator<T> iteratorDelegate) {
-		return new ListIterator<T>() {
-			@Override
-			public void add(T e) {
-				checkUndefinedId();
-				iteratorDelegate.add(e);
-			}
-
-			@Override
-			public boolean hasNext() {
-				return iteratorDelegate.hasNext();
-			}
-
-			@Override
-			public boolean hasPrevious() {
-				return iteratorDelegate.hasPrevious();
-			}
-
-			@Override
-			public T next() {
-				return iteratorDelegate.next();
-			}
-
-			@Override
-			public int nextIndex() {
-				return iteratorDelegate.nextIndex();
-			}
-
-			@Override
-			public T previous() {
-				return iteratorDelegate.previous();
-			}
-
-			@Override
-			public int previousIndex() {
-				return iteratorDelegate.previousIndex();
-			}
-
-			@Override
-			public void remove() {
-				checkUndefinedId();
-				iteratorDelegate.remove();
-			}
-
-			@Override
-			public void set(T e) {
-				checkUndefinedId();
-				iteratorDelegate.set(e);
-			}
-		};
-	}
-
-	@Override
-	public ListIterator<T> listIterator() {
-		return getCheckedListIterator(listDelegate.listIterator());
-	}
-
-	@Override
-	public ListIterator<T> listIterator(int index) {
-		return getCheckedListIterator(listDelegate.listIterator(index));
-	}
-
-	@Override
-	public boolean remove(Object o) {
-		checkUndefinedId();
-		return listDelegate.remove(o);
-	}
-
-	@Override
-	public T remove(int index) {
-		checkUndefinedId();
-		return listDelegate.remove(index);
-	}
-
-	@Override
-	public boolean removeAll(Collection<?> c) {
-		checkUndefinedId();
-		return listDelegate.removeAll(c);
-	}
-
-	@Override
-	public boolean retainAll(Collection<?> c) {
-		checkUndefinedId();
-		return listDelegate.retainAll(c);
-	}
-
-	@Override
-	public T set(int index, T element) {
-		checkUndefinedId();
-		return listDelegate.set(index, element);
-	}
-
-	@Override
-	public int size() {
-		return listDelegate.size();
-	}
-
-	@Override
-	public List<T> subList(int fromIndex, int toIndex) {
-		return listDelegate.subList(fromIndex, toIndex);
-	}
-
-	@Override
-	public Object[] toArray() {
-		return listDelegate.toArray();
-	}
-
-	@Override
-	public <U> U[] toArray(U[] a) {
-		return listDelegate.toArray(a);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/InMemoryErrorDocumentDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/InMemoryErrorDocumentDao.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/InMemoryErrorDocumentDao.java
deleted file mode 100644
index cb431d6..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/InMemoryErrorDocumentDao.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import net.sf.taverna.t2.reference.DaoException;
-import net.sf.taverna.t2.reference.ErrorDocument;
-import net.sf.taverna.t2.reference.ErrorDocumentDao;
-import net.sf.taverna.t2.reference.T2Reference;
-
-/**
- * A trivial in-memory implementation of ErrorDocumentDao for either testing or
- * very lightweight embedded systems. Uses a java Map as the backing store.
- * 
- * @author Tom Oinn
- */
-public class InMemoryErrorDocumentDao implements ErrorDocumentDao {
-	private Map<T2Reference, ErrorDocument> store;
-
-	public InMemoryErrorDocumentDao() {
-		this.store = new ConcurrentHashMap<>();
-	}
-
-	@Override
-	public synchronized ErrorDocument get(T2Reference reference)
-			throws DaoException {
-		return store.get(reference);
-	}
-
-	@Override
-	public synchronized void store(ErrorDocument theDoc) throws DaoException {
-		store.put(theDoc.getId(), theDoc);
-	}
-
-	@Override
-	public synchronized boolean delete(ErrorDocument theDoc)
-			throws DaoException {
-		return store.remove(theDoc.getId()) != null;
-	}
-
-	@Override
-	public synchronized void deleteErrorDocumentsForWFRun(String workflowRunId)
-			throws DaoException {
-		for (T2Reference reference : store.keySet())
-			if (reference.getNamespacePart().equals(workflowRunId))
-				store.remove(reference);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/InMemoryListDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/InMemoryListDao.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/InMemoryListDao.java
deleted file mode 100644
index 112bf80..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/InMemoryListDao.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import net.sf.taverna.t2.reference.DaoException;
-import net.sf.taverna.t2.reference.IdentifiedList;
-import net.sf.taverna.t2.reference.ListDao;
-import net.sf.taverna.t2.reference.T2Reference;
-
-/**
- * A trivial in-memory implementation of ListDao for either testing or very
- * lightweight embedded systems. Uses a java Map as the backing store.
- * 
- * @author Tom Oinn
- */
-public class InMemoryListDao implements ListDao {
-	private Map<T2Reference, IdentifiedList<T2Reference>> store;
-
-	public InMemoryListDao() {
-		this.store = new ConcurrentHashMap<>();
-	}
-
-	@Override
-	public synchronized IdentifiedList<T2Reference> get(T2Reference reference)
-			throws DaoException {
-		return store.get(reference);
-	}
-
-	@Override
-	public synchronized void store(IdentifiedList<T2Reference> theList)
-			throws DaoException {
-		store.put(theList.getId(), theList);
-	}
-
-	@Override
-	public boolean delete(IdentifiedList<T2Reference> theList)
-			throws DaoException {
-		return (store.remove(theList.getId()) != null);
-	}
-
-	@Override
-	public synchronized void deleteIdentifiedListsForWFRun(String workflowRunId)
-			throws DaoException {
-		for (T2Reference reference : store.keySet())
-			if (reference.getNamespacePart().equals(workflowRunId))
-				store.remove(reference);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/InMemoryReferenceSetDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/InMemoryReferenceSetDao.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/InMemoryReferenceSetDao.java
deleted file mode 100644
index 6d00337..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/InMemoryReferenceSetDao.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import net.sf.taverna.t2.reference.DaoException;
-import net.sf.taverna.t2.reference.ReferenceSet;
-import net.sf.taverna.t2.reference.ReferenceSetDao;
-import net.sf.taverna.t2.reference.T2Reference;
-
-/**
- * A trivial in-memory implementation of ReferenceSetDao for either testing or
- * very lightweight embedded systems. Uses a java Map as the backing store.
- * 
- * @author Tom Oinn
- */
-public class InMemoryReferenceSetDao implements ReferenceSetDao {
-	private Map<T2Reference, ReferenceSet> store;
-
-	public InMemoryReferenceSetDao() {
-		this.store = new ConcurrentHashMap<>();
-	}
-
-	@Override
-	public synchronized ReferenceSet get(T2Reference reference)
-			throws DaoException {
-		return store.get(reference);
-	}
-
-	@Override
-	public synchronized void store(ReferenceSet refSet) throws DaoException {
-		store.put(refSet.getId(), refSet);
-	}
-
-	@Override
-	public synchronized void update(ReferenceSet refSet) throws DaoException {
-		store.put(refSet.getId(), refSet);
-	}
-
-	@Override
-	public synchronized boolean delete(ReferenceSet refSet) throws DaoException {
-		return store.remove(refSet.getId()) != null;
-	}
-
-	@Override
-	public synchronized void deleteReferenceSetsForWFRun(String workflowRunId)
-			throws DaoException {
-		for (T2Reference reference : store.keySet())
-			if (reference.getNamespacePart().equals(workflowRunId))
-				store.remove(reference);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ListServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ListServiceImpl.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ListServiceImpl.java
deleted file mode 100644
index 76c219a..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ListServiceImpl.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import static net.sf.taverna.t2.reference.impl.T2ReferenceImpl.getAsImpl;
-
-import java.util.List;
-
-import net.sf.taverna.t2.reference.DaoException;
-import net.sf.taverna.t2.reference.IdentifiedList;
-import net.sf.taverna.t2.reference.ListService;
-import net.sf.taverna.t2.reference.ListServiceException;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferenceServiceException;
-import net.sf.taverna.t2.reference.T2Reference;
-
-/**
- * Implementation of ListService, inject with an appropriate ListDao and
- * T2ReferenceGenerator to enable.
- * 
- * @author Tom Oinn
- */
-public class ListServiceImpl extends AbstractListServiceImpl implements
-		ListService {
-	@Override
-	public IdentifiedList<T2Reference> getList(T2Reference id)
-			throws ListServiceException {
-		checkDao();
-		try {
-			return listDao.get(id);
-		} catch (DaoException de) {
-			throw new ListServiceException(de);
-		}
-	}
-
-	@Override
-	public IdentifiedList<T2Reference> registerEmptyList(int depth,
-			ReferenceContext context) throws ListServiceException {
-		if (depth < 1)
-			throw new ListServiceException(
-					"Can't register empty lists of depth " + depth);
-		checkDao();
-		checkGenerator();
-		T2ReferenceImpl newReference = getAsImpl(t2ReferenceGenerator
-				.nextListReference(false, depth, context));
-		T2ReferenceListImpl newList = new T2ReferenceListImpl();
-		newList.setTypedId(newReference);
-		try {
-			listDao.store(newList);
-			return newList;
-		} catch (DaoException de) {
-			throw new ListServiceException(de);
-		}
-	}
-
-	@Override
-	public IdentifiedList<T2Reference> registerList(List<T2Reference> items,
-			ReferenceContext context) throws ListServiceException {
-		checkDao();
-		checkGenerator();
-		if (items.isEmpty())
-			throw new ListServiceException(
-					"Can't register an empty list with this method,"
-							+ " use the registerEmptyList instead");
-		/*
-		 * Track whether there are any items in the collection which are or
-		 * contain error documents.
-		 */
-		boolean containsErrors = false;
-		// Track depth, ensure that all items have the same depth, fail if not.
-		int depth = items.get(0).getDepth();
-		if (depth < 0)
-			throw new ListServiceException(
-					"Can't register list of depth less than 1, but first item "
-							+ items.get(0) + " has depth " + depth);
-		T2ReferenceListImpl newList = new T2ReferenceListImpl();
-		int counter = 0;
-		for (T2Reference ref : items) {
-			if (ref.getDepth() != depth)
-				throw new ListServiceException(
-						"Mismatched depths in list registration; reference at index '"
-								+ counter + "' has depth " + ref.getDepth()
-								+ " but all preceeding items have depth "
-								+ depth);
-			if (ref.containsErrors())
-				// The collection's reference contains errors if any child does
-				containsErrors = true;
-			newList.add(ref);
-			counter++;
-		}
-		try {
-			T2ReferenceImpl newReference = getAsImpl(t2ReferenceGenerator
-					.nextListReference(containsErrors, depth + 1, context));
-			newList.setTypedId(newReference);
-			listDao.store(newList);
-			return newList;
-		} catch (Throwable t) {
-			throw new ListServiceException(t);
-		}
-	}
-
-	@Override
-	public boolean delete(T2Reference reference)
-			throws ReferenceServiceException {
-		checkDao();
-		IdentifiedList<T2Reference> list = listDao.get(reference);
-		if (list == null)
-			return false;
-		return listDao.delete(list);
-	}
-
-	@Override
-	public void deleteIdentifiedListsForWorkflowRun(String workflowRunId)
-			throws ReferenceServiceException {
-		checkDao();
-		listDao.deleteIdentifiedListsForWFRun(workflowRunId);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ReferenceServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ReferenceServiceImpl.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ReferenceServiceImpl.java
deleted file mode 100644
index 6dc3df4..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ReferenceServiceImpl.java
+++ /dev/null
@@ -1,731 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import static java.lang.Float.MAX_VALUE;
-import static net.sf.taverna.t2.reference.T2ReferenceType.ErrorDocument;
-import static net.sf.taverna.t2.reference.T2ReferenceType.IdentifiedList;
-import static net.sf.taverna.t2.reference.T2ReferenceType.ReferenceSet;
-import static net.sf.taverna.t2.reference.impl.T2ReferenceImpl.getAsImpl;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import net.sf.taverna.t2.reference.ContextualizedT2Reference;
-import net.sf.taverna.t2.reference.ErrorDocument;
-import net.sf.taverna.t2.reference.ErrorDocumentServiceException;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.Identified;
-import net.sf.taverna.t2.reference.IdentifiedList;
-import net.sf.taverna.t2.reference.ListServiceException;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferenceService;
-import net.sf.taverna.t2.reference.ReferenceServiceException;
-import net.sf.taverna.t2.reference.ReferenceSet;
-import net.sf.taverna.t2.reference.ReferenceSetServiceException;
-import net.sf.taverna.t2.reference.StreamToValueConverterSPI;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.ValueCarryingExternalReference;
-import net.sf.taverna.t2.reference.ValueToReferenceConversionException;
-import net.sf.taverna.t2.reference.ValueToReferenceConverterSPI;
-
-import org.apache.log4j.Logger;
-
-/**
- * Implementation of ReferenceService, inject with ReferenceSetService,
- * ErrorDocumentService and ListService to enable.
- * 
- * @author Tom Oinn
- * @author Alan R Williams
- * @author Stuart Owen
- * @author Stian Soiland-Reyes
- */
-public class ReferenceServiceImpl extends AbstractReferenceServiceImpl
-		implements ReferenceService {
-	private final Logger log = Logger.getLogger(ReferenceServiceImpl.class);
-
-	/**
-	 * The top level registration method is used to register either as yet
-	 * unregistered ErrorDocuments and ReferenceSets (if these are passed in and
-	 * already have an identifier this call does nothing) and arbitrarily nested
-	 * Lists of the same. In addition any ExternalReferenceSPI instances found
-	 * will be wrapped in a single item ReferenceSet and registered, and any
-	 * Throwables will be wrapped in an ErrorDocument and registered. Lists will
-	 * be converted to IdentifiedList&lt;T2Reference&gt; and registered if all
-	 * children can be (or were already) appropriately named.
-	 * <p>
-	 * This method is only valid on parameters of the following type :
-	 * <ol>
-	 * <li>{@link ReferenceSet} - registered if not already registered,
-	 * otherwise returns existing T2Reference</li>
-	 * <li>{@link ErrorDocument} - same behaviour as ReferenceSet</li>
-	 * <li>{@link ExternalReferenceSPI} - wrapped in ReferenceSet, registered
-	 * and ID returned</li>
-	 * <li>Throwable - wrapped in ErrorDocument with no message, registered and
-	 * ID returned</li>
-	 * <li>List - all children are first registered, if this succeeds the list
-	 * is itself registered as an IdentifiedList of T2Reference and its
-	 * reference returned.</li>
-	 * </ol>
-	 * The exception to this is if the useConvertorSPI parameter is set to true
-	 * - in this case any objects which do not match the above allowed list will
-	 * be run through any available ValueToReferenceConvertorSPI instances in
-	 * turn until one succeeds or all fail, which may result in the creation of
-	 * ExternalReferenceSPI instances. As these can be registered such objects
-	 * will not cause an exception to be thrown.
-	 * 
-	 * @param o
-	 *            the object to register with the reference system, must comply
-	 *            with and will be interpreted as shown in the type list above.
-	 * @param targetDepth
-	 *            the depth of the top level object supplied. This is needed
-	 *            when registering empty collections and error documents,
-	 *            whether as top level types or as members of a collection
-	 *            within the top level type. If registering a collection this is
-	 *            the collection depth, so a List of ReferenceSchemeSPI would be
-	 *            depth 1. Failing to specify this correctly will result in
-	 *            serious problems downstream so be careful! We can't catch all
-	 *            potential problems in this method (although some errors will
-	 *            be trapped).
-	 * @param useConverterSPI
-	 *            whether to attempt to use the ValueToReferenceConvertorSPI
-	 *            registry (if defined and available) to map arbitrary objects
-	 *            to ExternalReferenceSPI instances on the fly. The registry of
-	 *            converters is generally injected into the implementation of
-	 *            this service.
-	 * @param context
-	 *            ReferenceContext to use if required by component services,
-	 *            this is most likely to be used by the object to reference
-	 *            converters if engaged.
-	 *            <p>
-	 *            If the context is null a new empty reference context is
-	 *            inserted.
-	 * @return a T2Reference to the registered object
-	 * @throws ReferenceServiceException
-	 *             if the object type (or, for collections, the recursive type
-	 *             of its contents) is not in the allowed list or if a problem
-	 *             occurs during registration. Also thrown if attempting to use
-	 *             the converter SPI without an attached registry.
-	 */
-	@Override
-	public T2Reference register(Object o, int targetDepth,
-			boolean useConverterSPI, ReferenceContext context)
-			throws ReferenceServiceException {
-		checkServices();
-		if (context == null)
-			context = new EmptyReferenceContext();
-		if (useConverterSPI)
-			checkConverterRegistry();
-		return getNameForObject(o, targetDepth, useConverterSPI, context);
-	}
-
-	@SuppressWarnings("unchecked")
-	private T2Reference getNameForObject(Object o, int currentDepth,
-			boolean useConverterSPI, ReferenceContext context)
-			throws ReferenceServiceException {
-		if (currentDepth < 0)
-			throw new ReferenceServiceException("Cannot register at depth "
-					+ currentDepth + ": " + o);
-		/*
-		 * First check whether this is an Identified, and if so whether it
-		 * already has an ID. If this is the case then return it, we assume that
-		 * anything which has an identifier already allocated must have been
-		 * registered (this is implicit in the contract for the various
-		 * sub-services
-		 */
-		if (o instanceof Identified) {
-			Identified i = (Identified) o;
-			if (i.getId() != null)
-				return i.getId();
-		}
-		/*
-		 * Then check whether the item *is* a T2Reference, in which case we can
-		 * just return it (useful for when registering lists of existing
-		 * references)
-		 */
-		if (o instanceof T2Reference)
-			return (T2Reference) o;
-
-		if (o.getClass().isArray()) {
-			Class<?> elementType = o.getClass().getComponentType();
-			if (elementType.getCanonicalName().equals("char")) {
-				char[] cArray = (char[]) o;
-				List<Character> cList = new ArrayList<>();
-				for (char c : cArray)
-					cList.add(new Character(c));
-				o = cList;
-			} else if (elementType.getCanonicalName().equals("short")) {
-				short[] cArray = (short[]) o;
-				List<Short> cList = new ArrayList<>();
-				for (short c : cArray)
-					cList.add(new Short(c));
-				o = cList;
-			} else if (elementType.getCanonicalName().equals("int")) {
-				int[] cArray = (int[]) o;
-				List<Integer> cList = new ArrayList<>();
-				for (int c : cArray)
-					cList.add(new Integer(c));
-				o = cList;
-			} else if (elementType.getCanonicalName().equals("long")) {
-				long[] cArray = (long[]) o;
-				List<Long> cList = new ArrayList<>();
-				for (long c : cArray)
-					cList.add(new Long(c));
-				o = cList;
-			} else if (elementType.getCanonicalName().equals("float")) {
-				float[] cArray = (float[]) o;
-				List<Float> cList = new ArrayList<>();
-				for (float c : cArray)
-					cList.add(new Float(c));
-				o = cList;
-			} else if (elementType.getCanonicalName().equals("double")) {
-				double[] cArray = (double[]) o;
-				List<Double> cList = new ArrayList<>();
-				for (double c : cArray)
-					cList.add(new Double(c));
-				o = cList;
-			} else if (elementType.getCanonicalName().equals("boolean")) {
-				boolean[] cArray = (boolean[]) o;
-				List<Boolean> cList = new ArrayList<>();
-				for (boolean c : cArray)
-					cList.add(new Boolean(c));
-				o = cList;
-			} else if (!elementType.getCanonicalName().equals("byte")) {
-				// Covert arrays of objects
-				Object[] cArray = (Object[]) o;
-				List<Object> cList = new ArrayList<>();
-				for (Object c : cArray)
-					cList.add(c);
-				o = cList;
-			}
-		}
-
-		// If a Collection but not a List
-		if ((o instanceof Collection) && !(o instanceof List)) {
-			List<Object> cList = new ArrayList<>();
-			cList.addAll((Collection<Object>) o);
-			o = cList;
-		}
-		// Next check lists.
-		if (o instanceof List) {
-			if (currentDepth < 1)
-				throw new ReferenceServiceException(
-						"Cannot register list at depth " + currentDepth);
-			List<?> l = (List<?>) o;
-			/*
-			 * If the list is empty then register a new empty list of the
-			 * appropriate depth and return it
-			 */
-			if (l.isEmpty())
-				try {
-					return listService.registerEmptyList(currentDepth, context)
-							.getId();
-				} catch (ListServiceException lse) {
-					throw new ReferenceServiceException(lse);
-				}
-			/*
-			 * Otherwise construct a new list of T2Reference and register it,
-			 * calling the getNameForObject method on all children of the list
-			 * to construct the list of references
-			 */
-			else {
-				List<T2Reference> references = new ArrayList<>();
-				for (Object item : l)
-					/*
-					 * Recursively call this method with a depth one lower than
-					 * the current depth
-					 */
-					references.add(getNameForObject(item, currentDepth - 1,
-							useConverterSPI, context));
-				try {
-					return listService.registerList(references, context)
-							.getId();
-				} catch (ListServiceException lse) {
-					throw new ReferenceServiceException(lse);
-				}
-			}
-		} else {
-			/*
-			 * Neither a list nor an already identified object, first thing is
-			 * to engage the converters if enabled. Only engage if we don't
-			 * already have a Throwable or an ExternalReferenceSPI instance
-			 */
-			if (useConverterSPI && (o instanceof Throwable == false)
-					&& (o instanceof ExternalReferenceSPI == false)) {
-				if (currentDepth != 0)
-					throw new ReferenceServiceException(
-							"Cannot register object " + o + " at depth "
-									+ currentDepth);
-
-				for (ValueToReferenceConverterSPI converter : converters)
-					if (converter.canConvert(o, context))
-						try {
-							o = converter.convert(o, context);
-							break;
-						} catch (ValueToReferenceConversionException vtrce) {
-							/*
-							 * Fail, but that doesn't matter at the moment as
-							 * there may be more converters to try.
-							 * 
-							 * TODO - log this!
-							 */
-						}
-			}
-			/*
-			 * If the object is neither a Throwable nor an ExternalReferenceSPI
-			 * instance at this point we should fail the registration process,
-			 * this means either that the conversion process wasn't enabled or
-			 * that it failed to map the object type correctly.
-			 */
-			if (!(o instanceof Throwable)
-					&& !(o instanceof ExternalReferenceSPI))
-				throw new ReferenceServiceException(
-						"Failed to register object "
-								+ o
-								+ ", found a type '"
-								+ o.getClass().getCanonicalName()
-								+ "' which cannot currently be registered with the reference manager");
-
-			// Have either a Throwable or an ExternalReferenceSPI
-			if (o instanceof Throwable)
-				// Wrap in an ErrorDocument and return the ID
-				try {
-					ErrorDocument doc = errorDocumentService.registerError(
-							(Throwable) o, currentDepth, context);
-					return doc.getId();
-				} catch (ErrorDocumentServiceException edse) {
-					throw new ReferenceServiceException(edse);
-				}
-			if (o instanceof ExternalReferenceSPI) {
-				if (currentDepth != 0)
-					throw new ReferenceServiceException(
-							"Cannot register external references at depth "
-									+ currentDepth);
-				try {
-					Set<ExternalReferenceSPI> references = new HashSet<ExternalReferenceSPI>();
-					references.add((ExternalReferenceSPI) o);
-					ReferenceSet rs = referenceSetService.registerReferenceSet(
-							references, context);
-					return rs.getId();
-				} catch (ReferenceSetServiceException rsse) {
-					throw new ReferenceServiceException(rsse);
-				}
-			}
-		}
-		throw new ReferenceServiceException(
-				"Should never see this, reference registration"
-						+ " logic has fallen off the end of the"
-						+ " world, check the code!");
-	}
-
-	/**
-	 * Perform recursive identifier resolution, building a collection structure
-	 * of Identified objects, any collection elements being IdentifiedLists of
-	 * Identified subclasses. If the id has depth 0 this will just return the
-	 * Identified to which that id refers.
-	 * 
-	 * @param id
-	 *            the T2Reference to resolve
-	 * @param ensureTypes
-	 *            a set of ExternalReferenceSPI classes, this is used to augment
-	 *            any resolved ReferenceSet instances to ensure that each one
-	 *            has at least one of the specified types. If augmentation is
-	 *            not required this can be set to null.
-	 * @param context
-	 *            the ReferenceContext to use to resolve this and any
-	 *            recursively resolved identifiers
-	 *            <p>
-	 *            If the context is null a new EmptyReferenceContext is inserted
-	 *            in its place.
-	 * @return fully resolved Identified subclass - this is either a (recursive)
-	 *         IdentifiedList of Identified, a ReferenceSet or an ErrorDocument
-	 * @throws ReferenceServiceException
-	 *             if any problems occur during resolution
-	 */
-	@Override
-	public Identified resolveIdentifier(T2Reference id,
-			Set<Class<ExternalReferenceSPI>> ensureTypes,
-			ReferenceContext context) throws ReferenceServiceException {
-		checkServices();
-		if (context == null)
-			context = new EmptyReferenceContext();
-		switch (id.getReferenceType()) {
-		case ReferenceSet:
-			try {
-				ReferenceSet rs;
-				if (ensureTypes == null)
-					rs = referenceSetService.getReferenceSet(id);
-				else
-					rs = referenceSetService.getReferenceSetWithAugmentation(
-							id, ensureTypes, context);
-				if (rs == null)
-					throw new ReferenceServiceException(
-							"Could not find ReferenceSet " + id);
-				return rs;
-			} catch (ReferenceSetServiceException rsse) {
-				throw new ReferenceServiceException(rsse);
-			}
-
-		case ErrorDocument:
-			try {
-				ErrorDocument ed = errorDocumentService.getError(id);
-				if (ed == null)
-					throw new ReferenceServiceException(
-							"Could not find ErrorDocument " + id);
-				return ed;
-			} catch (ErrorDocumentServiceException edse) {
-				throw new ReferenceServiceException(edse);
-			}
-
-		case IdentifiedList:
-			try {
-				IdentifiedList<T2Reference> idList = listService.getList(id);
-				if (idList == null)
-					throw new ReferenceServiceException(
-							"Could not find IdentifiedList " + id);
-				/*
-				 * Construct a new list, and populate with the result of
-				 * resolving each ID in turn
-				 */
-				IdentifiedArrayList<Identified> newList = new IdentifiedArrayList<>();
-				for (T2Reference item : idList)
-					newList.add(resolveIdentifier(item, ensureTypes, context));
-				newList.setTypedId(getAsImpl(id));
-				return newList;
-			} catch (ListServiceException lse) {
-				throw new ReferenceServiceException(lse);
-			}
-
-		default:
-			throw new ReferenceServiceException("Unsupported ID type : "
-					+ id.getReferenceType());
-		}
-	}
-
-	@Override
-	public Object renderIdentifier(T2Reference id, Class<?> leafClass,
-			ReferenceContext context) throws ReferenceServiceException {
-		// Check we have the services installed
-		checkServices();
-
-		// Insert an empty context if context was null
-		if (context == null)
-			context = new EmptyReferenceContext();
-		// Reject if the source reference contains errors
-		if (id.containsErrors())
-			throw new ReferenceServiceException(
-					"Can't render an identifier which contains errors to a POJO");
-
-		/*
-		 * Attempt to find an appropriate StreamToValueConverterSPI instance to
-		 * build the specified class
-		 */
-		StreamToValueConverterSPI<?> converter = null;
-		if (valueBuilders != null)
-			for (StreamToValueConverterSPI<?> stvc : valueBuilders) {
-				Class<?> builtClass = stvc.getPojoClass();
-				if (leafClass.isAssignableFrom(builtClass)) {
-					converter = stvc;
-					break;
-				}
-			}
-		if (converter == null)
-			log.warn("No stream->value converters found for type '"
-					+ leafClass.getCanonicalName() + "'");
-
-		// Render the identifier
-		return renderIdentifierInner(id, leafClass, context, converter);
-	}
-
-	private Object renderIdentifierInner(T2Reference id, Class<?> leafClass,
-			ReferenceContext context, StreamToValueConverterSPI<?> converter)
-			throws ReferenceServiceException {
-		checkServices();
-
-		switch (id.getReferenceType()) {
-		case IdentifiedList:
-			try {
-				IdentifiedList<T2Reference> idList = listService.getList(id);
-				if (idList == null)
-					throw new ReferenceServiceException(
-							"Could not find IdentifiedList " + id);
-				List<Object> result = new ArrayList<>();
-				for (T2Reference child : idList)
-					result.add(renderIdentifierInner(child, leafClass, context,
-							converter));
-				return result;
-			} catch (ListServiceException lse) {
-				throw new ReferenceServiceException(lse);
-			}
-
-		case ReferenceSet:
-			try {
-				ReferenceSet rs = referenceSetService.getReferenceSet(id);
-				if (rs == null)
-					throw new ReferenceServiceException(
-							"Could not find ReferenceSet " + id);
-				// Check that there are references in the set
-				if (rs.getExternalReferences().isEmpty())
-					throw new ReferenceServiceException(
-							"Can't render an empty reference set to a POJO");
-				/*
-				 * If we can't directly map to an appropriate value keep track
-				 * of the cheapest reference from which to try to build the pojo
-				 * from a stream
-				 */
-				ExternalReferenceSPI cheapestReference = null;
-				float cheapestReferenceCost = MAX_VALUE;
-				for (ExternalReferenceSPI ers : rs.getExternalReferences()) {
-					if (ers instanceof ValueCarryingExternalReference<?>) {
-						ValueCarryingExternalReference<?> vcer = (ValueCarryingExternalReference<?>) ers;
-						if (leafClass.isAssignableFrom(vcer.getValueType()))
-							return vcer.getValue();
-					}
-					// Got here so this wasn't an appropriate value type
-					if (cheapestReference == null
-							|| ers.getResolutionCost() < cheapestReferenceCost) {
-						cheapestReference = ers;
-						cheapestReferenceCost = ers.getResolutionCost();
-					}
-				}
-				if (converter != null && cheapestReference != null)
-					try (InputStream stream = cheapestReference
-							.openStream(context)) {
-						return converter.renderFrom(stream,
-								cheapestReference.getDataNature(),
-								cheapestReference.getCharset());
-					}
-			} catch (Exception e) {
-				throw new ReferenceServiceException(e);
-			}
-			throw new ReferenceServiceException(
-					"No converter found, and reference set didn't contain"
-							+ " an appropriate value carrying reference, cannot render to POJO");
-
-		default:
-			throw new ReferenceServiceException("Unsupported ID type : "
-					+ id.getReferenceType());
-		}
-	}
-
-	/**
-	 * Initiates a traversal of the specified t2reference, traversing to
-	 * whatever level of depth is required such that all identifiers returned
-	 * within the iterator have the specified depth. The context (i.e. the index
-	 * path from the originally specified reference to each reference within the
-	 * iteration) is included through use of the ContextualizedT2Reference
-	 * wrapper class
-	 * 
-	 * @param source
-	 *            the T2Reference from which to traverse. In general this is the
-	 *            root of a collection structure.
-	 * @param desiredDepth
-	 *            the desired depth of all returned T2References, must be less
-	 *            than or equal to that of the source reference.
-	 * @throws ReferenceServiceException
-	 *             if unable to create the iterator for some reason. Note that
-	 *             implementations are free to lazily perform the iteration so
-	 *             this method may succeed but the iterator produced can fail
-	 *             when used. If the iterator fails it will do so by throwing
-	 *             one of the underlying sub-service exceptions.
-	 */
-	@Override
-	public Iterator<ContextualizedT2Reference> traverseFrom(T2Reference source,
-			int desiredDepth) throws ReferenceServiceException {
-		checkServices();
-		if (desiredDepth < 0)
-			throw new ReferenceServiceException(
-					"Cannot traverse to a negative depth");
-		List<ContextualizedT2Reference> workingSet = new ArrayList<>();
-		workingSet.add(new ContextualizedT2ReferenceImpl(source, new int[0]));
-		int currentDepth = source.getDepth();
-		while (currentDepth > desiredDepth) {
-			List<ContextualizedT2Reference> newSet = new ArrayList<>();
-			for (ContextualizedT2Reference ci : workingSet) {
-				T2ReferenceImpl ref = (T2ReferenceImpl) ci.getReference();
-				switch (ref.getReferenceType()) {
-				case IdentifiedList:
-					try {
-						int position = 0;
-						for (T2Reference child : getListService().getList(ref))
-							newSet.add(new ContextualizedT2ReferenceImpl(child,
-									addIndex(ci.getIndex(), position++)));
-					} catch (ListServiceException lse) {
-						throw new ReferenceServiceException(lse);
-					}
-					break;
-				case ReferenceSet:
-					throw new ReferenceServiceException(
-							"Should never be trying to drill inside a data document identifier");
-				case ErrorDocument:
-					newSet.add(new ContextualizedT2ReferenceImpl(ref
-							.getDeeperErrorReference(), addIndex(ci.getIndex(),
-							0)));
-					break;
-				default:
-					throw new ReferenceServiceException(
-							"Fallen off end of case statement, unknown reference type!");
-				}
-			}
-			currentDepth--;
-			workingSet = newSet;
-		}
-		return workingSet.iterator();
-	}
-
-	/**
-	 * Append to an int[]
-	 * 
-	 * @param current
-	 *            current int[]
-	 * @param head
-	 *            new int item to append to the current array
-	 * @return new array of int with the head added
-	 */
-	private static int[] addIndex(int[] current, int head) {
-		int[] result = new int[current.length + 1];
-		System.arraycopy(current, 0, result, 0, current.length);
-		result[current.length] = head;
-		return result;
-	}
-
-	/**
-	 * Parse the reference contained in the string and return a
-	 * {@link T2Reference} with the correct properties
-	 */
-	@Override
-	public T2Reference referenceFromString(String reference) {
-		T2ReferenceImpl newRef = new T2ReferenceImpl();
-		Map<String, String> parseRef = parseRef(reference);
-		newRef.setNamespacePart(parseRef.get("namespace"));
-		newRef.setLocalPart(parseRef.get("localPart"));
-		String type = parseRef.get("type");
-		if (type.equals("ref")) {
-			newRef.setReferenceType(ReferenceSet);
-		} else if (type.equals("list")) {
-			newRef.setReferenceType(IdentifiedList);
-			newRef.setContainsErrors(Boolean.parseBoolean(parseRef.get("error")));
-			newRef.setDepth(Integer.parseInt(parseRef.get("depth")));
-		} else if (type.equals("error")) {
-			newRef.setContainsErrors(true);
-			newRef.setReferenceType(ErrorDocument);
-			newRef.setDepth(Integer.parseInt(parseRef.get("depth")));
-		} else {
-			return null;
-			// should throw an error
-		}
-
-		return newRef;
-	}
-
-	/**
-	 * Parse the reference and return a map with localPart, namespace, depth,
-	 * contains errors and the type
-	 * 
-	 * @param ref
-	 * @return
-	 */
-	private Map<String, String> parseRef(String ref) {
-		String[] split = ref.split("\\?");
-		/*
-		 * get the bit before and after the final '/' ie. the local part and the
-		 * depth, there might not be a split1[1] since it might not be a list
-		 */
-		String[] split2 = split[1].split("/");
-		// get the t2:abc:// and the namespace
-		String[] split3 = split[0].split("//");
-		// get the t2 bit and the reference type bit
-		String[] split4 = split3[0].split(":");
-
-		Map<String, String> refPartsMap = new HashMap<String, String>();
-		refPartsMap.put("type", split4[1]);
-		refPartsMap.put("namespace", split3[1]);
-		refPartsMap.put("localPart", split2[0]);
-
-		if (refPartsMap.get("type").equals("list")) {
-			refPartsMap.put("error", split2[1]);
-			refPartsMap.put("depth", split2[2]);
-		}
-		if (refPartsMap.get("type").equals("error"))
-			refPartsMap.put("depth", split2[1]);
-
-		return refPartsMap;
-
-	}
-
-	@Override
-	public boolean delete(List<T2Reference> references)
-			throws ReferenceServiceException {
-		for (T2Reference reference : references)
-			delete(reference);
-		return true;
-	}
-
-	@Override
-	public boolean delete(T2Reference reference)
-			throws ReferenceServiceException {
-		switch (reference.getReferenceType()) {
-		case IdentifiedList:
-			return listService.delete(reference);
-		case ReferenceSet:
-			return referenceSetService.delete(reference);
-		case ErrorDocument:
-			return errorDocumentService.delete(reference);
-		default:
-			throw new ReferenceServiceException("Unknown reference type!");
-		}
-	}
-
-	@Override
-	public void deleteReferencesForWorkflowRun(String workflowRunId)
-			throws ReferenceServiceException {
-		String errorString = "";
-		try {
-			listService.deleteIdentifiedListsForWorkflowRun(workflowRunId);
-		} catch (ReferenceServiceException resex) {
-			errorString += "Failed to delete lists for workflow run: "
-					+ workflowRunId + ".";
-		}
-		try {
-			referenceSetService
-					.deleteReferenceSetsForWorkflowRun(workflowRunId);
-		} catch (ReferenceServiceException resex) {
-			errorString += "Failed to delete reference sets for workflow run: "
-					+ workflowRunId + ".";
-		}
-		try {
-			errorDocumentService
-					.deleteErrorDocumentsForWorkflowRun(workflowRunId);
-		} catch (ReferenceServiceException resex) {
-			errorString += "Failed to delete error documents for workflow run: "
-					+ workflowRunId + ".";
-		}
-		if (!errorString.equals(""))
-			throw new ReferenceServiceException(errorString);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ReferenceSetAugmentorImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ReferenceSetAugmentorImpl.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ReferenceSetAugmentorImpl.java
deleted file mode 100644
index 33c586b..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ReferenceSetAugmentorImpl.java
+++ /dev/null
@@ -1,462 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.PriorityQueue;
-import java.util.Set;
-
-import net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferenceSet;
-import net.sf.taverna.t2.reference.ReferenceSetAugmentationException;
-import net.sf.taverna.t2.reference.ReferenceSetAugmentor;
-import net.sf.taverna.t2.reference.ReferenceSetAugmentorCallback;
-
-import org.apache.log4j.Logger;
-
-/**
- * Implementation of ReferenceSetAugmentor using Dijkstra's shortest path
- * algorithm over a type graph built from SPI instance registries of reference
- * builders and reference translators.
- * 
- * @author Tom Oinn
- */
-public class ReferenceSetAugmentorImpl implements ReferenceSetAugmentor {
-	private final Logger log = Logger
-			.getLogger(ReferenceSetAugmentorImpl.class);
-
-	/**
-	 * A list of ExternalReferenceBuilderSPI instances used to construct
-	 * ExternalReferenceSPI instances from byte streams
-	 */
-	private List<ExternalReferenceBuilderSPI<?>> builders;
-
-	/**
-	 * A list of ExternalReferenceTranslatorSPI instances used to construct
-	 * ExternalReferenceSPI instances from existing ExternalReferenceSPI
-	 * instances.
-	 */
-	private List<ExternalReferenceTranslatorSPI<?, ?>> translators;
-
-	private boolean cacheValid = false;
-
-	private final Set<Class<ExternalReferenceSPI>> knownReferenceTypes = new HashSet<>();
-	@SuppressWarnings("rawtypes")
-	private final Map<Class<ExternalReferenceSPI>, Set<ExternalReferenceTranslatorSPI>> adjacencySets = new HashMap<>();
-	private final Map<Class<ExternalReferenceSPI>, ShortestPathSolver> solvers = new HashMap<>();
-
-	/**
-	 * Default constructor to make life easier when using Spring. To be
-	 * functional this implementation should be injected with InstanceRegistry
-	 * implementations containing lists of known implementations of the
-	 * ExternalReferenceBuilderSPI and ExternalReferenceTranslatorSPI
-	 * interfaces.
-	 */
-	public ReferenceSetAugmentorImpl() {
-		super();
-	}
-
-	public void buildersUpdated(Object service, Map<?, ?> properties) {
-		cacheValid = false;
-	}
-
-	public void translatorsUpdated(Object service, Map<?, ?> properties) {
-		cacheValid = false;
-	}
-
-	/**
-	 * Inject a list containing all known implementations of
-	 * ExternalReferenceBuilderSPI.
-	 * 
-	 * @throws IllegalStateException
-	 *             if this has already been set, the instance registries should
-	 *             only be set on bean construction.
-	 */
-	public synchronized void setBuilders(
-			List<ExternalReferenceBuilderSPI<?>> builders) {
-		if (this.builders != null) {
-			log.error("Builder registry already injected, invalid operation");
-			throw new IllegalStateException(
-					"Can't inject the external reference builder registry "
-							+ "multiple times.");
-		}
-
-		this.builders = builders;
-		if (log.isDebugEnabled()) {
-			log.debug("* Builders injected :");
-			int counter = 0;
-			for (ExternalReferenceBuilderSPI<?> builder : builders)
-				log.debug("*   " + (++counter) + ") "
-						+ builder.getClass().getSimpleName() + ", builds "
-						+ builder.getReferenceType().getSimpleName());
-		}
-		cacheValid = false;
-	}
-
-	/**
-	 * Inject a list containing all known implementations of
-	 * ExternalReferenceTranslatorSPI.
-	 * 
-	 * @throws IllegalStateException
-	 *             if this has already been set, the instance registries should
-	 *             only be set on bean construction.
-	 */
-	public synchronized void setTranslators(
-			List<ExternalReferenceTranslatorSPI<?, ?>> translators) {
-		if (this.translators == null) {
-			this.translators = translators;
-			if (log.isDebugEnabled()) {
-				log.debug("* Translators injected :");
-				int counter = 0;
-				for (ExternalReferenceTranslatorSPI<?, ?> translator : translators)
-					log.debug("*   "
-							+ (++counter)
-							+ ") "
-							+ translator.getClass().getSimpleName()
-							+ ", translates "
-							+ translator.getSourceReferenceType()
-									.getSimpleName()
-							+ " to "
-							+ translator.getTargetReferenceType()
-									.getSimpleName());
-			}
-			cacheValid = false;
-		} else {
-			log.error("Translator registry already injected, invalid operation");
-			throw new IllegalStateException(
-					"Can't inject the translator registry multiple times.");
-		}
-	}
-
-	@SuppressWarnings({ "unchecked", "rawtypes" })
-	protected synchronized final void update() {
-		if (builders == null || translators == null || cacheValid)
-			return;
-		log.debug("# Refreshing shortest path cache");
-		knownReferenceTypes.clear();
-		solvers.clear();
-		adjacencySets.clear();
-		for (ExternalReferenceBuilderSPI erb : builders)
-			knownReferenceTypes.add(erb.getReferenceType());
-		for (ExternalReferenceTranslatorSPI ert : translators) {
-			knownReferenceTypes.add(ert.getSourceReferenceType());
-			knownReferenceTypes.add(ert.getTargetReferenceType());
-			getNeighbours(ert.getTargetReferenceType()).add(ert);
-		}
-		for (Class<ExternalReferenceSPI> type : knownReferenceTypes)
-			try {
-				solvers.put(type, new ShortestPathSolver(type));
-			} catch (Throwable t) {
-				log.error(t);
-				if (t instanceof RuntimeException)
-					throw (RuntimeException) t;
-			}
-		log.debug("# Path cache refresh done");
-		cacheValid = true;
-	}
-
-	@SuppressWarnings("rawtypes")
-	Set<ExternalReferenceTranslatorSPI> getNeighbours(
-			Class<ExternalReferenceSPI> node) {
-		Set<ExternalReferenceTranslatorSPI> adjacentTo = adjacencySets
-				.get(node);
-		if (adjacentTo != null)
-			return adjacentTo;
-
-		HashSet<ExternalReferenceTranslatorSPI> neighbours = new HashSet<>();
-		adjacencySets.put(node, neighbours);
-		return neighbours;
-	}
-
-	@Override
-	public final Set<ExternalReferenceSPI> augmentReferenceSet(
-			ReferenceSet references,
-			Set<Class<ExternalReferenceSPI>> targetReferenceTypes,
-			ReferenceContext context) throws ReferenceSetAugmentationException {
-		synchronized (this) {
-			if (!cacheValid)
-				update();
-		}
-
-		// Synchronize on the reference set itself
-		synchronized (references) {
-			/*
-			 * First check whether we actually need to modify the reference set
-			 * at all - it's perfectly valid to call the augmentor when nothing
-			 * actually needs to be done (ideally you wouldn't do this, but it's
-			 * likely to happen)
-			 */
-			for (ExternalReferenceSPI er : references.getExternalReferences())
-				if (targetReferenceTypes.contains(er.getClass()))
-					return new HashSet<>();
-
-			// Need to perform augmentation if we reach this point
-			List<TranslationPath> candidatePaths = new ArrayList<>();
-			for (Class<ExternalReferenceSPI> target : targetReferenceTypes) {
-				ShortestPathSolver solver = solvers.get(target);
-				if (solver == null) {
-					solver = new ShortestPathSolver(target);
-					solvers.put(target, solver);
-				}
-				if (solver != null)
-					for (TranslationPath path : solver.getTranslationPaths()) {
-						for (ExternalReferenceSPI er : references
-								.getExternalReferences())
-							if (er.getClass().equals(path.getSourceType()))
-								candidatePaths.add(path);
-						for (TranslationPath dereferenceBasedPath : path
-								.getDereferenceBasedPaths(references))
-							candidatePaths.add(dereferenceBasedPath);
-					}
-			}
-			/*
-			 * Now add candidate paths to represent a no-translator 'direct from
-			 * byte stream source' path for each target type compatible
-			 * reference builder
-			 */
-			for (ExternalReferenceBuilderSPI<?> builder : builders)
-				if (targetReferenceTypes.contains(builder.getReferenceType()))
-					/*
-					 * The builder can construct one of the target types, add
-					 * paths for all possible pairs of 'de-reference existing
-					 * reference' and the builder
-					 */
-					for (ExternalReferenceSPI er : references
-							.getExternalReferences()) {
-						TranslationPath newPath = new TranslationPath();
-						newPath.setBuilders(builders);
-						newPath.setInitialBuilder(builder);
-						newPath.setSourceReference(er);
-						candidatePaths.add(newPath);
-					}
-
-			/*
-			 * Got a list of candidate paths sorted by estimated overall path
-			 * cost
-			 */
-			Collections.sort(candidatePaths);
-			if (log.isDebugEnabled()) {
-				log.debug("Found "
-						+ candidatePaths.size()
-						+ " contextual translation path(s) including builder based :");
-				int counter = 0;
-				for (TranslationPath path : candidatePaths)
-					log.debug("  " + (++counter) + ") " + path.toString());
-			}
-
-			if (candidatePaths.isEmpty()) {
-				log.warn("No candidate paths found for augmentation");
-				throw new ReferenceSetAugmentationException(
-						"No candidate translation paths were found");
-			}
-
-			log.debug("Performing augmentation :");
-			int counter = 0;
-			for (TranslationPath path : candidatePaths)
-				try {
-					counter++;
-					Set<ExternalReferenceSPI> newReferences = path
-							.doTranslation(references, context);
-					if (log.isDebugEnabled())
-						log.debug("  Success (" + counter + "), created "
-								+ printRefSet(newReferences));
-					return newReferences;
-				} catch (Exception ex) {
-					log.debug("  Failed (" + counter + ")");
-					log.trace(ex);
-					// Use next path...
-				}
-			log.warn("  No paths succeeded, augmentation failed");
-			throw new ReferenceSetAugmentationException(
-					"All paths threw exceptions, can't perform augmentation");
-		}
-	}
-
-	private String printRefSet(Set<ExternalReferenceSPI> set) {
-		StringBuilder sb = new StringBuilder("[");
-		String sep = "";
-		for (ExternalReferenceSPI ref : set) {
-			sb.append(sep).append(ref.toString());
-			sep = ",";
-		}
-		return sb.append("]").toString();
-	}
-
-	@Override
-	public final void augmentReferenceSetAsynch(final ReferenceSet references,
-			final Set<Class<ExternalReferenceSPI>> targetReferenceTypes,
-			final ReferenceContext context,
-			final ReferenceSetAugmentorCallback callback)
-			throws ReferenceSetAugmentationException {
-		Runnable r = new Runnable() {
-			@Override
-			public void run() {
-				try {
-					callback.augmentationCompleted(augmentReferenceSet(
-							references, targetReferenceTypes, context));
-				} catch (ReferenceSetAugmentationException rsae) {
-					callback.augmentationFailed(rsae);
-				}
-			}
-		};
-		executeRunnable(r);
-	}
-
-	/**
-	 * Schedule a runnable for execution - current naive implementation uses a
-	 * new thread and executes immediately, but this is where any thread pool
-	 * logic would go if we wanted to add that.
-	 * 
-	 * @param r
-	 */
-	private void executeRunnable(Runnable r) {
-		new Thread(r).start();
-	}
-
-	class ShortestPathSolver {
-		private Map<Class<ExternalReferenceSPI>, Class<ExternalReferenceSPI>> predecessors;
-		private Map<Class<ExternalReferenceSPI>, ExternalReferenceTranslatorSPI<?, ?>> translators;
-		private Map<Class<ExternalReferenceSPI>, Float> shortestDistances;
-		private final Comparator<Class<ExternalReferenceSPI>> shortestDistanceComparator = new Comparator<Class<ExternalReferenceSPI>>() {
-			@Override
-			public int compare(Class<ExternalReferenceSPI> left,
-					Class<ExternalReferenceSPI> right) {
-				float shortestDistanceLeft = shortestDistances.get(left);
-				float shortestDistanceRight = shortestDistances.get(right);
-				if (shortestDistanceLeft > shortestDistanceRight)
-					return +1;
-				if (shortestDistanceLeft < shortestDistanceRight)
-					return -1;
-				return left.getCanonicalName().compareTo(
-						right.getCanonicalName());
-			}
-		};
-		private final PriorityQueue<Class<ExternalReferenceSPI>> unsettledNodes = new PriorityQueue<>(
-				10, shortestDistanceComparator);
-		private final Set<Class<ExternalReferenceSPI>> settledNodes = new HashSet<>();
-
-		private final List<TranslationPath> translationPaths = new ArrayList<>();
-
-		public List<TranslationPath> getTranslationPaths() {
-			return this.translationPaths;
-		}
-
-		public ShortestPathSolver(Class<ExternalReferenceSPI> targetType) {
-			log.debug("# Constructing shortest paths to '"
-					+ targetType.getSimpleName() + "'");
-			predecessors = new HashMap<>();
-			translators = new HashMap<>();
-			shortestDistances = new HashMap<>();
-			setShortestDistance(targetType, 0.0f);
-			unsettledNodes.add(targetType);
-			while (!unsettledNodes.isEmpty()) {
-				Class<ExternalReferenceSPI> u = extractMin();
-				settledNodes.add(u);
-				relaxNeighbours(u);
-			}
-			for (Class<ExternalReferenceSPI> c : settledNodes)
-				if (!c.equals(targetType)) {
-					// Don't calculate a path to itself!
-					TranslationPath p = new TranslationPath();
-					p.setBuilders(builders);
-					Class<ExternalReferenceSPI> node = c;
-					while (predecessors.get(node) != null) {
-						p.pathSteps().add(translators.get(node));
-						// Recurse, should terminate at the target type
-						node = predecessors.get(node);
-					}
-					translationPaths.add(p);
-				}
-			Collections.sort(translationPaths);
-			if (translationPaths.isEmpty())
-				log.debug("#   no paths discovered, type not reachable through translation");
-			else if (log.isDebugEnabled()) {
-				log.debug("#   found " + translationPaths.size()
-						+ " distinct path(s) :");
-				int counter = 0;
-				for (TranslationPath path : translationPaths)
-					log.debug("#     " + (++counter) + ") " + path);
-			}
-		}
-
-		@SuppressWarnings({ "unchecked", "rawtypes" })
-		private void relaxNeighbours(Class<ExternalReferenceSPI> u) {
-			log.trace("#     relaxing node " + u.getSimpleName());
-			Set<Class<ExternalReferenceSPI>> alreadySeen = new HashSet<>();
-			for (ExternalReferenceTranslatorSPI ert : getNeighbours(u)) {
-				// all the translators that translate *to* u
-				Class<ExternalReferenceSPI> v = ert.getSourceReferenceType();
-				log.trace("#     translator found from from '" + v + "' : "
-						+ ert.getClass().getSimpleName());
-				if (!alreadySeen.contains(v) && !isSettled(v)) {
-					/*
-					 * Avoid duplicate edges, always take the first one where
-					 * such duplicates exist
-					 */
-					alreadySeen.add(v);
-					if (getShortestDistance(v) > getShortestDistance(u)
-							+ ert.getTranslationCost()) {
-						setShortestDistance(
-								v,
-								getShortestDistance(u)
-										+ ert.getTranslationCost());
-						setPredecessor(v, u, ert);
-						unsettledNodes.add(v);
-					}
-				}
-			}
-		}
-
-		private boolean isSettled(Class<ExternalReferenceSPI> node) {
-			return settledNodes.contains(node);
-		}
-
-		private void setShortestDistance(Class<ExternalReferenceSPI> node,
-				float distance) {
-			shortestDistances.put(node, distance);
-		}
-
-		private float getShortestDistance(Class<ExternalReferenceSPI> node) {
-			Float d = shortestDistances.get(node);
-			return (d == null) ? Float.MAX_VALUE : d;
-		}
-
-		private Class<ExternalReferenceSPI> extractMin() {
-			return unsettledNodes.poll();
-		}
-
-		private void setPredecessor(Class<ExternalReferenceSPI> child,
-				Class<ExternalReferenceSPI> parent,
-				ExternalReferenceTranslatorSPI<?, ?> translator) {
-			predecessors.put(child, parent);
-			translators.put(child, translator);
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ReferenceSetImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ReferenceSetImpl.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ReferenceSetImpl.java
deleted file mode 100644
index 437cd1d..0000000
--- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/ReferenceSetImpl.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import java.util.Set;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceSet;
-import net.sf.taverna.t2.reference.h3.HibernateMappedEntity;
-
-/**
- * An implementation of ReferenceSet with the additional methods and metadata
- * required by Hibernate3 to allow it to be persisted in a relational store. As
- * with everything else in this package you shouldn't be using this class
- * directly! Instead of this class you should use the registration methods on
- * {@link net.sf.taverna.t2.reference.ReferenceSetService}, implementations of
- * that interface will handle the construction of ReferenceSet implementations
- * (including this one).
- * 
- * @author Tom Oinn
- */
-public class ReferenceSetImpl extends AbstractEntityImpl implements
-		ReferenceSet, HibernateMappedEntity {
-	private Set<ExternalReferenceSPI> externalReferences;
-	private Long approximateSizeInBytes = new Long(-1);
-	
-	/**
-	 * Construct a new ReferenceSetImpl with the given set of external
-	 * references and identifier.
-	 * 
-	 * @param references
-	 *            the set of ExternalReferenceSPI which this reference set
-	 *            should contain initially
-	 * @param id
-	 *            the T2Reference to use, must be an instance of
-	 *            ReferenceSetT2ReferenceImpl so hibernate can make use of it as
-	 *            a compound primary key component
-	 */
-	public ReferenceSetImpl(Set<ExternalReferenceSPI> references,
-			T2ReferenceImpl id) {
-		setTypedId(id);
-		this.externalReferences = references;
-		
-		//  Should be at least one - otherwise we cannot calculate the data size
-		if (externalReferences != null && externalReferences.size() > 0) {
-			// Just take the first ExternalReferenceSPI returned
-			ExternalReferenceSPI externalReferenceSPI = externalReferences
-					.toArray(new ExternalReferenceSPI[0])[0];
-			approximateSizeInBytes = externalReferenceSPI
-					.getApproximateSizeInBytes();
-		}
-	}
-
-	/**
-	 * Default constructor, used by Hibernate when reconstructing this bean from
-	 * the database. If you call this directly from your code you must then call
-	 * both {@link #setExternalReferences(Set)} and
-	 * {@link #setId(T2ReferenceImpl)} before any use of the reference set. If
-	 * you're not writing the reference manager implementation you shouldn't be
-	 * using this class anyway.
-	 */
-	public ReferenceSetImpl() {
-		//
-	}
-
-	/**
-	 * For debugging purposes, prints a summary of the contents and identifier
-	 * of this reference set.
-	 * 
-	 * @return human readable string representation of this object. This is not
-	 *         regarded as 'stable' and should not be parsed for any reason!
-	 */
-	@Override
-	public String toString() {
-		StringBuilder sb = new StringBuilder();
-		sb.append(getId()).append(" [").append(externalReferences.size())
-				.append("]\n");
-		for (ExternalReferenceSPI ref : externalReferences)
-			sb.append("  ").append(ref).append("\n");
-		return sb.toString();
-
-	}
-
-	@Override
-	public Set<ExternalReferenceSPI> getExternalReferences() {
-		return externalReferences;
-	}
-
-	/**
-	 * This method is only ever called from within Hibernate, and is used to
-	 * initialize the set of external references.
-	 */
-	public void setExternalReferences(Set<ExternalReferenceSPI> newReferences) {
-		this.externalReferences = newReferences;
-	}
-
-	public void setApproximateSizeInBytes(Long sizeInBytes) {
-		this.approximateSizeInBytes = sizeInBytes;
-	}
-
-	@Override
-	public Long getApproximateSizeInBytes() {
-		return approximateSizeInBytes;
-	}
-}


[36/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractReferenceServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractReferenceServiceImpl.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractReferenceServiceImpl.java
new file mode 100644
index 0000000..c1c2743
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractReferenceServiceImpl.java
@@ -0,0 +1,170 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.taverna.reference.ErrorDocumentService;
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ListService;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferenceService;
+import org.apache.taverna.reference.ReferenceServiceException;
+import org.apache.taverna.reference.ReferenceServiceResolutionCallback;
+import org.apache.taverna.reference.ReferenceSetService;
+import org.apache.taverna.reference.StreamToValueConverterSPI;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.ValueToReferenceConverterSPI;
+
+/**
+ * Implementation of ReferenceService, inject with ReferenceSetService,
+ * ErrorDocumentService and ListService to enable. Inject with an instance
+ * registry of ValueToReferenceConvertorSPI to enable on the fly registration of
+ * otherwise illegal object types. This class contains the basic injection
+ * functionality and the getters for the sub-services, mostly to isolate these
+ * mundane bits of code from the more interesting actual implementation of the
+ * reference service logic.
+ * 
+ * @author Tom Oinn
+ */
+public abstract class AbstractReferenceServiceImpl extends AbstractServiceImpl
+		implements ReferenceService {
+	protected ErrorDocumentService errorDocumentService = null;
+	protected ReferenceSetService referenceSetService = null;
+	protected ListService listService = null;
+	protected List<ValueToReferenceConverterSPI> converters = null;
+	@SuppressWarnings("rawtypes")
+	protected List<StreamToValueConverterSPI> valueBuilders = null;
+
+	/**
+	 * Inject value to reference convertor SPI
+	 */
+	public final void setConverters(
+			List<ValueToReferenceConverterSPI> converters) {
+		this.converters = converters;
+	}
+
+	/**
+	 * Inject stream to value converter SPI
+	 */
+	@SuppressWarnings("rawtypes")
+	public final void setValueBuilders(
+			List<StreamToValueConverterSPI> valueBuilders) {
+		this.valueBuilders = valueBuilders;
+	}
+
+	/**
+	 * Inject error document service
+	 */
+	public final void setErrorDocumentService(ErrorDocumentService eds) {
+		this.errorDocumentService = eds;
+	}
+
+	/**
+	 * Inject reference set service
+	 */
+	public final void setReferenceSetService(ReferenceSetService rss) {
+		this.referenceSetService = rss;
+	}
+
+	/**
+	 * Inject list service
+	 */
+	public final void setListService(ListService ls) {
+		this.listService = ls;
+	}
+
+	/**
+	 * Throw a ReferenceServiceException if methods in ReferenceService are
+	 * called without the necessary sub-services configured.
+	 */
+	protected final void checkServices() throws ReferenceServiceException {
+		if (errorDocumentService == null)
+			throw new ReferenceServiceException(
+					"Reference service must be configued with an "
+							+ "instance of ErrorDocumentService to function");
+		if (referenceSetService == null)
+			throw new ReferenceServiceException(
+					"Reference service must be configued with an "
+							+ "instance of ReferenceSetService to function");
+		if (listService == null)
+			throw new ReferenceServiceException(
+					"Reference service must be configued with an "
+							+ "instance of ListService to function");
+	}
+
+	/**
+	 * Check whether the converter registry has been defined, throw a
+	 * ReferenceServiceException if not
+	 */
+	protected final void checkConverterRegistry()
+			throws ReferenceServiceException {
+		if (converters == null)
+			throw new ReferenceServiceException(
+					"Reference service must be configued with an "
+							+ "instance registry of ValueToReferenceConvertorSPI "
+							+ "to enable on the fly mapping of arbitrary objects "
+							+ "during compound registration");
+	}
+
+	@Override
+	public final ErrorDocumentService getErrorDocumentService() {
+		checkServices();
+		return this.errorDocumentService;
+	}
+
+	@Override
+	public final ListService getListService() {
+		checkServices();
+		return this.listService;
+	}
+
+	@Override
+	public final ReferenceSetService getReferenceSetService() {
+		checkServices();
+		return this.referenceSetService;
+	}
+
+	/**
+	 * Wraps the synchronous form, using the executeRunnable method to schedule
+	 * it.
+	 */
+	@Override
+	public void resolveIdentifierAsynch(final T2Reference id,
+			final Set<Class<ExternalReferenceSPI>> ensureTypes,
+			final ReferenceContext context,
+			final ReferenceServiceResolutionCallback callback)
+			throws ReferenceServiceException {
+		checkServices();
+		Runnable r = new Runnable() {
+			@Override
+			public void run() {
+				try {
+					callback.identifierResolved(resolveIdentifier(id,
+							ensureTypes, context));
+				} catch (ReferenceServiceException rse) {
+					callback.resolutionFailed(rse);
+				}
+			}
+		};
+		executeRunnable(r);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractReferenceSetServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractReferenceSetServiceImpl.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractReferenceSetServiceImpl.java
new file mode 100644
index 0000000..d84d7a8
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractReferenceSetServiceImpl.java
@@ -0,0 +1,159 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import java.util.Set;
+
+import org.apache.taverna.reference.DaoException;
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferenceSet;
+import org.apache.taverna.reference.ReferenceSetAugmentor;
+import org.apache.taverna.reference.ReferenceSetDao;
+import org.apache.taverna.reference.ReferenceSetService;
+import org.apache.taverna.reference.ReferenceSetServiceCallback;
+import org.apache.taverna.reference.ReferenceSetServiceException;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.T2ReferenceGenerator;
+
+/**
+ * Abstract implementation of ReferenceSetService, inject with an appropriate
+ * ReferenceSetDao to enable. Implements translation functionality as long as an
+ * appropriate ReferenceSetAugmentor implementation is injected. Contains
+ * injectors for id generation and dao along with other bookkeeping, leaving the
+ * implementation of the actual service logic to the subclass.
+ * 
+ * @author Tom Oinn
+ */
+public abstract class AbstractReferenceSetServiceImpl extends
+		AbstractServiceImpl implements ReferenceSetService {
+	protected ReferenceSetDao referenceSetDao = null;
+	protected T2ReferenceGenerator t2ReferenceGenerator = null;
+	protected ReferenceSetAugmentor referenceSetAugmentor = null;
+
+	/**
+	 * Inject the reference set data access object.
+	 */
+	public final void setReferenceSetDao(ReferenceSetDao dao) {
+		this.referenceSetDao = dao;
+	}
+
+	/**
+	 * Inject the T2Reference generator used to allocate new IDs when
+	 * registering sets of ExternalReferenceSPI
+	 */
+	public final void setT2ReferenceGenerator(T2ReferenceGenerator t2rg) {
+		this.t2ReferenceGenerator = t2rg;
+	}
+
+	/**
+	 * Inject the ReferenceSetAugmentor used to translate or construct new
+	 * ExternalReferenceSPI instances within a ReferenceSet
+	 */
+	public final void setReferenceSetAugmentor(ReferenceSetAugmentor rse) {
+		this.referenceSetAugmentor = rse;
+	}
+
+	/**
+	 * Check that the reference set dao is configured
+	 * 
+	 * @throws ReferenceSetServiceException
+	 *             if the dao is still null
+	 */
+	protected final void checkDao() throws ReferenceSetServiceException {
+		if (referenceSetDao == null)
+			throw new ReferenceSetServiceException(
+					"ReferenceSetDao not initialized, reference set "
+							+ "service operations are not available");
+	}
+
+	/**
+	 * Check that the t2reference generator is configured
+	 * 
+	 * @throws ReferenceSetServiceException
+	 *             if the generator is still null
+	 */
+	protected final void checkGenerator() throws ReferenceSetServiceException {
+		if (t2ReferenceGenerator == null)
+			throw new ReferenceSetServiceException(
+					"T2ReferenceGenerator not initialized, reference "
+							+ "set service operations not available");
+	}
+
+	/**
+	 * Check that the reference set augmentor is configured
+	 * 
+	 * @throws ReferenceSetServiceException
+	 *             if the reference set augmentor is still null
+	 */
+	protected final void checkAugmentor() throws ReferenceSetServiceException {
+		if (referenceSetAugmentor == null)
+			throw new ReferenceSetServiceException(
+					"ReferenceSetAugmentor not initialized, reference "
+							+ "set service operations not available");
+	}
+
+	@Override
+	public final void getReferenceSetAsynch(final T2Reference id,
+			final ReferenceSetServiceCallback callback)
+			throws ReferenceSetServiceException {
+		checkDao();
+		Runnable r = new Runnable() {
+			@Override
+			public void run() {
+				try {
+					ReferenceSet rs = referenceSetDao.get(id);
+					callback.referenceSetRetrieved(rs);
+				} catch (DaoException de) {
+					callback.referenceSetRetrievalFailed(new ReferenceSetServiceException(
+							de));
+				}
+			}
+		};
+		executeRunnable(r);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public final void getReferenceSetWithAugmentationAsynch(
+			final T2Reference id,
+			final Set<Class<ExternalReferenceSPI>> ensureTypes,
+			final ReferenceContext context,
+			final ReferenceSetServiceCallback callback)
+			throws ReferenceSetServiceException {
+		checkDao();
+		checkAugmentor();
+		Runnable r = new Runnable() {
+			@Override
+			public void run() {
+				try {
+					callback.referenceSetRetrieved(getReferenceSetWithAugmentation(
+							id, ensureTypes, context));
+				} catch (ReferenceSetServiceException rsse) {
+					callback.referenceSetRetrievalFailed(rsse);
+				}
+			}
+		};
+		executeRunnable(r);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractServiceImpl.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractServiceImpl.java
new file mode 100644
index 0000000..b97e036
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractServiceImpl.java
@@ -0,0 +1,43 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+/**
+ * Abstract superclass for all service implementation objects, will be used to
+ * allow injection of thread pooling logic as and when we implement it.
+ * 
+ * @author Tom Oinn
+ */
+public class AbstractServiceImpl {
+	/**
+	 * Schedule a runnable for execution - current naive implementation uses a
+	 * new thread and executes immediately, but this is where any thread pool
+	 * logic would go if we wanted to add that.
+	 * 
+	 * @param r
+	 */
+	protected void executeRunnable(Runnable r) {
+		makeExecutionThread(r).start();
+	}
+
+	protected Thread makeExecutionThread(Runnable r) {
+		return new Thread(r);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractT2ReferenceGenerator.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractT2ReferenceGenerator.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractT2ReferenceGenerator.java
new file mode 100644
index 0000000..29b6db7
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/AbstractT2ReferenceGenerator.java
@@ -0,0 +1,110 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import static org.apache.taverna.reference.T2ReferenceType.ErrorDocument;
+import static org.apache.taverna.reference.T2ReferenceType.IdentifiedList;
+import static org.apache.taverna.reference.T2ReferenceType.ReferenceSet;
+
+import java.util.List;
+
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.T2ReferenceGenerator;
+import org.apache.taverna.reference.WorkflowRunIdEntity;
+
+/**
+ * An abstract class for implementing simple {@link T2ReferenceGenerator}s.
+ * 
+ * @author Stian Soiland-Reyes
+ */
+public abstract class AbstractT2ReferenceGenerator implements
+		T2ReferenceGenerator {
+	public AbstractT2ReferenceGenerator() {
+		super();
+	}
+
+	private void initReferenceNamespace(T2ReferenceImpl r, ReferenceContext context) {
+		if (context == null) {
+			// this is not good, just use the default namespace
+			r.setNamespacePart(getNamespace());
+			return;
+		}
+
+		List<WorkflowRunIdEntity> workflowRunIdEntities = context
+				.getEntities(WorkflowRunIdEntity.class);
+		if (workflowRunIdEntities == null || workflowRunIdEntities.isEmpty()) {
+			// this is not good, just use the default namespace
+			r.setNamespacePart(getNamespace());
+			return;
+		}
+
+		// there should be only one wf run id entity
+		String workflowRunId = ((WorkflowRunIdEntity) workflowRunIdEntities
+				.get(0)).getWorkflowRunId();
+		r.setNamespacePart(workflowRunId);
+	}
+
+	@Override
+	public synchronized T2Reference nextReferenceSetReference(
+			ReferenceContext context) {
+		T2ReferenceImpl r = new T2ReferenceImpl();
+		initReferenceNamespace(r, context);
+		r.setLocalPart(getNextLocalPart());
+		r.setReferenceType(ReferenceSet);
+		r.setDepth(0);
+		r.setContainsErrors(false);
+		return r;
+	}
+
+	/**
+	 * Generate a new local part for a new {@link T2Reference reference}. The
+	 * local part should be unique within this
+	 * {@link T2ReferenceGenerator#getNamespace() namespace}.
+	 * 
+	 * @return A new, unique local part to identify a new reference.
+	 */
+	protected abstract String getNextLocalPart();
+
+	@Override
+	public T2Reference nextListReference(boolean containsErrors, int listDepth,
+			ReferenceContext context) {
+		T2ReferenceImpl r = new T2ReferenceImpl();
+		initReferenceNamespace(r, context);
+		r.setLocalPart(getNextLocalPart());
+		r.setReferenceType(IdentifiedList);
+		r.setDepth(listDepth);
+		r.setContainsErrors(containsErrors);
+		return r;
+	}
+
+	@Override
+	public T2Reference nextErrorDocumentReference(int depth,
+			ReferenceContext context) {
+		T2ReferenceImpl r = new T2ReferenceImpl();
+		initReferenceNamespace(r, context);
+		r.setLocalPart(getNextLocalPart());
+		r.setReferenceType(ErrorDocument);
+		r.setDepth(depth);
+		// This is an error document, it contains errors by definition
+		r.setContainsErrors(true);
+		return r;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/CacheAspect.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/CacheAspect.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/CacheAspect.java
new file mode 100644
index 0000000..b7aa5f6
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/CacheAspect.java
@@ -0,0 +1,126 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import org.apache.taverna.reference.DaoException;
+import org.apache.taverna.reference.Identified;
+import org.apache.taverna.reference.ReferenceServiceCacheProvider;
+import org.apache.taverna.reference.T2Reference;
+
+import org.aspectj.lang.ProceedingJoinPoint;
+
+/**
+ * An aspect used to intercept calls to the various data access objects and
+ * divert through a write-through cache provider
+ * 
+ * @author Tom Oinn
+ */
+public class CacheAspect {
+	private ReferenceServiceCacheProvider cacheProvider;
+
+	/**
+	 * Return an injected ReferenceServiceCacheProvider
+	 */
+	private final ReferenceServiceCacheProvider getCacheProvider() {
+		return cacheProvider;
+	}
+
+	/**
+	 * Inject an instance of ReferenceServiceCacheProvider
+	 * 
+	 * @param cacheProvider
+	 *            the cache provider to use
+	 */
+	public final void setCacheProvider(
+			final ReferenceServiceCacheProvider cacheProvider) {
+		this.cacheProvider = cacheProvider;
+	}
+
+	/**
+	 * Handle a 'get by T2Reference' operation on a Dao
+	 * 
+	 * @param pjp
+	 *            the join point representing the ongoing method call to the dao
+	 * @return the entity identified by the T2Reference supplied to the method
+	 *         to which this advice applies
+	 * @throws DaoException
+	 *             if anything goes wrong
+	 */
+	public final Identified getObject(final ProceedingJoinPoint pjp)
+			throws DaoException {
+		Identified result = null;
+
+		// Get the T2Reference from the argument to the get method
+		T2Reference id = (T2Reference) pjp.getArgs()[0];
+		if (id != null) {
+			result = getCacheProvider().get(id);
+			if (result != null)
+				return result;
+		}
+		// If we miss the cache then call the method as usual
+		try {
+			result = (Identified) pjp.proceed();
+		} catch (DaoException e) {
+			throw e;
+		} catch (Throwable e) {
+			throw new DaoException("Unexpected exception type during aspect "
+					+ "based invocation", e);
+		}
+
+		// Write back to the cache
+		if (result != null)
+			getCacheProvider().put(result);
+
+		return result;
+	}
+
+	/**
+	 * Called around a write or update operation on the backing store, writes
+	 * through to the cache after modifying the state of the backing store and
+	 * before returning from the dao method
+	 * 
+	 * @param pjp
+	 *            join point representing the ongoing method invocation to cache
+	 * @throws DaoException
+	 *             if anything goes wrong
+	 */
+	public void putObject(final ProceedingJoinPoint pjp) throws DaoException {
+		// Get the Identified being stored by the method we're advising
+		Identified storedObject = (Identified) pjp.getArgs()[0];
+
+		try {
+			// Run the store or update method
+			pjp.proceed();
+		} catch (DaoException e) {
+			throw e;
+		} catch (Throwable e) {
+			throw new DaoException("Unexpected exception type during aspect "
+					+ "based invocation", e);
+		}
+
+		/*
+		 * Assuming the method isn't null and has an identifier (which it will
+		 * if we haven't thrown an exception before now) write it back to the
+		 * cache provider
+		 */
+		if (storedObject != null && storedObject.getId() != null)
+			getCacheProvider().put(storedObject);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ContextualizedT2ReferenceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ContextualizedT2ReferenceImpl.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ContextualizedT2ReferenceImpl.java
new file mode 100644
index 0000000..1eca847
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ContextualizedT2ReferenceImpl.java
@@ -0,0 +1,60 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import org.apache.taverna.reference.ContextualizedT2Reference;
+import org.apache.taverna.reference.T2Reference;
+
+/**
+ * Simple implementation of ContextualizedT2Reference
+ * 
+ * @author Tom Oinn
+ */
+public class ContextualizedT2ReferenceImpl implements ContextualizedT2Reference {
+	private T2Reference reference;
+	private int[] index;
+
+	public ContextualizedT2ReferenceImpl(T2Reference ref, int[] context) {
+		this.reference = ref;
+		this.index = context;
+	}
+
+	@Override
+	public int[] getIndex() {
+		return this.index;
+	}
+
+	@Override
+	public T2Reference getReference() {
+		return this.reference;
+	}
+
+	@Override
+	public String toString() {
+		StringBuilder sb = new StringBuilder("[");
+		String sep = "";
+		for (int idx : index) {
+			sb.append(sep).append(idx);
+			sep = ",";
+		}
+		return sb.append("]").append(reference).toString();
+	}
+	
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/EmptyReferenceContext.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/EmptyReferenceContext.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/EmptyReferenceContext.java
new file mode 100644
index 0000000..74ee5db
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/EmptyReferenceContext.java
@@ -0,0 +1,45 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.taverna.reference.ReferenceContext;
+
+/**
+ * A trivial implementation of ReferenceContext, used if the context parameter
+ * to any service method is null.
+ * 
+ * @author Tom Oinn
+ */
+public class EmptyReferenceContext implements ReferenceContext {
+	/**
+	 * Return an empty entity set for all queries.
+	 */
+	@Override
+	public <T> List<T> getEntities(Class<T> arg0) {
+		return new ArrayList<>();
+	}
+
+	@Override
+	public void addEntity(Object entity) {
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ErrorDocumentImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ErrorDocumentImpl.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ErrorDocumentImpl.java
new file mode 100644
index 0000000..96bf3af
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ErrorDocumentImpl.java
@@ -0,0 +1,119 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.taverna.reference.ErrorDocument;
+import org.apache.taverna.reference.StackTraceElementBean;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.h3.HibernateMappedEntity;
+
+/**
+ * Simple bean implementation of ErrorDocument
+ * 
+ * @author Tom Oinn
+ */
+public class ErrorDocumentImpl extends AbstractEntityImpl implements
+		ErrorDocument, HibernateMappedEntity {
+	private String exceptionMessage = "";
+	private String message = "";
+	List<StackTraceElementBean> stackTrace;
+	Set<T2Reference> errorReferences = new HashSet<>();
+	
+	public ErrorDocumentImpl() {
+		this.stackTrace = new ArrayList<>();
+	}
+
+	@Override
+	public String getExceptionMessage() {
+		return this.exceptionMessage;
+	}
+
+	public void setExceptionMessage(String exceptionMessage) {
+		this.exceptionMessage = exceptionMessage;
+	}
+
+	@Override
+	public String getMessage() {
+		return this.message;
+	}
+
+	public void setMessage(String message) {
+		this.message = message;
+	}
+
+	/**
+	 * From interface, not used by hibernate internally
+	 */
+	@Override
+	public List<StackTraceElementBean> getStackTraceStrings() {
+		return this.stackTrace;
+	}
+
+	/**
+	 * Used by Hibernate to bodge around problems with interface types in the
+	 * API
+	 */
+	@SuppressWarnings({ "unchecked", "rawtypes" })
+	public void setStackTraceList(List newList) {
+		this.stackTrace = newList;
+	}
+
+	/**
+	 * Used by Hibernate to bodge around problems with interface types in the
+	 * API
+	 */
+	@SuppressWarnings("rawtypes")
+	public List getStackTraceList() {
+		return this.stackTrace;
+	}
+
+	@Override
+	public Set<T2Reference> getErrorReferences() {
+		return errorReferences;
+	}
+
+	/**
+	 * Used by Hibernate to bodge around problems with interface types in the
+	 * API
+	 */
+	@SuppressWarnings({ "unchecked", "rawtypes" })
+	public void setErrorReferenceSet(Set errorReferenceSet) {
+		this.errorReferences = errorReferenceSet;
+	}
+	
+	/**
+	 * Used by Hibernate to bodge around problems with interface types in the
+	 * API
+	 */
+	@SuppressWarnings("rawtypes")
+	public Set getErrorReferenceSet() {
+		return this.errorReferences;
+	}
+	
+	@Override
+	public String toString() {
+		return getMessage();
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ErrorDocumentServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ErrorDocumentServiceImpl.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ErrorDocumentServiceImpl.java
new file mode 100644
index 0000000..5592ef4
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ErrorDocumentServiceImpl.java
@@ -0,0 +1,162 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import static org.apache.taverna.reference.impl.T2ReferenceImpl.getAsImpl;
+
+import java.util.Set;
+
+import org.apache.taverna.reference.ErrorDocument;
+import org.apache.taverna.reference.ErrorDocumentService;
+import org.apache.taverna.reference.ErrorDocumentServiceException;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferenceServiceException;
+import org.apache.taverna.reference.T2Reference;
+
+/**
+ * Implementation of ErrorDocumentService, inject with an appropriate
+ * ErrorDocumentDao and T2ReferenceGenerator to enable.
+ * 
+ * @author Tom Oinn
+ */
+public class ErrorDocumentServiceImpl extends AbstractErrorDocumentServiceImpl
+		implements ErrorDocumentService {
+	@Override
+	public ErrorDocument getError(T2Reference id)
+			throws ErrorDocumentServiceException {
+		checkDao();
+		try {
+			return errorDao.get(id);
+		} catch (Throwable t) {
+			throw new ErrorDocumentServiceException(t);
+		}
+	}
+
+	/**
+	 * Register the specified error and any child errors (which have the same
+	 * namespace and local part but a lower depth, down to depth of zero
+	 */
+	@Override
+	public ErrorDocument registerError(String message, Throwable t, int depth,
+			ReferenceContext context) throws ErrorDocumentServiceException {
+		checkDao();
+		checkGenerator();
+
+		T2Reference ref = t2ReferenceGenerator.nextErrorDocumentReference(
+				depth, context);
+		T2ReferenceImpl typedId = getAsImpl(ref);
+
+		ErrorDocument docToReturn = null;
+		for (; depth >= 0; depth--) {
+			ErrorDocumentImpl edi = new ErrorDocumentImpl();
+			if (docToReturn == null)
+				docToReturn = edi;
+			edi.setTypedId(typedId);
+			if (message != null)
+				edi.setMessage(message);
+			else
+				edi.setMessage("");
+			if (t != null) {
+				edi.setExceptionMessage(t.toString());
+				for (StackTraceElement ste : t.getStackTrace()) {
+					StackTraceElementBeanImpl stebi = new StackTraceElementBeanImpl();
+					stebi.setClassName(ste.getClassName());
+					stebi.setFileName(ste.getFileName());
+					stebi.setLineNumber(ste.getLineNumber());
+					stebi.setMethodName(ste.getMethodName());
+					edi.stackTrace.add(stebi);
+				}
+			} else
+				edi.setExceptionMessage("");
+			try {
+				errorDao.store(edi);
+			} catch (Throwable t2) {
+				throw new ErrorDocumentServiceException(t2);
+			}
+			if (depth > 0)
+				typedId = typedId.getDeeperErrorReference();
+		}
+		return docToReturn;
+	}
+
+	@Override
+	public ErrorDocument registerError(String message, Set<T2Reference> errors,
+			int depth, ReferenceContext context)
+			throws ErrorDocumentServiceException {
+		checkDao();
+		checkGenerator();
+
+		T2Reference ref = t2ReferenceGenerator.nextErrorDocumentReference(
+				depth, context);
+		T2ReferenceImpl typedId = T2ReferenceImpl.getAsImpl(ref);
+
+		ErrorDocument docToReturn = null;
+		for (; depth >= 0; depth--) {
+			ErrorDocumentImpl edi = new ErrorDocumentImpl();
+			if (docToReturn == null)
+				docToReturn = edi;
+			edi.setTypedId(typedId);
+			if (message != null)
+				edi.setMessage(message);
+			else
+				edi.setMessage("");
+			if (errors != null)
+				edi.setErrorReferenceSet(errors);
+			edi.setExceptionMessage("");
+
+			try {
+				errorDao.store(edi);
+			} catch (Throwable t2) {
+				throw new ErrorDocumentServiceException(t2);
+			}
+			if (depth > 0)
+				typedId = typedId.getDeeperErrorReference();
+		}
+		return docToReturn;
+	}
+
+	@Override
+	public T2Reference getChild(T2Reference errorId)
+			throws ErrorDocumentServiceException {
+		T2ReferenceImpl refImpl = getAsImpl(errorId);
+		try {
+			return refImpl.getDeeperErrorReference();
+		} catch (Throwable t) {
+			throw new ErrorDocumentServiceException(t);
+		}
+	}
+
+	@Override
+	public boolean delete(T2Reference reference)
+			throws ReferenceServiceException {
+		checkDao();
+		ErrorDocument doc = errorDao.get(reference);
+		if (doc == null)
+			return false;
+		return errorDao.delete(doc);
+	}
+
+	@Override
+	public void deleteErrorDocumentsForWorkflowRun(String workflowRunId)
+			throws ReferenceServiceException {
+		checkDao();
+		errorDao.deleteErrorDocumentsForWFRun(workflowRunId);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateErrorDocumentDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateErrorDocumentDao.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateErrorDocumentDao.java
new file mode 100644
index 0000000..fe86880
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateErrorDocumentDao.java
@@ -0,0 +1,153 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import static org.apache.taverna.reference.T2ReferenceType.ErrorDocument;
+
+import java.util.List;
+
+import org.apache.taverna.reference.DaoException;
+import org.apache.taverna.reference.ErrorDocument;
+import org.apache.taverna.reference.ErrorDocumentDao;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.annotations.DeleteIdentifiedOperation;
+import org.apache.taverna.reference.annotations.GetIdentifiedOperation;
+import org.apache.taverna.reference.annotations.PutIdentifiedOperation;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
+
+/**
+ * An implementation of ErrorDocumentDao based on Spring's HibernateDaoSupport.
+ * To use this in spring inject a property 'sessionFactory' with either a
+ * {@link org.springframework.orm.hibernate3.LocalSessionFactoryBean
+ * LocalSessionFactoryBean} or the equivalent class from the T2Platform module
+ * to add SPI based implementation discovery and mapping. To use outside of
+ * Spring ensure you call the setSessionFactory(..) method before using this
+ * (but really, use it from Spring, so much easier).
+ * 
+ * @author Tom Oinn
+ */
+public class HibernateErrorDocumentDao extends HibernateDaoSupport implements
+		ErrorDocumentDao {
+	private static final String GET_ERRORS_FOR_RUN = "FROM ErrorDocumentImpl WHERE namespacePart = :workflow_run_id";
+
+	/**
+	 * Fetch an ErrorDocument list by id
+	 * 
+	 * @param ref
+	 *            the T2Reference to fetch
+	 * @return a retrieved identified list of T2 references
+	 * @throws DaoException
+	 *             if the supplied reference is of the wrong type or if
+	 *             something goes wrong fetching the data or connecting to the
+	 *             database
+	 */
+	@Override
+	@GetIdentifiedOperation
+	public ErrorDocument get(T2Reference ref) throws DaoException {
+		if (ref == null)
+			throw new DaoException(
+					"Supplied reference is null, can't retrieve.");
+		if (!ref.getReferenceType().equals(ErrorDocument))
+			throw new DaoException(
+					"This dao can only retrieve reference of type T2Reference.ErrorDocument");
+		if (!(ref instanceof T2ReferenceImpl))
+			throw new DaoException(
+					"Reference must be an instance of T2ReferenceImpl");
+
+		try {
+			return (ErrorDocumentImpl) getHibernateTemplate().get(
+					ErrorDocumentImpl.class,
+					((T2ReferenceImpl) ref).getCompactForm());
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+
+	@Override
+	@PutIdentifiedOperation
+	public void store(ErrorDocument theDocument) throws DaoException {
+		if (theDocument.getId() == null)
+			throw new DaoException(
+					"Supplied error document set has a null ID, allocate "
+							+ "an ID before calling the store method in the dao.");
+		if (!theDocument.getId().getReferenceType().equals(ErrorDocument))
+			throw new DaoException("Strangely the list ID doesn't have type "
+					+ "T2ReferenceType.ErrorDocument, something has probably "
+					+ "gone badly wrong somewhere earlier!");
+		if (!(theDocument instanceof ErrorDocumentImpl))
+			throw new DaoException(
+					"Supplied ErrorDocument not an instance of ErrorDocumentImpl");
+
+		try {
+			getHibernateTemplate().save(theDocument);
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+
+	@Override
+	@DeleteIdentifiedOperation
+	public boolean delete(ErrorDocument theDocument) throws DaoException {
+		if (theDocument.getId() == null)
+			throw new DaoException(
+					"Supplied error document set has a null ID, allocate "
+							+ "an ID before calling the store method in the dao.");
+		if (!theDocument.getId().getReferenceType()
+				.equals(ErrorDocument))
+			throw new DaoException("Strangely the list ID doesn't have type "
+					+ "T2ReferenceType.ErrorDocument, something has probably "
+					+ "gone badly wrong somewhere earlier!");
+		if (!(theDocument instanceof ErrorDocumentImpl))
+			throw new DaoException(
+					"Supplied ErrorDocument not an instance of ErrorDocumentImpl");
+
+		try {
+			getHibernateTemplate().delete(theDocument);
+			return true;
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+
+	@Override
+	@SuppressWarnings("unchecked")
+	@DeleteIdentifiedOperation
+	public synchronized void deleteErrorDocumentsForWFRun(String workflowRunId)
+			throws DaoException {
+		try {
+			// Select all ErrorDocuments for this wf run
+			Session session = getSession();
+			Query selectQuery = session.createQuery(GET_ERRORS_FOR_RUN);
+			selectQuery.setString("workflow_run_id", workflowRunId);
+			List<ErrorDocument> errorDocuments = selectQuery.list();
+			session.close();
+			/*
+			 * need to close before we do delete otherwise hibernate complains
+			 * that two sessions are accessing collection
+			 */
+			getHibernateTemplate().deleteAll(errorDocuments);
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateListDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateListDao.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateListDao.java
new file mode 100644
index 0000000..f7c0cbd
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateListDao.java
@@ -0,0 +1,150 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import static org.apache.taverna.reference.T2ReferenceType.IdentifiedList;
+
+import java.util.List;
+
+import org.apache.taverna.reference.DaoException;
+import org.apache.taverna.reference.IdentifiedList;
+import org.apache.taverna.reference.ListDao;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.annotations.DeleteIdentifiedOperation;
+import org.apache.taverna.reference.annotations.GetIdentifiedOperation;
+import org.apache.taverna.reference.annotations.PutIdentifiedOperation;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
+
+/**
+ * An implementation of ListDao based on Spring's HibernateDaoSupport. To use
+ * this in spring inject a property 'sessionFactory' with either a
+ * {@link org.springframework.orm.hibernate3.LocalSessionFactoryBean
+ * LocalSessionFactoryBean} or the equivalent class from the T2Platform module
+ * to add SPI based implementation discovery and mapping. To use outside of
+ * Spring ensure you call the setSessionFactory(..) method before using this
+ * (but really, use it from Spring, so much easier).
+ * 
+ * @author Tom Oinn
+ */
+public class HibernateListDao extends HibernateDaoSupport implements ListDao {
+	private static final String GET_LISTS_FOR_RUN = "FROM T2ReferenceListImpl WHERE namespacePart = :workflow_run_id";
+
+	/**
+	 * Fetch a t2reference list by id
+	 * 
+	 * @param ref
+	 *            the T2Reference to fetch
+	 * @return a retrieved identified list of T2 references
+	 * @throws DaoException
+	 *             if the supplied reference is of the wrong type or if
+	 *             something goes wrong fetching the data or connecting to the
+	 *             database
+	 */
+	@Override
+	@GetIdentifiedOperation
+	public IdentifiedList<T2Reference> get(T2Reference ref) throws DaoException {
+		if (ref == null)
+			throw new DaoException(
+					"Supplied reference is null, can't retrieve.");
+		if (!ref.getReferenceType().equals(IdentifiedList))
+			throw new DaoException(
+					"This dao can only retrieve reference of type T2Reference.IdentifiedList");
+		if (!(ref instanceof T2ReferenceImpl))
+			throw new DaoException(
+					"Reference must be an instance of T2ReferenceImpl");
+
+		try {
+			return (T2ReferenceListImpl) getHibernateTemplate().get(
+					T2ReferenceListImpl.class,
+					((T2ReferenceImpl) ref).getCompactForm());
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+
+	@Override
+	@PutIdentifiedOperation
+	public void store(IdentifiedList<T2Reference> theList) throws DaoException {
+		if (theList.getId() == null)
+			throw new DaoException("Supplied list set has a null ID, allocate "
+					+ "an ID before calling the store method in the dao.");
+		if (!theList.getId().getReferenceType().equals(IdentifiedList))
+			throw new DaoException("Strangely the list ID doesn't have type "
+					+ "T2ReferenceType.IdentifiedList, something has probably "
+					+ "gone badly wrong somewhere earlier!");
+		if (!(theList instanceof T2ReferenceListImpl))
+			throw new DaoException(
+					"Supplied identifier list not an instance of T2ReferenceList");
+
+		try {
+			getHibernateTemplate().save(theList);
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+
+	@Override
+	public boolean delete(IdentifiedList<T2Reference> theList)
+			throws DaoException {
+		if (theList.getId() == null)
+			throw new DaoException("Supplied list set has a null ID, allocate "
+					+ "an ID before calling the store method in the dao.");
+		if (!theList.getId().getReferenceType().equals(IdentifiedList))
+			throw new DaoException("Strangely the list ID doesn't have type "
+					+ "T2ReferenceType.IdentifiedList, something has probably "
+					+ "gone badly wrong somewhere earlier!");
+		if (!(theList instanceof T2ReferenceListImpl))
+			throw new DaoException(
+					"Supplied identifier list not an instance of T2ReferenceList");
+
+		try {
+			getHibernateTemplate().delete(theList);
+			return true;
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+
+	@Override
+	@SuppressWarnings("unchecked")
+	@DeleteIdentifiedOperation
+	public synchronized void deleteIdentifiedListsForWFRun(String workflowRunId)
+			throws DaoException {
+		try {
+			// Select all T2Reference lists for this wf run
+			Session session = getSession();
+			Query selectQuery = session.createQuery(GET_LISTS_FOR_RUN);
+			selectQuery.setString("workflow_run_id", workflowRunId);
+			List<IdentifiedList<T2Reference>> identifiedLists = selectQuery
+					.list();
+			session.close();
+			/*
+			 * need to close before we do delete otherwise hibernate complains
+			 * that two sessions are accessing collection
+			 */
+			getHibernateTemplate().deleteAll(identifiedLists);
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateReferenceSetDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateReferenceSetDao.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateReferenceSetDao.java
new file mode 100644
index 0000000..c710aa7
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateReferenceSetDao.java
@@ -0,0 +1,197 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program 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 program 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 program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package org.apache.taverna.reference.impl;
+
+import static org.apache.taverna.reference.T2ReferenceType.ReferenceSet;
+
+import java.util.List;
+
+import org.apache.taverna.reference.DaoException;
+import org.apache.taverna.reference.ReferenceSet;
+import org.apache.taverna.reference.ReferenceSetDao;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.annotations.DeleteIdentifiedOperation;
+import org.apache.taverna.reference.annotations.GetIdentifiedOperation;
+import org.apache.taverna.reference.annotations.PutIdentifiedOperation;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
+
+/**
+ * An implementation of ReferenceSetDao based on Spring's HibernateDaoSupport.
+ * To use this in spring inject a property 'sessionFactory' with either a
+ * {@link org.springframework.orm.hibernate3.LocalSessionFactoryBean
+ * LocalSessionFactoryBean} or the equivalent class from the T2Platform module
+ * to add SPI based implementation discovery and mapping. To use outside of
+ * Spring ensure you call the setSessionFactory(..) method before using this
+ * (but really, use it from Spring, so much easier).
+ * 
+ * @author Tom Oinn
+ */
+public class HibernateReferenceSetDao extends HibernateDaoSupport implements
+		ReferenceSetDao {
+	private static final String GET_REFSETS_FOR_RUN = "FROM ReferenceSetImpl WHERE namespacePart = :workflow_run_id";
+
+	/**
+	 * Store the specified new reference set
+	 * 
+	 * @param rs
+	 *            a reference set, must not already exist in the database.
+	 * @throws DaoException
+	 *             if the entry already exists in the database, if the supplied
+	 *             reference set isn't an instance of ReferenceSetImpl or if
+	 *             something else goes wrong connecting to the database
+	 */
+	@Override
+	@PutIdentifiedOperation
+	public void store(ReferenceSet rs) throws DaoException {
+		if (rs.getId() == null)
+			throw new DaoException(
+					"Supplied reference set has a null ID, allocate "
+							+ "an ID before calling the store method in the dao.");
+		if (!rs.getId().getReferenceType().equals(ReferenceSet))
+			throw new DaoException(
+					"Strangely the reference set ID doesn't have type "
+							+ "T2ReferenceType.ReferenceSet, something has probably "
+							+ "gone badly wrong somewhere earlier!");
+		if (!(rs instanceof ReferenceSetImpl))
+			throw new DaoException(
+					"Supplied reference set not an instance of ReferenceSetImpl");
+
+		try {
+			getHibernateTemplate().save(rs);
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+
+	/**
+	 * Update a pre-existing entry in the database
+	 * 
+	 * @param rs
+	 *            the reference set to update. This must already exist in the
+	 *            database
+	 * @throws DaoException
+	 */
+	@Override
+	@PutIdentifiedOperation
+	public void update(ReferenceSet rs) throws DaoException {
+		if (rs.getId() == null)
+			throw new DaoException(
+					"Supplied reference set has a null ID, allocate "
+							+ "an ID before calling the store method in the dao.");
+		if (!rs.getId().getReferenceType().equals(ReferenceSet))
+			throw new DaoException(
+					"Strangely the reference set ID doesn't have type "
+							+ "T2ReferenceType.ReferenceSet, something has probably "
+							+ "gone badly wrong somewhere earlier!");
+		if (!(rs instanceof ReferenceSetImpl))
+			throw new DaoException(
+					"Supplied reference set not an instance of ReferenceSetImpl");
+
+		try {
+			getHibernateTemplate().update(rs);
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+
+	/**
+	 * Fetch a reference set by id
+	 * 
+	 * @param ref
+	 *            the ReferenceSetT2ReferenceImpl to fetch
+	 * @return a retrieved ReferenceSetImpl
+	 * @throws DaoException
+	 *             if the supplied reference is of the wrong type or if
+	 *             something goes wrong fetching the data or connecting to the
+	 *             database
+	 */
+	@Override
+	@GetIdentifiedOperation
+	public ReferenceSetImpl get(T2Reference ref) throws DaoException {
+		if (ref == null)
+			throw new DaoException(
+					"Supplied reference is null, can't retrieve.");
+		if (!ref.getReferenceType().equals(ReferenceSet))
+			throw new DaoException(
+					"This dao can only retrieve reference of type T2Reference.ReferenceSet");
+		if (!(ref instanceof T2ReferenceImpl))
+			throw new DaoException(
+					"Reference must be an instance of T2ReferenceImpl");
+
+		try {
+			return (ReferenceSetImpl) getHibernateTemplate().get(
+					ReferenceSetImpl.class,
+					((T2ReferenceImpl) ref).getCompactForm());
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+
+	@Override
+	@DeleteIdentifiedOperation
+	public boolean delete(ReferenceSet rs) throws DaoException {
+		if (rs.getId() == null)
+			throw new DaoException(
+					"Supplied reference set has a null ID, allocate "
+							+ "an ID before calling the store method in the dao.");
+		if (!rs.getId().getReferenceType().equals(ReferenceSet))
+			throw new DaoException(
+					"Strangely the reference set ID doesn't have type "
+							+ "T2ReferenceType.ReferenceSet, something has probably "
+							+ "gone badly wrong somewhere earlier!");
+		if (!(rs instanceof ReferenceSetImpl))
+			throw new DaoException(
+					"Supplied reference set not an instance of ReferenceSetImpl");
+
+		try {
+			getHibernateTemplate().delete(rs);
+			return true;
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+
+	@Override
+	@SuppressWarnings("unchecked")
+	@DeleteIdentifiedOperation
+	public synchronized void deleteReferenceSetsForWFRun(String workflowRunId)
+			throws DaoException {
+		try {
+			// Select all ReferenceSets for this wf run
+			Session session = getSession();
+			Query selectQuery = session
+					.createQuery(GET_REFSETS_FOR_RUN);
+			selectQuery.setString("workflow_run_id", workflowRunId);
+			List<ReferenceSet> referenceSets = selectQuery.list();
+			session.close();
+			/*
+			 * need to close before we do delete otherwise hibernate complains
+			 * that two sessions are accessing collection
+			 */
+			getHibernateTemplate().deleteAll(referenceSets);
+		} catch (Exception ex) {
+			throw new DaoException(ex);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/IdentifiedArrayList.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/IdentifiedArrayList.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/IdentifiedArrayList.java
new file mode 100644
index 0000000..43325dc
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/IdentifiedArrayList.java
@@ -0,0 +1,252 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program 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 program 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 program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package org.apache.taverna.reference.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.apache.taverna.reference.IdentifiedList;
+
+/**
+ * Implementation of IdentifiedList which delegates to an ArrayList for its
+ * storage functionality.
+ * 
+ * @author Tom Oinn
+ * 
+ * @param <T>
+ */
+public class IdentifiedArrayList<T> extends AbstractEntityImpl implements
+		IdentifiedList<T> {
+	protected List<T> listDelegate = null;
+
+	// Constructors copied from ArrayList for convenience
+	public IdentifiedArrayList() {
+		super();
+		this.listDelegate = new ArrayList<>();
+	}
+
+	public IdentifiedArrayList(Collection<T> c) {
+		super();
+		this.listDelegate = new ArrayList<>(c);
+	}
+
+	public IdentifiedArrayList(int initialCapacity) {
+		super();
+		this.listDelegate = new ArrayList<>(initialCapacity);
+	}
+
+	private void checkUndefinedId() {
+		if (this.getId() != null)
+			throw new IllegalStateException(
+					"Attempt made to modify a list which has already been named");
+	}
+
+	@Override
+	public boolean add(T e) {
+		checkUndefinedId();
+		return listDelegate.add(e);
+	}
+
+	@Override
+	public void add(int index, T element) {
+		checkUndefinedId();
+		listDelegate.add(index, element);
+	}
+
+	@Override
+	public boolean addAll(Collection<? extends T> c) {
+		checkUndefinedId();
+		return listDelegate.addAll(c);
+	}
+
+	@Override
+	public boolean addAll(int index, Collection<? extends T> c) {
+		checkUndefinedId();
+		return listDelegate.addAll(index, c);
+	}
+
+	@Override
+	public void clear() {
+		checkUndefinedId();
+		listDelegate.clear();
+	}
+
+	@Override
+	public boolean contains(Object o) {
+		return listDelegate.contains(o);
+	}
+
+	@Override
+	public boolean containsAll(Collection<?> c) {
+		return listDelegate.containsAll(c);
+	}
+
+	@Override
+	public T get(int index) {
+		return listDelegate.get(index);
+	}
+
+	@Override
+	public int indexOf(Object o) {
+		return listDelegate.indexOf(o);
+	}
+
+	@Override
+	public boolean isEmpty() {
+		return listDelegate.isEmpty();
+	}
+
+	@Override
+	public Iterator<T> iterator() {
+		return listDelegate.iterator();
+	}
+
+	@Override
+	public int lastIndexOf(Object o) {
+		return listDelegate.lastIndexOf(o);
+	}
+
+	/**
+	 * The ListIterator can modify the list contents, so wrap the delegate's
+	 * list iterator and use as a delegate itself, checking for null ID on
+	 * operations which set list properties.
+	 * 
+	 * @param iteratorDelegate
+	 *            ListIterator to wrap.
+	 * @return wrapped ListIterator which throws IllegalStateException on calls
+	 *         which modify the list if the ID has been set to a non-null value
+	 */
+	private ListIterator<T> getCheckedListIterator(
+			final ListIterator<T> iteratorDelegate) {
+		return new ListIterator<T>() {
+			@Override
+			public void add(T e) {
+				checkUndefinedId();
+				iteratorDelegate.add(e);
+			}
+
+			@Override
+			public boolean hasNext() {
+				return iteratorDelegate.hasNext();
+			}
+
+			@Override
+			public boolean hasPrevious() {
+				return iteratorDelegate.hasPrevious();
+			}
+
+			@Override
+			public T next() {
+				return iteratorDelegate.next();
+			}
+
+			@Override
+			public int nextIndex() {
+				return iteratorDelegate.nextIndex();
+			}
+
+			@Override
+			public T previous() {
+				return iteratorDelegate.previous();
+			}
+
+			@Override
+			public int previousIndex() {
+				return iteratorDelegate.previousIndex();
+			}
+
+			@Override
+			public void remove() {
+				checkUndefinedId();
+				iteratorDelegate.remove();
+			}
+
+			@Override
+			public void set(T e) {
+				checkUndefinedId();
+				iteratorDelegate.set(e);
+			}
+		};
+	}
+
+	@Override
+	public ListIterator<T> listIterator() {
+		return getCheckedListIterator(listDelegate.listIterator());
+	}
+
+	@Override
+	public ListIterator<T> listIterator(int index) {
+		return getCheckedListIterator(listDelegate.listIterator(index));
+	}
+
+	@Override
+	public boolean remove(Object o) {
+		checkUndefinedId();
+		return listDelegate.remove(o);
+	}
+
+	@Override
+	public T remove(int index) {
+		checkUndefinedId();
+		return listDelegate.remove(index);
+	}
+
+	@Override
+	public boolean removeAll(Collection<?> c) {
+		checkUndefinedId();
+		return listDelegate.removeAll(c);
+	}
+
+	@Override
+	public boolean retainAll(Collection<?> c) {
+		checkUndefinedId();
+		return listDelegate.retainAll(c);
+	}
+
+	@Override
+	public T set(int index, T element) {
+		checkUndefinedId();
+		return listDelegate.set(index, element);
+	}
+
+	@Override
+	public int size() {
+		return listDelegate.size();
+	}
+
+	@Override
+	public List<T> subList(int fromIndex, int toIndex) {
+		return listDelegate.subList(fromIndex, toIndex);
+	}
+
+	@Override
+	public Object[] toArray() {
+		return listDelegate.toArray();
+	}
+
+	@Override
+	public <U> U[] toArray(U[] a) {
+		return listDelegate.toArray(a);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/InMemoryErrorDocumentDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/InMemoryErrorDocumentDao.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/InMemoryErrorDocumentDao.java
new file mode 100644
index 0000000..d06ecbe
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/InMemoryErrorDocumentDao.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program 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 program 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 program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package org.apache.taverna.reference.impl;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.taverna.reference.DaoException;
+import org.apache.taverna.reference.ErrorDocument;
+import org.apache.taverna.reference.ErrorDocumentDao;
+import org.apache.taverna.reference.T2Reference;
+
+/**
+ * A trivial in-memory implementation of ErrorDocumentDao for either testing or
+ * very lightweight embedded systems. Uses a java Map as the backing store.
+ * 
+ * @author Tom Oinn
+ */
+public class InMemoryErrorDocumentDao implements ErrorDocumentDao {
+	private Map<T2Reference, ErrorDocument> store;
+
+	public InMemoryErrorDocumentDao() {
+		this.store = new ConcurrentHashMap<>();
+	}
+
+	@Override
+	public synchronized ErrorDocument get(T2Reference reference)
+			throws DaoException {
+		return store.get(reference);
+	}
+
+	@Override
+	public synchronized void store(ErrorDocument theDoc) throws DaoException {
+		store.put(theDoc.getId(), theDoc);
+	}
+
+	@Override
+	public synchronized boolean delete(ErrorDocument theDoc)
+			throws DaoException {
+		return store.remove(theDoc.getId()) != null;
+	}
+
+	@Override
+	public synchronized void deleteErrorDocumentsForWFRun(String workflowRunId)
+			throws DaoException {
+		for (T2Reference reference : store.keySet())
+			if (reference.getNamespacePart().equals(workflowRunId))
+				store.remove(reference);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/InMemoryListDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/InMemoryListDao.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/InMemoryListDao.java
new file mode 100644
index 0000000..00bb188
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/InMemoryListDao.java
@@ -0,0 +1,68 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.taverna.reference.DaoException;
+import org.apache.taverna.reference.IdentifiedList;
+import org.apache.taverna.reference.ListDao;
+import org.apache.taverna.reference.T2Reference;
+
+/**
+ * A trivial in-memory implementation of ListDao for either testing or very
+ * lightweight embedded systems. Uses a java Map as the backing store.
+ * 
+ * @author Tom Oinn
+ */
+public class InMemoryListDao implements ListDao {
+	private Map<T2Reference, IdentifiedList<T2Reference>> store;
+
+	public InMemoryListDao() {
+		this.store = new ConcurrentHashMap<>();
+	}
+
+	@Override
+	public synchronized IdentifiedList<T2Reference> get(T2Reference reference)
+			throws DaoException {
+		return store.get(reference);
+	}
+
+	@Override
+	public synchronized void store(IdentifiedList<T2Reference> theList)
+			throws DaoException {
+		store.put(theList.getId(), theList);
+	}
+
+	@Override
+	public boolean delete(IdentifiedList<T2Reference> theList)
+			throws DaoException {
+		return (store.remove(theList.getId()) != null);
+	}
+
+	@Override
+	public synchronized void deleteIdentifiedListsForWFRun(String workflowRunId)
+			throws DaoException {
+		for (T2Reference reference : store.keySet())
+			if (reference.getNamespacePart().equals(workflowRunId))
+				store.remove(reference);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/InMemoryReferenceSetDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/InMemoryReferenceSetDao.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/InMemoryReferenceSetDao.java
new file mode 100644
index 0000000..76c0e56
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/InMemoryReferenceSetDao.java
@@ -0,0 +1,71 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.taverna.reference.DaoException;
+import org.apache.taverna.reference.ReferenceSet;
+import org.apache.taverna.reference.ReferenceSetDao;
+import org.apache.taverna.reference.T2Reference;
+
+/**
+ * A trivial in-memory implementation of ReferenceSetDao for either testing or
+ * very lightweight embedded systems. Uses a java Map as the backing store.
+ * 
+ * @author Tom Oinn
+ */
+public class InMemoryReferenceSetDao implements ReferenceSetDao {
+	private Map<T2Reference, ReferenceSet> store;
+
+	public InMemoryReferenceSetDao() {
+		this.store = new ConcurrentHashMap<>();
+	}
+
+	@Override
+	public synchronized ReferenceSet get(T2Reference reference)
+			throws DaoException {
+		return store.get(reference);
+	}
+
+	@Override
+	public synchronized void store(ReferenceSet refSet) throws DaoException {
+		store.put(refSet.getId(), refSet);
+	}
+
+	@Override
+	public synchronized void update(ReferenceSet refSet) throws DaoException {
+		store.put(refSet.getId(), refSet);
+	}
+
+	@Override
+	public synchronized boolean delete(ReferenceSet refSet) throws DaoException {
+		return store.remove(refSet.getId()) != null;
+	}
+
+	@Override
+	public synchronized void deleteReferenceSetsForWFRun(String workflowRunId)
+			throws DaoException {
+		for (T2Reference reference : store.keySet())
+			if (reference.getNamespacePart().equals(workflowRunId))
+				store.remove(reference);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ListServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ListServiceImpl.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ListServiceImpl.java
new file mode 100644
index 0000000..5cc1d60
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/ListServiceImpl.java
@@ -0,0 +1,135 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import static org.apache.taverna.reference.impl.T2ReferenceImpl.getAsImpl;
+
+import java.util.List;
+
+import org.apache.taverna.reference.DaoException;
+import org.apache.taverna.reference.IdentifiedList;
+import org.apache.taverna.reference.ListService;
+import org.apache.taverna.reference.ListServiceException;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferenceServiceException;
+import org.apache.taverna.reference.T2Reference;
+
+/**
+ * Implementation of ListService, inject with an appropriate ListDao and
+ * T2ReferenceGenerator to enable.
+ * 
+ * @author Tom Oinn
+ */
+public class ListServiceImpl extends AbstractListServiceImpl implements
+		ListService {
+	@Override
+	public IdentifiedList<T2Reference> getList(T2Reference id)
+			throws ListServiceException {
+		checkDao();
+		try {
+			return listDao.get(id);
+		} catch (DaoException de) {
+			throw new ListServiceException(de);
+		}
+	}
+
+	@Override
+	public IdentifiedList<T2Reference> registerEmptyList(int depth,
+			ReferenceContext context) throws ListServiceException {
+		if (depth < 1)
+			throw new ListServiceException(
+					"Can't register empty lists of depth " + depth);
+		checkDao();
+		checkGenerator();
+		T2ReferenceImpl newReference = getAsImpl(t2ReferenceGenerator
+				.nextListReference(false, depth, context));
+		T2ReferenceListImpl newList = new T2ReferenceListImpl();
+		newList.setTypedId(newReference);
+		try {
+			listDao.store(newList);
+			return newList;
+		} catch (DaoException de) {
+			throw new ListServiceException(de);
+		}
+	}
+
+	@Override
+	public IdentifiedList<T2Reference> registerList(List<T2Reference> items,
+			ReferenceContext context) throws ListServiceException {
+		checkDao();
+		checkGenerator();
+		if (items.isEmpty())
+			throw new ListServiceException(
+					"Can't register an empty list with this method,"
+							+ " use the registerEmptyList instead");
+		/*
+		 * Track whether there are any items in the collection which are or
+		 * contain error documents.
+		 */
+		boolean containsErrors = false;
+		// Track depth, ensure that all items have the same depth, fail if not.
+		int depth = items.get(0).getDepth();
+		if (depth < 0)
+			throw new ListServiceException(
+					"Can't register list of depth less than 1, but first item "
+							+ items.get(0) + " has depth " + depth);
+		T2ReferenceListImpl newList = new T2ReferenceListImpl();
+		int counter = 0;
+		for (T2Reference ref : items) {
+			if (ref.getDepth() != depth)
+				throw new ListServiceException(
+						"Mismatched depths in list registration; reference at index '"
+								+ counter + "' has depth " + ref.getDepth()
+								+ " but all preceeding items have depth "
+								+ depth);
+			if (ref.containsErrors())
+				// The collection's reference contains errors if any child does
+				containsErrors = true;
+			newList.add(ref);
+			counter++;
+		}
+		try {
+			T2ReferenceImpl newReference = getAsImpl(t2ReferenceGenerator
+					.nextListReference(containsErrors, depth + 1, context));
+			newList.setTypedId(newReference);
+			listDao.store(newList);
+			return newList;
+		} catch (Throwable t) {
+			throw new ListServiceException(t);
+		}
+	}
+
+	@Override
+	public boolean delete(T2Reference reference)
+			throws ReferenceServiceException {
+		checkDao();
+		IdentifiedList<T2Reference> list = listDao.get(reference);
+		if (list == null)
+			return false;
+		return listDao.delete(list);
+	}
+
+	@Override
+	public void deleteIdentifiedListsForWorkflowRun(String workflowRunId)
+			throws ReferenceServiceException {
+		checkDao();
+		listDao.deleteIdentifiedListsForWFRun(workflowRunId);
+	}
+}


[06/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/AnnotationAssertionImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/AnnotationAssertionImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/AnnotationAssertionImpl.java
deleted file mode 100644
index cb63cd6..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/AnnotationAssertionImpl.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation.impl;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import net.sf.taverna.t2.annotation.AnnotationAssertion;
-import net.sf.taverna.t2.annotation.AnnotationBeanSPI;
-import net.sf.taverna.t2.annotation.AnnotationRole;
-import net.sf.taverna.t2.annotation.AnnotationSourceSPI;
-import net.sf.taverna.t2.annotation.CurationEvent;
-import net.sf.taverna.t2.annotation.Person;
-
-public class AnnotationAssertionImpl implements AnnotationAssertion<AnnotationBeanSPI> {
-	
-	private AnnotationBeanSPI annotationBean;
-	private AnnotationRole annotationRole;
-	private Date date;
-	private List<Person> creators;
-	private AnnotationSourceSPI annotationSource;
-	private List<CurationEvent<?>> curationEventList;
-
-	public AnnotationAssertionImpl(){
-		date = new Date();
-		curationEventList = new ArrayList<CurationEvent<?>>();
-		creators = new ArrayList<Person>();
-		
-	}
-	
-	public AnnotationAssertionImpl(AnnotationBeanSPI freeTextDescription, AnnotationRole annotationRole, List<Person> creators, AnnotationSourceSPI annotationSource) {
-		this.annotationBean = freeTextDescription;
-		this.annotationRole = annotationRole;
-		this.creators = creators;
-		this.annotationSource = annotationSource;
-	}
-
-	@Override
-	public AnnotationBeanSPI getDetail() {
-		return annotationBean;
-	}
-
-	@Override
-	public AnnotationRole getRole() {
-		return annotationRole;
-	}
-
-	@Override
-	public Date getCreationDate() {
-		return date;
-	}
-
-	@Override
-	public List<? extends Person> getCreators() {
-		return creators;
-	}
-	
-	public void addCreator(Person person) {
-		creators.add(person);
-	}
-	
-	public void removeCreator(Person person) {
-		creators.remove(person);
-	}
-
-	@Override
-	public List<CurationEvent<?>> getCurationAssertions() {
-		return curationEventList;
-	}
-
-	@Override
-	public AnnotationSourceSPI getSource() {
-		return annotationSource;
-	}
-
-	public void setAnnotationBean(AnnotationBeanSPI annotationBean) {
-		this.annotationBean = annotationBean;
-	}
-
-	public void setAnnotationRole(AnnotationRole annotationRole) {
-		this.annotationRole = annotationRole;
-	}
-	
-	public void removeAnnotationRole() {
-		this.annotationRole = null;
-	}
-
-	public void setDate(Date date) {
-		this.date = date;
-	}
-
-	public void setCreators(List<Person> creators) {
-		this.creators = creators;
-	}
-
-	public void setAnnotationSource(AnnotationSourceSPI annotationSource) {
-		this.annotationSource = annotationSource;
-	}
-	
-	public void removeAnnotationSource() {
-		this.annotationSource = null;
-	}
-
-	public void removeAnnotationBean() {
-		annotationBean = null;
-	}
-	
-	public void addCurationEvent(CurationEvent<?> curationEvent) {
-		curationEventList.add(curationEvent);
-	}
-
-	public void removeCurationEvent(CurationEvent<?> curationEvent) {
-		curationEventList.remove(curationEvent);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/AnnotationChainImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/AnnotationChainImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/AnnotationChainImpl.java
deleted file mode 100644
index 452044d..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/AnnotationChainImpl.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sf.taverna.t2.annotation.AnnotationAssertion;
-import net.sf.taverna.t2.annotation.AnnotationChain;
-
-public class AnnotationChainImpl implements AnnotationChain{
-	private List<AnnotationAssertion<?>> annotationAssertions = new ArrayList<>();
-
-	@Override
-	public List<AnnotationAssertion<?>> getAssertions() {
-		return new ArrayList<>(annotationAssertions);
-	}
-	
-	/**
-	 * Add an annotation to the chain Added because without the edits stuff how
-	 * else can we do it?
-	 * 
-	 * @param annotationAssertion
-	 */
-	public void addAnnotationAssertion(AnnotationAssertion<?> annotationAssertion) {
-		annotationAssertions.add(annotationAssertion);
-	}
-	
-	public void removeAnnotationAssertion(AnnotationAssertion<?> annotationAssertion) {
-		annotationAssertions.remove(annotationAssertion);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/DisputeEvent.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/DisputeEvent.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/DisputeEvent.java
deleted file mode 100644
index 151768f..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/DisputeEvent.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation.impl;
-
-import net.sf.taverna.t2.annotation.Curateable;
-import net.sf.taverna.t2.annotation.CurationEvent;
-import net.sf.taverna.t2.annotation.CurationEventType;
-
-public class DisputeEvent implements CurationEvent<DisputeEventDetails> {
-	private DisputeEventDetails disputeEventDetails;
-	private CurationEventType curationEventType;
-	private Curateable targetEvent;
-
-	public DisputeEvent() {
-	}
-
-	public DisputeEvent(DisputeEventDetails disputeEventDetails,
-			CurationEventType curationEventType, Curateable targetEvent) {
-		this.disputeEventDetails = disputeEventDetails;
-		this.curationEventType = curationEventType;
-		this.targetEvent = targetEvent;
-	}
-
-	@Override
-	public DisputeEventDetails getDetail() {
-		return disputeEventDetails;
-	}
-
-	@Override
-	public Curateable getTarget() {
-		return targetEvent;
-	}
-
-	@Override
-	public CurationEventType getType() {
-		return curationEventType;
-	}
-
-	public void setDisputeEventDetails(DisputeEventDetails disputeEventDetails) {
-//		if (disputeEventDetails != null)
-//			throw new RuntimeException("Dispute event details have already been set");
-		this.disputeEventDetails = disputeEventDetails;
-	}
-
-	public void setCurationEventType(CurationEventType curationEventType) {
-//		if (curationEventType != null)
-//			throw new RuntimeException("Curation event details have already been set");
-		this.curationEventType = curationEventType;
-	}
-
-	public void setTargetEvent(Curateable targetEvent) {
-//		if (targetEvent!= null)
-//			throw new RuntimeException("Target event details have already been set");
-		this.targetEvent = targetEvent;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/DisputeEventDetails.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/DisputeEventDetails.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/DisputeEventDetails.java
deleted file mode 100644
index 55aed16..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/DisputeEventDetails.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation.impl;
-
-import net.sf.taverna.t2.annotation.CurationEventBeanSPI;
-
-public class DisputeEventDetails implements CurationEventBeanSPI {
-	public DisputeEventDetails() {
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/PersonImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/PersonImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/PersonImpl.java
deleted file mode 100644
index 8a80e81..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/PersonImpl.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation.impl;
-
-import net.sf.taverna.t2.annotation.Person;
-
-public class PersonImpl implements Person {
-	@SuppressWarnings("unused")
-	private String name;
-
-	public PersonImpl(String name) {
-		this.name = name;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/URISource.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/URISource.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/URISource.java
deleted file mode 100644
index 7cee476..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/annotation/impl/URISource.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation.impl;
-
-import java.net.URI;
-
-import net.sf.taverna.t2.annotation.AnnotationSourceSPI;
-
-public class URISource implements AnnotationSourceSPI{
-	private URI uri;
-
-	public URISource() {
-	}
-
-	public URISource(URI uri) {
-		this.uri = uri;
-	}
-
-	public void setUri(URI uri) {
-//		if (uri != null)
-//			throw new RuntimeException("URI has already been set");
-		this.uri = uri;
-	}
-
-	public URI getUri() {
-		return uri;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/facade/impl/WorkflowInstanceFacadeImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/facade/impl/WorkflowInstanceFacadeImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/facade/impl/WorkflowInstanceFacadeImpl.java
deleted file mode 100644
index a21fae6..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/facade/impl/WorkflowInstanceFacadeImpl.java
+++ /dev/null
@@ -1,631 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.facade.impl;
-
-import static java.lang.System.currentTimeMillis;
-import static java.util.Collections.synchronizedList;
-import static java.util.UUID.randomUUID;
-
-import java.lang.ref.WeakReference;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.UUID;
-import java.util.WeakHashMap;
-import java.util.concurrent.atomic.AtomicLong;
-
-import net.sf.taverna.t2.facade.FacadeListener;
-import net.sf.taverna.t2.facade.ResultListener;
-import net.sf.taverna.t2.facade.WorkflowInstanceFacade;
-import net.sf.taverna.t2.facade.WorkflowRunCancellation;
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.invocation.TokenOrderException;
-import net.sf.taverna.t2.invocation.WorkflowDataToken;
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.lang.observer.Observer;
-import net.sf.taverna.t2.monitor.MonitorManager;
-import net.sf.taverna.t2.monitor.MonitorNode;
-import net.sf.taverna.t2.monitor.MonitorableProperty;
-import net.sf.taverna.t2.monitor.NoSuchPropertyException;
-import net.sf.taverna.t2.provenance.item.DataflowRunComplete;
-import net.sf.taverna.t2.provenance.item.WorkflowDataProvenanceItem;
-import net.sf.taverna.t2.provenance.item.WorkflowProvenanceItem;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.WorkflowRunIdEntity;
-import net.sf.taverna.t2.utility.TypedTreeModel;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import net.sf.taverna.t2.workflowmodel.DataflowInputPort;
-import net.sf.taverna.t2.workflowmodel.DataflowOutputPort;
-import net.sf.taverna.t2.workflowmodel.DataflowValidationReport;
-import net.sf.taverna.t2.workflowmodel.EditException;
-import net.sf.taverna.t2.workflowmodel.Edits;
-import net.sf.taverna.t2.workflowmodel.InvalidDataflowException;
-import net.sf.taverna.t2.workflowmodel.Processor;
-import net.sf.taverna.t2.workflowmodel.ProcessorFinishedEvent;
-import net.sf.taverna.t2.workflowmodel.impl.EditsImpl;
-import net.sf.taverna.t2.workflowmodel.impl.ProcessorImpl;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchLayer;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchStack;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.ErrorBounce;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.IntermediateProvenance;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.Parallelize;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.Stop;
-
-import org.apache.log4j.Logger;
-
-/**
- * Implementation of {@link WorkflowInstanceFacade}
- * 
- * @author Tom Oinn
- * @author Stian Soiland-Reyes
- * @author Ian Dunlop
- * @author Alex Nenadic
- */
-public class WorkflowInstanceFacadeImpl implements WorkflowInstanceFacade {
-	private static Logger logger = Logger
-			.getLogger(WorkflowInstanceFacadeImpl.class);
-
-	protected static AtomicLong owningProcessId = new AtomicLong(0);
-	private InvocationContext context;	
-	private State state = State.prepared;
-	public Date stateLastModified = new Date();
-
-	@Override
-	public InvocationContext getContext() {
-		return context;
-	}
-
-	private Dataflow dataflow;
-	private FacadeResultListener facadeResultListener;
-	/** How many processors have finished so far */
-	private int processorsToComplete;
-	private String instanceOwningProcessId;
-	private String localName;
-	private MonitorManager monitorManager = MonitorManager.getInstance();
-	protected List<FacadeListener> facadeListeners = synchronizedList(new ArrayList<FacadeListener>());
-	protected List<ResultListener> resultListeners = synchronizedList(new ArrayList<ResultListener>());
-	private boolean provEnabled = false;
-	private WeakHashMap<String, T2Reference> pushedDataMap = new WeakHashMap<>();
-	/** Id of this run */
-	private String workflowRunId;
-	private Timestamp workflowStarted;
-	private WorkflowProvenanceItem workflowItem = null;
-	private int portsToComplete;
-	
-	private enum WorkflowInstanceFacadeChange {
-		CANCELLATION, PORT_DECREMENT, PROCESSOR_DECREMENT
-	};
-
-	public WorkflowInstanceFacadeImpl(Dataflow dataflow,
-			InvocationContext context, String parentProcess)
-			throws InvalidDataflowException {
-		if (dataflow == null) {
-			logger.error("Dataflow is null");
-			throw new IllegalArgumentException("Dataflow is null");
-		}
-		DataflowValidationReport report = dataflow.checkValidity();
-		if (!report.isValid())
-			throw new InvalidDataflowException(dataflow, report);
-
-		this.dataflow = dataflow;
-		this.context = context;
-		this.portsToComplete = dataflow.getOutputPorts().size();
-		this.processorsToComplete = dataflow.getProcessors().size();
-		this.localName = "facade" + owningProcessId.getAndIncrement();
-		// Set the wf run id
-		workflowRunId = UUID.randomUUID().toString();
-		if (parentProcess.isEmpty()) {
-			// Top-level workflow
-			
-			/*
-			 * add top level workflow run so that reference service can generate
-			 * identifiers linked to our run
-			 */
-			context.addEntity(new WorkflowRunIdEntity(workflowRunId));
-			this.instanceOwningProcessId = localName;
-			
-			/*
-			 * Add this WorkflowInstanceFacade to the map of all workflow run
-			 * IDs against the corresponding WorkflowInstanceFacadeS/ - to be
-			 * used by DependencyActivity's such as API consumer and Beanshell
-			 */
-			workflowRunFacades.put(localName, new WeakReference<WorkflowInstanceFacade>(this));
-			/*
-			 * Note that we do not put the IDs for nested workflows, just for
-			 * the main ones!
-			 */
-		} else {
-			// Nested workflow
-			this.instanceOwningProcessId = parentProcess + ":" + localName;
-		}		
-				
-		if (context.getProvenanceReporter() != null) {
-			provEnabled = true;
-			workflowItem = new WorkflowProvenanceItem();
-			workflowItem.setDataflow(dataflow);
-			workflowItem.setProcessId(instanceOwningProcessId);
-			workflowItem.setIdentifier(workflowRunId);
-			workflowItem.setParentId(dataflow.getIdentifier());
-			workflowItem.setWorkflowId(dataflow.getIdentifier());
-			
-			/*
-			 * FIXME: workflowItem is local to each instanceOwningProcessId, but
-			 * might be added to the Processor within different concurrent runs.
-			 * (T3-930)
-			 */
-			addProvenanceLayerToProcessors(workflowItem);
-			context.getProvenanceReporter().setSessionID(workflowRunId);
-		}
-		facadeResultListener = new FacadeResultListener(dataflow, workflowItem);
-		
-		// Register an observer with each of the processors
-		for (Processor processor : dataflow.getProcessors()) {
-			String expectedProcessId = instanceOwningProcessId + ":"
-					+ dataflow.getLocalName() + ":" + processor.getLocalName();
-			ProcessorFinishedObserver observer = new ProcessorFinishedObserver(
-					workflowItem, expectedProcessId);
-			((ProcessorImpl) processor).addObserver(observer);
-		}
-	}
-
-	private void addProvenanceLayerToProcessors(WorkflowProvenanceItem workflowItem) {
-		// TODO Shouldn't we use a bean for this? 
-		Edits edits = new EditsImpl();
-		for (Processor processor : dataflow.getProcessors())
-			/*
-			 * Synchronized per processor as we might be modifying its dispatch
-			 * stack (fixes T3-929)
-			 */
-		    synchronized (processor) {               
-		        DispatchStack dispatchStack = processor.getDispatchStack();
-    			List<DispatchLayer<?>> layers = dispatchStack.getLayers();
-    			if (isProvenanceAlreadyAdded(layers))
-    				continue;
-    			IntermediateProvenance provenance = new IntermediateProvenance();
-				provenance.setWorkflow(workflowItem);
-				provenance.setReporter(context.getProvenanceReporter());
-
-				try {
-					edits.getAddDispatchLayerEdit(dispatchStack, provenance,
-					        provenancePosition(layers)).doEdit();
-					break;
-				} catch (EditException e) {
-					logger.warn("adding provenance layer to dispatch stack failed "
-									+ e.toString());
-				}
-		    }
-	}
-
-    private boolean isProvenanceAlreadyAdded(List<DispatchLayer<?>> layers) {
-        for (DispatchLayer<?> layer : layers)
-        	if (layer instanceof IntermediateProvenance)
-        		return true;
-        return false;
-    }
-
-    private int provenancePosition(List<DispatchLayer<?>> layers) {
-        int position=0; // fallback - beginning of list
-        for (int i = 0; i < layers.size(); i++) {
-            DispatchLayer<?> layer = layers.get(i);
-        	if (layer instanceof Parallelize)
-        	    // Below Parallelize (should be there!)
-        	    position = i+1;
-        	else if (layer instanceof ErrorBounce)
-        	    // and inserted just above ErrorBounce (if it's there)
-        		position = i;
-        }
-        return position;
-    }
-
-	@Override
-	public void addFacadeListener(FacadeListener listener) {
-		facadeListeners.add(listener);
-	}
-
-	@Override
-	public void addResultListener(ResultListener listener) {
-		synchronized (resultListeners) {
-			if (resultListeners.isEmpty())
-				for (DataflowOutputPort port : dataflow.getOutputPorts())
-					port.addResultListener(facadeResultListener);
-			resultListeners.add(listener); 
-		}		
-	}
-
-	@Override
-	public synchronized void fire() throws IllegalStateException {
-		if (getState().equals(State.running))
-			throw new IllegalStateException("Workflow is already running!");
-		workflowStarted = new Timestamp(currentTimeMillis());
-		setState(State.running);
-		if (provEnabled) {
-			workflowItem.setInvocationStarted(workflowStarted);
-			context.getProvenanceReporter().addProvenanceItem(workflowItem);
-		}
-		
-		HashSet<MonitorableProperty<?>> properties = new HashSet<>();
-		properties.add(new StateProperty());
-		monitorManager.registerNode(this, instanceOwningProcessId.split(":"),				
-				properties);
-		dataflow.fire(instanceOwningProcessId, context);		
-	}
-
-	public final class StateProperty implements MonitorableProperty<State> {
-		@Override
-		public Date getLastModified() {
-			return stateLastModified;
-		}
-
-		@Override
-		public String[] getName() {
-			return new String[] { "facade", "state" };
-		}
-
-		@Override
-		public State getValue() throws NoSuchPropertyException {
-			return getState();
-		}
-	}
-	
-	@Override
-	public Dataflow getDataflow() {
-		return dataflow;
-	}
-
-	@Override
-	public TypedTreeModel<MonitorNode> getStateModel() {
-		// TODO WorkflowInstanceFacade.getStateModel not yet implemented
-		return null;
-	}
-
-	@Override
-	public void pushData(WorkflowDataToken token, String portName)
-			throws TokenOrderException {
-		State currentState = getState();
-		if (! currentState.equals(State.running))
-			throw new IllegalStateException(
-					"Can't push data, current state is not running, but "
-							+ currentState);
-		/*
-		 * TODO: throw TokenOrderException when token stream is violates order
-		 * constraints.
-		 */
-		for (DataflowInputPort port : dataflow.getInputPorts()) {
-			if (!portName.equals(port.getName()))
-				continue;
-			if (token.getIndex().length == 0) {
-				if (pushedDataMap.containsKey(portName))
-					throw new IllegalStateException("Already pushed for port " + portName);
-				pushedDataMap.put(portName, token.getData());					
-			}
-			if (provEnabled) {
-				WorkflowDataProvenanceItem provItem = new WorkflowDataProvenanceItem();
-				provItem.setPortName(portName);
-				provItem.setInputPort(true);
-				provItem.setData(token.getData());
-				provItem.setReferenceService(context.getReferenceService());
-				provItem.setParentId(workflowItem.getIdentifier());
-				provItem.setWorkflowId(workflowItem.getParentId());
-				provItem.setIdentifier(randomUUID().toString());
-				provItem.setParentId(instanceOwningProcessId);
-				provItem.setProcessId(instanceOwningProcessId);
-				provItem.setIndex(token.getIndex());
-				provItem.setFinal(token.isFinal());
-				context.getProvenanceReporter().addProvenanceItem(provItem);
-			}
-			port.receiveEvent(token.pushOwningProcess(localName));
-		}
-	}
-
-	@Override
-	public void removeFacadeListener(FacadeListener listener) {
-		facadeListeners.remove(listener);
-	}
-
-	private <T> ArrayList<T> copyList(List<T> listenerList) {
-		synchronized (listenerList) {
-			return new ArrayList<>(listenerList);
-		}
-	}
-
-	@Override
-	public void removeResultListener(ResultListener listener) {
-		synchronized (resultListeners) {
-			resultListeners.remove(listener);
-			if (resultListeners.isEmpty())
-				for (DataflowOutputPort port : dataflow.getOutputPorts())
-					port.removeResultListener(facadeResultListener);
-		}
-	}
-
-	protected class FacadeResultListener implements ResultListener {
-		private final WorkflowProvenanceItem workflowItem;
-
-		public FacadeResultListener(Dataflow dataflow,
-				WorkflowProvenanceItem workflowItem) {
-			this.workflowItem = workflowItem;
-		}
-
-		@Override
-		public void resultTokenProduced(WorkflowDataToken token, String portName) {			
-			if (!instanceOwningProcessId.equals(token.getOwningProcess()))
-				return;
-			if (getState().equals(State.cancelled))
-				// Throw the token away
-				return;
-
-			if (provEnabled) {
-				WorkflowDataProvenanceItem provItem = new WorkflowDataProvenanceItem();
-				provItem.setPortName(portName);
-				provItem.setInputPort(false);
-				provItem.setData(token.getData());
-				provItem.setReferenceService(context.getReferenceService());
-				provItem.setParentId(workflowItem.getIdentifier());
-				provItem.setWorkflowId(workflowItem.getParentId());
-				provItem.setIdentifier(randomUUID().toString());
-				provItem.setParentId(instanceOwningProcessId);
-				provItem.setProcessId(instanceOwningProcessId);
-				provItem.setIndex(token.getIndex());
-				provItem.setFinal(token.isFinal());
-				context.getProvenanceReporter().addProvenanceItem(provItem);
-			}
-			
-			for (ResultListener resultListener : copyList(resultListeners))
-				try {
-					resultListener.resultTokenProduced(
-							token.popOwningProcess(), portName);
-				} catch (RuntimeException ex) {
-					logger.warn("Could not notify result listener "
-							+ resultListener, ex);
-				}
-			if (token.getIndex().length == 0)
-				checkWorkflowFinished(WorkflowInstanceFacadeChange.PORT_DECREMENT);
-		}
-	}
-	
-
-	/**
-	 * An observer of events that occur when a processor finishes with execution.
-	 *
-	 */
-	private class ProcessorFinishedObserver implements Observer<ProcessorFinishedEvent>{
-		private final String expectedProcessId;
-
-		public ProcessorFinishedObserver(WorkflowProvenanceItem workflowItem, String expectedProcessId) {
-			this.expectedProcessId = expectedProcessId;
-		}
-
-		@Override
-		public void notify(Observable<ProcessorFinishedEvent> sender,
-				ProcessorFinishedEvent message) throws Exception {
-			if (! message.getOwningProcess().equals(expectedProcessId))
-				return;
-			
-			// De-register the processor node from the monitor as it has finished
-			monitorManager.deregisterNode(message.getOwningProcess());
-			
-			// De-register this observer from the processor
-			message.getProcessor().removeObserver(this);
-			
-			// All processors have finished => the workflow run has finished
-			checkWorkflowFinished(WorkflowInstanceFacadeChange.PROCESSOR_DECREMENT);
-		}
-	}
-
-	private void applyChange(WorkflowInstanceFacadeChange change) {
-		switch (change) {
-		case CANCELLATION:
-			processorsToComplete = 0;
-			portsToComplete = 0;
-			break;
-		case PORT_DECREMENT:
-			portsToComplete--;
-			break;
-		case PROCESSOR_DECREMENT:
-			processorsToComplete--;
-			break;
-		}
-	}
-	protected void checkWorkflowFinished(WorkflowInstanceFacadeChange change) {
-		synchronized (this) {
-			applyChange(change);
-			if (getState().equals(State.cancelled) && processorsToComplete < 0) {
-				logger.error("Already cancelled workflow run "
-						+ instanceOwningProcessId);
-				return;
-			}
-			if (getState().equals(State.completed)) {
-				logger.error("Already finished workflow run "
-						+ instanceOwningProcessId, new IllegalStateException());
-				return;
-			}
-			if (processorsToComplete > 0 || portsToComplete > 0)
-				// Not yet finished
-				return;
-			if (processorsToComplete < 0 || portsToComplete < 0) {
-				logger.error("Already finished workflow run "
-						+ instanceOwningProcessId, new IllegalStateException());
-				return;
-			}
-			if (!getState().equals(State.cancelled))
-				setState(State.completed);
-			processorsToComplete = -1;
-			portsToComplete = -1;
-		}	
-		// De-register the workflow node from the monitor
-		monitorManager.deregisterNode(instanceOwningProcessId + ":" + dataflow.getLocalName());
-
-		/*
-		 * De-register this facade node from the monitor - this will effectively
-		 * tell the monitor that the workflow run has finished
-		 */
-		monitorManager.deregisterNode(instanceOwningProcessId);
-
-		if (provEnabled) {
-			DataflowRunComplete provItem = new DataflowRunComplete();
-			provItem.setInvocationEnded(new Timestamp(currentTimeMillis()));
-			provItem.setParentId(workflowItem.getIdentifier());
-			provItem.setWorkflowId(workflowItem.getParentId());
-			provItem.setProcessId(instanceOwningProcessId);
-			provItem.setIdentifier(randomUUID().toString());
-			provItem.setState(getState());
-			context.getProvenanceReporter().addProvenanceItem(provItem);
-		}
-	}
-
-	@Override
-	public WeakHashMap<String, T2Reference> getPushedDataMap() {
-		return pushedDataMap;
-	}
-
-	public void setWorkflowRunId(String workflowRunId) {
-		this.workflowRunId = workflowRunId;
-	}
-
-	@Override
-	public String getWorkflowRunId() {
-		return workflowRunId;
-	}
-	
-	@Override
-	public synchronized State getState() {
-		return state;
-	}
-	
-	public synchronized void setState(State newState) throws IllegalStateException {
-		State oldState = state;
-		if (newState.equals(state))
-			return;
-		switch (newState) {
-		case running:
-			switch (state) {
-			case prepared:
-			case paused:
-				stateLastModified = new Date();
-				state = newState;
-				notifyFacadeListeners(oldState, newState);
-				return;
-			default:
-				throw new IllegalStateException("Can't change state from "
-						+ state + " to " + newState);
-			}
-		case paused:
-			switch (state) {
-			case running:
-				stateLastModified = new Date();
-				state = newState;
-				notifyFacadeListeners(oldState, newState);
-				return;
-			default:
-				throw new IllegalStateException("Can't change state from "
-						+ state + " to " + newState);
-			}
-		case completed:
-			switch (state) {
-			case running:
-				stateLastModified = new Date();
-				state = newState;
-				notifyFacadeListeners(oldState, newState);
-				return;
-			case cancelled:
-				// Keep as cancelled
-				return;
-			default:
-				throw new IllegalStateException("Can't change state from "
-						+ state + " to " + newState);
-			}
-		case cancelled:
-			switch (state) {
-			case completed:
-				throw new IllegalStateException("Can't change state from "
-						+ state + " to " + newState);
-			default:
-				stateLastModified = new Date();
-				state = newState;
-				notifyFacadeListeners(oldState, newState);
-				return;
-			}
-		default:
-			throw new IllegalStateException("Can't change state from " + state  + " to " + newState);		
-		}		
-	}
-
-	private void notifyFacadeListeners(State oldState, State newState) {
-		for (FacadeListener facadeListener : copyList(facadeListeners))
-			try {
-				facadeListener.stateChange(this, oldState, newState);
-			} catch (RuntimeException ex) {
-				logger.warn("Could not notify facade listener "
-						+ facadeListener, ex);
-			}
-	}
-
-	@Override
-	public synchronized boolean cancelWorkflowRun() {
-		if (getState().equals(State.completed))
-			return false;
-		boolean result = Stop.cancelWorkflow(getWorkflowRunId());
-		if (result) {
-			setState(State.cancelled);
-			logger.info("Cancelled workflow runId=" + getWorkflowRunId()
-					+ " processId=" + instanceOwningProcessId);
-			for (FacadeListener facadeListener : copyList(facadeListeners))
-				try {
-					facadeListener.workflowFailed(this, "Workflow was cancelled",
-							new WorkflowRunCancellation(getWorkflowRunId()));
-				} catch (RuntimeException ex) {
-					logger.warn("Could not notify failure listener "
-							+ facadeListener, ex);
-				}
-			checkWorkflowFinished(WorkflowInstanceFacadeChange.CANCELLATION);		
-		}
-		return result;
-	}
-
-	@Override
-	public boolean pauseWorkflowRun() {
-		setState(State.paused);
-		if (Stop.pauseWorkflow(getWorkflowRunId())) {
-			logger.info("Paused workflow runId=" + getWorkflowRunId()
-					+ " processId=" + instanceOwningProcessId);
-			return true;
-		}
-		return false;
-	}
-
-	@Override
-	public boolean resumeWorkflowRun() {
-		setState(State.running);
-		if (Stop.resumeWorkflow(getWorkflowRunId())) {
-			logger.info("Resumed paused workflow runId=" + getWorkflowRunId()
-					+ " processId=" + instanceOwningProcessId);
-			return true;
-		}
-		return false;
-	}
-
-	@Override
-	public String getIdentifier() {
-		return localName;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/invocation/impl/InvocationContextImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/invocation/impl/InvocationContextImpl.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/invocation/impl/InvocationContextImpl.java
deleted file mode 100644
index de4abe4..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/invocation/impl/InvocationContextImpl.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.invocation.impl;
-
-import static java.util.Collections.synchronizedList;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.provenance.reporter.ProvenanceReporter;
-import net.sf.taverna.t2.reference.ReferenceService;
-
-public class InvocationContextImpl implements InvocationContext {
-	private final ReferenceService referenceService;
-	private final ProvenanceReporter provenanceReporter;
-	private List<Object> entities = synchronizedList(new ArrayList<Object>());
-
-	public InvocationContextImpl(ReferenceService referenceService,
-			ProvenanceReporter provenanceReporter) {
-		this.referenceService = referenceService;
-		this.provenanceReporter = provenanceReporter;
-	}
-
-	@Override
-	public ReferenceService getReferenceService() {
-		return referenceService;
-	}
-
-	@Override
-	public ProvenanceReporter getProvenanceReporter() {
-		return provenanceReporter;
-	}
-
-	@Override
-	public <T extends Object> List<T> getEntities(Class<T> entityType) {
-		List<T> entitiesOfType = new ArrayList<>();
-		synchronized (entities) {
-			for (Object entity : entities)
-				if (entityType.isInstance(entity))
-					entitiesOfType.add(entityType.cast(entity));
-		}
-		return entitiesOfType;
-	}
-
-	@Override
-	public void addEntity(Object entity) {
-		entities.add(entity);
-	}
-
-	public void removeEntity(Object entity) {
-		entities.remove(entity);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/monitor/impl/MonitorTreeModel.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/monitor/impl/MonitorTreeModel.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/monitor/impl/MonitorTreeModel.java
deleted file mode 100644
index 2709164..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/monitor/impl/MonitorTreeModel.java
+++ /dev/null
@@ -1,423 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.monitor.impl;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.Collections;
-import java.util.Date;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
-
-import javax.swing.JFrame;
-import javax.swing.JScrollPane;
-import javax.swing.JTree;
-import javax.swing.SwingUtilities;
-import javax.swing.event.TreeModelEvent;
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.DefaultTreeCellRenderer;
-import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.MutableTreeNode;
-import javax.swing.tree.TreeModel;
-import javax.swing.tree.TreePath;
-
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.lang.observer.Observer;
-import net.sf.taverna.t2.monitor.MonitorNode;
-import net.sf.taverna.t2.monitor.MonitorableProperty;
-import net.sf.taverna.t2.monitor.NoSuchPropertyException;
-import net.sf.taverna.t2.monitor.MonitorManager.AddPropertiesMessage;
-import net.sf.taverna.t2.monitor.MonitorManager.DeregisterNodeMessage;
-import net.sf.taverna.t2.monitor.MonitorManager.MonitorMessage;
-import net.sf.taverna.t2.monitor.MonitorManager.RegisterNodeMessage;
-
-import org.apache.log4j.Logger;
-
-/**
- * A relatively naive Monitor interface which holds all
- * state in a tree model. Use getMonitor() to get the monitor singleton, all
- * workflows under a given JVM use the same instance in this implementation with
- * the root node of the monitor tree corresponding to the monitor itself.
- * <p>
- * Internally we use a default tree model with default mutable tree nodes where
- * the user object is set to instances of MonitorNode, with the exception of the
- * 'true' root of the tree in which it is set to the MonitorImpl itself
- * 
- * @author Tom Oinn
- * @author Stian Soiland-Reyes
- * 
- */
-public class MonitorTreeModel implements Observer<MonitorMessage> {
-	private static MonitorTreeModel instance = null;
-	private static Logger logger = Logger.getLogger(MonitorTreeModel.class);
-	
-	/**
-	 * Get the MonitorImpl singleton
-	 * 
-	 * @return The MonitorImpl singleton
-	 */
-	public synchronized static MonitorTreeModel getInstance() {
-		// TODO Convert to a bean?
-		if (instance == null)
-			instance = new MonitorTreeModel();
-		return instance;
-	}
-
-	private long nodeRemovalDelay = 1000;
-	private DefaultTreeModel monitorTree;
-	private Timer nodeRemovalTimer;
-
-	/**
-	 * Protected constructor, use singleton access {@link #getInstance()}
-	 * instead.
-	 * 
-	 */
-	protected MonitorTreeModel() {
-		monitorTree = new DefaultTreeModel(new DefaultMutableTreeNode(this));
-		// Create the node removal timer as a daemon thread
-		nodeRemovalTimer = new Timer(true);
-	}
-
-	/**
-	 * Returns a tree view over the monitor.
-	 * 
-	 * @return a tree view over the monitor
-	 */
-	public JTree getJTree() {
-		return new AlwaysOpenJTree(monitorTree);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public void notify(Observable<MonitorMessage> sender, MonitorMessage message)
-			throws Exception {
-		if (message instanceof RegisterNodeMessage) {
-			RegisterNodeMessage regMessage = (RegisterNodeMessage) message;
-			registerNode(regMessage.getWorkflowObject(), regMessage
-					.getOwningProcess(), regMessage.getProperties());
-		} else if (message instanceof DeregisterNodeMessage) {
-			deregisterNode(message.getOwningProcess());
-		} else if (message instanceof AddPropertiesMessage) {
-			AddPropertiesMessage addMessage = (AddPropertiesMessage) message;
-			addPropertiesToNode(addMessage.getOwningProcess(), addMessage
-					.getNewProperties());
-		} else {
-			logger.warn("Unknown message " + message + " from " + sender);
-		}
-	}
-
-	/**
-	 * Nodes will be removed at least delayTime milliseconds after their initial
-	 * deregistration request, this allows UI components to show nodes which
-	 * would otherwise vanish almost instantaneously.
-	 * 
-	 * @param delayTime
-	 *            time in milliseconds between the deregistration request and
-	 *            attempt to actually remove the node in question
-	 */
-	public void setNodeRemovalDelay(long delayTime) {
-		nodeRemovalDelay = delayTime;
-	}
-
-	/**
-	 * Very simple UI!
-	 */
-	public void showMonitorFrame() {
-		final JTree tree = new AlwaysOpenJTree(monitorTree);
-		final JScrollPane jsp = new JScrollPane(tree);
-		JFrame frame = new JFrame();
-		frame.getContentPane().setLayout(new BorderLayout());
-		frame.getContentPane().add(jsp);
-		frame.pack();
-		frame.setVisible(true);
-		new javax.swing.Timer(500, new ActionListener() {
-			@Override
-			public void actionPerformed(ActionEvent ae) {
-				jsp.repaint();
-			}
-		}).start();
-	}
-
-	/**
-	 * Return the node pointed to by the first 'limit' number of elements in the
-	 * owning process string array. If limit is -1 then use owningProcess.length
-	 * 
-	 * @param owningProcess
-	 * @param limit
-	 * @return
-	 */
-	protected DefaultMutableTreeNode nodeAtProcessPath(String[] owningProcess,
-			int limit) throws IndexOutOfBoundsException {
-		if (limit == -1)
-			limit = owningProcess.length;
-		DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) monitorTree
-				.getRoot();
-		for (int index = 0; index < limit && index < owningProcess.length; index++) {
-			boolean found = false;
-			for (int childIndex = 0; childIndex < monitorTree
-					.getChildCount(currentNode)
-					&& !found; childIndex++) {
-				DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) monitorTree
-						.getChild(currentNode, childIndex);
-				MonitorNode childMonitorNode = (MonitorNode) childNode
-						.getUserObject();
-				if (childMonitorNode.getOwningProcess()[index]
-						.equals(owningProcess[index])) {
-					currentNode = childNode;
-					found = true;
-					// break;
-				}
-			}
-			if (!found)
-				throw new IndexOutOfBoundsException(
-						"Cannot locate node with process ID "
-								+ printProcess(owningProcess));
-		}
-		return currentNode;
-	}
-
-	protected String printProcess(String[] process) {
-		StringBuffer sb = new StringBuffer();
-		for (String part : process)
-			sb.append("{").append(part).append("}");
-		return sb.toString();
-	}
-
-	/**
-	 * Inject properties into an existing node
-	 */
-	protected void addPropertiesToNode(String[] owningProcess,
-			Set<MonitorableProperty<?>> newProperties) {
-		try {
-			DefaultMutableTreeNode node = nodeAtProcessPath(owningProcess, -1);
-			MonitorNode mn = (MonitorNode) node.getUserObject();
-			for (MonitorableProperty<?> prop : newProperties)
-				mn.addMonitorableProperty(prop);
-		} catch (IndexOutOfBoundsException ioobe) {
-			// Fail silently here, the node wasn't found in the state tree
-			logger.warn("Could not add properties to unknown node "
-					+ printProcess(owningProcess));
-		}
-	}
-
-	/**
-	 * Request the removal of the specified node from the monitor tree. In this
-	 * particular case the removal task will be added to a timer and executed at
-	 * some (slightly) later time as determined by the removalDelay property.
-	 */
-	protected void deregisterNode(String[] owningProcess) {
-		// logger.debug("Remove node @" + printProcess(owningProcess));
-		final DefaultMutableTreeNode nodeToRemove = nodeAtProcessPath(
-				owningProcess, -1);
-		((MonitorNodeImpl) nodeToRemove.getUserObject()).expire();
-		nodeRemovalTimer.schedule(new TimerTask() {
-			@Override
-			public void run() {
-				synchronized (monitorTree) {
-					monitorTree.removeNodeFromParent(nodeToRemove);
-				}
-			}
-		}, getNodeRemovalDelay());
-	}
-
-	/**
-	 * Create a new node in the monitor
-	 */
-	protected void registerNode(final Object workflowObject,
-			final String[] owningProcess,
-			final Set<MonitorableProperty<?>> properties) {
-		// logger.debug("Registering node " + printProcess(owningProcess));
-	
-		// Create a new MonitorNode
-		final DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(
-				new MonitorNodeImpl(workflowObject, owningProcess, properties));
-		synchronized (monitorTree) {
-			final MutableTreeNode parentNode = nodeAtProcessPath(owningProcess,
-					owningProcess.length - 1);
-			monitorTree.insertNodeInto(newNode, parentNode, monitorTree
-					.getChildCount(parentNode));
-		}
-	}
-
-	class AlwaysOpenJTree extends JTree {
-		private static final long serialVersionUID = -3769998854485605447L;
-
-		public AlwaysOpenJTree(TreeModel newModel) {
-			super(newModel);
-			setRowHeight(18);
-			setLargeModel(true);
-			setEditable(false);
-			setExpandsSelectedPaths(false);
-			setDragEnabled(false);
-			setScrollsOnExpand(false);
-			setSelectionModel(EmptySelectionModel.sharedInstance());
-			setCellRenderer(new CellRenderer());
-		}
-
-		@Override
-		public void setModel(TreeModel model) {
-			if (treeModel == model)
-				return;
-			if (treeModelListener == null)
-				treeModelListener = new TreeModelListener();
-			if (model != null) {
-				model.addTreeModelListener(treeModelListener);
-			}
-			TreeModel oldValue = treeModel;
-			treeModel = model;
-			firePropertyChange(TREE_MODEL_PROPERTY, oldValue, model);
-		}
-
-		protected class CellRenderer extends DefaultTreeCellRenderer {
-			private static final long serialVersionUID = 7106767124654545039L;
-
-			@Override
-			public Component getTreeCellRendererComponent(JTree tree,
-					Object value, boolean sel, boolean expanded,
-					boolean leaf, int row, boolean hasFocus) {
-				super.getTreeCellRendererComponent(tree, value, sel,
-						expanded, leaf, row, hasFocus);
-				if (value instanceof DefaultMutableTreeNode) {
-					Object o = ((DefaultMutableTreeNode) value)
-							.getUserObject();
-					if (o instanceof MonitorNode)
-						if (((MonitorNode) o).hasExpired())
-							setEnabled(false);
-				}
-				return this;
-			}
-		}
-
-		protected class TreeModelListener extends TreeModelHandler {
-			@Override
-			public void treeNodesInserted(final TreeModelEvent ev) {
-				SwingUtilities.invokeLater(new Runnable() {
-					@Override
-					public void run() {
-						TreePath path = ev.getTreePath();
-						setExpandedState(path, true);
-						fireTreeExpanded(path);
-					}
-				});
-			}
-			@Override
-			public void treeStructureChanged(final TreeModelEvent ev) {
-				SwingUtilities.invokeLater(new Runnable() {
-					@Override
-					public void run() {
-						TreePath path = ev.getTreePath();
-						setExpandedState(path, true);
-						fireTreeExpanded(path);
-					}
-				});
-			}
-		}
-	}
-
-	class MonitorNodeImpl implements MonitorNode {
-		private boolean expired = false;
-		private String[] owningProcess;
-		private Set<MonitorableProperty<?>> properties;
-		private Object workflowObject;
-		Date creationDate = new Date();
-
-		MonitorNodeImpl(Object workflowObject, String[] owningProcess,
-				Set<MonitorableProperty<?>> properties) {
-			this.properties = properties;
-			this.workflowObject = workflowObject;
-			this.owningProcess = owningProcess;
-		}
-
-		@Override
-		public void addMonitorableProperty(MonitorableProperty<?> newProperty) {
-			properties.add(newProperty);
-		}
-
-		public void expire() {
-			expired = true;
-		}
-
-		@Override
-		public Date getCreationDate() {
-			return creationDate;
-		}
-
-		@Override
-		public String[] getOwningProcess() {
-			return owningProcess;
-		}
-
-		/**
-		 * Return an unmodifiable copy of the property set
-		 */
-		@Override
-		public Set<? extends MonitorableProperty<?>> getProperties() {
-			return Collections.unmodifiableSet(properties);
-		}
-
-		@Override
-		public Object getWorkflowObject() {
-			return workflowObject;
-		}
-
-		@Override
-		public boolean hasExpired() {
-			return this.expired;
-		}
-
-		@Override
-		public String toString() {
-			StringBuffer sb = new StringBuffer();
-			sb.append(getWorkflowObject().getClass().getSimpleName());
-			sb.append(", ");
-			sb.append(owningProcess[owningProcess.length - 1]);
-			sb.append(" : ");
-			for (MonitorableProperty<?> prop : getProperties()) {
-				String separator = "";
-				for (String nameElement : prop.getName()) {
-					sb.append(separator).append(nameElement);
-					separator = ".";
-				}
-				sb.append("=");
-				try {
-					sb.append(prop.getValue().toString());
-				} catch (NoSuchPropertyException nspe) {
-					sb.append("EXPIRED");
-				}
-				sb.append(" ");
-			}
-			return sb.toString();
-		}
-	}
-
-	public long getNodeRemovalDelay() {
-		return nodeRemovalDelay;
-	}
-
-	protected DefaultTreeModel getMonitorTree() {
-		return monitorTree;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractActivityEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractActivityEdit.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractActivityEdit.java
deleted file mode 100644
index 2725d2f..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractActivityEdit.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007-2008 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import net.sf.taverna.t2.workflowmodel.EditException;
-import net.sf.taverna.t2.workflowmodel.processor.activity.AbstractActivity;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-
-/**
- * Abstraction of an edit acting on a Activity instance. Handles the check to
- * see that the Activity supplied is really a AbstractActivity.
- * 
- * @author David Withers
- * @author Stian Soiland-Reyes
- */
-public abstract class AbstractActivityEdit<T> extends EditSupport<Activity<T>> {
-	private final AbstractActivity<T> activity;
-
-	protected AbstractActivityEdit(Activity<T> activity) {
-		if (activity == null)
-			throw new RuntimeException(
-					"Cannot construct an activity edit with null activity");
-		if (!(activity instanceof AbstractActivity))
-			throw new RuntimeException(
-					"Edit cannot be applied to an Activity which isn't an instance of AbstractActivity");
-		this.activity = (AbstractActivity<T>) activity;
-	}
-
-	@Override
-	public final Activity<T> applyEdit() throws EditException {
-		synchronized (activity) {
-			doEditAction(activity);
-		}
-		return activity;
-	}
-
-	/**
-	 * Do the actual edit here
-	 * 
-	 * @param processor
-	 *            The ProcessorImpl to which the edit applies
-	 * @throws EditException
-	 */
-	protected abstract void doEditAction(AbstractActivity<T> processor)
-			throws EditException;
-
-	@Override
-	public final Activity<T> getSubject() {
-		return activity;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractAnnotationEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractAnnotationEdit.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractAnnotationEdit.java
deleted file mode 100644
index ff89988..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractAnnotationEdit.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007-2014 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import net.sf.taverna.t2.annotation.AnnotationAssertion;
-import net.sf.taverna.t2.annotation.AnnotationBeanSPI;
-import net.sf.taverna.t2.annotation.impl.AnnotationAssertionImpl;
-import net.sf.taverna.t2.workflowmodel.EditException;
-
-/**
- * Abstraction of an edit acting on a AnnotationAssertion instance. Handles the
- * check to see that the AnnotationAssertion supplied is really an
- * AnnotationAssertionImpl.
- */
-abstract class AbstractAnnotationEdit extends
-		EditSupport<AnnotationAssertion<AnnotationBeanSPI>> {
-	private final AnnotationAssertionImpl annotation;
-
-	protected AbstractAnnotationEdit(AnnotationAssertion<AnnotationBeanSPI> annotation) {
-		if (annotation == null)
-			throw new RuntimeException(
-					"Cannot construct an annotation edit with null annotation");
-		if (!(annotation instanceof AnnotationAssertionImpl))
-			throw new RuntimeException(
-					"Edit cannot be applied to an AnnotationAssertion which isn't an instance of AnnotationAssertionImpl");
-		this.annotation = (AnnotationAssertionImpl) annotation;
-	}
-
-	@Override
-	public final AnnotationAssertion<AnnotationBeanSPI> applyEdit()
-			throws EditException {
-		synchronized (annotation) {
-			doEditAction(annotation);
-		}
-		return annotation;
-	}
-
-	/**
-	 * Do the actual edit here
-	 * 
-	 * @param annotationAssertion
-	 *            The AnnotationAssertionImpl to which the edit applies
-	 * @throws EditException
-	 */
-	protected abstract void doEditAction(
-			AnnotationAssertionImpl annotationAssertion) throws EditException;
-
-	@Override
-	public final AnnotationAssertion<AnnotationBeanSPI> getSubject() {
-		return annotation;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractBinaryProcessorEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractBinaryProcessorEdit.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractBinaryProcessorEdit.java
deleted file mode 100644
index ba1c505..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractBinaryProcessorEdit.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007-2014 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import static java.lang.System.identityHashCode;
-import net.sf.taverna.t2.workflowmodel.EditException;
-import net.sf.taverna.t2.workflowmodel.OrderedPair;
-import net.sf.taverna.t2.workflowmodel.Processor;
-
-/**
- * Generalization over all operations acting on an ordered pair of ProcessorImpl
- * objects. These include most operations where a relationship is created,
- * modified or destroyed between two processors.
- * 
- * @author Tom Oinn
- * @author Donal Fellows
- */
-abstract class AbstractBinaryProcessorEdit extends
-		EditSupport<OrderedPair<Processor>> {
-	private final OrderedPair<Processor> processors;
-
-	public AbstractBinaryProcessorEdit(Processor a, Processor b) {
-		if (!(a instanceof ProcessorImpl) || !(b instanceof ProcessorImpl))
-			throw new RuntimeException(
-					"Edit cannot be applied to a Processor which isn't an instance of ProcessorImpl");
-		processors = new OrderedPair<>(a, b);
-	}
-
-	@Override
-	public final OrderedPair<Processor> applyEdit() throws EditException {
-		ProcessorImpl pia = (ProcessorImpl) processors.getA();
-		ProcessorImpl pib = (ProcessorImpl) processors.getB();
-
-		/*
-		 * Acquire both locks. Guarantee to acquire in a consistent order, based
-		 * on the system hash code (i.e., the object addresses, which we're not
-		 * supposed to know). This means that we should not deadlock, as we've
-		 * got a total order over all extant processors.
-		 * 
-		 * If someone is silly enough to use the same processor for both halves,
-		 * it doesn't matter which arm of the conditional we take.
-		 */
-		if (identityHashCode(pia) < identityHashCode(pib)) {
-			synchronized (pia) {
-				synchronized (pib) {
-					doEditAction(pia, pib);
-				}
-			}
-		} else {
-			synchronized (pib) {
-				synchronized (pia) {
-					doEditAction(pia, pib);
-				}
-			}
-		}
-		return processors;
-	}
-
-	@Override
-	public final OrderedPair<Processor> getSubject() {
-		return processors;
-	}
-
-	/**
-	 * Do the actual edit here
-	 * 
-	 * @param processorA
-	 *            The ProcessorImpl which is in some sense the source of the
-	 *            relation between the two being asserted or operated on by this
-	 *            edit
-	 * @param processorB
-	 *            The ProcessorImpl at the other end of the relation. *
-	 * @throws EditException
-	 */
-	protected abstract void doEditAction(ProcessorImpl processorA,
-			ProcessorImpl processorB) throws EditException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractCrystalizer.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractCrystalizer.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractCrystalizer.java
deleted file mode 100644
index 7d519af..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractCrystalizer.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import net.sf.taverna.t2.invocation.Completion;
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.invocation.IterationInternalEvent;
-import net.sf.taverna.t2.invocation.TreeCache;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Job;
-
-/**
- * Receives Job and Completion events and emits Jobs unaltered. Completion
- * events additionally cause registration of lists for each key in the datamap
- * of the jobs at immediate child locations in the index structure. These list
- * identifiers are sent in place of the Completion events.
- * <p>
- * State for a given process ID is purged when a final completion event is
- * received so there is no need for an explicit cache purge operation in the
- * public API (although for termination of partially complete workflows it may
- * be sensible for subclasses to provide one)
- * <p>
- * 
- * @author Tom Oinn
- * @author David Withers
- */
-public abstract class AbstractCrystalizer implements Crystalizer {
-	private Map<String, CompletionAwareTreeCache> cacheMap = new HashMap<>();
-
-	public abstract Job getEmptyJob(String owningProcess, int[] index,
-			InvocationContext context);
-
-	/**
-	 * Receive a Job or Completion, Jobs are emitted unaltered and cached,
-	 * Completion events trigger registration of a corresponding list - this may
-	 * be recursive in nature if the completion event's index implies nested
-	 * lists which have not been registered.
-	 * <p>
-	 * If the baseListDepth property is defined then completion events on nodes
-	 * which don't already exist create empty jobs instead and emit those, if
-	 * undefined the completion event is emited intact.
-	 * 
-	 * @param e The event (a {@link Job} or a {@link Completion})
-	 */
-	@Override
-	public void receiveEvent(IterationInternalEvent<?> e) {
-		String owningProcess = e.getOwningProcess();
-		CompletionAwareTreeCache cache = null;
-		synchronized (cacheMap) {
-			if (!cacheMap.containsKey(owningProcess)) {
-				cache = new CompletionAwareTreeCache(owningProcess, e
-						.getContext());
-				cacheMap.put(owningProcess, cache);
-			} else
-				cache = cacheMap.get(owningProcess);
-		}
-		if (e instanceof Job) {
-			// Pass through Job after storing it in the cache
-			Job j = (Job) e;
-			synchronized (cache) {
-				cache.insertJob(new Job("", j.getIndex(), j.getData(), j
-						.getContext()));
-				jobCreated(j);
-				if (j.getIndex().length == 0)
-					cacheMap.remove(j.getOwningProcess());
-			}
-		} else if (e instanceof Completion) {
-			Completion c = (Completion) e;
-			synchronized (cache) {
-				cache.resolveAt(owningProcess, c.getIndex());
-				if (c.getIndex().length == 0)
-					cacheMap.remove(c.getOwningProcess());
-			}
-		}
-	}
-
-	protected class CompletionAwareTreeCache extends TreeCache {
-		private String owningProcess;
-		private InvocationContext context;
-
-		public CompletionAwareTreeCache(String owningProcess,
-				InvocationContext context) {
-			super();
-			this.context = context;
-			this.owningProcess = owningProcess;
-		}
-
-		public void resolveAt(String owningProcess, int[] completionIndex) {
-			NamedNode n = nodeAt(completionIndex);
-			if (n != null) {
-				assignNamesTo(n, completionIndex);
-				return;
-			}
-
-			/*
-			 * We know what the list depth should be, so we can construct
-			 * appropriate depth empty lists to fill in the gaps.
-			 */
-
-			Job j = getEmptyJob(owningProcess, completionIndex, context);
-			insertJob(j);
-			jobCreated(j);
-		}
-
-		private void assignNamesTo(NamedNode n, int[] index) {
-			/* Only act if contents of this node undefined */
-			if (n.contents != null)
-				return;
-
-			Map<String, List<T2Reference>> listItems = new HashMap<>();
-			int pos = 0;
-			for (NamedNode child : n.children) {
-				/*
-				 * If child doesn't have a defined name map yet then define it.
-				 */
-				Job j;
-				if (child == null) {
-					/*
-					 * happens if we're completing a partially empty collection
-					 * structure
-					 */
-					int[] newIndex = new int[index.length + 1];
-					for (int i = 0; i < index.length; i++)
-						newIndex[i] = index[i];
-					newIndex[index.length] = pos++;
-					j = getEmptyJob(owningProcess, newIndex, context);
-					jobCreated(j);
-				} else if (child.contents == null) {
-					int[] newIndex = new int[index.length + 1];
-					for (int i = 0; i < index.length; i++)
-						newIndex[i] = index[i];
-					newIndex[index.length] = pos++;
-					assignNamesTo(child, newIndex);
-					j = child.contents;
-				} else {
-					pos++;
-					j = child.contents;
-				}
-
-				/*
-				 * Now pull the names out of the child job map and push them
-				 * into lists to be registered
-				 */
-
-				for (String outputName : j.getData().keySet()) {
-					List<T2Reference> items = listItems.get(outputName);
-					if (items == null) {
-						items = new ArrayList<>();
-						listItems.put(outputName, items);
-					}
-					items.add(j.getData().get(outputName));
-				}
-			}
-			Map<String, T2Reference> newDataMap = new HashMap<>();
-			for (String outputName : listItems.keySet())
-				newDataMap.put(
-						outputName,
-						context.getReferenceService()
-								.getListService()
-								.registerList(listItems.get(outputName),
-										context).getId());
-			Job newJob = new Job(owningProcess, index, newDataMap, context);
-			n.contents = newJob;
-
-			/* Get rid of the children as we've now named this node */
-
-			n.children.clear();
-			jobCreated(n.contents);
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractDataflowEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractDataflowEdit.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractDataflowEdit.java
deleted file mode 100644
index 9f8bc33..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractDataflowEdit.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007-2008 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import net.sf.taverna.t2.workflowmodel.EditException;
-
-/**
- * Abstraction of an edit acting on a Dataflow instance. Handles the check to
- * see that the Dataflow supplied is really a DataflowImpl.
- * 
- * @author David Withers
- * 
- */
-public abstract class AbstractDataflowEdit extends EditSupport<Dataflow> {
-	private final DataflowImpl dataflow;
-
-	protected AbstractDataflowEdit(Dataflow dataflow) {
-		if (dataflow == null)
-			throw new RuntimeException(
-					"Cannot construct a dataflow edit with null dataflow");
-		if (!(dataflow instanceof DataflowImpl))
-			throw new RuntimeException(
-					"Edit cannot be applied to a Dataflow which isn't an instance of DataflowImpl");
-		this.dataflow = (DataflowImpl) dataflow;
-	}
-
-	@Override
-	public final Dataflow applyEdit() throws EditException {
-		synchronized (dataflow) {
-			doEditAction(dataflow);
-		}
-		return dataflow;
-	}
-
-	/**
-	 * Do the actual edit here
-	 * 
-	 * @param dataflow
-	 *            The DataflowImpl to which the edit applies
-	 * @throws EditException
-	 */
-	protected abstract void doEditAction(DataflowImpl dataflow)
-			throws EditException;
-
-	@Override
-	public final Dataflow getSubject() {
-		return dataflow;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractDataflowInputPortEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractDataflowInputPortEdit.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractDataflowInputPortEdit.java
deleted file mode 100644
index 8f90758..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractDataflowInputPortEdit.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import net.sf.taverna.t2.workflowmodel.DataflowInputPort;
-import net.sf.taverna.t2.workflowmodel.EditException;
-
-/**
- * Abstraction of an edit acting on a DataflowInputPort instance. Handles the check to
- * see that the DataflowInputPort supplied is really a DataflowInputPortImpl.
- * 
- * @author David Withers
- *
- */
-public abstract class AbstractDataflowInputPortEdit extends EditSupport<DataflowInputPort> {
-	private final DataflowInputPortImpl dataflowInputPort;
-
-	protected AbstractDataflowInputPortEdit(DataflowInputPort dataflowInputPort) {
-		if (dataflowInputPort == null)
-			throw new RuntimeException(
-					"Cannot construct a DataflowInputPort edit with null DataflowInputPort");
-		if (!(dataflowInputPort instanceof DataflowInputPortImpl))
-			throw new RuntimeException(
-					"Edit cannot be applied to a DataflowInputPort which isn't an instance of DataflowInputPortImpl");
-		this.dataflowInputPort = (DataflowInputPortImpl) dataflowInputPort;
-	}
-
-	@Override
-	public final DataflowInputPort applyEdit() throws EditException {
-		synchronized (dataflowInputPort) {
-			doEditAction(dataflowInputPort);
-		}
-		return dataflowInputPort;
-	}
-
-	/**
-	 * Do the actual edit here
-	 * 
-	 * @param dataflowInputPort
-	 *            The DataflowInputPortImpl to which the edit applies
-	 * @throws EditException
-	 */
-	protected abstract void doEditAction(DataflowInputPortImpl dataflowInputPort)
-			throws EditException;
-
-	@Override
-	public final DataflowInputPort getSubject() {
-		return dataflowInputPort;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractDataflowOutputPortEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractDataflowOutputPortEdit.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractDataflowOutputPortEdit.java
deleted file mode 100644
index 401faa5..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractDataflowOutputPortEdit.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import net.sf.taverna.t2.workflowmodel.DataflowOutputPort;
-import net.sf.taverna.t2.workflowmodel.EditException;
-
-/**
- * Abstraction of an edit acting on a DataflowOutputPort instance. Handles the
- * check to see that the DataflowOutputPort supplied is really a
- * DataflowOutputPortImpl.
- * 
- * @author David Withers
- */
-public abstract class AbstractDataflowOutputPortEdit extends
-		EditSupport<DataflowOutputPort> {
-	private final DataflowOutputPortImpl dataflowOutputPort;
-
-	protected AbstractDataflowOutputPortEdit(
-			DataflowOutputPort dataflowOutputPort) {
-		if (dataflowOutputPort == null)
-			throw new RuntimeException(
-					"Cannot construct a DataflowOutputPort edit with null DataflowOutputPort");
-		if (!(dataflowOutputPort instanceof DataflowOutputPortImpl))
-			throw new RuntimeException(
-					"Edit cannot be applied to a DataflowOutputPort which isn't an instance of DataflowOutputPortImpl");
-		this.dataflowOutputPort = (DataflowOutputPortImpl) dataflowOutputPort;
-	}
-
-	@Override
-	public final DataflowOutputPort applyEdit() throws EditException {
-		synchronized (dataflowOutputPort) {
-			doEditAction(dataflowOutputPort);
-		}
-		return dataflowOutputPort;
-	}
-
-	/**
-	 * Do the actual edit here
-	 * 
-	 * @param dataflowOutputPort
-	 *            The DataflowOutputPortImpl to which the edit applies
-	 * @throws EditException
-	 */
-	protected abstract void doEditAction(
-			DataflowOutputPortImpl dataflowOutputPort) throws EditException;
-
-	@Override
-	public final DataflowOutputPort getSubject() {
-		return dataflowOutputPort;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractDatalinkEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractDatalinkEdit.java b/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractDatalinkEdit.java
deleted file mode 100644
index 31b7480..0000000
--- a/taverna-workflowmodel-impl/src/main/java/net/sf/taverna/t2/workflowmodel/impl/AbstractDatalinkEdit.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.impl;
-
-import net.sf.taverna.t2.workflowmodel.Datalink;
-import net.sf.taverna.t2.workflowmodel.EditException;
-
-/**
- * Abstraction of an edit acting on a Datalink instance. Handles the check to
- * see that the Datalink supplied is really a DatalinkImpl.
- * 
- * @author David Withers
- */
-public abstract class AbstractDatalinkEdit extends EditSupport<Datalink> {
-	private final DatalinkImpl datalink;
-
-	protected AbstractDatalinkEdit(Datalink datalink) {
-		if (datalink == null)
-			throw new RuntimeException(
-					"Cannot construct a datalink edit with null datalink");
-		if (!(datalink instanceof DatalinkImpl))
-			throw new RuntimeException(
-					"Edit cannot be applied to a Datalink which isn't an instance of DatalinkImpl");
-		this.datalink = (DatalinkImpl) datalink;
-	}
-
-	@Override
-	public final Datalink applyEdit() throws EditException {
-		synchronized (datalink) {
-			doEditAction(datalink);
-		}
-		return datalink;
-	}
-
-	/**
-	 * Do the actual edit here
-	 * 
-	 * @param datalink
-	 *            The DatalinkImpl to which the edit applies
-	 * @throws EditException
-	 */
-	protected abstract void doEditAction(DatalinkImpl datalink)
-			throws EditException;
-
-	@Override
-	public final Datalink getSubject() {
-		return datalink;
-	}
-}


[13/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/HealthCheck.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/HealthCheck.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/HealthCheck.java
new file mode 100644
index 0000000..4bffc3d
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/HealthCheck.java
@@ -0,0 +1,84 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.health;
+
+import org.apache.taverna.visit.VisitKind;
+import org.apache.taverna.visit.Visitor;
+
+/**
+ * A HealthCheck is a kind of visit that determines if the corresponding object
+ * in a workflow (normally an Activity) will work during a workflow run.
+ * 
+ * @author alanrw
+ * 
+ */
+public class HealthCheck extends VisitKind {
+	/*
+	 * The following values indicate the type of results that can be associated
+	 * with a VisitReport generated by a health-checking visitor.
+	 */
+
+	public static final int NO_PROBLEM = 0;
+	public static final int NOT_IMPLEMENTED = 1;
+	public static final int CONNECTION_PROBLEM = 2;
+	public static final int INVALID_URL = 3;
+	public static final int TIME_OUT = 4;
+	public static final int IO_PROBLEM = 5;
+	public static final int MISSING_CLASS = 6;
+	public static final int MISSING_DEPENDENCY = 7;
+	public static final int INVALID_SCRIPT = 8;
+	public static final int NO_CONFIGURATION = 9;
+	public static final int NULL_VALUE = 10;
+	public static final int DEFAULT_VALUE = 11;
+	public static final int BAD_WSDL = 12;
+	public static final int NOT_HTTP = 13;
+	public static final int UNSUPPORTED_STYLE = 14;
+	public static final int UNKNOWN_OPERATION = 15;
+	public static final int NO_ENDPOINTS = 16;
+	public static final int INVALID_CONFIGURATION = 17;
+	public static final int NULL_DATATYPE = 18;
+	public static final int DISABLED = 19;
+	public static final int DATATYPE_SOURCE = 20;
+	public static final int UNRECOGNIZED = 21;
+    public static final int LOOP_CONNECTION = 22;
+    public static final int UNMANAGED_LOCATION = 23;
+    public static final int INCOMPATIBLE_MIMETYPES = 24;
+    public static final int HIGH_PORT_DEPTH = 25;
+
+    @SuppressWarnings("rawtypes")
+	private static final Class healthCheckerClass = HealthChecker.class;
+
+    /**
+	 * Sub-classes of HealthChecker are used to perform HealthCheck visits.
+	 */
+	@Override
+	@SuppressWarnings("unchecked")
+	public Class<? extends Visitor<?>> getVisitorClass() {
+		return healthCheckerClass;
+	}
+
+	private static class Singleton {
+		private static HealthCheck instance = new HealthCheck();
+	}
+
+	public static HealthCheck getInstance() {
+		return Singleton.instance;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/HealthChecker.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/HealthChecker.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/HealthChecker.java
new file mode 100644
index 0000000..618c06b
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/HealthChecker.java
@@ -0,0 +1,36 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.health;
+
+import org.apache.taverna.visit.Visitor;
+
+/**
+ * An SPI interface whose implementation performs a health check on an arbitrary
+ * instance.
+ * 
+ * @author Stuart Owen
+ * @author David Withers
+ * 
+ * @param <Type>
+ *            the type of the item being checked
+ */
+public interface HealthChecker<T> extends Visitor<T> {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/RemoteHealthChecker.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/RemoteHealthChecker.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/RemoteHealthChecker.java
new file mode 100644
index 0000000..94504c6
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/RemoteHealthChecker.java
@@ -0,0 +1,236 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.health;
+
+import static java.lang.System.currentTimeMillis;
+import static java.net.HttpURLConnection.HTTP_GONE;
+import static java.net.HttpURLConnection.HTTP_INTERNAL_ERROR;
+import static java.net.HttpURLConnection.HTTP_NOT_FOUND;
+import static java.net.HttpURLConnection.HTTP_OK;
+import static org.apache.taverna.visit.VisitReport.Status.SEVERE;
+import static org.apache.taverna.visit.VisitReport.Status.WARNING;
+import static org.apache.taverna.workflowmodel.health.HealthCheck.CONNECTION_PROBLEM;
+import static org.apache.taverna.workflowmodel.health.HealthCheck.INVALID_URL;
+import static org.apache.taverna.workflowmodel.health.HealthCheck.IO_PROBLEM;
+import static org.apache.taverna.workflowmodel.health.HealthCheck.NOT_HTTP;
+import static org.apache.taverna.workflowmodel.health.HealthCheck.NO_PROBLEM;
+import static org.apache.taverna.workflowmodel.health.HealthCheck.TIME_OUT;
+
+import java.io.IOException;
+import java.lang.ref.WeakReference;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.SocketTimeoutException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.net.ssl.SSLException;
+
+import org.apache.taverna.visit.VisitReport;
+import org.apache.taverna.visit.VisitReport.Status;
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+
+import org.apache.log4j.Logger;
+
+/**
+ * A RemoteHealthChecker performs a visit to an Activity by trying to contact a
+ * specific endpoint
+ * 
+ * @author alanrw
+ */
+public abstract class RemoteHealthChecker implements HealthChecker<Object> {
+	public static final long ENDPOINT_EXPIRY_MILLIS = 30 * 1000; // 30 seconds
+	private static final Logger logger = Logger.getLogger(RemoteHealthChecker.class);
+	private static int timeout = 10000; // TODO Manage via bean?
+	private static long endpointExpiryMillis = ENDPOINT_EXPIRY_MILLIS;
+
+	public static int getTimeoutInSeconds() {
+		return timeout / 1000;
+	}
+
+	public static void setTimeoutInSeconds(int timeout) {
+		RemoteHealthChecker.timeout = timeout * 1000;
+	}
+
+	public static long getEndpointExpiryInMilliseconds() {
+		return endpointExpiryMillis;
+	}
+
+	public static void setEndpointExpiryInMilliseconds(int endpointExpiry) {
+		endpointExpiryMillis = endpointExpiry;
+	}
+
+	/**
+	 * Clear the cached endpoint statuses. Normally {@link RemoteHealthChecker}
+	 * will only check an endpoint again if it has been more than
+	 * {@link #getEndpointExpiryInMilliseconds()} milliseconds since last check,
+	 * by default 30 seconds.
+	 */
+	public static void clearCachedEndpointStatus() {
+		visitReportsByEndpoint.clear();
+	}
+
+	private static Map<String, WeakReference<VisitReport>> visitReportsByEndpoint = new ConcurrentHashMap<>();
+
+	/**
+	 * Try to contact the specified endpoint as part of the health-checking of
+	 * the Activity.
+	 * 
+	 * @param activity
+	 *            The activity that is being checked
+	 * @param endpoint
+	 *            The String corresponding to the URL of the endpoint
+	 * 
+	 * @return
+	 */
+	public static VisitReport contactEndpoint(Activity<?> activity,
+			String endpoint) {
+		WeakReference<VisitReport> cachedReportRef = visitReportsByEndpoint
+				.get(endpoint);
+		VisitReport cachedReport = null;
+		if (cachedReportRef != null)
+			cachedReport = cachedReportRef.get();
+		if (cachedReport != null) {
+			long now = currentTimeMillis();
+			long age = now - cachedReport.getCheckTime();
+			if (age < getEndpointExpiryInMilliseconds()) {
+				VisitReport newReport;
+				try {
+					// Make a copy
+					newReport = cachedReport.clone();
+					// But changed the subject
+					newReport.setSubject(activity);
+					logger.info("Returning cached report for endpoint "
+							+ endpoint + ": " + newReport);
+					return newReport;
+				} catch (CloneNotSupportedException e) {
+					logger.warn("Could not clone VisitReport " + cachedReport,
+							e);
+				}
+			}
+		}
+		
+		Status status = Status.OK;
+		String message = "Responded OK";
+		int resultId = NO_PROBLEM;
+		URLConnection connection = null;
+		int responseCode = HTTP_OK;
+		Exception ex = null;
+		try {
+			URL url = new URL(endpoint);
+			connection = url.openConnection();
+			connection.setReadTimeout(timeout);
+			connection.setConnectTimeout(timeout);
+			if (connection instanceof HttpURLConnection) {
+				HttpURLConnection httpConnection = (HttpURLConnection) connection;
+				httpConnection.setRequestMethod("HEAD");
+				httpConnection.connect();
+				responseCode = httpConnection.getResponseCode();
+				if (responseCode != HTTP_OK) {
+					try {
+						if ((connection != null)
+								&& (connection.getInputStream() != null))
+							connection.getInputStream().close();
+					} catch (IOException e) {
+						logger.info(
+								"Unable to close connection to " + endpoint, e);
+					}
+					connection = url.openConnection();
+					connection.setReadTimeout(timeout);
+					connection.setConnectTimeout(timeout);
+					httpConnection = (HttpURLConnection) connection;
+					httpConnection.setRequestMethod("GET");
+					httpConnection.connect();
+					responseCode = httpConnection.getResponseCode();
+				}
+				if (responseCode != HTTP_OK) {
+					if ((responseCode > HTTP_INTERNAL_ERROR)) {
+						status = WARNING;
+						message = "Unexpected response";
+						resultId = CONNECTION_PROBLEM;
+					} else if ((responseCode == HTTP_NOT_FOUND)
+							|| (responseCode == HTTP_GONE)) {
+						status = WARNING;
+						message = "Bad response";
+						resultId = CONNECTION_PROBLEM;
+					}
+				}
+			} else {
+			    connection.connect();
+				status = WARNING;
+				message = "Not HTTP";
+				resultId = NOT_HTTP;
+			}
+		} catch (MalformedURLException e) {
+			status = SEVERE;
+			message = "Invalid URL";
+			resultId = INVALID_URL;
+			ex = e;
+		} catch (SocketTimeoutException e) {
+			status = SEVERE;
+			message = "Timed out";
+			resultId = TIME_OUT;
+			ex = e;
+		} catch (SSLException e){
+			// Some kind of error when trying to establish an HTTPS connection to the endpoint
+			status = SEVERE;
+			message = "HTTPS connection problem";
+			resultId = IO_PROBLEM; // SSLException is an IOException
+			ex = e;
+		} catch (IOException e) {
+			status = SEVERE;
+			message = "Read problem";
+			resultId = IO_PROBLEM;
+			ex = e;
+		} finally {
+			try {
+				if ((connection != null)
+						&& (connection.getInputStream() != null))
+					connection.getInputStream().close();
+			} catch (IOException e) {
+				logger.info("Unable to close connection to " + endpoint, e);
+			}
+		}
+		
+		VisitReport vr = new VisitReport(HealthCheck.getInstance(), activity, message,
+				resultId, status);
+		vr.setProperty("endpoint", endpoint);
+		if (ex != null)
+		    vr.setProperty("exception", ex);
+		if (responseCode != HTTP_OK)
+			vr.setProperty("responseCode", Integer.toString(responseCode));
+		if (resultId == TIME_OUT)
+			vr.setProperty("timeOut", Integer.toString(timeout));
+		visitReportsByEndpoint.put(endpoint, new WeakReference<>(vr));
+		return vr;
+	}
+
+	/**
+	 * A remote health-check is time consuming as it tries to contact an
+	 * external resource.
+	 */
+	@Override
+	public boolean isTimeConsuming() {
+		return true;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/UnrecognizedActivityHealthChecker.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/UnrecognizedActivityHealthChecker.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/UnrecognizedActivityHealthChecker.java
new file mode 100644
index 0000000..3232eb6
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/UnrecognizedActivityHealthChecker.java
@@ -0,0 +1,64 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.health;
+
+import static org.apache.taverna.visit.VisitReport.Status.SEVERE;
+import static org.apache.taverna.workflowmodel.health.HealthCheck.UNRECOGNIZED;
+
+import java.util.List;
+
+import org.apache.taverna.visit.VisitReport;
+import org.apache.taverna.workflowmodel.processor.activity.UnrecognizedActivity;
+
+/**
+ * Check on the health of a UnrecognizedActivity
+ * 
+ * @author alanrw
+ * 
+ */
+public class UnrecognizedActivityHealthChecker implements
+		HealthChecker<UnrecognizedActivity> {
+
+	/**
+	 * The visitor can visit {@link UnrecognizedActivity}s.
+	 */
+	@Override
+	public boolean canVisit(Object o) {
+		return ((o != null) && (o instanceof UnrecognizedActivity));
+	}
+
+	/**
+	 * The check is not time consuming as it simply constructs a VisitReport
+	 */
+	@Override
+	public boolean isTimeConsuming() {
+		return false;
+	}
+
+	/**
+	 * The result of the visit is simply a VisitReport to state that the service
+	 * is not available.
+	 */
+	@Override
+	public VisitReport visit(UnrecognizedActivity o, List<Object> ancestry) {
+		return new VisitReport(HealthCheck.getInstance(), o,
+				"Service is unrecognized", UNRECOGNIZED, SEVERE);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/package.html b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/package.html
new file mode 100644
index 0000000..6cbc3b5
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/package.html
@@ -0,0 +1,6 @@
+<body>
+
+A package that contains a set of classes to be used in testing a Dataflow prior to invocation.<br>
+These can carry our various tests such as a service endpoint being accessible. HealthChecker provides an
+SPI extension point to allow 3rd party developers to implement their own Activity checkers.
+</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/package.html b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/package.html
new file mode 100644
index 0000000..abaa693
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/package.html
@@ -0,0 +1,3 @@
+<body>
+Defines classes and interfaces for workflow level entities and events.
+</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/AbstractActivity.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/AbstractActivity.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/AbstractActivity.java
new file mode 100644
index 0000000..a3fc2d7
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/AbstractActivity.java
@@ -0,0 +1,263 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.taverna.annotation.AbstractAnnotatedThing;
+import org.apache.taverna.annotation.annotationbeans.MimeType;
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.workflowmodel.EditException;
+import org.apache.taverna.workflowmodel.Edits;
+import org.apache.taverna.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean;
+import org.apache.taverna.workflowmodel.processor.activity.config.ActivityOutputPortDefinitionBean;
+import org.apache.taverna.workflowmodel.processor.activity.config.ActivityPortsDefinitionBean;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Convenience abstract superclass for generic Activity instances. Parameterised
+ * on the configuration type used by the Activity implementation - when this
+ * object is serialised the getConfiguration method is used to store specific
+ * details of the activity, this is then used immediately after a call to the
+ * default constructor when deserialising from XML on a workflow load.
+ * <p>
+ * This class holds port sets and mappings, and returns references directly to
+ * them rather than copies thereof.
+ * <p>
+ * If you're writing an abstract activity (one that cannot be directly invoked)
+ * you should extend this class for convenience. This can be useful when you
+ * wish to specify some kind of abstract definition of a process which will be
+ * bound at workflow invocation time to a particular concrete activity through
+ * the action of a custom dispatch stack layer (which you will also provide)
+ *
+ * @author Tom Oinn
+ * @author Stuart Owen
+ *
+ * @param <ConfigType>
+ *            type of configuration object to be used to hold configuration
+ *            information
+ */
+public abstract class AbstractActivity<ConfigType> extends
+		AbstractAnnotatedThing<Activity<?>> implements Activity<ConfigType> {
+	private static Logger logger = Logger.getLogger(AbstractActivity.class);
+
+	private Edits edits;
+
+	protected Map<String, String> inputPortMapping = new HashMap<>();
+	protected Map<String, String> outputPortMapping = new HashMap<>();
+	protected Set<ActivityOutputPort> outputPorts = new HashSet<>();
+	protected Set<ActivityInputPort> inputPorts = new HashSet<>();
+
+	@Override
+	public void setEdits(Edits edits) {
+		if (edits == null)
+			throw new IllegalArgumentException("Edits can not be null.");
+		this.edits = edits;
+	}
+
+	/**
+	 * @return the edits
+	 */
+	public Edits getEdits() {
+		if (edits == null)
+			throw new IllegalStateException(
+					"Unable to run this meathod until setEdits has been called");
+		return edits;
+	}
+
+	/**
+	 * @see org.apache.taverna.workflowmodel.processor.activity.Activity#configure(java.lang.Object)
+	 */
+	@Override
+	public abstract void configure(ConfigType conf)
+			throws ActivityConfigurationException;
+
+	/**
+	 * @see org.apache.taverna.workflowmodel.processor.activity.Activity#getConfiguration()
+	 */
+	@Override
+	public abstract ConfigType getConfiguration();
+
+	/*
+	 * (non-Javadoc)
+	 *
+	 * @see org.apache.taverna.workflowmodel.processor.activity.Activity#getInputPortMapping()
+	 */
+	@Override
+	public final Map<String, String> getInputPortMapping() {
+		return this.inputPortMapping;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 *
+	 * @see org.apache.taverna.workflowmodel.processor.activity.Activity#getInputPorts()
+	 */
+	@Override
+	public final Set<ActivityInputPort> getInputPorts() {
+		return inputPorts;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 *
+	 * @see org.apache.taverna.workflowmodel.processor.activity.Activity#getOutputPortMapping()
+	 */
+	@Override
+	public final Map<String, String> getOutputPortMapping() {
+		return this.outputPortMapping;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 *
+	 * @see org.apache.taverna.workflowmodel.processor.activity.Activity#getOutputPorts()
+	 */
+	@Override
+	public final Set<ActivityOutputPort> getOutputPorts() {
+		return outputPorts;
+	}
+
+	/**
+	 * Creates and adds a new input port with the provided properties.
+	 *
+	 * @see #removeInputs()
+	 * @param portName -
+	 *            the name of the port to be created.
+	 * @param portDepth -
+	 *            the depth of the port to be created.
+	 */
+	protected void addInput(
+			String portName,
+			int portDepth,
+			boolean allowsLiteralValues,
+			List<Class<? extends ExternalReferenceSPI>> handledReferenceSchemes,
+			Class<?> translatedElementClass) {
+		if (handledReferenceSchemes == null)
+			handledReferenceSchemes = Collections.emptyList();
+		inputPorts.add(getEdits().createActivityInputPort(portName, portDepth,
+				allowsLiteralValues, handledReferenceSchemes,
+				translatedElementClass));
+	}
+
+	/**
+	 * Creates and adds a new output port with the provided properties.
+	 *
+	 * @see #removeOutputs()
+	 * @param portName -
+	 *            the name of the port to be created.
+	 * @param portDepth -
+	 *            the depth of the port to be created
+	 * @param granularDepth -
+	 *            the granular depth of the port to be created
+	 * @param mimeTypes -
+	 *            a List of String representations of the MIME type this port
+	 *            will emit as outputs.
+	 */
+	protected void addOutput(String portName, int portDepth, int granularDepth) {
+		outputPorts.add(getEdits().createActivityOutputPort(
+				portName, portDepth, granularDepth));
+	}
+
+	/**
+	 * Convenience method, creates a new output port with depth and granular
+	 * depth both set to the value for depth, i.e. no streaming behaviour.
+	 * <p>
+	 *
+	 * @see #removeOutputs()
+	 * @param portName
+	 * @param portDepth
+	 */
+	protected void addOutput(String portName, int portDepth) {
+		addOutput(portName, portDepth, portDepth);
+	}
+
+	/**
+	 * <p>
+	 * Simplifies configuring the Activity input and output ports if its
+	 * ConfigType is an implementation of {@link ActivityPortsDefinitionBean}
+	 * </p>
+	 * <p>
+	 * For an Activity that has ports that are defined dynamically it is natural
+	 * that is ConfigType will not implement this interface.
+	 * </p>
+	 *
+	 * @param configBean
+	 */
+	protected void configurePorts(ActivityPortsDefinitionBean configBean) {
+		removeInputs();
+		for (ActivityInputPortDefinitionBean inputDef : configBean
+				.getInputPortDefinitions()) {
+			addInput(inputDef.getName(), inputDef.getDepth(), inputDef
+					.getAllowsLiteralValues(), inputDef
+					.getHandledReferenceSchemes(), inputDef
+					.getTranslatedElementType());
+			// TODO - use the mime types from the config bean if required,
+			// probably best handled elsewhere though
+		}
+		removeOutputs();
+
+		for (ActivityOutputPortDefinitionBean outputDef : configBean
+				.getOutputPortDefinitions()) {
+			ActivityOutputPort createActivityOutputPort = getEdits()
+					.createActivityOutputPort(outputDef.getName(),
+							outputDef.getDepth(), outputDef.getGranularDepth());
+//			addOutput(outputDef.getName(), outputDef.getDepth(), outputDef
+//					.getGranularDepth());
+			outputPorts.add(createActivityOutputPort);
+			// add the mime types as annotations
+			for (String mimeType : outputDef.getMimeTypes())
+				setMimeType(createActivityOutputPort, mimeType);
+		}
+	}
+
+	private void setMimeType(ActivityOutputPort outputPort, String mimeType) {
+		MimeType mimeTypeAnnotation = new MimeType();
+		mimeTypeAnnotation.setText(mimeType);
+		try {
+			getEdits()
+					.getAddAnnotationChainEdit(outputPort, mimeTypeAnnotation)
+					.doEdit();
+		} catch (EditException e) {
+			logger.error(e);
+		}
+	}
+
+	/**
+	 * Remove existing output ports.
+	 */
+	protected void removeOutputs() {
+		outputPorts.clear();
+	}
+
+	/**
+	 * Remove existing input ports
+	 *
+	 */
+	protected void removeInputs() {
+		inputPorts.clear();
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/AbstractAsynchronousActivity.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/AbstractAsynchronousActivity.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/AbstractAsynchronousActivity.java
new file mode 100644
index 0000000..762b5e9
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/AbstractAsynchronousActivity.java
@@ -0,0 +1,80 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity;
+
+import java.util.Map;
+
+import org.apache.taverna.reference.T2Reference;
+
+/**
+ * Abstract superclass for asynchronous activities. Activity providers should only
+ * have to implement the configuration and invocation methods to have a fully
+ * functional activity - serialisation and deserialisation are handled
+ * automatically.
+ * 
+ * @author Tom Oinn
+ * 
+ * @param <ConfigType>
+ *            the configuration type used for this activity
+ */
+public abstract class AbstractAsynchronousActivity<ConfigType> extends
+		AbstractActivity<ConfigType> implements AsynchronousActivity<ConfigType> {
+
+	/**
+	 * Called immediately after object construction by the deserialisation
+	 * framework with a configuration bean built from the auto-generated XML.
+	 * <p>
+	 * This method is responsible for the creation of input and output ports,
+	 * something that is currently done in the constructor of the Taverna 1
+	 * Processor class.
+	 */
+	@Override
+	public abstract void configure(ConfigType conf)
+			throws ActivityConfigurationException;
+
+	/**
+	 * Get a configuration bean representing the definition of the activity. This
+	 * bean should contain enough information to rebuild the input and output
+	 * port sets, mappings are explicitly handled by the serialisation framework
+	 * but the ports are assumed to be generated during the configuration stage
+	 * rather than explicitly stored.
+	 */
+	@Override
+	public abstract ConfigType getConfiguration();
+
+	/**
+	 * Request an asynchronous invocation of the activity on the specified data.
+	 * The data items are named relative to the input port names of the activity
+	 * (as opposed to the parent processor), the invocation layer is responsible
+	 * for translating these appropriately before this method is called. The
+	 * callback object provides access to a DataManager instance that can be
+	 * used to resolve the entity identifiers in the data map, push results up
+	 * and signal failure conditions.
+	 * <p>
+	 * This method must not block! However it happens this method must return
+	 * immediately after creating the new activity invocation. Do not do any
+	 * heavy lifting in the body of this method without creating a new thread
+	 * specifically for it.
+	 */
+	@Override
+	public abstract void executeAsynch(Map<String, T2Reference> data,
+			AsynchronousActivityCallback callback);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/Activity.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/Activity.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/Activity.java
new file mode 100644
index 0000000..9438009
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/Activity.java
@@ -0,0 +1,92 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity;
+
+import static org.apache.taverna.annotation.HierarchyRole.CHILD;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.taverna.annotation.Annotated;
+import org.apache.taverna.annotation.HierarchyTraversal;
+import org.apache.taverna.workflowmodel.Configurable;
+import org.apache.taverna.workflowmodel.Edits;
+
+/**
+ * Defines a single abstract or concrete invokable activity. Each Processor
+ * contains at least one of these and may contain many, similarly the dispatch
+ * stack may create new Activity instances from e.g. dynamic lookup or
+ * resolution of an abstract activity to a concrete activity or set of
+ * activities.
+ * 
+ * @param <ConfigurationType>
+ *            the ConfigurationType associated with the Activity. This is an
+ *            arbitrary java class that provides details on how the Activity is
+ *            configured..
+ * @author Tom Oinn
+ * @author David Withers
+ */
+public interface Activity<ConfigurationType> extends Annotated<Activity<?>>,
+		Configurable<ConfigurationType> {
+	/**
+	 * An Activity contains a set of named input ports. Names must be unique
+	 * within this set.
+	 *
+	 * @return the set of input ports for this activity
+	 */
+	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
+	Set<ActivityInputPort> getInputPorts();
+
+	/**
+	 * A processor may have different input port names to the activity or
+	 * activities it contains. This map is keyed on the processor input port
+	 * names with the corresponding value being the activity port name.
+	 * 
+	 * @return mapping from processor input port names to activity input port
+	 *         names
+	 */
+	Map<String, String> getInputPortMapping();
+
+	/**
+	 * An Activity contains a set of named output ports. As with input ports
+	 * names must be unique within the set.
+	 * 
+	 * @return
+	 */
+	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
+	Set<ActivityOutputPort> getOutputPorts();
+
+	/**
+	 * Outputs of the activity may be named differently to those of the
+	 * processor. This map is keyed on an activity output port name with each
+	 * corresponding value being the processor output port name to which the
+	 * activity output is bound.
+	 * 
+	 * @return mapping from activity output port name to processor output port
+	 *         name
+	 */
+	Map<String, String> getOutputPortMapping();
+
+	@Override
+	abstract void configure(ConfigurationType conf)
+			throws ActivityConfigurationException;
+
+	void setEdits(Edits edits);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityAndBeanWrapper.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityAndBeanWrapper.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityAndBeanWrapper.java
new file mode 100644
index 0000000..c2e771b
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityAndBeanWrapper.java
@@ -0,0 +1,61 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity;
+
+import java.awt.datatransfer.Transferable;
+
+/**
+ * Used when dragging activities from the palette onto "something". Place it
+ * inside a {@link Transferable} when doing a drag operation. Contains an
+ * {@link Activity} and its configuration bean.
+ * 
+ * @author Ian Dunlop
+ */
+public class ActivityAndBeanWrapper {
+	/** The Activity being dragged */
+	private Activity<?> activity;
+	/** The bean used to configure the activity */
+	private Object bean;
+	private String name;
+
+	public Activity<?> getActivity() {
+		return activity;
+	}
+
+	public void setActivity(Activity<?> activity) {
+		this.activity = activity;
+	}
+
+	public Object getBean() {
+		return bean;
+	}
+
+	public void setBean(Object bean) {
+		this.bean = bean;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityConfigurationException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityConfigurationException.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityConfigurationException.java
new file mode 100644
index 0000000..c3ee06c
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityConfigurationException.java
@@ -0,0 +1,61 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity;
+
+import org.apache.taverna.workflowmodel.ConfigurationException;
+
+/**
+ * Thrown when attempting to configure an Activity instance with an invalid
+ * configuration. Causes may include actual configuration errors, unavailable
+ * activities etc.
+ * 
+ * @author Tom Oinn
+ */
+public class ActivityConfigurationException extends ConfigurationException {
+	private static final long serialVersionUID = 6940385954331153900L;
+
+	/**
+	 * @param msg
+	 *            a message describing the reason for the exception.
+	 */
+	public ActivityConfigurationException(String msg) {
+		super(msg);
+	}
+
+	/**
+	 * @param cause
+	 *            a previous exception that caused this
+	 *            ActivityConfigurationException to be thrown.
+	 */
+	public ActivityConfigurationException(Throwable cause) {
+		super(cause);
+	}
+
+	/**
+	 * @param msg
+	 *            a message describing the reason for the exception.
+	 * @param cause
+	 *            a previous exception that caused this
+	 *            ActivityConfigurationException to be thrown.
+	 */
+	public ActivityConfigurationException(String msg, Throwable cause) {
+		super(msg, cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityFactory.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityFactory.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityFactory.java
new file mode 100644
index 0000000..bbee4ef
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityFactory.java
@@ -0,0 +1,88 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity;
+
+import java.net.URI;
+import java.util.Set;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * Factory for creating {@link Activity} instances.
+ * 
+ * @author David Withers
+ */
+public interface ActivityFactory {
+	/**
+	 * Creates a new <code>Activity</code> instance.
+	 * 
+	 * @return the new <code>Activity</code> instance
+	 */
+	Activity<?> createActivity();
+
+	/**
+	 * What type of <code>Activity</code>s can this factory create?
+	 * 
+	 * @return the type of the <code>Activity</code>s that this factory can
+	 *         create
+	 */
+	URI getActivityType();
+
+	/**
+	 * Returns the JSON Schema for the configuration required by the
+	 * <code>Activity</code>.
+	 * 
+	 * @return the JSON Schema for the configuration required by the
+	 *         <code>Activity</code>
+	 */
+	JsonNode getActivityConfigurationSchema();
+
+	/**
+	 * Returns the <code>ActivityInputPort</code>s that the
+	 * <code>Activity</code> requires to be present in order to execute with the
+	 * specified configuration.
+	 * <p>
+	 * If the <code>Activity</code> does not require any input port for the
+	 * configuration then an empty set is returned.
+	 * 
+	 * @param configuration
+	 *            the configuration
+	 * @return the <code>ActivityInputPort</code>s that the
+	 *         <code>Activity</code> requires to be present in order to execute
+	 */
+	Set<ActivityInputPort> getInputPorts(JsonNode configuration)
+			throws ActivityConfigurationException;
+
+	/**
+	 * Returns the <code>ActivityOutputPort</code>s that the
+	 * <code>Activity</code> requires to be present in order to execute with the
+	 * specified configuration.
+	 * <p>
+	 * If the <code>Activity</code> does not require any output ports for the
+	 * configuration then an empty set is returned.
+	 * 
+	 * @param configuration
+	 *            the configuration
+	 * @return the <code>ActivityOutputPort</code>s that the
+	 *         <code>Activity</code> requires to be present in order to execute
+	 */
+	Set<ActivityOutputPort> getOutputPorts(JsonNode configuration)
+			throws ActivityConfigurationException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityInputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityInputPort.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityInputPort.java
new file mode 100644
index 0000000..a748b75
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityInputPort.java
@@ -0,0 +1,77 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity;
+
+import java.util.List;
+
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.workflowmodel.InputPort;
+
+/**
+ * Specialisation of InputPort to capture the extra information required by
+ * Activity instances.
+ * 
+ * @author Tom Oinn
+ */
+public interface ActivityInputPort extends InputPort, ActivityPort {
+	/**
+	 * Declares that the DataDocument instances fed as input data (either
+	 * directly or as elements of a collection) to this input port must contain
+	 * at least one of the specified ReferenceScheme types. This is used to
+	 * specify that e.g. an activity can only accept URLs, values or similar.
+	 * 
+	 * @return Class objects representing the reference scheme types which this
+	 *         input can handle
+	 */
+	List<Class<? extends ExternalReferenceSPI>> getHandledReferenceSchemes();
+
+	/**
+	 * Literal values are a special case as they are not represented by
+	 * reference schemes - in rare cases activities may choose to deny literal
+	 * values, forcing *all* their inputs to be in a particular reference
+	 * scheme. If this is the case then this method should return false, if the
+	 * activity is capable of handling literal types without any upconversion to
+	 * references (please do implement this!) then it returns false
+	 * 
+	 * @return true if the activity can cope with literal values, false if it
+	 *         requires them to be converted to an instance of a reference
+	 *         scheme class (as defined by getHandledReferenceSchemes)
+	 */
+	boolean allowsLiteralValues();
+
+	/**
+	 * The Java object type desired when the input data reference is converted
+	 * to an object. This is only used by the parent Activity when invoking the
+	 * data facade. Where the input data is a list this returns the type of leaf
+	 * nodes within the collection structure - the instances of this type will
+	 * always be wrapped up in a Java collection rather than an array type
+	 * <p>
+	 * Note that this is not intended to allow activities to consume arbitrary
+	 * java classes, activities such as the API consumer should handle this
+	 * through the reference scheme mechanism backed by an appropriate store
+	 * (most likely an in-memory hash of active objects)
+	 * 
+	 * @return the desired class of the object returned by the data facade when
+	 *         converting the input data reference into a java object. This will
+	 *         almost always be String.class or byte[].class but other cases may
+	 *         exist.
+	 */
+	Class<?> getTranslatedElementClass();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityOutputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityOutputPort.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityOutputPort.java
new file mode 100644
index 0000000..b79f7a8
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityOutputPort.java
@@ -0,0 +1,31 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity;
+
+import org.apache.taverna.workflowmodel.OutputPort;
+
+/**
+ * The output port of an {@link Activity}.
+ * 
+ * @author Stian Soiland-Reyes
+ */
+public interface ActivityOutputPort extends OutputPort, ActivityPort {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityPort.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityPort.java
new file mode 100644
index 0000000..20793d0
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/ActivityPort.java
@@ -0,0 +1,33 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity;
+
+import org.apache.taverna.workflowmodel.Port;
+
+/**
+ * The input or output port of an {@link Activity}.
+ * 
+ * @see ActivityInputPort
+ * @see ActivityOutputPort
+ * @author Stian Soiland-Reyes
+ */
+public interface ActivityPort extends Port {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/AsynchronousActivity.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/AsynchronousActivity.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/AsynchronousActivity.java
new file mode 100644
index 0000000..d34316a
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/AsynchronousActivity.java
@@ -0,0 +1,49 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity;
+
+import java.util.Map;
+
+import org.apache.taverna.reference.T2Reference;
+
+/**
+ * A concrete invokable activity with an asynchronous invocation API and no
+ * knowledge of invocation context. This is the most common concrete activity
+ * type in Taverna 2, it has no knowledge of any enclosing iteration or other
+ * handling process. The activity may stream results in the sense that it can
+ * use the AsynchronousActivityCallback object to push multiple results followed
+ * by a completion event. If a completion event is received by the callback
+ * before any data events the callback will insert a data event containing empty
+ * collections of the appropriate depth.
+ * 
+ * @param <ConfigurationType>
+ *            the ConfigurationType associated with the Activity.
+ * @author Tom Oinn
+ */
+public interface AsynchronousActivity<ConfigurationType> extends
+		Activity<ConfigurationType> {
+	/**
+	 * Invoke the activity in an asynchronous manner. The activity uses the
+	 * specified ActivityCallback object to push results, errors and completion
+	 * events back to the dispatch stack.
+	 */
+	void executeAsynch(Map<String, T2Reference> data,
+			AsynchronousActivityCallback callback);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/AsynchronousActivityCallback.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/AsynchronousActivityCallback.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/AsynchronousActivityCallback.java
new file mode 100644
index 0000000..78be314
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/AsynchronousActivityCallback.java
@@ -0,0 +1,136 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity;
+
+import java.util.Map;
+
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.workflowmodel.processor.dispatch.events.DispatchErrorType;
+
+/**
+ * The callback interface used by instances of AsynchronousActivity to push
+ * results and failure messages back to the invocation layer.
+ * 
+ * @author Tom Oinn
+ */
+public interface AsynchronousActivityCallback {
+	/**
+	 * The invocation context contains resources such as data managers, security
+	 * agents and provenance consumers to be used by the Activity as it runs.
+	 * This replaces the getLocalDataManager and getLocalSecurityManager calls.
+	 */
+	InvocationContext getContext();
+
+	/**
+	 * If an activity proxy wants to create a new thread of activity it should
+	 * use this method unless there is a very good reason not to. This allows
+	 * the workflow framework to control its own thread usage, possibly
+	 * implementing per user, per workflow or per processor thread limit
+	 * policies. Exceptions to this principle might include cases where the
+	 * activity proxy is capable of managing thread usage across all instances
+	 * of that activity type and therefore more efficiently (fewer threads) than
+	 * if it let the workflow manager perform this function.
+	 * 
+	 * @param runMe
+	 *            a Runnable to implement the activity proxy logic.
+	 */
+	void requestRun(Runnable runMe);
+
+	/**
+	 * Push a map of named identifiers out to the invocation layer which is then
+	 * responsible for wrapping them up into an appropriate Job object and
+	 * sending it up the dispatch stack. The keys of the map are names local to
+	 * the activity, the callback object is responsible for rewriting them
+	 * according to the activity mapping rules (i.e. Activity.getXXXPortMapping)
+	 * 
+	 * @param data
+	 *            a single result data packet
+	 * @param index
+	 *            the index of the result in the context of this single process
+	 *            invocation. If there's no streaming involved this should be a
+	 *            zero length int[].
+	 */
+	void receiveResult(Map<String, T2Reference> data, int[] index);
+
+	/**
+	 * If (and only if) the activity is streaming data then this method can be
+	 * called to signal a (possibly partial) completion of the stream. If this
+	 * is a total completion event, i.e. one with a zero length index array and
+	 * there have been no result data sent the callback object will create a
+	 * single job containing empty lists and send that instead otherwise it will
+	 * be passed straight through. The index array is relative to this
+	 * particular activity invocation as the invocation has no contextual
+	 * awareness.
+	 * 
+	 * @param completionIndex
+	 */
+	void receiveCompletion(int[] completionIndex);
+
+	/**
+	 * If the job fails (as opposed to succeeding and sending an error for which
+	 * the receiveResult method is used) this method will cause an error to be
+	 * sent up the dispatch stack, triggering any appropriate handling methods
+	 * such as retry, failover etc. This particular method accepts both a free
+	 * text message and an instance of Throwable for additional information, in
+	 * addition to which it sends an error type which allows upstream layers to
+	 * determine whether they can handle the error or whether it should be
+	 * passed directly upwards.
+	 * 
+	 * @param message
+	 * @param t
+	 */
+	void fail(String message, Throwable t, DispatchErrorType errorType);
+
+	/**
+	 * If the job fails (as opposed to succeeding and sending an error for which
+	 * the receiveResult method is used) this method will cause an error to be
+	 * sent up the dispatch stack, triggering any appropriate handling methods
+	 * such as retry, failover etc. This particular method accepts both a free
+	 * text message and an instance of Throwable for additional information.
+	 * 
+	 * @param message
+	 * @param t
+	 */
+	void fail(String message, Throwable t);
+
+	/**
+	 * If the job fails (as opposed to succeeding and sending an error for which
+	 * the receiveResult method is used) this method will cause an error to be
+	 * sent up the dispatch stack, triggering any appropriate handling methods
+	 * such as retry, failover etc. This method just takes a free text message
+	 * for cases where a failure is properly described by an instance of
+	 * Throwable
+	 * 
+	 * @param message
+	 */
+	void fail(String message);
+
+	/**
+	 * For activities which are going to establish state below the invoke node
+	 * in the monitor tree this method returns the owning process identifier
+	 * allocated to the invoke node. This is particularly necessary for nested
+	 * workflow activities.
+	 * <p>
+	 * Any calls to Monitor.register... must establish a state tree rooted at
+	 * this node, they may assume that this node already exists.
+	 */
+	String getParentProcessIdentifier();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/DisabledActivity.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/DisabledActivity.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/DisabledActivity.java
new file mode 100644
index 0000000..19123aa
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/DisabledActivity.java
@@ -0,0 +1,190 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity;
+
+import java.util.HashSet;
+import java.util.Map;
+
+import org.apache.taverna.workflowmodel.OutputPort;
+
+import org.apache.log4j.Logger;
+
+/**
+ * A disabled activity is a wrapper for an Activity that is offline or similarly
+ * disabled. This cannot be done just by setting a flag on the corresponding
+ * activity as special code needs to be used to create the ports of the disabled
+ * activity that, obviously, cannot be done by confighuring the offline
+ * activity.
+ *
+ * @author alanrw
+ */
+public final class DisabledActivity extends
+		NonExecutableActivity<ActivityAndBeanWrapper> {
+	public static final String URI = "http://ns.taverna.org.uk/2010/activity/disabled";
+	private static final Logger logger = Logger
+			.getLogger(DisabledActivity.class);
+
+	/**
+	 * Conf holds the offline Activity and its configuration.
+	 */
+	private ActivityAndBeanWrapper conf;
+	private Object lastWorkingConfiguration;
+
+	/**
+	 * It is not possible to create a "naked" DisabledActivity.
+	 */
+	private DisabledActivity() {
+		super();
+		lastWorkingConfiguration = null;
+	}
+
+	/**
+	 * Create a DisabledActivity that represents an offline activity of the
+	 * specified class with the specified configuration. This constructor is
+	 * commonly used when reading in an Activity which cannot be initially
+	 * configured because it is offline.
+	 *
+	 * @param activityClass
+	 *            The class of Activity that is offline.
+	 * @param config
+	 *            The configuration of the offline Activity.
+	 * @throws InstantiationException
+	 * @throws IllegalAccessException
+	 * @throws ActivityConfigurationException
+	 */
+	public DisabledActivity(Class<? extends Activity<?>> activityClass,
+			Object config) throws InstantiationException,
+			IllegalAccessException, ActivityConfigurationException {
+		this(activityClass.newInstance(), config);
+	}
+
+	/**
+	 * Create a DisabledActivity that represents a specific Activity with its
+	 * configuration.
+	 *
+	 * @param activity
+	 *            The Activity that is offline
+	 * @param config
+	 *            The configuration of the activity.
+	 */
+	public DisabledActivity(Activity<?> activity, Object config) {
+		this();
+		ActivityAndBeanWrapper disabledConfig = new ActivityAndBeanWrapper();
+		disabledConfig.setActivity(activity);
+		disabledConfig.setBean(config);
+		try {
+			configure(disabledConfig);
+		} catch (ActivityConfigurationException e) {
+			logger.error(e);
+		}
+	}
+
+	/**
+	 * Create a DisabledActivity that represents a specific Activity that is now
+	 * disabled e.g. by its remote endpoint going offline. Note that in this
+	 * case, the ports of the DisabledActivity and their mapping to the
+	 * containing Processor's ports can be inherited from the Activity that is
+	 * now disabled.
+	 * 
+	 * @param activity
+	 *            The Activity that is now disabled.
+	 */
+	public DisabledActivity(Activity<?> activity) {
+		this(activity, activity.getConfiguration());
+		for (ActivityInputPort aip : activity.getInputPorts())
+			addInput(aip.getName(), aip.getDepth(), aip.allowsLiteralValues(),
+					aip.getHandledReferenceSchemes(),
+					aip.getTranslatedElementClass());
+		for (OutputPort op : activity.getOutputPorts())
+			addOutput(op.getName(), op.getDepth(), op.getGranularDepth());
+		getInputPortMapping().clear();
+		getInputPortMapping().putAll(activity.getInputPortMapping());
+		getOutputPortMapping().clear();
+		getOutputPortMapping().putAll(activity.getOutputPortMapping());
+	}
+
+	@Override
+	public void configure(ActivityAndBeanWrapper conf)
+			throws ActivityConfigurationException {
+		this.conf = conf;
+	}
+
+	@Override
+	public ActivityAndBeanWrapper getConfiguration() {
+		return conf;
+	}
+
+	/**
+	 * @return The Activity that has been disabled
+	 */
+	public Activity<?> getActivity() {
+		return getConfiguration().getActivity();
+	}
+
+	/**
+	 * @return The configuration of the Activity that has been disabled
+	 */
+	public Object getActivityConfiguration() {
+		return getConfiguration().getBean();
+	}
+
+	public boolean configurationWouldWork() {
+		return configurationWouldWork(conf.getBean());
+	}
+
+	public boolean configurationWouldWork(Object newConfig) {
+		boolean result = true;
+		lastWorkingConfiguration = null;
+		try {
+			@SuppressWarnings("unchecked")
+			Activity<Object> aa = conf.getActivity().getClass().newInstance();
+			aa.configure(newConfig);
+			boolean unknownPort = false;
+			Map<String, String> currentInputPortMap = getInputPortMapping();
+			HashSet<String> currentInputNames = new HashSet<>();
+			currentInputNames.addAll(currentInputPortMap.values()) ;
+			for (ActivityInputPort aip : aa.getInputPorts())
+				currentInputNames.remove(aip.getName());
+			unknownPort = !currentInputNames.isEmpty();
+
+			if (!unknownPort) {
+				Map<String, String> currentOutputPortMap = getOutputPortMapping();
+				HashSet<String> currentOutputNames = new HashSet<>();
+				currentOutputNames.addAll(currentOutputPortMap.values());
+				for (OutputPort aop : aa.getOutputPorts())
+					currentOutputNames.remove(aop.getName());
+				unknownPort = !currentOutputNames.isEmpty();
+			}
+			if (unknownPort)
+				result = false;
+		} catch (ActivityConfigurationException ex) {
+			result = false;
+		} catch (InstantiationException|IllegalAccessException e) {
+			return false;
+		}
+		if (result)
+		    lastWorkingConfiguration = newConfig;
+		return result;
+	}
+
+	public Object getLastWorkingConfiguration() {
+	    return lastWorkingConfiguration;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/Job.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/Job.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/Job.java
new file mode 100644
index 0000000..66b61ac
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/Job.java
@@ -0,0 +1,129 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity;
+
+import java.util.Map;
+
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.invocation.IterationInternalEvent;
+import org.apache.taverna.invocation.ProcessIdentifierException;
+import org.apache.taverna.reference.T2Reference;
+
+/**
+ * Contains a (possibly partial) job description. A job is the smallest entity
+ * that can be enacted by the invocation layer of the dispatch stack within a
+ * processor. Jobs are partial jobs if the set of keys in the data map is not
+ * identical to the set of named input ports on the processor within which the
+ * job is used. These objects are used internally within the processor to stage
+ * data during iteration and within the dispatch stack, they do not appear
+ * within the workflow itself.
+ * 
+ * @author Tom Oinn
+ */
+public class Job extends IterationInternalEvent<Job> {
+	private Map<String, T2Reference> dataMap;
+
+	/**
+	 * Push the index array onto the owning process name and return the new Job
+	 * object. Does not modify this object, the method creates a new Job with
+	 * the modified index array and owning process
+	 * 
+	 * @return
+	 */
+	@Override
+	public Job pushIndex() {
+		return new Job(getPushedOwningProcess(), new int[] {}, dataMap, context);
+	}
+
+	/**
+	 * Pull the index array previous pushed to the owning process name and
+	 * prepend it to the current index array
+	 */
+	@Override
+	public Job popIndex() {
+		return new Job(owner.substring(0, owner.lastIndexOf(':')),
+				getPoppedIndex(), dataMap, context);
+	}
+
+	/**
+	 * The actual data carried by this (partial) Job object is in the form of a
+	 * map, where the keys of the map are Strings identifying the named input
+	 * and the values are Strings containing valid data identifiers within the
+	 * context of a visible DataManager object (see CloudOne specification for
+	 * further information on the DataManager system)
+	 * 
+	 * @return Map of name to data reference for this Job
+	 */
+	public Map<String, T2Reference> getData() {
+		return this.dataMap;
+	}
+
+	/**
+	 * Create a new Job object with the specified owning process (colon
+	 * separated 'list' of process identifiers), index array and data map
+	 * 
+	 * @param owner
+	 * @param index
+	 * @param data
+	 */
+	public Job(String owner, int[] index, Map<String, T2Reference> data,
+			InvocationContext context) {
+		super(owner, index, context);
+		this.dataMap = data;
+	}
+
+	/**
+	 * Show the owner, index array and data map in textual form for debugging
+	 * and any other purpose. Jobs appear in the form :
+	 * 
+	 * <pre>
+	 * Job(Process1)[2,0]{Input2=dataID4,Input1=dataID3}
+	 * </pre>
+	 */
+	@Override
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		sb.append("Job(").append(owner).append(")[");
+		String sep = "";
+		for (int i : index) {
+			sb.append(sep).append(i);
+			sep = ",";
+		}
+		sb.append("]{");
+		sep = "";
+		for (String key : dataMap.keySet()) {
+			sb.append(sep).append(key).append("=").append(dataMap.get(key));
+			sep = ",";
+		}
+		sb.append("}");
+		return sb.toString();
+	}
+
+	@Override
+	public Job popOwningProcess() throws ProcessIdentifierException {
+		return new Job(popOwner(), index, dataMap, context);
+	}
+
+	@Override
+	public Job pushOwningProcess(String localProcessName)
+			throws ProcessIdentifierException {
+		return new Job(pushOwner(localProcessName), index, dataMap, context);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/LockedNestedDataflow.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/LockedNestedDataflow.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/LockedNestedDataflow.java
new file mode 100644
index 0000000..f93d062
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/LockedNestedDataflow.java
@@ -0,0 +1,30 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity;
+
+/**
+ * A LockedNestedDataflow is intended to be unchangeable. It is normally defined
+ * elsewhere to the workflow.
+ * 
+ * @author alanrw
+ */
+public interface LockedNestedDataflow extends NestedDataflow {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/MonitorableAsynchronousActivity.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/MonitorableAsynchronousActivity.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/MonitorableAsynchronousActivity.java
new file mode 100644
index 0000000..a6e3a2d
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/MonitorableAsynchronousActivity.java
@@ -0,0 +1,55 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.taverna.monitor.MonitorableProperty;
+import org.apache.taverna.reference.T2Reference;
+
+/**
+ * An extension of AsynchronousActivity with the additional stipulation that
+ * implementing classes must return a set of monitorable properties for the
+ * activity invocation instance when invoked. This allows for deep state
+ * management, where the monitor state extends out from the workflow engine into
+ * the remote resources themselves and is dependant on the resource proxied by
+ * the activity implementation providing this information.
+ * 
+ * @author Tom Oinn
+ */
+public interface MonitorableAsynchronousActivity<ConfigType> extends
+		AsynchronousActivity<ConfigType> {
+	/**
+	 * This has the same invocation semantics as
+	 * {@link AsynchronousActivity}<code>.executeAsynch</code> and all
+	 * implementations should also implement that method, with the difference
+	 * that this one returns immediately with a set of monitorable properties
+	 * which represent monitorable or steerable state within the invocation
+	 * itself.
+	 * 
+	 * @param data
+	 * @param callback
+	 * @return a set of monitorable properties representing internal state of
+	 *         the invoked resource
+	 */
+	Set<MonitorableProperty<?>> executeAsynchWithMonitoring(
+			Map<String, T2Reference> data, AsynchronousActivityCallback callback);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/NestedDataflow.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/NestedDataflow.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/NestedDataflow.java
new file mode 100644
index 0000000..e70f8b1
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/NestedDataflow.java
@@ -0,0 +1,35 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity;
+
+import org.apache.taverna.workflowmodel.Dataflow;
+
+/**
+ * Nested workflows/dataflows can come in many shapes and sizes - in-line, url
+ * etc. However, they are all {@link Dataflow}s. Implement this in any
+ * implementation of a Nested dataflow
+ * 
+ * @author Ian Dunlop
+ */
+public interface NestedDataflow {
+	Dataflow getNestedDataflow();
+
+	void setNestedDataflow(Dataflow dataflow);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/NestedDataflowSource.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/NestedDataflowSource.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/NestedDataflowSource.java
new file mode 100644
index 0000000..21446d9
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/NestedDataflowSource.java
@@ -0,0 +1,34 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity;
+
+import org.apache.taverna.workflowmodel.Dataflow;
+
+/**
+ * @author alanrw
+ */
+public interface NestedDataflowSource<T extends NestedDataflow> {
+	T getNestedDataflow();
+
+	Dataflow getParentDataflow();
+
+	@Override
+	String toString();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/NonExecutableActivity.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/NonExecutableActivity.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/NonExecutableActivity.java
new file mode 100644
index 0000000..9b94d74
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/NonExecutableActivity.java
@@ -0,0 +1,96 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity;
+
+import java.util.Map;
+
+import org.apache.taverna.reference.T2Reference;
+
+/**
+ * A non-executable activity is a wrapper for an Activity that cannot be
+ * executed, for example because it is offline or unrecognized.
+ * 
+ * @author alanrw
+ */
+public abstract class NonExecutableActivity<T> extends
+		AbstractAsynchronousActivity<T> {
+	public static final String URI = "http://ns.taverna.org.uk/2010/activity/nonExecutable";
+
+	/**
+	 * It is not possible to create a "naked" NonExecutableActivity.
+	 */
+	protected NonExecutableActivity() {
+		super();
+	}
+
+	/**
+	 * Add an input to the NonExecutableActivity with the specified name.
+	 * 
+	 * @param portName
+	 */
+	public void addProxyInput(String portName) {
+		super.addInput(portName, 0, true, null, null);
+	}
+
+	/**
+	 * Add an input to the NonExecutableActivity with the specified name and
+	 * depth.
+	 * 
+	 * @param portName
+	 * @param depth
+	 */
+	public void addProxyInput(String portName, int depth) {
+		super.addInput(portName, depth, true, null, null);
+	}
+
+	/**
+	 * Add an output to the NonExecutableActivity with the specified name
+	 * 
+	 * @param portName
+	 */
+	public void addProxyOutput(String portName) {
+		super.addOutput(portName, 0);
+	}
+
+	/**
+	 * Add an output to the NonExecutableActivity with the specified name and
+	 * depth
+	 * 
+	 * @param portName
+	 * @param depth
+	 */
+	public void addProxyOutput(String portName, int depth) {
+		super.addOutput(portName, depth);
+	}
+
+	/**
+	 * Attempting to run a NonExecutableActivity will always fail.
+	 */
+	@Override
+	public void executeAsynch(Map<String, T2Reference> data,
+			final AsynchronousActivityCallback callback) {
+		callback.requestRun(new Runnable() {
+			@Override
+			public void run() {
+				callback.fail("The service is not executable");
+			}
+		});
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/SupersededActivity.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/SupersededActivity.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/SupersededActivity.java
new file mode 100644
index 0000000..cb01d6f
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/processor/activity/SupersededActivity.java
@@ -0,0 +1,32 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.processor.activity;
+
+/**
+ * 
+ * A superseded activity is one which has been replaced be another activity type
+ * of similar functionality but different configuration and name
+ * 
+ * @author alanrw
+ */
+public interface SupersededActivity<ConfigurationType> extends
+		Activity<ConfigurationType> {
+	Activity<?> getReplacementActivity() throws ActivityConfigurationException;
+}


[51/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.

Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/commit/5f1ddb71
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/tree/5f1ddb71
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/diff/5f1ddb71

Branch: refs/heads/master
Commit: 5f1ddb7158e6e415b3a215e76eb2178041f0e99d
Parents: a368539
Author: redmitry <re...@84.88.50.62>
Authored: Mon Mar 23 17:37:01 2015 +0100
Committer: redmitry <re...@84.88.50.62>
Committed: Mon Mar 23 17:37:01 2015 +0100

----------------------------------------------------------------------
 .../resources/META-INF/spring/context-osgi.xml  |   22 +-
 .../resources/META-INF/spring/context-osgi.xml  |    6 +-
 .../activities/testutils/ActivityInvoker.java   |  250 ----
 .../t2/activities/testutils/DummyCallback.java  |  106 --
 .../activities/testutils/LocationConstants.java |   31 -
 .../activities/testutils/ActivityInvoker.java   |  249 ++++
 .../activities/testutils/DummyCallback.java     |  105 ++
 .../activities/testutils/LocationConstants.java |   30 +
 .../context-parts/componentservices.xml         |   32 +-
 .../resources/context-parts/dao_hibernate.xml   |   28 +-
 .../dao_hibernate_transactional.xml             |   28 +-
 .../resources/context-parts/dao_inmemory.xml    |   12 +-
 .../context-parts/hibernateprops_derby.xml      |    4 +-
 .../resources/context-parts/raven_local.xml     |    4 +-
 .../context-parts/referenceservice.xml          |   16 +-
 .../capability/api/ActivityService.java         |    2 +-
 .../capability/api/DispatchLayerService.java    |    2 +-
 .../activity/impl/ActivityServiceImpl.java      |   14 +-
 .../dispatch/impl/DispatchLayerServiceImpl.java |    6 +-
 .../spring/taverna-capability-context-osgi.xml  |    8 +-
 .../impl/CredentialManagerImpl.java             |    6 +-
 .../spring/credential-manager-impl-context.xml  |    2 +-
 .../impl/CredentialManagerImplIT.java           |    4 +-
 .../impl/CredentialManagerImplTest.java         |   30 +-
 .../impl/HTTPAuthenticatorIT.java               |    2 +-
 .../credentialmanager/CredentialManager.java    |    2 +-
 .../credentialmanager/KeystoreChangedEvent.java |    2 +-
 ...rity.credentialmanager.CredentialProviderSPI |    1 -
 ...rity.credentialmanager.CredentialProviderSPI |    1 +
 .../database/DatabaseConfiguration.java         |  123 ++
 .../configuration/database/DatabaseManager.java |   44 +
 .../database/DatabaseConfiguration.java         |  124 --
 .../configuration/database/DatabaseManager.java |   45 -
 .../impl/DatabaseConfigurationImpl.java         |  251 ++++
 .../database/impl/DatabaseManagerImpl.java      |  174 +++
 .../impl/DatabaseConfigurationImpl.java         |  252 ----
 .../database/impl/DatabaseManagerImpl.java      |  155 ---
 .../META-INF/spring/database-context-osgi.xml   |    4 +-
 .../activities/dataflow/DataflowActivity.java   |  168 ---
 .../dataflow/DataflowActivityFactory.java       |   81 --
 .../dataflow/DataflowActivityHealthChecker.java |   42 -
 .../activities/dataflow/DataflowActivity.java   |  167 +++
 .../dataflow/DataflowActivityFactory.java       |   80 ++
 .../dataflow/DataflowActivityHealthChecker.java |   41 +
 ...averna.t2.workflowmodel.health.HealthChecker |    2 +-
 .../spring/dataflow-activity-context-osgi.xml   |    6 +-
 .../spring/dataflow-activity-context.xml        |    4 +-
 .../dataflow/DataflowActivityFactoryTest.java   |   65 -
 .../dataflow/DataflowActivityTest.java          |   98 --
 .../dataflow/DataflowActivityFactoryTest.java   |   65 +
 .../dataflow/DataflowActivityTest.java          |   97 ++
 .../execution/api/AbstractExecution.java        |  138 ++
 .../api/AbstractExecutionEnvironment.java       |   78 ++
 .../execution/api/AbstractExecutionService.java |  138 ++
 .../platform/execution/api/Execution.java       |  103 ++
 .../execution/api/ExecutionEnvironment.java     |  128 ++
 .../api/ExecutionEnvironmentService.java        |   51 +
 .../execution/api/ExecutionService.java         |  148 +++
 .../api/InvalidExecutionIdException.java        |   47 +
 .../execution/api/InvalidWorkflowException.java |   47 +
 .../execution/api/WorkflowCompiler.java         |   55 +
 .../execution/api/AbstractExecution.java        |  139 --
 .../api/AbstractExecutionEnvironment.java       |   79 --
 .../execution/api/AbstractExecutionService.java |  139 --
 .../platform/execution/api/Execution.java       |  104 --
 .../execution/api/ExecutionEnvironment.java     |  129 --
 .../api/ExecutionEnvironmentService.java        |   52 -
 .../execution/api/ExecutionService.java         |  149 ---
 .../api/InvalidExecutionIdException.java        |   48 -
 .../execution/api/InvalidWorkflowException.java |   48 -
 .../execution/api/WorkflowCompiler.java         |   36 -
 .../execution/api/AbstractExecutionTest.java    |  127 ++
 .../execution/api/AbstractExecutionTest.java    |  128 --
 .../impl/hadoop/CrossProductInputFormat.java    |  107 ++
 .../impl/hadoop/CrossProductInputSplit.java     |   87 ++
 .../impl/hadoop/CrossProductRecordReader.java   |  131 ++
 .../execution/impl/hadoop/CrossProductTest.java |  115 ++
 .../execution/impl/hadoop/DotProductTest.java   |  105 ++
 .../impl/hadoop/TavernaInputFormat.java         |   51 +
 .../impl/hadoop/TavernaInputSplit.java          |   68 +
 .../execution/impl/hadoop/TavernaMapper.java    |   94 ++
 .../impl/hadoop/TavernaRecordReader.java        |  105 ++
 .../execution/impl/hadoop/TavernaReducer.java   |   43 +
 .../platform/execution/impl/hadoop/Test.java    |   68 +
 .../impl/hadoop/TextArrayWritable.java          |   30 +
 .../impl/hadoop/CrossProductInputFormat.java    |  108 --
 .../impl/hadoop/CrossProductInputSplit.java     |   88 --
 .../impl/hadoop/CrossProductRecordReader.java   |  112 --
 .../execution/impl/hadoop/CrossProductTest.java |  116 --
 .../execution/impl/hadoop/DotProductTest.java   |  106 --
 .../impl/hadoop/TavernaInputFormat.java         |   52 -
 .../impl/hadoop/TavernaInputSplit.java          |   69 -
 .../execution/impl/hadoop/TavernaMapper.java    |   75 --
 .../impl/hadoop/TavernaRecordReader.java        |  106 --
 .../execution/impl/hadoop/TavernaReducer.java   |   24 -
 .../platform/execution/impl/hadoop/Test.java    |   69 -
 .../impl/hadoop/TextArrayWritable.java          |   31 -
 .../impl/ExecutionEnvironmentServiceImpl.java   |  353 +++++
 .../impl/ExecutionEnvironmentServiceImpl.java   |  354 -----
 .../META-INF/spring/execution-context-osgi.xml  |    4 +-
 .../META-INF/spring/execution-context.xml       |    2 +-
 .../execution/impl/local/LocalExecution.java    |  242 ++++
 .../impl/local/LocalExecutionEnvironment.java   |   86 ++
 .../impl/local/LocalExecutionMonitor.java       |  547 ++++++++
 .../impl/local/LocalExecutionService.java       |  148 +++
 .../impl/local/LocalProcessorReport.java        |  160 +++
 .../execution/impl/local/StaticProperty.java    |   65 +
 .../impl/local/T2ReferenceConverter.java        |   57 +
 .../impl/local/WorkflowToDataflowMapper.java    |  526 ++++++++
 .../execution/impl/local/LocalExecution.java    |  243 ----
 .../impl/local/LocalExecutionEnvironment.java   |   86 --
 .../impl/local/LocalExecutionMonitor.java       |  548 --------
 .../impl/local/LocalExecutionService.java       |  149 ---
 .../impl/local/LocalProcessorReport.java        |  141 --
 .../execution/impl/local/StaticProperty.java    |   66 -
 .../impl/local/T2ReferenceConverter.java        |   41 -
 .../impl/local/WorkflowToDataflowMapper.java    |  527 --------
 .../spring/execution-local-context-osgi.xml     |    8 +-
 .../META-INF/spring/execution-local-context.xml |    2 +-
 .../impl/local/LocalExecutionTest.java          |  165 +++
 .../impl/local/LocalExecutionTest.java          |  166 ---
 .../src/test/resources/t2flow/beanshell.t2flow  |   76 +-
 .../src/test/resources/t2flow/in-out.t2flow     |   18 +-
 .../execution/impl/remote/RemoteExecution.java  |   95 ++
 .../impl/remote/RemoteExecutionService.java     |   59 +
 .../execution/impl/remote/RemoteExecution.java  |   96 --
 .../impl/remote/RemoteExecutionService.java     |   60 -
 .../spring/execution-remote-context-osgi.xml    |    2 +-
 .../spring/execution-remote-context.xml         |    2 +-
 .../taverna/t2/lang/observer/MultiCaster.java   |   93 --
 .../sf/taverna/t2/lang/observer/Observable.java |   56 -
 .../sf/taverna/t2/lang/observer/Observer.java   |   44 -
 .../t2/lang/observer/SwingAwareObserver.java    |   51 -
 .../taverna/t2/lang/observer/package-info.java  |   73 -
 .../taverna/lang/observer/MultiCaster.java      |   92 ++
 .../taverna/lang/observer/Observable.java       |   55 +
 .../apache/taverna/lang/observer/Observer.java  |   43 +
 .../lang/observer/SwingAwareObserver.java       |   50 +
 .../taverna/lang/observer/package-info.java     |   72 +
 .../taverna/t2/lang/observer/ObserverTest.java  |  133 --
 .../taverna/lang/observer/ObserverTest.java     |  128 ++
 .../t2/reference/AbstractExternalReference.java |   89 --
 .../t2/reference/ContextualizedT2Reference.java |   47 -
 .../sf/taverna/t2/reference/DaoException.java   |   47 -
 .../t2/reference/DereferenceException.java      |   48 -
 .../sf/taverna/t2/reference/ErrorDocument.java  |   56 -
 .../taverna/t2/reference/ErrorDocumentDao.java  |   64 -
 .../t2/reference/ErrorDocumentService.java      |  152 ---
 .../reference/ErrorDocumentServiceCallback.java |   47 -
 .../ErrorDocumentServiceException.java          |   48 -
 .../reference/ExternalReferenceBuilderSPI.java  |   90 --
 .../ExternalReferenceConstructionException.java |   50 -
 .../t2/reference/ExternalReferenceSPI.java      |  132 --
 .../ExternalReferenceTranslatorSPI.java         |   96 --
 .../ExternalReferenceValidationException.java   |   50 -
 .../net/sf/taverna/t2/reference/Identified.java |   36 -
 .../sf/taverna/t2/reference/IdentifiedList.java |   46 -
 .../net/sf/taverna/t2/reference/ListDao.java    |   67 -
 .../sf/taverna/t2/reference/ListService.java    |  144 --
 .../t2/reference/ListServiceCallback.java       |   47 -
 .../t2/reference/ListServiceException.java      |   48 -
 .../taverna/t2/reference/ReferenceContext.java  |   66 -
 .../taverna/t2/reference/ReferenceService.java  |  294 ----
 .../ReferenceServiceCacheProvider.java          |   52 -
 .../t2/reference/ReferenceServiceException.java |   47 -
 .../ReferenceServiceResolutionCallback.java     |   47 -
 .../sf/taverna/t2/reference/ReferenceSet.java   |   53 -
 .../ReferenceSetAugmentationException.java      |   47 -
 .../t2/reference/ReferenceSetAugmentor.java     |   92 --
 .../ReferenceSetAugmentorCallback.java          |   53 -
 .../taverna/t2/reference/ReferenceSetDao.java   |   82 --
 .../t2/reference/ReferenceSetService.java       |  181 ---
 .../reference/ReferenceSetServiceCallback.java  |   47 -
 .../reference/ReferenceSetServiceException.java |   48 -
 .../t2/reference/ReferencedDataNature.java      |   45 -
 .../t2/reference/StackTraceElementBean.java     |   54 -
 .../t2/reference/StreamToValueConverterSPI.java |   48 -
 .../sf/taverna/t2/reference/T2Reference.java    |  102 --
 .../t2/reference/T2ReferenceGenerator.java      |   81 --
 .../taverna/t2/reference/T2ReferenceType.java   |   47 -
 .../ValueCarryingExternalReference.java         |   44 -
 .../ValueToReferenceConversionException.java    |   48 -
 .../reference/ValueToReferenceConverterSPI.java |   65 -
 .../t2/reference/WorkflowRunIdEntity.java       |   44 -
 .../annotations/DeleteIdentifiedOperation.java  |   18 -
 .../annotations/GetIdentifiedOperation.java     |   38 -
 .../annotations/PutIdentifiedOperation.java     |   38 -
 .../t2/reference/annotations/package.html       |    4 -
 .../reference/h3/HibernateComponentClass.java   |   38 -
 .../t2/reference/h3/HibernateMappedEntity.java  |   39 -
 .../net/sf/taverna/t2/reference/h3/package.html |    8 -
 .../net/sf/taverna/t2/reference/package.html    |   43 -
 .../reference/AbstractExternalReference.java    |   88 ++
 .../reference/ContextualizedT2Reference.java    |   46 +
 .../apache/taverna/reference/DaoException.java  |   46 +
 .../taverna/reference/DereferenceException.java |   47 +
 .../apache/taverna/reference/ErrorDocument.java |   55 +
 .../taverna/reference/ErrorDocumentDao.java     |   63 +
 .../taverna/reference/ErrorDocumentService.java |  151 +++
 .../reference/ErrorDocumentServiceCallback.java |   46 +
 .../ErrorDocumentServiceException.java          |   47 +
 .../reference/ExternalReferenceBuilderSPI.java  |   89 ++
 .../ExternalReferenceConstructionException.java |   49 +
 .../taverna/reference/ExternalReferenceSPI.java |  131 ++
 .../ExternalReferenceTranslatorSPI.java         |   95 ++
 .../ExternalReferenceValidationException.java   |   49 +
 .../apache/taverna/reference/Identified.java    |   35 +
 .../taverna/reference/IdentifiedList.java       |   45 +
 .../org/apache/taverna/reference/ListDao.java   |   66 +
 .../apache/taverna/reference/ListService.java   |  143 ++
 .../taverna/reference/ListServiceCallback.java  |   46 +
 .../taverna/reference/ListServiceException.java |   47 +
 .../taverna/reference/ReferenceContext.java     |   65 +
 .../taverna/reference/ReferenceService.java     |  293 ++++
 .../ReferenceServiceCacheProvider.java          |   51 +
 .../reference/ReferenceServiceException.java    |   46 +
 .../ReferenceServiceResolutionCallback.java     |   46 +
 .../apache/taverna/reference/ReferenceSet.java  |   52 +
 .../ReferenceSetAugmentationException.java      |   46 +
 .../reference/ReferenceSetAugmentor.java        |   91 ++
 .../ReferenceSetAugmentorCallback.java          |   52 +
 .../taverna/reference/ReferenceSetDao.java      |   81 ++
 .../taverna/reference/ReferenceSetService.java  |  180 +++
 .../reference/ReferenceSetServiceCallback.java  |   46 +
 .../reference/ReferenceSetServiceException.java |   47 +
 .../taverna/reference/ReferencedDataNature.java |   44 +
 .../reference/StackTraceElementBean.java        |   53 +
 .../reference/StreamToValueConverterSPI.java    |   47 +
 .../apache/taverna/reference/T2Reference.java   |  101 ++
 .../taverna/reference/T2ReferenceGenerator.java |   80 ++
 .../taverna/reference/T2ReferenceType.java      |   46 +
 .../ValueCarryingExternalReference.java         |   43 +
 .../ValueToReferenceConversionException.java    |   47 +
 .../reference/ValueToReferenceConverterSPI.java |   64 +
 .../taverna/reference/WorkflowRunIdEntity.java  |   43 +
 .../annotations/DeleteIdentifiedOperation.java  |   37 +
 .../annotations/GetIdentifiedOperation.java     |   37 +
 .../annotations/PutIdentifiedOperation.java     |   37 +
 .../taverna/reference/annotations/package.html  |    4 +
 .../reference/h3/HibernateComponentClass.java   |   37 +
 .../reference/h3/HibernateMappedEntity.java     |   38 +
 .../apache/taverna/reference/h3/package.html    |    8 +
 .../org/apache/taverna/reference/package.html   |   43 +
 .../reference/AbstractExternalReference.hbm.xml |   15 -
 .../reference/AbstractExternalReference.hbm.xml |   12 +
 .../platform/spring/jdbc/TemporaryJDBC.java     |   75 --
 .../taverna/platform/spring/jdbc/package.html   |    6 -
 .../t2/reference/impl/AbstractEntityImpl.java   |   66 -
 .../impl/AbstractErrorDocumentServiceImpl.java  |  119 --
 .../reference/impl/AbstractListServiceImpl.java |  100 --
 .../impl/AbstractReferenceServiceImpl.java      |  171 ---
 .../impl/AbstractReferenceSetServiceImpl.java   |  160 ---
 .../t2/reference/impl/AbstractServiceImpl.java  |   44 -
 .../impl/AbstractT2ReferenceGenerator.java      |  111 --
 .../taverna/t2/reference/impl/CacheAspect.java  |  127 --
 .../impl/ContextualizedT2ReferenceImpl.java     |   61 -
 .../reference/impl/EmptyReferenceContext.java   |   46 -
 .../t2/reference/impl/ErrorDocumentImpl.java    |  120 --
 .../impl/ErrorDocumentServiceImpl.java          |  163 ---
 .../impl/HibernateErrorDocumentDao.java         |  154 ---
 .../t2/reference/impl/HibernateListDao.java     |  151 ---
 .../impl/HibernateReferenceSetDao.java          |  197 ---
 .../t2/reference/impl/IdentifiedArrayList.java  |  252 ----
 .../impl/InMemoryErrorDocumentDao.java          |   69 -
 .../t2/reference/impl/InMemoryListDao.java      |   69 -
 .../reference/impl/InMemoryReferenceSetDao.java |   72 -
 .../t2/reference/impl/ListServiceImpl.java      |  136 --
 .../t2/reference/impl/ReferenceServiceImpl.java |  731 ----------
 .../impl/ReferenceSetAugmentorImpl.java         |  462 -------
 .../t2/reference/impl/ReferenceSetImpl.java     |  123 --
 .../reference/impl/ReferenceSetServiceImpl.java |  153 ---
 .../reference/impl/SimpleCacheProviderImpl.java |   57 -
 .../impl/SimpleT2ReferenceGenerator.java        |   63 -
 .../impl/StackTraceElementBeanImpl.java         |   77 --
 .../t2/reference/impl/T2ReferenceImpl.java      |  288 ----
 .../t2/reference/impl/T2ReferenceListImpl.java  |   75 --
 .../TransactionalHibernateErrorDocumentDao.java |  155 ---
 .../impl/TransactionalHibernateListDao.java     |  154 ---
 .../TransactionalHibernateReferenceSetDao.java  |  198 ---
 .../t2/reference/impl/TranslationPath.java      |  266 ----
 .../impl/UUIDT2ReferenceGenerator.java          |   56 -
 .../t2/reference/impl/WriteQueueAspect.java     |  142 --
 .../sf/taverna/t2/reference/impl/package.html   |    5 -
 .../platform/spring/jdbc/TemporaryJDBC.java     |   74 ++
 .../taverna/platform/spring/jdbc/package.html   |    6 +
 .../reference/impl/AbstractEntityImpl.java      |   65 +
 .../impl/AbstractErrorDocumentServiceImpl.java  |  118 ++
 .../reference/impl/AbstractListServiceImpl.java |   99 ++
 .../impl/AbstractReferenceServiceImpl.java      |  170 +++
 .../impl/AbstractReferenceSetServiceImpl.java   |  159 +++
 .../reference/impl/AbstractServiceImpl.java     |   43 +
 .../impl/AbstractT2ReferenceGenerator.java      |  110 ++
 .../taverna/reference/impl/CacheAspect.java     |  126 ++
 .../impl/ContextualizedT2ReferenceImpl.java     |   60 +
 .../reference/impl/EmptyReferenceContext.java   |   45 +
 .../reference/impl/ErrorDocumentImpl.java       |  119 ++
 .../impl/ErrorDocumentServiceImpl.java          |  162 +++
 .../impl/HibernateErrorDocumentDao.java         |  153 +++
 .../reference/impl/HibernateListDao.java        |  150 +++
 .../impl/HibernateReferenceSetDao.java          |  197 +++
 .../reference/impl/IdentifiedArrayList.java     |  252 ++++
 .../impl/InMemoryErrorDocumentDao.java          |   69 +
 .../taverna/reference/impl/InMemoryListDao.java |   68 +
 .../reference/impl/InMemoryReferenceSetDao.java |   71 +
 .../taverna/reference/impl/ListServiceImpl.java |  135 ++
 .../reference/impl/ReferenceServiceImpl.java    |  730 ++++++++++
 .../impl/ReferenceSetAugmentorImpl.java         |  461 +++++++
 .../reference/impl/ReferenceSetImpl.java        |  122 ++
 .../reference/impl/ReferenceSetServiceImpl.java |  152 +++
 .../reference/impl/SimpleCacheProviderImpl.java |   56 +
 .../impl/SimpleT2ReferenceGenerator.java        |   62 +
 .../impl/StackTraceElementBeanImpl.java         |   76 ++
 .../taverna/reference/impl/T2ReferenceImpl.java |  287 ++++
 .../reference/impl/T2ReferenceListImpl.java     |   74 ++
 .../TransactionalHibernateErrorDocumentDao.java |  154 +++
 .../impl/TransactionalHibernateListDao.java     |  153 +++
 .../TransactionalHibernateReferenceSetDao.java  |  197 +++
 .../taverna/reference/impl/TranslationPath.java |  285 ++++
 .../impl/UUIDT2ReferenceGenerator.java          |   55 +
 .../reference/impl/WriteQueueAspect.java        |  141 ++
 .../apache/taverna/reference/impl/package.html  |    5 +
 ...erna.t2.reference.h3.HibernateComponentClass |    2 -
 ...averna.t2.reference.h3.HibernateMappedEntity |    3 -
 ...taverna.reference.h3.HibernateComponentClass |    2 +
 ...e.taverna.reference.h3.HibernateMappedEntity |    3 +
 .../src/main/resources/META-INF/spring.handlers |    2 +-
 .../spring/hibernate-reference-impl-context.xml |   22 +-
 .../spring/in-memory-reference-impl-context.xml |   14 +-
 .../spring/reference-impl-context-osgi.xml      |   14 +-
 .../META-INF/spring/reference-impl-context.xml  |    4 +-
 .../t2/reference/impl/ErrorDocumentImpl.hbm.xml |   45 -
 .../t2/reference/impl/ReferenceSetImpl.hbm.xml  |   32 -
 .../reference/impl/T2ReferenceListImpl.hbm.xml  |   37 -
 .../reference/impl/ErrorDocumentImpl.hbm.xml    |   39 +
 .../reference/impl/ReferenceSetImpl.hbm.xml     |   24 +
 .../reference/impl/T2ReferenceListImpl.hbm.xml  |   32 +
 .../platform/spring/jdbc/TemporaryJDBCTest.java |   60 -
 .../t2/reference/impl/AppContextSetup.java      |   31 -
 .../t2/reference/impl/DatabaseSetupTest.java    |  140 --
 .../t2/reference/impl/ErrorDocumentDaoTest.java |  151 ---
 .../impl/ErrorDocumentServiceTest.java          |   88 --
 .../taverna/t2/reference/impl/ListDaoTest.java  |  121 --
 .../t2/reference/impl/ListServiceTest.java      |   91 --
 .../t2/reference/impl/ReferenceContextImpl.java |   30 -
 .../t2/reference/impl/ReferenceSetDaoTest.java  |  105 --
 .../reference/impl/ReferenceSetServiceTest.java |   92 --
 .../t2/reference/impl/TranslationPathTest.java  |   46 -
 .../platform/spring/jdbc/TemporaryJDBCTest.java |   59 +
 .../taverna/reference/impl/AppContextSetup.java |   50 +
 .../reference/impl/DatabaseSetupTest.java       |  139 ++
 .../reference/impl/ErrorDocumentDaoTest.java    |  170 +++
 .../impl/ErrorDocumentServiceTest.java          |  107 ++
 .../taverna/reference/impl/ListDaoTest.java     |  140 ++
 .../taverna/reference/impl/ListServiceTest.java |  110 ++
 .../reference/impl/ReferenceContextImpl.java    |   49 +
 .../reference/impl/ReferenceSetDaoTest.java     |  124 ++
 .../reference/impl/ReferenceSetServiceTest.java |  111 ++
 .../reference/impl/TranslationPathTest.java     |   65 +
 .../src/test/resources/log4j.xml                |    4 +-
 .../resources/vanillaHibernateAppContext.xml    |   16 +-
 .../vanillaHibernateTransactionalAppContext.xml |   16 +-
 .../resources/vanillaInMemoryAppContext.xml     |    6 +-
 .../taverna/t2referencetest/BlueReference.java  |  129 --
 .../t2referencetest/DummyReferenceSet.java      |   32 -
 .../taverna/t2referencetest/GreenBuilder.java   |  107 --
 .../taverna/t2referencetest/GreenReference.java |  129 --
 .../sf/taverna/t2referencetest/GreenToRed.java  |   65 -
 .../taverna/t2referencetest/RedReference.java   |  129 --
 .../t2referencetest/YellowReference.java        |  130 --
 .../taverna/t2referencetest/BlueReference.java  |  128 ++
 .../t2referencetest/DummyReferenceSet.java      |   51 +
 .../taverna/t2referencetest/GreenBuilder.java   |  106 ++
 .../taverna/t2referencetest/GreenReference.java |  128 ++
 .../taverna/t2referencetest/GreenToRed.java     |   64 +
 .../taverna/t2referencetest/RedReference.java   |  128 ++
 .../t2referencetest/YellowReference.java        |  129 ++
 ...rna.t2.reference.ExternalReferenceBuilderSPI |    2 -
 ...sf.taverna.t2.reference.ExternalReferenceSPI |    5 -
 ....t2.reference.ExternalReferenceTranslatorSPI |    2 -
 ...averna.reference.ExternalReferenceBuilderSPI |    2 +
 ...pache.taverna.reference.ExternalReferenceSPI |    5 +
 ...rna.reference.ExternalReferenceTranslatorSPI |    2 +
 .../reference-testhelpers-context-osgi.xml      |   12 +-
 .../spring/reference-testhelpers-context.xml    |   12 +-
 .../t2referencetest/BlueReference.hbm.xml       |   16 -
 .../t2referencetest/GreenReference.hbm.xml      |   16 -
 .../t2referencetest/RedReference.hbm.xml        |   16 -
 .../t2referencetest/YellowReference.hbm.xml     |   16 -
 .../t2referencetest/BlueReference.hbm.xml       |   11 +
 .../t2referencetest/GreenReference.hbm.xml      |   11 +
 .../t2referencetest/RedReference.hbm.xml        |   11 +
 .../t2referencetest/YellowReference.hbm.xml     |   11 +
 .../impl/external/file/FileReference.java       |  210 ---
 .../impl/external/file/FileToFileReference.java |   61 -
 .../reference/impl/external/file/package.html   |    4 -
 .../impl/external/http/HttpReference.java       |  217 ---
 .../impl/external/http/UrlToHttpReference.java  |   62 -
 .../reference/impl/external/http/package.html   |    3 -
 .../object/BooleanToStringReference.java        |   53 -
 .../object/ByteArrayToByteArrayReference.java   |   53 -
 .../object/CharacterToStringReference.java      |   53 -
 .../object/InlineByteArrayReference.java        |   93 --
 .../object/InlineByteArrayReferenceBuilder.java |   67 -
 .../InlineByteToInlineStringTranslator.java     |   51 -
 .../external/object/InlineStringReference.java  |  133 --
 .../object/InlineStringReferenceBuilder.java    |   76 --
 .../InlineStringToInlineByteTranslator.java     |   40 -
 .../object/NumberToStringReference.java         |   52 -
 .../object/StreamToBooleanConverter.java        |   29 -
 .../object/StreamToByteArrayConverter.java      |   62 -
 .../object/StreamToDoubleConverter.java         |   29 -
 .../object/StreamToIntegerConverter.java        |   29 -
 .../object/StreamToStringConverter.java         |   80 --
 .../StreamToVMObjectReferenceConverter.java     |   56 -
 .../object/StringToStringReference.java         |   52 -
 .../impl/external/object/VMObjectReference.java |  111 --
 .../reference/impl/external/object/package.html |    4 -
 .../impl/external/file/FileReference.java       |  210 +++
 .../impl/external/file/FileToFileReference.java |   60 +
 .../reference/impl/external/file/package.html   |    4 +
 .../impl/external/http/HttpReference.java       |  216 +++
 .../impl/external/http/UrlToHttpReference.java  |   61 +
 .../reference/impl/external/http/package.html   |    3 +
 .../object/BooleanToStringReference.java        |   52 +
 .../object/ByteArrayToByteArrayReference.java   |   52 +
 .../object/CharacterToStringReference.java      |   52 +
 .../object/InlineByteArrayReference.java        |   92 ++
 .../object/InlineByteArrayReferenceBuilder.java |   66 +
 .../InlineByteToInlineStringTranslator.java     |   70 +
 .../external/object/InlineStringReference.java  |  132 ++
 .../object/InlineStringReferenceBuilder.java    |   75 ++
 .../InlineStringToInlineByteTranslator.java     |   59 +
 .../object/NumberToStringReference.java         |   51 +
 .../object/StreamToBooleanConverter.java        |   45 +
 .../object/StreamToByteArrayConverter.java      |   61 +
 .../object/StreamToDoubleConverter.java         |   45 +
 .../object/StreamToIntegerConverter.java        |   45 +
 .../object/StreamToStringConverter.java         |   79 ++
 .../StreamToVMObjectReferenceConverter.java     |   55 +
 .../object/StringToStringReference.java         |   51 +
 .../impl/external/object/VMObjectReference.java |  110 ++
 .../reference/impl/external/object/package.html |    4 +
 ...rna.t2.reference.ExternalReferenceBuilderSPI |    3 -
 ...sf.taverna.t2.reference.ExternalReferenceSPI |    6 -
 ....t2.reference.ExternalReferenceTranslatorSPI |    3 -
 ...verna.t2.reference.StreamToValueConverterSPI |    7 -
 ...na.t2.reference.ValueToReferenceConverterSPI |    8 -
 ...averna.reference.ExternalReferenceBuilderSPI |    3 +
 ...pache.taverna.reference.ExternalReferenceSPI |    6 +
 ...rna.reference.ExternalReferenceTranslatorSPI |    3 +
 ....taverna.reference.StreamToValueConverterSPI |    7 +
 ...verna.reference.ValueToReferenceConverterSPI |    8 +
 .../reference-core-extensions-context-osgi.xml  |   40 +-
 .../reference-core-extensions-context.xml       |   40 +-
 .../impl/external/file/FileReference.hbm.xml    |   18 -
 .../impl/external/http/HttpReference.hbm.xml    |   16 -
 .../object/InlineByteArrayReference.hbm.xml     |   16 -
 .../object/InlineStringReference.hbm.xml        |   16 -
 .../external/object/VMObjectReference.hbm.xml   |   16 -
 .../impl/external/file/FileReference.hbm.xml    |   13 +
 .../impl/external/http/HttpReference.hbm.xml    |   11 +
 .../object/InlineByteArrayReference.hbm.xml     |   11 +
 .../object/InlineStringReference.hbm.xml        |   11 +
 .../external/object/VMObjectReference.hbm.xml   |   11 +
 .../external/object/ByteArrayToStringTest.java  |   91 --
 .../external/object/ByteArrayToStringTest.java  |  110 ++
 .../taverna/platform/report/ActivityReport.java |   48 +
 .../taverna/platform/report/Invocation.java     |  305 +++++
 .../platform/report/ProcessorReport.java        |  163 +++
 .../taverna/platform/report/ReportListener.java |   31 +
 .../apache/taverna/platform/report/State.java   |   29 +
 .../taverna/platform/report/StatusReport.java   |  372 ++++++
 .../taverna/platform/report/WorkflowReport.java |  168 +++
 .../taverna/platform/report/ActivityReport.java |   49 -
 .../org/taverna/platform/report/Invocation.java |  306 -----
 .../platform/report/ProcessorReport.java        |  164 ---
 .../taverna/platform/report/ReportListener.java |   32 -
 .../uk/org/taverna/platform/report/State.java   |   30 -
 .../taverna/platform/report/StatusReport.java   |  373 ------
 .../taverna/platform/report/WorkflowReport.java |  169 ---
 .../platform/report/StatusReportTest.java       |  244 ++++
 .../platform/report/StatusReportTest.java       |  245 ----
 .../platform/run/api/InvalidRunIdException.java |   45 +
 .../taverna/platform/run/api/RunProfile.java    |  215 +++
 .../platform/run/api/RunProfileException.java   |   46 +
 .../taverna/platform/run/api/RunService.java    |  254 ++++
 .../platform/run/api/RunStateException.java     |   46 +
 .../platform/run/api/InvalidRunIdException.java |   46 -
 .../taverna/platform/run/api/RunProfile.java    |  196 ---
 .../platform/run/api/RunProfileException.java   |   47 -
 .../taverna/platform/run/api/RunService.java    |  235 ----
 .../platform/run/api/RunStateException.java     |   47 -
 .../platform/run/api/RunProfileTest.java        |  232 ++++
 .../platform/run/api/RunProfileTest.java        |  233 ----
 .../apache/taverna/platform/run/impl/Run.java   |  278 ++++
 .../platform/run/impl/RunServiceImpl.java       |  267 ++++
 .../platform/run/impl/WorkflowReportJSON.java   |  347 +++++
 .../uk/org/taverna/platform/run/impl/Run.java   |  279 ----
 .../platform/run/impl/RunServiceImpl.java       |  268 ----
 .../platform/run/impl/WorkflowReportJSON.java   |  328 -----
 .../META-INF/spring/run-context-osgi.xml        |    4 +-
 .../resources/META-INF/spring/run-context.xml   |    2 +-
 .../platform/run/impl/DummyWorkflowReport.java  |  131 ++
 .../taverna/platform/run/impl/RunTest.java      |   69 +
 .../run/impl/WorkflowReportJSONTest.java        |  285 ++++
 .../platform/run/impl/DummyWorkflowReport.java  |  131 --
 .../org/taverna/platform/run/impl/RunTest.java  |   69 -
 .../run/impl/WorkflowReportJSONTest.java        |  288 ----
 .../services/ActivityTypeNotFoundException.java |   46 +
 .../services/InvalidConfigurationException.java |   46 +
 .../commons/services/ServiceRegistry.java       |   88 ++
 .../services/ActivityTypeNotFoundException.java |   47 -
 .../services/InvalidConfigurationException.java |   47 -
 .../commons/services/ServiceRegistry.java       |   89 --
 .../services/impl/ServiceRegistryImpl.java      |   91 ++
 .../services/impl/ServiceRegistryImpl.java      |   92 --
 .../spring/taverna-services-context-osgi.xml    |    2 +-
 .../spring/taverna-services-context.xml         |    2 +-
 .../stringconstant/StringConstantActivity.java  |  119 --
 .../StringConstantActivityFactory.java          |   81 --
 .../StringConstantActivityHealthChecker.java    |   58 -
 .../StringConstantConfigurationBean.java        |   45 -
 .../t2/activities/stringconstant/package.html   |    3 -
 .../stringconstant/StringConstantActivity.java  |  118 ++
 .../StringConstantActivityFactory.java          |   80 ++
 .../StringConstantActivityHealthChecker.java    |   57 +
 .../StringConstantConfigurationBean.java        |   44 +
 .../activities/stringconstant/package.html      |    3 +
 ...averna.t2.workflowmodel.health.HealthChecker |    1 -
 ...e.taverna.workflowmodel.health.HealthChecker |    1 +
 .../stringconstant-activity-context-osgi.xml    |    6 +-
 .../spring/stringconstant-activity-context.xml  |    4 +-
 .../StringConstantActivityFactoryTest.java      |   64 -
 .../StringConstantActivityTest.java             |   68 -
 .../StringConstantActivityFactoryTest.java      |   63 +
 .../StringConstantActivityTest.java             |   58 +
 .../t2/annotation/AbstractAnnotatedThing.java   |  164 ---
 .../net/sf/taverna/t2/annotation/Annotated.java |   79 --
 .../t2/annotation/AnnotationAssertion.java      |   52 -
 .../t2/annotation/AnnotationBeanSPI.java        |   32 -
 .../taverna/t2/annotation/AnnotationChain.java  |   51 -
 .../t2/annotation/AnnotationPerspective.java    |   62 -
 .../taverna/t2/annotation/AnnotationRole.java   |   51 -
 .../t2/annotation/AnnotationSourceSPI.java      |   35 -
 .../net/sf/taverna/t2/annotation/AppliesTo.java |   53 -
 .../sf/taverna/t2/annotation/Curateable.java    |   72 -
 .../sf/taverna/t2/annotation/CurationEvent.java |   52 -
 .../t2/annotation/CurationEventBeanSPI.java     |   35 -
 .../t2/annotation/CurationEventType.java        |   43 -
 .../sf/taverna/t2/annotation/HierarchyRole.java |   40 -
 .../t2/annotation/HierarchyTraversal.java       |   74 --
 .../net/sf/taverna/t2/annotation/Person.java    |   36 -
 .../AbstractNumericRangeAssertion.java          |   64 -
 .../AbstractNumericValueAssertion.java          |   54 -
 .../AbstractTextualValueAssertion.java          |   53 -
 .../t2/annotation/annotationbeans/Author.java   |   44 -
 .../annotationbeans/DescriptiveTitle.java       |   42 -
 .../annotationbeans/DocumentationUrl.java       |   58 -
 .../annotationbeans/ExampleValue.java           |   43 -
 .../annotationbeans/FreeTextDescription.java    |   48 -
 .../annotationbeans/HostInstitution.java        |   45 -
 .../IdentificationAssertion.java                |   38 -
 .../t2/annotation/annotationbeans/MimeType.java |   60 -
 .../t2/annotation/annotationbeans/Optional.java |   44 -
 .../annotationbeans/SemanticAnnotation.java     |   51 -
 .../net/sf/taverna/t2/annotation/package.html   |   17 -
 .../sf/taverna/t2/facade/FacadeListener.java    |   49 -
 .../sf/taverna/t2/facade/ResultListener.java    |   43 -
 .../t2/facade/WorkflowInstanceFacade.java       |  237 ----
 .../t2/facade/WorkflowRunCancellation.java      |   29 -
 .../java/net/sf/taverna/t2/facade/package.html  |   24 -
 .../sf/taverna/t2/invocation/Completion.java    |  107 --
 .../net/sf/taverna/t2/invocation/Event.java     |  168 ---
 .../t2/invocation/InvocationContext.java        |   44 -
 .../t2/invocation/IterationInternalEvent.java   |  103 --
 .../invocation/ProcessIdentifierException.java  |   48 -
 .../t2/invocation/TokenOrderException.java      |   49 -
 .../net/sf/taverna/t2/invocation/TreeCache.java |  200 ---
 .../t2/invocation/WorkflowDataToken.java        |   91 --
 .../net/sf/taverna/t2/invocation/package.html   |    6 -
 .../sf/taverna/t2/monitor/MonitorManager.java   |  378 ------
 .../net/sf/taverna/t2/monitor/MonitorNode.java  |   76 --
 .../taverna/t2/monitor/MonitorableProperty.java |   55 -
 .../t2/monitor/NoSuchPropertyException.java     |   50 -
 .../taverna/t2/monitor/SteerableProperty.java   |   37 -
 .../java/net/sf/taverna/t2/monitor/package.html |   36 -
 .../provenance/item/AbstractProvenanceItem.java |   77 --
 .../provenance/item/ActivityProvenanceItem.java |   62 -
 .../t2/provenance/item/DataProvenanceItem.java  |   63 -
 .../t2/provenance/item/DataflowRunComplete.java |   61 -
 .../t2/provenance/item/ErrorProvenanceItem.java |   71 -
 .../item/InputDataProvenanceItem.java           |   49 -
 .../item/InvocationStartedProvenanceItem.java   |   41 -
 .../item/IterationProvenanceItem.java           |  108 --
 .../item/OutputDataProvenanceItem.java          |   49 -
 .../provenance/item/ProcessProvenanceItem.java  |   89 --
 .../item/ProcessorProvenanceItem.java           |   57 -
 .../t2/provenance/item/ProvenanceItem.java      |  103 --
 .../item/WorkflowDataProvenanceItem.java        |  101 --
 .../provenance/item/WorkflowProvenanceItem.java |  101 --
 .../provenance/reporter/ProvenanceReporter.java |   72 -
 .../provenance/vocabulary/SharedVocabulary.java |   34 -
 .../sf/taverna/t2/utility/TreeModelAdapter.java |  174 ---
 .../sf/taverna/t2/utility/TypedTreeModel.java   |  117 --
 .../taverna/t2/utility/TypedTreeModelEvent.java |  151 ---
 .../t2/utility/TypedTreeModelListener.java      |   82 --
 .../java/net/sf/taverna/t2/utility/package.html |    5 -
 .../sf/taverna/t2/visit/DataflowCollation.java  |   32 -
 .../sf/taverna/t2/visit/HierarchyTraverser.java |  343 -----
 .../java/net/sf/taverna/t2/visit/VisitKind.java |   16 -
 .../net/sf/taverna/t2/visit/VisitReport.java    |  346 -----
 .../java/net/sf/taverna/t2/visit/Visitor.java   |   44 -
 .../t2/workflowmodel/AbstractOutputPort.java    |   43 -
 .../taverna/t2/workflowmodel/AbstractPort.java  |   54 -
 .../taverna/t2/workflowmodel/CompoundEdit.java  |  115 --
 .../sf/taverna/t2/workflowmodel/Condition.java  |   52 -
 .../taverna/t2/workflowmodel/Configurable.java  |   56 -
 .../workflowmodel/ConfigurationException.java   |   62 -
 .../t2/workflowmodel/ControlBoundary.java       |   47 -
 .../sf/taverna/t2/workflowmodel/Dataflow.java   |  173 ---
 .../t2/workflowmodel/DataflowInputPort.java     |   52 -
 .../t2/workflowmodel/DataflowOutputPort.java    |   61 -
 .../taverna/t2/workflowmodel/DataflowPort.java  |   34 -
 .../workflowmodel/DataflowValidationReport.java |   99 --
 .../sf/taverna/t2/workflowmodel/Datalink.java   |   56 -
 .../net/sf/taverna/t2/workflowmodel/Edit.java   |   65 -
 .../taverna/t2/workflowmodel/EditException.java |   43 -
 .../net/sf/taverna/t2/workflowmodel/Edits.java  |  832 ------------
 .../EventForwardingOutputPort.java              |   46 -
 .../workflowmodel/EventHandlingInputPort.java   |   41 -
 .../t2/workflowmodel/FailureTransmitter.java    |   34 -
 .../t2/workflowmodel/FilteringInputPort.java    |   52 -
 .../sf/taverna/t2/workflowmodel/InputPort.java  |   30 -
 .../workflowmodel/InvalidDataflowException.java |   63 -
 .../net/sf/taverna/t2/workflowmodel/Merge.java  |   63 -
 .../t2/workflowmodel/MergeInputPort.java        |   52 -
 .../t2/workflowmodel/MergeOutputPort.java       |   35 -
 .../sf/taverna/t2/workflowmodel/MergePort.java  |   35 -
 .../t2/workflowmodel/NamedWorkflowEntity.java   |   45 -
 .../t2/workflowmodel/NamingException.java       |   47 -
 .../taverna/t2/workflowmodel/OrderedPair.java   |   85 --
 .../sf/taverna/t2/workflowmodel/OutputPort.java |   46 -
 .../net/sf/taverna/t2/workflowmodel/Port.java   |   35 -
 .../sf/taverna/t2/workflowmodel/Processor.java  |  150 ---
 .../workflowmodel/ProcessorFinishedEvent.java   |   34 -
 .../t2/workflowmodel/ProcessorInputPort.java    |   30 -
 .../t2/workflowmodel/ProcessorOutputPort.java   |   31 -
 .../taverna/t2/workflowmodel/ProcessorPort.java |   32 -
 .../t2/workflowmodel/RunDeletionListener.java   |   15 -
 .../t2/workflowmodel/TokenProcessingEntity.java |   57 -
 .../taverna/t2/workflowmodel/WorkflowItem.java  |   28 -
 .../WorkflowStructureException.java             |   36 -
 .../health/DisabledActivityHealthChecker.java   |   48 -
 .../t2/workflowmodel/health/HealthCheck.java    |   68 -
 .../t2/workflowmodel/health/HealthChecker.java  |   37 -
 .../health/RemoteHealthChecker.java             |  220 ---
 .../UnrecognizedActivityHealthChecker.java      |   48 -
 .../t2/workflowmodel/health/package.html        |    6 -
 .../sf/taverna/t2/workflowmodel/package.html    |    3 -
 .../processor/activity/AbstractActivity.java    |  264 ----
 .../activity/AbstractAsynchronousActivity.java  |   81 --
 .../processor/activity/Activity.java            |   93 --
 .../activity/ActivityAndBeanWrapper.java        |   62 -
 .../ActivityConfigurationException.java         |   62 -
 .../processor/activity/ActivityFactory.java     |   89 --
 .../processor/activity/ActivityInputPort.java   |   78 --
 .../processor/activity/ActivityOutputPort.java  |   32 -
 .../processor/activity/ActivityPort.java        |   34 -
 .../activity/AsynchronousActivity.java          |   50 -
 .../activity/AsynchronousActivityCallback.java  |  137 --
 .../processor/activity/DisabledActivity.java    |  191 ---
 .../workflowmodel/processor/activity/Job.java   |  130 --
 .../activity/LockedNestedDataflow.java          |   11 -
 .../MonitorableAsynchronousActivity.java        |   56 -
 .../processor/activity/NestedDataflow.java      |   36 -
 .../activity/NestedDataflowSource.java          |   18 -
 .../activity/NonExecutableActivity.java         |   80 --
 .../processor/activity/SupersededActivity.java  |   16 -
 .../activity/UnrecognizedActivity.java          |   41 -
 .../config/ActivityInputPortDefinitionBean.java |   67 -
 .../ActivityOutputPortDefinitionBean.java       |   49 -
 .../config/ActivityPortDefinitionBean.java      |  104 --
 .../config/ActivityPortsDefinitionBean.java     |   82 --
 .../processor/activity/config/package.html      |    7 -
 .../processor/activity/package.html             |   10 -
 .../processor/config/ConfigurationBean.java     |   12 -
 .../processor/config/ConfigurationProperty.java |   27 -
 .../dispatch/AbstractDispatchLayer.java         |  103 --
 .../dispatch/AbstractErrorHandlerLayer.java     |  283 ----
 .../processor/dispatch/DispatchLayer.java       |   97 --
 .../dispatch/DispatchLayerFactory.java          |   62 -
 .../processor/dispatch/DispatchStack.java       |  100 --
 .../processor/dispatch/NotifiableLayer.java     |   40 -
 .../PropertyContributingDispatchLayer.java      |   64 -
 .../description/DispatchLayerErrorReaction.java |   44 -
 .../DispatchLayerJobQueueReaction.java          |   45 -
 .../description/DispatchLayerJobReaction.java   |   44 -
 .../DispatchLayerResultCompletionReaction.java  |   44 -
 .../DispatchLayerResultReaction.java            |   44 -
 .../description/DispatchLayerStateEffect.java   |   84 --
 .../description/DispatchMessageType.java        |   61 -
 .../dispatch/description/ReactionTo.java        |   40 -
 .../description/SupportsStreamedResult.java     |   41 -
 .../processor/dispatch/description/package.html |    3 -
 .../dispatch/events/AbstractDispatchEvent.java  |   45 -
 .../events/DispatchCompletionEvent.java         |   70 -
 .../dispatch/events/DispatchErrorEvent.java     |  119 --
 .../dispatch/events/DispatchErrorType.java      |   54 -
 .../dispatch/events/DispatchJobEvent.java       |  106 --
 .../dispatch/events/DispatchJobQueueEvent.java  |   95 --
 .../dispatch/events/DispatchResultEvent.java    |  108 --
 .../processor/dispatch/package.html             |   19 -
 .../AbstractIterationStrategyNode.java          |  225 ----
 ...onHandlingAbstractIterationStrategyNode.java |  136 --
 .../processor/iteration/CrossProduct.java       |  164 ---
 .../processor/iteration/DotProduct.java         |  123 --
 .../processor/iteration/IterationStrategy.java  |   54 -
 .../iteration/IterationStrategyNode.java        |  121 --
 .../iteration/IterationStrategyStack.java       |   65 -
 .../IterationTypeMismatchException.java         |   49 -
 .../MissingIterationInputException.java         |   50 -
 .../processor/iteration/NamedInputPortNode.java |  116 --
 .../processor/iteration/PrefixDotProduct.java   |  111 --
 .../processor/iteration/TerminalNode.java       |   39 -
 .../processor/iteration/package.html            |    4 -
 .../serialization/DeserializationException.java |   33 -
 .../serialization/SerializationException.java   |   33 -
 .../t2/workflowmodel/utils/AnnotationTools.java |  151 ---
 .../utils/NamedWorkflowEntityComparator.java    |   39 -
 .../t2/workflowmodel/utils/PortComparator.java  |   37 -
 .../taverna/t2/workflowmodel/utils/Tools.java   |  795 -----------
 .../annotation/AbstractAnnotatedThing.java      |  163 +++
 .../apache/taverna/annotation/Annotated.java    |   78 ++
 .../taverna/annotation/AnnotationAssertion.java |   51 +
 .../taverna/annotation/AnnotationBeanSPI.java   |   31 +
 .../taverna/annotation/AnnotationChain.java     |   50 +
 .../annotation/AnnotationPerspective.java       |   61 +
 .../taverna/annotation/AnnotationRole.java      |   50 +
 .../taverna/annotation/AnnotationSourceSPI.java |   34 +
 .../apache/taverna/annotation/AppliesTo.java    |   52 +
 .../apache/taverna/annotation/Curateable.java   |   71 +
 .../taverna/annotation/CurationEvent.java       |   51 +
 .../annotation/CurationEventBeanSPI.java        |   34 +
 .../taverna/annotation/CurationEventType.java   |   42 +
 .../taverna/annotation/HierarchyRole.java       |   39 +
 .../taverna/annotation/HierarchyTraversal.java  |   73 +
 .../org/apache/taverna/annotation/Person.java   |   35 +
 .../AbstractNumericRangeAssertion.java          |   63 +
 .../AbstractNumericValueAssertion.java          |   53 +
 .../AbstractTextualValueAssertion.java          |   52 +
 .../annotation/annotationbeans/Author.java      |   43 +
 .../annotationbeans/DescriptiveTitle.java       |   41 +
 .../annotationbeans/DocumentationUrl.java       |   57 +
 .../annotationbeans/ExampleValue.java           |   42 +
 .../annotationbeans/FreeTextDescription.java    |   47 +
 .../annotationbeans/HostInstitution.java        |   41 +
 .../IdentificationAssertion.java                |   54 +
 .../annotation/annotationbeans/MimeType.java    |   59 +
 .../annotation/annotationbeans/Optional.java    |   43 +
 .../annotationbeans/SemanticAnnotation.java     |   67 +
 .../org/apache/taverna/annotation/package.html  |   17 +
 .../apache/taverna/facade/FacadeListener.java   |   48 +
 .../apache/taverna/facade/ResultListener.java   |   42 +
 .../taverna/facade/WorkflowInstanceFacade.java  |  236 ++++
 .../taverna/facade/WorkflowRunCancellation.java |   45 +
 .../java/org/apache/taverna/facade/package.html |   24 +
 .../apache/taverna/invocation/Completion.java   |  106 ++
 .../org/apache/taverna/invocation/Event.java    |  167 +++
 .../taverna/invocation/InvocationContext.java   |   43 +
 .../invocation/IterationInternalEvent.java      |  102 ++
 .../invocation/ProcessIdentifierException.java  |   47 +
 .../taverna/invocation/TokenOrderException.java |   48 +
 .../apache/taverna/invocation/TreeCache.java    |  199 +++
 .../taverna/invocation/WorkflowDataToken.java   |   90 ++
 .../org/apache/taverna/invocation/package.html  |    6 +
 .../apache/taverna/monitor/MonitorManager.java  |  377 ++++++
 .../org/apache/taverna/monitor/MonitorNode.java |   75 ++
 .../taverna/monitor/MonitorableProperty.java    |   54 +
 .../monitor/NoSuchPropertyException.java        |   49 +
 .../taverna/monitor/SteerableProperty.java      |   36 +
 .../org/apache/taverna/monitor/package.html     |   36 +
 .../provenance/item/AbstractProvenanceItem.java |   96 ++
 .../provenance/item/ActivityProvenanceItem.java |   61 +
 .../provenance/item/DataProvenanceItem.java     |   62 +
 .../provenance/item/DataflowRunComplete.java    |   60 +
 .../provenance/item/ErrorProvenanceItem.java    |   70 +
 .../item/InputDataProvenanceItem.java           |   48 +
 .../item/InvocationStartedProvenanceItem.java   |   60 +
 .../item/IterationProvenanceItem.java           |  107 ++
 .../item/OutputDataProvenanceItem.java          |   48 +
 .../provenance/item/ProcessProvenanceItem.java  |   88 ++
 .../item/ProcessorProvenanceItem.java           |   56 +
 .../taverna/provenance/item/ProvenanceItem.java |  102 ++
 .../item/WorkflowDataProvenanceItem.java        |  100 ++
 .../provenance/item/WorkflowProvenanceItem.java |  100 ++
 .../provenance/reporter/ProvenanceReporter.java |   91 ++
 .../provenance/vocabulary/SharedVocabulary.java |   33 +
 .../taverna/utility/TreeModelAdapter.java       |  173 +++
 .../apache/taverna/utility/TypedTreeModel.java  |  116 ++
 .../taverna/utility/TypedTreeModelEvent.java    |  150 +++
 .../taverna/utility/TypedTreeModelListener.java |   81 ++
 .../org/apache/taverna/utility/package.html     |    5 +
 .../apache/taverna/visit/DataflowCollation.java |   51 +
 .../taverna/visit/HierarchyTraverser.java       |  362 +++++
 .../org/apache/taverna/visit/VisitKind.java     |   35 +
 .../org/apache/taverna/visit/VisitReport.java   |  362 +++++
 .../java/org/apache/taverna/visit/Visitor.java  |   63 +
 .../workflowmodel/AbstractOutputPort.java       |   42 +
 .../taverna/workflowmodel/AbstractPort.java     |   53 +
 .../taverna/workflowmodel/CompoundEdit.java     |  114 ++
 .../apache/taverna/workflowmodel/Condition.java |   51 +
 .../taverna/workflowmodel/Configurable.java     |   54 +
 .../workflowmodel/ConfigurationException.java   |   61 +
 .../taverna/workflowmodel/ControlBoundary.java  |   46 +
 .../apache/taverna/workflowmodel/Dataflow.java  |  172 +++
 .../workflowmodel/DataflowInputPort.java        |   51 +
 .../workflowmodel/DataflowOutputPort.java       |   61 +
 .../taverna/workflowmodel/DataflowPort.java     |   33 +
 .../workflowmodel/DataflowValidationReport.java |   98 ++
 .../apache/taverna/workflowmodel/Datalink.java  |   55 +
 .../org/apache/taverna/workflowmodel/Edit.java  |   64 +
 .../taverna/workflowmodel/EditException.java    |   42 +
 .../org/apache/taverna/workflowmodel/Edits.java |  831 ++++++++++++
 .../EventForwardingOutputPort.java              |   45 +
 .../workflowmodel/EventHandlingInputPort.java   |   40 +
 .../workflowmodel/FailureTransmitter.java       |   33 +
 .../workflowmodel/FilteringInputPort.java       |   51 +
 .../apache/taverna/workflowmodel/InputPort.java |   29 +
 .../workflowmodel/InvalidDataflowException.java |   62 +
 .../org/apache/taverna/workflowmodel/Merge.java |   62 +
 .../taverna/workflowmodel/MergeInputPort.java   |   51 +
 .../taverna/workflowmodel/MergeOutputPort.java  |   34 +
 .../apache/taverna/workflowmodel/MergePort.java |   34 +
 .../workflowmodel/NamedWorkflowEntity.java      |   44 +
 .../taverna/workflowmodel/NamingException.java  |   46 +
 .../taverna/workflowmodel/OrderedPair.java      |   84 ++
 .../taverna/workflowmodel/OutputPort.java       |   45 +
 .../org/apache/taverna/workflowmodel/Port.java  |   34 +
 .../apache/taverna/workflowmodel/Processor.java |  149 +++
 .../workflowmodel/ProcessorFinishedEvent.java   |   53 +
 .../workflowmodel/ProcessorInputPort.java       |   29 +
 .../workflowmodel/ProcessorOutputPort.java      |   30 +
 .../taverna/workflowmodel/ProcessorPort.java    |   31 +
 .../workflowmodel/RunDeletionListener.java      |   31 +
 .../workflowmodel/TokenProcessingEntity.java    |   56 +
 .../taverna/workflowmodel/WorkflowItem.java     |   47 +
 .../WorkflowStructureException.java             |   35 +
 .../health/DisabledActivityHealthChecker.java   |   64 +
 .../workflowmodel/health/HealthCheck.java       |   84 ++
 .../workflowmodel/health/HealthChecker.java     |   36 +
 .../health/RemoteHealthChecker.java             |  236 ++++
 .../UnrecognizedActivityHealthChecker.java      |   64 +
 .../taverna/workflowmodel/health/package.html   |    6 +
 .../apache/taverna/workflowmodel/package.html   |    3 +
 .../processor/activity/AbstractActivity.java    |  263 ++++
 .../activity/AbstractAsynchronousActivity.java  |   80 ++
 .../processor/activity/Activity.java            |   92 ++
 .../activity/ActivityAndBeanWrapper.java        |   61 +
 .../ActivityConfigurationException.java         |   61 +
 .../processor/activity/ActivityFactory.java     |   88 ++
 .../processor/activity/ActivityInputPort.java   |   77 ++
 .../processor/activity/ActivityOutputPort.java  |   31 +
 .../processor/activity/ActivityPort.java        |   33 +
 .../activity/AsynchronousActivity.java          |   49 +
 .../activity/AsynchronousActivityCallback.java  |  136 ++
 .../processor/activity/DisabledActivity.java    |  190 +++
 .../workflowmodel/processor/activity/Job.java   |  129 ++
 .../activity/LockedNestedDataflow.java          |   30 +
 .../MonitorableAsynchronousActivity.java        |   55 +
 .../processor/activity/NestedDataflow.java      |   35 +
 .../activity/NestedDataflowSource.java          |   34 +
 .../activity/NonExecutableActivity.java         |   96 ++
 .../processor/activity/SupersededActivity.java  |   32 +
 .../activity/UnrecognizedActivity.java          |   57 +
 .../config/ActivityInputPortDefinitionBean.java |   66 +
 .../ActivityOutputPortDefinitionBean.java       |   48 +
 .../config/ActivityPortDefinitionBean.java      |  103 ++
 .../config/ActivityPortsDefinitionBean.java     |   81 ++
 .../processor/activity/config/package.html      |    7 +
 .../processor/activity/package.html             |   10 +
 .../processor/config/ConfigurationBean.java     |   31 +
 .../processor/config/ConfigurationProperty.java |   46 +
 .../dispatch/AbstractDispatchLayer.java         |  102 ++
 .../dispatch/AbstractErrorHandlerLayer.java     |  282 ++++
 .../processor/dispatch/DispatchLayer.java       |   96 ++
 .../dispatch/DispatchLayerFactory.java          |   61 +
 .../processor/dispatch/DispatchStack.java       |   99 ++
 .../processor/dispatch/NotifiableLayer.java     |   39 +
 .../PropertyContributingDispatchLayer.java      |   63 +
 .../description/DispatchLayerErrorReaction.java |   43 +
 .../DispatchLayerJobQueueReaction.java          |   44 +
 .../description/DispatchLayerJobReaction.java   |   43 +
 .../DispatchLayerResultCompletionReaction.java  |   43 +
 .../DispatchLayerResultReaction.java            |   43 +
 .../description/DispatchLayerStateEffect.java   |   83 ++
 .../description/DispatchMessageType.java        |   60 +
 .../dispatch/description/ReactionTo.java        |   39 +
 .../description/SupportsStreamedResult.java     |   40 +
 .../processor/dispatch/description/package.html |    3 +
 .../dispatch/events/AbstractDispatchEvent.java  |   44 +
 .../events/DispatchCompletionEvent.java         |   69 +
 .../dispatch/events/DispatchErrorEvent.java     |  118 ++
 .../dispatch/events/DispatchErrorType.java      |   53 +
 .../dispatch/events/DispatchJobEvent.java       |  105 ++
 .../dispatch/events/DispatchJobQueueEvent.java  |   94 ++
 .../dispatch/events/DispatchResultEvent.java    |  107 ++
 .../processor/dispatch/package.html             |   19 +
 .../AbstractIterationStrategyNode.java          |  224 ++++
 ...onHandlingAbstractIterationStrategyNode.java |  135 ++
 .../processor/iteration/CrossProduct.java       |  163 +++
 .../processor/iteration/DotProduct.java         |  122 ++
 .../processor/iteration/IterationStrategy.java  |   53 +
 .../iteration/IterationStrategyNode.java        |  120 ++
 .../iteration/IterationStrategyStack.java       |   64 +
 .../IterationTypeMismatchException.java         |   48 +
 .../MissingIterationInputException.java         |   49 +
 .../processor/iteration/NamedInputPortNode.java |  115 ++
 .../processor/iteration/PrefixDotProduct.java   |  110 ++
 .../processor/iteration/TerminalNode.java       |   38 +
 .../processor/iteration/package.html            |    4 +
 .../serialization/DeserializationException.java |   32 +
 .../serialization/SerializationException.java   |   32 +
 .../workflowmodel/utils/AnnotationTools.java    |  170 +++
 .../utils/NamedWorkflowEntityComparator.java    |   38 +
 .../workflowmodel/utils/PortComparator.java     |   36 +
 .../taverna/workflowmodel/utils/Tools.java      |  794 +++++++++++
 .../services/net.sf.taverna.t2.visit.VisitKind  |    1 -
 ...averna.t2.workflowmodel.health.HealthChecker |    2 -
 .../services/org.apache.taverna.visit.VisitKind |    1 +
 ...e.taverna.workflowmodel.health.HealthChecker |    2 +
 .../spring/workflowmodel-api-context-osgi.xml   |   26 +-
 .../spring/workflowmodel-api-context.xml        |   26 +-
 .../taverna/t2/monitor/TestMonitorManager.java  |  173 ---
 .../t2/workflowmodel/health/DummyVisitKind.java |   26 -
 .../health/FloatHealthChecker.java              |   45 -
 .../health/FloatHealthChecker2.java             |   44 -
 .../workflowmodel/health/HealthReportTest.java  |   88 --
 .../health/StringHealthChecker.java             |   45 -
 .../iteration/TestIterationStrategyNodes.java   |  212 ---
 .../taverna/monitor/TestMonitorManager.java     |  172 +++
 .../workflowmodel/health/DummyVisitKind.java    |   42 +
 .../health/FloatHealthChecker.java              |   43 +
 .../health/FloatHealthChecker2.java             |   43 +
 .../workflowmodel/health/HealthReportTest.java  |   87 ++
 .../health/StringHealthChecker.java             |   43 +
 .../iteration/TestIterationStrategyNodes.java   |  211 +++
 ...averna.t2.workflowmodel.health.HealthChecker |    3 -
 ...e.taverna.workflowmodel.health.HealthChecker |    3 +
 .../layers/CoreDispatchLayerFactory.java        |  103 --
 .../processor/dispatch/layers/ErrorBounce.java  |  324 -----
 .../processor/dispatch/layers/Failover.java     |  111 --
 .../dispatch/layers/IntermediateProvenance.java |  508 -------
 .../processor/dispatch/layers/Invoke.java       |  369 ------
 .../processor/dispatch/layers/Loop.java         |  424 ------
 .../dispatch/layers/LoopConfiguration.java      |   75 --
 .../processor/dispatch/layers/Parallelize.java  |  463 -------
 .../dispatch/layers/ParallelizeConfig.java      |   50 -
 .../processor/dispatch/layers/Retry.java        |  180 ---
 .../processor/dispatch/layers/RetryConfig.java  |   97 --
 .../processor/dispatch/layers/Stop.java         |  163 ---
 .../processor/dispatch/layers/package.html      |    4 -
 .../layers/CoreDispatchLayerFactory.java        |  102 ++
 .../processor/dispatch/layers/ErrorBounce.java  |  323 +++++
 .../processor/dispatch/layers/Failover.java     |  110 ++
 .../dispatch/layers/IntermediateProvenance.java |  507 +++++++
 .../processor/dispatch/layers/Invoke.java       |  368 ++++++
 .../processor/dispatch/layers/Loop.java         |  423 ++++++
 .../dispatch/layers/LoopConfiguration.java      |   94 ++
 .../processor/dispatch/layers/Parallelize.java  |  462 +++++++
 .../dispatch/layers/ParallelizeConfig.java      |   49 +
 .../processor/dispatch/layers/Retry.java        |  179 +++
 .../processor/dispatch/layers/RetryConfig.java  |   96 ++
 .../processor/dispatch/layers/Stop.java         |  179 +++
 .../processor/dispatch/layers/package.html      |    4 +
 ...rkflowmodel-core-extensions-context-osgi.xml |    2 +-
 .../workflowmodel-core-extensions-context.xml   |    2 +-
 .../processor/dispatch/layers/TestRetry.java    |  110 --
 .../processor/dispatch/layers/TestRetry.java    |  129 ++
 .../impl/AnnotationAssertionImpl.java           |  135 --
 .../t2/annotation/impl/AnnotationChainImpl.java |   50 -
 .../t2/annotation/impl/DisputeEvent.java        |   74 --
 .../t2/annotation/impl/DisputeEventDetails.java |   28 -
 .../taverna/t2/annotation/impl/PersonImpl.java  |   32 -
 .../taverna/t2/annotation/impl/URISource.java   |   46 -
 .../facade/impl/WorkflowInstanceFacadeImpl.java |  631 ---------
 .../invocation/impl/InvocationContextImpl.java  |   72 -
 .../t2/monitor/impl/MonitorTreeModel.java       |  423 ------
 .../impl/AbstractActivityEdit.java              |   69 -
 .../impl/AbstractAnnotationEdit.java            |   70 -
 .../impl/AbstractBinaryProcessorEdit.java       |   95 --
 .../workflowmodel/impl/AbstractCrystalizer.java |  194 ---
 .../impl/AbstractDataflowEdit.java              |   68 -
 .../impl/AbstractDataflowInputPortEdit.java     |   68 -
 .../impl/AbstractDataflowOutputPortEdit.java    |   70 -
 .../impl/AbstractDatalinkEdit.java              |   67 -
 .../impl/AbstractEventHandlingInputPort.java    |   53 -
 .../impl/AbstractFilteringInputPort.java        |  178 ---
 .../workflowmodel/impl/AbstractMergeEdit.java   |   52 -
 .../impl/AbstractProcessorEdit.java             |   68 -
 .../impl/BasicEventForwardingOutputPort.java    |   93 --
 .../t2/workflowmodel/impl/ConditionImpl.java    |   61 -
 .../t2/workflowmodel/impl/ConfigureEdit.java    |   78 --
 .../t2/workflowmodel/impl/Crystalizer.java      |   66 -
 .../t2/workflowmodel/impl/DataflowImpl.java     |  797 -----------
 .../impl/DataflowInputPortImpl.java             |   93 --
 .../impl/DataflowOutputPortImpl.java            |  112 --
 .../impl/DataflowValidationReportImpl.java      |   94 --
 .../t2/workflowmodel/impl/DatalinkImpl.java     |   68 -
 .../t2/workflowmodel/impl/EditSupport.java      |   46 -
 .../t2/workflowmodel/impl/EditsImpl.java        | 1251 ------------------
 .../t2/workflowmodel/impl/MergeImpl.java        |  234 ----
 .../workflowmodel/impl/MergeInputPortImpl.java  |   45 -
 .../workflowmodel/impl/MergeOutputPortImpl.java |   40 -
 .../impl/ProcessorCrystalizerImpl.java          |  103 --
 .../t2/workflowmodel/impl/ProcessorImpl.java    |  426 ------
 .../impl/ProcessorInputPortImpl.java            |   72 -
 .../impl/ProcessorOutputPortImpl.java           |   59 -
 .../taverna/t2/workflowmodel/impl/package.html  |    3 -
 .../activity/impl/ActivityInputPortImpl.java    |   88 --
 .../activity/impl/ActivityOutputPortImpl.java   |   75 --
 .../processor/activity/impl/package.html        |    3 -
 .../impl/AbstractDispatchLayerEdit.java         |   98 --
 .../dispatch/impl/DispatchStackImpl.java        |  317 -----
 .../processor/dispatch/impl/package.html        |    8 -
 .../iteration/impl/IterationStrategyImpl.java   |  345 -----
 .../impl/IterationStrategyStackImpl.java        |  154 ---
 .../processor/iteration/impl/package.html       |    3 -
 .../impl/AnnotationAssertionImpl.java           |  134 ++
 .../annotation/impl/AnnotationChainImpl.java    |   49 +
 .../taverna/annotation/impl/DisputeEvent.java   |   73 +
 .../annotation/impl/DisputeEventDetails.java    |   27 +
 .../taverna/annotation/impl/PersonImpl.java     |   31 +
 .../taverna/annotation/impl/URISource.java      |   45 +
 .../facade/impl/WorkflowInstanceFacadeImpl.java |  630 +++++++++
 .../invocation/impl/InvocationContextImpl.java  |   71 +
 .../taverna/monitor/impl/MonitorTreeModel.java  |  422 ++++++
 .../impl/AbstractActivityEdit.java              |   68 +
 .../impl/AbstractAnnotationEdit.java            |   69 +
 .../impl/AbstractBinaryProcessorEdit.java       |   94 ++
 .../workflowmodel/impl/AbstractCrystalizer.java |  193 +++
 .../impl/AbstractDataflowEdit.java              |   67 +
 .../impl/AbstractDataflowInputPortEdit.java     |   67 +
 .../impl/AbstractDataflowOutputPortEdit.java    |   69 +
 .../impl/AbstractDatalinkEdit.java              |   66 +
 .../impl/AbstractEventHandlingInputPort.java    |   52 +
 .../impl/AbstractFilteringInputPort.java        |  177 +++
 .../workflowmodel/impl/AbstractMergeEdit.java   |   51 +
 .../impl/AbstractProcessorEdit.java             |   67 +
 .../impl/BasicEventForwardingOutputPort.java    |   92 ++
 .../workflowmodel/impl/ConditionImpl.java       |   60 +
 .../workflowmodel/impl/ConfigureEdit.java       |   77 ++
 .../taverna/workflowmodel/impl/Crystalizer.java |   65 +
 .../workflowmodel/impl/DataflowImpl.java        |  796 +++++++++++
 .../impl/DataflowInputPortImpl.java             |   92 ++
 .../impl/DataflowOutputPortImpl.java            |  111 ++
 .../impl/DataflowValidationReportImpl.java      |   93 ++
 .../workflowmodel/impl/DatalinkImpl.java        |   67 +
 .../taverna/workflowmodel/impl/EditSupport.java |   65 +
 .../taverna/workflowmodel/impl/EditsImpl.java   | 1250 +++++++++++++++++
 .../taverna/workflowmodel/impl/MergeImpl.java   |  233 ++++
 .../workflowmodel/impl/MergeInputPortImpl.java  |   44 +
 .../workflowmodel/impl/MergeOutputPortImpl.java |   39 +
 .../impl/ProcessorCrystalizerImpl.java          |  102 ++
 .../workflowmodel/impl/ProcessorImpl.java       |  425 ++++++
 .../impl/ProcessorInputPortImpl.java            |   71 +
 .../impl/ProcessorOutputPortImpl.java           |   58 +
 .../taverna/workflowmodel/impl/package.html     |    3 +
 .../activity/impl/ActivityInputPortImpl.java    |   87 ++
 .../activity/impl/ActivityOutputPortImpl.java   |   74 ++
 .../processor/activity/impl/package.html        |    3 +
 .../impl/AbstractDispatchLayerEdit.java         |   97 ++
 .../dispatch/impl/DispatchStackImpl.java        |  316 +++++
 .../processor/dispatch/impl/package.html        |    8 +
 .../iteration/impl/IterationStrategyImpl.java   |  344 +++++
 .../impl/IterationStrategyStackImpl.java        |  153 +++
 .../processor/iteration/impl/package.html       |    3 +
 ...t.sf.taverna.t2.annotation.AnnotationBeanSPI |   10 -
 ...sf.taverna.t2.annotation.AnnotationSourceSPI |    1 -
 ...f.taverna.t2.annotation.CurationEventBeanSPI |    1 -
 .../net.sf.taverna.t2.workflowmodel.Edits       |    1 -
 ...averna.t2.workflowmodel.health.HealthChecker |    1 -
 ....apache.taverna.annotation.AnnotationBeanSPI |   10 +
 ...pache.taverna.annotation.AnnotationSourceSPI |    1 +
 ...ache.taverna.annotation.CurationEventBeanSPI |    1 +
 .../org.apache.taverna.workflowmodel.Edits      |    1 +
 ...e.taverna.workflowmodel.health.HealthChecker |    1 +
 .../spring/workflowmodel-impl-context-osgi.xml  |    6 +-
 .../spring/workflowmodel-impl-context.xml       |    6 +-
 .../src/main/resources/provenanceContext.xml    |    4 +-
 .../taverna/t2/annotation/TestAnnotations.java  |  192 ---
 .../t2/monitor/impl/MonitorTreeModelTest.java   |   56 -
 .../impl/AbstractDatalinkEditTest.java          |  187 ---
 .../impl/AddProcessorEditTest.java              |   90 --
 .../ChangeDataflowInputPortDepthEditTest.java   |   77 --
 ...eDataflowInputPortGranularDepthEditTest.java |   73 -
 .../impl/ConfigureActivityEditTest.java         |   90 --
 .../impl/ConnectDatalinkEditTest.java           |   88 --
 .../impl/ConnectMergedDatalinkEditTest.java     |  129 --
 .../impl/CreateDataflowInputPortEditTest.java   |   87 --
 .../impl/CreateDataflowOutputPortEditTest.java  |   81 --
 .../t2/workflowmodel/impl/DataflowImplTest.java |   43 -
 .../impl/DefaultDispatchStackEditTest.java      |   79 --
 .../t2/workflowmodel/impl/DummyActivity.java    |   40 -
 .../t2/workflowmodel/impl/DummyDataflow.java    |  143 --
 .../impl/DummyDataflowInputPort.java            |   39 -
 .../impl/DummyDataflowOutputPort.java           |   37 -
 .../t2/workflowmodel/impl/DummyProcessor.java   |  150 ---
 .../impl/DummyValidationReport.java             |   69 -
 .../t2/workflowmodel/impl/EditsImplTests.java   |   61 -
 .../t2/workflowmodel/impl/EventKeeper.java      |   37 -
 .../MapProcessorPortsToActivityEditTest.java    |  133 --
 .../impl/ProcessorHealthReportTest.java         |  140 --
 .../impl/RemoveProcessorInputPortEditTest.java  |   69 -
 .../impl/RemoveProcessorOutputPortEditTest.java |   71 -
 ...pdateDataflowInternalIdentifierEditTest.java |   40 -
 .../processor/AsynchEchoActivity.java           |   61 -
 .../processor/DiagnosticEventHandler.java       |   70 -
 .../t2/workflowmodel/processor/EchoConfig.java  |   52 -
 .../NaiveProcessorConstructionTest.java         |   47 -
 .../t2/workflowmodel/processor/Tools.java       |   90 --
 .../processor/dispatch/DiagnosticLayer.java     |   75 --
 .../DiagnosticIterationStrategyNode.java        |  131 --
 .../impl/IterationTypeCheckerTest.java          |  217 ---
 .../taverna/annotation/TestAnnotations.java     |  191 +++
 .../monitor/impl/MonitorTreeModelTest.java      |   55 +
 .../impl/AbstractDatalinkEditTest.java          |  186 +++
 .../impl/AddProcessorEditTest.java              |   89 ++
 .../ChangeDataflowInputPortDepthEditTest.java   |   76 ++
 ...eDataflowInputPortGranularDepthEditTest.java |   72 +
 .../impl/ConfigureActivityEditTest.java         |   89 ++
 .../impl/ConnectDatalinkEditTest.java           |   87 ++
 .../impl/ConnectMergedDatalinkEditTest.java     |  128 ++
 .../impl/CreateDataflowInputPortEditTest.java   |   86 ++
 .../impl/CreateDataflowOutputPortEditTest.java  |   80 ++
 .../workflowmodel/impl/DataflowImplTest.java    |   42 +
 .../impl/DefaultDispatchStackEditTest.java      |   78 ++
 .../workflowmodel/impl/DummyActivity.java       |   39 +
 .../workflowmodel/impl/DummyDataflow.java       |  142 ++
 .../impl/DummyDataflowInputPort.java            |   38 +
 .../impl/DummyDataflowOutputPort.java           |   36 +
 .../workflowmodel/impl/DummyProcessor.java      |  149 +++
 .../impl/DummyValidationReport.java             |   65 +
 .../workflowmodel/impl/EditsImplTests.java      |   60 +
 .../taverna/workflowmodel/impl/EventKeeper.java |   36 +
 .../MapProcessorPortsToActivityEditTest.java    |  132 ++
 .../impl/ProcessorHealthReportTest.java         |  139 ++
 .../impl/RemoveProcessorInputPortEditTest.java  |   68 +
 .../impl/RemoveProcessorOutputPortEditTest.java |   70 +
 ...pdateDataflowInternalIdentifierEditTest.java |   38 +
 .../processor/AsynchEchoActivity.java           |   60 +
 .../processor/DiagnosticEventHandler.java       |   66 +
 .../workflowmodel/processor/EchoConfig.java     |   51 +
 .../NaiveProcessorConstructionTest.java         |   46 +
 .../taverna/workflowmodel/processor/Tools.java  |   89 ++
 .../processor/dispatch/DiagnosticLayer.java     |   74 ++
 .../DiagnosticIterationStrategyNode.java        |  130 ++
 .../impl/IterationTypeCheckerTest.java          |  216 +++
 .../resources/serialized-fragments/activity.xml |    2 +-
 .../serialized-fragments/dispatchLayer.xml      |    6 +-
 .../serialized-fragments/dispatchStack.xml      |   18 +-
 1160 files changed, 53441 insertions(+), 52894 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-activity-archetype/src/main/resources/archetype-resources/__rootArtifactId__-activity-ui/src/main/resources/META-INF/spring/context-osgi.xml
----------------------------------------------------------------------
diff --git a/taverna-activity-archetype/src/main/resources/archetype-resources/__rootArtifactId__-activity-ui/src/main/resources/META-INF/spring/context-osgi.xml b/taverna-activity-archetype/src/main/resources/archetype-resources/__rootArtifactId__-activity-ui/src/main/resources/META-INF/spring/context-osgi.xml
index 32ad4f1..2485411 100644
--- a/taverna-activity-archetype/src/main/resources/archetype-resources/__rootArtifactId__-activity-ui/src/main/resources/META-INF/spring/context-osgi.xml
+++ b/taverna-activity-archetype/src/main/resources/archetype-resources/__rootArtifactId__-activity-ui/src/main/resources/META-INF/spring/context-osgi.xml
@@ -6,21 +6,21 @@
                       http://www.springframework.org/schema/osgi
                       http://www.springframework.org/schema/osgi/spring-osgi.xsd">
 
-	<service ref="${classPrefix}ServiceIcon" interface="net.sf.taverna.t2.workbench.activityicons.ActivityIconSPI" />
+	<service ref="${classPrefix}ServiceIcon" interface="org.apache.taverna.workbench.activityicons.ActivityIconSPI" />
 
-	<service ref="${classPrefix}ServiceProvider" interface="net.sf.taverna.t2.servicedescriptions.ServiceDescriptionProvider" />
+	<service ref="${classPrefix}ServiceProvider" interface="org.apache.taverna.servicedescriptions.ServiceDescriptionProvider" />
 
 	<service ref="${classPrefix}ConfigureMenuAction" auto-export="interfaces" />
 
-	<service ref="${classPrefix}ActivityContextViewFactory" interface="net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory" />
+	<service ref="${classPrefix}ActivityContextViewFactory" interface="org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory" />
 
-	<reference id="editManager" interface="net.sf.taverna.t2.workbench.edits.EditManager" />
-	<reference id="fileManager" interface="net.sf.taverna.t2.workbench.file.FileManager" />
-	<reference id="menuManager" interface="net.sf.taverna.t2.ui.menu.MenuManager" />
-	<reference id="selectionManager" interface="net.sf.taverna.t2.workbench.selection.SelectionManager" />
-	<reference id="activityIconManager" interface="net.sf.taverna.t2.workbench.activityicons.ActivityIconManager" />
-	<reference id="colourManager" interface="net.sf.taverna.t2.workbench.configuration.colour.ColourManager" />
-	<reference id="serviceDescriptionRegistry" interface="net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry" />
-	<reference id="serviceRegistry" interface="uk.org.taverna.commons.services.ServiceRegistry" />
+	<reference id="editManager" interface="org.apache.taverna.workbench.edits.EditManager" />
+	<reference id="fileManager" interface="org.apache.taverna.workbench.file.FileManager" />
+	<reference id="menuManager" interface="org.apache.taverna.ui.menu.MenuManager" />
+	<reference id="selectionManager" interface="org.apache.taverna.workbench.selection.SelectionManager" />
+	<reference id="activityIconManager" interface="org.apache.taverna.workbench.activityicons.ActivityIconManager" />
+	<reference id="colourManager" interface="org.apache.taverna.workbench.configuration.colour.ColourManager" />
+	<reference id="serviceDescriptionRegistry" interface="org.apache.taverna.servicedescriptions.ServiceDescriptionRegistry" />
+	<reference id="serviceRegistry" interface="org.apache.taverna.commons.services.ServiceRegistry" />
 
 </beans:beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-activity-archetype/src/main/resources/archetype-resources/__rootArtifactId__-activity/src/main/resources/META-INF/spring/context-osgi.xml
----------------------------------------------------------------------
diff --git a/taverna-activity-archetype/src/main/resources/archetype-resources/__rootArtifactId__-activity/src/main/resources/META-INF/spring/context-osgi.xml b/taverna-activity-archetype/src/main/resources/archetype-resources/__rootArtifactId__-activity/src/main/resources/META-INF/spring/context-osgi.xml
index e8d6e12..2a22552 100644
--- a/taverna-activity-archetype/src/main/resources/archetype-resources/__rootArtifactId__-activity/src/main/resources/META-INF/spring/context-osgi.xml
+++ b/taverna-activity-archetype/src/main/resources/archetype-resources/__rootArtifactId__-activity/src/main/resources/META-INF/spring/context-osgi.xml
@@ -7,11 +7,11 @@
                                  http://www.springframework.org/schema/osgi/spring-osgi.xsd">
 
 	<!-- Services to be registered with the OSGi service register -->
-	<service ref="${classPrefix}ActivityHealthChecker" interface="net.sf.taverna.t2.workflowmodel.health.HealthChecker" />
+	<service ref="${classPrefix}ActivityHealthChecker" interface="org.apache.taverna.workflowmodel.health.HealthChecker" />
 
-	<service ref="${classPrefix}ActivityFactory" interface="net.sf.taverna.t2.workflowmodel.processor.activity.ActivityFactory" />
+	<service ref="${classPrefix}ActivityFactory" interface="org.apache.taverna.workflowmodel.processor.activity.ActivityFactory" />
 
 	<!-- References to services required from the OSGi service register -->
-	<reference id="edits" interface="net.sf.taverna.t2.workflowmodel.Edits" />
+	<reference id="edits" interface="org.apache.taverna.workflowmodel.Edits" />
 
 </beans:beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-activity-test-utils/src/main/java/net/sf/taverna/t2/activities/testutils/ActivityInvoker.java
----------------------------------------------------------------------
diff --git a/taverna-activity-test-utils/src/main/java/net/sf/taverna/t2/activities/testutils/ActivityInvoker.java b/taverna-activity-test-utils/src/main/java/net/sf/taverna/t2/activities/testutils/ActivityInvoker.java
deleted file mode 100644
index 934e31a..0000000
--- a/taverna-activity-test-utils/src/main/java/net/sf/taverna/t2/activities/testutils/ActivityInvoker.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.testutils;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.ServiceLoader;
-
-import net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI;
-import net.sf.taverna.t2.reference.ReferenceService;
-import net.sf.taverna.t2.reference.StreamToValueConverterSPI;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.ValueToReferenceConverterSPI;
-import net.sf.taverna.t2.reference.impl.ErrorDocumentServiceImpl;
-import net.sf.taverna.t2.reference.impl.InMemoryErrorDocumentDao;
-import net.sf.taverna.t2.reference.impl.InMemoryListDao;
-import net.sf.taverna.t2.reference.impl.InMemoryReferenceSetDao;
-import net.sf.taverna.t2.reference.impl.ListServiceImpl;
-import net.sf.taverna.t2.reference.impl.ReferenceServiceImpl;
-import net.sf.taverna.t2.reference.impl.ReferenceSetAugmentorImpl;
-import net.sf.taverna.t2.reference.impl.ReferenceSetServiceImpl;
-import net.sf.taverna.t2.reference.impl.SimpleT2ReferenceGenerator;
-import net.sf.taverna.t2.workflowmodel.processor.activity.AbstractAsynchronousActivity;
-import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivity;
-
-/**
- * Helper class to facilitate in executing Activities in isolation.
- * 
- * @author Stuart Owen
- * @author Alex Nenadic
- * @author Stian Soiland-Reyes
- * @author David Withers
- */
-public class ActivityInvoker {
-
-	/**
-	 * Timeout in seconds
-	 */
-	public static long TIMEOUT = 30;
-
-	
-	/**
-	 * Invokes an {@link AsynchronousActivity} with a given set of input Objects
-	 * and returns a Map<String,Object> of requested output values.
-	 * 
-	 * @param activity
-	 *            the activity to be tested
-	 * @param inputs
-	 *            a Map<String,Object> of input Objects
-	 * @param requestedOutputs
-	 *            a List<String> of outputs to be examined
-	 * 
-	 * @return a Map<String,Object> of the outputs requested by requestedOutput
-	 *         or <code>null</code> if a failure occurs
-	 * @throws InterruptedException 
-	 * @throws Throwable 
-	 */
-/*	public static Map<String, Object> invokeAsyncActivity(
-			AbstractAsynchronousActivity<?> activity,
-			Map<String, Object> inputs, Map<String, Class<?>> requestedOutputs)
-			throws Exception {
-		Map<String, Object> results = new HashMap<String, Object>();
-
-		ApplicationContext context = new RavenAwareClassPathXmlApplicationContext(
-		"inMemoryActivityTestsContext.xml");
-		ReferenceService referenceService = (ReferenceService) context.getBean("t2reference.service.referenceService");
-
-		DummyCallback callback = new DummyCallback(referenceService);
-		Map<String, T2Reference> inputEntities = new HashMap<String, T2Reference>();
-		for (String inputName : inputs.keySet()) {
-			Object val = inputs.get(inputName);
-			if (val instanceof List) {
-				inputEntities.put(inputName, referenceService.register(val, 1, true, callback.getContext()));
-			} else {
-				inputEntities.put(inputName, referenceService.register(val, 0, true, callback.getContext()));
-			}
-		}
-
-		activity.executeAsynch(inputEntities, callback);
-		callback.thread.join();
-
-		if (callback.failed) {
-			results = null;
-		} else {
-			for (Map.Entry<String, Class<?>> output : requestedOutputs.entrySet()) {
-				T2Reference id = callback.data.get(output.getKey());
-				if (id != null) {
-					Object result;
-					result = referenceService.renderIdentifier(id, output.getValue(), callback.getContext());
-					results.put(output.getKey(), result);
-				}
-			}
-		}
-		return results;
-	}
-	*/
-
-	// Changed this method to render the T2Reference to an object only if the type of the object in 
-	// requestedOutputs is not an instance of ExternalReferenceSPI. Otherwise, the calling test method 
-	// should get activity ReferenceSet and render the object itself. This was needed for API consumer activity 
-	// testing - see ApiConsumerActivityTest.
-	// Also added support for multi-dimensional lists.
-	public static Map<String, Object> invokeAsyncActivity(
-			AbstractAsynchronousActivity<?> activity,
-			Map<String, Object> inputs, Map<String, Class<?>> requestedOutputs) throws InterruptedException
-			 {
-		
-		Map<String, Object> results = new HashMap<String, Object>();
-
-		ReferenceService referenceService = createReferenceService();
-		
-		DummyCallback callback = new DummyCallback(referenceService);
-		Map<String, T2Reference> inputEntities = new HashMap<String, T2Reference>();
-		for (String inputName : inputs.keySet()) {
-			Object val = inputs.get(inputName);
-			int depth = getDepth(val);
-			inputEntities.put(inputName, referenceService.register(val, depth, true, callback.getContext()));
-		}
-
-		activity.executeAsynch(inputEntities, callback);
-		callback.thread.join(TIMEOUT*1000);
-
-		
-		if (callback.failed) {
-			throw callback.failures.get(0);
-		} else {
-			for (Map.Entry<String, Class<?>> output : requestedOutputs.entrySet()) {
-				T2Reference id = callback.data.get(output.getKey());
-				if (ExternalReferenceSPI.class.isAssignableFrom(output.getValue())){
-					// Do not render the object - just resolve the T2Reference
-					Object result;
-					result = referenceService.resolveIdentifier(id, null, callback.getContext());
-					results.put(output.getKey(), result);
-				}
-				else{
-					// Try to render the object behind the reference
-					Object result;
-					result = referenceService.renderIdentifier(id, output.getValue(), callback.getContext());
-					results.put(output.getKey(), result);
-				}
-			}
-		}
-		return results;
-	}
-
-	private static ReferenceService createReferenceService() {
-		SimpleT2ReferenceGenerator referenceGenerator = new SimpleT2ReferenceGenerator();
-		ReferenceSetAugmentorImpl referenceSetAugmentor = new ReferenceSetAugmentorImpl();
-		referenceSetAugmentor.setBuilders((List<ExternalReferenceBuilderSPI<?>>) getBuilders());
-		referenceSetAugmentor.setTranslators(getTranslators());
-		
-		ReferenceSetServiceImpl referenceSetService = new ReferenceSetServiceImpl();
-		referenceSetService.setT2ReferenceGenerator(referenceGenerator);
-		referenceSetService.setReferenceSetDao(new InMemoryReferenceSetDao());
-		referenceSetService.setReferenceSetAugmentor(referenceSetAugmentor);
-		
-		ListServiceImpl listService = new ListServiceImpl();
-		listService.setT2ReferenceGenerator(referenceGenerator);
-		listService.setListDao(new InMemoryListDao());
-		
-		ErrorDocumentServiceImpl errorDocumentService = new ErrorDocumentServiceImpl();
-		errorDocumentService.setT2ReferenceGenerator(referenceGenerator);
-		errorDocumentService.setErrorDao(new InMemoryErrorDocumentDao());
-		
-		ReferenceServiceImpl referenceService = new ReferenceServiceImpl();
-		referenceService.setReferenceSetService(referenceSetService);
-		referenceService.setListService(listService);
-		referenceService.setErrorDocumentService(errorDocumentService);
-		referenceService.setConverters(getConverters());
-		referenceService.setValueBuilders(getValueBuilders());
-		
-		return referenceService;
-	}
-	
-	private static <T> List<T> getImplementations(Class<T> api) {
-		List<T> implementations = new ArrayList<T>();
-		ServiceLoader<T> serviceLoader = ServiceLoader.load(api);
-		for (T implementation : serviceLoader) {
-			implementations.add(implementation);
-		}
-		return implementations;
-	}
-	
-	private static List<StreamToValueConverterSPI> getValueBuilders() {
-		return getImplementations(StreamToValueConverterSPI.class);
-	}
-
-	private static List<ValueToReferenceConverterSPI> getConverters() {
-		return getImplementations(ValueToReferenceConverterSPI.class);
-	}
-
-	private static List<ExternalReferenceTranslatorSPI<?, ?>> getTranslators() {
-		List<ExternalReferenceTranslatorSPI<?, ?>> implementations = new ArrayList<ExternalReferenceTranslatorSPI<?, ?>>();
-		ServiceLoader<ExternalReferenceTranslatorSPI> serviceLoader = ServiceLoader.load(ExternalReferenceTranslatorSPI.class);
-		for (ExternalReferenceTranslatorSPI implementation : serviceLoader) {
-			implementations.add(implementation);
-		}
-		return implementations;
-	}
-
-	private static List<ExternalReferenceBuilderSPI<?>> getBuilders() {
-		List<ExternalReferenceBuilderSPI<?>> implementations = new ArrayList<ExternalReferenceBuilderSPI<?>>();
-		ServiceLoader<ExternalReferenceBuilderSPI> serviceLoader = ServiceLoader.load(ExternalReferenceBuilderSPI.class);
-		for (ExternalReferenceBuilderSPI implementation : serviceLoader) {
-			implementations.add(implementation);
-		}
-		return implementations;
-	}
-
-	/**
-	 * If an object is activity list - returns its depth, 0 otherwise (for single objects).
-	 * @param obj
-	 * @return
-	 */
-	private static int getDepth(Object obj){
-
-		if (obj instanceof List) {
-			// Assumes all sub-lists are of the same depth,
-			// so just uses the first sub-list to calculate it.
-			Object[] sublists = ((List<?>)obj).toArray();
-			int depth = 1;
-			depth = getDepth(sublists[0]) + 1;
-			return depth;
-		} else {
-			return 0;
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-activity-test-utils/src/main/java/net/sf/taverna/t2/activities/testutils/DummyCallback.java
----------------------------------------------------------------------
diff --git a/taverna-activity-test-utils/src/main/java/net/sf/taverna/t2/activities/testutils/DummyCallback.java b/taverna-activity-test-utils/src/main/java/net/sf/taverna/t2/activities/testutils/DummyCallback.java
deleted file mode 100644
index 016caef..0000000
--- a/taverna-activity-test-utils/src/main/java/net/sf/taverna/t2/activities/testutils/DummyCallback.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.testutils;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.invocation.impl.InvocationContextImpl;
-import net.sf.taverna.t2.reference.ReferenceService;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchErrorType;
-
-import org.apache.log4j.Logger;
-
-/**
- * A DummyCallback to aid with testing Activities.
- * 
- * @author Stuart Owen
- * @author David Withers
- * @author Stian Soiland-Reyes
- *
- */
-public class DummyCallback implements AsynchronousActivityCallback {
-	
-	private static Logger logger = Logger
-	.getLogger(DummyCallback.class);
-
-	public ReferenceService referenceService;
-	public InvocationContext invocationContext;
-	public Map<String, T2Reference> data;
-	public Thread thread;
-
-	public boolean failed = false;
-	
-	public List<RuntimeException> failures = new ArrayList<RuntimeException>();
-	
-	public DummyCallback(ReferenceService referenceService) {
-		this.referenceService = referenceService;
-		this.invocationContext = new InvocationContextImpl(referenceService, null);
-	}
-
-	public void fail(String message, Throwable t) {
-		fail(message, t, null);
-	}
-
-	public void fail(String message) {
-		fail(message, null, null);
-	}
-
-	public void fail(String message, Throwable t, DispatchErrorType arg2) {
-		failed = true;
-		failures.add(new RuntimeException(arg2+message, t));
-		logger.error("", t);
-	}
-	
-	/*public SecurityAgentManager getLocalSecurityManager() {
-		// TODO Auto-generated method stub
-		return null;
-	}*/
-
-	public void receiveCompletion(int[] completionIndex) {
-		// TODO Auto-generated method stub
-
-	}
-
-	public void receiveResult(Map<String, T2Reference> data,
-			int[] index) {
-		this.data = data;
-	}
-
-	public void requestRun(Runnable runMe) {
-		thread = new Thread(runMe);
-		thread.start();
-	}
-
-	public InvocationContext getContext() {
-		return invocationContext;
-	}
-
-	public String getParentProcessIdentifier() {
-		// TODO Auto-generated method stub
-		return "";
-	}
-
-}


[16/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/MonitorManager.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/MonitorManager.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/MonitorManager.java
new file mode 100644
index 0000000..8662ebb
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/MonitorManager.java
@@ -0,0 +1,377 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.monitor;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.taverna.lang.observer.MultiCaster;
+import org.apache.taverna.lang.observer.Observable;
+import org.apache.taverna.lang.observer.Observer;
+import org.apache.taverna.monitor.MonitorManager.MonitorMessage;
+
+/**
+ * Manages a list of monitors implementations that get notified to register and
+ * deregister nodes (ie. {@link{org.apache.taverna.monitor.MonitorNode}s), in
+ * addition to the addition of {@link MonitorableProperty monitorable
+ * properties} of such nodes.
+ * <p>
+ * Nodes are identified by their owning process, which is an array of strings,
+ * for instance ["dataflow2", "processor5", "fish"]
+ * <p>
+ * To notify the (by default 0) monitors, use any of the
+ * {@link #addPropertiesToNode(String[], Set)},
+ * {@link #registerNode(Object, String[], Set)}, {@link #deregisterNode(String)}
+ * methods and variants.
+ * <p>
+ * To register a monitor, use {@link #addObserver(Observer)}.
+ * 
+ * @author Stian Soiland-Reyes
+ */
+public class MonitorManager implements Observable<MonitorMessage> {
+	private static MonitorManager instance;
+
+	/**
+	 * Get the MonitorManager singleton instance.
+	 * 
+	 * @return The MonitorManager singleton
+	 */
+	public synchronized static MonitorManager getInstance() {
+		if (instance == null)
+			setInstance(new MonitorManager());
+		return instance;
+	}
+
+	/**
+	 * Set the MonitorManager singleton instance. Only to be used by overriding
+	 * super classes at initialisation time.
+	 * 
+	 * @param instance
+	 *            MonitorManager singleton to be returned by
+	 *            {@link #getInstance()}.
+	 */
+	protected synchronized static void setInstance(MonitorManager instance) {
+		MonitorManager.instance = instance;
+	}
+
+	protected MultiCaster<MonitorMessage> multiCaster = new MultiCaster<>(this);
+
+	/**
+	 * Protected constructor, use singleton access
+	 * {@link MonitorManager#getInstance()} instead.
+	 * 
+	 */
+	protected MonitorManager() {
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void addObserver(Observer<MonitorMessage> observer) {
+		multiCaster.addObserver(observer);
+	}
+
+	/**
+	 * Push new property get / set methods into the specified node. This is used
+	 * for monitor-able activities where we have to create the node in the state
+	 * tree before we have the set of monitor-able properties for it.
+	 * 
+	 * @param owningProcess
+	 *            the node path to add properties, this must already be
+	 *            registered in the state model, if not then this method fails
+	 *            silently and does nothing.
+	 * @param newProperties
+	 *            the set of properties to add to the specified node in the
+	 *            state model
+	 */
+	public void addPropertiesToNode(String[] owningProcess,
+			Set<MonitorableProperty<?>> newProperties) {
+		multiCaster.notify(new AddPropertiesMessage(owningProcess,
+				newProperties));
+	}
+
+	/**
+	 * Remove the specified node from the monitor. This must be called when the
+	 * final data or completion event leaves a boundary of control. The monitor
+	 * is free to delay the actual removal of state, in which case the node may
+	 * choose to throw exceptions when properties are accessed. The monitor
+	 * should eventually release all references to work-flow objects and process
+	 * identifiers - typically this is used to allow a UI a few seconds delay on
+	 * de-registration so that very fast register / de-register cycles are
+	 * visible to a user.
+	 * <p>
+	 * The specified process identifier must exist within the monitor.
+	 * 
+	 * @param owningProcess
+	 *            the identifier of the node to remove as a :-separated string
+	 */
+	public void deregisterNode(String owningProcessIdentifier) {
+		deregisterNode(owningProcessIdentifier.split(":"));
+	}
+
+	/**
+	 * Remove the specified node from the monitor. This must be called when the
+	 * final data or completion event leaves a boundary of control. The monitor
+	 * is free to delay the actual removal of state, in which case the node may
+	 * choose to throw exceptions when properties are accessed. The monitor
+	 * should eventually release all references to work-flow objects and process
+	 * identifiers - typically this is used to allow a UI a few seconds delay on
+	 * de-registration so that very fast register / de-register cycles are
+	 * visible to a user.
+	 * <p>
+	 * The specified process identifier must exist within the monitor.
+	 * 
+	 * @param owningProcess
+	 *            the identifier of the node to remove.
+	 */
+	public void deregisterNode(String[] owningProcess) {
+		multiCaster.notify(new DeregisterNodeMessage(owningProcess));
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public List<Observer<MonitorMessage>> getObservers() {
+		return multiCaster.getObservers();
+	}
+
+	/**
+	 * Register a new node with this monitor. New nodes can only be registered
+	 * when a new process identifier is allocated to data corresponding to entry
+	 * to a boundary of control in the data-flow. For cases where extensions
+	 * such as dispatch layers wish to augment existing state the plug-in point
+	 * is responsible for the aggregation of appropriate properties.
+	 * <p>
+	 * The process identifier must not already exist within the state tree, if
+	 * it does it will be ignored. Similarly the parent of the process
+	 * identifier must exist, you cannot specify orphan nodes with no parent.
+	 * 
+	 * @param workflowObject
+	 *            an object within the work-flow model which has received the
+	 *            data stream and caused this node to be created. This may or
+	 *            may not be a top level work-flow entity such as a processor or
+	 *            data-flow. It may be empty in which case null can be used but
+	 *            this is not recommended (there's almost always something you
+	 *            can put here, in general the code to create a new node is
+	 *            contained within something that's just received a data stream
+	 *            so a default approach would be to use the 'this'
+	 *            meta-variable)
+	 * @param owningProcess
+	 *            the :-separated process identifier as a string which has been
+	 *            assigned to data moving through the workflow object. The list
+	 *            of IDs must contain the new identifier as the last element.
+	 */
+	public void registerNode(Object workflowObject,
+			String owningProcessIdentifier) {
+		registerNode(workflowObject, owningProcessIdentifier.split(":"), null);
+	}
+
+	/**
+	 * Register a new node with this monitor. New nodes can only be registered
+	 * when a new process identifier is allocated to data corresponding to entry
+	 * to a boundary of control in the data-flow. For cases where extensions
+	 * such as dispatch layers wish to augment existing state the plug-in point
+	 * is responsible for the aggregation of appropriate properties.
+	 * <p>
+	 * The process identifier must not already exist within the state tree, if
+	 * it does it will be ignored. Similarly the parent of the process
+	 * identifier must exist, you cannot specify orphan nodes with no parent.
+	 * 
+	 * @param workflowObject
+	 *            an object within the work-flow model which has received the
+	 *            data stream and caused this node to be created. This may or
+	 *            may not be a top level work-flow entity such as a processor or
+	 *            data-flow. It may be empty in which case null can be used but
+	 *            this is not recommended (there's almost always something you
+	 *            can put here, in general the code to create a new node is
+	 *            contained within something that's just received a data stream
+	 *            so a default approach would be to use the 'this'
+	 *            meta-variable)
+	 * @param owningProcess
+	 *            the :-separated process identifier as a string which has been
+	 *            assigned to data moving through the workflow object. The list
+	 *            of IDs must contain the new identifier as the last element. *
+	 * @param properties
+	 *            the set of monitor-able, and potentially steer-able,
+	 *            properties which can be monitored from this node. Properties
+	 *            may cache, may become invalid and may make no guarantee about
+	 *            timely updates.
+	 */
+	public void registerNode(Object workflowObject,
+			String owningProcessIdentifier,
+			Set<MonitorableProperty<?>> properties) {
+		registerNode(workflowObject, owningProcessIdentifier.split(":"),
+				properties);
+	}
+
+	/**
+	 * Register a new node with this monitor. New nodes can only be registered
+	 * when a new process identifier is allocated to data corresponding to entry
+	 * to a boundary of control in the data-flow. For cases where extensions
+	 * such as dispatch layers wish to augment existing state the plug-in point
+	 * is responsible for the aggregation of appropriate properties.
+	 * <p>
+	 * The process identifier must not already exist within the state tree, if
+	 * it does it will be ignored. Similarly the parent of the process
+	 * identifier must exist, you cannot specify orphan nodes with no parent.
+	 * 
+	 * @param workflowObject
+	 *            an object within the work-flow model which has received the
+	 *            data stream and caused this node to be created. This may or
+	 *            may not be a top level work-flow entity such as a processor or
+	 *            data-flow. It may be empty in which case null can be used but
+	 *            this is not recommended (there's almost always something you
+	 *            can put here, in general the code to create a new node is
+	 *            contained within something that's just received a data stream
+	 *            so a default approach would be to use the 'this'
+	 *            meta-variable)
+	 * @param owningProcess
+	 *            the process identifier which has been assigned to data moving
+	 *            through the work-flow object. The list of IDs must contain the
+	 *            new identifier as the last element.
+	 */
+	public void registerNode(Object workflowObject, String[] owningProcess) {
+		registerNode(workflowObject, owningProcess, null);
+	}
+
+	/**
+	 * Register a new node with this monitor. New nodes can only be registered
+	 * when a new process identifier is allocated to data corresponding to entry
+	 * to a boundary of control in the data-flow. For cases where extensions
+	 * such as dispatch layers wish to augment existing state the plug-in point
+	 * is responsible for the aggregation of appropriate properties.
+	 * <p>
+	 * The process identifier must not already exist within the state tree, if
+	 * it does it will be ignored. Similarly the parent of the process
+	 * identifier must exist, you cannot specify orphan nodes with no parent.
+	 * 
+	 * @param workflowObject
+	 *            an object within the work-flow model which has received the
+	 *            data stream and caused this node to be created. This may or
+	 *            may not be a top level work-flow entity such as a processor or
+	 *            data-flow. It may be empty in which case null can be used but
+	 *            this is not recommended (there's almost always something you
+	 *            can put here, in general the code to create a new node is
+	 *            contained within something that's just received a data stream
+	 *            so a default approach would be to use the 'this'
+	 *            meta-variable)
+	 * @param owningProcess
+	 *            the process identifier which has been assigned to data moving
+	 *            through the work-flow object. The list of IDs must contain the
+	 *            new identifier as the last element.
+	 * @param properties
+	 *            the set of monitor-able, and potentially steer-able,
+	 *            properties which can be monitored from this node. Properties
+	 *            may cache, may become invalid and may make no guarantee about
+	 *            timely updates.
+	 */
+	public void registerNode(Object workflowObject, String[] owningProcess,
+			Set<MonitorableProperty<?>> properties) {
+		if (properties == null)
+			properties = new HashSet<>();
+		multiCaster.notify(new RegisterNodeMessage(workflowObject,
+				owningProcess, properties));
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void removeObserver(Observer<MonitorMessage> observer) {
+		multiCaster.removeObserver(observer);
+	}
+
+	/**
+	 * Message indicating that {@link #getNewProperties() new properties} have
+	 * been added to a node identified by given {@link #getOwningProcess()
+	 * owning process}.
+	 * 
+	 */
+	public class AddPropertiesMessage extends MonitorMessage {
+		private final Set<MonitorableProperty<?>> newProperties;
+
+		public AddPropertiesMessage(String[] owningProcess,
+				Set<MonitorableProperty<?>> newProperties) {
+			super(owningProcess);
+			this.newProperties = newProperties;
+		}
+
+		public Set<MonitorableProperty<?>> getNewProperties() {
+			return newProperties;
+		}
+	}
+
+	/**
+	 * Message indicating that the node of the given {@link #getOwningProcess()
+	 * owning process} is to be deregistered.
+	 * 
+	 */
+	public class DeregisterNodeMessage extends MonitorMessage {
+		public DeregisterNodeMessage(String[] owningProcess) {
+			super(owningProcess);
+		}
+	}
+
+	/**
+	 * Common abstract superclass for all monitor messages. Identifies the
+	 * {@link #getOwningProcess() owning process}.
+	 * 
+	 */
+	public abstract class MonitorMessage {
+		private final String[] owningProcess;
+
+		public MonitorMessage(String[] owningProcess) {
+			this.owningProcess = owningProcess;
+		}
+
+		public String[] getOwningProcess() {
+			return owningProcess;
+		}
+	}
+
+	/**
+	 * Message indicating that the node of the given {@link #getOwningProcess()
+	 * owning process} is to be registered. The node might have
+	 * {@link #getProperties() a set of monitorable properties} and a
+	 * {@link #getWorkflowObject workflow object}.
+	 */
+	public class RegisterNodeMessage extends MonitorMessage {
+		private final Set<MonitorableProperty<?>> properties;
+		private final Object workflowObject;
+
+		public RegisterNodeMessage(Object workflowObject,
+				String[] owningProcess, Set<MonitorableProperty<?>> properties) {
+			super(owningProcess);
+			this.workflowObject = workflowObject;
+			this.properties = properties;
+		}
+
+		public Set<MonitorableProperty<?>> getProperties() {
+			return properties;
+		}
+
+		public Object getWorkflowObject() {
+			return workflowObject;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/MonitorNode.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/MonitorNode.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/MonitorNode.java
new file mode 100644
index 0000000..9979db8
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/MonitorNode.java
@@ -0,0 +1,75 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.monitor;
+
+import java.util.Date;
+import java.util.Set;
+
+/**
+ * A single node in the Monitor tree, containing an optional arbitrary workflow
+ * object and a set of properties which may or may not be mutable. For tree
+ * traversal operations the top level monitor tree must be used, instances of
+ * this class are not aware of the surrounding tree structure.
+ * 
+ * @author Tom Oinn
+ */
+public interface MonitorNode {
+	/**
+	 * Each monitor node can reference zero or one workflow object. This is the
+	 * object which is providing any properties the node exposes, so is likely
+	 * to be a workflow or processor but could be anything.
+	 * 
+	 * @return the workflow object providing this node's properties, or null if
+	 *         there is no directly corresponding workflow object. Note that
+	 *         this workflow object can be anything, and may not be a top level
+	 *         workflow object at all.
+	 */
+	Object getWorkflowObject();
+
+	/**
+	 * Each monitor node has an identity corresponding to the identifier stack
+	 * of the data flowing through the workflow object that created it. This
+	 * string array also defines its position in the monitor tree.
+	 */
+	String[] getOwningProcess();
+
+	/**
+	 * Each monitor node exposes a set of properties, which may or may not be
+	 * mutable
+	 */
+	Set<? extends MonitorableProperty<?>> getProperties();
+
+	/**
+	 * Each node has a creation date
+	 */
+	Date getCreationDate();
+
+	/**
+	 * Properties can be added to the monitor node after creation if required,
+	 * although this should be used only when necessary to avoid race conditions
+	 */
+	void addMonitorableProperty(MonitorableProperty<?> newProperty);
+
+	/**
+	 * Nodes can persist in the tree after they have expired, in which case this
+	 * will return true.
+	 */
+	boolean hasExpired();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/MonitorableProperty.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/MonitorableProperty.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/MonitorableProperty.java
new file mode 100644
index 0000000..6e83652
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/MonitorableProperty.java
@@ -0,0 +1,54 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.monitor;
+
+import java.util.Date;
+
+/**
+ * A single readable property contained by a Monitorable. This is used to
+ * express properties that are dynamic with respect to workflow invocation as
+ * opposed to static properties defined by the workflow model. A typical example
+ * of this might be dispatch stack queue size or number of jobs completed. All
+ * properties are defined relative to a particular owning process identifier,
+ * this is the same mechanism as used in the workflow model to isolate different
+ * data streams.
+ * 
+ * @author Tom Oinn
+ */
+public interface MonitorableProperty<T> {
+	/**
+	 * Return the value of this property
+	 */
+	T getValue() throws NoSuchPropertyException;
+
+	/**
+	 * Return the name of this property, names are heirarchical in nature and
+	 * are defined as an array of String objects. This is to allow e.g. dispatch
+	 * layers to expose a set of related properties under the same root name.
+	 */
+	String[] getName();
+
+	/**
+	 * Get the last update date for this property, if the property is immutable
+	 * then this should be set to the date at which the implementation is
+	 * created.
+	 */
+	Date getLastModified();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/NoSuchPropertyException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/NoSuchPropertyException.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/NoSuchPropertyException.java
new file mode 100644
index 0000000..aeb75fc
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/NoSuchPropertyException.java
@@ -0,0 +1,49 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.monitor;
+
+/**
+ * Thrown when an attempt is made to access a monitorable property which is no
+ * longer current. This is quite a common event as the properties can change
+ * extremely quickly whereas the logic accessing them is expected not to.
+ * Consumers of state data must cope with this disparity by handling this
+ * exception where it is thrown.
+ * 
+ * @author Tom Oinn
+ */
+public class NoSuchPropertyException extends Exception {
+	private static final long serialVersionUID = 6320919057517500603L;
+
+	public NoSuchPropertyException() {
+		super();
+	}
+
+	public NoSuchPropertyException(String arg0, Throwable arg1) {
+		super(arg0, arg1);
+	}
+
+	public NoSuchPropertyException(String arg0) {
+		super(arg0);
+	}
+
+	public NoSuchPropertyException(Throwable arg0) {
+		super(arg0);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/SteerableProperty.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/SteerableProperty.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/SteerableProperty.java
new file mode 100644
index 0000000..95448fa
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/SteerableProperty.java
@@ -0,0 +1,36 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.monitor;
+
+/**
+ * Some monitorable properties are mutable and can be written to by steering
+ * agents or other clients.
+ * 
+ * @author Tom Oinn
+ */
+public interface SteerableProperty<T> extends MonitorableProperty<T> {
+	/**
+	 * Set the property value
+	 * 
+	 * @param newValue
+	 * @throws NoSuchPropertyException
+	 */
+	void setProperty(T newValue) throws NoSuchPropertyException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/package.html b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/package.html
new file mode 100644
index 0000000..17ee572
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/monitor/package.html
@@ -0,0 +1,36 @@
+<body>
+Defines the API for the monitoring and steering system. As data flows
+through a workflow it passes through a succession of bounds of control.
+Each of these boundaries corresponds to a workflow, a nested process or
+some other contained entity where a new owning process identifier is
+pushed onto the process identifier stack for that data item. This
+modification to the owning process identifier implicitly creates a tree
+structure where the parent of a particular identifier can be obtained by
+popping the last component off its identifier stack (in general this
+means splitting into a list by the ':' character and removing the last
+item).
+<p>Any entity issuing a new identifier to data in this way must
+implement the Monitorable interface and should register itself with the
+Monitor before or at the point of assigning this new identifier. Some
+cases may register child items rather than delegating to the children
+themselves, for example a workflow definition may register all its
+processors as children and deregister on workflow completion rather than
+the process happening for each processor but however it is accomplished
+the result is the creation within the Monitor of a tree where nodes
+contain references to Monitorable objects within the workflow
+definition.
+<p>The Monitorable interface defines a simple contract - once
+registered the implementing class can return a list of
+MonitorableProperty instances defining the exposed dynamic state at this
+node in the context of a given process identifier. Any of these
+properties may be mutable in which case they will extend
+SteerableProperty, a sub-interface of MonitorableProperty which allows
+for the mutation of the property.
+<p>By design the Monitor is rather powerful - it has the ability to
+modify steerable properties in any running workflow. It is obviously
+desirable to restrict this, passing any given monitoring or steering
+agent a restricted subset of the monitor tree rooted at a specific
+process identifier and preventing direct access to the Monitor class.
+The Monitor interface defines methods to expose subsets of the
+monitorable state for this reason.
+</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/AbstractProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/AbstractProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/AbstractProvenanceItem.java
new file mode 100644
index 0000000..1d2e390
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/AbstractProvenanceItem.java
@@ -0,0 +1,96 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.provenance.item;
+
+import org.apache.taverna.provenance.vocabulary.SharedVocabulary;
+
+public abstract class AbstractProvenanceItem implements ProvenanceItem {
+	@Override
+	public abstract SharedVocabulary getEventType();
+
+	private String identifier, parentId, processId, workflowId;
+
+	@Override
+	public final String getIdentifier() {
+		return identifier;
+	}
+
+	@Override
+	public int hashCode() {
+		return 31 + (identifier == null ? 0 : identifier.hashCode());
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (obj == null)
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		AbstractProvenanceItem other = (AbstractProvenanceItem) obj;
+		if (identifier == null) {
+			if (other.identifier != null)
+				return false;
+		} else if (!identifier.equals(other.identifier))
+			return false;
+		return true;
+	}
+
+	@Override
+	public final void setIdentifier(String identifier) {
+		this.identifier = identifier;
+	}
+
+	@Override
+	public final String getParentId() {
+		return parentId;
+	}
+
+	@Override
+	public final void setParentId(String parentId) {
+		this.parentId = parentId;
+	}
+
+	@Override
+	public final String getProcessId() {
+		return processId;
+	}
+
+	@Override
+	public final void setProcessId(String processId) {
+		this.processId = processId;
+	}
+
+	@Override
+	public final String getWorkflowId() {
+		return workflowId;
+	}
+
+	@Override
+	public final void setWorkflowId(String workflowId) {
+		this.workflowId = workflowId;
+	}
+	
+	@Override
+	public String toString() {
+		return getEventType() + " id:" + getIdentifier() + " parent:" + getParentId();
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/ActivityProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/ActivityProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/ActivityProvenanceItem.java
new file mode 100644
index 0000000..4167bdc
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/ActivityProvenanceItem.java
@@ -0,0 +1,61 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.provenance.item;
+
+import org.apache.taverna.provenance.vocabulary.SharedVocabulary;
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+
+/**
+ * Contains details for an enacted Activity. Parent is a
+ * {@link ProcessorProvenanceItem}. Children are {@link IterationProvenanceItem}
+ * s. There could be multiple {@link ActivityProvenanceItem}s for each
+ * {@link ProcessorProvenanceItem}
+ * 
+ * @author Ian Dunlop
+ * @author Stuart Owen
+ * @author Paolo Missier
+ */
+public class ActivityProvenanceItem extends AbstractProvenanceItem implements ProvenanceItem  {
+	private Activity<?> activity;
+	private IterationProvenanceItem iterationProvenanceItem;
+	
+	public void setIterationProvenanceItem(
+			IterationProvenanceItem iterationProvenanceItem) {
+		this.iterationProvenanceItem = iterationProvenanceItem;
+	}
+
+	public IterationProvenanceItem getIterationProvenanceItem() {
+		return iterationProvenanceItem;
+	}
+
+	@Override
+	public SharedVocabulary getEventType() {
+		return SharedVocabulary.ACTIVITY_EVENT_TYPE;
+	}
+
+	public Activity<?> getActivity() {
+		return activity;
+	}
+
+	public void setActivity(Activity<?> activity) {
+		this.activity = activity;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/DataProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/DataProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/DataProvenanceItem.java
new file mode 100644
index 0000000..f3b366c
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/DataProvenanceItem.java
@@ -0,0 +1,62 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.provenance.item;
+
+import java.util.Map;
+
+import org.apache.taverna.reference.ReferenceService;
+import org.apache.taverna.reference.T2Reference;
+
+/**
+ * Contains references to data which a workflow has used or created. Parent is
+ * an {@link IterationProvenanceItem}
+ * 
+ * @author Ian Dunlop
+ * @auhor Stuart Owen
+ * @author Paolo Missier
+ */
+public abstract class DataProvenanceItem extends AbstractProvenanceItem {
+	/** A map of port name to data reference */
+	private Map<String, T2Reference> dataMap;
+	private ReferenceService referenceService;
+
+	/**
+	 * Is this {@link ProvenanceItem} for input or output data
+	 * 
+	 * @return
+	 */
+	protected abstract boolean isInput();
+
+	public Map<String, T2Reference> getDataMap() {
+		return dataMap;
+	}
+
+	public void setDataMap(Map<String, T2Reference> dataMap) {
+		this.dataMap = dataMap;
+	}
+	
+	public void setReferenceService(ReferenceService referenceService) {
+		this.referenceService = referenceService;
+	}
+
+	public ReferenceService getReferenceService() {
+		return referenceService;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/DataflowRunComplete.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/DataflowRunComplete.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/DataflowRunComplete.java
new file mode 100644
index 0000000..4d3eb2f
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/DataflowRunComplete.java
@@ -0,0 +1,60 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.provenance.item;
+
+import java.sql.Timestamp;
+
+import org.apache.taverna.facade.WorkflowInstanceFacade.State;
+import org.apache.taverna.provenance.vocabulary.SharedVocabulary;
+
+/**
+ * Informs the {@link ProvenanceConnector} that a workflow has been run to
+ * completion. If a {@link ProvenanceConnector} receives this event then it
+ * means that there are no further events to come and that the workflow has been
+ * enacted to completion
+ * 
+ * @author Ian Dunlop
+ */
+public class DataflowRunComplete extends AbstractProvenanceItem {
+	private SharedVocabulary eventType = SharedVocabulary.END_WORKFLOW_EVENT_TYPE;
+	private Timestamp invocationEnded;
+	private State state;
+
+	public Timestamp getInvocationEnded() {
+		return invocationEnded;
+	}
+
+	@Override
+	public SharedVocabulary getEventType() {
+		return eventType;
+	}
+
+	public void setInvocationEnded(Timestamp invocationEnded) {
+		this.invocationEnded = invocationEnded;
+	}
+
+	public void setState(State state) {
+		this.state = state;
+	}
+
+	public State getState() {
+		return state;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/ErrorProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/ErrorProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/ErrorProvenanceItem.java
new file mode 100644
index 0000000..7f1f8a1
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/ErrorProvenanceItem.java
@@ -0,0 +1,70 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.provenance.item;
+
+import org.apache.taverna.provenance.vocabulary.SharedVocabulary;
+
+/**
+ * When an error is received in the dispatch stack, one of these is created and
+ * sent across to the {@link ProvenanceConnector}. Parent is an
+ * {@link IterationProvenanceItem}
+ * 
+ * @author Ian Dunlop
+ * @author Stuart Owen
+ * @author Paolo Missier
+ */
+public class ErrorProvenanceItem extends AbstractProvenanceItem {
+	private Throwable cause;
+	private String message;
+	private String errorType;
+	private SharedVocabulary eventType = SharedVocabulary.ERROR_EVENT_TYPE;
+
+	public ErrorProvenanceItem() {
+	}
+
+	@Override
+	public SharedVocabulary getEventType() {
+		return eventType;
+	}
+
+	public Throwable getCause() {
+		return cause;
+	}
+
+	public void setCause(Throwable cause) {
+		this.cause = cause;
+	}
+
+	public String getMessage() {
+		return message;
+	}
+
+	public void setMessage(String message) {
+		this.message = message;
+	}
+
+	public String getErrorType() {
+		return errorType;
+	}
+
+	public void setErrorType(String errorType) {
+		this.errorType = errorType;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/InputDataProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/InputDataProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/InputDataProvenanceItem.java
new file mode 100644
index 0000000..1c03726
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/InputDataProvenanceItem.java
@@ -0,0 +1,48 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.provenance.item;
+
+import org.apache.taverna.provenance.vocabulary.SharedVocabulary;
+
+/**
+ * Contains details of port names and the input data they receive. Parent is an
+ * {@link IterationProvenanceItem}
+ * 
+ * @author Paolo Missier
+ * @author Stuart Owen
+ * @author Ian Dunlop
+ */
+public class InputDataProvenanceItem extends DataProvenanceItem {
+	private SharedVocabulary eventType = SharedVocabulary.INPUTDATA_EVENT_TYPE;
+
+	/**
+	 * Used when generating the xml version by the {@link DataProvenanceItem}.
+	 * Identifies this {@link DataProvenanceItem} as containing input
+	 */
+	@Override
+	protected boolean isInput() {
+		return true;
+	}
+
+	@Override
+	public SharedVocabulary getEventType() {
+		return eventType;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/InvocationStartedProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/InvocationStartedProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/InvocationStartedProvenanceItem.java
new file mode 100644
index 0000000..9b5add4
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/InvocationStartedProvenanceItem.java
@@ -0,0 +1,60 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.provenance.item;
+
+import java.sql.Date;
+
+import org.apache.taverna.provenance.vocabulary.SharedVocabulary;
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+
+public class InvocationStartedProvenanceItem extends AbstractProvenanceItem {
+	private Activity<?> activity;
+	private String invocationProcessId;
+	private Date invocationStarted;
+
+	public final Date getInvocationStarted() {
+		return invocationStarted;
+	}
+
+	@Override
+	public SharedVocabulary getEventType() {
+		return SharedVocabulary.INVOCATION_STARTED_EVENT_TYPE;
+	}
+
+	public void setActivity(Activity<?> activity) {
+		this.activity = activity;
+	}
+
+	public Activity<?> getActivity() {
+		return activity;
+	}
+
+	public void setInvocationProcessId(String invocationProcessId) {
+		this.invocationProcessId = invocationProcessId;
+	}
+
+	public String getInvocationProcessId() {
+		return invocationProcessId;
+	}
+
+	public void setInvocationStarted(Date invocationStarted) {
+		this.invocationStarted = invocationStarted;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/IterationProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/IterationProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/IterationProvenanceItem.java
new file mode 100644
index 0000000..b411e6e
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/IterationProvenanceItem.java
@@ -0,0 +1,107 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.provenance.item;
+
+import java.sql.Timestamp;
+
+import org.apache.taverna.provenance.vocabulary.SharedVocabulary;
+
+/**
+ * One of these is created for each iteration inside an enacted activity.
+ * Contains both the input and output data and port names contained inside
+ * {@link DataProvenanceItem}s. The actual iteration number is contained inside
+ * an int array eg [1]
+ * 
+ * @author Ian Dunlop
+ * @author Paolo Missier
+ * @author Stuart Owen
+ */
+public class IterationProvenanceItem extends AbstractProvenanceItem {
+	private Timestamp enactmentEnded;
+	private Timestamp enactmentStarted;
+	private ErrorProvenanceItem errorItem;
+	private final SharedVocabulary eventType = SharedVocabulary.ITERATION_EVENT_TYPE;
+	private InputDataProvenanceItem inputDataItem;
+	private int[] iteration;
+	private OutputDataProvenanceItem outputDataItem;
+	private IterationProvenanceItem parentIterationItem = null;
+
+	public IterationProvenanceItem getParentIterationItem() {
+		return parentIterationItem;
+	}
+
+	public Timestamp getEnactmentEnded() {
+		return enactmentEnded;
+	}
+
+	public Timestamp getEnactmentStarted() {
+		return enactmentStarted;
+	}
+
+	public ErrorProvenanceItem getErrorItem() {
+		return errorItem;
+	}
+
+	@Override
+	public SharedVocabulary getEventType() {
+		return eventType;
+	}
+
+	public InputDataProvenanceItem getInputDataItem() {
+		return inputDataItem;
+	}
+
+	public int[] getIteration() {
+		return iteration;
+	}
+
+	public OutputDataProvenanceItem getOutputDataItem() {
+		return outputDataItem;
+	}
+
+	public void setEnactmentEnded(Timestamp enactmentEnded) {
+		this.enactmentEnded = enactmentEnded;
+	}
+
+	public void setEnactmentStarted(Timestamp enactmentStarted) {
+		this.enactmentStarted = enactmentStarted;
+	}
+
+	public void setErrorItem(ErrorProvenanceItem errorItem) {
+		this.errorItem = errorItem;
+	}
+
+	public void setInputDataItem(InputDataProvenanceItem inputDataItem) {
+		this.inputDataItem = inputDataItem;
+	}
+
+	public void setIteration(int[] iteration) {
+		this.iteration = iteration;
+	}
+
+	public void setOutputDataItem(OutputDataProvenanceItem outputDataItem) {
+		this.outputDataItem = outputDataItem;
+	}
+
+	public void setParentIterationItem(
+			IterationProvenanceItem parentIterationItem) {
+		this.parentIterationItem = parentIterationItem;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/OutputDataProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/OutputDataProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/OutputDataProvenanceItem.java
new file mode 100644
index 0000000..223947a
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/OutputDataProvenanceItem.java
@@ -0,0 +1,48 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.provenance.item;
+
+import org.apache.taverna.provenance.vocabulary.SharedVocabulary;
+
+/**
+ * Contains details of port names and the output data they receive. Parent is an
+ * {@link IterationProvenanceItem}
+ * 
+ * @author Paolo Missier
+ * @author Stuart Owen
+ * @author Ian Dunlop
+ */
+public class OutputDataProvenanceItem extends DataProvenanceItem {
+	private SharedVocabulary eventType = SharedVocabulary.OUTPUTDATA_EVENT_TYPE;
+
+	/**
+	 * Used when generating the xml version by the {@link DataProvenanceItem}.
+	 * Identifies this {@link DataProvenanceItem} as containing output
+	 */
+	@Override
+	protected boolean isInput() {
+		return false;
+	}
+
+	@Override
+	public SharedVocabulary getEventType() {
+		return eventType;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/ProcessProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/ProcessProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/ProcessProvenanceItem.java
new file mode 100644
index 0000000..8789f08
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/ProcessProvenanceItem.java
@@ -0,0 +1,88 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.provenance.item;
+
+import org.apache.taverna.provenance.vocabulary.SharedVocabulary;
+
+/**
+ * Each time a job is received by the dispatch stack one of these will be
+ * created. It has a {@link ProcessorProvenanceItem} as its child. Its parent is
+ * a {@link WorkflowProvenanceItem} which in turn knows the unique id of the
+ * workflow the provenance is being stored for. NOTE: May be superfluous since
+ * it essentially mimics the behaviour of its child item but may be more hastle
+ * than it is worth to remove it
+ * 
+ * @author Stuart owen
+ * @author Paolo Missier
+ * @author Ian Dunlop
+ */
+public class ProcessProvenanceItem extends AbstractProvenanceItem {
+	private String owningProcess;
+	private ProcessorProvenanceItem processorProvenanceItem;
+	private String facadeID;
+	private String dataflowID;
+	private SharedVocabulary eventType = SharedVocabulary.PROCESS_EVENT_TYPE;
+
+	/**
+	 * As {@link WorkflowInstanceFacade}s are created for a Processor the
+	 * details are appended to the owning process identifier. This is in the
+	 * form facadeX:dataflowY:ProcessorZ etc. This method returns the facadeX
+	 * part.
+	 * 
+	 * @return
+	 */
+	public String getFacadeID() {
+		return facadeID;
+	}
+
+	public void setProcessorProvenanceItem(
+			ProcessorProvenanceItem processorProvenanceItem) {
+		this.processorProvenanceItem = processorProvenanceItem;
+	}
+
+	public ProcessorProvenanceItem getProcessorProvenanceItem() {
+		return processorProvenanceItem;
+	}
+
+	@Override
+	public SharedVocabulary getEventType() {
+		return eventType;
+	}
+
+	public String getOwningProcess() {
+		return owningProcess;
+	}
+
+	public void setOwningProcess(String owningProcess) {
+		this.owningProcess = owningProcess;
+	}
+
+	public void setFacadeID(String facadeID) {
+		this.facadeID = facadeID;
+	}
+
+	public void setDataflowID(String dataflowID) {
+		this.dataflowID = dataflowID;
+	}
+
+	public String getDataflowID() {
+		return dataflowID;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/ProcessorProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/ProcessorProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/ProcessorProvenanceItem.java
new file mode 100644
index 0000000..7c3239c
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/ProcessorProvenanceItem.java
@@ -0,0 +1,56 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.provenance.item;
+
+import org.apache.taverna.provenance.vocabulary.SharedVocabulary;
+
+/**
+ * Each Processor inside a workflow will have one of these for each provenance
+ * run. Its parent is a {@link ProcessProvenanceItem} and child is an
+ * {@link ActivityProvenanceItem}. In theory there could be more than one
+ * {@link ActivityProvenanceItem} per processor to cope with failover etc
+ * 
+ * @author Ian Dunlop
+ * @author Stuart Owen
+ * @author Paolo Missier
+ */
+public class ProcessorProvenanceItem extends AbstractProvenanceItem {
+	private ActivityProvenanceItem activityProvenanceItem;
+	private String identifier;
+	private SharedVocabulary eventType = SharedVocabulary.PROCESSOR_EVENT_TYPE;
+
+	public void setActivityProvenanceItem(
+			ActivityProvenanceItem activityProvenanceItem) {
+		this.activityProvenanceItem = activityProvenanceItem;
+	}
+
+	public ActivityProvenanceItem getActivityProvenanceItem() {
+		return activityProvenanceItem;
+	}
+
+	public String getProcessorID() {
+		return identifier;
+	}
+
+	@Override
+	public SharedVocabulary getEventType() {
+		return eventType;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/ProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/ProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/ProvenanceItem.java
new file mode 100644
index 0000000..2023c65
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/ProvenanceItem.java
@@ -0,0 +1,102 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.provenance.item;
+
+import org.apache.taverna.provenance.vocabulary.SharedVocabulary;
+
+/**
+ * Used to store some enactment information during a workflow run
+ * 
+ * @see AbstractProvenanceItem
+ * @author Ian Dunlop
+ */
+public interface ProvenanceItem {
+	/**
+	 * What type of information does the item contain. The
+	 * {@link SharedVocabulary} can be used to identify it
+	 * 
+	 * @return
+	 */
+	SharedVocabulary getEventType();
+
+	/**
+	 * The unique identifier for this item
+	 * 
+	 * @return
+	 */
+	String getIdentifier();
+
+	/**
+	 * A unique id for this event. Any children would use this as their parentId
+	 * 
+	 * @param identifier
+	 */
+	void setIdentifier(String identifier);
+
+	/**
+	 * The workflow model id that is supplied during enactment eg
+	 * facade0:dataflow2:processor1
+	 * 
+	 * @param processId
+	 */
+	void setProcessId(String processId);
+
+	/**
+	 * Get the enactor supplie identifier
+	 * 
+	 * @return
+	 */
+	String getProcessId();
+
+	/**
+	 * The parent of this provenance Item. The model is
+	 * WorkflowProvenanceItem>ProcessProvenanceItem
+	 * >ProcessorProvenanceItem>ActivityProvenanceITem
+	 * >IterationProvenanceItem>DataProvenanceItem
+	 * 
+	 * Additionally there is a WorkflowDataProvenanceItem that is sent when the
+	 * facade receives a completion event and a ErrorProvenanceItem when things
+	 * go wrong
+	 * 
+	 * @param parentId
+	 */
+	void setParentId(String parentId);
+
+	/**
+	 * Who is the parent of this item?
+	 * 
+	 * @return
+	 */
+	String getParentId();
+
+	/**
+	 * The uuid that belongs to the actual dataflow
+	 * 
+	 * @param workflowId
+	 */
+	void setWorkflowId(String workflowId);
+
+	/**
+	 * The uuid that belongs to the actual dataflow
+	 * 
+	 * @return a string representation of a uuid
+	 */
+	String getWorkflowId();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/WorkflowDataProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/WorkflowDataProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/WorkflowDataProvenanceItem.java
new file mode 100644
index 0000000..89a7a52
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/WorkflowDataProvenanceItem.java
@@ -0,0 +1,100 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.provenance.item;
+
+import org.apache.taverna.provenance.vocabulary.SharedVocabulary;
+import org.apache.taverna.reference.ReferenceService;
+import org.apache.taverna.reference.T2Reference;
+
+/**
+ * When the {@link WorkflowInstanceFacade} for a processor receives a data token
+ * one of these is created. This is especially important for data which flows
+ * straight through a facade without going into the dispatch stack (a rare event
+ * but it can happen)
+ * 
+ * @author Ian Dunlop
+ */
+public class WorkflowDataProvenanceItem extends AbstractProvenanceItem {
+	private ReferenceService referenceService;
+	/** The port name that the data is for */
+	private String portName;
+	/** A reference to the data token received in the facade */
+	private T2Reference data;
+	private SharedVocabulary eventType = SharedVocabulary.WORKFLOW_DATA_EVENT_TYPE;
+	private boolean isFinal;
+	private int[] index;
+	private boolean isInputPort;
+
+	public boolean isInputPort() {
+		return isInputPort;
+	}
+
+	public void setInputPort(boolean isInputPort) {
+		this.isInputPort = isInputPort;
+	}
+
+	public WorkflowDataProvenanceItem() {
+	}
+
+	@Override
+	public SharedVocabulary getEventType() {
+		return eventType;
+	}
+
+	public void setPortName(String portName) {
+		this.portName = portName;
+	}
+
+	public String getPortName() {
+		return portName;
+	}
+
+	public void setData(T2Reference data) {
+		this.data = data;
+	}
+
+	public T2Reference getData() {
+		return data;
+	}
+
+	public void setReferenceService(ReferenceService referenceService) {
+		this.referenceService = referenceService;
+	}
+
+	public ReferenceService getReferenceService() {
+		return referenceService;
+	}
+
+	public void setIndex(int[] index) {
+		this.index = index;
+	}
+
+	public int[] getIndex() {
+		return index;
+	}
+
+	public void setFinal(boolean isFinal) {
+		this.isFinal = isFinal;
+	}
+
+	public boolean isFinal() {
+		return isFinal;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/WorkflowProvenanceItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/WorkflowProvenanceItem.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/WorkflowProvenanceItem.java
new file mode 100644
index 0000000..939988c
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/item/WorkflowProvenanceItem.java
@@ -0,0 +1,100 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.provenance.item;
+
+import java.sql.Timestamp;
+
+import org.apache.taverna.facade.WorkflowInstanceFacade;
+import org.apache.taverna.provenance.vocabulary.SharedVocabulary;
+import org.apache.taverna.workflowmodel.Dataflow;
+
+/**
+ * The first {@link ProvenanceItem} that the {@link ProvenanceConnector} will
+ * receive for a workflow run. Contains the {@link Dataflow} itself as well as
+ * the process id for the {@link WorkflowInstanceFacade} (facadeX:dataflowY).
+ * Its child is a {@link ProcessProvenanceItem} and parent is the UUID of the
+ * {@link Dataflow} itself
+ * 
+ * @author Ian Dunlop
+ * @author Paolo Missier
+ * @author Stuart Owen
+ */
+public class WorkflowProvenanceItem extends AbstractProvenanceItem {
+	private Dataflow dataflow;
+	private SharedVocabulary eventType = SharedVocabulary.WORKFLOW_EVENT_TYPE;
+	private int[] index;
+	private boolean isFinal;
+
+	private Timestamp invocationStarted;
+
+	public Timestamp getInvocationStarted() {
+		return invocationStarted;
+	}
+
+	public WorkflowProvenanceItem() {
+	}
+
+	public Dataflow getDataflow() {
+		return dataflow;
+	}
+
+	public void setDataflow(Dataflow dataflow) {
+		this.dataflow = dataflow;
+	}
+
+	@Override
+	public SharedVocabulary getEventType() {
+		return eventType;
+	}
+
+	/**
+	 * @return the index
+	 */
+	public int[] getIndex() {
+		return index;
+	}
+
+	/**
+	 * @param index
+	 *            the index to set
+	 */
+	public void setIndex(int[] index) {
+		this.index = index;
+	}
+
+	/**
+	 * @return the isFinal
+	 */
+	public boolean isFinal() {
+		return isFinal;
+	}
+
+	/**
+	 * @param isFinal
+	 *            the isFinal to set
+	 */
+	public void setFinal(boolean isFinal) {
+		this.isFinal = isFinal;
+	}
+
+	public void setInvocationStarted(Timestamp invocationStarted) {
+		this.invocationStarted = invocationStarted;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/reporter/ProvenanceReporter.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/reporter/ProvenanceReporter.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/reporter/ProvenanceReporter.java
new file mode 100644
index 0000000..047b23c
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/reporter/ProvenanceReporter.java
@@ -0,0 +1,91 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.provenance.reporter;
+
+import java.util.List;
+
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.provenance.item.ProvenanceItem;
+import org.apache.taverna.provenance.item.WorkflowProvenanceItem;
+import org.apache.taverna.reference.ReferenceService;
+
+public interface ProvenanceReporter {
+	/**
+	 * Add a {@link ProvenanceItem} to the connector
+	 * 
+	 * @param provenanceItem
+	 * @param invocationContext
+	 */
+	void addProvenanceItem(ProvenanceItem provenanceItem);
+
+	// FIXME is this reference service really needed since we have the context?
+	/**
+	 * Tell the connector what {@link ReferenceService} it should use when
+	 * trying to dereference data items inside {@link ProvenanceItem}s
+	 * 
+	 * @param referenceService
+	 */
+	void setReferenceService(ReferenceService referenceService);
+
+	/**
+	 * Get the {@link ReferenceService} in use by this connector
+	 * 
+	 * @return
+	 */
+	ReferenceService getReferenceService();
+
+	/**
+	 * Get all the {@link ProvenanceItem}s that the connector currently knows
+	 * about
+	 * 
+	 * @return
+	 */
+	List<ProvenanceItem> getProvenanceCollection();
+
+	/**
+	 * Set the {@link InvocationContext} that this reporter should be using
+	 * 
+	 * @param invocationContext
+	 */
+	void setInvocationContext(InvocationContext invocationContext);
+
+	/**
+	 * Get the {@link InvocationContext} that this reporter should be using if
+	 * it needs to dereference any data
+	 * 
+	 * @return
+	 */
+	InvocationContext getInvocationContext();
+
+	/**
+	 * A unique identifier for this run of provenance, should correspond to the
+	 * initial {@link WorkflowProvenanceItem} idenifier that gets sent through
+	 * 
+	 * @param identifier
+	 */
+	void setSessionID(String sessionID);
+
+	/**
+	 * What is the unique identifier used by this connector
+	 * 
+	 * @return
+	 */
+	String getSessionID();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/vocabulary/SharedVocabulary.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/vocabulary/SharedVocabulary.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/vocabulary/SharedVocabulary.java
new file mode 100644
index 0000000..c36a322
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/provenance/vocabulary/SharedVocabulary.java
@@ -0,0 +1,33 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.provenance.vocabulary;
+
+import org.apache.taverna.provenance.item.ProvenanceItem;
+
+/**
+ * Static strings which identify all the {@link ProvenanceItem}s and
+ * {@link ProvenanceEventType}s
+ * 
+ * @author Paolo Missier
+ * @author Ian Dunlop
+ */
+public enum SharedVocabulary {
+	DATAFLOW_EVENT_TYPE, PROCESS_EVENT_TYPE, PROVENANCE_EVENT_TYPE, ACTIVITY_EVENT_TYPE, DATA_EVENT_TYPE, ERROR_EVENT_TYPE, INMEMORY_EVENT_TYPE, INPUTDATA_EVENT_TYPE, ITERATION_EVENT_TYPE, OUTPUTDATA_EVENT_TYPE, PROCESSOR_EVENT_TYPE, WEBSERVICE_EVENT_TYPE, WORKFLOW_DATA_EVENT_TYPE, WORKFLOW_EVENT_TYPE, END_WORKFLOW_EVENT_TYPE, INVOCATION_STARTED_EVENT_TYPE;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/utility/TreeModelAdapter.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/utility/TreeModelAdapter.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/utility/TreeModelAdapter.java
new file mode 100644
index 0000000..6b485f8
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/utility/TreeModelAdapter.java
@@ -0,0 +1,173 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.utility;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.swing.event.TreeModelEvent;
+import javax.swing.event.TreeModelListener;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+
+/**
+ * Wraps a typed tree model up in a standard tree model for use with JTree and
+ * friends.
+ * 
+ * @author Tom Oinn
+ */
+public final class TreeModelAdapter {
+	private static class TypedListenerPair<TT> {
+		TypedTreeModelListener<TT> typedListener;
+
+		TreeModelListener untypedListener;
+
+		TypedListenerPair(TypedTreeModelListener<TT> typedListener,
+				TreeModelListener untypedListener) {
+			this.typedListener = typedListener;
+			this.untypedListener = untypedListener;
+		}
+	}
+
+	private static Set<TypedListenerPair<Object>> mapping = new HashSet<>();
+
+	private static TreeModelAdapter instance = null;
+
+	private TreeModelAdapter() {
+		//
+	}
+
+	private synchronized static TreeModelAdapter getInstance() {
+		if (instance == null)
+			instance = new TreeModelAdapter();
+		return instance;
+	}
+
+	/**
+	 * Return an untyped TreeModel wrapper around the specified TypedTreeModel
+	 * 
+	 * @param <NodeType>
+	 *            the node type of the typed model being wrapped
+	 * @param typedModel
+	 *            typed model to wrap
+	 * @return a TreeModel acting as an untyped view of the typed tree model
+	 */
+	public static <NodeType extends Object> TreeModel untypedView(
+			TypedTreeModel<NodeType> typedModel) {
+		return getInstance().removeType(typedModel);
+	}
+
+	private <NodeType extends Object> TreeModel removeType(
+			final TypedTreeModel<NodeType> typedModel) {
+		return new TreeModel() {
+			@SuppressWarnings({ "rawtypes", "unchecked" })
+			@Override
+			public void addTreeModelListener(final TreeModelListener listener) {
+				TypedTreeModelListener<NodeType> typedListener = new TypedTreeModelListener<NodeType>() {
+					@Override
+					public void treeNodesChanged(TypedTreeModelEvent<NodeType> e) {
+						listener.treeNodesChanged(unwrapType(e));
+					}
+
+					@Override
+					public void treeNodesInserted(
+							TypedTreeModelEvent<NodeType> e) {
+						listener.treeNodesInserted(unwrapType(e));
+					}
+
+					@Override
+					public void treeNodesRemoved(TypedTreeModelEvent<NodeType> e) {
+						listener.treeNodesRemoved(unwrapType(e));
+					}
+
+					@Override
+					public void treeStructureChanged(
+							TypedTreeModelEvent<NodeType> e) {
+						listener.treeStructureChanged(unwrapType(e));
+					}
+
+					private TreeModelEvent unwrapType(
+							final TypedTreeModelEvent<NodeType> e) {
+						return new TreeModelEvent(e.getSource(),
+								e.getTreePath(), e.getChildIndices(),
+								e.getChildren());
+					}
+				};
+				synchronized (mapping) {
+					typedModel.addTreeModelListener(typedListener);
+					mapping.add(new TypedListenerPair(typedListener, listener));
+				}
+			}
+
+			@Override
+			@SuppressWarnings("unchecked")
+			public Object getChild(Object arg0, int arg1) {
+				return typedModel.getChild((NodeType) arg0, arg1);
+			}
+
+			@Override
+			@SuppressWarnings("unchecked")
+			public int getChildCount(Object arg0) {
+				return typedModel.getChildCount((NodeType) arg0);
+			}
+
+			@Override
+			@SuppressWarnings("unchecked")
+			public int getIndexOfChild(Object arg0, Object arg1) {
+				return typedModel.getIndexOfChild((NodeType) arg0,
+						(NodeType) arg1);
+			}
+
+			@Override
+			public Object getRoot() {
+				return typedModel.getRoot();
+			}
+
+			@Override
+			@SuppressWarnings("unchecked")
+			public boolean isLeaf(Object arg0) {
+				return typedModel.isLeaf((NodeType) arg0);
+			}
+
+			@Override
+			@SuppressWarnings("unchecked")
+			public void removeTreeModelListener(TreeModelListener arg0) {
+				synchronized (mapping) {
+					TypedListenerPair<NodeType> toRemove = null;
+					for (TypedListenerPair<Object> tpl : mapping)
+						if (tpl.untypedListener == arg0) {
+							toRemove = (TypedListenerPair<NodeType>) tpl;
+							typedModel
+									.removeTreeModelListener((TypedTreeModelListener<NodeType>) tpl.typedListener);
+							break;
+						}
+					if (toRemove == null)
+						return;
+					mapping.remove(toRemove);
+				}
+			}
+
+			@Override
+			public void valueForPathChanged(TreePath arg0, Object arg1) {
+				typedModel.valueForPathChanged(arg0, arg1);
+			}
+		};
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/utility/TypedTreeModel.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/utility/TypedTreeModel.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/utility/TypedTreeModel.java
new file mode 100644
index 0000000..9f65f57
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/utility/TypedTreeModel.java
@@ -0,0 +1,116 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.utility;
+
+import javax.swing.tree.TreePath;
+
+/**
+ * A replacement for TreeModel where nodes are typed rather than being generic
+ * objects. Because of the way interfaces and generics work this can't be
+ * related in any inheritance heirarchy to the actual javax.swing.TreeModel
+ * interface but is very similar (okay, identical) in operation. For cases where
+ * you want to use a normal TreeModel such as using this as the backing data
+ * model for a JTree you can use the TreeModelAdapter class to create an untyped
+ * view over the typed version defined here.
+ * 
+ * @author Tom Oinn
+ * 
+ * @see javax.swing.tree.TreeModel
+ * 
+ * @param <NodeType>
+ *            Each node in the tree is of this type
+ */
+public interface TypedTreeModel<NodeType> {
+	/**
+	 * Adds a listener for the TreeModelEvent posted after the tree changes.
+	 */
+	void addTreeModelListener(TypedTreeModelListener<NodeType> l);
+
+	/**
+	 * Returns the child of parent at index 'index' in the parent's child array.
+	 * 
+	 * @param parent
+	 *            parent instance of typed node type
+	 * @param index
+	 *            index within parent
+	 * @return child node at the specified index
+	 */
+	NodeType getChild(NodeType parent, int index);
+
+	/**
+	 * Returns the number of children of parent.
+	 * 
+	 * @param parent
+	 *            node to count children for
+	 * @return number of children
+	 */
+	int getChildCount(NodeType parent);
+
+	/**
+	 * Returns the index of child in parent.
+	 * 
+	 * @param parent
+	 *            a node in the tree, obtained from this data source
+	 * @param child
+	 *            the node we are interested in
+	 * @return the index of the child in the parent, or -1 if either child or
+	 *         parent are null
+	 */
+	int getIndexOfChild(NodeType parent, NodeType child);
+
+	/**
+	 * Returns the root of the tree. Returns null only if the tree has no nodes.
+	 * 
+	 * @return the root of the tree
+	 */
+	NodeType getRoot();
+
+	/**
+	 * Returns true if node is a leaf. It is possible for this method to return
+	 * false even if node has no children. A directory in a filesystem, for
+	 * example, may contain no files; the node representing the directory is not
+	 * a leaf, but it also has no children.
+	 * 
+	 * @param node
+	 *            a node in the tree, obtained from this data source
+	 * @return true if node is a leaf
+	 */
+	boolean isLeaf(NodeType node);
+
+	/**
+	 * Removes a listener previously added with addTreeModelListener.
+	 * 
+	 * @param l
+	 *            typed tree model listener to remove
+	 */
+	void removeTreeModelListener(TypedTreeModelListener<NodeType> l);
+
+	/**
+	 * Messaged when the user has altered the value for the item identified by
+	 * path to newValue. If newValue signifies a truly new value the model
+	 * should post a treeNodesChanged event.
+	 * 
+	 * @param path
+	 *            path to the node that the user has altered
+	 * @param newValue
+	 *            the new value from the TreeCellEditor
+	 */
+	void valueForPathChanged(TreePath path, Object newValue);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/utility/TypedTreeModelEvent.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/utility/TypedTreeModelEvent.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/utility/TypedTreeModelEvent.java
new file mode 100644
index 0000000..3bfb3d9
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/utility/TypedTreeModelEvent.java
@@ -0,0 +1,150 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.utility;
+
+import javax.swing.tree.TreePath;
+
+/**
+ * Type aware version of TreeModelEvent
+ * 
+ * @author Tom Oinn
+ * 
+ * @see javax.swing.tree.TreeModelEvent
+ * 
+ * @param <NodeType>
+ *            the node type parameter of the TypedTreeModel to which this event
+ *            applies
+ */
+public class TypedTreeModelEvent<NodeType> {
+	protected int[] childIndices;
+	protected NodeType[] children;
+	protected TreePath path;
+	protected Object source;
+
+	/**
+	 * Used to create an event when the node structure has changed in some way,
+	 * identifying the path to the root of a modified subtree as an array of
+	 * Objects.
+	 * 
+	 * @param source
+	 * @param path
+	 */
+	public TypedTreeModelEvent(Object source, NodeType[] path) {
+		this.path = new TreePath(path);
+		this.source = source;
+		this.childIndices = new int[0];
+	}
+
+	/**
+	 * Used to create an event when the node structure has changed in some way,
+	 * identifying the path to the root of the modified subtree as a TreePath
+	 * object.
+	 * 
+	 * @param source
+	 * @param path
+	 */
+	public TypedTreeModelEvent(Object source, TreePath path) {
+		this.path = path;
+		this.source = source;
+		this.childIndices = new int[0];
+	}
+
+	/**
+	 * Used to create an event when nodes have been changed, inserted, or
+	 * removed, identifying the path to the parent of the modified items as a
+	 * TreePath object.
+	 * 
+	 * @param source
+	 * @param path
+	 * @param childIndices
+	 * @param children
+	 */
+	public TypedTreeModelEvent(Object source, TreePath path,
+			int[] childIndices, NodeType[] children) {
+		this.source = source;
+		this.path = path;
+		this.childIndices = childIndices;
+		this.children = children;
+	}
+
+	/**
+	 * Used to create an event when nodes have been changed, inserted, or
+	 * removed, identifying the path to the parent of the modified items as an
+	 * array of Objects.
+	 * 
+	 * @param source
+	 * @param path
+	 * @param childIndices
+	 * @param children
+	 */
+	public TypedTreeModelEvent(Object source, NodeType[] path,
+			int[] childIndices, NodeType[] children) {
+		this.path = new TreePath(path);
+		this.source = source;
+		this.childIndices = childIndices;
+		this.children = children;
+	}
+
+	/**
+	 * Returns the values of the child indexes.
+	 * 
+	 * @return
+	 */
+	public int[] getChildIndices() {
+		return this.childIndices;
+	}
+
+	/**
+	 * Returns the objects that are children of the node identified by getPath
+	 * at the locations specified by getChildIndices.
+	 * 
+	 * @return
+	 */
+	public NodeType[] getChildren() {
+		return this.children;
+	}
+
+	/**
+	 * The object on which the Event initially occurred.
+	 * 
+	 * @return
+	 */
+	public Object getSource() {
+		return this.source;
+	}
+
+	/**
+	 * For all events, except treeStructureChanged, returns the parent of the
+	 * changed nodes.
+	 * 
+	 * @return
+	 */
+	public TreePath getTreePath() {
+		return path;
+	}
+
+	/**
+	 * Returns a string that displays and identifies this object's properties.
+	 */
+	@Override
+	public String toString() {
+		return "Typed TreeModelEvent " + super.toString();
+	}
+}


[42/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListService.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListService.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListService.java
deleted file mode 100644
index dae18af..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListService.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-import static org.springframework.transaction.annotation.Propagation.REQUIRED;
-import static org.springframework.transaction.annotation.Propagation.SUPPORTS;
-
-import java.util.List;
-
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * Provides facilities to register list of T2References, register empty lists at
- * any given depth and to resolve appropriate T2Reference instances back to
- * these lists. Registration operations assign names and lock the list contents
- * as a result. This service operates strictly on T2References, it neither tries
- * to nor is capable of any form of reference resolution, so aspects such as
- * collection traversal are not handled here (these are performed by the top
- * level reference service)
- * 
- * @author Tom Oinn
- */
-@Transactional(propagation = SUPPORTS, readOnly = true)
-public interface ListService {
-	/**
-	 * Register a new list of T2References. The depth of the list will be
-	 * calculated based on the depth of the references within it - if these are
-	 * not uniform the list won't be created (all children of a list in T2 must
-	 * have the same depth as their siblings). Provided this constraint is
-	 * satisfied the list is named and stored in the backing store. The returned
-	 * list is at this point immutable, operations modifying it either directly
-	 * or through the ListIterator will fail with an IllegalStateException.
-	 * Implementations should copy the input list rather than keeping a
-	 * reference to it to preserve this property.
-	 * <p>
-	 * The created references will be related with a workflow run id passed
-	 * through ReferenceContext so we can track all data referenced by a
-	 * specific run.
-	 * 
-	 * @param items
-	 *            the T2Reference instances to store as a list.
-	 * @return a new IdentifiedList of T2Reference instances allocated with a
-	 *         T2Reference itself as the unique name and cached by the backing
-	 *         store.
-	 * @throws ListServiceException
-	 *             if there is a problem either with the specified list of
-	 *             references or with the storage subsystem.
-	 */
-	@Transactional(propagation = REQUIRED, readOnly = false)
-	IdentifiedList<T2Reference> registerList(List<T2Reference> items,
-			ReferenceContext context) throws ListServiceException;
-
-	/**
-	 * Register a new empty list with the specified depth. This is needed
-	 * because in the case of empty lists we can't calculate the depth from the
-	 * list items (what with there not being any!), but the depth property is
-	 * critical for the T2 iteration and collection management system in the
-	 * enactor - we need to know that this is an empty list that
-	 * <em>would have</em> contained lists, for example.
-	 * <p>
-	 * The created references will be related with a workflow run id passed
-	 * through ReferenceContext so we can track all data referenced by a
-	 * specific run.
-	 * 
-	 * @param depth
-	 *            the depth of the empty list, must be >=1
-	 * @return a new empty IdentifiedList allocated with a T2Reference itself as
-	 *         the unique name and cached by the backing store.
-	 * @throws ListServiceException
-	 *             if there is a problem with the storage subsystem or if called
-	 *             with an invalid depth argument
-	 */
-	@Transactional(propagation = REQUIRED, readOnly = false)
-	IdentifiedList<T2Reference> registerEmptyList(int depth,
-			ReferenceContext context) throws ListServiceException;
-
-	/**
-	 * Retrieve a previously named and registered list of T2Reference instances
-	 * identified by the specified T2Reference (which must be of type
-	 * T2ReferenceType.IdentifiedList)
-	 * 
-	 * @param id
-	 *            identifier of the list of reference to retrieve
-	 * @return an IdentifiedList of T2References. Note that because this list is
-	 *         named it is effectively immutable, if you want to modify the list
-	 *         you have to create and register a new list, you cannot modify the
-	 *         returned value of this directly. This is why there is no update
-	 *         method in the service or dao for reference lists.
-	 * @throws ListServiceException
-	 *             if anything goes wrong with the retrieval process or if there
-	 *             is something wrong with the reference (such as it being of
-	 *             the wrong reference type).
-	 */
-	IdentifiedList<T2Reference> getList(T2Reference id)
-			throws ListServiceException;
-
-	/**
-	 * Functionality the same as {@link #getList(T2Reference) getList} but in
-	 * asynchronous mode, returning immediately and using the supplied callback
-	 * to communicate its results.
-	 * 
-	 * @param id
-	 *            a {@link T2Reference} identifying an {@link IdentifiedList} to
-	 *            retrieve
-	 * @param callback
-	 *            a {@link ListServiceCallback} used to convey the results of
-	 *            the asynchronous call
-	 * @throws ListServiceException
-	 *             if the reference set service is not correctly configured.
-	 *             Exceptions encountered when performing the asynchronous call
-	 *             are not returned here, for obvious reasons, and are instead
-	 *             messaged through the callback interface.
-	 */
-	void getListAsynch(T2Reference id, ListServiceCallback callback)
-			throws ListServiceException;
-
-	@Transactional(propagation = SUPPORTS, readOnly = false)
-	boolean delete(T2Reference reference) throws ReferenceServiceException;
-
-	/**
-	 * Delete all {@link IdentifiedList}S used by the specific workflow run.
-	 */
-	@Transactional(propagation = SUPPORTS, readOnly = false)
-	void deleteIdentifiedListsForWorkflowRun(String workflowRunId)
-			throws ReferenceServiceException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListServiceCallback.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListServiceCallback.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListServiceCallback.java
deleted file mode 100644
index 754caf6..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListServiceCallback.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * Callback interface used by asynchronous methods in the
- * {@link ListService} interface
- * 
- * @author Tom Oinn
- */
-public interface ListServiceCallback {
-	/**
-	 * Called when the requested {@link ReferenceSet} has been successfully
-	 * retrieved.
-	 * 
-	 * @param references
-	 *            the ReferenceSet requested
-	 */
-	void listRetrieved(IdentifiedList<T2Reference> references);
-
-	/**
-	 * Called if the retrieval failed for some reason
-	 * 
-	 * @param cause
-	 *            a ListServiceException explaining the retrieval
-	 *            failure
-	 */
-	void listRetrievalFailed(ListServiceException cause);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListServiceException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListServiceException.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListServiceException.java
deleted file mode 100644
index 01cdd82..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListServiceException.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * Thrown by methods in the ListService interface if anything goes wrong with
- * list registration or retrieval. Any underlying exceptions that can't be
- * handled in the service layer are wrapped in this and re-thrown.
- * 
- * @author Tom Oinn
- */
-public class ListServiceException extends RuntimeException {
-	private static final long serialVersionUID = 5049346991071587866L;
-
-	public ListServiceException() {
-		super();
-	}
-
-	public ListServiceException(String message) {
-		super(message);
-	}
-
-	public ListServiceException(Throwable cause) {
-		super(cause);
-	}
-
-	public ListServiceException(String message, Throwable cause) {
-		super(message, cause);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceContext.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceContext.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceContext.java
deleted file mode 100644
index 0ce2de3..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceContext.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-import java.util.List;
-
-/**
- * Many operations over the reference manager require access to an appropriate
- * context. The context contains hooks out to platform level facilities such as
- * the security agent framework (when used in conjunction with the enactor).
- * <p>
- * This interface is also used to pass in resources required by the external
- * reference translation and construction SPIs. An example might be a translator
- * from File to URL could work by copying the source file to a web share of some
- * kind, but obviously this can't happen unless properties such as the location
- * of the web share folder are known. These properties tend to be properties of
- * the installation rather than of the code, referring as they do to resources
- * on the machine hosting the reference manager (and elsewhere).
- * <p>
- * Where entities in the context represent properties of the platform rather
- * than the 'session' they are likely to be configured in a central location
- * such as a Spring context definition, this interface is neutral to those
- * concerns.
- * 
- * @author Tom Oinn
- */
-public interface ReferenceContext {
-	/**
-	 * Return a list of all entities in the resolution context which match the
-	 * supplied entity type argument.
-	 * 
-	 * @param <T>
-	 *            The generic type of the returned entity list. In general the
-	 *            compiler is smart enough that you don't need to specify this,
-	 *            it can pick it up from the entityType parameter.
-	 * @param entityType
-	 *            Class of entity to return. Use Object.class to return all
-	 *            entities within the reference context
-	 * @return a list of entities from the reference context which can be cast
-	 *         to the specified type.
-	 */
-	<T extends Object> List<T> getEntities(Class<T> entityType);
-
-	/**
-	 * Add an entity to the context.
-	 */
-	void addEntity(Object entity);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceService.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceService.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceService.java
deleted file mode 100644
index ed52ecd..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceService.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-import static org.springframework.transaction.annotation.Propagation.REQUIRED;
-import static org.springframework.transaction.annotation.Propagation.SUPPORTS;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * Top level access point to the reference manager for client code which is
- * aware of references and error documents. Provides methods to store and
- * retrieve instances of ReferenceSet, IdentifiedList&lt;T2Reference&gt; and
- * ErrorDocument. Acts as an integration layer for the three sub-component
- * service, providing in addition collection traversal and retrieval of lists of
- * identified entities (ReferenceSet, IdentifiedList&lt;Identified&gt; and
- * ErrorDocument) from a T2Reference identifying a list.
- * <p>
- * Also provides registration and retrieval logic for POJOs where supported by
- * appropriate plug-in instances, these methods can be used by code which is not
- * 'reference aware' to store and retrieve value types transparently.
- * <p>
- * Resolution of collections can happen at three different levels:
- * <ol>
- * <li>The embedded {@link ListService} resolves the collection ID to a list of
- * child IDs, and doesn't traverse these children if they are themselves lists.
- * Use the {@link #getListService()}.{@link ListService#getList(T2Reference)
- * getList()} to call this method directly on the list service if you need this
- * functionality, returning a list of {@link T2Reference}</li>
- * <li>The {@link #resolveIdentifier(T2Reference, Set, ReferenceContext)
- * resolveIdentifier} method in this service instead resolves to a fully
- * realized collection of the entities which those IDs reference, and does
- * recursively apply this to child lists, resulting in a nested collection
- * structure where the leaf nodes are ReferenceSet and ErrorDocument instances
- * and non-leaf are IdentifiedList of Identified (the super-interface for
- * IdentifiedList, ReferenceSet and ErrorDocument). Use this method if you want
- * to access the ExternalReferenceSPI and ErrorDocument entities directly
- * because your code can act on a particular reference type - in general in
- * these cases you would also be using the augmentation system to ensure that
- * the required reference type was actually present in the collection structure.
- * </li>
- * <li>The third level of resolution is to render the identifier through
- * {@link #renderIdentifier(T2Reference, Class, ReferenceContext)
- * renderIdentifier} to a nested structure as in
- * {@link #resolveIdentifier(T2Reference, Set, ReferenceContext)
- * resolveIdentifier} but where the structure consists of POJOs of the specified
- * type and lists or either list or the leaf type. This is used when your code
- * is reference agnostic and just requires the values in an easy to consume
- * fashion. Note that because this involves pulling the entire structure into
- * memory it may not be suitable for large data, use with caution. This method
- * will, unlike {@link #resolveIdentifier(T2Reference, Set, ReferenceContext)
- * resolveIdentifier}, fail if the reference contains or is an error.</li>
- * </ol>
- * 
- * @author Tom Oinn
- */
-public interface ReferenceService {
-	/**
-	 * Perform recursive identifier resolution, building a collection structure
-	 * of Identified objects, any collection elements being IdentifiedLists of
-	 * Identified subclasses. If the id has depth 0 this will just return the
-	 * Identified to which that id refers.
-	 * 
-	 * @param id
-	 *            the T2Reference to resolve
-	 * @param ensureTypes
-	 *            a set of ExternalReferenceSPI classes, this is used to augment
-	 *            any resolved ReferenceSet instances to ensure that each one
-	 *            has at least one of the specified types. If augmentation is
-	 *            not required this can be set to null.
-	 * @param context
-	 *            the ReferenceContext to use to resolve this and any
-	 *            recursively resolved identifiers <br/>
-	 *            If null the implementation should insert a new empty context
-	 *            and proceed.
-	 * @return fully resolved Identified subclass - this is either a (recursive)
-	 *         IdentifiedList of Identified, a ReferenceSet or an ErrorDocument
-	 * @throws ReferenceServiceException
-	 *             if any problems occur during resolution
-	 */
-	@Transactional(propagation = REQUIRED, readOnly = false)
-	Identified resolveIdentifier(T2Reference id,
-			Set<Class<ExternalReferenceSPI>> ensureTypes,
-			ReferenceContext context) throws ReferenceServiceException;
-
-	/**
-	 * As resolveIdentifier but using a callback object and returning
-	 * immediately
-	 * 
-	 * @throws ReferenceServiceException
-	 *             if anything goes wrong with the setup of the resolution job.
-	 *             Any exceptions during the resolution process itself are
-	 *             communicated through the callback object.
-	 */
-	@Transactional(propagation = REQUIRED, readOnly = false)
-	void resolveIdentifierAsynch(T2Reference id,
-			Set<Class<ExternalReferenceSPI>> ensureTypes,
-			ReferenceContext context,
-			ReferenceServiceResolutionCallback callback)
-			throws ReferenceServiceException;
-
-	/**
-	 * Resolve the given identifier, building a POJO structure where the
-	 * non-list items are of the desired class. This makes of any external
-	 * references that can directly expose the appropriate object type, then, if
-	 * none are present in a given reference set, it attempts to locate a POJO
-	 * builder and uses the cheapest available reference to get an InputStream
-	 * and build the target object. If no appropriate builder or embedded value
-	 * can be found the process throws ReferenceServiceException, it also does
-	 * this if any error occurs during retrieval of a (potentially nested)
-	 * identifier.
-	 * <p>
-	 * This method will return a collection structure mirroring that of the
-	 * specified T2Reference, client code should use T2Reference.getDepth() to
-	 * determine the depth of this structure; a reference with depth of 0 means
-	 * that the object returned is of the specified class, one of depth 1 is a
-	 * list of this class and so on.
-	 * <p>
-	 * If the T2Reference contains or is an error this method will not retrieve
-	 * it, and instead throws ReferenceServiceException
-	 * 
-	 * @see StreamToValueConverterSPI
-	 * @see ValueCarryingExternalReference
-	 * @param id
-	 *            the T2Reference to render to a POJO
-	 * @param leafClass
-	 *            the java class for leaves in the resulting POJO structure
-	 * @param context
-	 *            a reference context, potentially used if required by the
-	 *            openStream methods of ExternalReferenceSPI implementations
-	 *            used as sources for the POJO construction <br/>
-	 *            If null the implementation should insert a new empty context
-	 *            and proceed.
-	 * @return a java structure as defined above
-	 * @throws ReferenceServiceException
-	 *             if anything fails during this process
-	 */
-	Object renderIdentifier(T2Reference id, Class<?> leafClass,
-			ReferenceContext context) throws ReferenceServiceException;
-
-	/**
-	 * The top level registration method is used to register either as yet
-	 * unregistered ErrorDocuments and ReferenceSets (if these are passed in and
-	 * already have an identifier this call does nothing) and arbitrarily nested
-	 * Lists of the same. In addition any ExternalReferenceSPI instances found
-	 * will be wrapped in a single item ReferenceSet and registered, and any
-	 * Throwables will be wrapped in an ErrorDocument and registered. Lists will
-	 * be converted to IdentifiedList&lt;T2Reference&gt; and registered if all
-	 * children can be (or were already) appropriately named.
-	 * <p>
-	 * This method is only valid on parameters of the following type :
-	 * <ol>
-	 * <li>{@link T2Reference} - returned immediately as itself, this is needed
-	 * because it means we can register lists of existing T2Reference</li>
-	 * <li>{@link ReferenceSet} - registered if not already registered,
-	 * otherwise returns existing T2Reference</li>
-	 * <li>{@link ErrorDocument} - same behaviour as ReferenceSet</li>
-	 * <li>{@link ExternalReferenceSPI} - wrapped in ReferenceSet, registered
-	 * and ID returned</li>
-	 * <li>Throwable - wrapped in {@link ErrorDocument} with no message,
-	 * registered and ID returned</li>
-	 * <li>List - all children are first registered, if this succeeds the list
-	 * is itself registered as an {@link IdentifiedList} of {@link T2Reference}
-	 * and its reference returned.</li>
-	 * </ol>
-	 * The exception to this is if the useConvertorSPI parameter is set to true
-	 * - in this case any objects which do not match the above allowed list will
-	 * be run through any available ValueToReferenceConvertorSPI instances in
-	 * turn until one succeeds or all fail, which may result in the creation of
-	 * ExternalReferenceSPI instances. As these can be registered such objects
-	 * will not cause an exception to be thrown.
-	 * 
-	 * @see ValueToReferenceConverterSPI
-	 * @param o
-	 *            the object to register with the reference system, must comply
-	 *            with and will be interpreted as shown in the type list above.
-	 * @param targetDepth
-	 *            the depth of the top level object supplied. This is needed
-	 *            when registering empty collections and error documents,
-	 *            whether as top level types or as members of a collection
-	 *            within the top level type. If registering a collection this is
-	 *            the collection depth, so a List of ReferenceSchemeSPI would be
-	 *            depth 1. Failing to specify this correctly will result in
-	 *            serious problems downstream so be careful! We can't catch all
-	 *            potential problems in this method (although some errors will
-	 *            be trapped).
-	 * @param useConverterSPI
-	 *            whether to attempt to use the ValueToReferenceConvertorSPI
-	 *            registry (if defined and available) to map arbitrary objects
-	 *            to ExternalReferenceSPI instances on the fly. The registry of
-	 *            converters is generally injected into the implementation of
-	 *            this service.
-	 * @param context
-	 *            ReferenceContext to use if required by component services,
-	 *            this is most likely to be used by the object to reference
-	 *            converters if engaged. <br/>
-	 *            If null the implementation should insert a new empty context
-	 *            and proceed.
-	 * @return a T2Reference to the registered object
-	 * @throws ReferenceServiceException
-	 *             if the object type (or, for collections, the recursive type
-	 *             of its contents) is not in the allowed list or if a problem
-	 *             occurs during registration. Also thrown if attempting to use
-	 *             the converter SPI without an attached registry.
-	 */
-	@Transactional(propagation = REQUIRED, readOnly = false)
-	T2Reference register(Object o, int targetDepth, boolean useConverterSPI,
-			ReferenceContext context) throws ReferenceServiceException;
-
-	/**
-	 * Given a string representation of a T2Reference create a new T2Reference
-	 * with the correct depth etc.
-	 * 
-	 * @param reference
-	 * @return a new T2Reference parsed from the original
-	 */
-	T2Reference referenceFromString(String reference);
-
-	@Transactional(propagation = SUPPORTS, readOnly = false)
-	boolean delete(T2Reference reference) throws ReferenceServiceException;
-
-	@Transactional(propagation = SUPPORTS, readOnly = false)
-	boolean delete(List<T2Reference> references)
-			throws ReferenceServiceException;
-
-	@Transactional(propagation = SUPPORTS, readOnly = false)
-	void deleteReferencesForWorkflowRun(String workflowRunId)
-			throws ReferenceServiceException;
-
-	/**
-	 * Returns the {@link ErrorDocumentService} this ReferenceService uses, use
-	 * this when you need functionality from that service explicitly.
-	 */
-	ErrorDocumentService getErrorDocumentService();
-
-	/**
-	 * Returns the {@link ReferenceSetService} this ReferenceService uses, use
-	 * this when you need functionality from that service explicitly.
-	 */
-	ReferenceSetService getReferenceSetService();
-
-	/**
-	 * Returns the {@link ListService} this ReferenceService uses, use this when
-	 * you need functionality from that service explicitly.
-	 */
-	ListService getListService();
-
-	/**
-	 * Initiates a traversal of the specified t2reference, traversing to
-	 * whatever level of depth is required such that all identifiers returned
-	 * within the iterator have the specified depth. The context (i.e. the index
-	 * path from the originally specified reference to each reference within the
-	 * iteration) is included through use of the ContextualizedT2Reference
-	 * wrapper class
-	 * 
-	 * @param source
-	 *            the T2Reference from which to traverse. In general this is the
-	 *            root of a collection structure.
-	 * @param desiredDepth
-	 *            the desired depth of all returned T2References, must be less
-	 *            than or equal to that of the source reference.
-	 * @throws ReferenceServiceException
-	 *             if unable to create the iterator for some reason. Note that
-	 *             implementations are free to lazily perform the iteration so
-	 *             this method may succeed but the iterator produced can fail
-	 *             when used. If the iterator fails it will do so by throwing
-	 *             one of the underlying sub-service exceptions.
-	 */
-	@Transactional(propagation = SUPPORTS, readOnly = true)
-	Iterator<ContextualizedT2Reference> traverseFrom(T2Reference source,
-			int desiredDepth);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceServiceCacheProvider.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceServiceCacheProvider.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceServiceCacheProvider.java
deleted file mode 100644
index 56ebe4d..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceServiceCacheProvider.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * A simple interface to be implemented by data access object cache providers,
- * intended to be used to inject cache implementations through AoP
- * 
- * @author Tom Oinn
- */
-public interface ReferenceServiceCacheProvider {
-	/**
-	 * Called after an {@link Identified} has been written to the backing store,
-	 * either for the first time or after modification. In our model
-	 * {@link ReferenceSet} is the only {@link Identified} that is modifiable,
-	 * specifically only by the addition of {@link ExternalReferenceSPI}
-	 * instances to its reference set.
-	 * 
-	 * @param i
-	 *            the Identified written to the backing store
-	 */
-	void put(Identified i);
-
-	/**
-	 * Called before an attempt is made to retrieve an item from the backing
-	 * store
-	 * 
-	 * @param id
-	 *            the T2Reference of the item to retrieve
-	 * @return a cached item with matching {@link T2Reference}, or <tt>null</tt>
-	 *         if the cache does not contain that item
-	 */
-	Identified get(T2Reference id);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceServiceException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceServiceException.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceServiceException.java
deleted file mode 100644
index 25e1765..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceServiceException.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * Thrown by methods in the ReferenceService, used to wrap any underlying
- * exceptions from lower layers.
- * 
- * @author Tom Oinn
- */
-public class ReferenceServiceException extends RuntimeException {
-	private static final long serialVersionUID = -2607675495513408333L;
-
-	public ReferenceServiceException() {
-		//
-	}
-
-	public ReferenceServiceException(String message) {
-		super(message);
-	}
-
-	public ReferenceServiceException(Throwable cause) {
-		super(cause);
-	}
-
-	public ReferenceServiceException(String message, Throwable cause) {
-		super(message, cause);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceServiceResolutionCallback.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceServiceResolutionCallback.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceServiceResolutionCallback.java
deleted file mode 100644
index 3b67da0..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceServiceResolutionCallback.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * Used by the asynchronous form of the resolveIdentifier method in
- * {@link ReferenceService}
- * 
- * @author Tom Oinn
- */
-public interface ReferenceServiceResolutionCallback {
-	/**
-	 * Called when the resolution process has completed
-	 * 
-	 * @param result
-	 *            the Identified that corresponds to the {@link T2Reference}
-	 *            specified in the call to
-	 *            {@link ReferenceService#resolveIdentifierAsynch}
-	 */
-	void identifierResolved(Identified result);
-
-	/**
-	 * Called when the resolution process has failed
-	 * 
-	 * @param cause
-	 *            a ReferenceServiceException describing the failure
-	 */
-	void resolutionFailed(ReferenceServiceException cause);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSet.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSet.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSet.java
deleted file mode 100644
index 5c82cee..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSet.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-import java.util.Set;
-
-/**
- * A set of ExternalReferenceSPI instances, all of which point to the same (byte
- * equivalent) data. The set is identified by a T2Reference. This interface is
- * read-only, as are most of the interfaces in this package. Rather than
- * modifying properties of the reference set directly the client code should use
- * the reference manager functionality.
- * <p>
- * It is technically okay, but rather unhelpful, to have a ReferenceSet with no
- * ExternalReferenceSPI implementations. In general this is a sign that
- * something has gone wrong somewhere as the reference set will not be
- * resolvable in any way, but it would still retain its unique identifier so
- * there may be occasions where this is the desired behaviour.
- * 
- * @author Tom Oinn
- */
-public interface ReferenceSet extends Identified {
-	/**
-	 * The reference set contains a set of ExternalReferenceSPI instances, all
-	 * of which point to byte equivalent data.
-	 * 
-	 * @return the set of references to external data
-	 */
-	Set<ExternalReferenceSPI> getExternalReferences();
-
-	/**
-	 * Get approximate size of the data pointed to by this ReferenceSet.
-	 */
-	Long getApproximateSizeInBytes();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetAugmentationException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetAugmentationException.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetAugmentationException.java
deleted file mode 100644
index 1922baa..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetAugmentationException.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * Thrown when the reference set augmentor is unable to provide at least one of
- * the desired types for any reason.
- * 
- * @author Tom Oinn
- */
-public class ReferenceSetAugmentationException extends RuntimeException {
-	private static final long serialVersionUID = -6156508424485682266L;
-
-	public ReferenceSetAugmentationException() {
-		//
-	}
-
-	public ReferenceSetAugmentationException(String message) {
-		super(message);
-	}
-
-	public ReferenceSetAugmentationException(Throwable cause) {
-		super(cause);
-	}
-
-	public ReferenceSetAugmentationException(String message, Throwable cause) {
-		super(message, cause);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetAugmentor.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetAugmentor.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetAugmentor.java
deleted file mode 100644
index 1dd2f92..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetAugmentor.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-import java.util.Set;
-
-/**
- * Provides a framework to find and engage appropriate instances of
- * {@link ExternalReferenceTranslatorSPI} and
- * {@link ExternalReferenceBuilderSPI} to build external references from,
- * respectively, other external references and from streams. These are then used
- * to augment the contents of implementations of {@link ReferenceSet} with
- * additional {@link ExternalReferenceSPI} implementations.
- * <p>
- * Methods in this interface throw the runtime exception
- * {@link ReferenceSetAugmentationException} for all problems, other exceptions
- * are wrapped in this type and re-thrown.
- * 
- * @author Tom Oinn
- */
-public interface ReferenceSetAugmentor {
-	/**
-	 * Attempts to modify the supplied ReferenceSet such that it contains an
-	 * implementation of at least one of the ExternalReferenceSPI classes
-	 * specified. Uses the supplied context if required to build or translate
-	 * existing references within the reference set.
-	 * 
-	 * @param references
-	 *            reference set object to augment
-	 * @param targetReferenceTypes
-	 *            a set of Class objects, this method succeeds if it can create
-	 *            an instance of at least one of these pointing to the same data
-	 *            as the other external references in the supplied reference set
-	 * @param context
-	 *            a reference resolution context, potentially required for
-	 *            access to the existing references or for creation of the
-	 *            augmentations
-	 * @return a set of new ExternalReferenceSPI instances such that the union
-	 *         of this set with the pre-existing reference set satisfies the
-	 *         target reference constraint. It is the responsibility of the
-	 *         caller to re-integrate these references into the original
-	 *         ReferenceSet if so desired.
-	 * @throws ReferenceSetAugmentationException
-	 *             if a problem occurs either in configuration of the
-	 *             ReferenceSetAugmentor or in the augmentation process itself.
-	 *             Any other exception types are wrapped in this and re-thrown.
-	 */
-	Set<ExternalReferenceSPI> augmentReferenceSet(ReferenceSet references,
-			Set<Class<ExternalReferenceSPI>> targetReferenceTypes,
-			ReferenceContext context) throws ReferenceSetAugmentationException;
-
-	/**
-	 * As with {@link #augmentReferenceSet(ReferenceSet, Set, ReferenceContext)}
-	 * but called in an asynchronous fashion. Returns immediately and uses the
-	 * supplied instance of {@link ReferenceSetAugmentorCallback} to provide
-	 * either the augmented {@link ReferenceSet} or an exception indicating a
-	 * failure in the augmentation process.
-	 * 
-	 * @param callback
-	 *            callback object used to indicate failure or to return the
-	 *            modified reference set
-	 * @throws ReferenceSetAugmentationException
-	 *             if the ReferenceSetAugmentor is missing critical
-	 *             configuration. Exceptions that happen during augmentation or
-	 *             as a result of a failure to find an appropriate augmentation
-	 *             path are signalled by calls to the callback object, this
-	 *             method only throws the exception if it can't even try to do
-	 *             the augmentation for some reason.
-	 */
-	void augmentReferenceSetAsynch(ReferenceSet references,
-			Set<Class<ExternalReferenceSPI>> targetReferenceTypes,
-			ReferenceContext context, ReferenceSetAugmentorCallback callback)
-			throws ReferenceSetAugmentationException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetAugmentorCallback.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetAugmentorCallback.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetAugmentorCallback.java
deleted file mode 100644
index 8d03b45..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetAugmentorCallback.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-import java.util.Set;
-
-/**
- * Callback interface used when augmenting a ReferenceSet in an asynchronous
- * fashion through
- * {@link ReferenceSetAugmentor#augmentReferenceSetAsynch(ReferenceSet, Set, ReferenceContext, ReferenceSetAugmentorCallback)
- * augmentReferenceSetAsynch} in {@link ReferenceSetAugmentor}.
- * 
- * @author Tom Oinn
- */
-public interface ReferenceSetAugmentorCallback {
-	/**
-	 * Called when the augmentation has succeeded
-	 * 
-	 * @param newReferences
-	 *            a set of ExternalReferenceSPI instances created during the
-	 *            augmentation process. It is the responsibility of the caller
-	 *            to re-integrate these back into the ReferenceSet used in the
-	 *            translation
-	 */
-	void augmentationCompleted(Set<ExternalReferenceSPI> newReferences);
-
-	/**
-	 * Called when the augmentation has failed for some reason
-	 * 
-	 * @param cause
-	 *            a {@link ReferenceSetAugmentationException} object describing
-	 *            the failure.
-	 */
-	void augmentationFailed(ReferenceSetAugmentationException cause);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetDao.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetDao.java
deleted file mode 100644
index 3c60e89..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetDao.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-import static org.springframework.transaction.annotation.Propagation.REQUIRED;
-import static org.springframework.transaction.annotation.Propagation.SUPPORTS;
-
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * Data Access Object interface for {@link ReferenceSet}. Used by the
- * {@link ReferenceSetService} to store and retrieve implementations of
- * reference set to and from the database. Client code should use the reference
- * set service rather than using this Dao directly.
- * <p>
- * All methods throw DaoException, and nothing else. Where a deeper error is
- * propagated it is wrapped in a DaoException and passed on to the caller.
- * 
- * @author Tom Oinn
- */
-public interface ReferenceSetDao {
-	/**
-	 * Store the specified new reference set
-	 * 
-	 * @param rs
-	 *            a reference set, must not already exist in the database.
-	 * @throws DaoException
-	 *             if the entry already exists in the database or some other
-	 *             database related problem occurs
-	 */
-	@Transactional(propagation = REQUIRED, readOnly = false)
-	void store(ReferenceSet rs) throws DaoException;
-
-	/**
-	 * Update a pre-existing entry in the database
-	 * 
-	 * @param rs
-	 *            the reference set to update. This must already exist in the
-	 *            database
-	 * @throws DaoException
-	 */
-	@Transactional(propagation = REQUIRED, readOnly = false)
-	void update(ReferenceSet rs) throws DaoException;
-
-	/**
-	 * Fetch a reference set by id
-	 * 
-	 * @param ref
-	 *            the T2Reference to fetch
-	 * @return a retrieved ReferenceSet
-	 * @throws DaoException
-	 *             if the supplied reference is of the wrong type or if
-	 *             something goes wrong fetching the data or connecting to the
-	 *             database
-	 */
-	@Transactional(propagation = SUPPORTS, readOnly = true)
-	ReferenceSet get(T2Reference ref) throws DaoException;
-
-	@Transactional(propagation = SUPPORTS, readOnly = false)
-	boolean delete(ReferenceSet rs) throws DaoException;
-
-	@Transactional(propagation = SUPPORTS, readOnly = false)
-	void deleteReferenceSetsForWFRun(String workflowRunId) throws DaoException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetService.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetService.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetService.java
deleted file mode 100644
index a574264..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetService.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-import static org.springframework.transaction.annotation.Propagation.REQUIRED;
-import static org.springframework.transaction.annotation.Propagation.SUPPORTS;
-
-import java.util.Set;
-
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * Provides facilities to register sets of ExternalReferenceSPI implementations
- * within the reference manager and to retrieve these sets by T2Reference either
- * as stored or with translation support. In general applications should be
- * using this interface (where only ReferenceSet functionality is required) or
- * the support classes which in turn use this and the collection and error
- * handling interfaces to present a unified view over the various components of
- * the reference management system.
- * 
- * @author Tom Oinn
- */
-@Transactional(propagation = SUPPORTS, readOnly = true)
-public interface ReferenceSetService {
-	/**
-	 * Register a set of {@link ExternalReferenceSPI} instances, all of which
-	 * should point to byte equivalent data, and return the newly created
-	 * {@link ReferenceSet}. This method blocks on the underlying store, but
-	 * guarantees that the returned value has been persisted.
-	 * <p>
-	 * The created references will be related with a workflow run id passed
-	 * through ReferenceContext so we can track all data referenced by a
-	 * specific run.
-	 * 
-	 * @param references
-	 *            a set of {@link ExternalReferenceSPI} implementations to
-	 *            register as a {@link ReferenceSet}
-	 * @return the registered {@link ReferenceSet}
-	 */
-	@Transactional(propagation = REQUIRED, readOnly = false)
-	ReferenceSet registerReferenceSet(Set<ExternalReferenceSPI> references,
-			ReferenceContext context) throws ReferenceSetServiceException;
-
-	/**
-	 * Get a previously registered {@link ReferenceSet} by {@link T2Reference}.
-	 * Note that this method blocks and may take some time to return in the case
-	 * of distributed reference managers; if this is likely to be an issue then
-	 * you should use the asynchronous form
-	 * {@link #getReferenceSetAsynch(T2Reference, ReferenceSetServiceCallback)
-	 * getReferenceSetAsynch} instead of this method.
-	 * 
-	 * @param id
-	 *            a {@link T2Reference} identifying a {@link ReferenceSet} to
-	 *            retrieve
-	 * @return the requested {@link ReferenceSet}
-	 */
-	ReferenceSet getReferenceSet(T2Reference id)
-			throws ReferenceSetServiceException;
-
-	/**
-	 * Functionality the same as {@link #getReferenceSet(T2Reference)
-	 * getReferenceSet} but in asynchronous mode, returning immediately and
-	 * using the supplied callback to communicate its results.
-	 * 
-	 * @param id
-	 *            a {@link T2Reference} identifying a {@link ReferenceSet} to
-	 *            retrieve
-	 * @param callback
-	 *            a {@link ReferenceSetServiceCallback} used to convey the
-	 *            results of the asynchronous call
-	 * @throws ReferenceSetServiceException
-	 *             if the reference set service is not correctly configured.
-	 *             Exceptions encountered when performing the asynchronous call
-	 *             are not returned here, for obvious reasons, and are instead
-	 *             messaged through the callback interface.
-	 */
-	void getReferenceSetAsynch(T2Reference id,
-			ReferenceSetServiceCallback callback)
-			throws ReferenceSetServiceException;
-
-	/**
-	 * Functionality the same as {@link #getReferenceSet(T2Reference)
-	 * getReferenceSet} but with the additional option to specify a set of
-	 * {@link ExternalReferenceSPI} classes. The reference set manager will
-	 * attempt to ensure that the returned {@link ReferenceSet} contains an
-	 * instance of at least one of the specified classes. This method blocks,
-	 * and may potentially incur both the remote lookup overhead of the simpler
-	 * version of this call and any translation logic. It is <em>strongly</em>
-	 * recommended that you do not use this version of the call and instead use
-	 * the asynchronous form
-	 * {@link #getReferenceSetWithAugmentationAsynch(T2Reference, Set, ReferenceContext, ReferenceSetServiceCallback)
-	 * getReferenceSetWithAugmentationAsynch} instead.
-	 * <p>
-	 * If the translation logic cannot provide at least one of the required
-	 * types this call will fail, even if the {@link ReferenceSet} requested is
-	 * otherwise available.
-	 * 
-	 * @param id
-	 *            a {@link T2Reference} identifying a {@link ReferenceSet} to
-	 *            retrieve
-	 * @param ensureTypes
-	 *            a set of {@link ExternalReferenceSPI} classes. The framework
-	 *            will attempt to ensure there is an instance of at least one of
-	 *            these classes in the returned {@link ReferenceSet}
-	 * @param context
-	 *            if translation of references is required the translation
-	 *            infrastructure will need information in this
-	 *            {@link ReferenceContext} parameter.
-	 *            <p>
-	 *            If null the implementation should insert a new empty context
-	 *            and proceed.
-	 * @return the requested {@link ReferenceSet}
-	 */
-	@Transactional(propagation = REQUIRED, readOnly = false)
-	ReferenceSet getReferenceSetWithAugmentation(T2Reference id,
-			Set<Class<ExternalReferenceSPI>> ensureTypes,
-			ReferenceContext context) throws ReferenceSetServiceException;
-
-	/**
-	 * Functionality as
-	 * {@link #getReferenceSetWithAugmentation(T2Reference, Set, ReferenceContext)
-	 * getReferenceSetWithAugmentation} but with the addition of a callback
-	 * interface to report the result or failure of the method.
-	 * 
-	 * @param id
-	 *            a {@link T2Reference} identifying a {@link ReferenceSet} to
-	 *            retrieve
-	 * @param ensureTypes
-	 *            a set of {@link ExternalReferenceSPI} classes. The framework
-	 *            will attempt to ensure there is an instance of at least one of
-	 *            these classes in the returned {@link ReferenceSet}
-	 * @param context
-	 *            if translation of references is required the translation
-	 *            infrastructure will need information in this
-	 *            {@link ReferenceContext} parameter.
-	 *            <p>
-	 *            If null the implementation should insert a new empty context
-	 *            and proceed.
-	 * @param callback
-	 *            a {@link ReferenceSetServiceCallback} used to convey the
-	 *            results of the asynchronous call *
-	 * @throws ReferenceSetServiceException
-	 *             if the reference set service is not correctly configured.
-	 *             Exceptions encountered when performing the asynchronous call
-	 *             are not returned here, for obvious reasons, and are instead
-	 *             messaged through the callback interface.
-	 */
-	@Transactional(propagation = REQUIRED, readOnly = false)
-	void getReferenceSetWithAugmentationAsynch(T2Reference id,
-			Set<Class<ExternalReferenceSPI>> ensureTypes,
-			ReferenceContext context, ReferenceSetServiceCallback callback)
-			throws ReferenceSetServiceException;
-
-	@Transactional(propagation = SUPPORTS, readOnly = false)
-	boolean delete(T2Reference reference) throws ReferenceServiceException;
-
-	/**
-	 * Delete all {@link ReferenceSet}S used by the specific workflow run.
-	 */
-	@Transactional(propagation = SUPPORTS, readOnly = false)
-	void deleteReferenceSetsForWorkflowRun(String workflowRunId)
-			throws ReferenceServiceException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetServiceCallback.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetServiceCallback.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetServiceCallback.java
deleted file mode 100644
index a75eb1f..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetServiceCallback.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * Callback interface used by asynchronous methods in the
- * {@link ReferenceSetService} interface
- * 
- * @author Tom Oinn
- */
-public interface ReferenceSetServiceCallback {
-	/**
-	 * Called when the requested {@link ReferenceSet} has been successfully
-	 * retrieved.
-	 * 
-	 * @param references
-	 *            the ReferenceSet requested
-	 */
-	void referenceSetRetrieved(ReferenceSet references);
-
-	/**
-	 * Called if the retrieval failed for some reason
-	 * 
-	 * @param cause
-	 *            a ReferenceSetServiceException explaining the retrieval
-	 *            failure
-	 */
-	void referenceSetRetrievalFailed(ReferenceSetServiceException cause);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetServiceException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetServiceException.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetServiceException.java
deleted file mode 100644
index 7e8c507..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceSetServiceException.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * RuntimeException subclass thrown by the reference set service layer
- * interfaces. All underlying exceptions are either handled by the service layer
- * or wrapped in this exception (or a subclass) and rethrown.
- * 
- * @author Tom Oinn
- */
-public class ReferenceSetServiceException extends RuntimeException {
-	private static final long serialVersionUID = -2762995062729638168L;
-
-	public ReferenceSetServiceException() {
-		//
-	}
-
-	public ReferenceSetServiceException(String message) {
-		super(message);
-	}
-
-	public ReferenceSetServiceException(Throwable cause) {
-		super(cause);
-	}
-
-	public ReferenceSetServiceException(String message, Throwable cause) {
-		super(message, cause);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferencedDataNature.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferencedDataNature.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferencedDataNature.java
deleted file mode 100644
index a6861f1..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferencedDataNature.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * Where possible ExternalReferenceSPI implementations should be able to
- * determine whether the data they refer to is textual or binary in nature. This
- * enumeration contains values for textual, binary and unknown data natures.
- * 
- * @author Tom Oinn
- */
-public enum ReferencedDataNature {
-	/**
-	 * The data is binary, no character encoding will be specified.
-	 */
-	BINARY,
-
-	/**
-	 * The data is textual, character encoding may be defined.
-	 */
-	TEXT,
-
-	/**
-	 * Unknown data nature.
-	 */
-	UNKNOWN;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/StackTraceElementBean.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/StackTraceElementBean.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/StackTraceElementBean.java
deleted file mode 100644
index 8b560b1..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/StackTraceElementBean.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * Used by the {@link ErrorDocument} interface to represent a frame within a
- * stack trace
- * 
- * @author Tom Oinn
- * @see StackTraceElement
- */
-public interface StackTraceElementBean {
-	/**
-	 * Returns the fully qualified name of the class containing the execution
-	 * point represented by this stack trace element.
-	 */
-	String getClassName();
-
-	/**
-	 * Returns the name of the source file containing the execution point
-	 * represented by this stack trace element.
-	 */
-	String getFileName();
-
-	/**
-	 * Returns the line number of the source line containing the execution point
-	 * represented by this stack trace element.
-	 */
-	int getLineNumber();
-
-	/**
-	 * Returns the name of the method containing the execution point represented
-	 * by this stack trace element.
-	 */
-	String getMethodName();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/StreamToValueConverterSPI.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/StreamToValueConverterSPI.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/StreamToValueConverterSPI.java
deleted file mode 100644
index dc3da5c..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/StreamToValueConverterSPI.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-import java.io.InputStream;
-
-/**
- * SPI for objects that can render a POJO from an InputStream
- * 
- * @author Tom Oinn
- */
-public interface StreamToValueConverterSPI<T> {
-	/**
-	 * The class of objects which this builder can construct from a stream
-	 */
-	Class<T> getPojoClass();
-
-	/**
-	 * Render the stream to the target object type
-	 * 
-	 * @param stream
-	 *            input stream of data to render to the object; the caller will
-	 *            close it
-	 * @param charset
-	 * @param dataNature
-	 * @return the newly created object
-	 */
-	T renderFrom(InputStream stream, ReferencedDataNature dataNature,
-			String charset);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/T2Reference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/T2Reference.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/T2Reference.java
deleted file mode 100644
index 4a9a725..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/T2Reference.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-import java.net.URI;
-
-/**
- * The T2Reference is used within the workflow system to refer to any entity
- * within the reference management system, whether reference set, list or error
- * document. The reference carries certain properties which can be evaluated
- * without resolution, these include a depth property and whether the reference
- * either is or contains an error document at any point in its structure.
- * 
- * @author Tom Oinn
- */
-public interface T2Reference {
-	/**
-	 * To determine the entity that this reference points to we use an
-	 * enumeration of possible entity types
-	 * 
-	 * @return the type of entity to which this reference refers.
-	 */
-	T2ReferenceType getReferenceType();
-
-	/**
-	 * All entities identified by a T2Reference have a conceptual depth. In the
-	 * case of lists the depth is the (uniform) depth of any item in the list
-	 * plus one, in the case of reference sets the depth is 0. Error documents
-	 * and empty lists may also have non zero depth; error documents in
-	 * particular have a depth corresponding to the depth of the list or
-	 * reference set that would have been created if there was no error.
-	 * 
-	 * @return the depth of the entity identified by this T2Reference
-	 */
-	int getDepth();
-
-	/**
-	 * Error documents always return true, as do any lists where at least one
-	 * immediate child of the list returns true when this property is evaluated.
-	 * As lists are immutable this property is actually set on list
-	 * registration. This is used to determine whether to allow POJO resolution
-	 * of the entity identified by this T2Reference - this is configurable by
-	 * the caller but there will be some cases where an attempt to render a
-	 * collection containing errors to a POJO should return an error and other
-	 * occasions when it should return a collection containing error objects.
-	 * <p>
-	 * ReferenceSet implementations always return false.
-	 * 
-	 * @return whether the entity identified by this T2Reference either is or
-	 *         contains an error document. Containment is transitive, so a list
-	 *         containing a list that contained an error would return true.
-	 */
-	boolean containsErrors();
-
-	/**
-	 * T2Reference instances retain a reference to the reference manager which
-	 * created them in the form of a namespace. This is an opaque string
-	 * matching the regular expression [a-zA-Z_0-9]+, and is immutable once
-	 * assigned (as are the other properties of this interface). The reference
-	 * manager infrastructure uses this namespace property primarily to
-	 * differentiate between cases where a reference cannot be resolved because
-	 * of a lack of connection to the appropriate remote reference manager and
-	 * those where the reference simply does not exist anywhere.
-	 * 
-	 * @return the namespace of this T2Reference as a string.
-	 */
-	String getNamespacePart();
-
-	/**
-	 * In addition to the namespace the T2Reference contains a local identifier.
-	 * This identifier is unique in the context of the namespace and is also
-	 * represented as a string matching the regular expression [a-z_A-Z0-9]+
-	 * 
-	 * @return the local part of this T2Reference as a string.
-	 */
-	String getLocalPart();
-
-	/**
-	 * All T2Reference instances can be represented as a URI.
-	 * 
-	 * @return representation of this T2Reference as a URI
-	 */
-	URI toUri();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/T2ReferenceGenerator.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/T2ReferenceGenerator.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/T2ReferenceGenerator.java
deleted file mode 100644
index dfaca7a..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/T2ReferenceGenerator.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * Provides new unique T2Reference instances. Used by and injected into the
- * various service interface implementations when registering new reference
- * sets, error documents and lists.
- * 
- * @author Tom Oinn
- * @see T2Reference
- */
-public interface T2ReferenceGenerator {
-	/**
-	 * All T2Reference objects will have this namespace
-	 * 
-	 * @return the namespace as a string
-	 */
-	String getNamespace();
-
-	/**
-	 * Create a new and otherwise unused T2Reference to a ReferenceSet. The
-	 * namespace of the reference will depend on the current workflow run read
-	 * from the ReferenceContext.
-	 * 
-	 * @return new T2Reference for a ReferenceSet, namespace and local parts
-	 *         will be initialized and the reference is ready to use when
-	 *         returned.
-	 */
-	T2Reference nextReferenceSetReference(ReferenceContext context);
-
-	/**
-	 * Create a new and otherwise unused T2Reference to an IdentifiedList. The
-	 * namespace of the reference will depend on the current workflow run read
-	 * from the ReferenceContext.
-	 * 
-	 * @param containsErrors
-	 *            whether the list this reference is generated for contains
-	 *            t2references with their containsErrors property set to true.
-	 *            Returns true if <em>any</em> reference in the list is or
-	 *            contains an error.
-	 * @param listDepth
-	 *            depth of the list to which this identifier will be applied
-	 * @return a new T2Reference for an IdentifiedList. Namespace, type and
-	 *         local parts will be initialized but depth and error content will
-	 *         still be at their default values of '0' and 'false' respectively,
-	 *         these will need to be re-set before the reference is viable.
-	 */
-	T2Reference nextListReference(boolean containsErrors, int listDepth,
-			ReferenceContext context);
-
-	/**
-	 * Create a new and otherwise unused T2Reference to an ErrorDocument. The
-	 * namespace of the reference will depend on the current workflow run read
-	 * from the ReferenceContext.
-	 * 
-	 * @param depth
-	 *            the depth of the error document to which this identifier will
-	 *            refer
-	 * @return a new T2Reference for an ErrorDocument
-	 */
-	T2Reference nextErrorDocumentReference(int depth, ReferenceContext context);
-}


[25/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/Curateable.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/Curateable.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/Curateable.java
deleted file mode 100644
index 006a59c..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/Curateable.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation;
-
-import java.util.Date;
-import java.util.List;
-
-/**
- * Implemented by objects which can have curation assertions attached to them.
- * In our model this includes the AnnotationAssertion but also includes the
- * CurationEvent itself, in this way we allow curation of curation assertions
- * and thence a conversational model of annotation.
- * 
- * @author Tom Oinn
- * 
- */
-public interface Curateable {
-
-	/**
-	 * Curateable instances have a list of curation events which are used to
-	 * determine whether the implementing object is valid given a particular
-	 * interpretive context. If this list is empty the event is unchallenged.
-	 * 
-	 * @return
-	 */
-	public List<CurationEvent<?>> getCurationAssertions();
-
-	/**
-	 * All curation events are marked with their creation date, this is the date
-	 * at which the curation event was associated with its target.
-	 * 
-	 * @return
-	 */
-	public Date getCreationDate();
-
-	/**
-	 * Each curateable has a list of people associated with it, frequently one
-	 * person and in some cases none, although this should be avoided if
-	 * possible.
-	 * 
-	 * @return
-	 */
-	public List<? extends Person> getCreators();
-
-	/**
-	 * Each annotation or curation has a resource from which the event is
-	 * inherently derived, for example if the annotation was created manually
-	 * after reading a paper the source would unambiguously specify the
-	 * publication.
-	 * 
-	 * @return
-	 */
-	public AnnotationSourceSPI getSource();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/CurationEvent.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/CurationEvent.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/CurationEvent.java
deleted file mode 100644
index 173cf57..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/CurationEvent.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation;
-
-/**
- * Represents a single act of curation, parameterized on a bean encapsulating
- * the necessary and sufficient information to describe the specifics of the
- * curation event.
- * 
- * @author Tom Oinn
- * 
- * @param <T>
- */
-public interface CurationEvent<CurationType extends CurationEventBeanSPI> {
-
-	public CurationType getDetail();
-
-	/**
-	 * The curation event type specifies whether this curation event is a
-	 * validation, repudiation or neither of its target.
-	 * 
-	 * @return
-	 */
-	public CurationEventType getType();
-
-	/**
-	 * The curation event applies to a specific other event, either another
-	 * curation event or an annotation assertion.
-	 * 
-	 * @return the event which this event is curating
-	 */
-	public Curateable getTarget();
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/CurationEventBeanSPI.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/CurationEventBeanSPI.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/CurationEventBeanSPI.java
deleted file mode 100644
index 2316cde..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/CurationEventBeanSPI.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation;
-
-/**
- * Contains the detail for a single curation event. In many cases this will be a
- * plain base curation object with very little information but it allows for us
- * to specify additional parameters to the curation event which can then be used
- * by the AnnotationPerspective instance to determine whether it believes the
- * curator.
- * 
- * @author Tom Oinn
- * 
- */
-public interface CurationEventBeanSPI {
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/CurationEventType.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/CurationEventType.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/CurationEventType.java
deleted file mode 100644
index 5b21201..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/CurationEventType.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation;
-
-public enum CurationEventType {
-
-	/**
-	 * The curation event asserts that the event it is attached to was correct,
-	 * effectively signing off an approval on the attached event.
-	 */
-	VALIDATION,
-
-	/**
-	 * The curation event repudiates the information in the attached event,
-	 * denying its validity.
-	 */
-	REPUDIATION,
-
-	/**
-	 * The curation event neither validates nor repudiates the information in
-	 * the attached event.
-	 */
-	NEUTRAL;
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/HierarchyRole.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/HierarchyRole.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/HierarchyRole.java
deleted file mode 100644
index 1c46033..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/HierarchyRole.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation;
-
-/**
- * Possible relationships between entities in a hierarchical context. This is
- * used as a property of the HierarchyTraversal annotation on members which
- * traverse a conceptual object hierarchy such as a parent-child containment
- * relationship. As an example the getProcessors() method in Dataflow is
- * annotated with <code>&amp;HierarchyRole(role=CHILD)</code> to indicate that
- * it accesses child members of the workflow model containment hierarchy.
- * 
- * @author Tom Oinn
- * 
- */
-public enum HierarchyRole {
-
-	CHILD,
-
-	PARENT;
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/HierarchyTraversal.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/HierarchyTraversal.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/HierarchyTraversal.java
deleted file mode 100644
index cbcbbaa..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/HierarchyTraversal.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Applied to getFoo methods to indicate that the returned type is related to
- * the annotated type by some hierarchical relationship, either parent or child.
- * This can then be used by annotation tools to determine the structure of an
- * object under annotation in order to find any child objects without
- * accidentally traversing outside of the bound of the object to be annotated.
- * <p>
- * As annotations are not inherited any annotation tool should traverse up the
- * type structure of an object under annotation to determine the possible
- * child-parent relationships from superclasses and implemented interfaces.
- * <p>
- * There is no guarantee that the return types from annotated members implement
- * Annotated, in these cases traversal should still be followed to cover cases
- * where a grandchild of an object is annotatable even though all children are
- * not.
- * <p>
- * This should only be applied to method with no arguments, if this is not the
- * case an annotation tool is free to not follow such methods (as it has no way
- * to determine what should be applied as arguments)
- * 
- * @author Tom Oinn
- * 
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-@Documented
-public @interface HierarchyTraversal {
-
-	/**
-	 * The role the return type of the annotated method plays in the named
-	 * hierarchy relative to the containing type.
-	 * 
-	 * @return role in hierarchy at corresponding index in the Hierarchies
-	 *         property, currently either CHILD or PARENT
-	 */
-	HierarchyRole[] role();
-
-	/**
-	 * It is possible for multiple orthogonal containment hierarchies to exist,
-	 * to allow for this the hierarchies are named using this field.
-	 * 
-	 * @return name of the hierarchy to which this relationship applies
-	 */
-	String[] hierarchies();
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/Person.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/Person.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/Person.java
deleted file mode 100644
index 88de1cd..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/Person.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation;
-
-/**
- * All metadata assertions and curation assertions have a person who is
- * ultimately responsible for the assertion (although this may not necessarily
- * imply that the assertion was created interactively).
- * 
- * TODO this needs to have some members! Cross reference with myExperiment user
- * model I suspect.
- * 
- * @author Tom Oinn
- * 
- */
-public interface Person {
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/AbstractNumericRangeAssertion.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/AbstractNumericRangeAssertion.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/AbstractNumericRangeAssertion.java
deleted file mode 100644
index 76583af..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/AbstractNumericRangeAssertion.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation.annotationbeans;
-
-import net.sf.taverna.t2.annotation.AnnotationBeanSPI;
-import net.sf.taverna.t2.annotation.AppliesTo;
-
-/**
- * Generic annotation containing a pair of numeric values with precision
- * determined by the type parameter which form a bound.
- * 
- * @author Tom Oinn
- * 
- */
-@AppliesTo(targetObjectType = { Object.class }, many = true)
-public abstract class AbstractNumericRangeAssertion<NumericType extends Number>
-		implements AnnotationBeanSPI {
-
-	private NumericType upperNumericValue;
-
-	private NumericType lowerNumericValue;
-	
-	/**
-	 * Default constructor as mandated by java bean specification
-	 */
-	protected AbstractNumericRangeAssertion() {
-		//
-	}
-
-	public NumericType getUpperNumericValue() {
-		return upperNumericValue;
-	}
-
-	public void setUpperNumericValue(NumericType upperNumericValue) {
-		this.upperNumericValue = upperNumericValue;
-	}
-
-	public NumericType getLowerNumericValue() {
-		return lowerNumericValue;
-	}
-
-	public void setLowerNumericValue(NumericType lowerNumericValue) {
-		this.lowerNumericValue = lowerNumericValue;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/AbstractNumericValueAssertion.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/AbstractNumericValueAssertion.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/AbstractNumericValueAssertion.java
deleted file mode 100644
index 3688b12..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/AbstractNumericValueAssertion.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation.annotationbeans;
-
-import net.sf.taverna.t2.annotation.AnnotationBeanSPI;
-import net.sf.taverna.t2.annotation.AppliesTo;
-
-/**
- * Generic annotation containing a single number of precision specified by the
- * type variable
- * 
- * @author Tom Oinn
- * 
- */
-@AppliesTo(targetObjectType = { Object.class }, many = true)
-public abstract class AbstractNumericValueAssertion<NumericType extends Number>
-		implements AnnotationBeanSPI {
-
-	private NumericType numericValue;
-
-	/**
-	 * Default constructor as mandated by java bean specification
-	 */
-	protected AbstractNumericValueAssertion() {
-		//
-	}
-
-	public NumericType getNumericValue() {
-		return numericValue;
-	}
-
-	public void setNumericValue(NumericType numericValue) {
-		this.numericValue = numericValue;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/AbstractTextualValueAssertion.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/AbstractTextualValueAssertion.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/AbstractTextualValueAssertion.java
deleted file mode 100644
index 5270979..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/AbstractTextualValueAssertion.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation.annotationbeans;
-
-import net.sf.taverna.t2.annotation.AnnotationBeanSPI;
-import net.sf.taverna.t2.annotation.AppliesTo;
-
-/**
- * Generic bit of free text that can be stuck to anything, subclass for more
- * specific uses
- * 
- * @author Tom Oinn
- * 
- */
-@AppliesTo(targetObjectType = { Object.class }, many = true)
-public abstract class AbstractTextualValueAssertion implements AnnotationBeanSPI {
-
-	private String text;
-
-	/**
-	 * Default constructor as mandated by java bean specification
-	 */
-	protected AbstractTextualValueAssertion() {
-		//
-	}
-
-	public String getText() {
-		return text;
-	}
-
-	public void setText(String text) {
-		this.text = text;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/Author.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/Author.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/Author.java
deleted file mode 100644
index b0839da..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/Author.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation.annotationbeans;
-
-import net.sf.taverna.t2.annotation.AppliesTo;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-
-/**
- * The name of an author of a dataflow held as a String
- * 
- * It should allow many but currently only allows one
- * 
- * @author Alan R Williams
- * 
- */
-@AppliesTo(targetObjectType = { Dataflow.class }, many = false)
-public class Author extends AbstractTextualValueAssertion {
-
-	/**
-	 * Default constructor as mandated by java bean specification
-	 */
-	public Author() {
-		//
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/DescriptiveTitle.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/DescriptiveTitle.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/DescriptiveTitle.java
deleted file mode 100644
index f9defd6..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/DescriptiveTitle.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation.annotationbeans;
-
-import net.sf.taverna.t2.annotation.AppliesTo;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-
-/**
- * The descriptive title of a dataflow held as a String
- * 
- * @author Alan R Williams
- * 
- */
-@AppliesTo(targetObjectType = { Dataflow.class }, many = false)
-public class DescriptiveTitle extends AbstractTextualValueAssertion {
-
-	/**
-	 * Default constructor as mandated by java bean specification
-	 */
-	public DescriptiveTitle() {
-		//
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/DocumentationUrl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/DocumentationUrl.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/DocumentationUrl.java
deleted file mode 100644
index 96fe397..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/DocumentationUrl.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation.annotationbeans;
-
-import java.net.URL;
-import net.sf.taverna.t2.annotation.AnnotationBeanSPI;
-import net.sf.taverna.t2.annotation.AppliesTo;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import net.sf.taverna.t2.workflowmodel.Port;
-import net.sf.taverna.t2.workflowmodel.Processor;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-
-/**
- * A link to documentation for the target element contained at a particular
- * Uniform Resource Locator (URL)
- * 
- * @author Tom Oinn
- * @author Alan Williams
- */
-@AppliesTo(targetObjectType = { Port.class, Activity.class, Processor.class, Dataflow.class }, many = true)
-public class DocumentationUrl implements AnnotationBeanSPI {
-
-	private URL documentationURL;
-
-	/**
-	 * Default constructor as mandated by java bean specification
-	 */
-	public DocumentationUrl() {
-		//
-	}
-
-	public URL getDocumentationURL() {
-		return documentationURL;
-	}
-
-	public void setDocumentationURL(URL documentationURL) {
-		this.documentationURL = documentationURL;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/ExampleValue.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/ExampleValue.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/ExampleValue.java
deleted file mode 100644
index dd8540c..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/ExampleValue.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation.annotationbeans;
-
-import net.sf.taverna.t2.annotation.AppliesTo;
-import net.sf.taverna.t2.workflowmodel.DataflowInputPort;
-import net.sf.taverna.t2.workflowmodel.DataflowOutputPort;
-
-/**
- * A String containing an example or a description of an example
- * 
- * @author Alan R Williams
- * 
- */
-@AppliesTo(targetObjectType = { DataflowInputPort.class , DataflowOutputPort.class }, many = false)
-public class ExampleValue extends AbstractTextualValueAssertion {
-
-	/**
-	 * Default constructor as mandated by java bean specification
-	 */
-	public ExampleValue() {
-		//
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/FreeTextDescription.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/FreeTextDescription.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/FreeTextDescription.java
deleted file mode 100644
index c871ec5..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/FreeTextDescription.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation.annotationbeans;
-
-import net.sf.taverna.t2.annotation.AppliesTo;
-import net.sf.taverna.t2.workflowmodel.Condition;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import net.sf.taverna.t2.workflowmodel.DataflowPort;
-import net.sf.taverna.t2.workflowmodel.Datalink;
-import net.sf.taverna.t2.workflowmodel.Processor;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-
-/**
- * An unconstrained textual description held as a String
- * 
- * @author Tom Oinn
- * 
- */
-@AppliesTo(targetObjectType = { Dataflow.class, Processor.class,
-		Activity.class, DataflowPort.class, Datalink.class, Condition.class }, many = false)
-public class FreeTextDescription extends AbstractTextualValueAssertion {
-
-	/**
-	 * Default constructor as mandated by java bean specification
-	 */
-	public FreeTextDescription() {
-		//
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/HostInstitution.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/HostInstitution.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/HostInstitution.java
deleted file mode 100644
index db35cd3..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/HostInstitution.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-/**
- * 
- */
-package net.sf.taverna.t2.annotation.annotationbeans;
-
-import net.sf.taverna.t2.annotation.AppliesTo;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-
-/**
- * The host institution for an activity implementation
- * 
- * @author Tom Oinn
- * @author Alan Williams
- */
-@AppliesTo(targetObjectType = { Activity.class }, many = false)
-public class HostInstitution extends AbstractTextualValueAssertion {
-
-	/**
-	 * Default constructor as mandated by java bean specification
-	 */
-	public HostInstitution() {
-		super();
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/IdentificationAssertion.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/IdentificationAssertion.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/IdentificationAssertion.java
deleted file mode 100644
index 44bd587..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/IdentificationAssertion.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 
- */
-package net.sf.taverna.t2.annotation.annotationbeans;
-
-import net.sf.taverna.t2.annotation.AnnotationBeanSPI;
-import net.sf.taverna.t2.annotation.AppliesTo;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-
-/**
- * An IdentificationAssertion is used to hold previous identifications of an
- * object.
- * 
- * @author alanrw
- * 
- */
-@AppliesTo(targetObjectType = { Dataflow.class }, many = false, pruned = false)
-public class IdentificationAssertion implements AnnotationBeanSPI {
-
-	private String identification;
-
-	/**
-	 * @return The identification. This will be a previous identifier of the
-	 *         annotated object.
-	 */
-	public String getIdentification() {
-		return identification;
-	}
-
-	/**
-	 * @param identification
-	 *            A previous identified of the annotated object.
-	 */
-	public void setIdentification(String identification) {
-		this.identification = identification;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/MimeType.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/MimeType.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/MimeType.java
deleted file mode 100644
index eb09c61..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/MimeType.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation.annotationbeans;
-
-import net.sf.taverna.t2.annotation.AppliesTo;
-import net.sf.taverna.t2.workflowmodel.Port;
-
-/**
- * A single MIME type, intended to be used to annotate an input or output port
- * within the workflow to denote the type within that system of data produced or
- * consumed by the port.
- * 
- * @author Tom Oinn
- * 
- */
-@AppliesTo(targetObjectType = { Port.class })
-public class MimeType extends AbstractTextualValueAssertion {
-
-	/**
-	 * Default constructor as mandated by java bean specification
-	 */
-	public MimeType() {
-		super();
-	}
-
-	/**
-	 * Return the MIME type as a string, mime types look like 'part/part'. We
-	 * may want to consider whether it's possible to make this a genuine
-	 * enumeration driven off a canonical list of MIME types or whether it's
-	 * best kept as the current (free) string. The advantage of an enumerated
-	 * type is that we could attach description to the MIME types which would
-	 * help with the UI construction but maybe this isn't the place to put it
-	 * (should this link be in the UI layer? probably)
-	 * 
-	 * @return the MIME type as a string.
-	 */
-	@Override
-	public String getText() {
-		return super.getText();
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/Optional.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/Optional.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/Optional.java
deleted file mode 100644
index 3f18282..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/Optional.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.annotation.annotationbeans;
-
-import net.sf.taverna.t2.annotation.AppliesTo;
-import net.sf.taverna.t2.annotation.AnnotationBeanSPI;
-import net.sf.taverna.t2.workflowmodel.InputPort;
-
-/**
- * A declaration that the bound input port is optional, if this annotation is
- * refuted then the interpretation should be that the input port is required.
- * 
- * @author Tom Oinn
- * @author Alan Williams
- */
-@AppliesTo(targetObjectType = { InputPort.class }, many = false)
-public class Optional implements AnnotationBeanSPI {
-
-	/**
-	 * Default constructor as mandated by java bean specification
-	 */
-	public Optional() {
-		//
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/SemanticAnnotation.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/SemanticAnnotation.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/SemanticAnnotation.java
deleted file mode 100644
index 02dced3..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/annotationbeans/SemanticAnnotation.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * 
- */
-package net.sf.taverna.t2.annotation.annotationbeans;
-
-import net.sf.taverna.t2.annotation.AnnotationBeanSPI;
-import net.sf.taverna.t2.annotation.AppliesTo;
-import net.sf.taverna.t2.workflowmodel.Condition;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import net.sf.taverna.t2.workflowmodel.Datalink;
-import net.sf.taverna.t2.workflowmodel.Merge;
-import net.sf.taverna.t2.workflowmodel.Port;
-import net.sf.taverna.t2.workflowmodel.Processor;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.DispatchLayer;
-
-/**
- * A SemanticAssertion holds a String which contains RDF about an Object
- * @author alanrw
- *
- */
-@AppliesTo(targetObjectType = { Dataflow.class, Processor.class, Port.class, Activity.class, Datalink.class, Merge.class, Condition.class, DispatchLayer.class }, many = false)
-public class SemanticAnnotation implements AnnotationBeanSPI {
-	
-	private String mimeType = "text/rdf+n3";
-	
-	private String content = "";
-
-	public String getMimeType() {
-		return mimeType;
-	}
-
-	public void setMimeType(String mimeType) {
-		this.mimeType = mimeType;
-	}
-
-	/**
-	 * @param content the content to set
-	 */
-	public void setContent(String content) {
-		this.content = content;
-	}
-
-	/**
-	 * @return the content
-	 */
-	public String getContent() {
-		return content;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/package.html b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/package.html
deleted file mode 100644
index 99a5a4f..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/annotation/package.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<body>
-Entities within the workflow object model may be marked as annotated.
-When marked as such they contract to provide one or more of a variety of
-forms of metadata, whether generic or specific to the type of object
-within the model. This description is deliberately kept vague for now
-because we haven't yet enumerated what classes of annotation exist on
-each entity.
-<p>From this point in we will use the term 'metadata' to distinguish
-between annotations in terms of properties of the workflow and
-annotations in terms of the Java 5 language feature. This is
-particularly important we we use Java Annotations to implement the
-workflow annotations. Yay.
-<p>In keeping with the read-only model of the API package all
-metadata interfaces only specify the get methods for their respective
-contents. Modification of metadata instances is performed through Edit
-objects.
-</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/facade/FacadeListener.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/facade/FacadeListener.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/facade/FacadeListener.java
deleted file mode 100644
index 35d6fef..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/facade/FacadeListener.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.facade;
-
-import net.sf.taverna.t2.facade.WorkflowInstanceFacade.State;
-
-/**
- * Used to communicate a failure of the overall workflow to interested parties.
- * 
- * @author Tom Oinn
- */
-public interface FacadeListener {
-	/**
-	 * Called if the workflow fails in a critical and fundamental way. Most
-	 * internal failures of individual process instances will not trigger this,
-	 * being handled either by the per processor dispatch stack through retry,
-	 * failover etc or by being converted into error tokens and injected
-	 * directly into the data stream. This therefore denotes a catastrophic and
-	 * unrecoverable problem.
-	 * 
-	 * @param message
-	 *            Description of what happened
-	 * @param t
-	 *            The cause of the failure
-	 */
-	void workflowFailed(WorkflowInstanceFacade facade, String message,
-			Throwable t);
-
-	void stateChange(WorkflowInstanceFacade facade, State oldState,
-			State newState);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/facade/ResultListener.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/facade/ResultListener.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/facade/ResultListener.java
deleted file mode 100644
index ae5ea58..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/facade/ResultListener.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.facade;
-
-import net.sf.taverna.t2.invocation.WorkflowDataToken;
-
-/**
- * Implement and use with the WorkflowInstanceFacade to listen for data
- * production events from the underlying workflow instance
- * 
- * @author Tom Oinn
- */
-public interface ResultListener {
-	/**
-	 * Called when a new result token is produced by the workflow instance.
-	 * 
-	 * @param token
-	 *            the WorkflowDataToken containing the result.
-	 * @param portName
-	 *            The name of the output port on the workflow from which this
-	 *            token is produced, this now folds in the owning process which
-	 *            was part of the signature for this method
-	 */
-	void resultTokenProduced(WorkflowDataToken token, String portName);
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/facade/WorkflowInstanceFacade.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/facade/WorkflowInstanceFacade.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/facade/WorkflowInstanceFacade.java
deleted file mode 100644
index 11f1a64..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/facade/WorkflowInstanceFacade.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.facade;
-
-import java.lang.ref.WeakReference;
-import java.util.WeakHashMap;
-
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.invocation.TokenOrderException;
-import net.sf.taverna.t2.invocation.WorkflowDataToken;
-import net.sf.taverna.t2.monitor.MonitorNode;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.utility.TypedTreeModel;
-import net.sf.taverna.t2.workflowmodel.ControlBoundary;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-
-/**
- * The interaction point with a workflow instance. Technically there is no such
- * thing as a workflow instance in Taverna2, at least not in any real sense in
- * the code itself. The instance is more literally an identifier used as the
- * root of all data and error objects within this workflow and by which the top
- * level DataFlow or similar object is identified in the state tree. The
- * implementation of this interface should hide this though, automatically
- * prepending the internally stored (and hidden) identifier to all data push
- * messages and providing a subtree of the state model rooted at the internal
- * ID.
- * <p>
- * TODO - we should probably have callbacks for failure states here, but that
- * would need a decent definition (and maybe even ontology of) what failure
- * means. It's less obvious in a data streaming world what a failure is. At the
- * moment the dispatch stack can potentially treat unhandled error messages as
- * failing the processor, how do we get this exception information back up to
- * the workflow level?
- * 
- * @author Tom Oinn
- * @author Alex Nenadic
- * @author Stian Soiland-Reyes
- * @author Alan R Williams
- */
-@ControlBoundary
-public interface WorkflowInstanceFacade {
-	public static enum State {
-		/**
-		 * Workflow has not yet been started using
-		 * {@link WorkflowInstanceFacade#fire()}
-		 */
-		prepared,
-		/**
-		 * Workflow is running (or have been resumed using
-		 * {@link WorkflowInstanceFacade#fire()})
-		 */
-		running,
-		/**
-		 * Workflow has been paused using
-		 * {@link WorkflowInstanceFacade#pauseWorkflowRun()}
-		 */
-		paused,
-		/**
-		 * Workflow has completed, all processors are finished and all data
-		 * delivered to all output ports.
-		 */
-		completed,
-		/**
-		 * Workflow has been cancelled using
-		 * {@link WorkflowInstanceFacade#cancelWorkflowRun()}
-		 */
-		cancelled;
-	}
-
-	/**
-	 * A weak hash map of all workflow run IDs mapped against the corresponding
-	 * WorkflowInstanceFacadeS. This is needed for activities with dependencies
-	 * (such as beanshell and API consumer) to gain access to the current
-	 * workflow via the WorkflowInstanceFacade.
-	 */
-	static final WeakHashMap<String, WeakReference<WorkflowInstanceFacade>> workflowRunFacades = new WeakHashMap<>();
-
-	/**
-	 * Push a data token into the specified port. If the token is part of a
-	 * stream the index contains the index of this particular token. If not the
-	 * index should be the empty integer array.
-	 * 
-	 * @param token
-	 *            A WorkflowDataToken containing the data to be pushed to the
-	 *            workflow along with its current owning process identifier and
-	 *            index
-	 * @param portName
-	 *            Port name to use
-	 * @throws TokenOrderException
-	 *             if ordering constraints on the token stream to each input
-	 *             port are violated
-	 */
-	void pushData(WorkflowDataToken token, String portName)
-			throws TokenOrderException;
-
-	/**
-	 * Where a workflow has no inputs this method will cause it to start
-	 * processing. Any processors within the workflow with no inputs are fired.
-	 * 
-	 * @throws IllegalStateException
-	 *             if the workflow has already been fired or has had data pushed
-	 *             to it.
-	 */
-	void fire() throws IllegalStateException;
-
-	/**
-	 * The result listener is used to handle data tokens produced by the
-	 * workflow.
-	 * <p>
-	 * If the listener is registered after the workflow has already produced
-	 * results it will be immediately called with any results previously
-	 * produced. Where the workflow has completed a stream of results it may
-	 * only message the listener with the highest level one, so for a case where
-	 * a list of results is emited one at a time the listener may either get the
-	 * individual items followed by the list token or if registered after the
-	 * list token has been emited only receive the list token.
-	 * 
-	 * @param listener
-	 */
-	void addResultListener(ResultListener listener);
-
-	/**
-	 * Remove a previously registered result listener
-	 * 
-	 * @param listener
-	 */
-	void removeResultListener(ResultListener listener);
-
-	/**
-	 * A failure listener reports on overall workflow failure. It is not
-	 * triggered by the failure of individual processors unless that processor
-	 * is marked as critical. In fact in T2 all processors are marked as
-	 * critical by default as there are ways of handling errors within the data
-	 * stream, if the processor actually fails something really bad has
-	 * happened.
-	 * <p>
-	 * As with the result listener a failure listener registered after the
-	 * workflow has already failed will be immediately called with the failure
-	 * data.
-	 */
-	void addFacadeListener(FacadeListener listener);
-
-	/**
-	 * Remove a previously registered failure listener
-	 */
-	void removeFacadeListener(FacadeListener listener);
-
-	/**
-	 * Workflow state is available through a sub-tree of the monitor tree. For
-	 * security reasons the full monitor tree is never accessible through this
-	 * interface but the sub-tree rooted at the node representing this workflow
-	 * instance is and can be used for both monitoring and steering functions.
-	 * <p>
-	 * Uses the standard TreeModel-like mechanisms for registering change events
-	 * and can be plugged into a JTree for display purposes through the
-	 * TreeModelAdapter class.
-	 * 
-	 * @return Typed version of TreeModel representing the state of this
-	 *         workflow. Nodes in the tree are instances of MonitorNode
-	 */
-	TypedTreeModel<MonitorNode> getStateModel();
-
-	/**
-	 * Return the dataflow this facade facades
-	 */
-	Dataflow getDataflow();
-
-	/**
-	 * Return the invocation context used by this facade
-	 */
-	InvocationContext getContext();
-
-	/**
-	 * Return a map of the data pushed on the named port
-	 */
-	WeakHashMap<String, T2Reference> getPushedDataMap();
-
-	/**
-	 * Get the unique id of the wf run inside the facede.
-	 */
-	String getWorkflowRunId();
-
-	/**
-	 * Cancel the workflow run corresponding to this facade
-	 * 
-	 * @return true if the workflow run was successfully cancelled. Note that
-	 *         this does not mean that all of the invocations associated with
-	 *         the run have finished.
-	 */
-	boolean cancelWorkflowRun() throws IllegalStateException;
-
-	/**
-	 * Pause the workflow run corresponding to this facade
-	 * 
-	 * @return true if the workflow run was successfully paused.
-	 */
-	boolean pauseWorkflowRun() throws IllegalStateException;
-
-	/**
-	 * Resume the workflow run corresponding to this facade
-	 * 
-	 * @return true if the workflow run was successfully resumed
-	 */
-	boolean resumeWorkflowRun() throws IllegalStateException;
-
-	/**
-	 * Return the current workflow {@link State}.
-	 * 
-	 * @return The workflow state.
-	 */
-	State getState();
-
-	/**
-	 * An identifier that is unique to this facade.
-	 * 
-	 * @return a String representing a unique internal identifier.
-	 */
-	String getIdentifier();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/facade/WorkflowRunCancellation.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/facade/WorkflowRunCancellation.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/facade/WorkflowRunCancellation.java
deleted file mode 100644
index 216e7f5..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/facade/WorkflowRunCancellation.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * 
- */
-package net.sf.taverna.t2.facade;
-
-/**
- * A WorkflowRunCancellation is passed to listeners when a workflow run is
- * cancelled.
- * 
- * @author alanrw
- */
-@SuppressWarnings("serial")
-public class WorkflowRunCancellation extends Throwable {
-	/**
-	 * The id of the workflow run that was cancelled
-	 */
-	private String cancelledWorkflowRunId;
-	
-	public WorkflowRunCancellation (String runId) {
-		cancelledWorkflowRunId = runId;
-	}
-
-	/**
-	 * @return the id of the workflow run that was cancelled.
-	 */
-	public String getCancelledWorkflowRunId() {
-		return cancelledWorkflowRunId;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/facade/package.html
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/facade/package.html b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/facade/package.html
deleted file mode 100644
index 898ccdf..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/facade/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<body>
-Facade interfaces to represent a workflow instance within the enactor.
-<p>Although T2 has no 'real' concept of a workflow instance, using
-identifiers on data instead, it is useful to treat it as if it does. The
-facade classes are the external 'invoke only' interface to the enactment
-system, providing wrappers around the actual single instance model. This
-also hides the shared state tree, exposing only the sub-tree rooted at
-the base ID internal to the facade layer. The state tree acts both as
-monitoring and steering infrastructure, the facade therefore prevents a
-process accessing the state of another workflow either maliciously or
-inadvertently.
-<p>The construction of these facade objects is not defined here, a
-factory method in the implementation package is the most likely
-candidate but there are other options, for example a peer to peer cloud
-may expose services to create new facades and allow access as might a
-web service based interface. The interfaces here are intended to be as
-easy to access remotely as possible.
-<p>For the same reasons there are no methods in the workflow facade
-concerning security or the management of data access - it is assumed
-that the constructor of the facade layer has embedded such concerns
-within it. There is therefore a clear split between initiation of the
-workflow session and manipulation of it with this package only
-addressing the latter of the two.
-</body>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/Completion.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/Completion.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/Completion.java
deleted file mode 100644
index c9f84f2..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/Completion.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.invocation;
-
-/**
- * Contains a (possibly partial) completion event. The completion event is a
- * statement that no further events will occur on this channel with an index
- * prefixed by the completion index. As with Job events completion events have
- * an owning process with the same semantics as that of the Job class
- * <p>
- * The conceptual depth of a completion is the sum of the length of index array
- * for any data tokens the completion shares a stream with and the depth of
- * those tokens. This should be constant for any given token stream.
- * 
- * @author Tom Oinn
- * 
- */
-public class Completion extends IterationInternalEvent<Completion> {
-
-	/**
-	 * Construct a new optionally partial completion event with the specified
-	 * owner and completion index
-	 * 
-	 * @param owningProcess
-	 * @param completionIndex
-	 */
-	public Completion(String owningProcess, int[] completionIndex,
-			InvocationContext context) {
-		super(owningProcess, completionIndex, context);
-	}
-
-	/**
-	 * Construct a new final completion event, equivalent to calling new
-	 * Completion(owningProcess, new int[0]);
-	 * 
-	 * @param owningProcess
-	 */
-	public Completion(String owningProcess, InvocationContext context) {
-		super(owningProcess, new int[0], context);
-	}
-
-	@Override
-	public String toString() {
-		StringBuffer sb = new StringBuffer();
-		sb.append("Cmp(" + owner + ")[");
-		for (int i = 0; i < index.length; i++) {
-			if (i > 0) {
-				sb.append(",");
-			}
-			sb.append(index[i] + "");
-		}
-		sb.append("]");
-		return sb.toString();
-	}
-
-	/**
-	 * Push the index array onto the owning process name and return the new Job
-	 * object. Does not modify this object, the method creates a new Job with
-	 * the modified index array and owning process
-	 * 
-	 * @return
-	 */
-	@Override
-	public Completion pushIndex() {
-		return new Completion(getPushedOwningProcess(), new int[] {}, context);
-	}
-
-	/**
-	 * Pull the index array previous pushed to the owning process name and
-	 * prepend it to the current index array
-	 */
-	@Override
-	public Completion popIndex() {
-		return new Completion(owner.substring(0, owner.lastIndexOf(':')),
-				getPoppedIndex(), context);
-	}
-
-	@Override
-	public Completion popOwningProcess() throws ProcessIdentifierException {
-		return new Completion(popOwner(), index, context);
-	}
-
-	@Override
-	public Completion pushOwningProcess(String localProcessName)
-			throws ProcessIdentifierException {
-		return new Completion(pushOwner(localProcessName), index, context);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/Event.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/Event.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/Event.java
deleted file mode 100644
index f0816ac..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/Event.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.invocation;
-
-/**
- * Abstract superclass of all 'event' types within a workflow invocation. These
- * are the Job and Completion events which are used internally within a
- * Processor, in particular by the dispatch stack and iteration system, and the
- * WorkflowDataToken which is the only event class that can exist outside of a
- * Processor boundary (and is therefore the most significant one for users of
- * the API)
- * 
- * @author Tom Oinn
- */
-public abstract class Event<EventType extends Event<?>> {
-	protected String owner;
-	protected InvocationContext context;
-	protected int[] index;
-
-	protected Event(String owner, int[] index, InvocationContext context) {
-		this.owner = owner;
-		this.index = index;
-		this.context = context;
-		if (index == null)
-			throw new RuntimeException("Job index cannot be null");
-		if (owner == null)
-			throw new RuntimeException("Owning process cannot be null");
-		if (context == null)
-			throw new RuntimeException("Invocation context cannot be null");
-	}
-
-	/**
-	 * An event is final if its index array is zero length
-	 * 
-	 * @return true if indexarray.length==0
-	 */
-	public final boolean isFinal() {
-		return (index.length == 0);
-	}
-
-	/**
-	 * The event has an owner, this is represented as a String object but the
-	 * ownership is hierarchical in nature. The String is a colon separated list
-	 * of alphanumeric process identifiers, with identifiers being pushed onto
-	 * this list on entry to a process and popped off on exit.
-	 * 
-	 * @return String of colon separated process identifiers owning this Job
-	 */
-	public final String getOwningProcess() {
-		return this.owner;
-	}
-
-	public final InvocationContext getContext() {
-		return this.context;
-	}
-
-	/**
-	 * Return a copy of the event subclass with the last owning process removed
-	 * from the owning process list. For example, if the event had owner
-	 * 'foo:bar' this would return a duplicate event with owner 'foo'. If the
-	 * owning process is the empty string this is invalid and will throw a
-	 * ProcessIdentifierException
-	 * 
-	 * @return a copy of the event with the parent process identifier
-	 */
-	public abstract EventType popOwningProcess()
-			throws ProcessIdentifierException;
-
-	/**
-	 * Return a copy of the event subclass with the specified local process name
-	 * appended to the owning process identifier field. If the original owner
-	 * was 'foo' and this was called with 'bar' you'd end up with a copy of the
-	 * subclass with owner 'foo:bar'
-	 * 
-	 * @param localProcessName
-	 *            name to add
-	 * @return the modified event
-	 * @throws ProcessIdentifierException
-	 *             if the local process name contains the ':' character
-	 */
-	public abstract EventType pushOwningProcess(String localProcessName)
-			throws ProcessIdentifierException;
-
-	/**
-	 * Events have an index placing them in a conceptual tree structure. This
-	 * index is carried along with the event and used at various points to drive
-	 * iteration and ensure that separate jobs are kept that way
-	 */
-	public final int[] getIndex() {
-		return this.index;
-	}
-
-	/**
-	 * Helper method for implementations of popOwningProcess, this constructs
-	 * the appropriate process identifier after the leaf has been removed and
-	 * returns it. If there is no leaf to remove, i.e. the current process
-	 * identifier is the empty string, then ProcessIdentifierException is thrown
-	 * 
-	 * @return
-	 * @throws ProcessIdentifierException
-	 */
-	protected final String popOwner() throws ProcessIdentifierException {
-		// Empty string already, can't pop from here, throw exception
-		if (owner.isEmpty())
-			throw new ProcessIdentifierException(
-					"Attempt to pop a null owning process (empty string)");
-		// A single ID with no colon in, return the empty string
-		if (owner.lastIndexOf(':') < 0)
-			return "";
-		return owner.substring(0, owner.lastIndexOf(':'));
-	}
-
-	/**
-	 * Helper method for implementations of pushOwningProcess, appends the
-	 * specified local name to the current owning process identifier and returns
-	 * the new id. This doesn't change the current process identifier. If there
-	 * is a colon ':' in the specified name this is invalid and will throw
-	 * ProcessIdentifierException at you.
-	 * 
-	 * @param newLocalProcess
-	 * @return
-	 * @throws ProcessIdentifierException
-	 */
-	protected final String pushOwner(String newLocalProcess)
-			throws ProcessIdentifierException {
-		if (newLocalProcess.contains(":"))
-			throw new ProcessIdentifierException("Can't push '"
-					+ newLocalProcess + "' as it contains a ':' character");
-		if (owner.isEmpty())
-			// If the owner was the empty string we don't need to append the
-			// colon
-			return newLocalProcess;
-		return owner + ":" + newLocalProcess;
-	}
-
-	@Override
-	public String toString() {
-		StringBuilder sb = new StringBuilder();
-		sb.append(getClass().getSimpleName());
-		sb.append(' ');
-		sb.append(owner);
-		sb.append('[');
-		for (int i : index) {
-			sb.append(i);
-			sb.append(" ");
-		}
-		sb.append(']');
-		return sb.toString();
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/InvocationContext.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/InvocationContext.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/InvocationContext.java
deleted file mode 100644
index c3c7094..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/InvocationContext.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.invocation;
-
-import net.sf.taverna.t2.provenance.reporter.ProvenanceReporter;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferenceService;
-
-/**
- * Carries the context of a workflow invocation, the necessary data manager,
- * security agents and any other resource shared across the invocation such as
- * provenance injectors.
- * 
- * @author Tom Oinn
- */
-public interface InvocationContext extends ReferenceContext {
-	/**
-	 * Return the reference service to be used within this invocation context
-	 * 
-	 * @return a configured instance of ReferenceService to be used to resolve
-	 *         and register references to data in the workflow
-	 */
-	ReferenceService getReferenceService();
-
-	ProvenanceReporter getProvenanceReporter();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/IterationInternalEvent.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/IterationInternalEvent.java b/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/IterationInternalEvent.java
deleted file mode 100644
index f3b2c9b..0000000
--- a/taverna-workflowmodel-api/src/main/java/net/sf/taverna/t2/invocation/IterationInternalEvent.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.invocation;
-
-/**
- * Abstract superclass for event types which have to pass through the iteration
- * system. For this they need the ability to push and pull the iteration index
- * to and from the process identifier, this is done through the popIndex and
- * pushIndex methods. Subclasses of this may be used outside the iteration
- * system but anything which is passed into the iteration system must provide
- * this functionality.
- * 
- * @author Tom Oinn
- * 
- * @param <EventType>
- *            reflexive self type
- */
-public abstract class IterationInternalEvent<EventType extends IterationInternalEvent<?>>
-		extends Event<EventType> {
-	/**
-	 * Protected constructor for the minimum fields required by all Event
-	 * subclasses
-	 * 
-	 * @param owner
-	 * @param index
-	 * @param context
-	 */
-	protected IterationInternalEvent(String owner, int[] index,
-			InvocationContext context) {
-		super(owner, index, context);
-	}
-
-	/**
-	 * Pop a previously pushed index array off the process name and append the
-	 * current index array to create the new index array. This is applied to a
-	 * new instance of an Event subclass and does not modify the target.
-	 * 
-	 * @return new Event subclass with modified owning process and index
-	 */
-	public abstract IterationInternalEvent<EventType> popIndex();
-
-	/**
-	 * Push the index array onto the owning process name and return the new
-	 * Event subclass object. Does not modify this object, the method creates a
-	 * new Event subclass with the modified index array and owning process.
-	 * 
-	 */
-	public abstract IterationInternalEvent<EventType> pushIndex();
-
-	/**
-	 * Helper method for the pushIndex operation
-	 * 
-	 * @return
-	 */
-	protected final String getPushedOwningProcess() {
-		StringBuilder sb = new StringBuilder(owner).append(":");
-		String sep = "";
-		for (int idx : index) {
-			sb.append(sep).append(idx);
-			sep = ",";
-		}
-		return sb.toString();
-	}
-
-	/**
-	 * Helper method for the popIndex operation, returns the modified index
-	 * array. Subclasses must still implement logic to get the modified owning
-	 * process but that's relatively easy : <code>
-	 * return new &lt;Event subclass&gt;(owner.substring(0, owner.lastIndexOf(':')),getPoppedIndex(), dataMap);
-	 * </code>
-	 * 
-	 * @return
-	 */
-	protected final int[] getPoppedIndex() {
-		int lastLocation = owner.lastIndexOf(':');
-		String indexArrayAsString = owner.substring(lastLocation + 1);
-		String[] parts = indexArrayAsString.split(",");
-		int[] newIndexArray = new int[index.length + parts.length];
-		int pos = 0;
-		for (String part : parts)
-			newIndexArray[pos++] = Integer.parseInt(part);
-		System.arraycopy(index, 0, newIndexArray, pos, index.length);
-		return newIndexArray;
-	}
-}


[14/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Edits.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Edits.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Edits.java
new file mode 100644
index 0000000..e49bfea
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Edits.java
@@ -0,0 +1,831 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+import java.util.List;
+
+import org.apache.taverna.annotation.Annotated;
+import org.apache.taverna.annotation.AnnotationAssertion;
+import org.apache.taverna.annotation.AnnotationBeanSPI;
+import org.apache.taverna.annotation.AnnotationChain;
+import org.apache.taverna.annotation.AnnotationRole;
+import org.apache.taverna.annotation.AnnotationSourceSPI;
+import org.apache.taverna.annotation.CurationEvent;
+import org.apache.taverna.annotation.CurationEventBeanSPI;
+import org.apache.taverna.annotation.Person;
+import org.apache.taverna.facade.WorkflowInstanceFacade;
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+import org.apache.taverna.workflowmodel.processor.activity.ActivityInputPort;
+import org.apache.taverna.workflowmodel.processor.activity.ActivityOutputPort;
+import org.apache.taverna.workflowmodel.processor.dispatch.DispatchLayer;
+import org.apache.taverna.workflowmodel.processor.dispatch.DispatchStack;
+import org.apache.taverna.workflowmodel.processor.iteration.IterationStrategy;
+import org.apache.taverna.workflowmodel.processor.iteration.IterationStrategyStack;
+import org.apache.taverna.workflowmodel.processor.iteration.NamedInputPortNode;
+
+/**
+ * Defines the set of all available edit actions over a workflow model. This is
+ * the only point at which you can modify any of the entities in the workflow
+ * object model, the rest of this API is purely read only.
+ * <p>
+ * In theory this would be some kind of static interface but Java doesn't have
+ * this as a concept so the pattern here will be to discover an appropriate
+ * implementation of this interface from whatever version of the implementation
+ * package you want to use, instantiate it then use the methods defined here to
+ * construct and manipulate the workflow model.
+ * 
+ * @author Tom Oinn
+ * @author Stuart Owen
+ * @author David Withers
+ * @author Stian Soiland-Reyes
+ * 
+ */
+public interface Edits {
+
+	/**
+	 * Build a new Dataflow workflow
+	 * 
+	 * @return
+	 */
+	public Dataflow createDataflow();
+
+	/**
+	 * Builds a new DataflowInputPort.
+	 * 
+	 * @param name
+	 * @param depth
+	 * @param granularDepth
+	 * @param dataflow
+	 * @return a new DataflowInputPort
+	 */
+	public DataflowInputPort createDataflowInputPort(String name, int depth,
+			int granularDepth, Dataflow dataflow);
+
+	/**
+	 * Builds a new DataflowOutputPort.
+	 * 
+	 * @param name
+	 * @param dataflow
+	 * @return a new DataflowOutputPort
+	 */
+	public DataflowOutputPort createDataflowOutputPort(String name,
+			Dataflow dataflow);
+
+	/**
+	 * Builds a new Datalink with the given source and sink ports
+	 * 
+	 * @param source
+	 *            the source port
+	 * @param sink
+	 *            the sink port
+	 * @return a new Datalink instance
+	 */
+	public Datalink createDatalink(EventForwardingOutputPort source,
+			EventHandlingInputPort sink);
+
+	/**
+	 * @param dataflow
+	 * @return an instance of Merge
+	 * 
+	 * @see Merge
+	 */
+	public Merge createMerge(Dataflow dataflow);
+
+	/**
+	 * Builds a new MergeOutputPort.
+	 * 
+	 * @param merge
+	 *            the merge that the port eill be added to
+	 * @param name
+	 *            the name of the port
+	 * @param depth
+	 *            the depth of the port
+	 * @return a new MergeOutputPort
+	 */
+	public MergeInputPort createMergeInputPort(Merge merge, String name,
+			int depth);
+
+	/**
+	 * Builds a new instance of a Processor with the given name. The processor
+	 * is setup with a default dispatch stack.
+	 * 
+	 * @param the
+	 *            local name for the processor.
+	 */
+	public Processor createProcessor(String name);
+
+	/**
+	 * Builds a new instance of a IterationStrategy.
+	 * 
+	 * @return a new IterationStrategy
+	 */
+	public IterationStrategy createIterationStrategy();
+
+	/**
+	 * Build a new WorkflowInstanceFacade using the supplied Dataflow
+	 * 
+	 * @param dataflow
+	 * @param context
+	 * @return an instance of a WorkflowInstanceFacade
+	 * @throws InvalidDataflowException
+	 *             if the workflow was not valid
+	 * 
+	 * @see WorkflowInstanceFacade
+	 */
+	public WorkflowInstanceFacade createWorkflowInstanceFacade(
+			Dataflow dataflow, InvocationContext context, String parentProcess)
+			throws InvalidDataflowException;
+
+	/**
+	 * Add an Activity implementation to the set of activities within a
+	 * Processor
+	 * 
+	 * @param processor
+	 *            Processor to add the activity to
+	 * @param activity
+	 *            Activity to add
+	 */
+	public Edit<Processor> getAddActivityEdit(Processor processor,
+			Activity<?> activity);
+
+	/**
+	 * Returns an edit to add an ActivityInputPort to an Activity.
+	 * 
+	 * @param activity
+	 *            activity to add the port to
+	 * @param activityInputPort
+	 *            the port to add to the activity
+	 * @return an edit to add an ActivityInputPort to an Activity
+	 */
+	public Edit<Activity<?>> getAddActivityInputPortEdit(Activity<?> activity,
+			ActivityInputPort activityInputPort);
+
+	/**
+	 * Returns an edit to add a ProcessorInputPort to ActivityInputPort mapping
+	 * to an Activity.
+	 * 
+	 * @param activity
+	 *            activity to add the port mapping to
+	 * @param processorPortName
+	 *            the name of the processor port
+	 * @param activityPortName
+	 *            the name of the activity port
+	 * @return an edit to add a ProcessorInputPort to ActivityInputPort mapping
+	 *         to an Activity
+	 */
+	public Edit<Activity<?>> getAddActivityInputPortMappingEdit(
+			Activity<?> activity, String processorPortName,
+			String activityPortName);
+
+	/**
+	 * Returns an edit to add an ActivityOutputPort to an Activity.
+	 * 
+	 * @param activity
+	 *            activity to add the port to
+	 * @param activityOutputPort
+	 *            the port to add to the activity
+	 * @return an edit to add an ActivityOutputPort to an Activity
+	 */
+	public Edit<Activity<?>> getAddActivityOutputPortEdit(Activity<?> activity,
+			ActivityOutputPort activityOutputPort);
+
+	/**
+	 * Returns an edit to add a ProcessorOutputPort to OutputPort mapping to an
+	 * Activity.
+	 * 
+	 * @param activity
+	 *            activity to add the port mapping to
+	 * @param processorPortName
+	 *            the name of the processor port
+	 * @param activityPortName
+	 *            the name of the activity port
+	 * @return an edit to add a ProcessorOutputPort to OutputPort mapping to an
+	 *         Activity
+	 */
+	public Edit<Activity<?>> getAddActivityOutputPortMappingEdit(
+			Activity<?> activity, String processorPortName,
+			String activityPortName);
+
+	/**
+	 * Builds a new AnnotationChain.
+	 * 
+	 * @return a new AnnotationChain
+	 */
+	public AnnotationChain createAnnotationChain();
+
+	/**
+	 * Add an {@link AnnotationAssertion} to an {@link AnnotationChain}
+	 * 
+	 * @param annotationChain
+	 * @param annotationAssertion
+	 * @return an {@link Edit}able object with undo feature
+	 */
+	public Edit<AnnotationChain> getAddAnnotationAssertionEdit(
+			AnnotationChain annotationChain,
+			AnnotationAssertion<?> annotationAssertion);
+
+	/**
+	 * Add an {@link AnnotationBeanSPI} to an {@link AnnotationAssertion}
+	 * 
+	 * @param annotationAssertion
+	 * @param annotationBean
+	 * @return the edit which has do/undo functionality
+	 */
+	public <T extends AnnotationBeanSPI> Edit<AnnotationAssertion<T>> getAddAnnotationBean(
+			AnnotationAssertion<T> annotationAssertion,
+			AnnotationBeanSPI annotationBean);
+
+	/**
+	 * Returnes an edit that creates an AnnotationAssertion, adds the
+	 * AnnotationAssertion to an AnnotationChain and adds the AnnotationChain to
+	 * the Annotated.
+	 * 
+	 * @param annotated
+	 *            the Annotated to add an AnnotationChain to
+	 * @param annotation
+	 *            the annotation to add to the chain
+	 * @return an edit that creates and adds an AnnotationChain to an Annotated
+	 */
+	public Edit<?> getAddAnnotationChainEdit(Annotated<?> annotated,
+			AnnotationBeanSPI annotation);
+
+	public <T extends AnnotationBeanSPI> Edit<AnnotationAssertion<T>> getAddAnnotationRole(
+			AnnotationAssertion<T> annotationAssertion,
+			AnnotationRole annotationRole);
+
+	public <T extends AnnotationBeanSPI> Edit<AnnotationAssertion<T>> getAddAnnotationSource(
+			AnnotationAssertion<T> annotationAssertion,
+			AnnotationSourceSPI annotationSource);
+
+	public <T extends AnnotationBeanSPI> Edit<AnnotationAssertion<T>> getAddCreator(
+			AnnotationAssertion<T> annotationAssertion, Person person);
+
+	public <T extends AnnotationBeanSPI, S extends CurationEventBeanSPI> Edit<AnnotationAssertion<T>> getAddCurationEvent(
+			AnnotationAssertion<T> annotationAssertion,
+			CurationEvent<S> curationEvent);
+
+	/**
+	 * Returns an edit to add a DataflowInputPort to a Dataflow.
+	 * 
+	 * @param dataflow
+	 *            dataflow to add the port to
+	 * @param dataflowInputPort
+	 *            the port to add to the dataflow
+	 * @return an edit to add a DataflowInputPort to a Dataflow
+	 */
+	public Edit<Dataflow> getAddDataflowInputPortEdit(Dataflow dataflow,
+			DataflowInputPort dataflowInputPort);
+
+	/**
+	 * Returns an edit to add a DataflowOutputPort to a Dataflow.
+	 * 
+	 * @param dataflow
+	 *            dataflow to add the port to
+	 * @param dataflowOutputPort
+	 *            the port to add to the dataflow
+	 * @return an edit to add a DataflowOutputPort to a Dataflow
+	 */
+	public Edit<Dataflow> getAddDataflowOutputPortEdit(Dataflow dataflow,
+			DataflowOutputPort dataflowOutputPort);
+
+	/**
+	 * Returns an edit to change the depth of a DataflowInputPort.
+	 * 
+	 * @param dataflowInputPort
+	 *            the port to change the depth of
+	 * @param depth
+	 *            the new depth
+	 * @return an edit to change the depth of a Dataflow
+	 */
+	public Edit<DataflowInputPort> getChangeDataflowInputPortDepthEdit(
+			DataflowInputPort dataflowInputPort, int depth);
+
+	/**
+	 * Returns an edit to change the granular depth of a DataflowInputPort.
+	 * 
+	 * @param dataflowInputPort
+	 *            the port to change the granular depth of
+	 * @param granularDepth
+	 *            the new granular depth
+	 * @return an edit to change the granular depth of a Dataflow
+	 */
+	public Edit<DataflowInputPort> getChangeDataflowInputPortGranularDepthEdit(
+			DataflowInputPort dataflowInputPort, int granularDepth);
+
+	/**
+	 * Add a new layer to the specified dispatch stack
+	 * 
+	 * @param stack
+	 *            Stack to add to
+	 * @param layer
+	 *            New dispatch layer to add
+	 * @param position
+	 *            Where to add the new layer? 0 is at the top of the stack.
+	 */
+	public Edit<DispatchStack> getAddDispatchLayerEdit(DispatchStack stack,
+			DispatchLayer<?> layer, int position);
+
+	public Edit<Dataflow> getAddMergeEdit(Dataflow dataflow, Merge processor);
+
+	/**
+	 * Returns an edit to add a MergeInputPort to a Merge.
+	 * 
+	 * @param merge
+	 *            merge to add the port to
+	 * @param mergeInputPort
+	 *            the port to add to the merge
+	 * @return an edit to add a MergeInputPort to a Merge
+	 */
+	public Edit<Merge> getAddMergeInputPortEdit(Merge merge,
+			MergeInputPort mergeInputPort);
+
+	/**
+	 * Returns an edit to reorder the list of MergeInputPortS in a Merge.
+	 * 
+	 * @param merge
+	 *            merge to reorder the list of input ports to
+	 * @param reorderedMergeInputPortList
+	 *            a list of reordered input ports
+	 * @return an edit to reorder the list of MergeInputPortS to a Merge
+	 */
+	public Edit<Merge> getReorderMergeInputPortsEdit(Merge merge,
+			List<MergeInputPort> reorderedMergeInputPortList);
+
+	/**
+	 * Provides an edit object responsible for adding a Processor to a Dataflow
+	 * 
+	 * @param dataflow
+	 *            the dataflow to add this processor to
+	 * @param processor
+	 *            the processor to be added to the dataflow
+	 */
+	public Edit<Dataflow> getAddProcessorEdit(Dataflow dataflow,
+			Processor processor);
+
+	/**
+	 * Provides an Edit to add an input port a processor, creating matching
+	 * ports in the iteration strategy or strategies as a side effect.
+	 * 
+	 * @param processor
+	 *            processor to add the port to
+	 * 
+	 * @param port
+	 *            the input port to be added
+	 */
+	public Edit<Processor> getAddProcessorInputPortEdit(Processor processor,
+			ProcessorInputPort port);
+
+	/**
+	 * Provides an Edit to add a new output port on a processor
+	 * 
+	 * @param processor
+	 *            processor to add the new output port to
+	 * 
+	 * @param port
+	 *            the port to be added
+	 */
+	public Edit<Processor> getAddProcessorOutputPortEdit(Processor processor,
+			ProcessorOutputPort port);
+
+	/**
+	 * Returns an Edit that is responsible for configuring an Activity with a
+	 * given configuration bean.
+	 * 
+	 * @see #getConfigureEdit(Configurable, Object)
+	 * @param activity
+	 * @param configurationBean
+	 * @return
+	 */
+	public <ConfigurationBean> Edit<Activity<?>> getConfigureActivityEdit(
+			Activity<ConfigurationBean> activity,
+			ConfigurationBean configurationBean);
+
+	/**
+	 * Return an Edit that can configure a {@link Configurable} (such as an
+	 * {@link Activity} or {@link DispatchLayer} with a given configuration
+	 * bean.
+	 * 
+	 * @param <ConfigurationType>
+	 * @param configurable
+	 * @param configBean
+	 * @return
+	 */
+	public <ConfigurationType> Edit<? extends Configurable<ConfigurationType>> getConfigureEdit(
+			Configurable<ConfigurationType> configurable,
+			ConfigurationType configBean);
+
+	/**
+	 * Connect a datalink to its source and sink.
+	 * 
+	 * @param datalink
+	 *            the datalink to connect
+	 * @return a datalink edit
+	 */
+	public Edit<Datalink> getConnectDatalinkEdit(Datalink datalink);
+
+	/**
+	 * Creates and returns an instance of an Edit<Merge> that is responsible for
+	 * generating the links to an from the Merge instance to link together the
+	 * source and sink port via the merge instance.
+	 * 
+	 * @return a new instance of Edit<Merge> constructed from the provided
+	 *         parameters.
+	 * 
+	 * @param merge
+	 *            a Merge instance
+	 * @param sourcePort
+	 *            the source port from which a link is to be created.
+	 * @param sinkPort
+	 *            the sink port to which the link is to be created.
+	 * 
+	 * @see Merge
+	 */
+	public Edit<Merge> getConnectMergedDatalinkEdit(Merge merge,
+			EventForwardingOutputPort sourcePort,
+			EventHandlingInputPort sinkPort);
+
+	/**
+	 * Connect the output port of the specified processor to a target input
+	 * port. To connect multiple inputs use this method multiple times with
+	 * different targetPort arguments.
+	 * 
+	 * @param processor
+	 *            Processor to link from
+	 * @param outputPortName
+	 *            Name of the output port within the specified processor to link
+	 *            from
+	 * @param targetPort
+	 *            Input port (specifically an EventHandlingInputPort) to forward
+	 *            data events to.
+	 */
+	public Edit<Processor> getConnectProcessorOutputEdit(Processor processor,
+			String outputPortName, EventHandlingInputPort targetPort);
+
+	/**
+	 * Create a condition governing execution of the target processor. The
+	 * target will not consume jobs from any inputs until all control processors
+	 * linked through this edit have completed.
+	 * 
+	 * @param control
+	 *            Processor controlling execution - this must complete before
+	 *            the target can start.
+	 * @param target
+	 *            Processor controlled by this condition.
+	 */
+	public Edit<OrderedPair<Processor>> getCreateConditionEdit(
+			Processor control, Processor target);
+
+	/**
+	 * Add an input port to a dataflow.
+	 * 
+	 * @param dataflow
+	 *            dataflow to add the port to
+	 * @param portName
+	 *            name of the port, unique in the dataflow
+	 * @param portDepth
+	 *            the conceptual depth of collections consumed by this input
+	 *            port
+	 * @param granularDepth
+	 *            granular depth to copy to the internal output port
+	 */
+	public Edit<Dataflow> getCreateDataflowInputPortEdit(Dataflow dataflow,
+			String portName, int portDepth, int granularDepth);
+
+	/**
+	 * Add an output port to a dataflow.
+	 * 
+	 * @param dataflow
+	 *            dataflow to add the port to
+	 * @param portName
+	 *            name of the port, unique in the dataflow
+	 */
+	public Edit<Dataflow> getCreateDataflowOutputPortEdit(Dataflow dataflow,
+			String portName);
+
+	/**
+	 * Provides an edit that setup the default dispatch stack on a raw
+	 * processor.
+	 * 
+	 * @param processor
+	 * @return
+	 */
+	public Edit<Processor> getDefaultDispatchStackEdit(Processor processor);
+
+	/**
+	 * Remove a dispatch layer from its dispatch stack
+	 * 
+	 * @param stack
+	 *            The stack from which to remove the layer
+	 * @param layer
+	 *            The layer to remove
+	 */
+	public Edit<DispatchStack> getDeleteDispatchLayerEdit(DispatchStack stack,
+			DispatchLayer<?> layer);
+
+	/**
+	 * Disconnect a datalink from its source and sink.
+	 * 
+	 * @param datalink
+	 *            the datalink to disconnect
+	 * @return a datalink edit
+	 */
+	public Edit<Datalink> getDisconnectDatalinkEdit(Datalink datalink);
+
+	/**
+	 * Provides an edit that will configure the processors ports to map to those
+	 * of its internal Activity. If there is more than 1 activity then only
+	 * first activity is used. If there are zero then an EditException will be
+	 * thrown when using the Edit.
+	 * 
+	 * @param processor
+	 * @return
+	 */
+	public Edit<Processor> getMapProcessorPortsForActivityEdit(
+			Processor processor);
+
+	/**
+	 * Returns an edit to remove an Activity from a Processor
+	 */
+	public Edit<Processor> getRemoveActivityEdit(Processor processor,
+			Activity<?> activity);
+
+	/**
+	 * Returns an edit to remove an ActivityInputPort from an Activity.
+	 * 
+	 * @param activity
+	 *            activity to remove the port from
+	 * @param activityInputPort
+	 *            the port to remove from the activity
+	 * @return an edit to remove an ActivityInputPort from an Activity
+	 */
+	public Edit<Activity<?>> getRemoveActivityInputPortEdit(
+			Activity<?> activity, ActivityInputPort activityInputPort);
+
+	/**
+	 * Returns an edit to remove a ProcessorInputPort to ActivityInputPort
+	 * mapping from an Activity.
+	 * 
+	 * @param activity
+	 *            activity to remove the port mapping from
+	 * @param processorPortName
+	 *            the name of the processor port to remove from the mapping
+	 * @return an edit to remove a ProcessorInputPort to ActivityInputPort
+	 *         mapping from an Activity
+	 */
+	public Edit<Activity<?>> getRemoveActivityInputPortMappingEdit(
+			Activity<?> activity, String processorPortName);
+
+	/**
+	 * Returns an edit to remove an OutputPort from an Activity.
+	 * 
+	 * @param activity
+	 *            activity to remove the port from
+	 * @param activityOutputPort
+	 *            the port to remove from the activity
+	 * @return an edit to remove an OutputPort from an Activity
+	 */
+	public Edit<Activity<?>> getRemoveActivityOutputPortEdit(
+			Activity<?> activity, ActivityOutputPort activityOutputPort);
+
+	/**
+	 * Returns an edit to remove a ProcessorOutputPort to OutputPort mapping
+	 * from an Activity.
+	 * 
+	 * @param activity
+	 *            activity to remove the port mapping from
+	 * @param processorPortName
+	 *            the name of the processor port to remove from the mapping
+	 * @return an edit to remove a ProcessorOutputPort to OutputPort mapping
+	 *         from an Activity
+	 */
+	public Edit<Activity<?>> getRemoveActivityOutputPortMappingEdit(
+			Activity<?> activity, String processorPortName);
+
+	/**
+	 * Remove a condition previously applied to the specified pair of Processor
+	 * instances
+	 * 
+	 * @param control
+	 *            Processor controlling execution - this must complete before
+	 *            the target can start.
+	 * @param target
+	 *            Processor controlled by this condition.
+	 * @return
+	 */
+	public Edit<OrderedPair<Processor>> getRemoveConditionEdit(
+			Processor control, Processor target);
+
+	/**
+	 * Returns an edit to remove a DataflowInputPort from a Dataflow.
+	 * 
+	 * @param dataflow
+	 *            the Dataflow to remove this DataflowInputPort from
+	 * @param dataflowInputPort
+	 *            the DataflowInputPort to be removed from the Dataflow
+	 */
+	public Edit<Dataflow> getRemoveDataflowInputPortEdit(Dataflow dataflow,
+			DataflowInputPort dataflowInputPort);
+
+	/**
+	 * Returns an edit to remove a DataflowOutputPort from a Dataflow.
+	 * 
+	 * @param dataflow
+	 *            the Dataflow to remove this DataflowOutputPort from
+	 * @param dataflowOutputPort
+	 *            the DataflowOutputPort to be removed from the Dataflow
+	 */
+	public Edit<Dataflow> getRemoveDataflowOutputPortEdit(Dataflow dataflow,
+			DataflowOutputPort dataflowOutputPort);
+
+	/**
+	 * Returns an edit to remove a Processor from a Dataflow.
+	 * 
+	 * @param dataflow
+	 *            the dataflow to remove the processor from
+	 * @param processor
+	 *            the processor to be removed from the dataflow
+	 */
+	public Edit<Dataflow> getRemoveProcessorEdit(Dataflow dataflow,
+			Processor processor);
+
+	/**
+	 * Removes a Processor input port.
+	 * 
+	 * @param processor
+	 * @param port
+	 * @return
+	 */
+	public Edit<Processor> getRemoveProcessorInputPortEdit(Processor processor,
+			ProcessorInputPort port);
+
+	/**
+	 * @param processor
+	 * @param port
+	 * @return
+	 */
+	public Edit<Processor> getRemoveProcessorOutputPortEdit(
+			Processor processor, ProcessorOutputPort port);
+
+	/**
+	 * Removes a merge from the dataflow.
+	 * 
+	 * @param dataflow
+	 * @param processor
+	 * @return
+	 */
+	public Edit<Dataflow> getRemoveMergeEdit(Dataflow dataflow, Merge merge);
+
+	/**
+	 * Rename a dataflow input port
+	 * 
+	 * @param dataflowInputPort
+	 *            the dataflow input port to rename
+	 * @param newName
+	 *            the new name, must be unique within the workflow enclosing the
+	 *            dataflow input port instance
+	 */
+	public Edit<DataflowInputPort> getRenameDataflowInputPortEdit(
+			DataflowInputPort dataflowInputPort, String newName);
+
+	/**
+	 * Rename a dataflow output port
+	 * 
+	 * @param dataflowOutputPort
+	 *            the dataflow output port to rename
+	 * @param newName
+	 *            the new name, must be unique within the workflow enclosing the
+	 *            dataflow output port instance
+	 */
+	public Edit<DataflowOutputPort> getRenameDataflowOutputPortEdit(
+			DataflowOutputPort dataflowOutputPort, String newName);
+
+	/**
+	 * Rename a processor
+	 * 
+	 * @param processor
+	 *            the processor to rename
+	 * @param newName
+	 *            the new name, must be unique within the workflow enclosing the
+	 *            processor instance
+	 */
+	public Edit<Processor> getRenameProcessorEdit(Processor processor,
+			String newName);
+
+	/**
+	 * Rename a merge
+	 * 
+	 * @param merge
+	 *            the merge to rename
+	 * @param newName
+	 *            the new name, must be unique within the workflow enclosing the
+	 *            merge instance
+	 */
+	public Edit<Merge> getRenameMergeEdit(Merge merge, String newName);
+
+	/**
+	 * Provide an edit that will configure a processors's iteration strategy
+	 * stack to the one provided.
+	 * 
+	 * @param processor
+	 *            Processor which iteration stack is to be set
+	 * @param iterationStrategyStack
+	 *            The new iteration strategy stack
+	 * @return An Edit that will set the iteration strategy stack of a processor
+	 */
+	public Edit<Processor> getSetIterationStrategyStackEdit(
+			Processor processor, IterationStrategyStack iterationStrategyStack);
+
+	public Edit<IterationStrategyStack> getClearIterationStrategyStackEdit(
+			IterationStrategyStack iterationStrategyStack);
+
+	public Edit<IterationStrategyStack> getAddIterationStrategyEdit(
+			IterationStrategyStack iterationStrategyStack,
+			IterationStrategy iterationStrategy);
+
+	public Edit<IterationStrategy> getAddIterationStrategyInputNodeEdit(
+			IterationStrategy iterationStrategy,
+			NamedInputPortNode namedInputPortNode);
+
+	public Edit<Dataflow> getUpdateDataflowInternalIdentifierEdit(
+			Dataflow dataflow, String newId);
+
+	public Edit<Dataflow> getUpdateDataflowNameEdit(Dataflow dataflow,
+			String newName);
+
+	/**
+	 * Builds an instance of an {@link InputPort} for an Activity.
+	 * 
+	 * @param portName
+	 * @param portDepth
+	 * @param allowsLiteralValues
+	 *            whether the input port can cope with literal values
+	 * @param handledReferenceSchemes
+	 *            a list of the reference scheme types that can be legitimately
+	 *            pushed into this input port
+	 * @param translatedElementClass
+	 *            the class desired as result (or elements of collections of
+	 *            results) when interpreted by the data facade
+	 * @return an instance of InputPort
+	 */
+	ActivityInputPort createActivityInputPort(
+			String portName,
+			int portDepth,
+			boolean allowsLiteralValues,
+			List<Class<? extends ExternalReferenceSPI>> handledReferenceSchemes,
+			Class<?> translatedElementClass);
+
+	/**
+	 * Builds an instance of an {@link ActivityOutputPort} for an Activity.
+	 * 
+	 * @param portName
+	 * @param portDepth
+	 * @param portGranularDepth
+	 * @return an instance of ActivityOutputPort
+	 */
+	ActivityOutputPort createActivityOutputPort(String portName, int portDepth,
+			int portGranularDepth);
+
+	/**
+	 * Creates a new ProcessorInputPort
+	 * 
+	 * @param processor
+	 *            the processor to with the port will be added
+	 * @param name
+	 * @param depth
+	 * @return
+	 */
+	ProcessorInputPort createProcessorInputPort(Processor processor,
+			String name, int depth);
+
+	/**
+	 * Creates a new ProcessorOutputPort
+	 * 
+	 * @param processor
+	 * @param name
+	 * @param depth
+	 * @param granularDepth
+	 * @return
+	 */
+	ProcessorOutputPort createProcessorOutputPort(Processor processor,
+			String name, int depth, int granularDepth);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/EventForwardingOutputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/EventForwardingOutputPort.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/EventForwardingOutputPort.java
new file mode 100644
index 0000000..55d70ba
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/EventForwardingOutputPort.java
@@ -0,0 +1,45 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+import java.util.Set;
+
+/**
+ * An extension of OutputPort defining a set of target EventReceivingInputPorts
+ * to which internally generated events will be relayed. This is the interface
+ * used by output ports on a workflow entity with internal logic generating or
+ * relaying events.
+ * 
+ * @author Tom Oinn
+ */
+public interface EventForwardingOutputPort extends OutputPort {
+	/**
+	 * The set of EventHandlingInputPort objects which act as targets for events
+	 * produced from this OutputPort
+	 * 
+	
+	public Set<EventHandlingInputPort> getTargets();
+*/ //FIXME What is happening here???
+
+	/**
+	 * The set of datalinks for which this output port is the source of events
+	 */
+	Set<? extends Datalink> getOutgoingLinks();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/EventHandlingInputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/EventHandlingInputPort.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/EventHandlingInputPort.java
new file mode 100644
index 0000000..8328850
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/EventHandlingInputPort.java
@@ -0,0 +1,40 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+import org.apache.taverna.invocation.WorkflowDataToken;
+
+/**
+ * Input port capable of receiving and reacting to workflow events.
+ * 
+ * @author Tom Oinn
+ */
+public interface EventHandlingInputPort extends InputPort {
+	/**
+	 * Receive an arbitrary workflow event.
+	 */
+	void receiveEvent(WorkflowDataToken t);
+
+	/**
+	 * If this port is connected to a Datalink return the link, otherwise return
+	 * null
+	 */
+	Datalink getIncomingLink();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/FailureTransmitter.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/FailureTransmitter.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/FailureTransmitter.java
new file mode 100644
index 0000000..00f1922
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/FailureTransmitter.java
@@ -0,0 +1,33 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+/**
+ * Used to message interested parties when a top level failure occurs within a
+ * {@link Dataflow}
+ * <p>
+ * Not implemented in the current code, this is a placeholder for the failure
+ * handling system.
+ * 
+ * @author Tom Oinn
+ */
+public interface FailureTransmitter {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/FilteringInputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/FilteringInputPort.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/FilteringInputPort.java
new file mode 100644
index 0000000..e29edaf
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/FilteringInputPort.java
@@ -0,0 +1,51 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+/**
+ * A filtering input port is one capable of filtering events to only pass
+ * through data events at a certain depth. Other events are either ignored (in
+ * the case of finer granularity) or converted to completion events (for
+ * coarser). Where the filter depth and the port depth are distinct this port
+ * type will filter on the filter depth then drill into the data to get down to
+ * the port depth. Filter depth must always be equal to or greater than port
+ * depth.
+ * <p>
+ * This is used as the interface for Processor input ports.
+ * <p>
+ * A condition to use this type is that the stream of events for a given process
+ * ID must terminate with a top level (i.e. zero length index array) token. This
+ * can be accomplished by use of the crystalizer (as found on the output of a
+ * Processor instance) or some other mechanism but is required. Similarly it is
+ * assumed that all intermediate collections are emited in the correct sequence,
+ * if this is not the case the filtering may not function correctly.
+ * 
+ * @author Tom Oinn
+ */
+public interface FilteringInputPort extends EventHandlingInputPort {
+	/**
+	 * Set the depth at which to filter events. Events at a lower depth than
+	 * this are ignored completely, those at exactly this depth are passed
+	 * through intact and those above are converted to completion events.
+	 * 
+	 * @param filterDepth
+	 */
+	int getFilterDepth();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/InputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/InputPort.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/InputPort.java
new file mode 100644
index 0000000..037d582
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/InputPort.java
@@ -0,0 +1,29 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+/**
+ * Marker interface denoting that the instance is an input port.
+ * 
+ * @author Tom Oinn
+ */
+public interface InputPort extends Port {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/InvalidDataflowException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/InvalidDataflowException.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/InvalidDataflowException.java
new file mode 100644
index 0000000..0dcc525
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/InvalidDataflowException.java
@@ -0,0 +1,62 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+/**
+ * Thrown if attempting to use a workflow that is not
+ * {@link Dataflow#checkValidity() valid}.
+ * <p>
+ * The {@link DataflowValidationReport} can be retrieved using
+ * {@link #getDataflowValidationReport()} and will provide details on how the
+ * dataflow is invalid. The {@link #getDataflow()} will provide the invalid
+ * dataflow.
+ * 
+ * @author Stian Soiland-Reyes
+ */
+public class InvalidDataflowException extends Exception {
+	private static final long serialVersionUID = -8470683930687738369L;
+	private final DataflowValidationReport report;
+	private final Dataflow dataflow;
+
+	public InvalidDataflowException(Dataflow dataflow,
+			DataflowValidationReport report) {
+		this.report = report;
+		this.dataflow = dataflow;
+	}
+
+	/**
+	 * Get the {@link DataflowValidationReport validation report} for the
+	 * failing dataflow.
+	 * 
+	 * @return Dataflow validation report
+	 */
+	public DataflowValidationReport getDataflowValidationReport() {
+		return report;
+	}
+
+	/**
+	 * Get the {@link Dataflow} that is not valid.
+	 * 
+	 * @return Invalid Dataflow
+	 */
+	public Dataflow getDataflow() {
+		return dataflow;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Merge.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Merge.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Merge.java
new file mode 100644
index 0000000..66532a3
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Merge.java
@@ -0,0 +1,62 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+import java.util.List;
+
+/**
+ * Allows multiple outputs to be routed to a single input within the dataflow.
+ * The merge operation defines a total order over its input ports, this order is
+ * used to modify the index array of all incoming events by adding the port
+ * index as a prefix to that array. At a conceptual level this means that any
+ * event coming in is 'binned' by port index creating a collection of whatever
+ * the port type was. This also places a constraint that all input ports must
+ * have the same cardinality (i.e. depth + length of index array must be equal
+ * for all events on all ports). If this constraint is violated the merge
+ * operation is free to throw a WorkflowStructureException at runtime although
+ * it would be preferable if implementing classes were capable of static type
+ * analysis to preclude this from happening.
+ * 
+ * @author Tom Oinn
+ */
+public interface Merge extends TokenProcessingEntity {
+	/**
+	 * The Merge object contains an ordered list of InputPort objects. Data and
+	 * completion events arriving at an input port have the index of that input
+	 * within the list prepended to their index array, effectively placing them
+	 * in a virtual collection the top level of which corresponds to the various
+	 * input ports defined within the Merge node. When final completion events
+	 * from all input ports are received the Merge object registers the top
+	 * level collection with the attached DataManager and emits it and the
+	 * completion event through the single output port.
+	 * 
+	 * @return Ordered list of InputPort objects
+	 */
+	@Override
+	List<? extends MergeInputPort> getInputPorts();
+
+	/**
+	 * The Merge object has a single output port through which modified events
+	 * are emitted as described in the javadoc for getInputPorts
+	 * 
+	 * @return OutputPort for this Merge object
+	 */
+	EventForwardingOutputPort getOutputPort();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/MergeInputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/MergeInputPort.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/MergeInputPort.java
new file mode 100644
index 0000000..ed1a200
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/MergeInputPort.java
@@ -0,0 +1,51 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+import org.apache.taverna.invocation.WorkflowDataToken;
+
+/**
+ * Input port on a Merge object
+ * 
+ * @author Tom Oinn
+ * @author Stian Soiland-Reyes
+ */
+public interface MergeInputPort extends EventHandlingInputPort, MergePort {
+	/**
+	 * Receive an arbitrary workflow event. The index of this port relative to
+	 * its parent Merge object is prepended to the event index and the event
+	 * forwarded through the Merge output port to any targets.
+	 * <p>
+	 * If this is a workflow data token and the first such received under a
+	 * given owning process ID the implementing method also must also store the
+	 * cardinality, i.e. length of index array + depth of token. Subsequent
+	 * events are matched to this, if they have unequal cardinality the parent
+	 * Merge operation will throw a WorkflowStructureException as the merge
+	 * would result in a collection which violated the constraints defined by
+	 * the Taverna 2 data model.
+	 * 
+	 * @param e
+	 *            arbitrary workflow event, will be forwarded unchanged other
+	 *            than an alteration of the index array by prefixing the index
+	 *            of this input port relative to the parent Merge object
+	 */
+	@Override
+	public void receiveEvent(WorkflowDataToken t);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/MergeOutputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/MergeOutputPort.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/MergeOutputPort.java
new file mode 100644
index 0000000..19d4e2c
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/MergeOutputPort.java
@@ -0,0 +1,34 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+/**
+ * An EventForwardingOutputPort that is associated with Merge instances.
+ * In particular it provides access to the Merge instance it is associated with.
+ * 
+ * @see Merge
+ * @see MergePort
+ * @see EventForwardingOutputPort
+ * 
+ * @author Stuart Owen
+ * @author Stian Soiland-Reyes
+ */
+public interface MergeOutputPort extends EventForwardingOutputPort, MergePort {
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/MergePort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/MergePort.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/MergePort.java
new file mode 100644
index 0000000..640ee5c
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/MergePort.java
@@ -0,0 +1,34 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+/**
+ * An input or output {@link Port} for a {@link Merge}.
+ * 
+ * @see MergeInputPort
+ * @see MergeOutputPort
+ * @author Stian Soiland-Reyes
+ */
+public interface MergePort extends Port {
+	/**
+	 * @return the Merge instance the port is associated with. 
+	 */
+	Merge getMerge();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/NamedWorkflowEntity.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/NamedWorkflowEntity.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/NamedWorkflowEntity.java
new file mode 100644
index 0000000..6e2a93c
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/NamedWorkflowEntity.java
@@ -0,0 +1,44 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+/**
+ * Entities existing directly within a workflow such as Processors, Merge
+ * operators and other potential future extensions exist within a naming scheme.
+ * The local name of an entity is unique relative to the enclosing workflow.
+ * Global names are not defined outside of the context of a given instance of a
+ * workflow as the same workflow may be re-used in multiple other workflows,
+ * there is therefore no single parent defined for some entities and the
+ * approach of traversing the hierarchy to build a fully qualified name cannot
+ * be applied. A given instance can be treated this way but this depends on
+ * dataflow rather than inherent workflow structure.
+ * <p>
+ * All named workflow entities support the sticky note annotation type
+ * 
+ * @author Tom Oinn
+ */
+public interface NamedWorkflowEntity extends WorkflowItem {
+	/**
+	 * Every workflow level entity has a name which is unique within the
+	 * workflow in which it exists. This only applies to the immediate parent
+	 * workflow, names may be duplicated in child workflows etc.
+	 */
+	String getLocalName();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/NamingException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/NamingException.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/NamingException.java
new file mode 100644
index 0000000..83beed6
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/NamingException.java
@@ -0,0 +1,46 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+/**
+ * Potentially thrown when an edit fails due to naming of entities created or
+ * modified by the edit. This could be because there are duplicate names in e.g.
+ * processor input ports or invalid characters in the name itself
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public class NamingException extends EditException {
+
+	private static final long serialVersionUID = -6945542133180017313L;
+
+	public NamingException(String message) {
+		super(message);
+	}
+
+	public NamingException(Throwable cause) {
+		super(cause);
+	}
+
+	public NamingException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/OrderedPair.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/OrderedPair.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/OrderedPair.java
new file mode 100644
index 0000000..2f394b4
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/OrderedPair.java
@@ -0,0 +1,84 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+/**
+ * A simple generic class to hold a pair of same type objects. Used by various
+ * Edit implementations that operate on pairs of Processors amongst other
+ * things.
+ * 
+ * @author Tom Oinn
+ * 
+ * @param <T>
+ *            Type of the pair of contained objects
+ */
+public class OrderedPair<T> {
+	private T a, b;
+
+	/**
+	 * Build a new ordered pair with the specified objects.
+	 * 
+	 * @throws RuntimeException
+	 *             if either a or b are null
+	 * @param a
+	 * @param b
+	 */
+	public OrderedPair(T a, T b) {
+		if (a == null || b == null)
+			throw new RuntimeException(
+					"Cannot construct ordered pair with null arguments");
+		this.a = a;
+		this.b = b;
+	}
+
+	/**
+	 * Return object a
+	 */
+	public T getA() {
+		return this.a;
+	}
+
+	/**
+	 * Return object b
+	 */
+	public T getB() {
+		return this.b;
+	}
+
+	/**
+	 * A pair of objects (a,b) is equal to another pair (c,d) if and only if a,
+	 * b, c and d are all the same type and the condition (a.equals(c) &
+	 * b.equals(d)) is true.
+	 */
+	@Override
+	public boolean equals(Object other) {
+		if (!(other instanceof OrderedPair))
+			return false;
+		OrderedPair<?> op = (OrderedPair<?>) other;
+		return (a.equals(op.getA()) && b.equals(op.getB()));
+	}
+
+	@Override
+	public int hashCode() {
+		int aHash = a.hashCode();
+		int bHash = b.hashCode();
+		return (aHash << 16) | (aHash >> 16) | bHash;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/OutputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/OutputPort.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/OutputPort.java
new file mode 100644
index 0000000..a484ca6
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/OutputPort.java
@@ -0,0 +1,45 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+/**
+ * Port representing the output of an activity, processor or workflow. In
+ * addition to the name and port depth defined by the Port interface this
+ * includes a granular depth property. The granular depth of an output is the
+ * depth of the finest grained entity that can be emitted from that port. For
+ * example, if a process conceptually returned a list of strings but was
+ * actually capable of streaming strings as they were generated it would set a
+ * port depth of 1 and granular depth of zero.
+ * 
+ * @author Tom Oinn
+ */
+public interface OutputPort extends Port {
+	/**
+	 * The granular depth is the depth of the finest grained item that can be
+	 * emitted from this output port. A difference in this and the port depth
+	 * indicates that the entity this port is attached to is capable of
+	 * streaming data resulting from a single process invocation. The port depth
+	 * defines the conceptual depth, so a process returning a stream of single
+	 * items would set port depth to 1 and granular depth to zero.
+	 * 
+	 * @return granular depth of output port
+	 */
+	int getGranularDepth();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Port.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Port.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Port.java
new file mode 100644
index 0000000..e905455
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Port.java
@@ -0,0 +1,34 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+import org.apache.taverna.annotation.Annotated;
+
+/**
+ * Named port which receives events from some other entity and handles them
+ * appropriately.
+ * 
+ * @author Tom Oinn
+ */
+public interface Port extends Annotated<Port>, WorkflowItem {
+	String getName();
+
+	int getDepth();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Processor.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Processor.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Processor.java
new file mode 100644
index 0000000..211f433
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/Processor.java
@@ -0,0 +1,149 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+import static org.apache.taverna.annotation.HierarchyRole.CHILD;
+
+import java.util.List;
+
+import org.apache.taverna.annotation.Annotated;
+import org.apache.taverna.annotation.HierarchyTraversal;
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.lang.observer.Observable;
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+import org.apache.taverna.workflowmodel.processor.dispatch.DispatchStack;
+import org.apache.taverna.workflowmodel.processor.iteration.IterationStrategyStack;
+
+/**
+ * A single node within the dataflow digraph, the Processor is the basic
+ * functional unit within a Taverna workflow. It should also notify interested
+ * observers when it has finished execution (including all iterations of the
+ * processor).
+ * 
+ * @author Tom Oinn
+ * @author Alex Nenadic
+ */
+@ControlBoundary
+public interface Processor extends TokenProcessingEntity, Annotated<Processor>,
+		Observable<ProcessorFinishedEvent>, WorkflowItem {
+	/**
+	 * The iteration strategy is responsible for combining input data events
+	 * into jobs which are then queued for execution through the dispatch stack
+	 * 
+	 * @return IterationStrategyStack containing one or more IterationStrategy
+	 *         objects. In most cases this will only contain a single
+	 *         IterationStrategy but there are particular scenarios where
+	 *         staging partial iteration strategies together is the only way to
+	 *         get the desired combination of inputs
+	 */
+	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
+	IterationStrategyStack getIterationStrategy();
+
+	/**
+	 * Each processor has a list of zero or more input ports. These are uniquely
+	 * named within the list. Any input port may have a default value associated
+	 * with it and may be attached to exactly one upstream output port. Where it
+	 * is necessary to connect a single input port to multiple output ports a
+	 * Merge object is used. Ordering within the list is not meaningful but we
+	 * use List rather than Set to preserve the ordering across serialisation
+	 * operations.
+	 * <p>
+	 * Processor inputs are instances of FilteringInputPort - they must have the
+	 * filter depth set before any data events arrive at the Processor. In
+	 * addition they assume that a full collection will be supplied, i.e. that
+	 * there will be exactly one event at the end of the list of events for a
+	 * given process ID with an index array of length zero.
+	 * 
+	 * @return List of named input ports
+	 */
+	@Override
+	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
+	List<? extends ProcessorInputPort> getInputPorts();
+
+	/**
+	 * Each processor has a list of zero or more output ports. Output ports are
+	 * uniquely named within the list and may be connected to arbitrarily many
+	 * downstream input ports or Merge objects. Ordering within the list is not
+	 * meaningful but we use List rather than Set to preserve the ordering
+	 * across serialisation operations.
+	 * 
+	 * @return List of named output ports
+	 */
+	@Override
+	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
+	List<? extends ProcessorOutputPort> getOutputPorts();
+
+	/**
+	 * The dispatch stack pulls jobs from the queue generated by the iteration
+	 * system and handles the dispatch of these jobs to appropriate activity
+	 * workers
+	 * 
+	 * @return the DispatchStackImpl for this processor
+	 */
+	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
+	DispatchStack getDispatchStack();
+
+	/**
+	 * A processor contains zero or more activities in an ordered list. To be
+	 * any use in a workflow the processor should contain at least one activity
+	 * but it's technically valid to have none! Activities may be abstract or
+	 * concrete where an abstract activity is one with no invocation mechanism,
+	 * in these cases additional logic must be added to the dispatch stack of
+	 * the containing processor to convert these to concrete invokable
+	 * activities during the workflow invocation.
+	 * 
+	 * @return list of Activity instances
+	 */
+	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
+	List<? extends Activity<?>> getActivityList();
+
+	/**
+	 * A processor with no inputs cannot be driven by the supply of data tokens
+	 * as it has nowhere to receive such tokens. This method allows a processor
+	 * to fire on an empty input set, in this case the owning process identifier
+	 * must be passed explicitly to the processor. Internally this pushes a
+	 * single empty job event into the dispatch queue, bypassing the iteration
+	 * logic (which is entirely predicated on the existence of input ports).
+	 * Callers must ensure that an appropriate process identifier is specified,
+	 * the behaviour on missing or duplicate process identifiers is not defined.
+	 */
+	void fire(String owningProcess, InvocationContext context);
+
+	/**
+	 * A processor has zero or more preconditions explicitly declared. All such
+	 * preconditions must be satisfied before any jobs are passed into the
+	 * dispatch stack. These preconditions replace and generalise the
+	 * coordination constraints from Taverna 1.
+	 * 
+	 * @return a List of Condition objects defining constraints on this
+	 *         processor's execution
+	 */
+	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
+	List<? extends Condition> getPreconditionList();
+
+	/**
+	 * A processor may control zero or more other processors within the same
+	 * level of the workflow through preconditions.
+	 * 
+	 * @return a List of Condition objects for which this is the controlling
+	 *         processor
+	 */
+	List<? extends Condition> getControlledPreconditionList();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ProcessorFinishedEvent.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ProcessorFinishedEvent.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ProcessorFinishedEvent.java
new file mode 100644
index 0000000..944a6fa
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ProcessorFinishedEvent.java
@@ -0,0 +1,53 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+/**
+ * 
+ * An event saying that a processor with a given owning process has finished with execution
+ * (that includes the whole dispatch stack - iterations of the processor and all).
+ * 
+ * @author Alex Nenadic
+ */
+public class ProcessorFinishedEvent {
+	private Processor processor;
+	private String owningProcess;
+	
+	public ProcessorFinishedEvent(Processor processor, String owningProcess) {
+		this.setProcessor(processor);
+		this.setOwningProcess(owningProcess);
+	}
+
+	public void setOwningProcess(String owningProcess) {
+		this.owningProcess = owningProcess;
+	}
+
+	public String getOwningProcess() {
+		return owningProcess;
+	}
+
+	public void setProcessor(Processor processor) {
+		this.processor = processor;
+	}
+
+	public Processor getProcessor() {
+		return processor;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ProcessorInputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ProcessorInputPort.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ProcessorInputPort.java
new file mode 100644
index 0000000..9399af8
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ProcessorInputPort.java
@@ -0,0 +1,29 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+/**
+ * Input port on a Processor, is both a filtering input port and a processor
+ * port
+ * 
+ * @author Tom Oinn
+ */
+public interface ProcessorInputPort extends FilteringInputPort, ProcessorPort {
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ProcessorOutputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ProcessorOutputPort.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ProcessorOutputPort.java
new file mode 100644
index 0000000..8538880
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ProcessorOutputPort.java
@@ -0,0 +1,30 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+/**
+ * Input port on a Processor, is both an event forwarding output port and a
+ * processor port
+ * 
+ * @author Tom Oinn
+ */
+public interface ProcessorOutputPort extends EventForwardingOutputPort,
+		ProcessorPort {
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ProcessorPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ProcessorPort.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ProcessorPort.java
new file mode 100644
index 0000000..4fb85bf
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/ProcessorPort.java
@@ -0,0 +1,31 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+/**
+ * An {@link ProcessorInputPort} or {@link ProcessorOutputPort} belonging to a
+ * {@link Processor}.
+ */
+public interface ProcessorPort extends Port {
+	/**
+	 * Get the Processor to which this port belongs
+	 */
+	public Processor getProcessor();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/RunDeletionListener.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/RunDeletionListener.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/RunDeletionListener.java
new file mode 100644
index 0000000..9dcd902
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/RunDeletionListener.java
@@ -0,0 +1,31 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+/**
+ * A RunDeletionListener is notified when a run is deleted. It is then able to
+ * take any specific action needed to deal with the deletion of the run, for
+ * example deleting data that is not held within Taverna.
+ * 
+ * @author alanrw
+ */
+public interface RunDeletionListener {
+	void deleteRun(String runToDelete);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/TokenProcessingEntity.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/TokenProcessingEntity.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/TokenProcessingEntity.java
new file mode 100644
index 0000000..df106cf
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/TokenProcessingEntity.java
@@ -0,0 +1,56 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+import static org.apache.taverna.annotation.HierarchyRole.CHILD;
+
+import java.util.List;
+
+import org.apache.taverna.annotation.HierarchyTraversal;
+import org.apache.taverna.workflowmodel.processor.iteration.IterationTypeMismatchException;
+
+/**
+ * Superinterface for all classes within the workflow model which consume and
+ * emit workflow data tokens.
+ * 
+ * @author Tom Oinn
+ */
+public interface TokenProcessingEntity extends NamedWorkflowEntity {
+	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
+	List<? extends EventHandlingInputPort> getInputPorts();
+
+	@HierarchyTraversal(hierarchies = { "workflowStructure" }, role = { CHILD })
+	List<? extends EventForwardingOutputPort> getOutputPorts();
+
+	/**
+	 * Run a collection level based type check on the token processing entity
+	 * 
+	 * @return true if the typecheck was successful or false if the check failed
+	 *         because there were preconditions missing such as unsatisfied
+	 *         input types
+	 * @throws IterationTypeMismatchException
+	 *             if the typing occurred but didn't match because of an
+	 *             iteration mismatch
+	 * @throws InvalidDataflowException
+	 *             if the entity depended on a dataflow that was not valid
+	 */
+	boolean doTypeCheck() throws IterationTypeMismatchException,
+			InvalidDataflowException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/WorkflowItem.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/WorkflowItem.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/WorkflowItem.java
new file mode 100644
index 0000000..cc7a40a
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/WorkflowItem.java
@@ -0,0 +1,47 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+import org.apache.taverna.workflowmodel.processor.dispatch.DispatchStack;
+import org.apache.taverna.workflowmodel.processor.iteration.IterationStrategy;
+
+/**
+ * An item that forms a structural part of a Workflow.
+ * 
+ * Workflow item are {@link Dataflow}, its {@link Processor} and {@link Port}
+ * s, and other deeper structural parts like {@link DispatchStack} and
+ * {@link IterationStrategy}.
+ * 
+ * @author Stian Soiland-Reyes
+ */
+public interface WorkflowItem {
+	// FIXME: Should this be deleted?
+    // TODO: Implement this for every WorkflowItem
+    
+//    /**
+//     * Mark this item (and its child WorkflowItems) as immutable.
+//     * 
+//     * Subsequent edits to its structural components will
+//     * throw a RuntimeException like UnsupportedOperationException.
+//     * 
+//     */
+//    public void setImmutable();
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/WorkflowStructureException.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/WorkflowStructureException.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/WorkflowStructureException.java
new file mode 100644
index 0000000..4955b78
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/WorkflowStructureException.java
@@ -0,0 +1,35 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel;
+
+/**
+ * Thrown predominantly at runtime under circumstances that suggest an
+ * inconsistancy in the workflow model. This might include attempting to feed
+ * data into a port that doesn't exist or has an unknown name or similar errors.
+ * 
+ * @author Tom OInn
+ */
+public class WorkflowStructureException extends RuntimeException {
+	private static final long serialVersionUID = 1L;
+
+	public WorkflowStructureException(String string) {
+		super(string);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/DisabledActivityHealthChecker.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/DisabledActivityHealthChecker.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/DisabledActivityHealthChecker.java
new file mode 100644
index 0000000..b4072d4
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/health/DisabledActivityHealthChecker.java
@@ -0,0 +1,64 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.health;
+
+import static org.apache.taverna.visit.VisitReport.Status.SEVERE;
+import static org.apache.taverna.workflowmodel.health.HealthCheck.DISABLED;
+
+import java.util.List;
+
+import org.apache.taverna.visit.VisitReport;
+import org.apache.taverna.workflowmodel.processor.activity.DisabledActivity;
+
+/**
+ * Check on the health of a DisabledActivity
+ * 
+ * @author alanrw
+ * 
+ */
+public class DisabledActivityHealthChecker implements
+		HealthChecker<DisabledActivity> {
+
+	/**
+	 * The visitor can visit DisabledActivitys.
+	 */
+	@Override
+	public boolean canVisit(Object o) {
+		return ((o != null) && (o instanceof DisabledActivity));
+	}
+
+	/**
+	 * The check is not time consuming as it simply constructs a VisitReport
+	 */
+	@Override
+	public boolean isTimeConsuming() {
+		return false;
+	}
+
+	/**
+	 * The result of the visit is simply a VisitReport to state that the service
+	 * is not available.
+	 */
+	@Override
+	public VisitReport visit(DisabledActivity o, List<Object> ancestry) {
+		return new VisitReport(HealthCheck.getInstance(), o,
+				"Service is not available", DISABLED, SEVERE);
+	}
+}


[02/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/monitor/impl/MonitorTreeModel.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/monitor/impl/MonitorTreeModel.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/monitor/impl/MonitorTreeModel.java
new file mode 100644
index 0000000..428c050
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/monitor/impl/MonitorTreeModel.java
@@ -0,0 +1,422 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.monitor.impl;
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Set;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import javax.swing.JFrame;
+import javax.swing.JScrollPane;
+import javax.swing.JTree;
+import javax.swing.SwingUtilities;
+import javax.swing.event.TreeModelEvent;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.MutableTreeNode;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+
+import org.apache.taverna.lang.observer.Observable;
+import org.apache.taverna.lang.observer.Observer;
+import org.apache.taverna.monitor.MonitorNode;
+import org.apache.taverna.monitor.MonitorableProperty;
+import org.apache.taverna.monitor.NoSuchPropertyException;
+import org.apache.taverna.monitor.MonitorManager.AddPropertiesMessage;
+import org.apache.taverna.monitor.MonitorManager.DeregisterNodeMessage;
+import org.apache.taverna.monitor.MonitorManager.MonitorMessage;
+import org.apache.taverna.monitor.MonitorManager.RegisterNodeMessage;
+
+import org.apache.log4j.Logger;
+
+/**
+ * A relatively naive Monitor interface which holds all
+ * state in a tree model. Use getMonitor() to get the monitor singleton, all
+ * workflows under a given JVM use the same instance in this implementation with
+ * the root node of the monitor tree corresponding to the monitor itself.
+ * <p>
+ * Internally we use a default tree model with default mutable tree nodes where
+ * the user object is set to instances of MonitorNode, with the exception of the
+ * 'true' root of the tree in which it is set to the MonitorImpl itself
+ * 
+ * @author Tom Oinn
+ * @author Stian Soiland-Reyes
+ * 
+ */
+public class MonitorTreeModel implements Observer<MonitorMessage> {
+	private static MonitorTreeModel instance = null;
+	private static Logger logger = Logger.getLogger(MonitorTreeModel.class);
+	
+	/**
+	 * Get the MonitorImpl singleton
+	 * 
+	 * @return The MonitorImpl singleton
+	 */
+	public synchronized static MonitorTreeModel getInstance() {
+		// TODO Convert to a bean?
+		if (instance == null)
+			instance = new MonitorTreeModel();
+		return instance;
+	}
+
+	private long nodeRemovalDelay = 1000;
+	private DefaultTreeModel monitorTree;
+	private Timer nodeRemovalTimer;
+
+	/**
+	 * Protected constructor, use singleton access {@link #getInstance()}
+	 * instead.
+	 * 
+	 */
+	protected MonitorTreeModel() {
+		monitorTree = new DefaultTreeModel(new DefaultMutableTreeNode(this));
+		// Create the node removal timer as a daemon thread
+		nodeRemovalTimer = new Timer(true);
+	}
+
+	/**
+	 * Returns a tree view over the monitor.
+	 * 
+	 * @return a tree view over the monitor
+	 */
+	public JTree getJTree() {
+		return new AlwaysOpenJTree(monitorTree);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void notify(Observable<MonitorMessage> sender, MonitorMessage message)
+			throws Exception {
+		if (message instanceof RegisterNodeMessage) {
+			RegisterNodeMessage regMessage = (RegisterNodeMessage) message;
+			registerNode(regMessage.getWorkflowObject(), regMessage
+					.getOwningProcess(), regMessage.getProperties());
+		} else if (message instanceof DeregisterNodeMessage) {
+			deregisterNode(message.getOwningProcess());
+		} else if (message instanceof AddPropertiesMessage) {
+			AddPropertiesMessage addMessage = (AddPropertiesMessage) message;
+			addPropertiesToNode(addMessage.getOwningProcess(), addMessage
+					.getNewProperties());
+		} else {
+			logger.warn("Unknown message " + message + " from " + sender);
+		}
+	}
+
+	/**
+	 * Nodes will be removed at least delayTime milliseconds after their initial
+	 * deregistration request, this allows UI components to show nodes which
+	 * would otherwise vanish almost instantaneously.
+	 * 
+	 * @param delayTime
+	 *            time in milliseconds between the deregistration request and
+	 *            attempt to actually remove the node in question
+	 */
+	public void setNodeRemovalDelay(long delayTime) {
+		nodeRemovalDelay = delayTime;
+	}
+
+	/**
+	 * Very simple UI!
+	 */
+	public void showMonitorFrame() {
+		final JTree tree = new AlwaysOpenJTree(monitorTree);
+		final JScrollPane jsp = new JScrollPane(tree);
+		JFrame frame = new JFrame();
+		frame.getContentPane().setLayout(new BorderLayout());
+		frame.getContentPane().add(jsp);
+		frame.pack();
+		frame.setVisible(true);
+		new javax.swing.Timer(500, new ActionListener() {
+			@Override
+			public void actionPerformed(ActionEvent ae) {
+				jsp.repaint();
+			}
+		}).start();
+	}
+
+	/**
+	 * Return the node pointed to by the first 'limit' number of elements in the
+	 * owning process string array. If limit is -1 then use owningProcess.length
+	 * 
+	 * @param owningProcess
+	 * @param limit
+	 * @return
+	 */
+	protected DefaultMutableTreeNode nodeAtProcessPath(String[] owningProcess,
+			int limit) throws IndexOutOfBoundsException {
+		if (limit == -1)
+			limit = owningProcess.length;
+		DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) monitorTree
+				.getRoot();
+		for (int index = 0; index < limit && index < owningProcess.length; index++) {
+			boolean found = false;
+			for (int childIndex = 0; childIndex < monitorTree
+					.getChildCount(currentNode)
+					&& !found; childIndex++) {
+				DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) monitorTree
+						.getChild(currentNode, childIndex);
+				MonitorNode childMonitorNode = (MonitorNode) childNode
+						.getUserObject();
+				if (childMonitorNode.getOwningProcess()[index]
+						.equals(owningProcess[index])) {
+					currentNode = childNode;
+					found = true;
+					// break;
+				}
+			}
+			if (!found)
+				throw new IndexOutOfBoundsException(
+						"Cannot locate node with process ID "
+								+ printProcess(owningProcess));
+		}
+		return currentNode;
+	}
+
+	protected String printProcess(String[] process) {
+		StringBuffer sb = new StringBuffer();
+		for (String part : process)
+			sb.append("{").append(part).append("}");
+		return sb.toString();
+	}
+
+	/**
+	 * Inject properties into an existing node
+	 */
+	protected void addPropertiesToNode(String[] owningProcess,
+			Set<MonitorableProperty<?>> newProperties) {
+		try {
+			DefaultMutableTreeNode node = nodeAtProcessPath(owningProcess, -1);
+			MonitorNode mn = (MonitorNode) node.getUserObject();
+			for (MonitorableProperty<?> prop : newProperties)
+				mn.addMonitorableProperty(prop);
+		} catch (IndexOutOfBoundsException ioobe) {
+			// Fail silently here, the node wasn't found in the state tree
+			logger.warn("Could not add properties to unknown node "
+					+ printProcess(owningProcess));
+		}
+	}
+
+	/**
+	 * Request the removal of the specified node from the monitor tree. In this
+	 * particular case the removal task will be added to a timer and executed at
+	 * some (slightly) later time as determined by the removalDelay property.
+	 */
+	protected void deregisterNode(String[] owningProcess) {
+		// logger.debug("Remove node @" + printProcess(owningProcess));
+		final DefaultMutableTreeNode nodeToRemove = nodeAtProcessPath(
+				owningProcess, -1);
+		((MonitorNodeImpl) nodeToRemove.getUserObject()).expire();
+		nodeRemovalTimer.schedule(new TimerTask() {
+			@Override
+			public void run() {
+				synchronized (monitorTree) {
+					monitorTree.removeNodeFromParent(nodeToRemove);
+				}
+			}
+		}, getNodeRemovalDelay());
+	}
+
+	/**
+	 * Create a new node in the monitor
+	 */
+	protected void registerNode(final Object workflowObject,
+			final String[] owningProcess,
+			final Set<MonitorableProperty<?>> properties) {
+		// logger.debug("Registering node " + printProcess(owningProcess));
+	
+		// Create a new MonitorNode
+		final DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(
+				new MonitorNodeImpl(workflowObject, owningProcess, properties));
+		synchronized (monitorTree) {
+			final MutableTreeNode parentNode = nodeAtProcessPath(owningProcess,
+					owningProcess.length - 1);
+			monitorTree.insertNodeInto(newNode, parentNode, monitorTree
+					.getChildCount(parentNode));
+		}
+	}
+
+	class AlwaysOpenJTree extends JTree {
+		private static final long serialVersionUID = -3769998854485605447L;
+
+		public AlwaysOpenJTree(TreeModel newModel) {
+			super(newModel);
+			setRowHeight(18);
+			setLargeModel(true);
+			setEditable(false);
+			setExpandsSelectedPaths(false);
+			setDragEnabled(false);
+			setScrollsOnExpand(false);
+			setSelectionModel(EmptySelectionModel.sharedInstance());
+			setCellRenderer(new CellRenderer());
+		}
+
+		@Override
+		public void setModel(TreeModel model) {
+			if (treeModel == model)
+				return;
+			if (treeModelListener == null)
+				treeModelListener = new TreeModelListener();
+			if (model != null) {
+				model.addTreeModelListener(treeModelListener);
+			}
+			TreeModel oldValue = treeModel;
+			treeModel = model;
+			firePropertyChange(TREE_MODEL_PROPERTY, oldValue, model);
+		}
+
+		protected class CellRenderer extends DefaultTreeCellRenderer {
+			private static final long serialVersionUID = 7106767124654545039L;
+
+			@Override
+			public Component getTreeCellRendererComponent(JTree tree,
+					Object value, boolean sel, boolean expanded,
+					boolean leaf, int row, boolean hasFocus) {
+				super.getTreeCellRendererComponent(tree, value, sel,
+						expanded, leaf, row, hasFocus);
+				if (value instanceof DefaultMutableTreeNode) {
+					Object o = ((DefaultMutableTreeNode) value)
+							.getUserObject();
+					if (o instanceof MonitorNode)
+						if (((MonitorNode) o).hasExpired())
+							setEnabled(false);
+				}
+				return this;
+			}
+		}
+
+		protected class TreeModelListener extends TreeModelHandler {
+			@Override
+			public void treeNodesInserted(final TreeModelEvent ev) {
+				SwingUtilities.invokeLater(new Runnable() {
+					@Override
+					public void run() {
+						TreePath path = ev.getTreePath();
+						setExpandedState(path, true);
+						fireTreeExpanded(path);
+					}
+				});
+			}
+			@Override
+			public void treeStructureChanged(final TreeModelEvent ev) {
+				SwingUtilities.invokeLater(new Runnable() {
+					@Override
+					public void run() {
+						TreePath path = ev.getTreePath();
+						setExpandedState(path, true);
+						fireTreeExpanded(path);
+					}
+				});
+			}
+		}
+	}
+
+	class MonitorNodeImpl implements MonitorNode {
+		private boolean expired = false;
+		private String[] owningProcess;
+		private Set<MonitorableProperty<?>> properties;
+		private Object workflowObject;
+		Date creationDate = new Date();
+
+		MonitorNodeImpl(Object workflowObject, String[] owningProcess,
+				Set<MonitorableProperty<?>> properties) {
+			this.properties = properties;
+			this.workflowObject = workflowObject;
+			this.owningProcess = owningProcess;
+		}
+
+		@Override
+		public void addMonitorableProperty(MonitorableProperty<?> newProperty) {
+			properties.add(newProperty);
+		}
+
+		public void expire() {
+			expired = true;
+		}
+
+		@Override
+		public Date getCreationDate() {
+			return creationDate;
+		}
+
+		@Override
+		public String[] getOwningProcess() {
+			return owningProcess;
+		}
+
+		/**
+		 * Return an unmodifiable copy of the property set
+		 */
+		@Override
+		public Set<? extends MonitorableProperty<?>> getProperties() {
+			return Collections.unmodifiableSet(properties);
+		}
+
+		@Override
+		public Object getWorkflowObject() {
+			return workflowObject;
+		}
+
+		@Override
+		public boolean hasExpired() {
+			return this.expired;
+		}
+
+		@Override
+		public String toString() {
+			StringBuffer sb = new StringBuffer();
+			sb.append(getWorkflowObject().getClass().getSimpleName());
+			sb.append(", ");
+			sb.append(owningProcess[owningProcess.length - 1]);
+			sb.append(" : ");
+			for (MonitorableProperty<?> prop : getProperties()) {
+				String separator = "";
+				for (String nameElement : prop.getName()) {
+					sb.append(separator).append(nameElement);
+					separator = ".";
+				}
+				sb.append("=");
+				try {
+					sb.append(prop.getValue().toString());
+				} catch (NoSuchPropertyException nspe) {
+					sb.append("EXPIRED");
+				}
+				sb.append(" ");
+			}
+			return sb.toString();
+		}
+	}
+
+	public long getNodeRemovalDelay() {
+		return nodeRemovalDelay;
+	}
+
+	protected DefaultTreeModel getMonitorTree() {
+		return monitorTree;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractActivityEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractActivityEdit.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractActivityEdit.java
new file mode 100644
index 0000000..73aec49
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractActivityEdit.java
@@ -0,0 +1,68 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.impl;
+
+import org.apache.taverna.workflowmodel.EditException;
+import org.apache.taverna.workflowmodel.processor.activity.AbstractActivity;
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+
+/**
+ * Abstraction of an edit acting on a Activity instance. Handles the check to
+ * see that the Activity supplied is really a AbstractActivity.
+ * 
+ * @author David Withers
+ * @author Stian Soiland-Reyes
+ */
+public abstract class AbstractActivityEdit<T> extends EditSupport<Activity<T>> {
+	private final AbstractActivity<T> activity;
+
+	protected AbstractActivityEdit(Activity<T> activity) {
+		if (activity == null)
+			throw new RuntimeException(
+					"Cannot construct an activity edit with null activity");
+		if (!(activity instanceof AbstractActivity))
+			throw new RuntimeException(
+					"Edit cannot be applied to an Activity which isn't an instance of AbstractActivity");
+		this.activity = (AbstractActivity<T>) activity;
+	}
+
+	@Override
+	public final Activity<T> applyEdit() throws EditException {
+		synchronized (activity) {
+			doEditAction(activity);
+		}
+		return activity;
+	}
+
+	/**
+	 * Do the actual edit here
+	 * 
+	 * @param processor
+	 *            The ProcessorImpl to which the edit applies
+	 * @throws EditException
+	 */
+	protected abstract void doEditAction(AbstractActivity<T> processor)
+			throws EditException;
+
+	@Override
+	public final Activity<T> getSubject() {
+		return activity;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractAnnotationEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractAnnotationEdit.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractAnnotationEdit.java
new file mode 100644
index 0000000..0708b0e
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractAnnotationEdit.java
@@ -0,0 +1,69 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.impl;
+
+import org.apache.taverna.annotation.AnnotationAssertion;
+import org.apache.taverna.annotation.AnnotationBeanSPI;
+import org.apache.taverna.annotation.impl.AnnotationAssertionImpl;
+import org.apache.taverna.workflowmodel.EditException;
+
+/**
+ * Abstraction of an edit acting on a AnnotationAssertion instance. Handles the
+ * check to see that the AnnotationAssertion supplied is really an
+ * AnnotationAssertionImpl.
+ */
+abstract class AbstractAnnotationEdit extends
+		EditSupport<AnnotationAssertion<AnnotationBeanSPI>> {
+	private final AnnotationAssertionImpl annotation;
+
+	protected AbstractAnnotationEdit(AnnotationAssertion<AnnotationBeanSPI> annotation) {
+		if (annotation == null)
+			throw new RuntimeException(
+					"Cannot construct an annotation edit with null annotation");
+		if (!(annotation instanceof AnnotationAssertionImpl))
+			throw new RuntimeException(
+					"Edit cannot be applied to an AnnotationAssertion which isn't an instance of AnnotationAssertionImpl");
+		this.annotation = (AnnotationAssertionImpl) annotation;
+	}
+
+	@Override
+	public final AnnotationAssertion<AnnotationBeanSPI> applyEdit()
+			throws EditException {
+		synchronized (annotation) {
+			doEditAction(annotation);
+		}
+		return annotation;
+	}
+
+	/**
+	 * Do the actual edit here
+	 * 
+	 * @param annotationAssertion
+	 *            The AnnotationAssertionImpl to which the edit applies
+	 * @throws EditException
+	 */
+	protected abstract void doEditAction(
+			AnnotationAssertionImpl annotationAssertion) throws EditException;
+
+	@Override
+	public final AnnotationAssertion<AnnotationBeanSPI> getSubject() {
+		return annotation;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractBinaryProcessorEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractBinaryProcessorEdit.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractBinaryProcessorEdit.java
new file mode 100644
index 0000000..7e5b605
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractBinaryProcessorEdit.java
@@ -0,0 +1,94 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.impl;
+
+import static java.lang.System.identityHashCode;
+import org.apache.taverna.workflowmodel.EditException;
+import org.apache.taverna.workflowmodel.OrderedPair;
+import org.apache.taverna.workflowmodel.Processor;
+
+/**
+ * Generalization over all operations acting on an ordered pair of ProcessorImpl
+ * objects. These include most operations where a relationship is created,
+ * modified or destroyed between two processors.
+ * 
+ * @author Tom Oinn
+ * @author Donal Fellows
+ */
+abstract class AbstractBinaryProcessorEdit extends
+		EditSupport<OrderedPair<Processor>> {
+	private final OrderedPair<Processor> processors;
+
+	public AbstractBinaryProcessorEdit(Processor a, Processor b) {
+		if (!(a instanceof ProcessorImpl) || !(b instanceof ProcessorImpl))
+			throw new RuntimeException(
+					"Edit cannot be applied to a Processor which isn't an instance of ProcessorImpl");
+		processors = new OrderedPair<>(a, b);
+	}
+
+	@Override
+	public final OrderedPair<Processor> applyEdit() throws EditException {
+		ProcessorImpl pia = (ProcessorImpl) processors.getA();
+		ProcessorImpl pib = (ProcessorImpl) processors.getB();
+
+		/*
+		 * Acquire both locks. Guarantee to acquire in a consistent order, based
+		 * on the system hash code (i.e., the object addresses, which we're not
+		 * supposed to know). This means that we should not deadlock, as we've
+		 * got a total order over all extant processors.
+		 * 
+		 * If someone is silly enough to use the same processor for both halves,
+		 * it doesn't matter which arm of the conditional we take.
+		 */
+		if (identityHashCode(pia) < identityHashCode(pib)) {
+			synchronized (pia) {
+				synchronized (pib) {
+					doEditAction(pia, pib);
+				}
+			}
+		} else {
+			synchronized (pib) {
+				synchronized (pia) {
+					doEditAction(pia, pib);
+				}
+			}
+		}
+		return processors;
+	}
+
+	@Override
+	public final OrderedPair<Processor> getSubject() {
+		return processors;
+	}
+
+	/**
+	 * Do the actual edit here
+	 * 
+	 * @param processorA
+	 *            The ProcessorImpl which is in some sense the source of the
+	 *            relation between the two being asserted or operated on by this
+	 *            edit
+	 * @param processorB
+	 *            The ProcessorImpl at the other end of the relation. *
+	 * @throws EditException
+	 */
+	protected abstract void doEditAction(ProcessorImpl processorA,
+			ProcessorImpl processorB) throws EditException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractCrystalizer.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractCrystalizer.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractCrystalizer.java
new file mode 100644
index 0000000..4308022
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractCrystalizer.java
@@ -0,0 +1,193 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.taverna.invocation.Completion;
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.invocation.IterationInternalEvent;
+import org.apache.taverna.invocation.TreeCache;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.workflowmodel.processor.activity.Job;
+
+/**
+ * Receives Job and Completion events and emits Jobs unaltered. Completion
+ * events additionally cause registration of lists for each key in the datamap
+ * of the jobs at immediate child locations in the index structure. These list
+ * identifiers are sent in place of the Completion events.
+ * <p>
+ * State for a given process ID is purged when a final completion event is
+ * received so there is no need for an explicit cache purge operation in the
+ * public API (although for termination of partially complete workflows it may
+ * be sensible for subclasses to provide one)
+ * <p>
+ * 
+ * @author Tom Oinn
+ * @author David Withers
+ */
+public abstract class AbstractCrystalizer implements Crystalizer {
+	private Map<String, CompletionAwareTreeCache> cacheMap = new HashMap<>();
+
+	public abstract Job getEmptyJob(String owningProcess, int[] index,
+			InvocationContext context);
+
+	/**
+	 * Receive a Job or Completion, Jobs are emitted unaltered and cached,
+	 * Completion events trigger registration of a corresponding list - this may
+	 * be recursive in nature if the completion event's index implies nested
+	 * lists which have not been registered.
+	 * <p>
+	 * If the baseListDepth property is defined then completion events on nodes
+	 * which don't already exist create empty jobs instead and emit those, if
+	 * undefined the completion event is emited intact.
+	 * 
+	 * @param e The event (a {@link Job} or a {@link Completion})
+	 */
+	@Override
+	public void receiveEvent(IterationInternalEvent<?> e) {
+		String owningProcess = e.getOwningProcess();
+		CompletionAwareTreeCache cache = null;
+		synchronized (cacheMap) {
+			if (!cacheMap.containsKey(owningProcess)) {
+				cache = new CompletionAwareTreeCache(owningProcess, e
+						.getContext());
+				cacheMap.put(owningProcess, cache);
+			} else
+				cache = cacheMap.get(owningProcess);
+		}
+		if (e instanceof Job) {
+			// Pass through Job after storing it in the cache
+			Job j = (Job) e;
+			synchronized (cache) {
+				cache.insertJob(new Job("", j.getIndex(), j.getData(), j
+						.getContext()));
+				jobCreated(j);
+				if (j.getIndex().length == 0)
+					cacheMap.remove(j.getOwningProcess());
+			}
+		} else if (e instanceof Completion) {
+			Completion c = (Completion) e;
+			synchronized (cache) {
+				cache.resolveAt(owningProcess, c.getIndex());
+				if (c.getIndex().length == 0)
+					cacheMap.remove(c.getOwningProcess());
+			}
+		}
+	}
+
+	protected class CompletionAwareTreeCache extends TreeCache {
+		private String owningProcess;
+		private InvocationContext context;
+
+		public CompletionAwareTreeCache(String owningProcess,
+				InvocationContext context) {
+			super();
+			this.context = context;
+			this.owningProcess = owningProcess;
+		}
+
+		public void resolveAt(String owningProcess, int[] completionIndex) {
+			NamedNode n = nodeAt(completionIndex);
+			if (n != null) {
+				assignNamesTo(n, completionIndex);
+				return;
+			}
+
+			/*
+			 * We know what the list depth should be, so we can construct
+			 * appropriate depth empty lists to fill in the gaps.
+			 */
+
+			Job j = getEmptyJob(owningProcess, completionIndex, context);
+			insertJob(j);
+			jobCreated(j);
+		}
+
+		private void assignNamesTo(NamedNode n, int[] index) {
+			/* Only act if contents of this node undefined */
+			if (n.contents != null)
+				return;
+
+			Map<String, List<T2Reference>> listItems = new HashMap<>();
+			int pos = 0;
+			for (NamedNode child : n.children) {
+				/*
+				 * If child doesn't have a defined name map yet then define it.
+				 */
+				Job j;
+				if (child == null) {
+					/*
+					 * happens if we're completing a partially empty collection
+					 * structure
+					 */
+					int[] newIndex = new int[index.length + 1];
+					for (int i = 0; i < index.length; i++)
+						newIndex[i] = index[i];
+					newIndex[index.length] = pos++;
+					j = getEmptyJob(owningProcess, newIndex, context);
+					jobCreated(j);
+				} else if (child.contents == null) {
+					int[] newIndex = new int[index.length + 1];
+					for (int i = 0; i < index.length; i++)
+						newIndex[i] = index[i];
+					newIndex[index.length] = pos++;
+					assignNamesTo(child, newIndex);
+					j = child.contents;
+				} else {
+					pos++;
+					j = child.contents;
+				}
+
+				/*
+				 * Now pull the names out of the child job map and push them
+				 * into lists to be registered
+				 */
+
+				for (String outputName : j.getData().keySet()) {
+					List<T2Reference> items = listItems.get(outputName);
+					if (items == null) {
+						items = new ArrayList<>();
+						listItems.put(outputName, items);
+					}
+					items.add(j.getData().get(outputName));
+				}
+			}
+			Map<String, T2Reference> newDataMap = new HashMap<>();
+			for (String outputName : listItems.keySet())
+				newDataMap.put(
+						outputName,
+						context.getReferenceService()
+								.getListService()
+								.registerList(listItems.get(outputName),
+										context).getId());
+			Job newJob = new Job(owningProcess, index, newDataMap, context);
+			n.contents = newJob;
+
+			/* Get rid of the children as we've now named this node */
+
+			n.children.clear();
+			jobCreated(n.contents);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractDataflowEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractDataflowEdit.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractDataflowEdit.java
new file mode 100644
index 0000000..4809bd6
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractDataflowEdit.java
@@ -0,0 +1,67 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.impl;
+
+import org.apache.taverna.workflowmodel.Dataflow;
+import org.apache.taverna.workflowmodel.EditException;
+
+/**
+ * Abstraction of an edit acting on a Dataflow instance. Handles the check to
+ * see that the Dataflow supplied is really a DataflowImpl.
+ * 
+ * @author David Withers
+ * 
+ */
+public abstract class AbstractDataflowEdit extends EditSupport<Dataflow> {
+	private final DataflowImpl dataflow;
+
+	protected AbstractDataflowEdit(Dataflow dataflow) {
+		if (dataflow == null)
+			throw new RuntimeException(
+					"Cannot construct a dataflow edit with null dataflow");
+		if (!(dataflow instanceof DataflowImpl))
+			throw new RuntimeException(
+					"Edit cannot be applied to a Dataflow which isn't an instance of DataflowImpl");
+		this.dataflow = (DataflowImpl) dataflow;
+	}
+
+	@Override
+	public final Dataflow applyEdit() throws EditException {
+		synchronized (dataflow) {
+			doEditAction(dataflow);
+		}
+		return dataflow;
+	}
+
+	/**
+	 * Do the actual edit here
+	 * 
+	 * @param dataflow
+	 *            The DataflowImpl to which the edit applies
+	 * @throws EditException
+	 */
+	protected abstract void doEditAction(DataflowImpl dataflow)
+			throws EditException;
+
+	@Override
+	public final Dataflow getSubject() {
+		return dataflow;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractDataflowInputPortEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractDataflowInputPortEdit.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractDataflowInputPortEdit.java
new file mode 100644
index 0000000..57d677a
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractDataflowInputPortEdit.java
@@ -0,0 +1,67 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.impl;
+
+import org.apache.taverna.workflowmodel.DataflowInputPort;
+import org.apache.taverna.workflowmodel.EditException;
+
+/**
+ * Abstraction of an edit acting on a DataflowInputPort instance. Handles the check to
+ * see that the DataflowInputPort supplied is really a DataflowInputPortImpl.
+ * 
+ * @author David Withers
+ *
+ */
+public abstract class AbstractDataflowInputPortEdit extends EditSupport<DataflowInputPort> {
+	private final DataflowInputPortImpl dataflowInputPort;
+
+	protected AbstractDataflowInputPortEdit(DataflowInputPort dataflowInputPort) {
+		if (dataflowInputPort == null)
+			throw new RuntimeException(
+					"Cannot construct a DataflowInputPort edit with null DataflowInputPort");
+		if (!(dataflowInputPort instanceof DataflowInputPortImpl))
+			throw new RuntimeException(
+					"Edit cannot be applied to a DataflowInputPort which isn't an instance of DataflowInputPortImpl");
+		this.dataflowInputPort = (DataflowInputPortImpl) dataflowInputPort;
+	}
+
+	@Override
+	public final DataflowInputPort applyEdit() throws EditException {
+		synchronized (dataflowInputPort) {
+			doEditAction(dataflowInputPort);
+		}
+		return dataflowInputPort;
+	}
+
+	/**
+	 * Do the actual edit here
+	 * 
+	 * @param dataflowInputPort
+	 *            The DataflowInputPortImpl to which the edit applies
+	 * @throws EditException
+	 */
+	protected abstract void doEditAction(DataflowInputPortImpl dataflowInputPort)
+			throws EditException;
+
+	@Override
+	public final DataflowInputPort getSubject() {
+		return dataflowInputPort;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractDataflowOutputPortEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractDataflowOutputPortEdit.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractDataflowOutputPortEdit.java
new file mode 100644
index 0000000..7d18271
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractDataflowOutputPortEdit.java
@@ -0,0 +1,69 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.impl;
+
+import org.apache.taverna.workflowmodel.DataflowOutputPort;
+import org.apache.taverna.workflowmodel.EditException;
+
+/**
+ * Abstraction of an edit acting on a DataflowOutputPort instance. Handles the
+ * check to see that the DataflowOutputPort supplied is really a
+ * DataflowOutputPortImpl.
+ * 
+ * @author David Withers
+ */
+public abstract class AbstractDataflowOutputPortEdit extends
+		EditSupport<DataflowOutputPort> {
+	private final DataflowOutputPortImpl dataflowOutputPort;
+
+	protected AbstractDataflowOutputPortEdit(
+			DataflowOutputPort dataflowOutputPort) {
+		if (dataflowOutputPort == null)
+			throw new RuntimeException(
+					"Cannot construct a DataflowOutputPort edit with null DataflowOutputPort");
+		if (!(dataflowOutputPort instanceof DataflowOutputPortImpl))
+			throw new RuntimeException(
+					"Edit cannot be applied to a DataflowOutputPort which isn't an instance of DataflowOutputPortImpl");
+		this.dataflowOutputPort = (DataflowOutputPortImpl) dataflowOutputPort;
+	}
+
+	@Override
+	public final DataflowOutputPort applyEdit() throws EditException {
+		synchronized (dataflowOutputPort) {
+			doEditAction(dataflowOutputPort);
+		}
+		return dataflowOutputPort;
+	}
+
+	/**
+	 * Do the actual edit here
+	 * 
+	 * @param dataflowOutputPort
+	 *            The DataflowOutputPortImpl to which the edit applies
+	 * @throws EditException
+	 */
+	protected abstract void doEditAction(
+			DataflowOutputPortImpl dataflowOutputPort) throws EditException;
+
+	@Override
+	public final DataflowOutputPort getSubject() {
+		return dataflowOutputPort;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractDatalinkEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractDatalinkEdit.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractDatalinkEdit.java
new file mode 100644
index 0000000..4a76eb4
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractDatalinkEdit.java
@@ -0,0 +1,66 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.impl;
+
+import org.apache.taverna.workflowmodel.Datalink;
+import org.apache.taverna.workflowmodel.EditException;
+
+/**
+ * Abstraction of an edit acting on a Datalink instance. Handles the check to
+ * see that the Datalink supplied is really a DatalinkImpl.
+ * 
+ * @author David Withers
+ */
+public abstract class AbstractDatalinkEdit extends EditSupport<Datalink> {
+	private final DatalinkImpl datalink;
+
+	protected AbstractDatalinkEdit(Datalink datalink) {
+		if (datalink == null)
+			throw new RuntimeException(
+					"Cannot construct a datalink edit with null datalink");
+		if (!(datalink instanceof DatalinkImpl))
+			throw new RuntimeException(
+					"Edit cannot be applied to a Datalink which isn't an instance of DatalinkImpl");
+		this.datalink = (DatalinkImpl) datalink;
+	}
+
+	@Override
+	public final Datalink applyEdit() throws EditException {
+		synchronized (datalink) {
+			doEditAction(datalink);
+		}
+		return datalink;
+	}
+
+	/**
+	 * Do the actual edit here
+	 * 
+	 * @param datalink
+	 *            The DatalinkImpl to which the edit applies
+	 * @throws EditException
+	 */
+	protected abstract void doEditAction(DatalinkImpl datalink)
+			throws EditException;
+
+	@Override
+	public final Datalink getSubject() {
+		return datalink;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractEventHandlingInputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractEventHandlingInputPort.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractEventHandlingInputPort.java
new file mode 100644
index 0000000..f816b83
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractEventHandlingInputPort.java
@@ -0,0 +1,52 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.impl;
+
+import org.apache.taverna.workflowmodel.AbstractPort;
+import org.apache.taverna.workflowmodel.Datalink;
+import org.apache.taverna.workflowmodel.EventHandlingInputPort;
+
+/**
+ * Extends AbstractPort with the getIncomingLink method and an additional
+ * implementation method to set the incoming data link
+ * 
+ * @author Tom Oinn
+ */
+public abstract class AbstractEventHandlingInputPort extends AbstractPort
+		implements EventHandlingInputPort {
+	private Datalink incomingLink = null;
+
+	protected AbstractEventHandlingInputPort(String name, int depth) {
+		super(name, depth);
+	}
+
+	@Override
+	public Datalink getIncomingLink() {
+		return this.incomingLink;
+	}
+
+	protected void setIncomingLink(Datalink newLink) {
+		this.incomingLink = newLink;
+	}
+	
+	protected void setName(String name) {
+		this.name = name;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractFilteringInputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractFilteringInputPort.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractFilteringInputPort.java
new file mode 100644
index 0000000..38f3f55
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractFilteringInputPort.java
@@ -0,0 +1,177 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.impl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.taverna.invocation.InvocationContext;
+import org.apache.taverna.invocation.WorkflowDataToken;
+import org.apache.taverna.reference.ContextualizedT2Reference;
+import org.apache.taverna.reference.ReferenceService;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.workflowmodel.FilteringInputPort;
+import org.apache.taverna.workflowmodel.WorkflowStructureException;
+
+/**
+ * Abstract superclass for filtering input ports, extend and implement the
+ * pushXXX methods to configure behaviour
+ * 
+ * @author Tom Oinn
+ */
+public abstract class AbstractFilteringInputPort extends
+		AbstractEventHandlingInputPort implements FilteringInputPort {
+	protected AbstractFilteringInputPort(String name, int depth) {
+		super(name, depth);
+		this.filterDepth = depth;
+	}
+
+	@Override
+	public int getFilterDepth() {
+		return this.filterDepth;
+	}
+
+	private int filterDepth;
+
+	@Override
+	public void receiveEvent(WorkflowDataToken token) {
+		receiveToken(token);
+	}
+
+	public void pushToken(WorkflowDataToken dt, String owningProcess,
+			int desiredDepth) {
+		if (dt.getData().getDepth() == desiredDepth)
+			pushData(getName(), owningProcess, dt.getIndex(), dt.getData(), dt
+					.getContext());
+		else {
+			ReferenceService rs = dt.getContext().getReferenceService();
+			Iterator<ContextualizedT2Reference> children = rs.traverseFrom(dt
+					.getData(), dt.getData().getDepth() - 1);
+
+			while (children.hasNext()) {
+				ContextualizedT2Reference ci = children.next();
+				int[] newIndex = new int[dt.getIndex().length
+						+ ci.getIndex().length];
+				int i = 0;
+				for (int indx : dt.getIndex())
+					newIndex[i++] = indx;
+				for (int indx : ci.getIndex())
+					newIndex[i++] = indx;
+				pushToken(new WorkflowDataToken(owningProcess, newIndex, ci
+						.getReference(), dt.getContext()), owningProcess,
+						desiredDepth);
+			}
+			pushCompletion(getName(), owningProcess, dt.getIndex(), dt
+					.getContext());
+		}
+	}
+
+	public void receiveToken(WorkflowDataToken token) {
+		String newOwner = transformOwningProcess(token.getOwningProcess());
+		if (filterDepth == -1)
+			throw new WorkflowStructureException(
+					"Input depth filter not configured on input port, failing");
+
+		int tokenDepth = token.getData().getDepth();
+		if (tokenDepth == filterDepth) {
+			if (filterDepth == getDepth())
+				/*
+				 * Pass event straight through, the filter depth is the same as
+				 * the desired input port depth
+				 */
+				pushData(getName(), newOwner, token.getIndex(),
+						token.getData(), token.getContext());
+			else {
+				pushToken(token, newOwner, getDepth());
+				/*
+				 * Shred the input identifier into the appropriate port depth
+				 * and send the events through, pushing a completion event at
+				 * the end.
+				 */
+			}
+		} else if (tokenDepth > filterDepth) {
+			// Convert to a completion event and push into the iteration strategy
+			pushCompletion(getName(), newOwner, token.getIndex(), token
+					.getContext());
+		} else if (tokenDepth < filterDepth) {
+			/*
+			 * Normally we can ignore these, but there is a special case where
+			 * token depth is less than filter depth and there is no index
+			 * array. In this case we can't throw the token away as there will
+			 * never be an enclosing one so we have to use the data manager to
+			 * register a new single element collection and recurse.
+			 */
+			if (token.getIndex().length == 0) {
+				T2Reference ref = token.getData();
+				ReferenceService rs = token.getContext().getReferenceService();
+				int currentDepth = tokenDepth;
+				while (currentDepth < filterDepth) {
+					// Wrap in a single item list
+					List<T2Reference> newList = new ArrayList<>();
+					newList.add(ref);
+					ref = rs.getListService()
+							.registerList(newList, token.getContext()).getId();
+					currentDepth++;
+				}
+				pushData(getName(), newOwner, new int[0], ref,
+						token.getContext());
+			}
+		}
+	}
+
+	public void setFilterDepth(int filterDepth) {
+		this.filterDepth = filterDepth;
+		if (filterDepth < getDepth())
+			this.filterDepth = getDepth();
+	}
+
+	/**
+	 * Action to take when the filter pushes a completion event out
+	 * 
+	 * @param portName
+	 * @param owningProcess
+	 * @param index
+	 */
+	protected abstract void pushCompletion(String portName,
+			String owningProcess, int[] index, InvocationContext context);
+
+	/**
+	 * Action to take when a data event is created by the filter
+	 * 
+	 * @param portName
+	 * @param owningProcess
+	 * @param index
+	 * @param data
+	 */
+	protected abstract void pushData(String portName, String owningProcess,
+			int[] index, T2Reference data, InvocationContext context);
+
+	/**
+	 * Override this to transform owning process identifiers as they pass
+	 * through the filter, by default this is the identity transformation
+	 * 
+	 * @param oldOwner
+	 * @return
+	 */
+	protected String transformOwningProcess(String oldOwner) {
+		return oldOwner;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractMergeEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractMergeEdit.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractMergeEdit.java
new file mode 100644
index 0000000..769da09
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractMergeEdit.java
@@ -0,0 +1,51 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.impl;
+
+import org.apache.taverna.workflowmodel.EditException;
+import org.apache.taverna.workflowmodel.Merge;
+
+public abstract class AbstractMergeEdit extends EditSupport<Merge> {
+	private final MergeImpl merge;
+	
+	public AbstractMergeEdit(Merge merge) {
+		if (merge == null)
+			throw new RuntimeException(
+					"Cannot construct a merge edit with a null merge");
+		if (!(merge instanceof MergeImpl))
+			throw new RuntimeException("Merge must be an instanceof MergeImpl");
+		this.merge = (MergeImpl) merge;
+	}
+
+	@Override
+	public final Merge applyEdit() throws EditException {
+		synchronized (merge) {
+			doEditAction(merge);
+		}
+		return merge;
+	}
+
+	protected abstract void doEditAction(MergeImpl mergeImpl) throws EditException;
+	
+	@Override
+	public final Object getSubject() {
+		return merge;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractProcessorEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractProcessorEdit.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractProcessorEdit.java
new file mode 100644
index 0000000..dc7bbc3
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/AbstractProcessorEdit.java
@@ -0,0 +1,67 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.impl;
+
+import org.apache.taverna.workflowmodel.EditException;
+import org.apache.taverna.workflowmodel.Processor;
+
+/**
+ * Abstraction of an edit acting on a Processor instance. Handles the check to
+ * see that the Processor supplied is really a ProcessorImpl.
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public abstract class AbstractProcessorEdit extends EditSupport<Processor> {
+	private final ProcessorImpl processor;
+
+	protected AbstractProcessorEdit(Processor processor) {
+		if (processor == null)
+			throw new RuntimeException(
+					"Cannot construct a processor edit with null processor");
+		if (!(processor instanceof ProcessorImpl))
+			throw new RuntimeException(
+					"Edit cannot be applied to a Processor which isn't an instance of ProcessorImpl");
+		this.processor = (ProcessorImpl) processor;
+	}
+
+	@Override
+	public final Processor applyEdit() throws EditException {
+		synchronized (processor) {
+			doEditAction(processor);
+		}
+		return processor;
+	}
+
+	/**
+	 * Do the actual edit here
+	 * 
+	 * @param processor
+	 *            The ProcessorImpl to which the edit applies
+	 * @throws EditException
+	 */
+	protected abstract void doEditAction(ProcessorImpl processor)
+			throws EditException;
+
+	@Override
+	public final Processor getSubject() {
+		return processor;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/BasicEventForwardingOutputPort.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/BasicEventForwardingOutputPort.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/BasicEventForwardingOutputPort.java
new file mode 100644
index 0000000..84b5c55
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/BasicEventForwardingOutputPort.java
@@ -0,0 +1,92 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.impl;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.taverna.invocation.WorkflowDataToken;
+import org.apache.taverna.workflowmodel.AbstractOutputPort;
+import org.apache.taverna.workflowmodel.Datalink;
+import org.apache.taverna.workflowmodel.EventForwardingOutputPort;
+
+/**
+ * Extension of AbstractOutputPort implementing EventForwardingOutputPort
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public class BasicEventForwardingOutputPort extends AbstractOutputPort
+		implements EventForwardingOutputPort {
+	protected Set<DatalinkImpl> outgoingLinks;
+
+	/**
+	 * Construct a new abstract output port with event forwarding capability
+	 * 
+	 * @param portName
+	 * @param portDepth
+	 * @param granularDepth
+	 */
+	public BasicEventForwardingOutputPort(String portName, int portDepth,
+			int granularDepth) {
+		super(portName, portDepth, granularDepth);
+		this.outgoingLinks = new HashSet<>();
+	}
+
+	/**
+	 * Implements EventForwardingOutputPort
+	 */
+	@Override
+	public final Set<? extends Datalink> getOutgoingLinks() {
+		return Collections.unmodifiableSet(this.outgoingLinks);
+	}
+
+	/**
+	 * Forward the specified event to all targets
+	 * 
+	 * @param e
+	 */
+	public void sendEvent(WorkflowDataToken e) {
+		for (Datalink link : outgoingLinks)
+			link.getSink().receiveEvent(e);
+	}
+
+	protected void addOutgoingLink(DatalinkImpl link) {
+		if (outgoingLinks.contains(link) == false)
+			outgoingLinks.add(link);
+	}
+
+	protected void removeOutgoingLink(Datalink link) {
+		outgoingLinks.remove(link);
+	}
+
+	protected void setDepth(int depth) {
+		this.depth = depth;
+	}
+	
+	protected void setGranularDepth(int granularDepth) {
+		this.granularDepth = granularDepth;
+	}
+	
+	protected void setName(String name) {
+		this.name = name;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/ConditionImpl.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/ConditionImpl.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/ConditionImpl.java
new file mode 100644
index 0000000..f78a5c0
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/ConditionImpl.java
@@ -0,0 +1,60 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.impl;
+
+import static java.lang.Boolean.TRUE;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.taverna.annotation.AbstractAnnotatedThing;
+import org.apache.taverna.workflowmodel.Condition;
+
+class ConditionImpl extends AbstractAnnotatedThing<Condition> implements Condition {
+	private ProcessorImpl control, target;
+	private Map<String, Boolean> stateMap = new HashMap<>();
+
+	protected ConditionImpl(ProcessorImpl control, ProcessorImpl target) {
+		this.control = control;
+		this.target = target;
+	}
+
+	@Override
+	public ProcessorImpl getControl() {
+		return this.control;
+	}
+
+	@Override
+	public ProcessorImpl getTarget() {
+		return this.target;
+	}
+
+	@Override
+	public boolean isSatisfied(String owningProcess) {
+		if (!stateMap.containsKey(owningProcess))
+			return false;
+		return stateMap.get(owningProcess);
+	}
+
+	protected void satisfy(String owningProcess) {
+		stateMap.put(owningProcess, TRUE);
+		// TODO - poke target processor here
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/ConfigureEdit.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/ConfigureEdit.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/ConfigureEdit.java
new file mode 100644
index 0000000..818ecb5
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/ConfigureEdit.java
@@ -0,0 +1,77 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.impl;
+
+import org.apache.taverna.workflowmodel.Configurable;
+import org.apache.taverna.workflowmodel.ConfigurationException;
+import org.apache.taverna.workflowmodel.EditException;
+
+import org.apache.log4j.Logger;
+
+/**
+ * An Edit that is responsible for configuring a {@link Configurable} with a
+ * given configuration bean.
+ * 
+ * @author Stuart Owen
+ * @author Stian Soiland-Reyes
+ * @author Donal Fellows
+ */
+class ConfigureEdit<T> extends EditSupport<Configurable<T>> {
+	private static Logger logger = Logger.getLogger(ConfigureEdit.class);
+
+	private final Configurable<T> configurable;
+	private final Class<? extends Configurable<T>> configurableType;
+	private final T configurationBean;
+
+	ConfigureEdit(Class<? extends Configurable<T>> subjectType,
+			Configurable<T> configurable, T configurationBean) {
+		if (configurable == null)
+			throw new RuntimeException(
+					"Cannot construct an edit with null subject");
+		this.configurableType = subjectType;
+		this.configurable = configurable;
+		this.configurationBean = configurationBean;
+		if (!configurableType.isInstance(configurable))
+			throw new RuntimeException(
+					"Edit cannot be applied to an object which isn't an instance of "
+							+ configurableType);
+	}
+
+	@Override
+	public final Configurable<T> applyEdit() throws EditException {
+		try {
+			// FIXME: Should clone bean on configuration to prevent caller from
+			// modifying bean afterwards
+			synchronized (configurable) {
+				configurable.configure(configurationBean);
+			}
+			return configurable;
+		} catch (ConfigurationException e) {
+			logger.error("Error configuring :"
+					+ configurable.getClass().getSimpleName(), e);
+			throw new EditException(e);
+		}
+	}
+
+	@Override
+	public final Configurable<T> getSubject() {
+		return configurable;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/Crystalizer.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/Crystalizer.java b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/Crystalizer.java
new file mode 100644
index 0000000..0b59b73
--- /dev/null
+++ b/taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/Crystalizer.java
@@ -0,0 +1,65 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.impl;
+
+import org.apache.taverna.invocation.Completion;
+import org.apache.taverna.invocation.IterationInternalEvent;
+import org.apache.taverna.workflowmodel.processor.activity.Job;
+
+/**
+ * Recieves Job and Completion events and emits Jobs unaltered. Completion
+ * events additionally cause registration of lists for each key in the datamap
+ * of the jobs at immediate child locations in the index structure. These list
+ * identifiers are sent in place of the Completion events.
+ * <p>
+ * State for a given process ID is purged when a final completion event is
+ * received so there is no need for an explicit cache purge operation in the
+ * public API (although for termination of partially complete workflows it may
+ * be sensible for subclasses to provide one)
+ * 
+ * @author Tom Oinn
+ */
+public interface Crystalizer {
+	/**
+	 * Receive a Job or Completion, Jobs are emitted unaltered and cached,
+	 * Completion events trigger registration of a corresponding list - this may
+	 * be recursive in nature if the completion event's index implies nested
+	 * lists which have not been registered.
+	 */
+	void receiveEvent(
+			IterationInternalEvent<? extends IterationInternalEvent<?>> event);
+
+	/**
+	 * This method is called when a new Job has been handled by the
+	 * AbstractCrystalizer, either by direct passthrough or by list
+	 * registration.
+	 * 
+	 */
+	void jobCreated(Job outputJob);
+
+	/**
+	 * Called whenever a completion not corresponding to a node in the cache is
+	 * generated. In many cases this is an indication of an error state, the
+	 * processor implementation should ensure that completion events are only
+	 * sent to the crystalizer if there has been at least one data event with a
+	 * lower depth on the same path.
+	 */
+	void completionCreated(Completion completion);
+}


[40/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ListService.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ListService.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ListService.java
new file mode 100644
index 0000000..3df2b5b
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ListService.java
@@ -0,0 +1,143 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+import static org.springframework.transaction.annotation.Propagation.REQUIRED;
+import static org.springframework.transaction.annotation.Propagation.SUPPORTS;
+
+import java.util.List;
+
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Provides facilities to register list of T2References, register empty lists at
+ * any given depth and to resolve appropriate T2Reference instances back to
+ * these lists. Registration operations assign names and lock the list contents
+ * as a result. This service operates strictly on T2References, it neither tries
+ * to nor is capable of any form of reference resolution, so aspects such as
+ * collection traversal are not handled here (these are performed by the top
+ * level reference service)
+ * 
+ * @author Tom Oinn
+ */
+@Transactional(propagation = SUPPORTS, readOnly = true)
+public interface ListService {
+	/**
+	 * Register a new list of T2References. The depth of the list will be
+	 * calculated based on the depth of the references within it - if these are
+	 * not uniform the list won't be created (all children of a list in T2 must
+	 * have the same depth as their siblings). Provided this constraint is
+	 * satisfied the list is named and stored in the backing store. The returned
+	 * list is at this point immutable, operations modifying it either directly
+	 * or through the ListIterator will fail with an IllegalStateException.
+	 * Implementations should copy the input list rather than keeping a
+	 * reference to it to preserve this property.
+	 * <p>
+	 * The created references will be related with a workflow run id passed
+	 * through ReferenceContext so we can track all data referenced by a
+	 * specific run.
+	 * 
+	 * @param items
+	 *            the T2Reference instances to store as a list.
+	 * @return a new IdentifiedList of T2Reference instances allocated with a
+	 *         T2Reference itself as the unique name and cached by the backing
+	 *         store.
+	 * @throws ListServiceException
+	 *             if there is a problem either with the specified list of
+	 *             references or with the storage subsystem.
+	 */
+	@Transactional(propagation = REQUIRED, readOnly = false)
+	IdentifiedList<T2Reference> registerList(List<T2Reference> items,
+			ReferenceContext context) throws ListServiceException;
+
+	/**
+	 * Register a new empty list with the specified depth. This is needed
+	 * because in the case of empty lists we can't calculate the depth from the
+	 * list items (what with there not being any!), but the depth property is
+	 * critical for the T2 iteration and collection management system in the
+	 * enactor - we need to know that this is an empty list that
+	 * <em>would have</em> contained lists, for example.
+	 * <p>
+	 * The created references will be related with a workflow run id passed
+	 * through ReferenceContext so we can track all data referenced by a
+	 * specific run.
+	 * 
+	 * @param depth
+	 *            the depth of the empty list, must be >=1
+	 * @return a new empty IdentifiedList allocated with a T2Reference itself as
+	 *         the unique name and cached by the backing store.
+	 * @throws ListServiceException
+	 *             if there is a problem with the storage subsystem or if called
+	 *             with an invalid depth argument
+	 */
+	@Transactional(propagation = REQUIRED, readOnly = false)
+	IdentifiedList<T2Reference> registerEmptyList(int depth,
+			ReferenceContext context) throws ListServiceException;
+
+	/**
+	 * Retrieve a previously named and registered list of T2Reference instances
+	 * identified by the specified T2Reference (which must be of type
+	 * T2ReferenceType.IdentifiedList)
+	 * 
+	 * @param id
+	 *            identifier of the list of reference to retrieve
+	 * @return an IdentifiedList of T2References. Note that because this list is
+	 *         named it is effectively immutable, if you want to modify the list
+	 *         you have to create and register a new list, you cannot modify the
+	 *         returned value of this directly. This is why there is no update
+	 *         method in the service or dao for reference lists.
+	 * @throws ListServiceException
+	 *             if anything goes wrong with the retrieval process or if there
+	 *             is something wrong with the reference (such as it being of
+	 *             the wrong reference type).
+	 */
+	IdentifiedList<T2Reference> getList(T2Reference id)
+			throws ListServiceException;
+
+	/**
+	 * Functionality the same as {@link #getList(T2Reference) getList} but in
+	 * asynchronous mode, returning immediately and using the supplied callback
+	 * to communicate its results.
+	 * 
+	 * @param id
+	 *            a {@link T2Reference} identifying an {@link IdentifiedList} to
+	 *            retrieve
+	 * @param callback
+	 *            a {@link ListServiceCallback} used to convey the results of
+	 *            the asynchronous call
+	 * @throws ListServiceException
+	 *             if the reference set service is not correctly configured.
+	 *             Exceptions encountered when performing the asynchronous call
+	 *             are not returned here, for obvious reasons, and are instead
+	 *             messaged through the callback interface.
+	 */
+	void getListAsynch(T2Reference id, ListServiceCallback callback)
+			throws ListServiceException;
+
+	@Transactional(propagation = SUPPORTS, readOnly = false)
+	boolean delete(T2Reference reference) throws ReferenceServiceException;
+
+	/**
+	 * Delete all {@link IdentifiedList}S used by the specific workflow run.
+	 */
+	@Transactional(propagation = SUPPORTS, readOnly = false)
+	void deleteIdentifiedListsForWorkflowRun(String workflowRunId)
+			throws ReferenceServiceException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ListServiceCallback.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ListServiceCallback.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ListServiceCallback.java
new file mode 100644
index 0000000..4915d39
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ListServiceCallback.java
@@ -0,0 +1,46 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * Callback interface used by asynchronous methods in the
+ * {@link ListService} interface
+ * 
+ * @author Tom Oinn
+ */
+public interface ListServiceCallback {
+	/**
+	 * Called when the requested {@link ReferenceSet} has been successfully
+	 * retrieved.
+	 * 
+	 * @param references
+	 *            the ReferenceSet requested
+	 */
+	void listRetrieved(IdentifiedList<T2Reference> references);
+
+	/**
+	 * Called if the retrieval failed for some reason
+	 * 
+	 * @param cause
+	 *            a ListServiceException explaining the retrieval
+	 *            failure
+	 */
+	void listRetrievalFailed(ListServiceException cause);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ListServiceException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ListServiceException.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ListServiceException.java
new file mode 100644
index 0000000..6379596
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ListServiceException.java
@@ -0,0 +1,47 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * Thrown by methods in the ListService interface if anything goes wrong with
+ * list registration or retrieval. Any underlying exceptions that can't be
+ * handled in the service layer are wrapped in this and re-thrown.
+ * 
+ * @author Tom Oinn
+ */
+public class ListServiceException extends RuntimeException {
+	private static final long serialVersionUID = 5049346991071587866L;
+
+	public ListServiceException() {
+		super();
+	}
+
+	public ListServiceException(String message) {
+		super(message);
+	}
+
+	public ListServiceException(Throwable cause) {
+		super(cause);
+	}
+
+	public ListServiceException(String message, Throwable cause) {
+		super(message, cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceContext.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceContext.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceContext.java
new file mode 100644
index 0000000..26b330b
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceContext.java
@@ -0,0 +1,65 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+import java.util.List;
+
+/**
+ * Many operations over the reference manager require access to an appropriate
+ * context. The context contains hooks out to platform level facilities such as
+ * the security agent framework (when used in conjunction with the enactor).
+ * <p>
+ * This interface is also used to pass in resources required by the external
+ * reference translation and construction SPIs. An example might be a translator
+ * from File to URL could work by copying the source file to a web share of some
+ * kind, but obviously this can't happen unless properties such as the location
+ * of the web share folder are known. These properties tend to be properties of
+ * the installation rather than of the code, referring as they do to resources
+ * on the machine hosting the reference manager (and elsewhere).
+ * <p>
+ * Where entities in the context represent properties of the platform rather
+ * than the 'session' they are likely to be configured in a central location
+ * such as a Spring context definition, this interface is neutral to those
+ * concerns.
+ * 
+ * @author Tom Oinn
+ */
+public interface ReferenceContext {
+	/**
+	 * Return a list of all entities in the resolution context which match the
+	 * supplied entity type argument.
+	 * 
+	 * @param <T>
+	 *            The generic type of the returned entity list. In general the
+	 *            compiler is smart enough that you don't need to specify this,
+	 *            it can pick it up from the entityType parameter.
+	 * @param entityType
+	 *            Class of entity to return. Use Object.class to return all
+	 *            entities within the reference context
+	 * @return a list of entities from the reference context which can be cast
+	 *         to the specified type.
+	 */
+	<T extends Object> List<T> getEntities(Class<T> entityType);
+
+	/**
+	 * Add an entity to the context.
+	 */
+	void addEntity(Object entity);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceService.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceService.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceService.java
new file mode 100644
index 0000000..1cb0147
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceService.java
@@ -0,0 +1,293 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+import static org.springframework.transaction.annotation.Propagation.REQUIRED;
+import static org.springframework.transaction.annotation.Propagation.SUPPORTS;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Top level access point to the reference manager for client code which is
+ * aware of references and error documents. Provides methods to store and
+ * retrieve instances of ReferenceSet, IdentifiedList&lt;T2Reference&gt; and
+ * ErrorDocument. Acts as an integration layer for the three sub-component
+ * service, providing in addition collection traversal and retrieval of lists of
+ * identified entities (ReferenceSet, IdentifiedList&lt;Identified&gt; and
+ * ErrorDocument) from a T2Reference identifying a list.
+ * <p>
+ * Also provides registration and retrieval logic for POJOs where supported by
+ * appropriate plug-in instances, these methods can be used by code which is not
+ * 'reference aware' to store and retrieve value types transparently.
+ * <p>
+ * Resolution of collections can happen at three different levels:
+ * <ol>
+ * <li>The embedded {@link ListService} resolves the collection ID to a list of
+ * child IDs, and doesn't traverse these children if they are themselves lists.
+ * Use the {@link #getListService()}.{@link ListService#getList(T2Reference)
+ * getList()} to call this method directly on the list service if you need this
+ * functionality, returning a list of {@link T2Reference}</li>
+ * <li>The {@link #resolveIdentifier(T2Reference, Set, ReferenceContext)
+ * resolveIdentifier} method in this service instead resolves to a fully
+ * realized collection of the entities which those IDs reference, and does
+ * recursively apply this to child lists, resulting in a nested collection
+ * structure where the leaf nodes are ReferenceSet and ErrorDocument instances
+ * and non-leaf are IdentifiedList of Identified (the super-interface for
+ * IdentifiedList, ReferenceSet and ErrorDocument). Use this method if you want
+ * to access the ExternalReferenceSPI and ErrorDocument entities directly
+ * because your code can act on a particular reference type - in general in
+ * these cases you would also be using the augmentation system to ensure that
+ * the required reference type was actually present in the collection structure.
+ * </li>
+ * <li>The third level of resolution is to render the identifier through
+ * {@link #renderIdentifier(T2Reference, Class, ReferenceContext)
+ * renderIdentifier} to a nested structure as in
+ * {@link #resolveIdentifier(T2Reference, Set, ReferenceContext)
+ * resolveIdentifier} but where the structure consists of POJOs of the specified
+ * type and lists or either list or the leaf type. This is used when your code
+ * is reference agnostic and just requires the values in an easy to consume
+ * fashion. Note that because this involves pulling the entire structure into
+ * memory it may not be suitable for large data, use with caution. This method
+ * will, unlike {@link #resolveIdentifier(T2Reference, Set, ReferenceContext)
+ * resolveIdentifier}, fail if the reference contains or is an error.</li>
+ * </ol>
+ * 
+ * @author Tom Oinn
+ */
+public interface ReferenceService {
+	/**
+	 * Perform recursive identifier resolution, building a collection structure
+	 * of Identified objects, any collection elements being IdentifiedLists of
+	 * Identified subclasses. If the id has depth 0 this will just return the
+	 * Identified to which that id refers.
+	 * 
+	 * @param id
+	 *            the T2Reference to resolve
+	 * @param ensureTypes
+	 *            a set of ExternalReferenceSPI classes, this is used to augment
+	 *            any resolved ReferenceSet instances to ensure that each one
+	 *            has at least one of the specified types. If augmentation is
+	 *            not required this can be set to null.
+	 * @param context
+	 *            the ReferenceContext to use to resolve this and any
+	 *            recursively resolved identifiers <br/>
+	 *            If null the implementation should insert a new empty context
+	 *            and proceed.
+	 * @return fully resolved Identified subclass - this is either a (recursive)
+	 *         IdentifiedList of Identified, a ReferenceSet or an ErrorDocument
+	 * @throws ReferenceServiceException
+	 *             if any problems occur during resolution
+	 */
+	@Transactional(propagation = REQUIRED, readOnly = false)
+	Identified resolveIdentifier(T2Reference id,
+			Set<Class<ExternalReferenceSPI>> ensureTypes,
+			ReferenceContext context) throws ReferenceServiceException;
+
+	/**
+	 * As resolveIdentifier but using a callback object and returning
+	 * immediately
+	 * 
+	 * @throws ReferenceServiceException
+	 *             if anything goes wrong with the setup of the resolution job.
+	 *             Any exceptions during the resolution process itself are
+	 *             communicated through the callback object.
+	 */
+	@Transactional(propagation = REQUIRED, readOnly = false)
+	void resolveIdentifierAsynch(T2Reference id,
+			Set<Class<ExternalReferenceSPI>> ensureTypes,
+			ReferenceContext context,
+			ReferenceServiceResolutionCallback callback)
+			throws ReferenceServiceException;
+
+	/**
+	 * Resolve the given identifier, building a POJO structure where the
+	 * non-list items are of the desired class. This makes of any external
+	 * references that can directly expose the appropriate object type, then, if
+	 * none are present in a given reference set, it attempts to locate a POJO
+	 * builder and uses the cheapest available reference to get an InputStream
+	 * and build the target object. If no appropriate builder or embedded value
+	 * can be found the process throws ReferenceServiceException, it also does
+	 * this if any error occurs during retrieval of a (potentially nested)
+	 * identifier.
+	 * <p>
+	 * This method will return a collection structure mirroring that of the
+	 * specified T2Reference, client code should use T2Reference.getDepth() to
+	 * determine the depth of this structure; a reference with depth of 0 means
+	 * that the object returned is of the specified class, one of depth 1 is a
+	 * list of this class and so on.
+	 * <p>
+	 * If the T2Reference contains or is an error this method will not retrieve
+	 * it, and instead throws ReferenceServiceException
+	 * 
+	 * @see StreamToValueConverterSPI
+	 * @see ValueCarryingExternalReference
+	 * @param id
+	 *            the T2Reference to render to a POJO
+	 * @param leafClass
+	 *            the java class for leaves in the resulting POJO structure
+	 * @param context
+	 *            a reference context, potentially used if required by the
+	 *            openStream methods of ExternalReferenceSPI implementations
+	 *            used as sources for the POJO construction <br/>
+	 *            If null the implementation should insert a new empty context
+	 *            and proceed.
+	 * @return a java structure as defined above
+	 * @throws ReferenceServiceException
+	 *             if anything fails during this process
+	 */
+	Object renderIdentifier(T2Reference id, Class<?> leafClass,
+			ReferenceContext context) throws ReferenceServiceException;
+
+	/**
+	 * The top level registration method is used to register either as yet
+	 * unregistered ErrorDocuments and ReferenceSets (if these are passed in and
+	 * already have an identifier this call does nothing) and arbitrarily nested
+	 * Lists of the same. In addition any ExternalReferenceSPI instances found
+	 * will be wrapped in a single item ReferenceSet and registered, and any
+	 * Throwables will be wrapped in an ErrorDocument and registered. Lists will
+	 * be converted to IdentifiedList&lt;T2Reference&gt; and registered if all
+	 * children can be (or were already) appropriately named.
+	 * <p>
+	 * This method is only valid on parameters of the following type :
+	 * <ol>
+	 * <li>{@link T2Reference} - returned immediately as itself, this is needed
+	 * because it means we can register lists of existing T2Reference</li>
+	 * <li>{@link ReferenceSet} - registered if not already registered,
+	 * otherwise returns existing T2Reference</li>
+	 * <li>{@link ErrorDocument} - same behaviour as ReferenceSet</li>
+	 * <li>{@link ExternalReferenceSPI} - wrapped in ReferenceSet, registered
+	 * and ID returned</li>
+	 * <li>Throwable - wrapped in {@link ErrorDocument} with no message,
+	 * registered and ID returned</li>
+	 * <li>List - all children are first registered, if this succeeds the list
+	 * is itself registered as an {@link IdentifiedList} of {@link T2Reference}
+	 * and its reference returned.</li>
+	 * </ol>
+	 * The exception to this is if the useConvertorSPI parameter is set to true
+	 * - in this case any objects which do not match the above allowed list will
+	 * be run through any available ValueToReferenceConvertorSPI instances in
+	 * turn until one succeeds or all fail, which may result in the creation of
+	 * ExternalReferenceSPI instances. As these can be registered such objects
+	 * will not cause an exception to be thrown.
+	 * 
+	 * @see ValueToReferenceConverterSPI
+	 * @param o
+	 *            the object to register with the reference system, must comply
+	 *            with and will be interpreted as shown in the type list above.
+	 * @param targetDepth
+	 *            the depth of the top level object supplied. This is needed
+	 *            when registering empty collections and error documents,
+	 *            whether as top level types or as members of a collection
+	 *            within the top level type. If registering a collection this is
+	 *            the collection depth, so a List of ReferenceSchemeSPI would be
+	 *            depth 1. Failing to specify this correctly will result in
+	 *            serious problems downstream so be careful! We can't catch all
+	 *            potential problems in this method (although some errors will
+	 *            be trapped).
+	 * @param useConverterSPI
+	 *            whether to attempt to use the ValueToReferenceConvertorSPI
+	 *            registry (if defined and available) to map arbitrary objects
+	 *            to ExternalReferenceSPI instances on the fly. The registry of
+	 *            converters is generally injected into the implementation of
+	 *            this service.
+	 * @param context
+	 *            ReferenceContext to use if required by component services,
+	 *            this is most likely to be used by the object to reference
+	 *            converters if engaged. <br/>
+	 *            If null the implementation should insert a new empty context
+	 *            and proceed.
+	 * @return a T2Reference to the registered object
+	 * @throws ReferenceServiceException
+	 *             if the object type (or, for collections, the recursive type
+	 *             of its contents) is not in the allowed list or if a problem
+	 *             occurs during registration. Also thrown if attempting to use
+	 *             the converter SPI without an attached registry.
+	 */
+	@Transactional(propagation = REQUIRED, readOnly = false)
+	T2Reference register(Object o, int targetDepth, boolean useConverterSPI,
+			ReferenceContext context) throws ReferenceServiceException;
+
+	/**
+	 * Given a string representation of a T2Reference create a new T2Reference
+	 * with the correct depth etc.
+	 * 
+	 * @param reference
+	 * @return a new T2Reference parsed from the original
+	 */
+	T2Reference referenceFromString(String reference);
+
+	@Transactional(propagation = SUPPORTS, readOnly = false)
+	boolean delete(T2Reference reference) throws ReferenceServiceException;
+
+	@Transactional(propagation = SUPPORTS, readOnly = false)
+	boolean delete(List<T2Reference> references)
+			throws ReferenceServiceException;
+
+	@Transactional(propagation = SUPPORTS, readOnly = false)
+	void deleteReferencesForWorkflowRun(String workflowRunId)
+			throws ReferenceServiceException;
+
+	/**
+	 * Returns the {@link ErrorDocumentService} this ReferenceService uses, use
+	 * this when you need functionality from that service explicitly.
+	 */
+	ErrorDocumentService getErrorDocumentService();
+
+	/**
+	 * Returns the {@link ReferenceSetService} this ReferenceService uses, use
+	 * this when you need functionality from that service explicitly.
+	 */
+	ReferenceSetService getReferenceSetService();
+
+	/**
+	 * Returns the {@link ListService} this ReferenceService uses, use this when
+	 * you need functionality from that service explicitly.
+	 */
+	ListService getListService();
+
+	/**
+	 * Initiates a traversal of the specified t2reference, traversing to
+	 * whatever level of depth is required such that all identifiers returned
+	 * within the iterator have the specified depth. The context (i.e. the index
+	 * path from the originally specified reference to each reference within the
+	 * iteration) is included through use of the ContextualizedT2Reference
+	 * wrapper class
+	 * 
+	 * @param source
+	 *            the T2Reference from which to traverse. In general this is the
+	 *            root of a collection structure.
+	 * @param desiredDepth
+	 *            the desired depth of all returned T2References, must be less
+	 *            than or equal to that of the source reference.
+	 * @throws ReferenceServiceException
+	 *             if unable to create the iterator for some reason. Note that
+	 *             implementations are free to lazily perform the iteration so
+	 *             this method may succeed but the iterator produced can fail
+	 *             when used. If the iterator fails it will do so by throwing
+	 *             one of the underlying sub-service exceptions.
+	 */
+	@Transactional(propagation = SUPPORTS, readOnly = true)
+	Iterator<ContextualizedT2Reference> traverseFrom(T2Reference source,
+			int desiredDepth);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceServiceCacheProvider.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceServiceCacheProvider.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceServiceCacheProvider.java
new file mode 100644
index 0000000..8602420
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceServiceCacheProvider.java
@@ -0,0 +1,51 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * A simple interface to be implemented by data access object cache providers,
+ * intended to be used to inject cache implementations through AoP
+ * 
+ * @author Tom Oinn
+ */
+public interface ReferenceServiceCacheProvider {
+	/**
+	 * Called after an {@link Identified} has been written to the backing store,
+	 * either for the first time or after modification. In our model
+	 * {@link ReferenceSet} is the only {@link Identified} that is modifiable,
+	 * specifically only by the addition of {@link ExternalReferenceSPI}
+	 * instances to its reference set.
+	 * 
+	 * @param i
+	 *            the Identified written to the backing store
+	 */
+	void put(Identified i);
+
+	/**
+	 * Called before an attempt is made to retrieve an item from the backing
+	 * store
+	 * 
+	 * @param id
+	 *            the T2Reference of the item to retrieve
+	 * @return a cached item with matching {@link T2Reference}, or <tt>null</tt>
+	 *         if the cache does not contain that item
+	 */
+	Identified get(T2Reference id);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceServiceException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceServiceException.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceServiceException.java
new file mode 100644
index 0000000..d7eb91d
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceServiceException.java
@@ -0,0 +1,46 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * Thrown by methods in the ReferenceService, used to wrap any underlying
+ * exceptions from lower layers.
+ * 
+ * @author Tom Oinn
+ */
+public class ReferenceServiceException extends RuntimeException {
+	private static final long serialVersionUID = -2607675495513408333L;
+
+	public ReferenceServiceException() {
+		//
+	}
+
+	public ReferenceServiceException(String message) {
+		super(message);
+	}
+
+	public ReferenceServiceException(Throwable cause) {
+		super(cause);
+	}
+
+	public ReferenceServiceException(String message, Throwable cause) {
+		super(message, cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceServiceResolutionCallback.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceServiceResolutionCallback.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceServiceResolutionCallback.java
new file mode 100644
index 0000000..7a6ffb5
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceServiceResolutionCallback.java
@@ -0,0 +1,46 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * Used by the asynchronous form of the resolveIdentifier method in
+ * {@link ReferenceService}
+ * 
+ * @author Tom Oinn
+ */
+public interface ReferenceServiceResolutionCallback {
+	/**
+	 * Called when the resolution process has completed
+	 * 
+	 * @param result
+	 *            the Identified that corresponds to the {@link T2Reference}
+	 *            specified in the call to
+	 *            {@link ReferenceService#resolveIdentifierAsynch}
+	 */
+	void identifierResolved(Identified result);
+
+	/**
+	 * Called when the resolution process has failed
+	 * 
+	 * @param cause
+	 *            a ReferenceServiceException describing the failure
+	 */
+	void resolutionFailed(ReferenceServiceException cause);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSet.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSet.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSet.java
new file mode 100644
index 0000000..d2be6c8
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSet.java
@@ -0,0 +1,52 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+import java.util.Set;
+
+/**
+ * A set of ExternalReferenceSPI instances, all of which point to the same (byte
+ * equivalent) data. The set is identified by a T2Reference. This interface is
+ * read-only, as are most of the interfaces in this package. Rather than
+ * modifying properties of the reference set directly the client code should use
+ * the reference manager functionality.
+ * <p>
+ * It is technically okay, but rather unhelpful, to have a ReferenceSet with no
+ * ExternalReferenceSPI implementations. In general this is a sign that
+ * something has gone wrong somewhere as the reference set will not be
+ * resolvable in any way, but it would still retain its unique identifier so
+ * there may be occasions where this is the desired behaviour.
+ * 
+ * @author Tom Oinn
+ */
+public interface ReferenceSet extends Identified {
+	/**
+	 * The reference set contains a set of ExternalReferenceSPI instances, all
+	 * of which point to byte equivalent data.
+	 * 
+	 * @return the set of references to external data
+	 */
+	Set<ExternalReferenceSPI> getExternalReferences();
+
+	/**
+	 * Get approximate size of the data pointed to by this ReferenceSet.
+	 */
+	Long getApproximateSizeInBytes();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetAugmentationException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetAugmentationException.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetAugmentationException.java
new file mode 100644
index 0000000..ff41f4d
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetAugmentationException.java
@@ -0,0 +1,46 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * Thrown when the reference set augmentor is unable to provide at least one of
+ * the desired types for any reason.
+ * 
+ * @author Tom Oinn
+ */
+public class ReferenceSetAugmentationException extends RuntimeException {
+	private static final long serialVersionUID = -6156508424485682266L;
+
+	public ReferenceSetAugmentationException() {
+		//
+	}
+
+	public ReferenceSetAugmentationException(String message) {
+		super(message);
+	}
+
+	public ReferenceSetAugmentationException(Throwable cause) {
+		super(cause);
+	}
+
+	public ReferenceSetAugmentationException(String message, Throwable cause) {
+		super(message, cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetAugmentor.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetAugmentor.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetAugmentor.java
new file mode 100644
index 0000000..fcde110
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetAugmentor.java
@@ -0,0 +1,91 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+import java.util.Set;
+
+/**
+ * Provides a framework to find and engage appropriate instances of
+ * {@link ExternalReferenceTranslatorSPI} and
+ * {@link ExternalReferenceBuilderSPI} to build external references from,
+ * respectively, other external references and from streams. These are then used
+ * to augment the contents of implementations of {@link ReferenceSet} with
+ * additional {@link ExternalReferenceSPI} implementations.
+ * <p>
+ * Methods in this interface throw the runtime exception
+ * {@link ReferenceSetAugmentationException} for all problems, other exceptions
+ * are wrapped in this type and re-thrown.
+ * 
+ * @author Tom Oinn
+ */
+public interface ReferenceSetAugmentor {
+	/**
+	 * Attempts to modify the supplied ReferenceSet such that it contains an
+	 * implementation of at least one of the ExternalReferenceSPI classes
+	 * specified. Uses the supplied context if required to build or translate
+	 * existing references within the reference set.
+	 * 
+	 * @param references
+	 *            reference set object to augment
+	 * @param targetReferenceTypes
+	 *            a set of Class objects, this method succeeds if it can create
+	 *            an instance of at least one of these pointing to the same data
+	 *            as the other external references in the supplied reference set
+	 * @param context
+	 *            a reference resolution context, potentially required for
+	 *            access to the existing references or for creation of the
+	 *            augmentations
+	 * @return a set of new ExternalReferenceSPI instances such that the union
+	 *         of this set with the pre-existing reference set satisfies the
+	 *         target reference constraint. It is the responsibility of the
+	 *         caller to re-integrate these references into the original
+	 *         ReferenceSet if so desired.
+	 * @throws ReferenceSetAugmentationException
+	 *             if a problem occurs either in configuration of the
+	 *             ReferenceSetAugmentor or in the augmentation process itself.
+	 *             Any other exception types are wrapped in this and re-thrown.
+	 */
+	Set<ExternalReferenceSPI> augmentReferenceSet(ReferenceSet references,
+			Set<Class<ExternalReferenceSPI>> targetReferenceTypes,
+			ReferenceContext context) throws ReferenceSetAugmentationException;
+
+	/**
+	 * As with {@link #augmentReferenceSet(ReferenceSet, Set, ReferenceContext)}
+	 * but called in an asynchronous fashion. Returns immediately and uses the
+	 * supplied instance of {@link ReferenceSetAugmentorCallback} to provide
+	 * either the augmented {@link ReferenceSet} or an exception indicating a
+	 * failure in the augmentation process.
+	 * 
+	 * @param callback
+	 *            callback object used to indicate failure or to return the
+	 *            modified reference set
+	 * @throws ReferenceSetAugmentationException
+	 *             if the ReferenceSetAugmentor is missing critical
+	 *             configuration. Exceptions that happen during augmentation or
+	 *             as a result of a failure to find an appropriate augmentation
+	 *             path are signalled by calls to the callback object, this
+	 *             method only throws the exception if it can't even try to do
+	 *             the augmentation for some reason.
+	 */
+	void augmentReferenceSetAsynch(ReferenceSet references,
+			Set<Class<ExternalReferenceSPI>> targetReferenceTypes,
+			ReferenceContext context, ReferenceSetAugmentorCallback callback)
+			throws ReferenceSetAugmentationException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetAugmentorCallback.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetAugmentorCallback.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetAugmentorCallback.java
new file mode 100644
index 0000000..3f53dd0
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetAugmentorCallback.java
@@ -0,0 +1,52 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+import java.util.Set;
+
+/**
+ * Callback interface used when augmenting a ReferenceSet in an asynchronous
+ * fashion through
+ * {@link ReferenceSetAugmentor#augmentReferenceSetAsynch(ReferenceSet, Set, ReferenceContext, ReferenceSetAugmentorCallback)
+ * augmentReferenceSetAsynch} in {@link ReferenceSetAugmentor}.
+ * 
+ * @author Tom Oinn
+ */
+public interface ReferenceSetAugmentorCallback {
+	/**
+	 * Called when the augmentation has succeeded
+	 * 
+	 * @param newReferences
+	 *            a set of ExternalReferenceSPI instances created during the
+	 *            augmentation process. It is the responsibility of the caller
+	 *            to re-integrate these back into the ReferenceSet used in the
+	 *            translation
+	 */
+	void augmentationCompleted(Set<ExternalReferenceSPI> newReferences);
+
+	/**
+	 * Called when the augmentation has failed for some reason
+	 * 
+	 * @param cause
+	 *            a {@link ReferenceSetAugmentationException} object describing
+	 *            the failure.
+	 */
+	void augmentationFailed(ReferenceSetAugmentationException cause);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetDao.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetDao.java
new file mode 100644
index 0000000..6b6332e
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetDao.java
@@ -0,0 +1,81 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+import static org.springframework.transaction.annotation.Propagation.REQUIRED;
+import static org.springframework.transaction.annotation.Propagation.SUPPORTS;
+
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Data Access Object interface for {@link ReferenceSet}. Used by the
+ * {@link ReferenceSetService} to store and retrieve implementations of
+ * reference set to and from the database. Client code should use the reference
+ * set service rather than using this Dao directly.
+ * <p>
+ * All methods throw DaoException, and nothing else. Where a deeper error is
+ * propagated it is wrapped in a DaoException and passed on to the caller.
+ * 
+ * @author Tom Oinn
+ */
+public interface ReferenceSetDao {
+	/**
+	 * Store the specified new reference set
+	 * 
+	 * @param rs
+	 *            a reference set, must not already exist in the database.
+	 * @throws DaoException
+	 *             if the entry already exists in the database or some other
+	 *             database related problem occurs
+	 */
+	@Transactional(propagation = REQUIRED, readOnly = false)
+	void store(ReferenceSet rs) throws DaoException;
+
+	/**
+	 * Update a pre-existing entry in the database
+	 * 
+	 * @param rs
+	 *            the reference set to update. This must already exist in the
+	 *            database
+	 * @throws DaoException
+	 */
+	@Transactional(propagation = REQUIRED, readOnly = false)
+	void update(ReferenceSet rs) throws DaoException;
+
+	/**
+	 * Fetch a reference set by id
+	 * 
+	 * @param ref
+	 *            the T2Reference to fetch
+	 * @return a retrieved ReferenceSet
+	 * @throws DaoException
+	 *             if the supplied reference is of the wrong type or if
+	 *             something goes wrong fetching the data or connecting to the
+	 *             database
+	 */
+	@Transactional(propagation = SUPPORTS, readOnly = true)
+	ReferenceSet get(T2Reference ref) throws DaoException;
+
+	@Transactional(propagation = SUPPORTS, readOnly = false)
+	boolean delete(ReferenceSet rs) throws DaoException;
+
+	@Transactional(propagation = SUPPORTS, readOnly = false)
+	void deleteReferenceSetsForWFRun(String workflowRunId) throws DaoException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetService.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetService.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetService.java
new file mode 100644
index 0000000..5a9327f
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetService.java
@@ -0,0 +1,180 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+import static org.springframework.transaction.annotation.Propagation.REQUIRED;
+import static org.springframework.transaction.annotation.Propagation.SUPPORTS;
+
+import java.util.Set;
+
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Provides facilities to register sets of ExternalReferenceSPI implementations
+ * within the reference manager and to retrieve these sets by T2Reference either
+ * as stored or with translation support. In general applications should be
+ * using this interface (where only ReferenceSet functionality is required) or
+ * the support classes which in turn use this and the collection and error
+ * handling interfaces to present a unified view over the various components of
+ * the reference management system.
+ * 
+ * @author Tom Oinn
+ */
+@Transactional(propagation = SUPPORTS, readOnly = true)
+public interface ReferenceSetService {
+	/**
+	 * Register a set of {@link ExternalReferenceSPI} instances, all of which
+	 * should point to byte equivalent data, and return the newly created
+	 * {@link ReferenceSet}. This method blocks on the underlying store, but
+	 * guarantees that the returned value has been persisted.
+	 * <p>
+	 * The created references will be related with a workflow run id passed
+	 * through ReferenceContext so we can track all data referenced by a
+	 * specific run.
+	 * 
+	 * @param references
+	 *            a set of {@link ExternalReferenceSPI} implementations to
+	 *            register as a {@link ReferenceSet}
+	 * @return the registered {@link ReferenceSet}
+	 */
+	@Transactional(propagation = REQUIRED, readOnly = false)
+	ReferenceSet registerReferenceSet(Set<ExternalReferenceSPI> references,
+			ReferenceContext context) throws ReferenceSetServiceException;
+
+	/**
+	 * Get a previously registered {@link ReferenceSet} by {@link T2Reference}.
+	 * Note that this method blocks and may take some time to return in the case
+	 * of distributed reference managers; if this is likely to be an issue then
+	 * you should use the asynchronous form
+	 * {@link #getReferenceSetAsynch(T2Reference, ReferenceSetServiceCallback)
+	 * getReferenceSetAsynch} instead of this method.
+	 * 
+	 * @param id
+	 *            a {@link T2Reference} identifying a {@link ReferenceSet} to
+	 *            retrieve
+	 * @return the requested {@link ReferenceSet}
+	 */
+	ReferenceSet getReferenceSet(T2Reference id)
+			throws ReferenceSetServiceException;
+
+	/**
+	 * Functionality the same as {@link #getReferenceSet(T2Reference)
+	 * getReferenceSet} but in asynchronous mode, returning immediately and
+	 * using the supplied callback to communicate its results.
+	 * 
+	 * @param id
+	 *            a {@link T2Reference} identifying a {@link ReferenceSet} to
+	 *            retrieve
+	 * @param callback
+	 *            a {@link ReferenceSetServiceCallback} used to convey the
+	 *            results of the asynchronous call
+	 * @throws ReferenceSetServiceException
+	 *             if the reference set service is not correctly configured.
+	 *             Exceptions encountered when performing the asynchronous call
+	 *             are not returned here, for obvious reasons, and are instead
+	 *             messaged through the callback interface.
+	 */
+	void getReferenceSetAsynch(T2Reference id,
+			ReferenceSetServiceCallback callback)
+			throws ReferenceSetServiceException;
+
+	/**
+	 * Functionality the same as {@link #getReferenceSet(T2Reference)
+	 * getReferenceSet} but with the additional option to specify a set of
+	 * {@link ExternalReferenceSPI} classes. The reference set manager will
+	 * attempt to ensure that the returned {@link ReferenceSet} contains an
+	 * instance of at least one of the specified classes. This method blocks,
+	 * and may potentially incur both the remote lookup overhead of the simpler
+	 * version of this call and any translation logic. It is <em>strongly</em>
+	 * recommended that you do not use this version of the call and instead use
+	 * the asynchronous form
+	 * {@link #getReferenceSetWithAugmentationAsynch(T2Reference, Set, ReferenceContext, ReferenceSetServiceCallback)
+	 * getReferenceSetWithAugmentationAsynch} instead.
+	 * <p>
+	 * If the translation logic cannot provide at least one of the required
+	 * types this call will fail, even if the {@link ReferenceSet} requested is
+	 * otherwise available.
+	 * 
+	 * @param id
+	 *            a {@link T2Reference} identifying a {@link ReferenceSet} to
+	 *            retrieve
+	 * @param ensureTypes
+	 *            a set of {@link ExternalReferenceSPI} classes. The framework
+	 *            will attempt to ensure there is an instance of at least one of
+	 *            these classes in the returned {@link ReferenceSet}
+	 * @param context
+	 *            if translation of references is required the translation
+	 *            infrastructure will need information in this
+	 *            {@link ReferenceContext} parameter.
+	 *            <p>
+	 *            If null the implementation should insert a new empty context
+	 *            and proceed.
+	 * @return the requested {@link ReferenceSet}
+	 */
+	@Transactional(propagation = REQUIRED, readOnly = false)
+	ReferenceSet getReferenceSetWithAugmentation(T2Reference id,
+			Set<Class<ExternalReferenceSPI>> ensureTypes,
+			ReferenceContext context) throws ReferenceSetServiceException;
+
+	/**
+	 * Functionality as
+	 * {@link #getReferenceSetWithAugmentation(T2Reference, Set, ReferenceContext)
+	 * getReferenceSetWithAugmentation} but with the addition of a callback
+	 * interface to report the result or failure of the method.
+	 * 
+	 * @param id
+	 *            a {@link T2Reference} identifying a {@link ReferenceSet} to
+	 *            retrieve
+	 * @param ensureTypes
+	 *            a set of {@link ExternalReferenceSPI} classes. The framework
+	 *            will attempt to ensure there is an instance of at least one of
+	 *            these classes in the returned {@link ReferenceSet}
+	 * @param context
+	 *            if translation of references is required the translation
+	 *            infrastructure will need information in this
+	 *            {@link ReferenceContext} parameter.
+	 *            <p>
+	 *            If null the implementation should insert a new empty context
+	 *            and proceed.
+	 * @param callback
+	 *            a {@link ReferenceSetServiceCallback} used to convey the
+	 *            results of the asynchronous call *
+	 * @throws ReferenceSetServiceException
+	 *             if the reference set service is not correctly configured.
+	 *             Exceptions encountered when performing the asynchronous call
+	 *             are not returned here, for obvious reasons, and are instead
+	 *             messaged through the callback interface.
+	 */
+	@Transactional(propagation = REQUIRED, readOnly = false)
+	void getReferenceSetWithAugmentationAsynch(T2Reference id,
+			Set<Class<ExternalReferenceSPI>> ensureTypes,
+			ReferenceContext context, ReferenceSetServiceCallback callback)
+			throws ReferenceSetServiceException;
+
+	@Transactional(propagation = SUPPORTS, readOnly = false)
+	boolean delete(T2Reference reference) throws ReferenceServiceException;
+
+	/**
+	 * Delete all {@link ReferenceSet}S used by the specific workflow run.
+	 */
+	@Transactional(propagation = SUPPORTS, readOnly = false)
+	void deleteReferenceSetsForWorkflowRun(String workflowRunId)
+			throws ReferenceServiceException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetServiceCallback.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetServiceCallback.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetServiceCallback.java
new file mode 100644
index 0000000..670fec2
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetServiceCallback.java
@@ -0,0 +1,46 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * Callback interface used by asynchronous methods in the
+ * {@link ReferenceSetService} interface
+ * 
+ * @author Tom Oinn
+ */
+public interface ReferenceSetServiceCallback {
+	/**
+	 * Called when the requested {@link ReferenceSet} has been successfully
+	 * retrieved.
+	 * 
+	 * @param references
+	 *            the ReferenceSet requested
+	 */
+	void referenceSetRetrieved(ReferenceSet references);
+
+	/**
+	 * Called if the retrieval failed for some reason
+	 * 
+	 * @param cause
+	 *            a ReferenceSetServiceException explaining the retrieval
+	 *            failure
+	 */
+	void referenceSetRetrievalFailed(ReferenceSetServiceException cause);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetServiceException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetServiceException.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetServiceException.java
new file mode 100644
index 0000000..9381d7e
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferenceSetServiceException.java
@@ -0,0 +1,47 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * RuntimeException subclass thrown by the reference set service layer
+ * interfaces. All underlying exceptions are either handled by the service layer
+ * or wrapped in this exception (or a subclass) and rethrown.
+ * 
+ * @author Tom Oinn
+ */
+public class ReferenceSetServiceException extends RuntimeException {
+	private static final long serialVersionUID = -2762995062729638168L;
+
+	public ReferenceSetServiceException() {
+		//
+	}
+
+	public ReferenceSetServiceException(String message) {
+		super(message);
+	}
+
+	public ReferenceSetServiceException(Throwable cause) {
+		super(cause);
+	}
+
+	public ReferenceSetServiceException(String message, Throwable cause) {
+		super(message, cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferencedDataNature.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferencedDataNature.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferencedDataNature.java
new file mode 100644
index 0000000..b1b7f2c
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ReferencedDataNature.java
@@ -0,0 +1,44 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * Where possible ExternalReferenceSPI implementations should be able to
+ * determine whether the data they refer to is textual or binary in nature. This
+ * enumeration contains values for textual, binary and unknown data natures.
+ * 
+ * @author Tom Oinn
+ */
+public enum ReferencedDataNature {
+	/**
+	 * The data is binary, no character encoding will be specified.
+	 */
+	BINARY,
+
+	/**
+	 * The data is textual, character encoding may be defined.
+	 */
+	TEXT,
+
+	/**
+	 * Unknown data nature.
+	 */
+	UNKNOWN;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/StackTraceElementBean.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/StackTraceElementBean.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/StackTraceElementBean.java
new file mode 100644
index 0000000..70ce0d2
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/StackTraceElementBean.java
@@ -0,0 +1,53 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * Used by the {@link ErrorDocument} interface to represent a frame within a
+ * stack trace
+ * 
+ * @author Tom Oinn
+ * @see StackTraceElement
+ */
+public interface StackTraceElementBean {
+	/**
+	 * Returns the fully qualified name of the class containing the execution
+	 * point represented by this stack trace element.
+	 */
+	String getClassName();
+
+	/**
+	 * Returns the name of the source file containing the execution point
+	 * represented by this stack trace element.
+	 */
+	String getFileName();
+
+	/**
+	 * Returns the line number of the source line containing the execution point
+	 * represented by this stack trace element.
+	 */
+	int getLineNumber();
+
+	/**
+	 * Returns the name of the method containing the execution point represented
+	 * by this stack trace element.
+	 */
+	String getMethodName();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/StreamToValueConverterSPI.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/StreamToValueConverterSPI.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/StreamToValueConverterSPI.java
new file mode 100644
index 0000000..e618523
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/StreamToValueConverterSPI.java
@@ -0,0 +1,47 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+import java.io.InputStream;
+
+/**
+ * SPI for objects that can render a POJO from an InputStream
+ * 
+ * @author Tom Oinn
+ */
+public interface StreamToValueConverterSPI<T> {
+	/**
+	 * The class of objects which this builder can construct from a stream
+	 */
+	Class<T> getPojoClass();
+
+	/**
+	 * Render the stream to the target object type
+	 * 
+	 * @param stream
+	 *            input stream of data to render to the object; the caller will
+	 *            close it
+	 * @param charset
+	 * @param dataNature
+	 * @return the newly created object
+	 */
+	T renderFrom(InputStream stream, ReferencedDataNature dataNature,
+			String charset);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/T2Reference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/T2Reference.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/T2Reference.java
new file mode 100644
index 0000000..96f7330
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/T2Reference.java
@@ -0,0 +1,101 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+import java.net.URI;
+
+/**
+ * The T2Reference is used within the workflow system to refer to any entity
+ * within the reference management system, whether reference set, list or error
+ * document. The reference carries certain properties which can be evaluated
+ * without resolution, these include a depth property and whether the reference
+ * either is or contains an error document at any point in its structure.
+ * 
+ * @author Tom Oinn
+ */
+public interface T2Reference {
+	/**
+	 * To determine the entity that this reference points to we use an
+	 * enumeration of possible entity types
+	 * 
+	 * @return the type of entity to which this reference refers.
+	 */
+	T2ReferenceType getReferenceType();
+
+	/**
+	 * All entities identified by a T2Reference have a conceptual depth. In the
+	 * case of lists the depth is the (uniform) depth of any item in the list
+	 * plus one, in the case of reference sets the depth is 0. Error documents
+	 * and empty lists may also have non zero depth; error documents in
+	 * particular have a depth corresponding to the depth of the list or
+	 * reference set that would have been created if there was no error.
+	 * 
+	 * @return the depth of the entity identified by this T2Reference
+	 */
+	int getDepth();
+
+	/**
+	 * Error documents always return true, as do any lists where at least one
+	 * immediate child of the list returns true when this property is evaluated.
+	 * As lists are immutable this property is actually set on list
+	 * registration. This is used to determine whether to allow POJO resolution
+	 * of the entity identified by this T2Reference - this is configurable by
+	 * the caller but there will be some cases where an attempt to render a
+	 * collection containing errors to a POJO should return an error and other
+	 * occasions when it should return a collection containing error objects.
+	 * <p>
+	 * ReferenceSet implementations always return false.
+	 * 
+	 * @return whether the entity identified by this T2Reference either is or
+	 *         contains an error document. Containment is transitive, so a list
+	 *         containing a list that contained an error would return true.
+	 */
+	boolean containsErrors();
+
+	/**
+	 * T2Reference instances retain a reference to the reference manager which
+	 * created them in the form of a namespace. This is an opaque string
+	 * matching the regular expression [a-zA-Z_0-9]+, and is immutable once
+	 * assigned (as are the other properties of this interface). The reference
+	 * manager infrastructure uses this namespace property primarily to
+	 * differentiate between cases where a reference cannot be resolved because
+	 * of a lack of connection to the appropriate remote reference manager and
+	 * those where the reference simply does not exist anywhere.
+	 * 
+	 * @return the namespace of this T2Reference as a string.
+	 */
+	String getNamespacePart();
+
+	/**
+	 * In addition to the namespace the T2Reference contains a local identifier.
+	 * This identifier is unique in the context of the namespace and is also
+	 * represented as a string matching the regular expression [a-z_A-Z0-9]+
+	 * 
+	 * @return the local part of this T2Reference as a string.
+	 */
+	String getLocalPart();
+
+	/**
+	 * All T2Reference instances can be represented as a URI.
+	 * 
+	 * @return representation of this T2Reference as a URI
+	 */
+	URI toUri();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/T2ReferenceGenerator.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/T2ReferenceGenerator.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/T2ReferenceGenerator.java
new file mode 100644
index 0000000..1ba4376
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/T2ReferenceGenerator.java
@@ -0,0 +1,80 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * Provides new unique T2Reference instances. Used by and injected into the
+ * various service interface implementations when registering new reference
+ * sets, error documents and lists.
+ * 
+ * @author Tom Oinn
+ * @see T2Reference
+ */
+public interface T2ReferenceGenerator {
+	/**
+	 * All T2Reference objects will have this namespace
+	 * 
+	 * @return the namespace as a string
+	 */
+	String getNamespace();
+
+	/**
+	 * Create a new and otherwise unused T2Reference to a ReferenceSet. The
+	 * namespace of the reference will depend on the current workflow run read
+	 * from the ReferenceContext.
+	 * 
+	 * @return new T2Reference for a ReferenceSet, namespace and local parts
+	 *         will be initialized and the reference is ready to use when
+	 *         returned.
+	 */
+	T2Reference nextReferenceSetReference(ReferenceContext context);
+
+	/**
+	 * Create a new and otherwise unused T2Reference to an IdentifiedList. The
+	 * namespace of the reference will depend on the current workflow run read
+	 * from the ReferenceContext.
+	 * 
+	 * @param containsErrors
+	 *            whether the list this reference is generated for contains
+	 *            t2references with their containsErrors property set to true.
+	 *            Returns true if <em>any</em> reference in the list is or
+	 *            contains an error.
+	 * @param listDepth
+	 *            depth of the list to which this identifier will be applied
+	 * @return a new T2Reference for an IdentifiedList. Namespace, type and
+	 *         local parts will be initialized but depth and error content will
+	 *         still be at their default values of '0' and 'false' respectively,
+	 *         these will need to be re-set before the reference is viable.
+	 */
+	T2Reference nextListReference(boolean containsErrors, int listDepth,
+			ReferenceContext context);
+
+	/**
+	 * Create a new and otherwise unused T2Reference to an ErrorDocument. The
+	 * namespace of the reference will depend on the current workflow run read
+	 * from the ReferenceContext.
+	 * 
+	 * @param depth
+	 *            the depth of the error document to which this identifier will
+	 *            refer
+	 * @return a new T2Reference for an ErrorDocument
+	 */
+	T2Reference nextErrorDocumentReference(int depth, ReferenceContext context);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/T2ReferenceType.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/T2ReferenceType.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/T2ReferenceType.java
new file mode 100644
index 0000000..fc2743a
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/T2ReferenceType.java
@@ -0,0 +1,46 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * The T2Reference interface is used to identify several different kinds of
+ * information, namely ReferenceSet, IdentifiedList and ErrorDocument. Because
+ * the top level reference service needs to determine which sub-service to
+ * delegate to when resolving references we carry this information in each
+ * T2Reference in the form of one of these enumerated types.
+ * 
+ * @author Tom Oinn
+ */
+public enum T2ReferenceType {
+	/**
+	 * A reference to a ReferenceSet
+	 */
+	ReferenceSet,
+
+	/**
+	 * A reference to an IdentifiedList of other T2References
+	 */
+	IdentifiedList,
+
+	/**
+	 * A reference to an ErrorDocument
+	 */
+	ErrorDocument;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ValueCarryingExternalReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ValueCarryingExternalReference.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ValueCarryingExternalReference.java
new file mode 100644
index 0000000..3fd54d5
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ValueCarryingExternalReference.java
@@ -0,0 +1,43 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * Specialization of ExternalReferenceSPI for reference types which carry a
+ * value type internally. Such references can be de-referenced to the specified
+ * object type very cheaply. Note that this is not to be used to get an object
+ * property of a reference, the returned object must correspond to the value of
+ * the referenced data - this means that the HttpUrlReference does not use this
+ * to return a java.net.URL, but that the InlineStringReference does use it to
+ * return a java.lang.String
+ * 
+ * @author Tom Oinn
+ */
+public interface ValueCarryingExternalReference<T> extends ExternalReferenceSPI {
+	/**
+	 * Returns the type of the inlined value
+	 */
+	Class<T> getValueType();
+
+	/**
+	 * Returns the value
+	 */
+	T getValue();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ValueToReferenceConversionException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ValueToReferenceConversionException.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ValueToReferenceConversionException.java
new file mode 100644
index 0000000..7e2ba25
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ValueToReferenceConversionException.java
@@ -0,0 +1,47 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * Thrown by instances of ValueToReferenceConvertor when trying to convert an
+ * object to an instance of ExternalReferenceSPI if the conversion process fails
+ * for some reason.
+ * 
+ * @author Tom Oinn
+ */
+public class ValueToReferenceConversionException extends RuntimeException {
+	private static final long serialVersionUID = 3259959719223191820L;
+
+	public ValueToReferenceConversionException() {
+		//
+	}
+
+	public ValueToReferenceConversionException(String message) {
+		super(message);
+	}
+
+	public ValueToReferenceConversionException(Throwable cause) {
+		super(cause);
+	}
+
+	public ValueToReferenceConversionException(String message, Throwable cause) {
+		super(message, cause);
+	}
+}


[33/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceSetServiceTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceSetServiceTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceSetServiceTest.java
deleted file mode 100644
index fc445ae..0000000
--- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceSetServiceTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package net.sf.taverna.t2.reference.impl;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-
-import net.sf.taverna.t2.reference.ReferenceSet;
-import net.sf.taverna.t2.reference.ReferenceSetDao;
-import net.sf.taverna.t2.reference.WorkflowRunIdEntity;
-
-import org.junit.Before;
-import org.junit.Test;
-
-public class ReferenceSetServiceTest {
-	
-	private List<ReferenceSetServiceImpl> serviceList = new ArrayList<ReferenceSetServiceImpl>();
-
-	@Before
-	public void setup() throws Exception {
-
-		AppContextSetup.setup();
-
-		ReferenceSetServiceImpl service = null;
-
-		service = new ReferenceSetServiceImpl();
-		service.setReferenceSetDao((ReferenceSetDao)AppContextSetup.contextList.get(0).getBean("testDao")); // hibernate
-		service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());	
-		serviceList.add(service);
-		
-		service = new ReferenceSetServiceImpl();
-		service.setReferenceSetDao((ReferenceSetDao)AppContextSetup.contextList.get(1).getBean("testDao")); // in memory
-		service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());	
-		serviceList.add(service);
-		
-		service = new ReferenceSetServiceImpl();
-		service.setReferenceSetDao((ReferenceSetDao)AppContextSetup.contextList.get(2).getBean("testDao")); // transactional hibernate
-		service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());	
-		serviceList.add(service);
-
-	}
-	
-	@Test
-	@SuppressWarnings({ "rawtypes", "unchecked" })
-	public void testDelete() throws Exception {
-		ReferenceContextImpl invocationContext = new ReferenceContextImpl();
-		invocationContext.addEntity(new WorkflowRunIdEntity("wfRunRefSetTest0"));
-		for (ReferenceSetServiceImpl service : serviceList){
-			ReferenceSet set = service.registerReferenceSet(new HashSet(), invocationContext);
-			assertNotNull(service.getReferenceSet(set.getId()));
-			assertTrue(service.delete(set.getId()));
-			assertNull(service.getReferenceSet(set.getId()));
-			assertFalse(service.delete(set.getId()));
-		}
-	}
-	
-	@Test
-	@SuppressWarnings({ "rawtypes", "unchecked" })
-	public void testDeleteReferenceSetsForWFRun() throws Exception {
-
-		for (ReferenceSetServiceImpl service : serviceList){
-			
-			String wfRunId1 = "wfRunRefSetTest1";
-			ReferenceContextImpl invocationContext1 = new ReferenceContextImpl();
-			invocationContext1.addEntity(new WorkflowRunIdEntity(wfRunId1));
-			
-			String wfRunId2 = "wfRunRefSetTest2";
-			ReferenceContextImpl invocationContext2 = new ReferenceContextImpl();
-			invocationContext2.addEntity(new WorkflowRunIdEntity(wfRunId2));
-			
-			ReferenceSet set1 = service.registerReferenceSet(new HashSet(), invocationContext1);
-			ReferenceSet set2 = service.registerReferenceSet(new HashSet(), invocationContext1);
-			ReferenceSet set3 = service.registerReferenceSet(new HashSet(), invocationContext2);
-
-			assertNotNull(service.getReferenceSet(set1.getId()));
-			assertNotNull(service.getReferenceSet(set2.getId()));
-			assertNotNull(service.getReferenceSet(set3.getId()));
-
-			service.deleteReferenceSetsForWorkflowRun(wfRunId1);
-			
-			assertNull(service.getReferenceSet(set1.getId()));
-			assertNull(service.getReferenceSet(set2.getId()));
-			assertNotNull(service.getReferenceSet(set3.getId()));
-
-		}
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/TranslationPathTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/TranslationPathTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/TranslationPathTest.java
deleted file mode 100644
index 35d6f64..0000000
--- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/TranslationPathTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package net.sf.taverna.t2.reference.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Set;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferenceSet;
-import net.sf.taverna.t2referencetest.DummyReferenceSet;
-import net.sf.taverna.t2referencetest.GreenBuilder;
-import net.sf.taverna.t2referencetest.GreenReference;
-import net.sf.taverna.t2referencetest.GreenToRed;
-import net.sf.taverna.t2referencetest.RedReference;
-
-import org.junit.Test;
-
-public class TranslationPathTest {
-
-	protected TranslationPath path  = new TranslationPath();
-	
-	@Test
-	public void doTranslationWithTranslator() throws Exception {
-		ReferenceContext context = new EmptyReferenceContext();
-		ReferenceSet rs = new DummyReferenceSet(new GreenReference("green"));		
-		path.getTranslators().add(new GreenToRed());
-		Set<ExternalReferenceSPI> set = path.doTranslation(rs, context);		
-		assertEquals(1, set.size());
-		assertTrue(set.iterator().next() instanceof RedReference);
-	}
-	
-	@Test
-	public void doTranslationByReadingStream() throws Exception {
-		ReferenceContext context = new EmptyReferenceContext();
-		path.setSourceReference(new RedReference("red"));
-		ReferenceSet rs = new DummyReferenceSet(path.getSourceReference());
-		path.setInitialBuilder(new GreenBuilder());
-		//augmentor.path.translators.add(new DummyTranslator());
-		Set<ExternalReferenceSPI> set = path.doTranslation(rs, context);		
-		assertEquals(1, set.size());
-		assertTrue(set.iterator().next() instanceof GreenReference);
-	}
-
-	
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/org/apache/taverna/platform/spring/jdbc/TemporaryJDBCTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/platform/spring/jdbc/TemporaryJDBCTest.java b/taverna-reference-impl/src/test/java/org/apache/taverna/platform/spring/jdbc/TemporaryJDBCTest.java
new file mode 100644
index 0000000..2432cbb
--- /dev/null
+++ b/taverna-reference-impl/src/test/java/org/apache/taverna/platform/spring/jdbc/TemporaryJDBCTest.java
@@ -0,0 +1,59 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.spring.jdbc;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+
+import org.junit.Test;
+
+/**
+ * Test {@link TemporaryJDBC}
+ * 
+ * @author Stian Soiland-Reyes
+ *
+ */
+public class TemporaryJDBCTest {
+
+	private static final String DB = ".db";
+	private static final String T2PLATFORM = "t2platform-";
+	private static final String CREATE_TRUE = ";create=true";
+	private static final String JDBC_DERBY = "jdbc:derby:";
+
+	@Test
+	public void getDerby() throws Exception {
+		TemporaryJDBC temporaryJDBC = new TemporaryJDBC();
+		String jdbcURL = temporaryJDBC.getTemporaryDerbyJDBC();
+		assertTrue("Not a Derby URL", jdbcURL.startsWith(JDBC_DERBY));
+		String url = jdbcURL.split(JDBC_DERBY)[1];
+		assertTrue("Did not end with " + CREATE_TRUE, url.endsWith(CREATE_TRUE));
+		String location = url.split(CREATE_TRUE)[0];
+		assertFalse("Location was an empty string", location.equals(""));
+		File locationFile = new File(location);
+		assertFalse("File already exists: " + locationFile, locationFile.exists());
+		File parentFile = locationFile.getParentFile();
+		assertTrue("Parent directory did not exist", parentFile.isDirectory());
+		assertTrue("Did not end with " + T2PLATFORM, parentFile.getName().startsWith(T2PLATFORM));
+		assertTrue("Did not start with " + DB , parentFile.getName().endsWith(DB));
+	}
+	
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/AppContextSetup.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/AppContextSetup.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/AppContextSetup.java
new file mode 100644
index 0000000..fb3d1f0
--- /dev/null
+++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/AppContextSetup.java
@@ -0,0 +1,50 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class AppContextSetup {
+	public static List<ApplicationContext> contextList;
+
+	public static void setup() throws Exception {
+		if (contextList == null){
+			
+			contextList = new ArrayList<ApplicationContext>();
+			//Add all three contexts for storing referenced data
+			contextList = new ArrayList<ApplicationContext>();
+			ApplicationContext context = null;
+			context = new ClassPathXmlApplicationContext(
+					"vanillaHibernateAppContext.xml"); // hibernate context
+			contextList.add(context);
+			context = new ClassPathXmlApplicationContext(
+			"vanillaInMemoryAppContext.xml");
+			contextList.add(context); // in memory
+			context = new ClassPathXmlApplicationContext(
+			"vanillaHibernateTransactionalAppContext.xml");
+			contextList.add(context);	 // transactional hibernate context
+			
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/DatabaseSetupTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/DatabaseSetupTest.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/DatabaseSetupTest.java
new file mode 100644
index 0000000..265719c
--- /dev/null
+++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/DatabaseSetupTest.java
@@ -0,0 +1,139 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import java.util.HashSet;
+
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ListDao;
+import org.apache.taverna.reference.ReferenceSet;
+import org.apache.taverna.reference.ReferenceSetDao;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.T2ReferenceType;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * Tests initialization of the Derby database and Hibernate ORM system
+ * 
+ * @author Tom Oinn
+ */
+public class DatabaseSetupTest {
+
+	@Before
+	public void setup() throws Exception {
+		AppContextSetup.setup();
+	}
+	
+	
+	@Test
+	public void testListStorage() {
+			ApplicationContext context = AppContextSetup.contextList.get(0); // Hibernate context
+			ListDao o = (ListDao) context.getBean("testListDao");
+			T2ReferenceImpl listReference = new T2ReferenceImpl();
+			listReference.setContainsErrors(false);
+			listReference.setDepth(1);
+			listReference.setLocalPart("list1");
+			listReference.setNamespacePart("testNamespace");
+			listReference.setReferenceType(T2ReferenceType.IdentifiedList);
+
+			T2ReferenceListImpl l = new T2ReferenceListImpl();
+
+			T2ReferenceImpl itemId1 = new T2ReferenceImpl();
+			itemId1.setNamespacePart("testNamespace");
+			itemId1.setLocalPart("item1");
+			T2ReferenceImpl itemId2 = new T2ReferenceImpl();
+			itemId2.setNamespacePart("testNamespace");
+			itemId2.setLocalPart("item2");
+
+			l.add(itemId1);
+			l.add(itemId2);
+
+			l.setTypedId(listReference);
+
+			System.out.println(l);
+
+			o.store(l);
+
+			T2ReferenceImpl listReference2 = new T2ReferenceImpl();
+			listReference2.setContainsErrors(false);
+			listReference2.setDepth(1);
+			listReference2.setLocalPart("list1");
+			listReference2.setNamespacePart("testNamespace");
+			listReference2.setReferenceType(T2ReferenceType.IdentifiedList);
+
+			System.out.println(o.get(listReference2));
+
+	}
+
+	@SuppressWarnings("serial")
+	@Test
+	public void testDatabaseReadWriteWithoutPlugins() {
+			ApplicationContext context = AppContextSetup.contextList.get(0); // Hibernate context
+			ReferenceSetDao o = (ReferenceSetDao) context
+					.getBean("testDao");
+			T2ReferenceImpl id = new T2ReferenceImpl();
+			id.setNamespacePart("testNamespace");
+			id.setLocalPart("testLocal");
+			ReferenceSetImpl rs = new ReferenceSetImpl(
+					new HashSet<ExternalReferenceSPI>(), id);
+			o.store(rs);
+			
+			
+			// Retrieve with a new instance of an anonymous subclass of
+			// ReferenceSetT2ReferenceImpl, just to check that hibernate can cope
+			// with this. It can, but this *must* be a subclass of the registered
+			// component type, which means we need to modify the component type to
+			// be the fully generic T2Reference with all fields accessed via
+			// properties.
+			T2Reference newReference = new T2ReferenceImpl() {
+
+				@Override
+				public boolean containsErrors() {
+					return false;
+				}
+
+				@Override
+				public int getDepth() {
+					return 0;
+				}
+
+				@Override
+				public String getLocalPart() {
+					return "testLocal";
+				}
+
+				@Override
+				public String getNamespacePart() {
+					return "testNamespace";
+				}
+
+			};
+
+			
+			ReferenceSet returnedset = o.get(newReference);
+			Assert.assertNotNull(returnedset.getId());	
+
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ErrorDocumentDaoTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ErrorDocumentDaoTest.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ErrorDocumentDaoTest.java
new file mode 100644
index 0000000..107986d
--- /dev/null
+++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ErrorDocumentDaoTest.java
@@ -0,0 +1,170 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.taverna.reference.ErrorDocumentDao;
+import org.apache.taverna.reference.T2ReferenceType;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+
+public class ErrorDocumentDaoTest {
+	
+	@Before
+	public void setup() throws Exception {
+		AppContextSetup.setup();
+	}
+	
+	@Test
+	public void testStore() throws Exception {
+		for (ApplicationContext context : AppContextSetup.contextList){
+			
+			ErrorDocumentDao dao = (ErrorDocumentDao) context.getBean("testErrorDao");
+			ErrorDocumentImpl doc = new ErrorDocumentImpl();
+			T2ReferenceImpl id = new T2ReferenceImpl();
+			id.setReferenceType(T2ReferenceType.ErrorDocument);
+			id.setDepth(0);
+			id.setContainsErrors(true);
+			id.setNamespacePart("testNamespace0");		
+			id.setLocalPart("testLocal0");
+			
+			doc.setExceptionMessage("An exception");		
+			
+			T2ReferenceImpl typedId = T2ReferenceImpl.getAsImpl(id);
+			
+			doc.setTypedId(typedId);
+			
+			dao.store(doc);
+			assertNotNull(dao.get(id));	
+		}
+	}
+	
+	/**
+	 * Tests that .get returns null when its missing, rather than throw an exception
+	 */
+	@Test
+	public void getMissingItemReturnsNull() {
+		for (ApplicationContext context : AppContextSetup.contextList){
+			ErrorDocumentDao dao = (ErrorDocumentDao) context.getBean("testErrorDao");
+			ErrorDocumentImpl doc = new ErrorDocumentImpl();
+			T2ReferenceImpl id = new T2ReferenceImpl();
+			id.setReferenceType(T2ReferenceType.ErrorDocument);
+			id.setDepth(0);
+			id.setContainsErrors(true);
+			id.setNamespacePart("testNamespace1");		
+			id.setLocalPart("testLocal1");
+			
+			doc.setExceptionMessage("An exception");		
+			
+			T2ReferenceImpl typedId = T2ReferenceImpl.getAsImpl(id);
+			
+			doc.setTypedId(typedId);
+			assertNull(dao.get(id));	
+		}
+	}
+	
+	@Test
+	public void testDelete() throws Exception {
+		for (ApplicationContext context : AppContextSetup.contextList){
+			
+			ErrorDocumentDao dao = (ErrorDocumentDao) context.getBean("testErrorDao");
+			ErrorDocumentImpl doc = new ErrorDocumentImpl();
+			T2ReferenceImpl id = new T2ReferenceImpl();
+			id.setReferenceType(T2ReferenceType.ErrorDocument);
+			id.setDepth(0);
+			id.setContainsErrors(true);
+			id.setNamespacePart("testNamespace2");		
+			id.setLocalPart("testLocal2");
+			
+			doc.setExceptionMessage("An exception");		
+			
+			T2ReferenceImpl typedId = T2ReferenceImpl.getAsImpl(id);
+			
+			doc.setTypedId(typedId);
+			
+			dao.store(doc);
+			assertNotNull(dao.get(id));
+			
+			assertTrue(dao.delete(doc));		
+			assertNull(dao.get(id));	
+		}
+
+	}
+
+	@Test
+	public void testDeleteErrorDocumentsForWFRun() throws Exception {
+		for (ApplicationContext context : AppContextSetup.contextList){
+			
+			ErrorDocumentDao dao = (ErrorDocumentDao) context.getBean("testErrorDao");
+			
+			ErrorDocumentImpl doc1 = new ErrorDocumentImpl();	
+			T2ReferenceImpl id1 = new T2ReferenceImpl();
+			id1.setReferenceType(T2ReferenceType.ErrorDocument);
+			id1.setDepth(0);
+			id1.setContainsErrors(true);
+			id1.setNamespacePart("wfRunErrorDocTest1");		
+			id1.setLocalPart("testLocal1");		
+			doc1.setExceptionMessage("An exception 1");			
+			T2ReferenceImpl typedId1 = T2ReferenceImpl.getAsImpl(id1);		
+			doc1.setTypedId(typedId1);	
+			dao.store(doc1);
+			assertNotNull(dao.get(id1));
+			
+			ErrorDocumentImpl doc2 = new ErrorDocumentImpl();	
+			T2ReferenceImpl id2 = new T2ReferenceImpl();
+			id2.setReferenceType(T2ReferenceType.ErrorDocument);
+			id2.setDepth(0);
+			id2.setContainsErrors(true);
+			id2.setNamespacePart("wfRunErrorDocTest1");		
+			id2.setLocalPart("testLocal2");		
+			doc2.setExceptionMessage("An exception 2");			
+			T2ReferenceImpl typedId2 = T2ReferenceImpl.getAsImpl(id2);		
+			doc2.setTypedId(typedId2);	
+			dao.store(doc2);
+			assertNotNull(dao.get(id2));
+			
+			ErrorDocumentImpl doc3 = new ErrorDocumentImpl();	
+			T2ReferenceImpl id3 = new T2ReferenceImpl();
+			id3.setReferenceType(T2ReferenceType.ErrorDocument);
+			id3.setDepth(0);
+			id3.setContainsErrors(true);
+			id3.setNamespacePart("wfRunErrorDocTest2");		
+			id3.setLocalPart("testLocal3");		
+			doc3.setExceptionMessage("An exception 3");			
+			T2ReferenceImpl typedId3 = T2ReferenceImpl.getAsImpl(id3);		
+			doc3.setTypedId(typedId3);	
+			dao.store(doc3);
+			assertNotNull(dao.get(id3));
+			
+			dao.deleteErrorDocumentsForWFRun("wfRunErrorDocTest1");
+			
+			assertNull(dao.get(id1));			
+			assertNull(dao.get(id2));
+			assertNotNull(dao.get(id3));	
+		}
+
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ErrorDocumentServiceTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ErrorDocumentServiceTest.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ErrorDocumentServiceTest.java
new file mode 100644
index 0000000..a7b8425
--- /dev/null
+++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ErrorDocumentServiceTest.java
@@ -0,0 +1,107 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.taverna.reference.ErrorDocument;
+import org.apache.taverna.reference.ErrorDocumentDao;
+import org.apache.taverna.reference.WorkflowRunIdEntity;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class ErrorDocumentServiceTest {
+	
+	private List<ErrorDocumentServiceImpl> serviceList = new ArrayList<ErrorDocumentServiceImpl>();
+	
+	@Before
+	public void setup() throws Exception {
+		
+		AppContextSetup.setup();
+		
+		ErrorDocumentServiceImpl service = null;
+
+			service = new ErrorDocumentServiceImpl();
+			service.setErrorDao((ErrorDocumentDao)AppContextSetup.contextList.get(0).getBean("testErrorDao")); // hiberate
+			service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
+			serviceList.add(service);	
+		
+			service = new ErrorDocumentServiceImpl();
+			service.setErrorDao((ErrorDocumentDao)AppContextSetup.contextList.get(1).getBean("testErrorDao")); // in memory
+			service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
+			serviceList.add(service);
+		
+			service = new ErrorDocumentServiceImpl();
+			service.setErrorDao((ErrorDocumentDao)AppContextSetup.contextList.get(2).getBean("testErrorDao")); // transactional hibernate
+			service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
+			serviceList.add(service);
+				
+	}
+	
+	@Test
+	public void testDelete() throws Exception {
+		ReferenceContextImpl invocationContext = new ReferenceContextImpl();
+		invocationContext.addEntity(new WorkflowRunIdEntity("wfRunErrorDocTest"));
+		for (ErrorDocumentServiceImpl service : serviceList){
+			ErrorDocument doc = service.registerError("Fred", 0, invocationContext);
+			assertNotNull(service.getError(doc.getId()));
+			assertTrue(service.delete(doc.getId()));
+			assertNull(service.getError(doc.getId()));
+			assertFalse(service.delete(doc.getId()));
+		}
+	}
+
+	@Test
+	public void testDeleteErrorDocumentsForWFRun() throws Exception {
+
+		for (ErrorDocumentServiceImpl service : serviceList){
+			
+			String wfRunId1 = "wfRunErrorDocTest1";
+			ReferenceContextImpl invocationContext1 = new ReferenceContextImpl();
+			invocationContext1.addEntity(new WorkflowRunIdEntity(wfRunId1));
+			
+			String wfRunId2 = "wfRunErrorDocTest2";
+			ReferenceContextImpl invocationContext2 = new ReferenceContextImpl();
+			invocationContext2.addEntity(new WorkflowRunIdEntity(wfRunId2));
+			
+			ErrorDocument doc1 = service.registerError("Fred1", 0, invocationContext1);
+			ErrorDocument doc2 = service.registerError("Fred2", 0, invocationContext1);
+			ErrorDocument doc3 = service.registerError("Fred3", 0, invocationContext2);
+
+			assertNotNull(service.getError(doc1.getId()));
+			assertNotNull(service.getError(doc2.getId()));
+			assertNotNull(service.getError(doc3.getId()));
+
+			service.deleteErrorDocumentsForWorkflowRun(wfRunId1);
+			
+			assertNull(service.getError(doc1.getId()));
+			assertNull(service.getError(doc2.getId()));
+			assertNotNull(service.getError(doc3.getId()));
+
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ListDaoTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ListDaoTest.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ListDaoTest.java
new file mode 100644
index 0000000..6ae7496
--- /dev/null
+++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ListDaoTest.java
@@ -0,0 +1,140 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.taverna.reference.ListDao;
+import org.apache.taverna.reference.T2ReferenceType;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+
+public class ListDaoTest {
+	
+	@Before
+	public void setup() throws Exception {
+		AppContextSetup.setup();
+	}
+	
+	@Test
+	public void testStore() throws Exception {
+		for (ApplicationContext context : AppContextSetup.contextList){
+			ListDao dao = (ListDao)context.getBean("testListDao");
+			T2ReferenceImpl r = new T2ReferenceImpl();
+			r.setNamespacePart("testNamespace0");
+			r.setLocalPart("testLocal0");
+			r.setReferenceType(T2ReferenceType.IdentifiedList);
+			r.setDepth(0);
+			r.setContainsErrors(false);
+			T2ReferenceListImpl newList = new T2ReferenceListImpl();
+			newList.setTypedId(r);
+			dao.store(newList);
+			assertNotNull(dao.get(r));	
+		}	
+	}
+	
+	/**
+	 * Tests that .get returns null when its missing, rather than throw an exception
+	 */
+	@Test
+	public void getMissingItemReturnsNull() {
+		for (ApplicationContext context : AppContextSetup.contextList){
+			ListDao dao = (ListDao)context.getBean("testListDao");
+			T2ReferenceImpl r = new T2ReferenceImpl();
+			r.setNamespacePart("testNamespace1");
+			r.setLocalPart("testLocal1");
+			r.setReferenceType(T2ReferenceType.IdentifiedList);
+			r.setDepth(0);
+			r.setContainsErrors(false);
+			T2ReferenceListImpl newList = new T2ReferenceListImpl();
+			newList.setTypedId(r);
+			assertNull(dao.get(r));
+		}
+	}
+	
+	@Test
+	public void testDelete() throws Exception {
+		for (ApplicationContext context : AppContextSetup.contextList){
+			ListDao dao = (ListDao)context.getBean("testListDao");
+			T2ReferenceImpl r = new T2ReferenceImpl();
+			r.setNamespacePart("testNamespace2");
+			r.setLocalPart("testLocal2");
+			r.setReferenceType(T2ReferenceType.IdentifiedList);
+			r.setDepth(0);
+			r.setContainsErrors(false);
+			T2ReferenceListImpl newList = new T2ReferenceListImpl();
+			newList.setTypedId(r);
+			dao.store(newList);
+			assertNotNull(dao.get(r));	
+			assertTrue(dao.delete(newList));
+			assertNull(dao.get(r));	
+		}	
+	}
+
+	@Test
+	public void testIdentifiedListsForWFRun() throws Exception {
+		for (ApplicationContext context : AppContextSetup.contextList){
+			ListDao dao = (ListDao)context.getBean("testListDao");
+			
+			T2ReferenceImpl r1 = new T2ReferenceImpl();
+			r1.setReferenceType(T2ReferenceType.IdentifiedList);
+			r1.setDepth(0);
+			r1.setContainsErrors(true);
+			r1.setNamespacePart("wfRunListsTest1");		
+			r1.setLocalPart("testLocal1");		
+			T2ReferenceListImpl list1 = new T2ReferenceListImpl();		
+			list1.setTypedId(r1);	
+			dao.store(list1);
+			assertNotNull(dao.get(r1));
+			
+			T2ReferenceImpl r2 = new T2ReferenceImpl();
+			r2.setReferenceType(T2ReferenceType.IdentifiedList);
+			r2.setDepth(1);
+			r2.setContainsErrors(true);
+			r2.setNamespacePart("wfRunListsTest1");		
+			r2.setLocalPart("testLocal2");		
+			T2ReferenceListImpl list2 = new T2ReferenceListImpl();		
+			list2.setTypedId(r2);	
+			dao.store(list2);
+			assertNotNull(dao.get(r2));
+			
+			T2ReferenceImpl r3 = new T2ReferenceImpl();
+			r3.setReferenceType(T2ReferenceType.IdentifiedList);
+			r3.setDepth(0);
+			r3.setContainsErrors(true);
+			r3.setNamespacePart("wfRunListsTest2");		
+			r3.setLocalPart("testLocal3");		
+			T2ReferenceListImpl list3 = new T2ReferenceListImpl();		
+			list3.setTypedId(r3);	
+			dao.store(list3);
+			assertNotNull(dao.get(r3));
+			
+			dao.deleteIdentifiedListsForWFRun("wfRunListsTest1");
+			
+			assertNull(dao.get(r1));			
+			assertNull(dao.get(r2));
+			assertNotNull(dao.get(r3));	
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ListServiceTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ListServiceTest.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ListServiceTest.java
new file mode 100644
index 0000000..1d40730
--- /dev/null
+++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ListServiceTest.java
@@ -0,0 +1,110 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.taverna.reference.IdentifiedList;
+import org.apache.taverna.reference.ListDao;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.WorkflowRunIdEntity;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class ListServiceTest {
+	
+	private List<ListServiceImpl> serviceList = new ArrayList<ListServiceImpl>();
+
+	@Before
+	public void setup() throws Exception {
+		
+		AppContextSetup.setup();
+		
+		ListServiceImpl service = null;
+		
+			service = new ListServiceImpl();
+			service.setListDao((ListDao)AppContextSetup.contextList.get(0).getBean("testListDao")); // hibernate
+			service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());	
+			serviceList.add(service);
+		
+			service = new ListServiceImpl();
+			service.setListDao((ListDao)AppContextSetup.contextList.get(1).getBean("testListDao")); // in memory
+			service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());	
+			serviceList.add(service);
+
+		
+			service = new ListServiceImpl();
+			service.setListDao((ListDao)AppContextSetup.contextList.get(2).getBean("testListDao")); // transactional hibernate
+			service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());	
+			serviceList.add(service);
+		
+	}
+	
+	@Test
+	public void testDelete() throws Exception {
+		ReferenceContextImpl invocationContext = new ReferenceContextImpl();
+		invocationContext.addEntity(new WorkflowRunIdEntity("wfRunListsTest"));
+		for (ListServiceImpl service : serviceList){
+			IdentifiedList<T2Reference> list =service.registerEmptyList(1, invocationContext);
+			assertNotNull(service.getList(list.getId()));
+			assertTrue(service.delete(list.getId()));
+			assertNull(service.getList(list.getId()));
+			assertFalse(service.delete(list.getId()));
+		}
+	}
+	
+	@Test
+	public void testDeleteIdentifiedListsForWFRun() throws Exception {
+
+		for (ListServiceImpl service : serviceList){
+			
+			String wfRunId1 = "wfRunListsTest1";
+			ReferenceContextImpl invocationContext1 = new ReferenceContextImpl();
+			invocationContext1.addEntity(new WorkflowRunIdEntity(wfRunId1));
+			
+			String wfRunId2 = "wfRunListsTest2";
+			ReferenceContextImpl invocationContext2 = new ReferenceContextImpl();
+			invocationContext2.addEntity(new WorkflowRunIdEntity(wfRunId2));
+			
+			IdentifiedList<T2Reference> list1 = service.registerEmptyList(2, invocationContext1);
+			IdentifiedList<T2Reference> list2 = service.registerEmptyList(1, invocationContext1);
+			IdentifiedList<T2Reference> list3 = service.registerEmptyList(1, invocationContext2);
+
+			assertNotNull(service.getList(list1.getId()));
+			assertNotNull(service.getList(list2.getId()));
+			assertNotNull(service.getList(list3.getId()));
+
+			service.deleteIdentifiedListsForWorkflowRun(wfRunId1);
+			
+			assertNull(service.getList(list1.getId()));
+			assertNull(service.getList(list2.getId()));
+			assertNotNull(service.getList(list3.getId()));
+
+		}
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceContextImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceContextImpl.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceContextImpl.java
new file mode 100644
index 0000000..557710c
--- /dev/null
+++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceContextImpl.java
@@ -0,0 +1,49 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.taverna.reference.ReferenceContext;
+
+class ReferenceContextImpl implements ReferenceContext{
+	private List<Object> entities;
+
+	public ReferenceContextImpl(){
+		entities = new ArrayList<Object>();
+	}
+	
+	@Override
+	public <T> List<T> getEntities(Class<T> entityType) {
+		List<T> entitiesOfType = new ArrayList<T>();
+		for (Object entity : entities){
+			if (entityType.isInstance(entity)){
+				entitiesOfType.add(entityType.cast(entity));
+			}
+		}
+		return entitiesOfType;
+	}
+
+	@Override
+	public void addEntity(Object entity){
+		entities.add(entity);
+	}
+};

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceSetDaoTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceSetDaoTest.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceSetDaoTest.java
new file mode 100644
index 0000000..6409837
--- /dev/null
+++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceSetDaoTest.java
@@ -0,0 +1,124 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashSet;
+
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceSetDao;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+
+public class ReferenceSetDaoTest {
+
+	@Before
+	public void setup() throws Exception {
+
+		AppContextSetup.setup();
+	}
+
+	@Test
+	public void testStore() throws Exception {
+		for (ApplicationContext context : AppContextSetup.contextList){
+			ReferenceSetDao dao = (ReferenceSetDao) context.getBean("testDao");
+			T2ReferenceImpl id = new T2ReferenceImpl();
+			id.setNamespacePart("testNamespace0");		
+			id.setLocalPart("testLocal0");
+			ReferenceSetImpl rs = new ReferenceSetImpl(
+					new HashSet<ExternalReferenceSPI>(), id);
+			dao.store(rs);
+			assertNotNull(dao.get(id));
+		}
+	}
+	
+	@Test
+	public void testDelete() throws Exception {
+		for (ApplicationContext context : AppContextSetup.contextList){
+			ReferenceSetDao dao = (ReferenceSetDao) context.getBean("testDao");
+			T2ReferenceImpl id = new T2ReferenceImpl();
+			id.setNamespacePart("testNamespace1");
+			id.setLocalPart("testLocal1");
+			ReferenceSetImpl rs = new ReferenceSetImpl(
+					new HashSet<ExternalReferenceSPI>(), id);		
+			dao.store(rs);
+			assertNotNull(dao.get(id));
+			assertTrue(dao.delete(rs));
+			assertNull(dao.get(id));
+		}
+	}
+	
+	@Test
+	public void testDeleteRerefenceSetsForWFRun() throws Exception {
+		for (ApplicationContext context : AppContextSetup.contextList){
+			ReferenceSetDao dao = (ReferenceSetDao) context.getBean("testDao");
+			
+			T2ReferenceImpl id1 = new T2ReferenceImpl();
+			id1.setNamespacePart("wfRunRefSetTest1");
+			id1.setLocalPart("testLocal1");
+			ReferenceSetImpl rs1 = new ReferenceSetImpl(
+					new HashSet<ExternalReferenceSPI>(), id1);		
+			dao.store(rs1);
+			assertNotNull(dao.get(id1));
+			
+			T2ReferenceImpl id2 = new T2ReferenceImpl();
+			id2.setNamespacePart("wfRunRefSetTest1");
+			id2.setLocalPart("testLocal2");
+			ReferenceSetImpl rs2 = new ReferenceSetImpl(
+					new HashSet<ExternalReferenceSPI>(), id2);		
+			dao.store(rs2);
+			assertNotNull(dao.get(id2));
+			
+			T2ReferenceImpl id3 = new T2ReferenceImpl();
+			id3.setNamespacePart("wfRunRefSetTest2");
+			id3.setLocalPart("testLocal3");
+			ReferenceSetImpl rs3 = new ReferenceSetImpl(
+					new HashSet<ExternalReferenceSPI>(), id3);		
+			dao.store(rs3);
+			assertNotNull(dao.get(id3));
+			
+			dao.deleteReferenceSetsForWFRun("wfRunRefSetTest1");
+			
+			assertNull(dao.get(id1));			
+			assertNull(dao.get(id2));
+			assertNotNull(dao.get(id3));	
+		}
+	}
+	
+	/**
+	 * Tests that .get returns null when its missing, rather than throw an exception
+	 */
+	@Test
+	public void getMissingItemReturnsNull() {
+		for (ApplicationContext context : AppContextSetup.contextList){
+			ReferenceSetDao dao = (ReferenceSetDao) context.getBean("testDao");
+			T2ReferenceImpl id = new T2ReferenceImpl();
+			id.setNamespacePart("testNamespace2");		
+			id.setLocalPart("testLocal2");
+			assertNull(dao.get(id));
+		}
+	}
+		
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceSetServiceTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceSetServiceTest.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceSetServiceTest.java
new file mode 100644
index 0000000..8eb39f4
--- /dev/null
+++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceSetServiceTest.java
@@ -0,0 +1,111 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+
+import org.apache.taverna.reference.ReferenceSet;
+import org.apache.taverna.reference.ReferenceSetDao;
+import org.apache.taverna.reference.WorkflowRunIdEntity;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class ReferenceSetServiceTest {
+	
+	private List<ReferenceSetServiceImpl> serviceList = new ArrayList<ReferenceSetServiceImpl>();
+
+	@Before
+	public void setup() throws Exception {
+
+		AppContextSetup.setup();
+
+		ReferenceSetServiceImpl service = null;
+
+		service = new ReferenceSetServiceImpl();
+		service.setReferenceSetDao((ReferenceSetDao)AppContextSetup.contextList.get(0).getBean("testDao")); // hibernate
+		service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());	
+		serviceList.add(service);
+		
+		service = new ReferenceSetServiceImpl();
+		service.setReferenceSetDao((ReferenceSetDao)AppContextSetup.contextList.get(1).getBean("testDao")); // in memory
+		service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());	
+		serviceList.add(service);
+		
+		service = new ReferenceSetServiceImpl();
+		service.setReferenceSetDao((ReferenceSetDao)AppContextSetup.contextList.get(2).getBean("testDao")); // transactional hibernate
+		service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());	
+		serviceList.add(service);
+
+	}
+	
+	@Test
+	@SuppressWarnings({ "rawtypes", "unchecked" })
+	public void testDelete() throws Exception {
+		ReferenceContextImpl invocationContext = new ReferenceContextImpl();
+		invocationContext.addEntity(new WorkflowRunIdEntity("wfRunRefSetTest0"));
+		for (ReferenceSetServiceImpl service : serviceList){
+			ReferenceSet set = service.registerReferenceSet(new HashSet(), invocationContext);
+			assertNotNull(service.getReferenceSet(set.getId()));
+			assertTrue(service.delete(set.getId()));
+			assertNull(service.getReferenceSet(set.getId()));
+			assertFalse(service.delete(set.getId()));
+		}
+	}
+	
+	@Test
+	@SuppressWarnings({ "rawtypes", "unchecked" })
+	public void testDeleteReferenceSetsForWFRun() throws Exception {
+
+		for (ReferenceSetServiceImpl service : serviceList){
+			
+			String wfRunId1 = "wfRunRefSetTest1";
+			ReferenceContextImpl invocationContext1 = new ReferenceContextImpl();
+			invocationContext1.addEntity(new WorkflowRunIdEntity(wfRunId1));
+			
+			String wfRunId2 = "wfRunRefSetTest2";
+			ReferenceContextImpl invocationContext2 = new ReferenceContextImpl();
+			invocationContext2.addEntity(new WorkflowRunIdEntity(wfRunId2));
+			
+			ReferenceSet set1 = service.registerReferenceSet(new HashSet(), invocationContext1);
+			ReferenceSet set2 = service.registerReferenceSet(new HashSet(), invocationContext1);
+			ReferenceSet set3 = service.registerReferenceSet(new HashSet(), invocationContext2);
+
+			assertNotNull(service.getReferenceSet(set1.getId()));
+			assertNotNull(service.getReferenceSet(set2.getId()));
+			assertNotNull(service.getReferenceSet(set3.getId()));
+
+			service.deleteReferenceSetsForWorkflowRun(wfRunId1);
+			
+			assertNull(service.getReferenceSet(set1.getId()));
+			assertNull(service.getReferenceSet(set2.getId()));
+			assertNotNull(service.getReferenceSet(set3.getId()));
+
+		}
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/TranslationPathTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/TranslationPathTest.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/TranslationPathTest.java
new file mode 100644
index 0000000..aae12e6
--- /dev/null
+++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/TranslationPathTest.java
@@ -0,0 +1,65 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferenceSet;
+import org.apache.taverna.t2referencetest.DummyReferenceSet;
+import org.apache.taverna.t2referencetest.GreenBuilder;
+import org.apache.taverna.t2referencetest.GreenReference;
+import org.apache.taverna.t2referencetest.GreenToRed;
+import org.apache.taverna.t2referencetest.RedReference;
+
+import org.junit.Test;
+
+public class TranslationPathTest {
+
+	protected TranslationPath path  = new TranslationPath();
+	
+	@Test
+	public void doTranslationWithTranslator() throws Exception {
+		ReferenceContext context = new EmptyReferenceContext();
+		ReferenceSet rs = new DummyReferenceSet(new GreenReference("green"));		
+		path.getTranslators().add(new GreenToRed());
+		Set<ExternalReferenceSPI> set = path.doTranslation(rs, context);		
+		assertEquals(1, set.size());
+		assertTrue(set.iterator().next() instanceof RedReference);
+	}
+	
+	@Test
+	public void doTranslationByReadingStream() throws Exception {
+		ReferenceContext context = new EmptyReferenceContext();
+		path.setSourceReference(new RedReference("red"));
+		ReferenceSet rs = new DummyReferenceSet(path.getSourceReference());
+		path.setInitialBuilder(new GreenBuilder());
+		//augmentor.path.translators.add(new DummyTranslator());
+		Set<ExternalReferenceSPI> set = path.doTranslation(rs, context);		
+		assertEquals(1, set.size());
+		assertTrue(set.iterator().next() instanceof GreenReference);
+	}
+
+	
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/resources/log4j.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/resources/log4j.xml b/taverna-reference-impl/src/test/resources/log4j.xml
index f1f4d5e..5573f50 100644
--- a/taverna-reference-impl/src/test/resources/log4j.xml
+++ b/taverna-reference-impl/src/test/resources/log4j.xml
@@ -11,11 +11,11 @@
 		</layout>
 	</appender>
 
-	<logger name="net.sf.taverna.platform.spring.orm">
+	<logger name="org.apache.taverna.platform.spring.orm">
 		<level value="TRACE" />
 	</logger>
 
-	<logger name="net.sf.taverna.platform.spring">
+	<logger name="org.apache.taverna.platform.spring">
 		<level value="INFO" />
 	</logger>
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/resources/vanillaHibernateAppContext.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/resources/vanillaHibernateAppContext.xml b/taverna-reference-impl/src/test/resources/vanillaHibernateAppContext.xml
index 8853410..0bcd04d 100644
--- a/taverna-reference-impl/src/test/resources/vanillaHibernateAppContext.xml
+++ b/taverna-reference-impl/src/test/resources/vanillaHibernateAppContext.xml
@@ -23,7 +23,7 @@
 
 	<!-- Apache Derby rooted at a temporary directory -->
 	<bean id="t2reference.jdbc.temporaryjdbc"
-		class="net.sf.taverna.platform.spring.jdbc.TemporaryJDBC">
+		class="org.apache.taverna.platform.spring.jdbc.TemporaryJDBC">
 	</bean>
 	<bean id="t2reference.jdbc.url" class="java.lang.String"
 		factory-bean="t2reference.jdbc.temporaryjdbc"
@@ -78,16 +78,16 @@
 		<property name="mappingResources">
 			<list>
 				<value>
-					net/sf/taverna/t2/reference/AbstractExternalReference.hbm.xml
+					org/apache/taverna/reference/AbstractExternalReference.hbm.xml
 				</value>
 				<value>
-					net/sf/taverna/t2/reference/impl/ReferenceSetImpl.hbm.xml
+					org/apache/taverna/reference/impl/ReferenceSetImpl.hbm.xml
 				</value>
 				<value>
-					net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.hbm.xml
+					org/apache/taverna/reference/impl/T2ReferenceListImpl.hbm.xml
 				</value>
 				<value>
-					net/sf/taverna/t2/reference/impl/ErrorDocumentImpl.hbm.xml
+					org/apache/taverna/reference/impl/ErrorDocumentImpl.hbm.xml
 				</value>
 			</list>
 		</property>
@@ -95,7 +95,7 @@
 
 	<!-- Test data access object -->
 	<bean id="testDao"
-		class="net.sf.taverna.t2.reference.impl.HibernateReferenceSetDao">
+		class="org.apache.taverna.reference.impl.HibernateReferenceSetDao">
 		<property name="sessionFactory">
 			<ref local="sessionFactoryBean" />
 		</property>
@@ -103,7 +103,7 @@
 
 	<!-- Test list data access object -->
 	<bean id="testListDao"
-		class="net.sf.taverna.t2.reference.impl.HibernateListDao">
+		class="org.apache.taverna.reference.impl.HibernateListDao">
 		<property name="sessionFactory">
 			<ref local="sessionFactoryBean" />
 		</property>
@@ -111,7 +111,7 @@
 	
 	<!-- Test list data access object -->
 	<bean id="testErrorDao"
-		class="net.sf.taverna.t2.reference.impl.HibernateErrorDocumentDao">
+		class="org.apache.taverna.reference.impl.HibernateErrorDocumentDao">
 		<property name="sessionFactory">
 			<ref local="sessionFactoryBean" />
 		</property>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/resources/vanillaHibernateTransactionalAppContext.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/resources/vanillaHibernateTransactionalAppContext.xml b/taverna-reference-impl/src/test/resources/vanillaHibernateTransactionalAppContext.xml
index be66358..373e2e8 100644
--- a/taverna-reference-impl/src/test/resources/vanillaHibernateTransactionalAppContext.xml
+++ b/taverna-reference-impl/src/test/resources/vanillaHibernateTransactionalAppContext.xml
@@ -21,7 +21,7 @@
 
 	<!-- Apache Derby rooted at a temporary directory -->
 	<bean id="t2reference.jdbc.temporaryjdbc"
-		class="net.sf.taverna.platform.spring.jdbc.TemporaryJDBC">
+		class="org.apache.taverna.platform.spring.jdbc.TemporaryJDBC">
 	</bean>
 	<bean id="t2reference.jdbc.url" class="java.lang.String"
 		factory-bean="t2reference.jdbc.temporaryjdbc"
@@ -76,16 +76,16 @@
 		<property name="mappingResources">
 			<list>
 				<value>
-					net/sf/taverna/t2/reference/AbstractExternalReference.hbm.xml
+					org/apache/taverna/reference/AbstractExternalReference.hbm.xml
 				</value>
 				<value>
-					net/sf/taverna/t2/reference/impl/ReferenceSetImpl.hbm.xml
+					org/apache/taverna/reference/impl/ReferenceSetImpl.hbm.xml
 				</value>
 				<value>
-					net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.hbm.xml
+					org/apache/taverna/reference/impl/T2ReferenceListImpl.hbm.xml
 				</value>
 				<value>
-					net/sf/taverna/t2/reference/impl/ErrorDocumentImpl.hbm.xml
+					org/apache/taverna/reference/impl/ErrorDocumentImpl.hbm.xml
 				</value>
 			</list>
 		</property>
@@ -93,7 +93,7 @@
 
 	<!-- Test data access object -->
 	<bean id="testDao"
-		class="net.sf.taverna.t2.reference.impl.TransactionalHibernateReferenceSetDao">
+		class="org.apache.taverna.reference.impl.TransactionalHibernateReferenceSetDao">
 		<property name="sessionFactory">
 			<ref local="sessionFactoryBean" />
 		</property>
@@ -101,7 +101,7 @@
 
 	<!-- Test list data access object -->
 	<bean id="testListDao"
-		class="net.sf.taverna.t2.reference.impl.TransactionalHibernateListDao">
+		class="org.apache.taverna.reference.impl.TransactionalHibernateListDao">
 		<property name="sessionFactory">
 			<ref local="sessionFactoryBean" />
 		</property>
@@ -109,7 +109,7 @@
 	
 	<!-- Test list data access object -->
 	<bean id="testErrorDao"
-		class="net.sf.taverna.t2.reference.impl.TransactionalHibernateErrorDocumentDao">
+		class="org.apache.taverna.reference.impl.TransactionalHibernateErrorDocumentDao">
 		<property name="sessionFactory">
 			<ref local="sessionFactoryBean" />
 		</property>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/resources/vanillaInMemoryAppContext.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/resources/vanillaInMemoryAppContext.xml b/taverna-reference-impl/src/test/resources/vanillaInMemoryAppContext.xml
index 6ea6565..bea0930 100644
--- a/taverna-reference-impl/src/test/resources/vanillaInMemoryAppContext.xml
+++ b/taverna-reference-impl/src/test/resources/vanillaInMemoryAppContext.xml
@@ -13,17 +13,17 @@
 
 	<!-- Test data access object -->
 	<bean id="testDao"
-		class="net.sf.taverna.t2.reference.impl.InMemoryReferenceSetDao">
+		class="org.apache.taverna.reference.impl.InMemoryReferenceSetDao">
 	</bean>
 
 	<!-- Test list data access object -->
 	<bean id="testListDao"
-		class="net.sf.taverna.t2.reference.impl.InMemoryListDao">
+		class="org.apache.taverna.reference.impl.InMemoryListDao">
 	</bean>
 	
 	<!-- Test list data access object -->
 	<bean id="testErrorDao"
-		class="net.sf.taverna.t2.reference.impl.InMemoryErrorDocumentDao">
+		class="org.apache.taverna.reference.impl.InMemoryErrorDocumentDao">
 	</bean>
 
 </beans>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/BlueReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/BlueReference.java b/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/BlueReference.java
deleted file mode 100644
index 5eabe9d..0000000
--- a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/BlueReference.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2referencetest;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-
-import net.sf.taverna.t2.reference.AbstractExternalReference;
-import net.sf.taverna.t2.reference.DereferenceException;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferencedDataNature;
-
-/**
- * BlueReferences carry their data as an internal String and have a resolution
- * cost of 1.0f whatever the value of that string.
- * 
- * @author Tom Oinn
- * 
- */
-public class BlueReference extends AbstractExternalReference implements
-		ExternalReferenceSPI {
-
-	// Hold the 'value' of this reference, probably the simplest backing store
-	// possible for an ExternalReferenceSPI implementation :)
-	private String contents;
-
-	public BlueReference() {
-		//
-	}
-
-	public BlueReference(String contents) {
-		this.contents = contents;
-	}
-
-	/**
-	 * Set the 'value' of this reference as a string. It's not really a
-	 * reference type in any true sense of the word, but it'll do for testing
-	 * the augmentation system. This method is really here so you can configure
-	 * test beans from spring.
-	 */
-	public void setContents(String contents) {
-		this.contents = contents;
-	}
-
-	/**
-	 * Get the 'value' of this reference as a string, really just returns the
-	 * internal string representation.
-	 */
-	public String getContents() {
-		return this.contents;
-	}
-
-	/**
-	 * Fakes a de-reference operation, returning a byte stream over the string
-	 * data.
-	 */
-	@Override
-	public InputStream openStream(ReferenceContext arg0) {
-		try {
-			return new ByteArrayInputStream(this.contents
-					.getBytes(getCharset()));
-		} catch (UnsupportedEncodingException e) {
-			throw new DereferenceException(e);
-		}
-	}
-
-	/**
-	 * Default resolution cost of 1.0f whatever the contents
-	 */
-	@Override
-	public float getResolutionCost() {
-		return 1.0f;
-	}
-
-	/**
-	 * Data nature set to 'ReferencedDataNature.TEXT'
-	 */
-	@Override
-	public ReferencedDataNature getDataNature() {
-		return ReferencedDataNature.TEXT;
-	}
-
-	/**
-	 * Character encoding set to 'UTF-8'
-	 */
-	@Override
-	public String getCharset() {
-		return "UTF-8";
-	}
-
-	/**
-	 * String representation for testing, returns <code>blue{CONTENTS}</code>
-	 */
-	@Override
-	public String toString() {
-		return "blue{" + contents + "}";
-	}
-
-	@Override
-	public Long getApproximateSizeInBytes() {
-		return new Long(contents.getBytes().length);
-	}
-
-	@Override
-	public ExternalReferenceSPI clone() throws CloneNotSupportedException {
-		return new BlueReference(this.getContents());
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/DummyReferenceSet.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/DummyReferenceSet.java b/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/DummyReferenceSet.java
deleted file mode 100644
index 1d51fe9..0000000
--- a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/DummyReferenceSet.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package net.sf.taverna.t2referencetest;
-
-import java.util.Collections;
-import java.util.Set;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceSet;
-import net.sf.taverna.t2.reference.T2Reference;
-
-public class DummyReferenceSet implements ReferenceSet {
-	
-	private Set<ExternalReferenceSPI> refs;
-
-	public DummyReferenceSet(ExternalReferenceSPI ref) {
-		refs = Collections.singleton(ref);
-	}
-	
-	@Override
-	public T2Reference getId() {
-		return null;
-	}
-
-	@Override
-	public Set<ExternalReferenceSPI> getExternalReferences() {
-		return refs;
-	}
-
-	@Override
-	public Long getApproximateSizeInBytes() {
-		return null;
-	}
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenBuilder.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenBuilder.java b/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenBuilder.java
deleted file mode 100644
index 6a11546..0000000
--- a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenBuilder.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2referencetest;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-import net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI;
-import net.sf.taverna.t2.reference.ExternalReferenceConstructionException;
-import net.sf.taverna.t2.reference.ReferenceContext;
-
-import org.apache.log4j.Logger;
-
-/**
- * Trivially build a GreenReference from an InputStream, implementing the
- * ExternalReferenceBuilderSPI interface. Used in the augmentation test cases.
- * 
- * @author Tom Oinn
- * 
- */
-public class GreenBuilder implements
-		ExternalReferenceBuilderSPI<GreenReference> {
-
-	private static Logger logger = Logger
-	.getLogger(GreenBuilder.class);
-
-	/**
-	 * Construct a new GreenReference from the given input stream, ignoring the
-	 * otherwise helpful context as we don't need any resources from it. We
-	 * assume UTF-8 encoding as that's what all the test reference types use,
-	 * again, with a real example this might have to be a bit smarter!
-	 * 
-	 * @throws ExternalReferenceConstructionException
-	 *             if there are any issues building the new GreenReference
-	 *             (which there won't be)
-	 */
-	@Override
-	public GreenReference createReference(InputStream is,
-			ReferenceContext context)
-			throws ExternalReferenceConstructionException {
-		GreenReference newReference = new GreenReference();
-		// Read input stream into the 'contents' property of the reference
-		BufferedReader in = new BufferedReader(new InputStreamReader(is));
-		try {
-			newReference.setContents(in.readLine());
-		} catch (IOException e) {
-			throw new ExternalReferenceConstructionException(e);
-		} finally {
-			try {
-				is.close();
-				in.close();
-			} catch (IOException e) {
-				logger.error("Unable to close streams", e);
-			}
-		}
-		return newReference;
-	}
-
-	/**
-	 * Construction cost fixed at 1.5f
-	 * 
-	 * @return <code>1.5f</code>
-	 */
-	@Override
-	public float getConstructionCost() {
-		return 1.5f;
-	}
-
-	/**
-	 * @return <code>{@link net.sf.taverna.t2referencetest.GreenReference GreenReference}.class</code>
-	 */
-	@Override
-	public Class<GreenReference> getReferenceType() {
-		return GreenReference.class;
-	}
-
-	/**
-	 * Doesn't use any context resources so is always enabled
-	 * 
-	 * @return <code>true</code>
-	 */
-	@Override
-	public boolean isEnabled(ReferenceContext arg0) {
-		return true;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenReference.java b/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenReference.java
deleted file mode 100644
index e01f604..0000000
--- a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenReference.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2referencetest;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-
-import net.sf.taverna.t2.reference.AbstractExternalReference;
-import net.sf.taverna.t2.reference.DereferenceException;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferencedDataNature;
-
-/**
- * GreenReferences carry their data as an internal String and have a resolution
- * cost of 1.1f whatever the value of that string.
- * 
- * @author Tom Oinn
- * 
- */
-public class GreenReference extends AbstractExternalReference implements
-		ExternalReferenceSPI {
-
-	// Hold the 'value' of this reference, probably the simplest backing store
-	// possible for an ExternalReferenceSPI implementation :)
-	private String contents;
-
-	public GreenReference() {
-		//
-	}
-	
-	public GreenReference(String contents) {
-		this.contents = contents;
-	}
-	
-	/**
-	 * Set the 'value' of this reference as a string. It's not really a
-	 * reference type in any true sense of the word, but it'll do for testing
-	 * the augmentation system. This method is really here so you can configure
-	 * test beans from spring. 
-	 */
-	public void setContents(String contents) {
-		this.contents = contents;
-	}
-
-	/**
-	 * Get the 'value' of this reference as a string, really just returns the
-	 * internal string representation.
-	 */
-	public String getContents() {
-		return this.contents;
-	}
-
-	/**
-	 * Fakes a de-reference operation, returning a byte stream over the string
-	 * data.
-	 */
-	@Override
-	public InputStream openStream(ReferenceContext arg0) {
-		try {
-			return new ByteArrayInputStream(this.contents
-					.getBytes(getCharset()));
-		} catch (UnsupportedEncodingException e) {
-			throw new DereferenceException(e);
-		}
-	}
-
-	/**
-	 * Default resolution cost of 1.0f whatever the contents
-	 */
-	@Override
-	public float getResolutionCost() {
-		return 1.1f;
-	}
-
-	/**
-	 * Data nature set to 'ReferencedDataNature.TEXT'
-	 */
-	@Override
-	public ReferencedDataNature getDataNature() {
-		return ReferencedDataNature.TEXT;
-	}
-
-	/**
-	 * Character encoding set to 'UTF-8'
-	 */
-	@Override
-	public String getCharset() {
-		return "UTF-8";
-	}
-
-	/**
-	 * String representation for testing, returns <code>green{CONTENTS}</code>
-	 */
-	@Override
-	public String toString() {
-		return "green{" + contents + "}";
-	}
-
-	@Override
-	public Long getApproximateSizeInBytes() {
-		return new Long(contents.getBytes().length);
-	}
-
-	@Override
-	public ExternalReferenceSPI clone() throws CloneNotSupportedException {
-		return new GreenReference(this.getContents());
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenToRed.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenToRed.java b/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenToRed.java
deleted file mode 100644
index 8c673d6..0000000
--- a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenToRed.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2referencetest;
-
-import net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-
-public class GreenToRed implements
-		ExternalReferenceTranslatorSPI<GreenReference, RedReference> {
-
-	@Override
-	public RedReference createReference(GreenReference ref,
-			ReferenceContext context) {
-		RedReference newReference = new RedReference();
-		newReference.setContents(ref.getContents());
-		// Insert a two second pause to simulate reference translation and to
-		// test the behaviour of multiple concurrent translations
-		try {
-			Thread.sleep(2000);
-		} catch (InterruptedException ie) {
-			System.out
-					.println("Translation thread was interrupted, probably something wrong.");
-		}
-		return newReference;
-	}
-
-	@Override
-	public Class<GreenReference> getSourceReferenceType() {
-		return GreenReference.class;
-	}
-
-	@Override
-	public Class<RedReference> getTargetReferenceType() {
-		return RedReference.class;
-	}
-
-	@Override
-	public float getTranslationCost() {
-		return 0.4f;
-	}
-
-	@Override
-	public boolean isEnabled(ReferenceContext arg0) {
-		return true;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/RedReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/RedReference.java b/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/RedReference.java
deleted file mode 100644
index 0c21c72..0000000
--- a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/RedReference.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2referencetest;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-
-import net.sf.taverna.t2.reference.AbstractExternalReference;
-import net.sf.taverna.t2.reference.DereferenceException;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferencedDataNature;
-
-/**
- * RedReferences carry their data as an internal String and have a resolution
- * cost of 0.9f whatever the value of that string.
- * 
- * @author Tom Oinn
- * 
- */
-public class RedReference extends AbstractExternalReference implements
-		ExternalReferenceSPI {
-
-	// Hold the 'value' of this reference, probably the simplest backing store
-	// possible for an ExternalReferenceSPI implementation :)
-	private String contents;
-
-	public RedReference() {
-		//
-	}
-
-	public RedReference(String contents) {
-		this.contents = contents;
-	}
-
-	/**
-	 * Set the 'value' of this reference as a string. It's not really a
-	 * reference type in any true sense of the word, but it'll do for testing
-	 * the augmentation system. This method is really here so you can configure
-	 * test beans from spring.
-	 */
-	public void setContents(String contents) {
-		this.contents = contents;
-	}
-
-	/**
-	 * Get the 'value' of this reference as a string, really just returns the
-	 * internal string representation.
-	 */
-	public String getContents() {
-		return this.contents;
-	}
-
-	/**
-	 * Fakes a de-reference operation, returning a byte stream over the string
-	 * data.
-	 */
-	@Override
-	public InputStream openStream(ReferenceContext arg0) {
-		try {
-			return new ByteArrayInputStream(this.contents
-					.getBytes(getCharset()));
-		} catch (UnsupportedEncodingException e) {
-			throw new DereferenceException(e);
-		}
-	}
-
-	/**
-	 * Default resolution cost of 1.0f whatever the contents
-	 */
-	@Override
-	public float getResolutionCost() {
-		return 0.9f;
-	}
-
-	/**
-	 * Data nature set to 'ReferencedDataNature.TEXT'
-	 */
-	@Override
-	public ReferencedDataNature getDataNature() {
-		return ReferencedDataNature.TEXT;
-	}
-
-	/**
-	 * Character encoding set to 'UTF-8'
-	 */
-	@Override
-	public String getCharset() {
-		return "UTF-8";
-	}
-
-	/**
-	 * String representation for testing, returns <code>red{CONTENTS}</code>
-	 */
-	@Override
-	public String toString() {
-		return "red{" + contents + "}";
-	}
-	
-	@Override
-	public Long getApproximateSizeInBytes() {
-		return new Long(contents.getBytes().length);
-	}
-
-	@Override
-	public ExternalReferenceSPI clone() throws CloneNotSupportedException {
-		return new RedReference(this.getContents());
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/YellowReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/YellowReference.java b/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/YellowReference.java
deleted file mode 100644
index b276f58..0000000
--- a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/YellowReference.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2referencetest;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-
-import net.sf.taverna.t2.reference.AbstractExternalReference;
-import net.sf.taverna.t2.reference.DereferenceException;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferencedDataNature;
-
-
-/**
- * YellowReferences carry their data as an internal String and have a resolution
- * cost of 1.0f whatever the value of that string.
- * 
- * @author Tom Oinn
- * 
- */
-public class YellowReference extends AbstractExternalReference implements
-		ExternalReferenceSPI {
-
-	// Hold the 'value' of this reference, probably the simplest backing store
-	// possible for an ExternalReferenceSPI implementation :)
-	private String contents;
-
-	public YellowReference() {
-		//
-	}
-	
-	public YellowReference(String contents) {
-		this.contents = contents;
-	}
-	
-	/**
-	 * Set the 'value' of this reference as a string. It's not really a
-	 * reference type in any true sense of the word, but it'll do for testing
-	 * the augmentation system. This method is really here so you can configure
-	 * test beans from spring.
-	 */
-	public void setContents(String contents) {
-		this.contents = contents;
-	}
-
-	/**
-	 * Get the 'value' of this reference as a string, really just returns the
-	 * internal string representation.
-	 */
-	public String getContents() {
-		return this.contents;
-	}
-
-	/**
-	 * Fakes a de-reference operation, returning a byte stream over the string
-	 * data.
-	 */
-	@Override
-	public InputStream openStream(ReferenceContext arg0) {
-		try {
-			return new ByteArrayInputStream(this.contents
-					.getBytes(getCharset()));
-		} catch (UnsupportedEncodingException e) {
-			throw new DereferenceException(e);
-		}
-	}
-
-	/**
-	 * Default resolution cost of 1.0f whatever the contents
-	 */
-	@Override
-	public float getResolutionCost() {
-		return 1.0f;
-	}
-
-	/**
-	 * Data nature set to 'ReferencedDataNature.TEXT'
-	 */
-	@Override
-	public ReferencedDataNature getDataNature() {
-		return ReferencedDataNature.TEXT;
-	}
-
-	/**
-	 * Character encoding set to 'UTF-8'
-	 */
-	@Override
-	public String getCharset() {
-		return "UTF-8";
-	}
-
-	/**
-	 * String representation for testing, returns <code>yellow{CONTENTS}</code>
-	 */
-	@Override
-	public String toString() {
-		return "yellow{" + contents + "}";
-	}
-
-	@Override
-	public Long getApproximateSizeInBytes() {
-		return new Long(contents.getBytes().length);
-	}
-
-	@Override
-	public ExternalReferenceSPI clone() throws CloneNotSupportedException {
-		return new YellowReference(this.getContents());
-	}
-
-}


[49/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-database-configuration-impl/src/main/java/org/apache/taverna/configuration/database/impl/DatabaseManagerImpl.java
----------------------------------------------------------------------
diff --git a/taverna-database-configuration-impl/src/main/java/org/apache/taverna/configuration/database/impl/DatabaseManagerImpl.java b/taverna-database-configuration-impl/src/main/java/org/apache/taverna/configuration/database/impl/DatabaseManagerImpl.java
new file mode 100644
index 0000000..67e34be
--- /dev/null
+++ b/taverna-database-configuration-impl/src/main/java/org/apache/taverna/configuration/database/impl/DatabaseManagerImpl.java
@@ -0,0 +1,174 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.configuration.database.impl;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import javax.sql.DataSource;
+
+import org.apache.commons.dbcp.BasicDataSource;
+import org.apache.derby.drda.NetworkServerControl;
+import org.apache.log4j.Logger;
+
+import org.apache.taverna.configuration.database.DatabaseConfiguration;
+import org.apache.taverna.configuration.database.DatabaseManager;
+import uk.org.taverna.configuration.app.ApplicationConfiguration;
+
+/**
+ * A set of utility methods related to basic data management.
+ *
+ * @author Stuart Owen
+ * @author Stian Soiland-Reyes
+ *
+ */
+public class DatabaseManagerImpl implements DatabaseManager {
+
+	private final static Logger logger = Logger.getLogger(DatabaseManagerImpl.class);
+
+	private  NetworkServerControl server;
+
+	private BasicDataSource dataSource;
+
+	private DatabaseConfiguration databaseConfiguration;
+
+	private ApplicationConfiguration applicationConfiguration;
+
+	public DatabaseManagerImpl(ApplicationConfiguration applicationConfiguration, DatabaseConfiguration databaseConfiguration) throws SQLException {
+		this.applicationConfiguration = applicationConfiguration;
+		this.databaseConfiguration = databaseConfiguration;
+		getConnection();
+	}
+
+	@Override
+	public Connection getConnection() throws SQLException {
+		return getDataSource().getConnection();
+	}
+
+	@Override
+	public DataSource getDataSource() {
+		if (dataSource == null) {
+			setupDataSource();
+		}
+		return dataSource;
+	}
+
+	@Override
+	public synchronized void startDerbyNetworkServer() {
+		setDerbyPaths();
+
+        System.setProperty("derby.drda.host","localhost");
+        System.setProperty("derby.drda.minThreads","5");
+        System.setProperty("derby.drda.maxThreads",String.valueOf(databaseConfiguration.getPoolMaxActive()));
+        int port = databaseConfiguration.getPort();
+        int maxPort = port+50;
+
+        try {
+        	System.setProperty("derby.drda.portNumber",String.valueOf(port));
+            if (server==null) server = new NetworkServerControl();
+            while(port<maxPort) { //loop to find another available port on which Derby isn't already running
+            	if (!isRunning()) break;
+            	logger.info("Derby connection port: "+port+" is currently not available for Taverna, trying next value");
+            	port++;
+            	System.setProperty("derby.drda.portNumber",String.valueOf(port));
+            	server = new NetworkServerControl();
+            }
+            server.start(null);
+            databaseConfiguration.setCurrentPort(port);
+        } catch (Exception ex) {
+            logger.error("Error starting up Derby network server",ex);
+        }
+    }
+
+	@Override
+	public void stopDerbyNetworkServer() {
+		try {
+			server.shutdown();
+		} catch (Exception e) {
+			logger.error("Error shutting down Derby network server",e);
+		}
+	}
+
+	@Override
+	public boolean isRunning() {
+		if (server==null) {
+			return false;
+		}
+		else {
+			try {
+				server.ping();
+				return true;
+			} catch (Exception e) {
+				return false;
+			}
+		}
+	}
+
+	private void setupDataSource() {
+		setDerbyPaths();
+
+		dataSource = new BasicDataSource();
+		dataSource.setDriverClassName(databaseConfiguration.getDriverClassName());
+
+		System.setProperty("hibernate.dialect", databaseConfiguration.getHibernateDialect());
+
+		dataSource.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
+		dataSource.setMaxActive(databaseConfiguration.getPoolMaxActive());
+		dataSource.setMinIdle(databaseConfiguration.getPoolMinIdle());
+		dataSource.setMaxIdle(databaseConfiguration.getPoolMaxIdle());
+		dataSource.setDefaultAutoCommit(true);
+		dataSource.setInitialSize(databaseConfiguration.getPoolMinIdle());
+		//Derby blows up if the username of password is empty (even an empty string thats not null).
+		if (databaseConfiguration.getUsername()!=null && databaseConfiguration.getUsername().length()>=1) dataSource.setUsername(databaseConfiguration.getUsername());
+		if (databaseConfiguration.getPassword()!=null && databaseConfiguration.getPassword().length()>=1) dataSource.setPassword(databaseConfiguration.getPassword());
+
+		dataSource.setUrl(databaseConfiguration.getJDBCUri());
+    }
+
+	private void setDerbyPaths() {
+		if (databaseConfiguration.getConnectorType() == DatabaseConfiguration.CONNECTOR_DERBY) {
+			String homeDir = applicationConfiguration.getApplicationHomeDir().getAbsolutePath();
+			System.setProperty("derby.system.home",homeDir);
+			File logFile = new File(applicationConfiguration.getLogDir(), "derby.log");
+			System.setProperty("derby.stream.error.file", logFile.getAbsolutePath());
+		}
+
+	}
+
+	/**
+	 * Sets the databaseConfiguration.
+	 *
+	 * @param databaseConfiguration the new value of databaseConfiguration
+	 */
+	public void setDatabaseConfiguration(DatabaseConfiguration databaseConfiguration) {
+		this.databaseConfiguration = databaseConfiguration;
+	}
+
+	/**
+	 * Sets the applicationConfiguration.
+	 *
+	 * @param applicationConfiguration the new value of applicationConfiguration
+	 */
+	public void setApplicationConfiguration(ApplicationConfiguration applicationConfiguration) {
+		this.applicationConfiguration = applicationConfiguration;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-database-configuration-impl/src/main/java/uk/org/taverna/configuration/database/impl/DatabaseConfigurationImpl.java
----------------------------------------------------------------------
diff --git a/taverna-database-configuration-impl/src/main/java/uk/org/taverna/configuration/database/impl/DatabaseConfigurationImpl.java b/taverna-database-configuration-impl/src/main/java/uk/org/taverna/configuration/database/impl/DatabaseConfigurationImpl.java
deleted file mode 100644
index de73269..0000000
--- a/taverna-database-configuration-impl/src/main/java/uk/org/taverna/configuration/database/impl/DatabaseConfigurationImpl.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.configuration.database.impl;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import uk.org.taverna.configuration.database.DatabaseConfiguration;
-import uk.org.taverna.configuration.AbstractConfigurable;
-import uk.org.taverna.configuration.ConfigurationManager;
-
-/**
- * Configuration for the reference service and provenance.
- *
- * @author David Withers
- * @author Stuart Owen
- */
-
-public class DatabaseConfigurationImpl extends AbstractConfigurable implements DatabaseConfiguration {
-
-	private Map<String, String> defaultPropertyMap;
-
-	private boolean autoSave = true;
-
-	public DatabaseConfigurationImpl(ConfigurationManager configurationManager) {
-		super(configurationManager);
-	}
-
-	@Override
-	public boolean isAutoSave() {
-		return autoSave;
-	}
-
-	@Override
-	public void enableAutoSave() {
-		autoSave = true;
-	}
-
-	@Override
-	public void disableAutoSave() {
-		autoSave = false;
-	}
-
-	@Override
-	protected void store() {
-		if (autoSave) {
-			super.store();
-		}
-	}
-
-	@Override
-	public boolean isInMemory() {
-		return getProperty(IN_MEMORY).equalsIgnoreCase("true");
-	}
-
-	@Override
-	public void setInMemory(boolean value) {
-		setProperty(IN_MEMORY, String.valueOf(value));
-	}
-
-	@Override
-	public boolean isExposeDatanature() {
-		return getProperty(EXPOSE_DATANATURE).equalsIgnoreCase("true");
-	}
-
-	@Override
-	public void setExposeDatanature(boolean exposeDatanature) {
-		setProperty(EXPOSE_DATANATURE, String.valueOf(exposeDatanature));
-	}
-
-	@Override
-	public String getDatabaseContext() {
-		if (getProperty(IN_MEMORY).equalsIgnoreCase("true")) {
-			return IN_MEMORY_CONTEXT;
-		} else {
-			return HIBERNATE_CONTEXT;
-		}
-	}
-
-	@Override
-	public void setPort(int port) {
-		setPort(String.valueOf(port));
-	}
-
-	@Override
-	public void setPort(String port) {
-		setProperty(PORT, port);
-	}
-
-	@Override
-	public void setDriverClassName(String driverClassName) {
-		setProperty(DRIVER_CLASS_NAME, driverClassName);
-	}
-
-	@Override
-	public String getDriverClassName() {
-		return getProperty(DRIVER_CLASS_NAME);
-	}
-
-	@Override
-	public boolean isProvenanceEnabled() {
-		return getProperty(ENABLE_PROVENANCE).equalsIgnoreCase("true");
-	}
-
-	@Override
-	public void setProvenanceEnabled(boolean value) {
-		setProperty(ENABLE_PROVENANCE, String.valueOf(value));
-	}
-
-	@Override
-	public void setStartInternalDerbyServer(boolean value) {
-		setProperty(START_INTERNAL_DERBY, String.valueOf(value));
-	}
-
-	@Override
-	public boolean getStartInternalDerbyServer() {
-		return getProperty(START_INTERNAL_DERBY).equalsIgnoreCase("true");
-	}
-
-	@Override
-	public int getPort() {
-		return Integer.valueOf(getProperty(PORT));
-	}
-
-	@Override
-	public void setCurrentPort(int port) {
-		setProperty(CURRENT_PORT, String.valueOf(port));
-	}
-
-	@Override
-	public int getCurrentPort() {
-		return Integer.valueOf(getProperty(CURRENT_PORT));
-	}
-
-	@Override
-	public int getPoolMaxActive() {
-		return Integer.valueOf(getProperty(POOL_MAX_ACTIVE));
-	}
-
-	@Override
-	public int getPoolMinIdle() {
-		return Integer.valueOf(getProperty(POOL_MIN_IDLE));
-	}
-
-	@Override
-	public int getPoolMaxIdle() {
-		return Integer.valueOf(getProperty(POOL_MAX_IDLE));
-	}
-
-	@Override
-	public String getCategory() {
-		return "general";
-	}
-
-	@Override
-	public Map<String, String> getDefaultPropertyMap() {
-
-		if (defaultPropertyMap == null) {
-			defaultPropertyMap = new HashMap<String, String>();
-			defaultPropertyMap.put(IN_MEMORY, "true");
-			defaultPropertyMap.put(ENABLE_PROVENANCE, "true");
-			defaultPropertyMap.put(PORT, "1527");
-			// defaultPropertyMap.put(DRIVER_CLASS_NAME,
-			// "org.apache.derby.jdbc.ClientDriver");
-			defaultPropertyMap.put(DRIVER_CLASS_NAME,
-					"org.apache.derby.jdbc.EmbeddedDriver");
-			defaultPropertyMap.put(HIBERNATE_DIALECT,
-					"org.hibernate.dialect.DerbyDialect");
-			defaultPropertyMap.put(POOL_MAX_ACTIVE, "50");
-			defaultPropertyMap.put(POOL_MAX_IDLE, "50");
-			defaultPropertyMap.put(POOL_MIN_IDLE, "10");
-			defaultPropertyMap.put(USERNAME, "");
-			defaultPropertyMap.put(PASSWORD, "");
-			defaultPropertyMap.put(JDBC_URI,
-					"jdbc:derby:t2-database;create=true;upgrade=true");
-			defaultPropertyMap.put(START_INTERNAL_DERBY, "false");
-
-			defaultPropertyMap.put(CONNECTOR_TYPE, CONNECTOR_DERBY);
-			defaultPropertyMap.put(EXPOSE_DATANATURE, "false");
-		}
-		return defaultPropertyMap;
-	}
-
-	@Override
-	public String getHibernateDialect() {
-		return getProperty(HIBERNATE_DIALECT);
-	}
-
-	@Override
-	public String getDisplayName() {
-		return "Data and provenance";
-	}
-
-	@Override
-	public String getFilePrefix() {
-		return "DataAndProvenance";
-	}
-
-	@Override
-	public String getUUID() {
-		return "6BD3F5C1-C68D-4893-8D9B-2F46FA1DDB19";
-	}
-
-	@Override
-	public String getConnectorType() {
-		return getProperty(CONNECTOR_TYPE);
-	}
-
-	@Override
-	public String getJDBCUri() {
-		if (CONNECTOR_DERBY.equals(getConnectorType())
-				&& getStartInternalDerbyServer()) {
-			return "jdbc:derby://localhost:" + getCurrentPort()
-					+ "/t2-database;create=true;upgrade=true";
-		} else {
-			return getProperty(JDBC_URI);
-		}
-	}
-
-	@Override
-	public void setJDBCUri(String uri) {
-		setProperty(JDBC_URI, uri);
-	}
-
-	@Override
-	public String getUsername() {
-		return getProperty(USERNAME);
-	}
-
-	@Override
-	public String getPassword() {
-		return getProperty(PASSWORD);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-database-configuration-impl/src/main/java/uk/org/taverna/configuration/database/impl/DatabaseManagerImpl.java
----------------------------------------------------------------------
diff --git a/taverna-database-configuration-impl/src/main/java/uk/org/taverna/configuration/database/impl/DatabaseManagerImpl.java b/taverna-database-configuration-impl/src/main/java/uk/org/taverna/configuration/database/impl/DatabaseManagerImpl.java
deleted file mode 100644
index 8a10d24..0000000
--- a/taverna-database-configuration-impl/src/main/java/uk/org/taverna/configuration/database/impl/DatabaseManagerImpl.java
+++ /dev/null
@@ -1,155 +0,0 @@
-package uk.org.taverna.configuration.database.impl;
-
-import java.io.File;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-import javax.sql.DataSource;
-
-import org.apache.commons.dbcp.BasicDataSource;
-import org.apache.derby.drda.NetworkServerControl;
-import org.apache.log4j.Logger;
-
-import uk.org.taverna.configuration.database.DatabaseConfiguration;
-import uk.org.taverna.configuration.database.DatabaseManager;
-import uk.org.taverna.configuration.app.ApplicationConfiguration;
-
-/**
- * A set of utility methods related to basic data management.
- *
- * @author Stuart Owen
- * @author Stian Soiland-Reyes
- *
- */
-public class DatabaseManagerImpl implements DatabaseManager {
-
-	private final static Logger logger = Logger.getLogger(DatabaseManagerImpl.class);
-
-	private  NetworkServerControl server;
-
-	private BasicDataSource dataSource;
-
-	private DatabaseConfiguration databaseConfiguration;
-
-	private ApplicationConfiguration applicationConfiguration;
-
-	public DatabaseManagerImpl(ApplicationConfiguration applicationConfiguration, DatabaseConfiguration databaseConfiguration) throws SQLException {
-		this.applicationConfiguration = applicationConfiguration;
-		this.databaseConfiguration = databaseConfiguration;
-		getConnection();
-	}
-
-	@Override
-	public Connection getConnection() throws SQLException {
-		return getDataSource().getConnection();
-	}
-
-	@Override
-	public DataSource getDataSource() {
-		if (dataSource == null) {
-			setupDataSource();
-		}
-		return dataSource;
-	}
-
-	@Override
-	public synchronized void startDerbyNetworkServer() {
-		setDerbyPaths();
-
-        System.setProperty("derby.drda.host","localhost");
-        System.setProperty("derby.drda.minThreads","5");
-        System.setProperty("derby.drda.maxThreads",String.valueOf(databaseConfiguration.getPoolMaxActive()));
-        int port = databaseConfiguration.getPort();
-        int maxPort = port+50;
-
-        try {
-        	System.setProperty("derby.drda.portNumber",String.valueOf(port));
-            if (server==null) server = new NetworkServerControl();
-            while(port<maxPort) { //loop to find another available port on which Derby isn't already running
-            	if (!isRunning()) break;
-            	logger.info("Derby connection port: "+port+" is currently not available for Taverna, trying next value");
-            	port++;
-            	System.setProperty("derby.drda.portNumber",String.valueOf(port));
-            	server = new NetworkServerControl();
-            }
-            server.start(null);
-            databaseConfiguration.setCurrentPort(port);
-        } catch (Exception ex) {
-            logger.error("Error starting up Derby network server",ex);
-        }
-    }
-
-	@Override
-	public void stopDerbyNetworkServer() {
-		try {
-			server.shutdown();
-		} catch (Exception e) {
-			logger.error("Error shutting down Derby network server",e);
-		}
-	}
-
-	@Override
-	public boolean isRunning() {
-		if (server==null) {
-			return false;
-		}
-		else {
-			try {
-				server.ping();
-				return true;
-			} catch (Exception e) {
-				return false;
-			}
-		}
-	}
-
-	private void setupDataSource() {
-		setDerbyPaths();
-
-		dataSource = new BasicDataSource();
-		dataSource.setDriverClassName(databaseConfiguration.getDriverClassName());
-
-		System.setProperty("hibernate.dialect", databaseConfiguration.getHibernateDialect());
-
-		dataSource.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
-		dataSource.setMaxActive(databaseConfiguration.getPoolMaxActive());
-		dataSource.setMinIdle(databaseConfiguration.getPoolMinIdle());
-		dataSource.setMaxIdle(databaseConfiguration.getPoolMaxIdle());
-		dataSource.setDefaultAutoCommit(true);
-		dataSource.setInitialSize(databaseConfiguration.getPoolMinIdle());
-		//Derby blows up if the username of password is empty (even an empty string thats not null).
-		if (databaseConfiguration.getUsername()!=null && databaseConfiguration.getUsername().length()>=1) dataSource.setUsername(databaseConfiguration.getUsername());
-		if (databaseConfiguration.getPassword()!=null && databaseConfiguration.getPassword().length()>=1) dataSource.setPassword(databaseConfiguration.getPassword());
-
-		dataSource.setUrl(databaseConfiguration.getJDBCUri());
-    }
-
-	private void setDerbyPaths() {
-		if (databaseConfiguration.getConnectorType() == DatabaseConfiguration.CONNECTOR_DERBY) {
-			String homeDir = applicationConfiguration.getApplicationHomeDir().getAbsolutePath();
-			System.setProperty("derby.system.home",homeDir);
-			File logFile = new File(applicationConfiguration.getLogDir(), "derby.log");
-			System.setProperty("derby.stream.error.file", logFile.getAbsolutePath());
-		}
-
-	}
-
-	/**
-	 * Sets the databaseConfiguration.
-	 *
-	 * @param databaseConfiguration the new value of databaseConfiguration
-	 */
-	public void setDatabaseConfiguration(DatabaseConfiguration databaseConfiguration) {
-		this.databaseConfiguration = databaseConfiguration;
-	}
-
-	/**
-	 * Sets the applicationConfiguration.
-	 *
-	 * @param applicationConfiguration the new value of applicationConfiguration
-	 */
-	public void setApplicationConfiguration(ApplicationConfiguration applicationConfiguration) {
-		this.applicationConfiguration = applicationConfiguration;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-database-configuration-impl/src/main/resources/META-INF/spring/database-context-osgi.xml
----------------------------------------------------------------------
diff --git a/taverna-database-configuration-impl/src/main/resources/META-INF/spring/database-context-osgi.xml b/taverna-database-configuration-impl/src/main/resources/META-INF/spring/database-context-osgi.xml
index 2eae538..9bc5909 100644
--- a/taverna-database-configuration-impl/src/main/resources/META-INF/spring/database-context-osgi.xml
+++ b/taverna-database-configuration-impl/src/main/resources/META-INF/spring/database-context-osgi.xml
@@ -6,8 +6,8 @@
                                  http://www.springframework.org/schema/osgi
                                  http://www.springframework.org/schema/osgi/spring-osgi.xsd">
 
-	<service ref="databaseConfiguration" interface="uk.org.taverna.configuration.database.DatabaseConfiguration" />
-	<service ref="databaseManager" interface="uk.org.taverna.configuration.database.DatabaseManager" />
+	<service ref="databaseConfiguration" interface="org.apache.taverna.configuration.database.DatabaseConfiguration" />
+	<service ref="databaseManager" interface="org.apache.taverna.configuration.database.DatabaseManager" />
 
 	<reference id="configurationManager" interface="uk.org.taverna.configuration.ConfigurationManager" />
 	<reference id="applicationConfiguration" interface="uk.org.taverna.configuration.app.ApplicationConfiguration" />

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-dataflow-activity/src/main/java/net/sf/taverna/t2/activities/dataflow/DataflowActivity.java
----------------------------------------------------------------------
diff --git a/taverna-dataflow-activity/src/main/java/net/sf/taverna/t2/activities/dataflow/DataflowActivity.java b/taverna-dataflow-activity/src/main/java/net/sf/taverna/t2/activities/dataflow/DataflowActivity.java
deleted file mode 100644
index 7ec8e22..0000000
--- a/taverna-dataflow-activity/src/main/java/net/sf/taverna/t2/activities/dataflow/DataflowActivity.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.dataflow;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import net.sf.taverna.t2.facade.FacadeListener;
-import net.sf.taverna.t2.facade.ResultListener;
-import net.sf.taverna.t2.facade.WorkflowInstanceFacade;
-import net.sf.taverna.t2.facade.WorkflowInstanceFacade.State;
-import net.sf.taverna.t2.invocation.TokenOrderException;
-import net.sf.taverna.t2.invocation.WorkflowDataToken;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import net.sf.taverna.t2.workflowmodel.InvalidDataflowException;
-import net.sf.taverna.t2.workflowmodel.processor.activity.AbstractAsynchronousActivity;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityConfigurationException;
-import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback;
-import net.sf.taverna.t2.workflowmodel.processor.activity.NestedDataflow;
-
-import org.apache.log4j.Logger;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * An Activity providing nested Dataflow functionality.
- *
- * @author David Withers
- */
-public class DataflowActivity extends AbstractAsynchronousActivity<JsonNode> implements NestedDataflow {
-
-	public static final String URI = "http://ns.taverna.org.uk/2010/activity/nested-workflow";
-
-	@SuppressWarnings("unused")
-	private static final Logger logger = Logger.getLogger(DataflowActivity.class);
-
-	private Dataflow dataflow;
-
-	private JsonNode json;
-
-	@Override
-	public void configure(JsonNode json) throws ActivityConfigurationException {
-		this.json = json;
-//		dataflow.checkValidity();
-//		buildInputPorts();
-//		buildOutputPorts();
-	}
-
-	@Override
-	public JsonNode getConfiguration() {
-		return json;
-	}
-
-	@Override
-	public void executeAsynch(final Map<String, T2Reference> data,
-			final AsynchronousActivityCallback callback) {
-		callback.requestRun(new Runnable() {
-			
-			Map<String, T2Reference> outputData = new HashMap<String, T2Reference>();
-
-			public void run() {
-
-				final WorkflowInstanceFacade facade;
-				try {
-					facade = getEdits().createWorkflowInstanceFacade(dataflow, callback.getContext(),
-							callback.getParentProcessIdentifier());
-				} catch (InvalidDataflowException ex) {
-					callback.fail("Invalid workflow", ex);
-					return;
-				}
-
-				final ResultListener rl = new ResultListener() {
-
-
-					public void resultTokenProduced(WorkflowDataToken dataToken, String port) {
-						if (dataToken.getIndex().length == 0) {
-							outputData.put(port, dataToken.getData());
-						}
-					}
-				};
-				
-				final FacadeListener fl = new FacadeListener() {
-
-					@Override
-					public void workflowFailed(WorkflowInstanceFacade facade,
-							String message, Throwable t) {
-						callback.fail(message, t);
-					}
-
-					@Override
-					public void stateChange(WorkflowInstanceFacade facade,
-							State oldState, State newState) {
-						if (newState == State.completed) {
-							facade.removeResultListener(rl);
-							facade.removeFacadeListener(this);
-							callback.receiveResult(outputData, new int[]{});
-						}
-					}
-					
-				};
-				
-				facade.addResultListener(rl);
-				facade.addFacadeListener(fl);
-
-				facade.fire();
-
-				for (Map.Entry<String, T2Reference> entry : data.entrySet()) {
-					try {
-						WorkflowDataToken token = new WorkflowDataToken(callback
-								.getParentProcessIdentifier(), new int[] {}, entry.getValue(),
-								callback.getContext());
-						facade.pushData(token, entry.getKey());
-					} catch (TokenOrderException e) {
-						callback.fail("Failed to push data into facade", e);
-					}
-				}
-
-			}
-
-		});
-	}
-
-//	private void buildInputPorts() throws ActivityConfigurationException {
-//		inputPorts.clear();
-//		for (DataflowInputPort dataflowInputPort : dataflow.getInputPorts()) {
-//			addInput(dataflowInputPort.getName(), dataflowInputPort.getDepth(), true,
-//					new ArrayList<Class<? extends ExternalReferenceSPI>>(), null);
-//		}
-//	}
-
-//	private void buildOutputPorts() throws ActivityConfigurationException {
-//		outputPorts.clear();
-//		// granular depth same as depth - no streaming of results
-//		for (DataflowOutputPort dataflowOutputPort : dataflow.getOutputPorts()) {
-//			addOutput(dataflowOutputPort.getName(), dataflowOutputPort.getDepth(),
-//					dataflowOutputPort.getDepth());
-//		}
-//	}
-
-	public Dataflow getNestedDataflow() {
-		return dataflow;
-	}
-
-	@Override
-	public void setNestedDataflow(Dataflow dataflow) {
-		this.dataflow = dataflow;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-dataflow-activity/src/main/java/net/sf/taverna/t2/activities/dataflow/DataflowActivityFactory.java
----------------------------------------------------------------------
diff --git a/taverna-dataflow-activity/src/main/java/net/sf/taverna/t2/activities/dataflow/DataflowActivityFactory.java b/taverna-dataflow-activity/src/main/java/net/sf/taverna/t2/activities/dataflow/DataflowActivityFactory.java
deleted file mode 100644
index 1529e00..0000000
--- a/taverna-dataflow-activity/src/main/java/net/sf/taverna/t2/activities/dataflow/DataflowActivityFactory.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.dataflow;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.HashSet;
-import java.util.Set;
-
-import net.sf.taverna.t2.workflowmodel.Edits;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityFactory;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityInputPort;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityOutputPort;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * An {@link ActivityFactory} for creating <code>DataflowActivity</code>.
- *
- * @author David Withers
- */
-public class DataflowActivityFactory implements ActivityFactory {
-
-	private Edits edits;
-
-	@Override
-	public DataflowActivity createActivity() {
-		DataflowActivity activity = new DataflowActivity();
-		activity.setEdits(edits);
-		return activity;
-	}
-
-	@Override
-	public URI getActivityType() {
-		return URI.create(DataflowActivity.URI);
-	}
-
-	@Override
-	public JsonNode getActivityConfigurationSchema() {
-		ObjectMapper objectMapper = new ObjectMapper();
-		try {
-			return objectMapper.readTree(getClass().getResource("/schema.json"));
-		} catch (IOException e) {
-			return objectMapper.createObjectNode();
-		}
-	}
-
-	@Override
-	public Set<ActivityInputPort> getInputPorts(JsonNode configuration) {
-		return new HashSet<>();
-	}
-
-	@Override
-	public Set<ActivityOutputPort> getOutputPorts(JsonNode configuration) {
-		return new HashSet<>();
-	}
-
-	public void setEdits(Edits edits) {
-		this.edits = edits;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-dataflow-activity/src/main/java/net/sf/taverna/t2/activities/dataflow/DataflowActivityHealthChecker.java
----------------------------------------------------------------------
diff --git a/taverna-dataflow-activity/src/main/java/net/sf/taverna/t2/activities/dataflow/DataflowActivityHealthChecker.java b/taverna-dataflow-activity/src/main/java/net/sf/taverna/t2/activities/dataflow/DataflowActivityHealthChecker.java
deleted file mode 100644
index 86cf595..0000000
--- a/taverna-dataflow-activity/src/main/java/net/sf/taverna/t2/activities/dataflow/DataflowActivityHealthChecker.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.dataflow;
-
-import java.util.List;
-
-import net.sf.taverna.t2.visit.VisitReport;
-import net.sf.taverna.t2.workflowmodel.health.HealthChecker;
-
-public class DataflowActivityHealthChecker implements HealthChecker<DataflowActivity> {
-
-	public boolean canVisit(Object subject) {
-		return false;
-	}
-
-	public VisitReport visit(DataflowActivity activity, List<Object> ancestors) {
-		return null;
-	}
-
-	public boolean isTimeConsuming() {
-		return true;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-dataflow-activity/src/main/java/org/apache/taverna/activities/dataflow/DataflowActivity.java
----------------------------------------------------------------------
diff --git a/taverna-dataflow-activity/src/main/java/org/apache/taverna/activities/dataflow/DataflowActivity.java b/taverna-dataflow-activity/src/main/java/org/apache/taverna/activities/dataflow/DataflowActivity.java
new file mode 100644
index 0000000..fa29e3c
--- /dev/null
+++ b/taverna-dataflow-activity/src/main/java/org/apache/taverna/activities/dataflow/DataflowActivity.java
@@ -0,0 +1,167 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.activities.dataflow;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.taverna.facade.FacadeListener;
+import org.apache.taverna.facade.ResultListener;
+import org.apache.taverna.facade.WorkflowInstanceFacade;
+import org.apache.taverna.facade.WorkflowInstanceFacade.State;
+import org.apache.taverna.invocation.TokenOrderException;
+import org.apache.taverna.invocation.WorkflowDataToken;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.workflowmodel.Dataflow;
+import org.apache.taverna.workflowmodel.InvalidDataflowException;
+import org.apache.taverna.workflowmodel.processor.activity.AbstractAsynchronousActivity;
+import org.apache.taverna.workflowmodel.processor.activity.ActivityConfigurationException;
+import org.apache.taverna.workflowmodel.processor.activity.AsynchronousActivityCallback;
+import org.apache.taverna.workflowmodel.processor.activity.NestedDataflow;
+
+import org.apache.log4j.Logger;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * An Activity providing nested Dataflow functionality.
+ *
+ * @author David Withers
+ */
+public class DataflowActivity extends AbstractAsynchronousActivity<JsonNode> implements NestedDataflow {
+
+	public static final String URI = "http://ns.taverna.org.uk/2010/activity/nested-workflow";
+
+	@SuppressWarnings("unused")
+	private static final Logger logger = Logger.getLogger(DataflowActivity.class);
+
+	private Dataflow dataflow;
+
+	private JsonNode json;
+
+	@Override
+	public void configure(JsonNode json) throws ActivityConfigurationException {
+		this.json = json;
+//		dataflow.checkValidity();
+//		buildInputPorts();
+//		buildOutputPorts();
+	}
+
+	@Override
+	public JsonNode getConfiguration() {
+		return json;
+	}
+
+	@Override
+	public void executeAsynch(final Map<String, T2Reference> data,
+			final AsynchronousActivityCallback callback) {
+		callback.requestRun(new Runnable() {
+			
+			Map<String, T2Reference> outputData = new HashMap<String, T2Reference>();
+
+			public void run() {
+
+				final WorkflowInstanceFacade facade;
+				try {
+					facade = getEdits().createWorkflowInstanceFacade(dataflow, callback.getContext(),
+							callback.getParentProcessIdentifier());
+				} catch (InvalidDataflowException ex) {
+					callback.fail("Invalid workflow", ex);
+					return;
+				}
+
+				final ResultListener rl = new ResultListener() {
+
+
+					public void resultTokenProduced(WorkflowDataToken dataToken, String port) {
+						if (dataToken.getIndex().length == 0) {
+							outputData.put(port, dataToken.getData());
+						}
+					}
+				};
+				
+				final FacadeListener fl = new FacadeListener() {
+
+					@Override
+					public void workflowFailed(WorkflowInstanceFacade facade,
+							String message, Throwable t) {
+						callback.fail(message, t);
+					}
+
+					@Override
+					public void stateChange(WorkflowInstanceFacade facade,
+							State oldState, State newState) {
+						if (newState == State.completed) {
+							facade.removeResultListener(rl);
+							facade.removeFacadeListener(this);
+							callback.receiveResult(outputData, new int[]{});
+						}
+					}
+					
+				};
+				
+				facade.addResultListener(rl);
+				facade.addFacadeListener(fl);
+
+				facade.fire();
+
+				for (Map.Entry<String, T2Reference> entry : data.entrySet()) {
+					try {
+						WorkflowDataToken token = new WorkflowDataToken(callback
+								.getParentProcessIdentifier(), new int[] {}, entry.getValue(),
+								callback.getContext());
+						facade.pushData(token, entry.getKey());
+					} catch (TokenOrderException e) {
+						callback.fail("Failed to push data into facade", e);
+					}
+				}
+
+			}
+
+		});
+	}
+
+//	private void buildInputPorts() throws ActivityConfigurationException {
+//		inputPorts.clear();
+//		for (DataflowInputPort dataflowInputPort : dataflow.getInputPorts()) {
+//			addInput(dataflowInputPort.getName(), dataflowInputPort.getDepth(), true,
+//					new ArrayList<Class<? extends ExternalReferenceSPI>>(), null);
+//		}
+//	}
+
+//	private void buildOutputPorts() throws ActivityConfigurationException {
+//		outputPorts.clear();
+//		// granular depth same as depth - no streaming of results
+//		for (DataflowOutputPort dataflowOutputPort : dataflow.getOutputPorts()) {
+//			addOutput(dataflowOutputPort.getName(), dataflowOutputPort.getDepth(),
+//					dataflowOutputPort.getDepth());
+//		}
+//	}
+
+	public Dataflow getNestedDataflow() {
+		return dataflow;
+	}
+
+	@Override
+	public void setNestedDataflow(Dataflow dataflow) {
+		this.dataflow = dataflow;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-dataflow-activity/src/main/java/org/apache/taverna/activities/dataflow/DataflowActivityFactory.java
----------------------------------------------------------------------
diff --git a/taverna-dataflow-activity/src/main/java/org/apache/taverna/activities/dataflow/DataflowActivityFactory.java b/taverna-dataflow-activity/src/main/java/org/apache/taverna/activities/dataflow/DataflowActivityFactory.java
new file mode 100644
index 0000000..caf314d
--- /dev/null
+++ b/taverna-dataflow-activity/src/main/java/org/apache/taverna/activities/dataflow/DataflowActivityFactory.java
@@ -0,0 +1,80 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.activities.dataflow;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.taverna.workflowmodel.Edits;
+import org.apache.taverna.workflowmodel.processor.activity.ActivityFactory;
+import org.apache.taverna.workflowmodel.processor.activity.ActivityInputPort;
+import org.apache.taverna.workflowmodel.processor.activity.ActivityOutputPort;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+/**
+ * An {@link ActivityFactory} for creating <code>DataflowActivity</code>.
+ *
+ * @author David Withers
+ */
+public class DataflowActivityFactory implements ActivityFactory {
+
+	private Edits edits;
+
+	@Override
+	public DataflowActivity createActivity() {
+		DataflowActivity activity = new DataflowActivity();
+		activity.setEdits(edits);
+		return activity;
+	}
+
+	@Override
+	public URI getActivityType() {
+		return URI.create(DataflowActivity.URI);
+	}
+
+	@Override
+	public JsonNode getActivityConfigurationSchema() {
+		ObjectMapper objectMapper = new ObjectMapper();
+		try {
+			return objectMapper.readTree(getClass().getResource("/schema.json"));
+		} catch (IOException e) {
+			return objectMapper.createObjectNode();
+		}
+	}
+
+	@Override
+	public Set<ActivityInputPort> getInputPorts(JsonNode configuration) {
+		return new HashSet<>();
+	}
+
+	@Override
+	public Set<ActivityOutputPort> getOutputPorts(JsonNode configuration) {
+		return new HashSet<>();
+	}
+
+	public void setEdits(Edits edits) {
+		this.edits = edits;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-dataflow-activity/src/main/java/org/apache/taverna/activities/dataflow/DataflowActivityHealthChecker.java
----------------------------------------------------------------------
diff --git a/taverna-dataflow-activity/src/main/java/org/apache/taverna/activities/dataflow/DataflowActivityHealthChecker.java b/taverna-dataflow-activity/src/main/java/org/apache/taverna/activities/dataflow/DataflowActivityHealthChecker.java
new file mode 100644
index 0000000..7464120
--- /dev/null
+++ b/taverna-dataflow-activity/src/main/java/org/apache/taverna/activities/dataflow/DataflowActivityHealthChecker.java
@@ -0,0 +1,41 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.activities.dataflow;
+
+import java.util.List;
+
+import org.apache.taverna.visit.VisitReport;
+import org.apache.taverna.workflowmodel.health.HealthChecker;
+
+public class DataflowActivityHealthChecker implements HealthChecker<DataflowActivity> {
+
+	public boolean canVisit(Object subject) {
+		return false;
+	}
+
+	public VisitReport visit(DataflowActivity activity, List<Object> ancestors) {
+		return null;
+	}
+
+	public boolean isTimeConsuming() {
+		return true;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-dataflow-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
----------------------------------------------------------------------
diff --git a/taverna-dataflow-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker b/taverna-dataflow-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
index 1254008..058e0d6 100644
--- a/taverna-dataflow-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
+++ b/taverna-dataflow-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
@@ -1 +1 @@
-net.sf.taverna.t2.activities.dataflow.DataflowActivityHealthChecker
\ No newline at end of file
+org.apache.taverna.activities.dataflow.DataflowActivityHealthChecker
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-dataflow-activity/src/main/resources/META-INF/spring/dataflow-activity-context-osgi.xml
----------------------------------------------------------------------
diff --git a/taverna-dataflow-activity/src/main/resources/META-INF/spring/dataflow-activity-context-osgi.xml b/taverna-dataflow-activity/src/main/resources/META-INF/spring/dataflow-activity-context-osgi.xml
index 480b7e7..471a41e 100644
--- a/taverna-dataflow-activity/src/main/resources/META-INF/spring/dataflow-activity-context-osgi.xml
+++ b/taverna-dataflow-activity/src/main/resources/META-INF/spring/dataflow-activity-context-osgi.xml
@@ -6,10 +6,10 @@
                                  http://www.springframework.org/schema/osgi
                                  http://www.springframework.org/schema/osgi/spring-osgi.xsd">
 
-	<service ref="dataflowActivityHealthChecker" interface="net.sf.taverna.t2.workflowmodel.health.HealthChecker" />
+	<service ref="dataflowActivityHealthChecker" interface="org.apache.taverna.workflowmodel.health.HealthChecker" />
 
-	<service ref="dataflowActivityFactory" interface="net.sf.taverna.t2.workflowmodel.processor.activity.ActivityFactory" />
+	<service ref="dataflowActivityFactory" interface="org.apache.taverna.workflowmodel.processor.activity.ActivityFactory" />
 
-	<reference id="edits" interface="net.sf.taverna.t2.workflowmodel.Edits" />
+	<reference id="edits" interface="org.apache.taverna.workflowmodel.Edits" />
 
 </beans:beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-dataflow-activity/src/main/resources/META-INF/spring/dataflow-activity-context.xml
----------------------------------------------------------------------
diff --git a/taverna-dataflow-activity/src/main/resources/META-INF/spring/dataflow-activity-context.xml b/taverna-dataflow-activity/src/main/resources/META-INF/spring/dataflow-activity-context.xml
index b689bf9..5b283ca 100644
--- a/taverna-dataflow-activity/src/main/resources/META-INF/spring/dataflow-activity-context.xml
+++ b/taverna-dataflow-activity/src/main/resources/META-INF/spring/dataflow-activity-context.xml
@@ -3,9 +3,9 @@
 	xsi:schemaLocation="http://www.springframework.org/schema/beans
                            http://www.springframework.org/schema/beans/spring-beans.xsd">
 
-	<bean id="dataflowActivityHealthChecker" class="net.sf.taverna.t2.activities.dataflow.DataflowActivityHealthChecker" />
+	<bean id="dataflowActivityHealthChecker" class="org.apache.taverna.activities.dataflow.DataflowActivityHealthChecker" />
 
-	<bean id="dataflowActivityFactory" class="net.sf.taverna.t2.activities.dataflow.DataflowActivityFactory" >
+	<bean id="dataflowActivityFactory" class="org.apache.taverna.activities.dataflow.DataflowActivityFactory" >
 		<property name="edits" ref="edits" />
 	</bean>
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-dataflow-activity/src/test/java/net/sf/taverna/t2/activities/dataflow/DataflowActivityFactoryTest.java
----------------------------------------------------------------------
diff --git a/taverna-dataflow-activity/src/test/java/net/sf/taverna/t2/activities/dataflow/DataflowActivityFactoryTest.java b/taverna-dataflow-activity/src/test/java/net/sf/taverna/t2/activities/dataflow/DataflowActivityFactoryTest.java
deleted file mode 100644
index 5942109..0000000
--- a/taverna-dataflow-activity/src/test/java/net/sf/taverna/t2/activities/dataflow/DataflowActivityFactoryTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.dataflow;
-
-import java.net.URI;
-import net.sf.taverna.t2.workflowmodel.impl.EditsImpl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * 
- * @author David Withers
- */
-public class DataflowActivityFactoryTest {
-
-	private DataflowActivityFactory factory;
-	
-	/**
-	 * @throws java.lang.Exception
-	 */
-	@Before
-	public void setUp() throws Exception {
-		factory = new DataflowActivityFactory();
-                factory.setEdits(new EditsImpl());
-	}
-
-	/**
-	 * Test method for {@link net.sf.taverna.t2.activities.beanshell.BeanshellActivityFactory#createActivity()}.
-	 */
-	@Test
-	public void testCreateActivity() {
-		DataflowActivity createActivity = factory.createActivity();
-		assertNotNull(createActivity);
-	}
-
-	/**
-	 * Test method for {@link net.sf.taverna.t2.activities.beanshell.BeanshellActivityFactory#getActivityType()}.
-	 */
-	@Test
-	public void testGetActivityURI() {
-		assertEquals(URI.create(DataflowActivity.URI), factory.getActivityType());
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-dataflow-activity/src/test/java/net/sf/taverna/t2/activities/dataflow/DataflowActivityTest.java
----------------------------------------------------------------------
diff --git a/taverna-dataflow-activity/src/test/java/net/sf/taverna/t2/activities/dataflow/DataflowActivityTest.java b/taverna-dataflow-activity/src/test/java/net/sf/taverna/t2/activities/dataflow/DataflowActivityTest.java
deleted file mode 100644
index 7cd7c97..0000000
--- a/taverna-dataflow-activity/src/test/java/net/sf/taverna/t2/activities/dataflow/DataflowActivityTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.dataflow;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import net.sf.taverna.t2.activities.testutils.ActivityInvoker;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import net.sf.taverna.t2.workflowmodel.Datalink;
-import net.sf.taverna.t2.workflowmodel.Edits;
-import net.sf.taverna.t2.workflowmodel.impl.EditsImpl;
-import net.sf.taverna.t2.workflowmodel.processor.activity.impl.ActivityInputPortImpl;
-import net.sf.taverna.t2.workflowmodel.processor.activity.impl.ActivityOutputPortImpl;
-
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Dataflow Activity Tests
- *
- * @author David Withers
- */
-public class DataflowActivityTest {
-
-	private Dataflow dataflow;
-
-	private DataflowActivity activity;
-
-	@Before
-	public void setUp() throws Exception {
-		activity = new DataflowActivity();
-		Edits edits = new EditsImpl();
-		activity.setEdits(edits);
-		dataflow = edits.createDataflow();
-		edits.getCreateDataflowInputPortEdit(dataflow, "input", 0, 0).doEdit();
-		edits.getCreateDataflowOutputPortEdit(dataflow, "output").doEdit();
-		Datalink datalink = edits.createDatalink(dataflow.getInputPorts().get(0)
-				.getInternalOutputPort(), dataflow.getOutputPorts().get(0).getInternalInputPort());
-		edits.getConnectDatalinkEdit(datalink).doEdit();
-	}
-
-	@Test
-	public void testConfigureDataflowActivityConfigurationBean() throws Exception {
-		activity.setNestedDataflow(dataflow);
-		assertEquals(dataflow, activity.getNestedDataflow());
-
-		Edits edits = new EditsImpl();
-		dataflow = edits.createDataflow();
-		edits.getAddActivityInputPortEdit(activity, new ActivityInputPortImpl("input", 0)).doEdit();
-		edits.getAddActivityOutputPortEdit(activity, new ActivityOutputPortImpl("output", 0, 0))
-				.doEdit();
-
-		assertEquals(1, activity.getInputPorts().size());
-		assertEquals("input", activity.getInputPorts().iterator().next().getName());
-		assertEquals(1, activity.getOutputPorts().size());
-		assertEquals("output", activity.getOutputPorts().iterator().next().getName());
-
-		Map<String, Object> inputs = new HashMap<String, Object>();
-		inputs.put("input", "aString");
-		Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>();
-		expectedOutputs.put("output", String.class);
-
-		Map<String, Object> outputs = ActivityInvoker.invokeAsyncActivity(activity, inputs,
-				expectedOutputs);
-		assertTrue("there should be an output named output", outputs.containsKey("output"));
-		assertEquals("output should have the value aString", "aString", outputs.get("output"));
-	}
-
-	@Test
-	public void testGetConfiguration() {
-		assertNull("freshly created activity should not contain configuration",
-				activity.getConfiguration());
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-dataflow-activity/src/test/java/org/apache/taverna/activities/dataflow/DataflowActivityFactoryTest.java
----------------------------------------------------------------------
diff --git a/taverna-dataflow-activity/src/test/java/org/apache/taverna/activities/dataflow/DataflowActivityFactoryTest.java b/taverna-dataflow-activity/src/test/java/org/apache/taverna/activities/dataflow/DataflowActivityFactoryTest.java
new file mode 100644
index 0000000..9e2e0a4
--- /dev/null
+++ b/taverna-dataflow-activity/src/test/java/org/apache/taverna/activities/dataflow/DataflowActivityFactoryTest.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (C) 2010 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program 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 program 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 program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package org.apache.taverna.activities.dataflow;
+
+import java.net.URI;
+import org.apache.taverna.workflowmodel.impl.EditsImpl;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * 
+ * @author David Withers
+ */
+public class DataflowActivityFactoryTest {
+
+	private DataflowActivityFactory factory;
+	
+	/**
+	 * @throws java.lang.Exception
+	 */
+	@Before
+	public void setUp() throws Exception {
+		factory = new DataflowActivityFactory();
+                factory.setEdits(new EditsImpl());
+	}
+
+	/**
+	 * Test method for {@link org.apache.taverna.activities.beanshell.BeanshellActivityFactory#createActivity()}.
+	 */
+	@Test
+	public void testCreateActivity() {
+		DataflowActivity createActivity = factory.createActivity();
+		assertNotNull(createActivity);
+	}
+
+	/**
+	 * Test method for {@link org.apache.taverna.activities.beanshell.BeanshellActivityFactory#getActivityType()}.
+	 */
+	@Test
+	public void testGetActivityURI() {
+		assertEquals(URI.create(DataflowActivity.URI), factory.getActivityType());
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-dataflow-activity/src/test/java/org/apache/taverna/activities/dataflow/DataflowActivityTest.java
----------------------------------------------------------------------
diff --git a/taverna-dataflow-activity/src/test/java/org/apache/taverna/activities/dataflow/DataflowActivityTest.java b/taverna-dataflow-activity/src/test/java/org/apache/taverna/activities/dataflow/DataflowActivityTest.java
new file mode 100644
index 0000000..4986f47
--- /dev/null
+++ b/taverna-dataflow-activity/src/test/java/org/apache/taverna/activities/dataflow/DataflowActivityTest.java
@@ -0,0 +1,97 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.activities.dataflow;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.taverna.activities.testutils.ActivityInvoker;
+import org.apache.taverna.workflowmodel.Dataflow;
+import org.apache.taverna.workflowmodel.Datalink;
+import org.apache.taverna.workflowmodel.Edits;
+import org.apache.taverna.workflowmodel.impl.EditsImpl;
+import org.apache.taverna.workflowmodel.processor.activity.impl.ActivityInputPortImpl;
+import org.apache.taverna.workflowmodel.processor.activity.impl.ActivityOutputPortImpl;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Dataflow Activity Tests
+ *
+ * @author David Withers
+ */
+public class DataflowActivityTest {
+
+	private Dataflow dataflow;
+
+	private DataflowActivity activity;
+
+	@Before
+	public void setUp() throws Exception {
+		activity = new DataflowActivity();
+		Edits edits = new EditsImpl();
+		activity.setEdits(edits);
+		dataflow = edits.createDataflow();
+		edits.getCreateDataflowInputPortEdit(dataflow, "input", 0, 0).doEdit();
+		edits.getCreateDataflowOutputPortEdit(dataflow, "output").doEdit();
+		Datalink datalink = edits.createDatalink(dataflow.getInputPorts().get(0)
+				.getInternalOutputPort(), dataflow.getOutputPorts().get(0).getInternalInputPort());
+		edits.getConnectDatalinkEdit(datalink).doEdit();
+	}
+
+	@Test
+	public void testConfigureDataflowActivityConfigurationBean() throws Exception {
+		activity.setNestedDataflow(dataflow);
+		assertEquals(dataflow, activity.getNestedDataflow());
+
+		Edits edits = new EditsImpl();
+		dataflow = edits.createDataflow();
+		edits.getAddActivityInputPortEdit(activity, new ActivityInputPortImpl("input", 0)).doEdit();
+		edits.getAddActivityOutputPortEdit(activity, new ActivityOutputPortImpl("output", 0, 0))
+				.doEdit();
+
+		assertEquals(1, activity.getInputPorts().size());
+		assertEquals("input", activity.getInputPorts().iterator().next().getName());
+		assertEquals(1, activity.getOutputPorts().size());
+		assertEquals("output", activity.getOutputPorts().iterator().next().getName());
+
+		Map<String, Object> inputs = new HashMap<String, Object>();
+		inputs.put("input", "aString");
+		Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>();
+		expectedOutputs.put("output", String.class);
+
+		Map<String, Object> outputs = ActivityInvoker.invokeAsyncActivity(activity, inputs,
+				expectedOutputs);
+		assertTrue("there should be an output named output", outputs.containsKey("output"));
+		assertEquals("output should have the value aString", "aString", outputs.get("output"));
+	}
+
+	@Test
+	public void testGetConfiguration() {
+		assertNull("freshly created activity should not contain configuration",
+				activity.getConfiguration());
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/AbstractExecution.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/AbstractExecution.java b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/AbstractExecution.java
new file mode 100644
index 0000000..e1b7962
--- /dev/null
+++ b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/AbstractExecution.java
@@ -0,0 +1,138 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.api;
+
+import java.util.UUID;
+
+import org.apache.taverna.robundle.Bundle;
+
+import org.apache.taverna.platform.report.ActivityReport;
+import org.apache.taverna.platform.report.ProcessorReport;
+import org.apache.taverna.platform.report.WorkflowReport;
+import org.apache.taverna.scufl2.api.activity.Activity;
+import org.apache.taverna.scufl2.api.common.Scufl2Tools;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.Processor;
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.profiles.ProcessorBinding;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+/**
+ * Abstract implementation of an {@link Execution}.
+ *
+ * @author David Withers
+ */
+public abstract class AbstractExecution implements Execution {
+
+	private final String ID;
+	private final WorkflowBundle workflowBundle;
+	private final Bundle dataBundle;
+	private final Workflow workflow;
+	private final Profile profile;
+	private final WorkflowReport workflowReport;
+
+	private final Scufl2Tools scufl2Tools = new Scufl2Tools();
+
+	/**
+	 * Constructs an abstract implementation of an Execution.
+	 *
+	 * @param workflowBundle
+	 *            the <code>WorkflowBundle</code> containing the <code>Workflow</code>s required for
+	 *            execution
+	 * @param workflow
+	 *            the <code>Workflow</code> to execute
+	 * @param profile
+	 *            the <code>Profile</code> to use when executing the <code>Workflow</code>
+	 * @param dataBundle
+	 *            the <code>Bundle</code> containing the data values for the <code>Workflow</code>
+	 * @throws InvalidWorkflowException
+	 *             if the specified workflow is invalid
+	 */
+	public AbstractExecution(WorkflowBundle workflowBundle, Workflow workflow, Profile profile,
+			Bundle dataBundle) {
+		this.workflowBundle = workflowBundle;
+		this.workflow = workflow;
+		this.profile = profile;
+		this.dataBundle = dataBundle;
+		ID = UUID.randomUUID().toString();
+		workflowReport = generateWorkflowReport(workflow);
+	}
+
+	protected abstract WorkflowReport createWorkflowReport(Workflow workflow);
+
+	protected abstract ProcessorReport createProcessorReport(Processor processor);
+
+	protected abstract ActivityReport createActivityReport(Activity activity);
+
+	public WorkflowReport generateWorkflowReport(Workflow workflow) {
+		WorkflowReport workflowReport = createWorkflowReport(workflow);
+		for (Processor processor : workflow.getProcessors()) {
+			ProcessorReport processorReport = createProcessorReport(processor);
+			processorReport.setParentReport(workflowReport);
+			workflowReport.addProcessorReport(processorReport);
+			for (ProcessorBinding processorBinding : scufl2Tools.processorBindingsForProcessor(
+					processor, profile)) {
+				Activity boundActivity = processorBinding.getBoundActivity();
+				ActivityReport activityReport = createActivityReport(boundActivity);
+				activityReport.setParentReport(processorReport);
+				if (scufl2Tools.containsNestedWorkflow(processor, profile)) {
+					Workflow nestedWorkflow = scufl2Tools.nestedWorkflowForProcessor(processor,
+							profile);
+					WorkflowReport nestedWorkflowReport = generateWorkflowReport(nestedWorkflow);
+					nestedWorkflowReport.setParentReport(activityReport);
+					activityReport.setNestedWorkflowReport(nestedWorkflowReport);
+				}
+				processorReport.addActivityReport(activityReport);
+			}
+		}
+		return workflowReport;
+	}
+
+	@Override
+	public String getID() {
+		return ID;
+	}
+
+	@Override
+	public WorkflowBundle getWorkflowBundle() {
+		return workflowBundle;
+	}
+
+	@Override
+	public Bundle getDataBundle() {
+		return dataBundle;
+	}
+
+	@Override
+	public Workflow getWorkflow() {
+		return workflow;
+	}
+
+	@Override
+	public Profile getProfile() {
+		return profile;
+	}
+
+	@Override
+	public WorkflowReport getWorkflowReport() {
+		return workflowReport;
+	}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/AbstractExecutionEnvironment.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/AbstractExecutionEnvironment.java b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/AbstractExecutionEnvironment.java
new file mode 100644
index 0000000..9364fca
--- /dev/null
+++ b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/AbstractExecutionEnvironment.java
@@ -0,0 +1,78 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.api;
+
+import java.net.URI;
+
+/**
+ * A common super type for concrete implementations of <code>ExecutionEnvironment</code>s.
+ *
+ * @author David Withers
+ */
+public abstract class AbstractExecutionEnvironment implements ExecutionEnvironment {
+	private final String ID;
+	private final String name;
+	private final String description;
+	private final ExecutionService executionService;
+
+	public AbstractExecutionEnvironment(String ID, String name, String description,
+			ExecutionService executionService) {
+		this.ID = ID;
+		this.name = name;
+		this.description = description;
+		this.executionService = executionService;
+	}
+
+	@Override
+	public String getID() {
+		return ID;
+	}
+
+	@Override
+	public String getName() {
+		return name;
+	}
+
+	@Override
+	public String getDescription() {
+		return description;
+	}
+
+	@Override
+	public ExecutionService getExecutionService() {
+		return executionService;
+	}
+
+	@Override
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		sb.append(ID + "\n");
+		sb.append(name + "\n");
+		sb.append(description + "\n");
+		sb.append("Activities : \n");
+		for (URI uri : getActivityTypes())
+			sb.append("  " + uri + "\n");
+		sb.append("Dispatch Layers : \n");
+		for (URI uri : getDispatchLayerTypes())
+			sb.append("  " + uri + "\n");
+		return sb.toString();
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/AbstractExecutionService.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/AbstractExecutionService.java b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/AbstractExecutionService.java
new file mode 100755
index 0000000..f884de7
--- /dev/null
+++ b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/AbstractExecutionService.java
@@ -0,0 +1,138 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.api;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.taverna.robundle.Bundle;
+
+import org.apache.taverna.platform.report.WorkflowReport;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+/**
+ * A common super type for concrete implementations of <code>ExecutionService</code>s.
+ *
+ * @author David Withers
+ */
+public abstract class AbstractExecutionService implements ExecutionService {
+	private final String ID;
+	private final String name;
+	private final String description;
+	private final Map<String, Execution> executionMap;
+
+	public AbstractExecutionService(String ID, String name, String description) {
+		this.ID = ID;
+		this.name = name;
+		this.description = description;
+		executionMap = Collections.synchronizedMap(new HashMap<String, Execution>());
+	}
+
+	@Override
+	public String getID() {
+		return ID;
+	}
+
+	@Override
+	public String getName() {
+		return name;
+	}
+
+	@Override
+	public String getDescription() {
+		return description;
+	}
+
+	@Override
+	public String createExecution(ExecutionEnvironment executionEnvironment,
+			WorkflowBundle workflowBundle, Workflow workflow, Profile profile,
+			Bundle dataBundle) throws InvalidWorkflowException {
+		Execution execution = createExecutionImpl(workflowBundle, workflow, profile, dataBundle);
+		executionMap.put(execution.getID(), execution);
+		return execution.getID();
+	}
+
+	/**
+	 * Creates an implementation of an Execution.
+	 *
+	 * To be implemented by concrete implementations of <code>ExecutionService</code>.
+	 *
+	 * @param workflowBundle
+	 *            the <code>WorkflowBundle</code> containing the <code>Workflow</code>s required for
+	 *            execution
+	 * @param workflow
+	 *            the <code>Workflow</code> to execute
+	 * @param profile
+	 *            the <code>Profile</code> to use when executing the <code>Workflow</code>
+	 * @param dataBundle
+	 *            the <code>Bundle</code> containing the data values for the <code>Workflow</code>
+	 * @return a new Execution implementation
+	 * @throws InvalidWorkflowException
+	 *             if the specified workflow is invalid
+	 */
+	protected abstract Execution createExecutionImpl(
+			WorkflowBundle workflowBundle, Workflow workflow, Profile profile,
+			Bundle dataBundle) throws InvalidWorkflowException;
+
+	@Override
+	public WorkflowReport getWorkflowReport(String executionID)
+			throws InvalidExecutionIdException {
+		return getExecution(executionID).getWorkflowReport();
+	}
+
+	@Override
+	public void delete(String executionID) throws InvalidExecutionIdException {
+		getExecution(executionID).delete();
+		executionMap.remove(executionID);
+	}
+
+	@Override
+	public void start(String executionID) throws InvalidExecutionIdException {
+		getExecution(executionID).start();
+	}
+
+	@Override
+	public void pause(String executionID) throws InvalidExecutionIdException {
+		getExecution(executionID).pause();
+	}
+
+	@Override
+	public void resume(String executionID) throws InvalidExecutionIdException {
+		getExecution(executionID).resume();
+	}
+
+	@Override
+	public void cancel(String executionID) throws InvalidExecutionIdException {
+		getExecution(executionID).cancel();
+	}
+
+	protected Execution getExecution(String executionID)
+			throws InvalidExecutionIdException {
+		Execution execution = executionMap.get(executionID);
+		if (execution == null)
+			throw new InvalidExecutionIdException("Execution ID " + executionID
+					+ " is not valid");
+		return execution;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/Execution.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/Execution.java b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/Execution.java
new file mode 100644
index 0000000..b49652a
--- /dev/null
+++ b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/Execution.java
@@ -0,0 +1,103 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.api;
+
+import org.apache.taverna.robundle.Bundle;
+
+import org.apache.taverna.platform.report.WorkflowReport;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+/**
+ * Interface for a single execution of a Taverna workflow.
+ *
+ * @author David Withers
+ */
+public interface Execution {
+
+	/**
+	 * Returns the identifier for this execution.
+	 *
+	 * @return the identifier for this execution
+	 */
+	public abstract String getID();
+
+	/**
+	 * Returns the <code>WorkflowBundle</code> containing the <code>Workflow</code>s required for execution.
+	 *
+	 * @return the <code>WorkflowBundle</code> containing the <code>Workflow</code>s required for execution
+	 */
+	public abstract WorkflowBundle getWorkflowBundle();
+
+	/**
+	 * Returns the <code>Bundle</code> containing the data values for the <code>Workflow</code>.
+	 *
+	 * @return the <code>Bundle</code> containing the data values for the <code>Workflow</code>
+	 */
+	public abstract Bundle getDataBundle();
+
+	/**
+	 * Returns the <code>Workflow</code> to execute.
+	 *
+	 * @return the <code>Workflow</code> to execute
+	 */
+	public abstract Workflow getWorkflow();
+
+	/**
+	 * Returns the <code>Profile</code> to use when executing the <code>Workflow</code>.
+	 *
+	 * @return the <code>Profile</code> to use when executing the <code>Workflow</code>
+	 */
+	public abstract Profile getProfile();
+
+	/**
+	 * Returns the <code>WorkflowReport</code> for the execution.
+	 *
+	 * @return the <code>WorkflowReport</code> for the execution
+	 */
+	public abstract WorkflowReport getWorkflowReport();
+
+	/**
+	 * Deletes the execution.
+	 */
+	public abstract void delete();
+
+	/**
+	 * Starts the execution.
+	 */
+	public abstract void start();
+
+	/**
+	 * Pauses the execution.
+	 */
+	public abstract void pause();
+
+	/**
+	 * Resumes a paused execution.
+	 */
+	public abstract void resume();
+
+	/**
+	 * Cancels the execution.
+	 */
+	public abstract void cancel();
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/ExecutionEnvironment.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/ExecutionEnvironment.java b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/ExecutionEnvironment.java
new file mode 100644
index 0000000..3528c5b
--- /dev/null
+++ b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/ExecutionEnvironment.java
@@ -0,0 +1,128 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.api;
+
+import java.net.URI;
+import java.util.Set;
+
+import org.apache.taverna.platform.capability.api.ActivityConfigurationException;
+import org.apache.taverna.platform.capability.api.ActivityNotFoundException;
+import org.apache.taverna.platform.capability.api.DispatchLayerConfigurationException;
+import org.apache.taverna.platform.capability.api.DispatchLayerNotFoundException;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * The ExecutionEnvironment specifies the capabilities of a workflow execution environment.
+ *
+ * @author David Withers
+ */
+public interface ExecutionEnvironment {
+
+	/**
+	 * Returns the identifier for this ExecutionEnvironment.
+	 *
+	 * @return the identifier for this ExecutionEnvironment
+	 */
+	public String getID();
+
+	/**
+	 * Returns the name of this ExecutionEnvironment.
+	 *
+	 * @return the name of this ExecutionEnvironment
+	 */
+	public String getName();
+
+	/**
+	 * Returns a description of this ExecutionEnvironment.
+	 *
+	 * @return a description of this ExecutionEnvironment
+	 */
+	public String getDescription();
+
+	/**
+	 * Returns the ExecutionService that provides this ExecutionEnvironment.
+	 *
+	 * @return the ExecutionService that provides this ExecutionEnvironment
+	 */
+	public ExecutionService getExecutionService();
+
+	/**
+	 * Returns the activity types available in this ExecutionEnvironment.
+	 *
+	 * @return the activity types available in this ExecutionEnvironment
+	 */
+	public Set<URI> getActivityTypes();
+
+	/**
+	 * Returns true iff an activity exists for the specified URI in this ExecutionEnvironment.
+	 *
+	 * @param uri
+	 *            the activity URI to check
+	 * @return true if an activity exists for the specified URI in this ExecutionEnvironment
+	 */
+	public boolean activityExists(URI uri);
+
+	/**
+	 * Returns a JSON Schema for the configuration required by an activity.
+	 *
+	 * @param uri
+	 *            a URI that identifies an activity
+	 * @return a JSON Schema for the configuration required by an activity
+	 * @throws ActivityNotFoundException
+	 *             if an activity cannot be found for the specified URI
+	 * @throws ActivityConfigurationException
+	 *             if the ConfigurationDefinition cannot be created
+	 */
+	public JsonNode getActivityConfigurationSchema(URI uri)
+			throws ActivityNotFoundException, ActivityConfigurationException;
+
+	/**
+	 * Returns the dispatch layer types available in this ExecutionEnvironment.
+	 *
+	 * @return the dispatch layer types available in this ExecutionEnvironment
+	 */
+	public Set<URI> getDispatchLayerTypes();
+
+	/**
+	 * Returns true iff a dispatch layer exists for the specified URI in this ExecutionEnvironment.
+	 *
+	 * @param uri
+	 *            the dispatch layer URI to check
+	 * @return true if a dispatch layer exists for the specified URI in this ExecutionEnvironment
+	 */
+	public boolean dispatchLayerExists(URI uri);
+
+	/**
+	 * Returns a JSON Schema for the configuration required by a dispatch layer.
+	 *
+	 * @param uri
+	 *            a URI that identifies a dispatch layer
+	 * @return
+	 * @return a JSON Schema for the configuration required by a dispatch layer
+	 * @throws DispatchLayerNotFoundException
+	 *             if a dispatch layer cannot be found for the specified URI
+	 * @throws DispatchLayerConfigurationException
+	 *             if the ConfigurationDefinition cannot be created
+	 */
+	public JsonNode getDispatchLayerConfigurationSchema(URI uri)
+			throws DispatchLayerNotFoundException, DispatchLayerConfigurationException;
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/ExecutionEnvironmentService.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/ExecutionEnvironmentService.java b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/ExecutionEnvironmentService.java
new file mode 100644
index 0000000..a100603
--- /dev/null
+++ b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/ExecutionEnvironmentService.java
@@ -0,0 +1,51 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.execution.api;
+
+import java.util.Set;
+
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+/**
+ * Service for finding <code>ExecutionEnvironment</code>s.
+ *
+ * @author David Withers
+ */
+public interface ExecutionEnvironmentService {
+
+	/**
+	 * Returns the available <code>ExecutionEnvironment</code>s.
+	 *
+	 * @return the available <code>ExecutionEnvironment</code>s
+	 */
+	public Set<ExecutionEnvironment> getExecutionEnvironments();
+
+	/**
+	 * Returns the <code>ExecutionEnvironment</code>s that can execute the specified
+	 * <code>Profile</code>.
+	 *
+	 * @param profile
+	 *            the <code>Profile</code> to find <code>ExecutionEnvironment</code>s for
+	 * @return the <code>ExecutionEnvironment</code>s that can execute a workflow with the specified
+	 *         <code>Profile</code>
+	 */
+	public Set<ExecutionEnvironment> getExecutionEnvironments(Profile profile);
+
+}


[41/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/T2ReferenceType.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/T2ReferenceType.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/T2ReferenceType.java
deleted file mode 100644
index b60333c..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/T2ReferenceType.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * The T2Reference interface is used to identify several different kinds of
- * information, namely ReferenceSet, IdentifiedList and ErrorDocument. Because
- * the top level reference service needs to determine which sub-service to
- * delegate to when resolving references we carry this information in each
- * T2Reference in the form of one of these enumerated types.
- * 
- * @author Tom Oinn
- */
-public enum T2ReferenceType {
-	/**
-	 * A reference to a ReferenceSet
-	 */
-	ReferenceSet,
-
-	/**
-	 * A reference to an IdentifiedList of other T2References
-	 */
-	IdentifiedList,
-
-	/**
-	 * A reference to an ErrorDocument
-	 */
-	ErrorDocument;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ValueCarryingExternalReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ValueCarryingExternalReference.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ValueCarryingExternalReference.java
deleted file mode 100644
index a1ecc7d..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ValueCarryingExternalReference.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * Specialization of ExternalReferenceSPI for reference types which carry a
- * value type internally. Such references can be de-referenced to the specified
- * object type very cheaply. Note that this is not to be used to get an object
- * property of a reference, the returned object must correspond to the value of
- * the referenced data - this means that the HttpUrlReference does not use this
- * to return a java.net.URL, but that the InlineStringReference does use it to
- * return a java.lang.String
- * 
- * @author Tom Oinn
- */
-public interface ValueCarryingExternalReference<T> extends ExternalReferenceSPI {
-	/**
-	 * Returns the type of the inlined value
-	 */
-	Class<T> getValueType();
-
-	/**
-	 * Returns the value
-	 */
-	T getValue();
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ValueToReferenceConversionException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ValueToReferenceConversionException.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ValueToReferenceConversionException.java
deleted file mode 100644
index 3187184..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ValueToReferenceConversionException.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * Thrown by instances of ValueToReferenceConvertor when trying to convert an
- * object to an instance of ExternalReferenceSPI if the conversion process fails
- * for some reason.
- * 
- * @author Tom Oinn
- */
-public class ValueToReferenceConversionException extends RuntimeException {
-	private static final long serialVersionUID = 3259959719223191820L;
-
-	public ValueToReferenceConversionException() {
-		//
-	}
-
-	public ValueToReferenceConversionException(String message) {
-		super(message);
-	}
-
-	public ValueToReferenceConversionException(Throwable cause) {
-		super(cause);
-	}
-
-	public ValueToReferenceConversionException(String message, Throwable cause) {
-		super(message, cause);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ValueToReferenceConverterSPI.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ValueToReferenceConverterSPI.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ValueToReferenceConverterSPI.java
deleted file mode 100644
index 04a4cfd..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ValueToReferenceConverterSPI.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * SPI for components that can convert an arbitrary object to an
- * ExternalReferenceSPI representing the value of that object. Used by
- * implementations of {@link ReferenceService#register(Object, int, boolean)} to
- * map arbitrary objects to ExternalReferenceSPI instances if encountered during
- * the registration process. This SPI is only used if the boolean
- * useConverterSPI parameter is set to true on that method.
- * 
- * @author Tom Oinn
- */
-public interface ValueToReferenceConverterSPI {
-	/**
-	 * Can this SPI implementation convert the specified object to an
-	 * ExternalReferenceSPI? This test should be as lightweight as possible, and
-	 * will usually be based on the Class of the object supplied.
-	 * 
-	 * @param context
-	 *            a ReferenceContext to use if required by the plugin, the
-	 *            ability to convert should be interpreted in the scope of this
-	 *            context. In general the context probably not used by most
-	 *            implementations but it's here if required.
-	 * 
-	 * @return whether this converter is applicable to the specified object
-	 */
-	boolean canConvert(Object o, ReferenceContext context);
-
-	/**
-	 * Construct and return a new ExternalReferenceSPI implementation which is
-	 * in some way equivalent to the supplied object. This is not intended to be
-	 * a two-way process necessarily, although the conversion should attempt to
-	 * be conservative (so not actually changing the data!).
-	 * 
-	 * @param context
-	 *            a ReferenceContext to use, if required, during construction of
-	 *            the new external reference
-	 * @return A new instance of ExternalReferenceSPI which references, as far
-	 *         as possible, the value represented by the specified object
-	 * @throws ValueToReferenceConversionException
-	 *             if any problem occurs during the conversion
-	 */
-	ExternalReferenceSPI convert(Object o, ReferenceContext context)
-			throws ValueToReferenceConversionException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/WorkflowRunIdEntity.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/WorkflowRunIdEntity.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/WorkflowRunIdEntity.java
deleted file mode 100644
index e60bed9..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/WorkflowRunIdEntity.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference;
-
-/**
- * Entity that wraps workflow run id and can be passed through (
- * {@link ReferenceContext} to be used by {@link T2ReferenceGenerator} to
- * generate references that are specific for a workflow run.
- * 
- * @author Alex Nenadic
- */
-public class WorkflowRunIdEntity {
-	private String workflowRunId;
-
-	public WorkflowRunIdEntity(String workflowRunId) {
-		this.setWorkflowRunId(workflowRunId);
-	}
-
-	public void setWorkflowRunId(String workflowRunId) {
-		this.workflowRunId = workflowRunId;
-	}
-
-	public String getWorkflowRunId() {
-		return workflowRunId;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/annotations/DeleteIdentifiedOperation.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/annotations/DeleteIdentifiedOperation.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/annotations/DeleteIdentifiedOperation.java
deleted file mode 100644
index 863a193..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/annotations/DeleteIdentifiedOperation.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package net.sf.taverna.t2.reference.annotations;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Applied to methods in Dao implementations which delete data in the backing
- * store.
- * 
- * @author Stuart Owen
- */
-@Retention(RUNTIME)
-@Target(METHOD)
-public @interface DeleteIdentifiedOperation {
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/annotations/GetIdentifiedOperation.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/annotations/GetIdentifiedOperation.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/annotations/GetIdentifiedOperation.java
deleted file mode 100644
index bc23b20..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/annotations/GetIdentifiedOperation.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.annotations;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Applied to methods in Dao implementations which fetch data from the backing
- * store by ID
- * 
- * @author Tom Oinn
- */
-@Retention(RUNTIME)
-@Target(METHOD)
-public @interface GetIdentifiedOperation {
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/annotations/PutIdentifiedOperation.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/annotations/PutIdentifiedOperation.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/annotations/PutIdentifiedOperation.java
deleted file mode 100644
index d05febe..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/annotations/PutIdentifiedOperation.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.annotations;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Applied to methods in Dao implementations which store or update data in the
- * backing store.
- * 
- * @author Tom Oinn
- */
-@Retention(RUNTIME)
-@Target(METHOD)
-public @interface PutIdentifiedOperation {
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/annotations/package.html
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/annotations/package.html b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/annotations/package.html
deleted file mode 100644
index 0d38e1e..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/annotations/package.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<body>
-Annotations to make methods in the data access object implementations
-for cache injection.
-</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/h3/HibernateComponentClass.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/h3/HibernateComponentClass.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/h3/HibernateComponentClass.java
deleted file mode 100644
index f8f2076..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/h3/HibernateComponentClass.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.h3;
-
-/**
- * A marker used to denote that the class should be pre-loaded into hibernate's
- * class mapping. Used for component classes which are not going to be mapped to
- * the RDBMS but which must be loadable for mapped classes to instantiate
- * correctly. Basically if you refer to a class that isn't itself going to be
- * mapped in hibernate within a mapping definition you'll need to add that
- * component class to this SPI or hibernate won't be able to find it as it won't
- * know that it should associate it with the appropriate class loader.
- * <p>
- * This should be used as an SPI marker, and set as the first SPI registry in
- * the preloadRegistries property of the SpiRegistryAwareLocalSessionFactoryBean
- * 
- * @author Tom Oinn
- */
-public interface HibernateComponentClass {
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/h3/HibernateMappedEntity.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/h3/HibernateMappedEntity.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/h3/HibernateMappedEntity.java
deleted file mode 100644
index ae77e1d..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/h3/HibernateMappedEntity.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.h3;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceSet;
-
-/**
- * A marker interface used to denote that the component should be registered
- * with the Hibernate ORM system prior to any {@link ExternalReferenceSPI}
- * implementations. This is here to allow implementations of e.g.
- * {@link ReferenceSet} to be in the implementation package where they belong
- * and still guarantee that they are registered before any other plugins.
- * <p>
- * This should be used as an SPI marker, and set as the first SPI registry in
- * the spiRegistries property of the SpiRegistryAwareLocalSessionFactoryBean
- * 
- * @author Tom Oinn
- */
-public interface HibernateMappedEntity {
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/h3/package.html
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/h3/package.html b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/h3/package.html
deleted file mode 100644
index 4ffba14..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/h3/package.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<body>
-Contains the marker interfaces used by the implementation package to
-ensure that all appropriate classes are mapped in hibernate
-<em>before</em>
-implementations of classes that depend upon them, and to ensure that
-'static' classes such as the implementations of reference set etc are
-mapped correctly.
-</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/package.html
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/package.html b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/package.html
deleted file mode 100644
index 503dc3b..0000000
--- a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/package.html
+++ /dev/null
@@ -1,43 +0,0 @@
-<body>
-<p>Interfaces for the Taverna 2 reference manager. This replaces the
-(badly named) DataManager and is, in effect, a version 2 of that system.
-While these APIs are implementation neutral the intent is heavily
-towards the use of an object relational mapping (ORM) tool such as
-Hibernate backed by a relational database to hold the various
-collection, external reference and error documents managed by the
-reference manager.</p>
-<p>For those familiar with the previous DataManager code the table
-below shows the old class names and the equivalent (where appropriate)
-in the new code:
-</p>
-<table>
-	<tr>
-		<td>DataDocument</td>
-		<td>{@link net.sf.taverna.t2.reference.ReferenceSet}</td>
-	</tr>
-	<tr>
-		<td>ReferenceScheme</td>
-		<td>{@link net.sf.taverna.t2.reference.ExternalReferenceSPI}</td>
-	</tr>
-	<tr>
-		<td>EntityIdentifier</td>
-		<td>{@link net.sf.taverna.t2.reference.T2Reference}</td>
-	</tr>
-	<tr>
-		<td colspan="2">...</td>
-	</tr>
-</table>
-<p>One fundamental change is a move to runtime exceptions rather
-than checked exceptions. This follows the pattern used by Spring and
-Hibernate. The rationale is the same as in those systems - in general
-checked exceptions are not handled properly by client code. The loss of
-compiler level functionality from moving to runtime exceptions is
-countered by much higher readability of code which in itself leads to
-more robust and reliable systems.</p>
-<p>A second change is the availability of asynchronous versions of
-all the critical APIs. Reference construction or translation in
-particular can be a costly process taking substantial time to complete.
-Synchronous versions of the get methods still exist but in general the
-simple callback based asynchronous ones are recommended over them for
-most applications.</p>
-</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/AbstractExternalReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/AbstractExternalReference.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/AbstractExternalReference.java
new file mode 100644
index 0000000..084844a
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/AbstractExternalReference.java
@@ -0,0 +1,88 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+import static org.apache.taverna.reference.ReferencedDataNature.*;
+
+/**
+ * A trivial implementation of ExternalReference. This abstract class should be
+ * used as the superclass of any ExternalReference implementations as it
+ * provides base metadata for the hibernate-based persistence system used by the
+ * main reference manager implementation. While the interface contract cannot
+ * require this your extensions will likely not work properly unless you use
+ * this class.
+ * 
+ * @author Tom Oinn
+ */
+public abstract class AbstractExternalReference implements ExternalReferenceSPI {
+	// Used internally by Hibernate for this class and subclasses
+	private int primaryKey;
+
+	/**
+	 * Used by Hibernate internally to establish a foreign key relationship
+	 * between this abstract superclass and tables corresponding to
+	 * implementations of the ExternalReference interface. Has no impact on any
+	 * application level code, this method is only ever used by the internals of
+	 * the hibernate framework.
+	 */
+	public final void setPrimaryKey(int newKey) {
+		this.primaryKey = newKey;
+	}
+
+	/**
+	 * Used by Hibernate internally to establish a foreign key relationship
+	 * between this abstract superclass and tables corresponding to
+	 * implementations of the ExternalReference interface. Has no impact on any
+	 * application level code, this method is only ever used by the internals of
+	 * the hibernate framework.
+	 */
+	public final int getPrimaryKey() {
+		return this.primaryKey;
+	}
+
+	/**
+	 * Default to returning DataReferenceNature.UNKNOWN
+	 */
+	@Override
+	public ReferencedDataNature getDataNature() {
+		return UNKNOWN;
+	}
+
+	/**
+	 * Default to returning null for charset
+	 */
+	@Override
+	public String getCharset() {
+		return null;
+	}
+
+	/**
+	 * Default to a value of 0.0f for the resolution cost, but implementations
+	 * should at least attempt to set this to a more sensible level!
+	 */
+	@Override
+	public float getResolutionCost() {
+		return 0.0f;
+	}
+
+	@Override
+	public abstract ExternalReferenceSPI clone()
+			throws CloneNotSupportedException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ContextualizedT2Reference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ContextualizedT2Reference.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ContextualizedT2Reference.java
new file mode 100644
index 0000000..c0249e7
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ContextualizedT2Reference.java
@@ -0,0 +1,46 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * Used by the {@link ReferenceService#traverseFrom(T2Reference, int)} when
+ * traversing a collection structure. Each contextualized t2reference contains
+ * the {@link T2Reference} along with an integer array index representing the
+ * position of that reference within the traversal structure. The index
+ * [i<sub>0</sub>,i<sub>1</sub>,i<sub>2</sub> ... i<sub>n</sub>] is interpreted
+ * such that the reference is located at
+ * parent.get(i<sub>0</sub>).get(i<sub>1</sub
+ * >).get(i<sub>2</sub>)....get(i<sub>n</sub>). If the index is empty then the
+ * T2Reference <em>is</em> the original reference supplied to the
+ * {@link ReferenceService#traverseFrom(T2Reference, int) traverseFrom} method.
+ * 
+ * @author Tom Oinn
+ */
+public interface ContextualizedT2Reference {
+	/**
+	 * @return the T2Reference to which the associated index applies.
+	 */
+	T2Reference getReference();
+
+	/**
+	 * @return the index of this T2Reference
+	 */
+	int[] getIndex();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/DaoException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/DaoException.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/DaoException.java
new file mode 100644
index 0000000..62d67cd
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/DaoException.java
@@ -0,0 +1,46 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * Thrown by the Data Access Object interface methods, wrapping any underlying
+ * exception.
+ * 
+ * @author Tom Oinn
+ */
+public class DaoException extends RuntimeException {
+	static final long serialVersionUID = 8496141798637577803L;
+
+	public DaoException() {
+		super();
+	}
+
+	public DaoException(String message) {
+		super(message);
+	}
+
+	public DaoException(Throwable cause) {
+		super(cause);
+	}
+
+	public DaoException(String message, Throwable cause) {
+		super(message, cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/DereferenceException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/DereferenceException.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/DereferenceException.java
new file mode 100644
index 0000000..572d150
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/DereferenceException.java
@@ -0,0 +1,47 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * Thrown when a problem occurs during de-reference of an ExternalReferenceSPI
+ * implementation. This include operations which implicitly de-reference the
+ * reference such as those infering character set or data natures.
+ * 
+ * @author Tom Oinn
+ */
+public class DereferenceException extends RuntimeException {
+	private static final long serialVersionUID = 8054381613840005541L;
+
+	public DereferenceException() {
+		//
+	}
+
+	public DereferenceException(String message) {
+		super(message);
+	}
+
+	public DereferenceException(Throwable cause) {
+		super(cause);
+	}
+
+	public DereferenceException(String message, Throwable cause) {
+		super(message, cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ErrorDocument.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ErrorDocument.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ErrorDocument.java
new file mode 100644
index 0000000..fbc5f1c
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ErrorDocument.java
@@ -0,0 +1,55 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Contains the definition of an error token within the workflow system.
+ * 
+ * @author Tom Oinn
+ * @author David Withers
+ */
+public interface ErrorDocument extends Identified {
+	/**
+	 * If the error document is created from a {@link Throwable} it will have a
+	 * stack trace, in this case the stack trace is represented as a list of
+	 * {@link StackTraceElement} beans
+	 */
+	List<StackTraceElementBean> getStackTraceStrings();
+
+	/**
+	 * If the error document is created from a {@link Throwable}, this contains
+	 * the message part of the {@link Throwable}.
+	 */
+	String getExceptionMessage();
+
+	/**
+	 * Error documents can carry an arbitrary string message, this returns it.
+	 */
+	String getMessage();
+
+	/**
+	 * If the error document is created from set of references that contain
+	 * error documents, this method returns them.
+	 */
+	Set<T2Reference> getErrorReferences();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ErrorDocumentDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ErrorDocumentDao.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ErrorDocumentDao.java
new file mode 100644
index 0000000..a6adea2
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ErrorDocumentDao.java
@@ -0,0 +1,63 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+import static org.springframework.transaction.annotation.Propagation.REQUIRED;
+import static org.springframework.transaction.annotation.Propagation.SUPPORTS;
+
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Data access object handling ErrorDocument instances.
+ * 
+ * @author Tom Oinn
+ */
+public interface ErrorDocumentDao {
+	/**
+	 * Store a named ErrorDocument to the database.
+	 * 
+	 * @param errorDoc
+	 *            error document to store
+	 * @throws DaoException
+	 *             if any exception is thrown when connecting to the underlying
+	 *             store or when storing the error document
+	 */
+	@Transactional(propagation = REQUIRED, readOnly = false)
+	void store(ErrorDocument errorDoc) throws DaoException;
+
+	/**
+	 * Retrieves a named and populated ErrorDocument
+	 * 
+	 * @param reference
+	 *            id of the error document to retrieve
+	 * @return a previously stored ErrorDocument instance
+	 * @throws DaoException
+	 *             if any exception is thrown when connecting to the underlying
+	 *             data store or when attempting retrieval of the error document
+	 */
+	@Transactional(propagation = SUPPORTS, readOnly = true)
+	ErrorDocument get(T2Reference reference) throws DaoException;
+
+	@Transactional(propagation = SUPPORTS, readOnly = false)
+	boolean delete(ErrorDocument errorDoc) throws DaoException;
+
+	@Transactional(propagation = SUPPORTS, readOnly = false)
+	void deleteErrorDocumentsForWFRun(String workflowRunId) throws DaoException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ErrorDocumentService.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ErrorDocumentService.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ErrorDocumentService.java
new file mode 100644
index 0000000..1c8b5d4
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ErrorDocumentService.java
@@ -0,0 +1,151 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+import java.util.Set;
+
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Provides facilities to register list of T2References, register empty lists at
+ * any given depth and to resolve appropriate T2Reference instances back to
+ * these lists. Registration operations assign names and lock the list contents
+ * as a result. This service operates strictly on T2References, it neither tries
+ * to nor is capable of any form of reference resolution, so aspects such as
+ * collection traversal are not handled here (these are performed by the top
+ * level reference service)
+ * 
+ * @author Tom Oinn
+ */
+@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
+public interface ErrorDocumentService {
+	/**
+	 * Register a new error document.
+	 * <p>
+	 * The created reference will be related with a workflow run id passed
+	 * through ReferenceContext so we can track all data referenced by a
+	 * specific run.
+	 * 
+	 * @param message
+	 *            a free text message describing the error, if available. If
+	 *            there is no message use the empty string here.
+	 * @param t
+	 *            a Throwable describing the underlying fault causing this error
+	 *            document to be registered, if any. If there is no Throwable
+	 *            associated use null.
+	 * @param depth
+	 *            depth of the error, used when returning an error document
+	 *            instead of an identified list.
+	 * @return a new ErrorDocument instance, constructed fully and stored in the
+	 *         underlying storage system
+	 */
+	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
+	ErrorDocument registerError(String message, Throwable t, int depth,
+			ReferenceContext context) throws ErrorDocumentServiceException;
+
+	/**
+	 * Equivalent to <code>registerError(message, null, depth, context)</code>.
+	 */
+	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
+	ErrorDocument registerError(String message, int depth,
+			ReferenceContext context) throws ErrorDocumentServiceException;
+
+	/**
+	 * Equivalent to <code>registerError("", t, depth, context)</code>.
+	 */
+	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
+	ErrorDocument registerError(Throwable t, int depth, ReferenceContext context)
+			throws ErrorDocumentServiceException;
+
+	/**
+	 * Register a new error document.
+	 * <p>
+	 * The created reference will be related with a workflow run id passed
+	 * through ReferenceContext so we can track all data referenced by a
+	 * specific run.
+	 * 
+	 * @param message
+	 *            a free text message describing the error, if available. If
+	 *            there is no message use the empty string here.
+	 * @param errors
+	 *            a set of references that contain error documents.
+	 * @param depth
+	 *            depth of the error, used when returning an error document
+	 *            instead of an identified list.
+	 * @return a new ErrorDocument instance, constructed fully and stored in the
+	 *         underlying storage system
+	 */
+	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
+	ErrorDocument registerError(String message, Set<T2Reference> errors,
+			int depth, ReferenceContext context)
+			throws ErrorDocumentServiceException;
+
+	/**
+	 * Retrieve a previously named and registered ErrorDocument from the backing
+	 * store
+	 * 
+	 * @param id
+	 *            identifier of the error document to retrieve
+	 * @return an ErrorDocument
+	 * @throws ErrorDocumentServiceException
+	 *             if anything goes wrong with the retrieval process or if there
+	 *             is something wrong with the reference (such as it being of
+	 *             the wrong reference type).
+	 */
+	ErrorDocument getError(T2Reference id) throws ErrorDocumentServiceException;
+
+	/**
+	 * Functionality the same as {@link #getError(T2Reference) getError} but in
+	 * asynchronous mode, returning immediately and using the supplied callback
+	 * to communicate its results.
+	 * 
+	 * @param id
+	 *            a {@link T2Reference} identifying an {@link ErrorDocument} to
+	 *            retrieve
+	 * @param callback
+	 *            a {@link ErrorDocumentServiceCallback} used to convey the
+	 *            results of the asynchronous call
+	 * @throws ErrorDocumentServiceException
+	 *             if the reference set service is not correctly configured.
+	 *             Exceptions encountered when performing the asynchronous call
+	 *             are not returned here, for obvious reasons, and are instead
+	 *             messaged through the callback interface.
+	 */
+	void getErrorAsynch(T2Reference id, ErrorDocumentServiceCallback callback)
+			throws ErrorDocumentServiceException;
+
+	/**
+	 * Return the T2Reference for the sole child of an error document
+	 * identifier.
+	 */
+	T2Reference getChild(T2Reference errorId)
+			throws ErrorDocumentServiceException;
+
+	@Transactional(propagation = Propagation.SUPPORTS, readOnly = false)
+	boolean delete(T2Reference reference) throws ReferenceServiceException;
+
+	/**
+	 * Delete all {@link ErrorDocument}S used by the specific workflow run.
+	 */
+	@Transactional(propagation = Propagation.SUPPORTS, readOnly = false)
+	void deleteErrorDocumentsForWorkflowRun(String workflowRunId)
+			throws ReferenceServiceException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ErrorDocumentServiceCallback.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ErrorDocumentServiceCallback.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ErrorDocumentServiceCallback.java
new file mode 100644
index 0000000..245faa2
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ErrorDocumentServiceCallback.java
@@ -0,0 +1,46 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * Callback interface used by asynchronous methods in the
+ * {@link ErrorDocumentService} interface
+ * 
+ * @author Tom Oinn
+ */
+public interface ErrorDocumentServiceCallback {
+	/**
+	 * Called when the requested {@link ReferenceSet} has been successfully
+	 * retrieved.
+	 * 
+	 * @param errorDoc
+	 *            the ErrorDocument requested
+	 */
+	void errorRetrieved(ErrorDocument errorDoc);
+
+	/**
+	 * Called if the retrieval failed for some reason
+	 * 
+	 * @param cause
+	 *            an ErrorDocumentServiceException explaining the retrieval
+	 *            failure
+	 */
+	void errorRetrievalFailed(ErrorDocumentServiceException cause);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ErrorDocumentServiceException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ErrorDocumentServiceException.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ErrorDocumentServiceException.java
new file mode 100644
index 0000000..f10189b
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ErrorDocumentServiceException.java
@@ -0,0 +1,47 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * RuntimeException subclass thrown by the error document service layer
+ * interfaces. All underlying exceptions are either handled by the service layer
+ * or wrapped in this exception (or a subclass) and rethrown.
+ * 
+ * @author Tom Oinn
+ */
+public class ErrorDocumentServiceException extends RuntimeException {
+	private static final long serialVersionUID = 5556399589785258956L;
+
+	public ErrorDocumentServiceException() {
+		super();
+	}
+
+	public ErrorDocumentServiceException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+	public ErrorDocumentServiceException(String message) {
+		super(message);
+	}
+
+	public ErrorDocumentServiceException(Throwable cause) {
+		super(cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ExternalReferenceBuilderSPI.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ExternalReferenceBuilderSPI.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ExternalReferenceBuilderSPI.java
new file mode 100644
index 0000000..a22d1f2
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ExternalReferenceBuilderSPI.java
@@ -0,0 +1,89 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+import java.io.InputStream;
+
+/**
+ * Constructs an ExternalReferenceSPI instance from a byte stream. Used by the
+ * {@link ReferenceSetAugmentor} when there isn't a direct reference to
+ * reference translation path available for a desired target type, but available
+ * for external use wherever this functionality is needed.
+ * <p>
+ * Where an underlying resource is required this is extracted from the supplied
+ * ReferenceContext, this implies that all methods in implementations of this
+ * interface should be thread safe, allowing multiple concurrent threads
+ * cleanly. For SPI purposes implementations should be java beans with default
+ * constructors.
+ * 
+ * @author Tom Oinn
+ */
+public interface ExternalReferenceBuilderSPI<TargetType extends ExternalReferenceSPI> {
+	/**
+	 * Given a stream of bytes, build the appropriate target
+	 * ExternalReferenceSPI implementation which would de-reference to the value
+	 * of that stream and return it.
+	 * 
+	 * @param byteStream
+	 *            the bytestream to read target from.
+	 * @param context
+	 *            a reference resolution context, needed potentially to
+	 *            construct the new ExternalReferenceSchemeSPI, especially in
+	 *            cases where the context contains security agents giving access
+	 *            to a remote data staging system *
+	 * @throws ExternalReferenceConstructionException
+	 *             if an error occurs instantiating the new reference.
+	 * @return the newly constructed ExternalReferenceSPI instance.
+	 */
+	TargetType createReference(InputStream byteStream, ReferenceContext context);
+
+	/**
+	 * Expose the type of the ExternalReferenceSPI that this builder can
+	 * construct
+	 * 
+	 * @return the class of ExternalReferenceSPI returned by the create
+	 *         reference methods.
+	 */
+	Class<TargetType> getReferenceType();
+
+	/**
+	 * Because the reference builder may rely on facilities provided to it
+	 * through the context this method is available to check whether these
+	 * facilities are sufficient.
+	 * 
+	 * @param context
+	 *            the reference context that will be used to construct new
+	 *            references
+	 * @return whether the context contains necessary resources for the
+	 *         reference construction process
+	 */
+	boolean isEnabled(ReferenceContext context);
+
+	/**
+	 * Return an approximate complexity cost of the reference construction. In
+	 * general we can't make any guarantees about this because the complexity of
+	 * the construction depends on more than just the type involved - it can
+	 * depend on local configuration, network location relative to the data
+	 * stores referenced and in some cases on the data themselves. For now
+	 * though we assign an approximation, the default value is 1.0f and lower
+	 * values represent less costly operations.
+	 */
+	float getConstructionCost();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ExternalReferenceConstructionException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ExternalReferenceConstructionException.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ExternalReferenceConstructionException.java
new file mode 100644
index 0000000..715d53d
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ExternalReferenceConstructionException.java
@@ -0,0 +1,49 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * Thrown when an exception occurs during construction of an
+ * ExternalReferenceSPI instance. This includes construction through direct
+ * method invocation, through the ExternalReferenceBuilderSPI interface and
+ * through the ExternalReferenceTranslatorSPI interface.
+ * 
+ * @author Tom Oinn
+ */
+public class ExternalReferenceConstructionException extends RuntimeException {
+	private static final long serialVersionUID = 8334725795238353354L;
+
+	public ExternalReferenceConstructionException() {
+		super();
+	}
+
+	public ExternalReferenceConstructionException(String message) {
+		super(message);
+	}
+
+	public ExternalReferenceConstructionException(Throwable cause) {
+		super(cause);
+	}
+
+	public ExternalReferenceConstructionException(String message,
+			Throwable cause) {
+		super(message, cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ExternalReferenceSPI.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ExternalReferenceSPI.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ExternalReferenceSPI.java
new file mode 100644
index 0000000..43f00b7
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ExternalReferenceSPI.java
@@ -0,0 +1,131 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+import java.io.InputStream;
+
+/**
+ * A reference to a single piece of data. This may or may not be within the
+ * enactment infrastructure, it could refer to data held in a file, a URL, a
+ * grid storage system or anything of that nature. Ideally the data this
+ * reference points to should not change - we'd like to say 'must not change' at
+ * this point but this isn't always possible, implementations should aim to
+ * provide the appearance that data are immutable.
+ * <p>
+ * When used within the workflow engine implementations of this interface are
+ * always contained in a ReferenceSet instance.
+ * <p>
+ * Implementors of this interface are strongly advised to use the
+ * AbstractExternalReference superclass - this provides the necessary primary
+ * key information used by hibernate-based implementations of the reference
+ * manager. Technically we don't require it as it's possible that other backend
+ * stores may exist, but the core store used by T2 is based on hibernate so it's
+ * a very good idea to follow this! Basically if you don't your code won't work
+ * in the current system.
+ * <p>
+ * This interface is an SPI - while implementations are never constructed based
+ * on the SPI registry it is used to discover all implementing classes and
+ * automatically register their hibernate mapping files. Implementors should add
+ * their implementation class name to a
+ * META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceSPI file in
+ * the implementation artifact. For examples please refer to the
+ * t2reference-core-extensions module, this contains implementations of this
+ * interface for common basic reference types.
+ * <p>
+ * Note - if your implementation class has a complex hibernate mapping that uses
+ * components which are themselves mapped into the database (perfectly legal to
+ * do) then you must mark those components as instances of HibernateMappedEntity
+ * so their corresponding mapping and class definitions are loaded by the
+ * Hibernate backed reference set dao. If your implementation class uses inline
+ * compound keys or other component types where you reference another class but
+ * the other class is not mapped itself in hibernate you must instead make the
+ * component class an instance of HibernateComponentClass - a marker interface -
+ * for the same reason. Both of these are SPIs themselves, and require the
+ * appropriate entries to be added to their service metadata files in your
+ * extension jar.
+ * 
+ * @author Tom Oinn
+ */
+public interface ExternalReferenceSPI extends Cloneable {
+	/**
+	 * Determine, if possible, whether the data this reference refers to is
+	 * textual or binary in nature. If this determination is impossible, either
+	 * because the ExternalReference implementation does not know or because the
+	 * data is not accessible for some reason then this should return
+	 * ReferenceDataNature.UNKNOWN
+	 * 
+	 * @return the nature of the referenced data
+	 */
+	ReferencedDataNature getDataNature();
+
+	/**
+	 * For textual data return the character set that should be used to pull
+	 * data into a java String object. Callers must deal with a null return
+	 * value in the event of either unknown charset or unknown or binary data
+	 * types.
+	 * 
+	 * @return string character set, for example 'utf-8', or <code>null</code>
+	 *         if binary or unknown type.
+	 */
+	String getCharset();
+
+	/**
+	 * Open and return an InputStream to the data referenced using, if required,
+	 * any facilities within the supplied context.
+	 * 
+	 * @param context
+	 *            the ReferenceContext object used to obtain e.g. security
+	 *            agents or other facilities required when de-referencing this
+	 *            reference.
+	 * @return an InputStream providing access to the referenced data
+	 * @throws DereferenceException
+	 *             if the reference cannot be de-referenced. This may be because
+	 *             of problems with the context such as security failures, or it
+	 *             may be because the reference is inherently not possible to
+	 *             de-reference (as in the case of a non-serializable API
+	 *             consumer reference).
+	 */
+	InputStream openStream(ReferenceContext context)
+			throws DereferenceException;
+
+	/**
+	 * Approximate size of the stored data or -1 if we do not know.
+	 */
+	Long getApproximateSizeInBytes();
+
+	/**
+	 * Resolution cost is an informal guide to how costly the process of
+	 * de-referencing this reference would be. It's used when assessing which
+	 * out of a set of ExternalReferenceSPI implementations to use to get the
+	 * value of the reference(s), in particular when rendering to POJOs or when
+	 * translating throught the de-reference / construct from stream route. As
+	 * this property is highly complex and potentially expensive in itself to
+	 * evaluate there's no requirement for it to be absolutely correct, it's
+	 * just used as a guide that, for example, it is easier to get bytes from a
+	 * file on the local disk than to get them from a resource held on a grid on
+	 * the other side of the planet.
+	 * 
+	 * @return a float representing some notion of resolution cost, lower values
+	 *         represent cheaper de-reference paths.
+	 */
+	float getResolutionCost();
+
+	ExternalReferenceSPI clone() throws CloneNotSupportedException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ExternalReferenceTranslatorSPI.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ExternalReferenceTranslatorSPI.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ExternalReferenceTranslatorSPI.java
new file mode 100644
index 0000000..30047e7
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ExternalReferenceTranslatorSPI.java
@@ -0,0 +1,95 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * Constructs an ExternalReference instance from an existing ExternalReference,
+ * most usually of a different type. Used by the {@link ReferenceSetAugmentor}.
+ * This SPI should not be used for cases where an ExternalReferenceSPI is
+ * constructed from a stream of bytes, this is intended for direct reference to
+ * reference translation with the assumption that this is more efficient for
+ * whatever reason. For cases where the reference is constructed from a byte
+ * stream you should implement {@link ExternalReferenceBuilder} instead.
+ * <p>
+ * For SPI purposes implementations should be java beans with default
+ * constructors, any required state such as the location of remote repositories
+ * to which data can be staged will be passed in in the ReferenceContext.
+ * 
+ * @author Tom Oinn
+ */
+public interface ExternalReferenceTranslatorSPI<SourceType extends ExternalReferenceSPI, TargetType extends ExternalReferenceSPI> {
+	/**
+	 * Given an existing ExternalReferenceSPI, build the appropriate target
+	 * ExternalReferenceSPI implementation and return it.
+	 * 
+	 * @param sourceReference
+	 *            the reference to be used as source for the translation.
+	 * @param context
+	 *            a reference resolution context, needed potentially to access
+	 *            the existing external references or to construct the new one,
+	 *            especially in cases where the context contains security agents
+	 *            giving access to a remote data staging system
+	 * @throws ExternalReferenceConstructionException
+	 *             if an error occurs instantiating the new reference.
+	 * @return the newly constructed ExternalReferenceSPI instance.
+	 */
+	TargetType createReference(SourceType sourceReference,
+			ReferenceContext context);
+
+	/**
+	 * Return the type of external reference that this translator consumes.
+	 * 
+	 * @return ExternalReferenceSPI class corresponding to the reference type
+	 *         used as a source by this translator.
+	 */
+	Class<SourceType> getSourceReferenceType();
+
+	/**
+	 * Return the type of external reference this translator constructs.
+	 * 
+	 * @return ExternalReferenceSPI class corresponding to the reference type
+	 *         emitted by this translator.
+	 */
+	Class<TargetType> getTargetReferenceType();
+
+	/**
+	 * Because the reference translator may rely on facilities provided to it
+	 * through the context this method is available to check whether these
+	 * facilities are sufficient.
+	 * 
+	 * @param context
+	 *            the reference context that will be used to construct new
+	 *            references during the translation process
+	 * @return whether the context contains necessary resources for the
+	 *         reference construction process
+	 */
+	boolean isEnabled(ReferenceContext context);
+
+	/**
+	 * Return an approximate complexity cost of the translation. In general we
+	 * can't make any guarantees about this because the complexity of the
+	 * translation depends on more than just the types involved - it can depend
+	 * on local configuration, network location relative to the data stores
+	 * referenced and in some cases on the data themselves. For now though we
+	 * assign an approximation, the default value is 1.0f and lower values
+	 * represent less costly operations.
+	 */
+	float getTranslationCost();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ExternalReferenceValidationException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ExternalReferenceValidationException.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ExternalReferenceValidationException.java
new file mode 100644
index 0000000..aa084ca
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ExternalReferenceValidationException.java
@@ -0,0 +1,49 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * Thrown by setter methods and constructors of ExternalReferenceSPI
+ * implementations when fed parameters which cause some kind of format or
+ * validation error. These might include badly formed URL or file paths or any
+ * other property that fails to validate against some reference type specific
+ * scheme.
+ * 
+ * @author Tom Oinn
+ */
+public class ExternalReferenceValidationException extends RuntimeException {
+	private static final long serialVersionUID = 3031393671457773057L;
+
+	public ExternalReferenceValidationException() {
+		//
+	}
+
+	public ExternalReferenceValidationException(String message) {
+		super(message);
+	}
+
+	public ExternalReferenceValidationException(Throwable cause) {
+		super(cause);
+	}
+
+	public ExternalReferenceValidationException(String message, Throwable cause) {
+		super(message, cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/Identified.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/Identified.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/Identified.java
new file mode 100644
index 0000000..9da23ca
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/Identified.java
@@ -0,0 +1,35 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+/**
+ * Interface for any object that has an associated {@link T2Reference}
+ * 
+ * @author Tom Oinn
+ */
+public interface Identified {
+	/**
+	 * Return an appropriately configured instance of T2Reference for this
+	 * identified object.
+	 * 
+	 * @return the id of this object in the form of a T2Reference
+	 */
+	T2Reference getId();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/IdentifiedList.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/IdentifiedList.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/IdentifiedList.java
new file mode 100644
index 0000000..747ff84
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/IdentifiedList.java
@@ -0,0 +1,45 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+import java.util.List;
+
+/**
+ * An identified list is a list which is identified by a T2Reference. Lists are
+ * immutable once named - if getId() returns a non null value all list methods
+ * modifying the underlying list data will throw {@link IllegalStateException}.
+ * In the reference management API this list sub-interface is used to represent
+ * both collections of identifiers (i.e. 'raw' stored lists) and more fully
+ * resolved structures where the types in the list can be reference sets, error
+ * documents and other lists of such. The {@link ListDao} interface uses only
+ * the 'raw' form consisting of flat lists of identifiers.
+ * <p>
+ * The IdentifiedList has a unique T2Reference associated with it. If this is
+ * null the contents of the list may be modified, otherwise all modification
+ * operations throw {@link IllegalStateException}. Lists in T2, once named, are
+ * immutable.
+ * 
+ * @author Tom Oinn
+ * 
+ * @param <T>
+ */
+public interface IdentifiedList<T> extends List<T>, Identified {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-api/src/main/java/org/apache/taverna/reference/ListDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/org/apache/taverna/reference/ListDao.java b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ListDao.java
new file mode 100644
index 0000000..7be8c5e
--- /dev/null
+++ b/taverna-reference-api/src/main/java/org/apache/taverna/reference/ListDao.java
@@ -0,0 +1,66 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference;
+
+import static org.springframework.transaction.annotation.Propagation.REQUIRED;
+import static org.springframework.transaction.annotation.Propagation.SUPPORTS;
+
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Data access object handling NamedLists of T2Reference instances.
+ * 
+ * @author Tom Oinn
+ */
+public interface ListDao {
+	/**
+	 * Store a named and populated IdentifiedList of T2Reference to the
+	 * database.
+	 * 
+	 * @param theList
+	 *            list to store
+	 * @throws DaoException
+	 *             if any exception is thrown when connecting to the underlying
+	 *             store or when storing the list
+	 */
+	@Transactional(propagation = REQUIRED, readOnly = false)
+	void store(IdentifiedList<T2Reference> theList) throws DaoException;
+
+	/**
+	 * Retrieves a named and populated IdentifiedList of T2Reference from the
+	 * database by T2Reference
+	 * 
+	 * @param reference
+	 *            id of the list to retrieve
+	 * @return a previously stored list of T2References
+	 * @throws DaoException
+	 *             if any exception is thrown when connecting to the underlying
+	 *             data store or when attempting retrieval of the list
+	 */
+	@Transactional(propagation = SUPPORTS, readOnly = true)
+	IdentifiedList<T2Reference> get(T2Reference reference) throws DaoException;
+
+	@Transactional(propagation = SUPPORTS, readOnly = false)
+	boolean delete(IdentifiedList<T2Reference> theList) throws DaoException;
+
+	@Transactional(propagation = SUPPORTS, readOnly = false)
+	void deleteIdentifiedListsForWFRun(String workflowRunId)
+			throws DaoException;
+}


[30/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToStringConverter.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToStringConverter.java b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToStringConverter.java
new file mode 100644
index 0000000..5b3ccac
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToStringConverter.java
@@ -0,0 +1,79 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl.external.object;
+
+import static org.apache.taverna.reference.ReferencedDataNature.TEXT;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.nio.charset.Charset;
+
+import org.apache.taverna.reference.ReferencedDataNature;
+import org.apache.taverna.reference.StreamToValueConverterSPI;
+
+/**
+ * Build a String from an InputStream
+ * 
+ * @author Tom Oinn
+ */
+public class StreamToStringConverter implements
+		StreamToValueConverterSPI<String> {
+	private static final int END_OF_FILE = -1;
+	private static final int CHUNK_SIZE = 4096;
+	private static final Charset UTF8 = Charset.forName("UTF-8");
+
+	/**
+	 * Reads a text file and returns a string.
+	 */
+	static String readFile(Reader reader) throws IOException {
+		BufferedReader br = new BufferedReader(reader);
+		StringBuilder buffer = new StringBuilder();
+		char[] chunk = new char[CHUNK_SIZE];
+		int character;
+		while ((character = br.read(chunk)) != END_OF_FILE)
+			buffer.append(chunk, 0, character);
+		return buffer.toString();
+	}
+
+	@Override
+	public Class<String> getPojoClass() {
+		return String.class;
+	}
+
+	@Override
+	public String renderFrom(InputStream stream,
+			ReferencedDataNature dataNature, String charset) {
+		try {
+			if (charset != null && dataNature.equals(TEXT))
+				try {
+					Charset c = Charset.forName(charset);
+					return readFile(new InputStreamReader(stream, c));
+				} catch (IllegalArgumentException e1) {
+					// Ignore; fallback below is good enough
+				}
+			return readFile(new InputStreamReader(stream, UTF8));
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToVMObjectReferenceConverter.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToVMObjectReferenceConverter.java b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToVMObjectReferenceConverter.java
new file mode 100644
index 0000000..3e96d08
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToVMObjectReferenceConverter.java
@@ -0,0 +1,55 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl.external.object;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+
+import org.apache.taverna.reference.ReferencedDataNature;
+import org.apache.taverna.reference.StreamToValueConverterSPI;
+
+/**
+ * Builds a VMObjectReference from an InputStream.
+ * 
+ * @author Alex Nenadic
+ */
+public class StreamToVMObjectReferenceConverter implements
+		StreamToValueConverterSPI<VMObjectReference> {
+	@Override
+	public Class<VMObjectReference> getPojoClass() {
+		return VMObjectReference.class;
+	}
+
+	@Override
+	public VMObjectReference renderFrom(InputStream stream,
+			ReferencedDataNature dataNature, String charset) {
+		VMObjectReference vmRef = new VMObjectReference();
+		try {
+			ObjectInputStream in = new ObjectInputStream(stream);
+			vmRef = (VMObjectReference) in.readObject();
+			return vmRef;
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		} catch (ClassNotFoundException e) {
+			throw new RuntimeException(e);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StringToStringReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StringToStringReference.java b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StringToStringReference.java
new file mode 100644
index 0000000..6c872a6
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StringToStringReference.java
@@ -0,0 +1,51 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl.external.object;
+
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ValueToReferenceConversionException;
+import org.apache.taverna.reference.ValueToReferenceConverterSPI;
+
+/**
+ * Convert a String to a StringReference
+ * 
+ * @author Tom Oinn
+ */
+public class StringToStringReference implements ValueToReferenceConverterSPI {
+	/**
+	 * Can convert if the object is an instance of java.lang.String
+	 */
+	@Override
+	public boolean canConvert(Object o, ReferenceContext context) {
+		return o instanceof String;
+	}
+
+	/**
+	 * Return a new InlineStringReference wrapping the supplied String
+	 */
+	@Override
+	public ExternalReferenceSPI convert(Object o, ReferenceContext context)
+			throws ValueToReferenceConversionException {
+		InlineStringReference result = new InlineStringReference();
+		result.setContents((String) o);
+		return result;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/VMObjectReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/VMObjectReference.java b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/VMObjectReference.java
new file mode 100644
index 0000000..51e6669
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/VMObjectReference.java
@@ -0,0 +1,110 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl.external.object;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.nio.charset.Charset;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.taverna.reference.AbstractExternalReference;
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceContext;
+
+/**
+ * Implementation of ExternalReferenceSPI used to refer to objects in the local
+ * virtual machine.
+ * 
+ * @author Stian Soiland-Reyes
+ * @author Alex Nenadic
+ */
+public class VMObjectReference extends AbstractExternalReference implements
+		ExternalReferenceSPI, Serializable {
+	private static final long serialVersionUID = 6708284419760319684L;
+	private static final Charset UTF8 = Charset.forName("UTF-8");
+
+	/**
+	 * Mapping from objects to their UUIDs.
+	 */
+	private static Map<Object, UUID> objectToUUID = new HashMap<>();
+	/**
+	 * Mapping from UUIDs to objects.
+	 */
+	private static Map<UUID, Object> uuidToObject = new HashMap<>();
+
+	/**
+	 * Unique reference to the object.
+	 */
+	private String uuid;
+
+	@Override
+	public InputStream openStream(ReferenceContext context) {
+		return new ByteArrayInputStream(getObject().toString().getBytes(UTF8));
+	}
+
+	/**
+	 * Getter used by hibernate to retrieve the object uuid property.
+	 */
+	public String getUuid() {
+		return uuid;
+	}
+
+	/**
+	 * Setter used by hibernate to set the object uuid property.
+	 */
+	public void setUuid(String id) {
+		if (uuid != null)
+			throw new IllegalStateException("Can't set UUID of an object twice");
+		this.uuid = id;
+	}
+
+	public void setObject(Object object) {
+		if (uuid != null)
+			throw new IllegalStateException("Can't set UUID an object twice");
+		UUID knownUUID = objectToUUID.get(object);
+		if (knownUUID == null) {
+			// register object
+			knownUUID = UUID.randomUUID();
+			objectToUUID.put(object, knownUUID);
+			uuidToObject.put(knownUUID, object);
+		}
+		setUuid(knownUUID.toString());
+	}
+
+	public Object getObject() {
+		return uuidToObject.get(UUID.fromString(uuid));
+	}
+
+	@Override
+	public Long getApproximateSizeInBytes() {
+		// We do not know the object size
+		return new Long(-1);
+	}
+
+	@Override
+	public VMObjectReference clone() {
+		VMObjectReference result = new VMObjectReference();
+		result.setUuid(this.getUuid());
+		return result;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/package.html
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/package.html b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/package.html
new file mode 100644
index 0000000..b5b3b72
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/package.html
@@ -0,0 +1,4 @@
+<body>
+Support for representation of inlined objects as references. Replaces
+the old Literal support
+</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI b/taverna-reference-types/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI
deleted file mode 100644
index b90bb55..0000000
--- a/taverna-reference-types/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI
+++ /dev/null
@@ -1,3 +0,0 @@
-# Implementation classes of ExternalReferenceBuilderSPI go here, one per line
-net.sf.taverna.t2.reference.impl.external.object.InlineStringReferenceBuilder
-net.sf.taverna.t2.reference.impl.external.object.InlineByteArrayReferenceBuilder
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceSPI
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceSPI b/taverna-reference-types/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceSPI
deleted file mode 100644
index d4ad547..0000000
--- a/taverna-reference-types/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceSPI
+++ /dev/null
@@ -1,6 +0,0 @@
-# Implementation classes of ExternalReferenceSPI go here, one per line
-net.sf.taverna.t2.reference.impl.external.file.FileReference
-net.sf.taverna.t2.reference.impl.external.http.HttpReference
-net.sf.taverna.t2.reference.impl.external.object.InlineStringReference
-net.sf.taverna.t2.reference.impl.external.object.InlineByteArrayReference
-net.sf.taverna.t2.reference.impl.external.object.VMObjectReference
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI b/taverna-reference-types/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI
deleted file mode 100644
index a5547db..0000000
--- a/taverna-reference-types/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI
+++ /dev/null
@@ -1,3 +0,0 @@
-# Implementation classes of ExternalReferenceTranslatorSPI go here, one per line
-net.sf.taverna.t2.reference.impl.external.object.InlineByteToInlineStringTranslator
-net.sf.taverna.t2.reference.impl.external.object.InlineStringToInlineByteTranslator

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.StreamToValueConverterSPI
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.StreamToValueConverterSPI b/taverna-reference-types/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.StreamToValueConverterSPI
deleted file mode 100644
index a433461..0000000
--- a/taverna-reference-types/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.StreamToValueConverterSPI
+++ /dev/null
@@ -1,7 +0,0 @@
-# Implementation classes of StreamToValueConverterSPI go here, one per line
-net.sf.taverna.t2.reference.impl.external.object.StreamToStringConverter
-net.sf.taverna.t2.reference.impl.external.object.StreamToByteArrayConverter
-net.sf.taverna.t2.reference.impl.external.object.StreamToVMObjectReferenceConverter
-net.sf.taverna.t2.reference.impl.external.object.StreamToDoubleConverter
-net.sf.taverna.t2.reference.impl.external.object.StreamToBooleanConverter
-net.sf.taverna.t2.reference.impl.external.object.StreamToIntegerConverter

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ValueToReferenceConverterSPI
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ValueToReferenceConverterSPI b/taverna-reference-types/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ValueToReferenceConverterSPI
deleted file mode 100644
index e1c3593..0000000
--- a/taverna-reference-types/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ValueToReferenceConverterSPI
+++ /dev/null
@@ -1,8 +0,0 @@
-# Implementation classes of ValueToReferenceConverterSPI go here, one per line
-net.sf.taverna.t2.reference.impl.external.file.FileToFileReference
-net.sf.taverna.t2.reference.impl.external.http.UrlToHttpReference
-net.sf.taverna.t2.reference.impl.external.object.StringToStringReference
-net.sf.taverna.t2.reference.impl.external.object.ByteArrayToByteArrayReference
-net.sf.taverna.t2.reference.impl.external.object.NumberToStringReference
-net.sf.taverna.t2.reference.impl.external.object.CharacterToStringReference
-net.sf.taverna.t2.reference.impl.external.object.BooleanToStringReference

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceBuilderSPI
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceBuilderSPI b/taverna-reference-types/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceBuilderSPI
new file mode 100644
index 0000000..4f1b88e
--- /dev/null
+++ b/taverna-reference-types/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceBuilderSPI
@@ -0,0 +1,3 @@
+# Implementation classes of ExternalReferenceBuilderSPI go here, one per line
+org.apache.taverna.reference.impl.external.object.InlineStringReferenceBuilder
+org.apache.taverna.reference.impl.external.object.InlineByteArrayReferenceBuilder
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceSPI
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceSPI b/taverna-reference-types/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceSPI
new file mode 100644
index 0000000..f62c91d
--- /dev/null
+++ b/taverna-reference-types/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceSPI
@@ -0,0 +1,6 @@
+# Implementation classes of ExternalReferenceSPI go here, one per line
+org.apache.taverna.reference.impl.external.file.FileReference
+org.apache.taverna.reference.impl.external.http.HttpReference
+org.apache.taverna.reference.impl.external.object.InlineStringReference
+org.apache.taverna.reference.impl.external.object.InlineByteArrayReference
+org.apache.taverna.reference.impl.external.object.VMObjectReference
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceTranslatorSPI
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceTranslatorSPI b/taverna-reference-types/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceTranslatorSPI
new file mode 100644
index 0000000..7306bc0
--- /dev/null
+++ b/taverna-reference-types/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceTranslatorSPI
@@ -0,0 +1,3 @@
+# Implementation classes of ExternalReferenceTranslatorSPI go here, one per line
+org.apache.taverna.reference.impl.external.object.InlineByteToInlineStringTranslator
+org.apache.taverna.reference.impl.external.object.InlineStringToInlineByteTranslator

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/resources/META-INF/services/org.apache.taverna.reference.StreamToValueConverterSPI
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/resources/META-INF/services/org.apache.taverna.reference.StreamToValueConverterSPI b/taverna-reference-types/src/main/resources/META-INF/services/org.apache.taverna.reference.StreamToValueConverterSPI
new file mode 100644
index 0000000..cb4abe6
--- /dev/null
+++ b/taverna-reference-types/src/main/resources/META-INF/services/org.apache.taverna.reference.StreamToValueConverterSPI
@@ -0,0 +1,7 @@
+# Implementation classes of StreamToValueConverterSPI go here, one per line
+org.apache.taverna.reference.impl.external.object.StreamToStringConverter
+org.apache.taverna.reference.impl.external.object.StreamToByteArrayConverter
+org.apache.taverna.reference.impl.external.object.StreamToVMObjectReferenceConverter
+org.apache.taverna.reference.impl.external.object.StreamToDoubleConverter
+org.apache.taverna.reference.impl.external.object.StreamToBooleanConverter
+org.apache.taverna.reference.impl.external.object.StreamToIntegerConverter

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/resources/META-INF/services/org.apache.taverna.reference.ValueToReferenceConverterSPI
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/resources/META-INF/services/org.apache.taverna.reference.ValueToReferenceConverterSPI b/taverna-reference-types/src/main/resources/META-INF/services/org.apache.taverna.reference.ValueToReferenceConverterSPI
new file mode 100644
index 0000000..fcf18a0
--- /dev/null
+++ b/taverna-reference-types/src/main/resources/META-INF/services/org.apache.taverna.reference.ValueToReferenceConverterSPI
@@ -0,0 +1,8 @@
+# Implementation classes of ValueToReferenceConverterSPI go here, one per line
+org.apache.taverna.reference.impl.external.file.FileToFileReference
+org.apache.taverna.reference.impl.external.http.UrlToHttpReference
+org.apache.taverna.reference.impl.external.object.StringToStringReference
+org.apache.taverna.reference.impl.external.object.ByteArrayToByteArrayReference
+org.apache.taverna.reference.impl.external.object.NumberToStringReference
+org.apache.taverna.reference.impl.external.object.CharacterToStringReference
+org.apache.taverna.reference.impl.external.object.BooleanToStringReference

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/resources/META-INF/spring/reference-core-extensions-context-osgi.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/resources/META-INF/spring/reference-core-extensions-context-osgi.xml b/taverna-reference-types/src/main/resources/META-INF/spring/reference-core-extensions-context-osgi.xml
index aeed47f..c18021e 100644
--- a/taverna-reference-types/src/main/resources/META-INF/spring/reference-core-extensions-context-osgi.xml
+++ b/taverna-reference-types/src/main/resources/META-INF/spring/reference-core-extensions-context-osgi.xml
@@ -6,28 +6,28 @@
                                  http://www.springframework.org/schema/osgi 
                                  http://www.springframework.org/schema/osgi/spring-osgi.xsd" >
 
-	<service ref="inlineStringReferenceBuilder" interface="net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI" />
-	<service ref="inlineByteArrayReferenceBuilder" interface="net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI" />
+	<service ref="inlineStringReferenceBuilder" interface="org.apache.taverna.reference.ExternalReferenceBuilderSPI" />
+	<service ref="inlineByteArrayReferenceBuilder" interface="org.apahce.taverna.reference.ExternalReferenceBuilderSPI" />
 
-	<service ref="fileReference" interface="net.sf.taverna.t2.reference.ExternalReferenceSPI" />
-	<service ref="httpReference" interface="net.sf.taverna.t2.reference.ExternalReferenceSPI" />
-	<service ref="inlineStringReference" interface="net.sf.taverna.t2.reference.ExternalReferenceSPI" />
-	<service ref="inlineByteArrayReference" interface="net.sf.taverna.t2.reference.ExternalReferenceSPI" />
-	<service ref="vmObjectReference" interface="net.sf.taverna.t2.reference.ExternalReferenceSPI" />
+	<service ref="fileReference" interface="org.apache.taverna.reference.ExternalReferenceSPI" />
+	<service ref="httpReference" interface="org.apache.taverna.reference.ExternalReferenceSPI" />
+	<service ref="inlineStringReference" interface="org.apache.taverna.reference.ExternalReferenceSPI" />
+	<service ref="inlineByteArrayReference" interface="org.apache.taverna.reference.ExternalReferenceSPI" />
+	<service ref="vmObjectReference" interface="org.apache.taverna.reference.ExternalReferenceSPI" />
 		
-	<service ref="streamToStringConverter" interface="net.sf.taverna.t2.reference.StreamToValueConverterSPI" />
-	<service ref="streamToByteArrayConverter" interface="net.sf.taverna.t2.reference.StreamToValueConverterSPI" />
-	<service ref="streamToVMObjectReferenceConverter" interface="net.sf.taverna.t2.reference.StreamToValueConverterSPI" />
-	<service ref="streamToDoubleConverter" interface="net.sf.taverna.t2.reference.StreamToValueConverterSPI" />
-	<service ref="streamToBooleanConverter" interface="net.sf.taverna.t2.reference.StreamToValueConverterSPI" />
-	<service ref="streamToIntegerConverter" interface="net.sf.taverna.t2.reference.StreamToValueConverterSPI" />
+	<service ref="streamToStringConverter" interface="org.apache.taverna.reference.StreamToValueConverterSPI" />
+	<service ref="streamToByteArrayConverter" interface="org.apache.taverna.reference.StreamToValueConverterSPI" />
+	<service ref="streamToVMObjectReferenceConverter" interface="org.apache.taverna.reference.StreamToValueConverterSPI" />
+	<service ref="streamToDoubleConverter" interface="org.apache.taverna.reference.StreamToValueConverterSPI" />
+	<service ref="streamToBooleanConverter" interface="org.apache.taverna.reference.StreamToValueConverterSPI" />
+	<service ref="streamToIntegerConverter" interface="org.apache.taverna.reference.StreamToValueConverterSPI" />
 
-	<service ref="fileToFileReference" interface="net.sf.taverna.t2.reference.ValueToReferenceConverterSPI" />
-	<service ref="urlToHttpReference" interface="net.sf.taverna.t2.reference.ValueToReferenceConverterSPI" />
-	<service ref="stringToStringReference" interface="net.sf.taverna.t2.reference.ValueToReferenceConverterSPI" />
-	<service ref="byteArrayToByteArrayReference" interface="net.sf.taverna.t2.reference.ValueToReferenceConverterSPI" />
-	<service ref="numberToStringReference" interface="net.sf.taverna.t2.reference.ValueToReferenceConverterSPI" />
-	<service ref="characterToStringReference" interface="net.sf.taverna.t2.reference.ValueToReferenceConverterSPI" />
-	<service ref="booleanToStringReference" interface="net.sf.taverna.t2.reference.ValueToReferenceConverterSPI" />
+	<service ref="fileToFileReference" interface="org.apache.taverna.reference.ValueToReferenceConverterSPI" />
+	<service ref="urlToHttpReference" interface="org.apache.taverna.reference.ValueToReferenceConverterSPI" />
+	<service ref="stringToStringReference" interface="org.apache.taverna.reference.ValueToReferenceConverterSPI" />
+	<service ref="byteArrayToByteArrayReference" interface="org.apache.taverna.reference.ValueToReferenceConverterSPI" />
+	<service ref="numberToStringReference" interface="org.apache.taverna.reference.ValueToReferenceConverterSPI" />
+	<service ref="characterToStringReference" interface="org.apache.taverna.reference.ValueToReferenceConverterSPI" />
+	<service ref="booleanToStringReference" interface="org.apache.taverna.reference.ValueToReferenceConverterSPI" />
 
 </beans:beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/resources/META-INF/spring/reference-core-extensions-context.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/resources/META-INF/spring/reference-core-extensions-context.xml b/taverna-reference-types/src/main/resources/META-INF/spring/reference-core-extensions-context.xml
index 6b7a4cb..ee8702a 100644
--- a/taverna-reference-types/src/main/resources/META-INF/spring/reference-core-extensions-context.xml
+++ b/taverna-reference-types/src/main/resources/META-INF/spring/reference-core-extensions-context.xml
@@ -4,28 +4,28 @@
 	xsi:schemaLocation="http://www.springframework.org/schema/beans 
                            http://www.springframework.org/schema/beans/spring-beans.xsd">
                            
-	<bean id="inlineStringReferenceBuilder" class="net.sf.taverna.t2.reference.impl.external.object.InlineStringReferenceBuilder" />
-	<bean id="inlineByteArrayReferenceBuilder" class="net.sf.taverna.t2.reference.impl.external.object.InlineByteArrayReferenceBuilder" />
+	<bean id="inlineStringReferenceBuilder" class="org.apache.taverna.reference.impl.external.object.InlineStringReferenceBuilder" />
+	<bean id="inlineByteArrayReferenceBuilder" class="org.apache.taverna.reference.impl.external.object.InlineByteArrayReferenceBuilder" />
 
-	<bean id="fileReference" class="net.sf.taverna.t2.reference.impl.external.file.FileReference" />
-	<bean id="httpReference" class="net.sf.taverna.t2.reference.impl.external.http.HttpReference" />
-	<bean id="inlineStringReference" class="net.sf.taverna.t2.reference.impl.external.object.InlineStringReference" />
-	<bean id="inlineByteArrayReference" class="net.sf.taverna.t2.reference.impl.external.object.InlineByteArrayReference" />
-	<bean id="vmObjectReference" class="net.sf.taverna.t2.reference.impl.external.object.VMObjectReference" />
+	<bean id="fileReference" class="org.apache.taverna.reference.impl.external.file.FileReference" />
+	<bean id="httpReference" class="org.apache.taverna.reference.impl.external.http.HttpReference" />
+	<bean id="inlineStringReference" class="org.apache.taverna.reference.impl.external.object.InlineStringReference" />
+	<bean id="inlineByteArrayReference" class="org.apache.taverna.reference.impl.external.object.InlineByteArrayReference" />
+	<bean id="vmObjectReference" class="org.apache.taverna.reference.impl.external.object.VMObjectReference" />
 
-	<bean id="streamToStringConverter" class="net.sf.taverna.t2.reference.impl.external.object.StreamToStringConverter" />
-	<bean id="streamToByteArrayConverter" class="net.sf.taverna.t2.reference.impl.external.object.StreamToByteArrayConverter" />
-	<bean id="streamToVMObjectReferenceConverter" class="net.sf.taverna.t2.reference.impl.external.object.StreamToVMObjectReferenceConverter" />
-	<bean id="streamToDoubleConverter" class="net.sf.taverna.t2.reference.impl.external.object.StreamToDoubleConverter" />
-	<bean id="streamToBooleanConverter" class="net.sf.taverna.t2.reference.impl.external.object.StreamToBooleanConverter" />
-	<bean id="streamToIntegerConverter" class="net.sf.taverna.t2.reference.impl.external.object.StreamToIntegerConverter" />
+	<bean id="streamToStringConverter" class="org.apache.taverna.reference.impl.external.object.StreamToStringConverter" />
+	<bean id="streamToByteArrayConverter" class="org.apache.taverna.reference.impl.external.object.StreamToByteArrayConverter" />
+	<bean id="streamToVMObjectReferenceConverter" class="org.apache.taverna.reference.impl.external.object.StreamToVMObjectReferenceConverter" />
+	<bean id="streamToDoubleConverter" class="org.apache.taverna.reference.impl.external.object.StreamToDoubleConverter" />
+	<bean id="streamToBooleanConverter" class="org.apache.taverna.reference.impl.external.object.StreamToBooleanConverter" />
+	<bean id="streamToIntegerConverter" class="org.apache.taverna.reference.impl.external.object.StreamToIntegerConverter" />
 	
-	<bean id="fileToFileReference" class="net.sf.taverna.t2.reference.impl.external.file.FileToFileReference" />
-	<bean id="urlToHttpReference" class="net.sf.taverna.t2.reference.impl.external.http.UrlToHttpReference" />
-	<bean id="stringToStringReference" class="net.sf.taverna.t2.reference.impl.external.object.StringToStringReference" />
-	<bean id="byteArrayToByteArrayReference" class="net.sf.taverna.t2.reference.impl.external.object.ByteArrayToByteArrayReference" />
-	<bean id="numberToStringReference" class="net.sf.taverna.t2.reference.impl.external.object.NumberToStringReference" />
-	<bean id="characterToStringReference" class="net.sf.taverna.t2.reference.impl.external.object.CharacterToStringReference" />
-	<bean id="booleanToStringReference" class="net.sf.taverna.t2.reference.impl.external.object.BooleanToStringReference" />
+	<bean id="fileToFileReference" class="org.apache.taverna.reference.impl.external.file.FileToFileReference" />
+	<bean id="urlToHttpReference" class="org.apache.taverna.reference.impl.external.http.UrlToHttpReference" />
+	<bean id="stringToStringReference" class="org.apache.taverna.reference.impl.external.object.StringToStringReference" />
+	<bean id="byteArrayToByteArrayReference" class="org.apache.taverna.reference.impl.external.object.ByteArrayToByteArrayReference" />
+	<bean id="numberToStringReference" class="org.apache.taverna.reference.impl.external.object.NumberToStringReference" />
+	<bean id="characterToStringReference" class="org.apache.taverna.reference.impl.external.object.CharacterToStringReference" />
+	<bean id="booleanToStringReference" class="org.apache.taverna.reference.impl.external.object.BooleanToStringReference" />
 
 </beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/resources/net/sf/taverna/t2/reference/impl/external/file/FileReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/resources/net/sf/taverna/t2/reference/impl/external/file/FileReference.hbm.xml b/taverna-reference-types/src/main/resources/net/sf/taverna/t2/reference/impl/external/file/FileReference.hbm.xml
deleted file mode 100644
index 9a8fc05..0000000
--- a/taverna-reference-types/src/main/resources/net/sf/taverna/t2/reference/impl/external/file/FileReference.hbm.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
-                "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-                "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!-- Hibernate mapping for file reference bean -->
-<hibernate-mapping>
-	<joined-subclass
-		name="net.sf.taverna.t2.reference.impl.external.file.FileReference"
-		extends="net.sf.taverna.t2.reference.AbstractExternalReference">
-		<!-- Link to primary key from abstract superclass -->
-		<key column="bean_id" />
-		<!-- FileReference specific properties below here -->
-		<property name="filePath" type="string" />
-		<property name="dataNatureName" type="string"/>
-		<property name="charset" type="string" />
-	</joined-subclass>
-</hibernate-mapping>
-

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/resources/net/sf/taverna/t2/reference/impl/external/http/HttpReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/resources/net/sf/taverna/t2/reference/impl/external/http/HttpReference.hbm.xml b/taverna-reference-types/src/main/resources/net/sf/taverna/t2/reference/impl/external/http/HttpReference.hbm.xml
deleted file mode 100644
index 99af97c..0000000
--- a/taverna-reference-types/src/main/resources/net/sf/taverna/t2/reference/impl/external/http/HttpReference.hbm.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
-                "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-                "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!-- Hibernate mapping for http and https reference bean -->
-<hibernate-mapping>
-	<joined-subclass
-		name="net.sf.taverna.t2.reference.impl.external.http.HttpReference"
-		extends="net.sf.taverna.t2.reference.AbstractExternalReference">
-		<!-- Link to primary key from abstract superclass -->
-		<key column="bean_id" />
-		<!-- HttpReference specific properties below here -->
-		<property name="httpUrlString" type="string" />
-	</joined-subclass>
-</hibernate-mapping>
-

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/resources/net/sf/taverna/t2/reference/impl/external/object/InlineByteArrayReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/resources/net/sf/taverna/t2/reference/impl/external/object/InlineByteArrayReference.hbm.xml b/taverna-reference-types/src/main/resources/net/sf/taverna/t2/reference/impl/external/object/InlineByteArrayReference.hbm.xml
deleted file mode 100644
index 8f9ff44..0000000
--- a/taverna-reference-types/src/main/resources/net/sf/taverna/t2/reference/impl/external/object/InlineByteArrayReference.hbm.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
-                "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-                "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!-- Hibernate mapping for inline byte array reference bean -->
-<hibernate-mapping>
-	<joined-subclass
-		name="net.sf.taverna.t2.reference.impl.external.object.InlineByteArrayReference"
-		extends="net.sf.taverna.t2.reference.AbstractExternalReference">
-		<!-- Link to primary key from abstract superclass -->
-		<key column="bean_id" />
-		<!-- Reference specific props -->
-		<property name="contents" type="text" length="1000000000" />
-	</joined-subclass>
-</hibernate-mapping>
-

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/resources/net/sf/taverna/t2/reference/impl/external/object/InlineStringReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/resources/net/sf/taverna/t2/reference/impl/external/object/InlineStringReference.hbm.xml b/taverna-reference-types/src/main/resources/net/sf/taverna/t2/reference/impl/external/object/InlineStringReference.hbm.xml
deleted file mode 100644
index d81b227..0000000
--- a/taverna-reference-types/src/main/resources/net/sf/taverna/t2/reference/impl/external/object/InlineStringReference.hbm.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
-                "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-                "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!-- Hibernate mapping for inline string reference bean -->
-<hibernate-mapping>
-	<joined-subclass
-		name="net.sf.taverna.t2.reference.impl.external.object.InlineStringReference"
-		extends="net.sf.taverna.t2.reference.AbstractExternalReference">
-		<!-- Link to primary key from abstract superclass -->
-		<key column="bean_id" />
-		<!-- Reference specific props -->
-		<property name="contents" type="text" length="1000000000"/>
-	</joined-subclass>
-</hibernate-mapping>
-

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/resources/net/sf/taverna/t2/reference/impl/external/object/VMObjectReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/resources/net/sf/taverna/t2/reference/impl/external/object/VMObjectReference.hbm.xml b/taverna-reference-types/src/main/resources/net/sf/taverna/t2/reference/impl/external/object/VMObjectReference.hbm.xml
deleted file mode 100644
index 74c47a7..0000000
--- a/taverna-reference-types/src/main/resources/net/sf/taverna/t2/reference/impl/external/object/VMObjectReference.hbm.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
-                "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-                "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!-- Hibernate mapping for VM object reference bean -->
-<hibernate-mapping>
-	<joined-subclass
-		name="net.sf.taverna.t2.reference.impl.external.object.VMObjectReference"
-		extends="net.sf.taverna.t2.reference.AbstractExternalReference">
-		<!-- Link to primary key from abstract superclass -->
-		<key column="bean_id" />
-		<!-- VMObjectReference specific properties below here -->
-		<property name="uuid" type="string" />
-	</joined-subclass>
-</hibernate-mapping>
-

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/resources/org/apache/taverna/reference/impl/external/file/FileReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/resources/org/apache/taverna/reference/impl/external/file/FileReference.hbm.xml b/taverna-reference-types/src/main/resources/org/apache/taverna/reference/impl/external/file/FileReference.hbm.xml
new file mode 100644
index 0000000..3a2f3e6
--- /dev/null
+++ b/taverna-reference-types/src/main/resources/org/apache/taverna/reference/impl/external/file/FileReference.hbm.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Hibernate mapping for file reference bean -->
+<hibernate-mapping>
+  <joined-subclass extends="org.apache.taverna.reference.AbstractExternalReference" name="org.apache.taverna.reference.impl.external.file.FileReference">
+    <!-- Link to primary key from abstract superclass -->
+    <key column="bean_id"/>
+    <!-- FileReference specific properties below here -->
+    <property name="filePath" type="string"/>
+    <property name="dataNatureName" type="string"/>
+    <property name="charset" type="string"/>
+  </joined-subclass>
+</hibernate-mapping>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/resources/org/apache/taverna/reference/impl/external/http/HttpReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/resources/org/apache/taverna/reference/impl/external/http/HttpReference.hbm.xml b/taverna-reference-types/src/main/resources/org/apache/taverna/reference/impl/external/http/HttpReference.hbm.xml
new file mode 100644
index 0000000..52608a0
--- /dev/null
+++ b/taverna-reference-types/src/main/resources/org/apache/taverna/reference/impl/external/http/HttpReference.hbm.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Hibernate mapping for http and https reference bean -->
+<hibernate-mapping>
+  <joined-subclass extends="org.apache.taverna.reference.AbstractExternalReference" name="org.apache.taverna.reference.impl.external.http.HttpReference">
+    <!-- Link to primary key from abstract superclass -->
+    <key column="bean_id"/>
+    <!-- HttpReference specific properties below here -->
+    <property name="httpUrlString" type="string"/>
+  </joined-subclass>
+</hibernate-mapping>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/resources/org/apache/taverna/reference/impl/external/object/InlineByteArrayReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/resources/org/apache/taverna/reference/impl/external/object/InlineByteArrayReference.hbm.xml b/taverna-reference-types/src/main/resources/org/apache/taverna/reference/impl/external/object/InlineByteArrayReference.hbm.xml
new file mode 100644
index 0000000..e8b9810
--- /dev/null
+++ b/taverna-reference-types/src/main/resources/org/apache/taverna/reference/impl/external/object/InlineByteArrayReference.hbm.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Hibernate mapping for inline byte array reference bean -->
+<hibernate-mapping>
+  <joined-subclass extends="org.apache.taverna.t2.reference.AbstractExternalReference" name="org.apache.taverna.reference.impl.external.object.InlineByteArrayReference">
+    <!-- Link to primary key from abstract superclass -->
+    <key column="bean_id"/>
+    <!-- Reference specific props -->
+    <property length="1000000000" name="contents" type="text"/>
+  </joined-subclass>
+</hibernate-mapping>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/resources/org/apache/taverna/reference/impl/external/object/InlineStringReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/resources/org/apache/taverna/reference/impl/external/object/InlineStringReference.hbm.xml b/taverna-reference-types/src/main/resources/org/apache/taverna/reference/impl/external/object/InlineStringReference.hbm.xml
new file mode 100644
index 0000000..492acd6
--- /dev/null
+++ b/taverna-reference-types/src/main/resources/org/apache/taverna/reference/impl/external/object/InlineStringReference.hbm.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Hibernate mapping for inline string reference bean -->
+<hibernate-mapping>
+  <joined-subclass extends="org.apache.taverna.reference.AbstractExternalReference" name="org.apache.taverna.reference.impl.external.object.InlineStringReference">
+    <!-- Link to primary key from abstract superclass -->
+    <key column="bean_id"/>
+    <!-- Reference specific props -->
+    <property length="1000000000" name="contents" type="text"/>
+  </joined-subclass>
+</hibernate-mapping>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/resources/org/apache/taverna/reference/impl/external/object/VMObjectReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/resources/org/apache/taverna/reference/impl/external/object/VMObjectReference.hbm.xml b/taverna-reference-types/src/main/resources/org/apache/taverna/reference/impl/external/object/VMObjectReference.hbm.xml
new file mode 100644
index 0000000..0343a33
--- /dev/null
+++ b/taverna-reference-types/src/main/resources/org/apache/taverna/reference/impl/external/object/VMObjectReference.hbm.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Hibernate mapping for VM object reference bean -->
+<hibernate-mapping>
+  <joined-subclass extends="org.apache.taverna.reference.AbstractExternalReference" name="org.apache.taverna.reference.impl.external.object.VMObjectReference">
+    <!-- Link to primary key from abstract superclass -->
+    <key column="bean_id"/>
+    <!-- VMObjectReference specific properties below here -->
+    <property name="uuid" type="string"/>
+  </joined-subclass>
+</hibernate-mapping>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/test/java/net/sf/taverna/t2/reference/impl/external/object/ByteArrayToStringTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/test/java/net/sf/taverna/t2/reference/impl/external/object/ByteArrayToStringTest.java b/taverna-reference-types/src/test/java/net/sf/taverna/t2/reference/impl/external/object/ByteArrayToStringTest.java
deleted file mode 100644
index 5afa878..0000000
--- a/taverna-reference-types/src/test/java/net/sf/taverna/t2/reference/impl/external/object/ByteArrayToStringTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package net.sf.taverna.t2.reference.impl.external.object;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.nio.charset.Charset;
-import java.util.Set;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferenceSet;
-import net.sf.taverna.t2.reference.impl.EmptyReferenceContext;
-import net.sf.taverna.t2.reference.impl.TranslationPath;
-import net.sf.taverna.t2referencetest.DummyReferenceSet;
-
-import org.junit.Test;
-
-public class ByteArrayToStringTest {
-
-	protected TranslationPath path  = new TranslationPath();
-	private final Charset UTF8 = Charset.forName("UTF-8");
-	// cleverly including the supplementary character U+10400
-	// which in UTF8 should be \xf0\x90\x90\x80
-	private final String string = "Ferronni\u00e8re \ud801\udc00";	
-	
-	
-	@Test
-	public void translateStringToByteTranslator() throws Exception {
-		ReferenceContext context = new EmptyReferenceContext();
-		InlineStringReference inlineString = new InlineStringReference();
-		inlineString.setContents(string);
-		path.setSourceReference(inlineString);
-		ReferenceSet rs = new DummyReferenceSet(inlineString);		
-		path.getTranslators().add(new InlineStringToInlineByteTranslator());
-		
-		Set<ExternalReferenceSPI> set = path.doTranslation(rs, context);		
-		assertEquals(1, set.size());
-		InlineByteArrayReference byteRef = (InlineByteArrayReference) set.iterator().next();
-		
-		assertEquals(string, new String(byteRef.getValue(), UTF8));		
-	}
-
-	@Test
-	public void translateByteToStringTranslator() throws Exception {
-		ReferenceContext context = new EmptyReferenceContext();
-		InlineByteArrayReference inlineByte = new InlineByteArrayReference();
-		inlineByte.setValue(string.getBytes(UTF8));
-		path.setSourceReference(inlineByte);
-		ReferenceSet rs = new DummyReferenceSet(inlineByte);		
-		path.getTranslators().add(new InlineByteToInlineStringTranslator());		
-		
-		Set<ExternalReferenceSPI> set = path.doTranslation(rs, context);		
-		assertEquals(1, set.size());
-		InlineStringReference inlineString = (InlineStringReference) set.iterator().next();
-		assertEquals(string,  inlineString.getContents());	
-	}
-
-	
-	@Test
-	public void translateStringToByteArrayBuilder() throws Exception {
-		ReferenceContext context = new EmptyReferenceContext();
-		InlineStringReference inlineString = new InlineStringReference();
-		inlineString.setContents(string);
-		path.setSourceReference(inlineString);
-		ReferenceSet rs = new DummyReferenceSet(inlineString);
-		path.setInitialBuilder(new InlineByteArrayReferenceBuilder());
-		Set<ExternalReferenceSPI> set = path.doTranslation(rs, context);		
-		assertEquals(1, set.size());
-		InlineByteArrayReference byteRef = (InlineByteArrayReference) set.iterator().next();
-		
-		assertEquals(string, new String(byteRef.getValue(), UTF8));		
-	}
-
-	@Test
-	public void translateByteArrayToStringBuilder() throws Exception {
-		ReferenceContext context = new EmptyReferenceContext();
-		InlineByteArrayReference inlineByte = new InlineByteArrayReference();
-		inlineByte.setValue(string.getBytes(UTF8));
-		path.setSourceReference(inlineByte);
-		ReferenceSet rs = new DummyReferenceSet(inlineByte);
-		path.setInitialBuilder(new InlineStringReferenceBuilder());
-		Set<ExternalReferenceSPI> set = path.doTranslation(rs, context);		
-		assertEquals(1, set.size());
-		assertTrue(set.iterator().next() instanceof InlineStringReference);
-		InlineStringReference inlineString = (InlineStringReference) set.iterator().next();
-		assertEquals(string,  inlineString.getContents());
-		//System.out.println(string);
-	}
-	
-	
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/test/java/org/apache/taverna/reference/impl/external/object/ByteArrayToStringTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/test/java/org/apache/taverna/reference/impl/external/object/ByteArrayToStringTest.java b/taverna-reference-types/src/test/java/org/apache/taverna/reference/impl/external/object/ByteArrayToStringTest.java
new file mode 100644
index 0000000..6325156
--- /dev/null
+++ b/taverna-reference-types/src/test/java/org/apache/taverna/reference/impl/external/object/ByteArrayToStringTest.java
@@ -0,0 +1,110 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl.external.object;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.nio.charset.Charset;
+import java.util.Set;
+
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferenceSet;
+import org.apache.taverna.reference.impl.EmptyReferenceContext;
+import org.apache.taverna.reference.impl.TranslationPath;
+import org.apache.taverna.t2referencetest.DummyReferenceSet;
+
+import org.junit.Test;
+
+public class ByteArrayToStringTest {
+
+	protected TranslationPath path  = new TranslationPath();
+	private final Charset UTF8 = Charset.forName("UTF-8");
+	// cleverly including the supplementary character U+10400
+	// which in UTF8 should be \xf0\x90\x90\x80
+	private final String string = "Ferronni\u00e8re \ud801\udc00";	
+	
+	
+	@Test
+	public void translateStringToByteTranslator() throws Exception {
+		ReferenceContext context = new EmptyReferenceContext();
+		InlineStringReference inlineString = new InlineStringReference();
+		inlineString.setContents(string);
+		path.setSourceReference(inlineString);
+		ReferenceSet rs = new DummyReferenceSet(inlineString);		
+		path.getTranslators().add(new InlineStringToInlineByteTranslator());
+		
+		Set<ExternalReferenceSPI> set = path.doTranslation(rs, context);		
+		assertEquals(1, set.size());
+		InlineByteArrayReference byteRef = (InlineByteArrayReference) set.iterator().next();
+		
+		assertEquals(string, new String(byteRef.getValue(), UTF8));		
+	}
+
+	@Test
+	public void translateByteToStringTranslator() throws Exception {
+		ReferenceContext context = new EmptyReferenceContext();
+		InlineByteArrayReference inlineByte = new InlineByteArrayReference();
+		inlineByte.setValue(string.getBytes(UTF8));
+		path.setSourceReference(inlineByte);
+		ReferenceSet rs = new DummyReferenceSet(inlineByte);		
+		path.getTranslators().add(new InlineByteToInlineStringTranslator());		
+		
+		Set<ExternalReferenceSPI> set = path.doTranslation(rs, context);		
+		assertEquals(1, set.size());
+		InlineStringReference inlineString = (InlineStringReference) set.iterator().next();
+		assertEquals(string,  inlineString.getContents());	
+	}
+
+	
+	@Test
+	public void translateStringToByteArrayBuilder() throws Exception {
+		ReferenceContext context = new EmptyReferenceContext();
+		InlineStringReference inlineString = new InlineStringReference();
+		inlineString.setContents(string);
+		path.setSourceReference(inlineString);
+		ReferenceSet rs = new DummyReferenceSet(inlineString);
+		path.setInitialBuilder(new InlineByteArrayReferenceBuilder());
+		Set<ExternalReferenceSPI> set = path.doTranslation(rs, context);		
+		assertEquals(1, set.size());
+		InlineByteArrayReference byteRef = (InlineByteArrayReference) set.iterator().next();
+		
+		assertEquals(string, new String(byteRef.getValue(), UTF8));		
+	}
+
+	@Test
+	public void translateByteArrayToStringBuilder() throws Exception {
+		ReferenceContext context = new EmptyReferenceContext();
+		InlineByteArrayReference inlineByte = new InlineByteArrayReference();
+		inlineByte.setValue(string.getBytes(UTF8));
+		path.setSourceReference(inlineByte);
+		ReferenceSet rs = new DummyReferenceSet(inlineByte);
+		path.setInitialBuilder(new InlineStringReferenceBuilder());
+		Set<ExternalReferenceSPI> set = path.doTranslation(rs, context);		
+		assertEquals(1, set.size());
+		assertTrue(set.iterator().next() instanceof InlineStringReference);
+		InlineStringReference inlineString = (InlineStringReference) set.iterator().next();
+		assertEquals(string,  inlineString.getContents());
+		//System.out.println(string);
+	}
+	
+	
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/main/java/org/apache/taverna/platform/report/ActivityReport.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/main/java/org/apache/taverna/platform/report/ActivityReport.java b/taverna-report-api/src/main/java/org/apache/taverna/platform/report/ActivityReport.java
new file mode 100644
index 0000000..e01669d
--- /dev/null
+++ b/taverna-report-api/src/main/java/org/apache/taverna/platform/report/ActivityReport.java
@@ -0,0 +1,48 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.report;
+
+import org.apache.taverna.scufl2.api.activity.Activity;
+
+/**
+ * Report about the {@link State} of an {@link Activity} invocation.
+ *
+ * @author David Withers
+ */
+public class ActivityReport extends StatusReport<Activity, ProcessorReport> {
+	private WorkflowReport nestedWorkflowReport;
+
+	/**
+	 * Constructs a new <code>ActivityReport</code>.
+	 *
+	 * @param activity
+	 */
+	public ActivityReport(Activity activity) {
+		super(activity);
+	}
+
+	public WorkflowReport getNestedWorkflowReport() {
+		return nestedWorkflowReport;
+	}
+
+	public void setNestedWorkflowReport(WorkflowReport nestedWorkflowReport) {
+		this.nestedWorkflowReport = nestedWorkflowReport;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/main/java/org/apache/taverna/platform/report/Invocation.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/main/java/org/apache/taverna/platform/report/Invocation.java b/taverna-report-api/src/main/java/org/apache/taverna/platform/report/Invocation.java
new file mode 100644
index 0000000..4bbef53
--- /dev/null
+++ b/taverna-report-api/src/main/java/org/apache/taverna/platform/report/Invocation.java
@@ -0,0 +1,305 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.report;
+
+import java.nio.file.Path;
+import java.util.Date;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import org.apache.taverna.scufl2.api.port.Port;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+/**
+ * A single invocation of a workflow, processor or activity.
+ *
+ * @author David Withers
+ */
+@JsonPropertyOrder({"id","parent", "name",  "index", "state", "startedDate", "completedDate", "inputs", "outputs"})
+public class Invocation implements Comparable<Invocation> {
+	private final String name;
+	private final int[] index;
+	private final Invocation parent;
+	private State state;
+	private Date startedDate, completedDate;
+	private final SortedSet<Invocation> invocations;
+	private final StatusReport<?, ?> report;
+	private SortedMap<String, Path> inputs, outputs;
+
+	/**
+     * Internal constructor for comparison use.
+     *
+     * Only use with {@link #compareTo(Invocation)} use when looking
+     * up from {@link StatusReport#getInvocation(String)}. All fields except
+     * {@link #getName()} are <code>null</code>.
+     *
+     * @param name The name of the invocation to compare with
+     **/
+	Invocation(String name) {
+	    this.name = name;
+	    this.report = null;
+	    this.parent = null;
+	    this.invocations = null;
+	    this.index = null;
+	}
+
+	public Invocation(String name, Invocation parent, StatusReport<?, ?> report) {
+		this(name, new int[0], parent, report);
+	}
+
+	public Invocation(String name, int[] index, Invocation parent, StatusReport<?, ?> report) {
+		this.name = name;
+		this.index = index;
+		this.parent = parent;
+		this.report = report;
+
+		invocations = new TreeSet<>();
+
+		inputs = new TreeMap<>();
+		for (Port port : report.getSubject().getInputPorts())
+			inputs.put(port.getName(), null);
+
+		outputs = new TreeMap<>();
+		for (Port port : report.getSubject().getOutputPorts())
+			outputs.put(port.getName(), null);
+
+		setStartedDate(new Date());
+
+		if (parent != null)
+			parent.getInvocations().add(this);
+		report.addInvocation(this);
+	}
+
+	/**
+	 * Returns the name for this invocation.
+	 *
+	 * @return the name for this invocation
+	 */
+	@JsonProperty("name")
+	public String getName() {
+		return name;
+	}
+
+	public int[] getIndex() {
+		return index;
+	}
+
+	/**
+	 * Returns the  identifier for this invocation by prepending the identifier of the parent
+	 * invocation.
+	 *
+	 * @return the identifier for this invocation
+	 */
+	@JsonProperty("id")
+	public String getId() {
+		if (parent != null) {
+			String parentId = parent.getId();
+			if (parentId != null && !parentId.isEmpty())
+				return parent.getId() + "/" + name;
+		}
+		return name;
+	}
+
+	@JsonIgnore
+	public StatusReport<?, ?> getReport() {
+		return report;
+	}
+
+	/**
+	 * Returns the parent invocation.
+	 * <p>
+	 * Returns <code>null</code> if there is no parent invocation.
+	 *
+	 * @return the parent invocation
+	 */
+	@JsonIgnore
+	public Invocation getParent() {
+		return parent;
+	}
+
+	@JsonProperty("parent")
+	public String getParentId() {
+	    if (parent == null)
+	        return null;
+	    return parent.getId();
+	}
+
+	/**
+	 * Returns the child invocations.
+	 * <p>
+	 * Returns and empty set if there are no child invocations.
+	 *
+	 * @return the child invocations
+	 */
+	@JsonIgnore
+	public SortedSet<Invocation> getInvocations() {
+		return invocations;
+	}
+
+	/**
+	 * Returns a map of input port names to values.
+	 * <p>
+	 * Returns an empty map if there are no input ports. If there is no value for an input port the
+	 * map will contain a <code>null</code> value.
+	 *
+	 * @return a map of input port names to values
+	 */
+	public SortedMap<String, Path> getInputs() {
+		return inputs;
+	}
+
+	/**
+	 * Sets the values of input ports.
+	 *
+	 * @param inputs
+	 *            the values of input ports
+	 */
+	public void setInputs(Map<String, Path> inputs) {
+		this.inputs.putAll(inputs);
+	}
+
+	/**
+	 * Sets the value of an input port.
+	 *
+	 * @param port the port name
+	 * @param value the port value
+	 */
+	public void setInput(String port, Path value) {
+		inputs.put(port, value);
+	}
+
+	/**
+	 * Returns a map of output port names to values.
+	 * <p>
+	 * Returns an empty map if there are no output ports. If there is no value for an output port
+	 * the map will contain a <code>null</code> value.
+	 *
+	 * @return a map of input port names to values
+	 */
+	public SortedMap<String, Path> getOutputs() {
+		return outputs;
+	}
+
+	/**
+	 * Sets the values of input ports.
+	 *
+	 * @param inputs
+	 *            the values of input ports
+	 */
+	public void setOutputs(Map<String, Path> outputs) {
+		this.outputs.putAll(outputs);
+	}
+
+	/**
+	 * Sets the value of an output port.
+	 *
+	 * @param port the port name
+	 * @param value the port value
+	 */
+	public void setOutput(String port, Path value) {
+		outputs.put(port, value);
+	}
+
+	/**
+	 * Returns the current {@link State} of the invocation.
+	 * <p>
+	 * An invocation state can be RUNNING or COMPLETED.
+	 *
+	 * @return the current <code>State</code>
+	 */
+	public State getState() {
+		return state;
+	}
+
+	/**
+	 * Returns the date that the status changed to RUNNING.
+	 * <p>
+	 * If the status has never been RUNNING <code>null</code> is returned.
+	 *
+	 * @return the date that the status changed to started
+	 */
+	public Date getStartedDate() {
+		return startedDate;
+	}
+
+	/**
+	 * Sets the date that the status changed to RUNNING.
+	 *
+	 * @param startedDate
+	 *            the date that the status changed to RUNNING
+	 */
+	public void setStartedDate(Date startedDate) {
+		this.startedDate = startedDate;
+		state = State.RUNNING;
+	}
+
+	/**
+	 * Returns the date that the status changed to COMPLETED.
+	 * <p>
+	 * If the status never been COMPLETED <code>null</code> is returned.
+	 *
+	 * @return the date that the status changed to COMPLETED
+	 */
+	public Date getCompletedDate() {
+		return completedDate;
+	}
+
+	/**
+	 * Sets the date that the status changed to COMPLETED.
+	 *
+	 * @param completedDate
+	 *            the date that the status changed to COMPLETED
+	 */
+	public void setCompletedDate(Date completedDate) {
+		this.completedDate = completedDate;
+		state = State.COMPLETED;
+	}
+
+	@Override
+	public String toString() {
+		return "Invocation " + indexToString(index);
+	}
+
+	@Override
+	public int compareTo(Invocation o) {
+		String id = getId();
+		String otherId = o.getId();
+		if (id.length() == otherId.length())
+			return id.compareTo(otherId);
+		// Make "invoc5" be sorted before "invoc49"
+		return id.length() - otherId.length();
+	}
+
+	private String indexToString(int[] index) {
+		StringBuilder indexString = new StringBuilder();
+		String sep = "";
+		for (int idx : index) {
+			indexString.append(sep).append(idx + 1);
+			sep = ":";
+		}
+		return indexString.toString();
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/main/java/org/apache/taverna/platform/report/ProcessorReport.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/main/java/org/apache/taverna/platform/report/ProcessorReport.java b/taverna-report-api/src/main/java/org/apache/taverna/platform/report/ProcessorReport.java
new file mode 100644
index 0000000..fe54774
--- /dev/null
+++ b/taverna-report-api/src/main/java/org/apache/taverna/platform/report/ProcessorReport.java
@@ -0,0 +1,163 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.report;
+
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.apache.taverna.scufl2.api.core.Processor;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+/**
+ * Report about the {@link State} of a {@link Processor} invocation.
+ *
+ * @author David Withers
+ * @author Stian Soiland-Reyes
+ */
+@JsonPropertyOrder({ "subject", "parent", "state", "createdDate",
+        "startedDate", "pausedDate", "pausedDates", "resumedDate",
+        "resumedDates", "cancelledDate", "failedDate", "completedDate",
+        "jobsQueued", "jobsStarted", "jobsCompleted",
+        "jobsCompletedWithErrors", "invocations", "activityReports"})
+public class ProcessorReport extends StatusReport<Processor, WorkflowReport> {
+	private Set<ActivityReport> activityReports = new LinkedHashSet<>();
+	private int jobsCompleted;
+    private int jobsCompletedWithErrors;
+    private int jobsQueued;
+    private int jobsStarted;
+    private SortedMap<String, Object> properties = new TreeMap<>();
+
+    /**
+	 * Constructs a new <code>ProcessorReport</code>.
+	 *
+	 * @param processor The processor to report on
+	 */
+	public ProcessorReport(Processor processor) {
+		super(processor);
+	}
+
+    public void addActivityReport(ActivityReport activityReport) {
+		activityReports.add(activityReport);
+	}
+
+    public Set<ActivityReport> getActivityReports() {
+		return activityReports;
+	}
+
+    /**
+	 * Returns the number of jobs that the processor has completed.
+	 *
+	 * @return the number of jobs that the processor has completed
+	 */
+	public int getJobsCompleted() {
+	    return jobsCompleted;
+	}
+
+	/**
+	 * Returns the number of jobs that completed with an error.
+	 *
+	 * @return the number of jobs that completed with an error
+	 */
+	public int getJobsCompletedWithErrors() {
+	    return jobsCompletedWithErrors;
+	}
+
+	/**
+	 * Returns the number of jobs queued by the processor.
+	 *
+	 * @return the number of jobs queued by the processor
+	 */
+	public int getJobsQueued() {
+        return jobsQueued;
+    }
+
+	/**
+	 * Returns the number of jobs that the processor has started processing.
+	 *
+	 * @return the number of jobs that the processor has started processing
+	 */
+	public int getJobsStarted() {
+	    return jobsStarted;
+	}
+
+	public Object getProperty(String key) {
+		return properties.get(key);
+	}
+
+	@JsonIgnore 
+	public Set<String> getPropertyKeys() {
+		return new HashSet<>(properties.keySet());
+	}
+
+	/**
+     * Set the number of completed jobs.
+     * 
+     * @param jobsCompleted the number of jobs that the processor has completed.
+     */
+    public void setJobsCompleted(int jobsCompleted) {
+        this.jobsCompleted = jobsCompleted;
+    }
+
+	/**
+     * Set the number of jobs that have completed, but with errors.
+     * 
+     * @param jobsCompletedWithErrors the number of jobs that completed with errors
+     */
+    public void setJobsCompletedWithErrors(int jobsCompletedWithErrors) {
+        this.jobsCompletedWithErrors = jobsCompletedWithErrors;
+    }
+
+	/**
+     * Set the number of queued jobs.
+     * 
+     * @param jobsQueued the number of jobs queued by the processor
+     */
+    public void setJobsQueued(int jobsQueued) {
+        this.jobsQueued = jobsQueued;
+    }
+
+	/**
+     * Set the number of started jobs.
+     * 
+     * @param jobsStarted the number of jobs that the processor has started processing
+     */
+    public void setJobsStarted(int jobsStarted) {
+        this.jobsStarted = jobsStarted;
+    }
+
+    /**
+     * Set an additional property
+     * 
+     * @param key
+     * @param value
+     */
+	public void setProperty(String key, Object value) {
+		synchronized (properties) {
+			// if (properties.containsKey(key)) {
+			properties.put(key, value);
+			// }
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/main/java/org/apache/taverna/platform/report/ReportListener.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/main/java/org/apache/taverna/platform/report/ReportListener.java b/taverna-report-api/src/main/java/org/apache/taverna/platform/report/ReportListener.java
new file mode 100644
index 0000000..e3a0c6e
--- /dev/null
+++ b/taverna-report-api/src/main/java/org/apache/taverna/platform/report/ReportListener.java
@@ -0,0 +1,31 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.report;
+
+import java.nio.file.Path;
+
+/**
+ * @author David Withers
+ */
+public interface ReportListener {
+	void outputAdded(Path path, String portName, int[] index);
+
+	void stateChanged(State oldState, State newState);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/main/java/org/apache/taverna/platform/report/State.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/main/java/org/apache/taverna/platform/report/State.java b/taverna-report-api/src/main/java/org/apache/taverna/platform/report/State.java
new file mode 100755
index 0000000..b42b722
--- /dev/null
+++ b/taverna-report-api/src/main/java/org/apache/taverna/platform/report/State.java
@@ -0,0 +1,29 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.report;
+
+/**
+ * Valid states for status reports.
+ *
+ * @author David Withers
+ */
+public enum State {
+	CREATED, RUNNING, COMPLETED, PAUSED, CANCELLED, FAILED
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-report-api/src/main/java/org/apache/taverna/platform/report/StatusReport.java
----------------------------------------------------------------------
diff --git a/taverna-report-api/src/main/java/org/apache/taverna/platform/report/StatusReport.java b/taverna-report-api/src/main/java/org/apache/taverna/platform/report/StatusReport.java
new file mode 100644
index 0000000..1ea47d5
--- /dev/null
+++ b/taverna-report-api/src/main/java/org/apache/taverna/platform/report/StatusReport.java
@@ -0,0 +1,372 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.platform.report;
+
+import java.net.URI;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.NavigableSet;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.apache.taverna.scufl2.api.common.Ported;
+import org.apache.taverna.scufl2.api.common.URITools;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+/**
+ * Report about the {@link State} of a workflow component.
+ *
+ * @author David Withers
+ * @param <SUBJECT>
+ *            the WorkflowBean that the report is about
+ * @param <PARENT>
+ *            the parent report type
+ */
+
+@JsonPropertyOrder({ "subject", "parent", "state", "createdDate", "startedDate", "pausedDate",
+    "pausedDates", "resumedDate", "resumedDates", "cancelledDate", "failedDate", "completedDate"})
+public class StatusReport<SUBJECT extends Ported, PARENT extends StatusReport<?, ?>> {
+	private final SUBJECT subject;
+	private PARENT parentReport;
+	private State state;
+	private NavigableSet<Invocation> invocations = new TreeSet<>();
+	private Date createdDate, startedDate, pausedDate, resumedDate, cancelledDate, completedDate,
+			failedDate;
+	private final List<Date> pausedDates = new ArrayList<>(),
+			resumedDates = new ArrayList<>();
+	private List<ReportListener> reportListeners = new ArrayList<>();
+
+	/**
+	 * Constructs a new <code>StatusReport</code> for the subject and sets the created date to the
+	 * current date.
+	 *
+	 * @param subject
+	 *            the subject of the report
+	 */
+	public StatusReport(SUBJECT subject) {
+		this.subject = subject;
+		setCreatedDate(new Date());
+	}
+
+	/**
+	 * Returns the subject of this report.
+	 *
+	 * @return the subject of this report
+	 */
+	@JsonIgnore
+	public SUBJECT getSubject() {
+		return subject;
+	}
+
+	@JsonProperty("subject")
+	public URI getSubjectURI() {
+		return new URITools().uriForBean(subject);
+	}
+
+	/**
+	 * Returns the parent report.
+	 * <p>
+	 * Returns null if this report has no parent.
+	 *
+	 * @return the parent report
+	 */
+	@JsonIgnore
+	public PARENT getParentReport() {
+		return parentReport;
+	}
+
+	/**
+	 * Sets the parent report.
+	 * <p>
+	 * Can be null if this report has no parent.
+	 *
+	 * @param workflowReport
+	 *            the parent report
+	 */
+	public void setParentReport(PARENT parentReport) {
+		this.parentReport = parentReport;
+	}
+
+	/**
+	 * Returns the current {@link State}.
+	 * <p>
+	 * A state can be CREATED, RUNNING, COMPLETED, PAUSED, CANCELLED or FAILED.
+	 *
+	 * @return the current <code>State</code>
+	 */
+	public State getState() {
+		return state;
+	}
+
+	public void setState(State state) {
+		synchronized (reportListeners) {
+			if (this.state != state) {
+				State oldState = this.state;
+				this.state = state;
+				for (ReportListener reportListener : reportListeners)
+					reportListener.stateChanged(oldState, state);
+			}
+		}
+	}
+
+	/**
+	 * Returns the date that the status was set to CREATED.
+	 *
+	 * @return the the date that the status was set to CREATED
+	 */
+	public Date getCreatedDate() {
+		return createdDate;
+	}
+
+	/**
+	 * Sets the date that the status was set to CREATED.
+	 *
+	 * @param createdDate
+	 *            the date that the status was set to CREATED
+	 */
+	public void setCreatedDate(Date createdDate) {
+		this.createdDate = createdDate;
+		setState(State.CREATED);
+	}
+
+	/**
+	 * Returns the date that the status changed to RUNNING.
+	 * <p>
+	 * If the status has never been RUNNING <code>null</code> is returned.
+	 *
+	 * @return the date that the status changed to started
+	 */
+	public Date getStartedDate() {
+		return startedDate;
+	}
+
+	/**
+	 * Sets the date that the status changed to RUNNING.
+	 *
+	 * @param startedDate
+	 *            the date that the status changed to RUNNING
+	 */
+	public void setStartedDate(Date startedDate) {
+		if (this.startedDate == null)
+			this.startedDate = startedDate;
+		setState(State.RUNNING);
+	}
+
+	/**
+	 * Returns the date that the status last changed to PAUSED.
+	 * <p>
+	 * If the status has never been PAUSED <code>null</code> is returned.
+	 *
+	 * @return the date that the status last changed to PAUSED
+	 */
+	public Date getPausedDate() {
+		return pausedDate;
+	}
+
+	/**
+	 * Sets the date that the status last changed to PAUSED.
+	 *
+	 * @param pausedDate
+	 *            the date that the status last changed to PAUSED
+	 */
+	public void setPausedDate(Date pausedDate) {
+		this.pausedDate = pausedDate;
+		pausedDates.add(pausedDate);
+		setState(State.PAUSED);
+	}
+
+	/**
+	 * Returns the date that the status last changed form PAUSED to RUNNING.
+	 * <p>
+	 * If the status has never changed form PAUSED to RUNNING <code>null</code> is returned.
+	 *
+	 * @return the date that the status last changed form PAUSED to RUNNING
+	 */
+	public Date getResumedDate() {
+		return resumedDate;
+	}
+
+	/**
+	 * Sets the date that the status last changed form PAUSED to RUNNING.
+	 *
+	 * @param resumedDate
+	 *            the date that the status last changed form PAUSED to RUNNING
+	 */
+	public void setResumedDate(Date resumedDate) {
+		this.resumedDate = resumedDate;
+		resumedDates.add(resumedDate);
+		setState(State.RUNNING);
+	}
+
+	/**
+	 * Returns the date that the status changed to CANCELLED.
+	 * <p>
+	 * If the status has never been CANCELLED <code>null</code> is returned.
+	 *
+	 * @return the date that the status changed to canceled
+	 */
+	public Date getCancelledDate() {
+		return cancelledDate;
+	}
+
+	/**
+	 * Sets the date that the status changed to CANCELLED.
+	 *
+	 * @param cancelledDate
+	 *            the date that the status changed to CANCELLED
+	 */
+	public void setCancelledDate(Date cancelledDate) {
+		this.cancelledDate = cancelledDate;
+		setState(State.CANCELLED);
+	}
+
+	/**
+	 * Returns the date that the status changed to COMPLETED.
+	 * <p>
+	 * If the status never been COMPLETED <code>null</code> is returned.
+	 *
+	 * @return the date that the status changed to COMPLETED
+	 */
+	public Date getCompletedDate() {
+		return completedDate;
+	}
+
+	/**
+	 * Sets the date that the status changed to COMPLETED.
+	 *
+	 * @param completedDate
+	 *            the date that the status changed to COMPLETED
+	 */
+	public void setCompletedDate(Date completedDate) {
+		this.completedDate = completedDate;
+		setState(State.COMPLETED);
+	}
+
+	/**
+	 * Returns the date that the status changed to FAILED. If the status has never been FAILED
+	 * <code>null</code> is returned.
+	 *
+	 * @return the date that the status changed to failed
+	 */
+	public Date getFailedDate() {
+		return failedDate;
+	}
+
+	/**
+	 * Sets the date that the status changed to FAILED.
+	 *
+	 * @param failedDate
+	 *            the date that the status changed to FAILED
+	 */
+	public void setFailedDate(Date failedDate) {
+		this.failedDate = failedDate;
+		setState(State.FAILED);
+	}
+
+	/**
+	 * Returns the dates that the status changed to PAUSED.
+	 * <p>
+	 * If the status has never been PAUSED an empty list is returned.
+	 *
+	 * @return the dates that the status was paused
+	 */
+	public List<Date> getPausedDates() {
+		return pausedDates;
+	}
+
+	/**
+	 * Returns the dates that the status changed from PAUSED to RUNNING.
+	 * <p>
+	 * If the status has never changed from PAUSED to RUNNING an empty list is returned.
+	 *
+	 * @return the dates that the status was resumed
+	 */
+	public List<Date> getResumedDates() {
+		return resumedDates;
+	}
+
+	/**
+	 * Returns the invocations.
+	 *
+	 * @return the invocations
+	 */
+	public NavigableSet<Invocation> getInvocations() {
+		synchronized (invocations) {
+			return new TreeSet<>(invocations);
+		}
+	}
+
+	public void addInvocation(Invocation invocation) {
+		synchronized (invocations) {
+			invocations.add(invocation);
+		}
+	}
+
+	/**
+	 * Informs the report that an output value has been added.
+	 * <p>
+	 * Any <code>ReportListener</code>s registered with this report will be notified that an output
+	 * value has been added.
+	 *
+	 * @param path
+	 *            the path that the value was added to
+	 * @param portName
+	 *            the port that the value belongs to
+	 * @param index
+	 *            the position of the value
+	 */
+	public void outputAdded(Path path, String portName, int[] index) {
+		synchronized (reportListeners) {
+			for (ReportListener reportListener : reportListeners)
+				reportListener.outputAdded(path, portName, index);
+		}
+	}
+
+	public void addReportListener(ReportListener reportListener) {
+		synchronized (reportListeners) {
+			reportListeners.add(reportListener);
+		}
+	}
+
+	public void removeReportListener(ReportListener reportListener) {
+		synchronized (reportListeners) {
+			reportListeners.remove(reportListener);
+		}
+	}
+
+	/**
+	 * Get an invocation with a given name.
+	 * @param invocationName
+	 * @return
+	 */
+    public Invocation getInvocation(String invocationName) {
+        NavigableSet<Invocation> invocs = getInvocations();
+        // A Comparable Invocation with the desired name
+        SortedSet<Invocation> tailSet = invocs.tailSet(new Invocation(invocationName));
+        if (!tailSet.isEmpty())
+        	return tailSet.first();
+        return null;
+    }
+}
\ No newline at end of file


[27/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-impl/src/main/java/uk/org/taverna/platform/run/impl/RunServiceImpl.java
----------------------------------------------------------------------
diff --git a/taverna-run-impl/src/main/java/uk/org/taverna/platform/run/impl/RunServiceImpl.java b/taverna-run-impl/src/main/java/uk/org/taverna/platform/run/impl/RunServiceImpl.java
deleted file mode 100755
index 1a4ca29..0000000
--- a/taverna-run-impl/src/main/java/uk/org/taverna/platform/run/impl/RunServiceImpl.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.run.impl;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.ClosedFileSystemException;
-import java.nio.file.InvalidPathException;
-import java.nio.file.Path;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.osgi.service.event.Event;
-import org.osgi.service.event.EventAdmin;
-import org.apache.taverna.robundle.Bundle;
-
-import org.apache.taverna.databundle.DataBundles;
-import uk.org.taverna.platform.execution.api.ExecutionEnvironment;
-import uk.org.taverna.platform.execution.api.ExecutionEnvironmentService;
-import uk.org.taverna.platform.execution.api.InvalidExecutionIdException;
-import uk.org.taverna.platform.execution.api.InvalidWorkflowException;
-import uk.org.taverna.platform.report.ReportListener;
-import uk.org.taverna.platform.report.State;
-import uk.org.taverna.platform.report.WorkflowReport;
-import uk.org.taverna.platform.run.api.InvalidRunIdException;
-import uk.org.taverna.platform.run.api.RunProfile;
-import uk.org.taverna.platform.run.api.RunProfileException;
-import uk.org.taverna.platform.run.api.RunService;
-import uk.org.taverna.platform.run.api.RunStateException;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.io.ReaderException;
-import org.apache.taverna.scufl2.api.io.WorkflowBundleIO;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/**
- * Implementation of the <code>RunService</code>.
- *
- * @author David Withers
- */
-public class RunServiceImpl implements RunService {
-	private static final Logger logger = Logger.getLogger(RunServiceImpl.class.getName());
-	private static SimpleDateFormat ISO_8601 = new SimpleDateFormat("yyyy-MM-dd_HHmmss");
-
-	private final Map<String, Run> runMap;
-	private ExecutionEnvironmentService executionEnvironmentService;
-	private EventAdmin eventAdmin;
-
-	public RunServiceImpl() {
-		runMap = new TreeMap<>();
-	}
-
-	@Override
-	public Set<ExecutionEnvironment> getExecutionEnvironments() {
-		return executionEnvironmentService.getExecutionEnvironments();
-	}
-
-	@Override
-	public Set<ExecutionEnvironment> getExecutionEnvironments(WorkflowBundle workflowBundle) {
-		return getExecutionEnvironments(workflowBundle.getMainProfile());
-	}
-
-	@Override
-	public Set<ExecutionEnvironment> getExecutionEnvironments(Profile profile) {
-		return executionEnvironmentService.getExecutionEnvironments(profile);
-	}
-
-	@Override
-	public List<String> getRuns() {
-		return new ArrayList<>(runMap.keySet());
-	}
-
-	@Override
-	public String createRun(RunProfile runProfile) throws InvalidWorkflowException, RunProfileException {
-		Run run = new Run(runProfile);
-		run.getWorkflowReport().addReportListener(new RunReportListener(run.getID()));
-		runMap.put(run.getID(), run);
-		postEvent(RUN_CREATED, run.getID());
-		return run.getID();
-	}
-
-	@Override
-	public String open(File runFile) throws IOException {
-		try {
-			String runID = runFile.getName();
-			int dot = runID.indexOf('.');
-			if (dot > 0)
-				runID = runID.substring(0, dot);
-			if (!runMap.containsKey(runID)) {
-				Bundle bundle = DataBundles.openBundle(runFile.toPath());
-				Run run = new Run(runID, bundle);
-				runMap.put(run.getID(), run);
-			}
-			postEvent(RUN_OPENED, runID);
-			return runID;
-		} catch (ReaderException | ParseException e) {
-			throw new IOException("Error opening file " + runFile, e);
-		}
-	}
-
-	@Override
-	public void close(String runID) throws InvalidRunIdException, InvalidExecutionIdException {
-		Run run = getRun(runID);
-		try {
-			Bundle dataBundle = run.getDataBundle();
-			DataBundles.closeBundle(dataBundle);
-		} catch (IOException | ClosedFileSystemException e) {
-			logger.log(Level.WARNING, "Error closing data bundle for run " + runID, e);
-		}
-		runMap.remove(runID);
-		postEvent(RUN_CLOSED, runID);
-	}
-
-	@Override
-	public void save(String runID, File runFile) throws InvalidRunIdException, IOException {
-		Run run = getRun(runID);
-		Bundle dataBundle = run.getDataBundle();
-		try {
-			DataBundles.closeAndSaveBundle(dataBundle, runFile.toPath());
-		} catch (InvalidPathException e) {
-			throw new IOException(e);
-		}
-	}
-
-	@Override
-	public void delete(String runID) throws InvalidRunIdException, InvalidExecutionIdException {
-		Run run = getRun(runID);
-		run.delete();
-		Bundle dataBundle = run.getDataBundle();
-		try {
-			DataBundles.closeBundle(dataBundle);
-		} catch (IOException e) {
-			logger.log(Level.WARNING, "Error closing data bundle for run " + runID, e);
-		}
-		runMap.remove(runID);
-		postEvent(RUN_DELETED, runID);
-	}
-
-	@Override
-	public void start(String runID) throws InvalidRunIdException, RunStateException, InvalidExecutionIdException {
-		getRun(runID).start();
-		postEvent(RUN_STARTED, runID);
-	}
-
-	@Override
-	public void pause(String runID) throws InvalidRunIdException, RunStateException, InvalidExecutionIdException {
-		getRun(runID).pause();
-		postEvent(RUN_PAUSED, runID);
-	}
-
-	@Override
-	public void resume(String runID) throws InvalidRunIdException, RunStateException, InvalidExecutionIdException {
-		getRun(runID).resume();
-		postEvent(RUN_RESUMED, runID);
-	}
-
-	@Override
-	public void cancel(String runID) throws InvalidRunIdException, RunStateException, InvalidExecutionIdException {
-		getRun(runID).cancel();
-		postEvent(RUN_STOPPED, runID);
-	}
-
-	@Override
-	public State getState(String runID) throws InvalidRunIdException {
-		return getRun(runID).getState();
-	}
-
-	@Override
-	public Bundle getDataBundle(String runID) throws InvalidRunIdException {
-		return getRun(runID).getDataBundle();
-	}
-
-	@Override
-	public WorkflowReport getWorkflowReport(String runID) throws InvalidRunIdException {
-		return getRun(runID).getWorkflowReport();
-	}
-
-	@Override
-	public Workflow getWorkflow(String runID) throws InvalidRunIdException {
-		return getRun(runID).getWorkflow();
-	}
-
-	@Override
-	public Profile getProfile(String runID) throws InvalidRunIdException {
-		return getRun(runID).getProfile();
-	}
-
-	@Override
-	public String getRunName(String runID) throws InvalidRunIdException {
-		WorkflowReport workflowReport = getWorkflowReport(runID);
-		return workflowReport.getSubject().getName() + "_" + ISO_8601.format(workflowReport.getCreatedDate());
-	}
-
-	private Run getRun(String runID) throws InvalidRunIdException {
-		Run run = runMap.get(runID);
-		if (run == null)
-			throw new InvalidRunIdException("Run ID " + runID + " is not valid");
-		return run;
-	}
-
-	private void postEvent(String topic, String runId) {
-		HashMap<String, String> properties = new HashMap<>();
-		properties.put("RUN_ID", runId);
-		Event event = new Event(topic, properties);
-		eventAdmin.postEvent(event);
-	}
-
-	public void setExecutionEnvironmentService(ExecutionEnvironmentService executionEnvironmentService) {
-		this.executionEnvironmentService = executionEnvironmentService;
-	}
-
-	public void setEventAdmin(EventAdmin eventAdmin) {
-		this.eventAdmin = eventAdmin;
-	}
-
-	public void setWorkflowBundleIO(WorkflowBundleIO workflowBundleIO) {
-		DataBundles.setWfBundleIO(workflowBundleIO);
-	}
-
-	private class RunReportListener implements ReportListener {
-		private final String runId;
-
-		public RunReportListener(String runId) {
-			this.runId = runId;
-		}
-
-		@Override
-		public void outputAdded(Path path, String portName, int[] index) {
-		}
-
-		@Override
-		public void stateChanged(State oldState, State newState) {
-			switch (newState) {
-			case COMPLETED:
-			case FAILED:
-				postEvent(RUN_STOPPED, runId);
-			default:
-				break;
-			}
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-impl/src/main/java/uk/org/taverna/platform/run/impl/WorkflowReportJSON.java
----------------------------------------------------------------------
diff --git a/taverna-run-impl/src/main/java/uk/org/taverna/platform/run/impl/WorkflowReportJSON.java b/taverna-run-impl/src/main/java/uk/org/taverna/platform/run/impl/WorkflowReportJSON.java
deleted file mode 100644
index 0c6f8e3..0000000
--- a/taverna-run-impl/src/main/java/uk/org/taverna/platform/run/impl/WorkflowReportJSON.java
+++ /dev/null
@@ -1,328 +0,0 @@
-package uk.org.taverna.platform.run.impl;
-
-import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
-import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;
-import static com.fasterxml.jackson.databind.SerializationFeature.FAIL_ON_EMPTY_BEANS;
-import static com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT;
-import static com.fasterxml.jackson.databind.SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS;
-import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS;
-import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_EMPTY_JSON_ARRAYS;
-import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_NULL_MAP_VALUES;
-import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED;
-import static java.nio.file.Files.newBufferedWriter;
-import static java.nio.file.StandardOpenOption.CREATE;
-import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
-import static java.nio.file.StandardOpenOption.WRITE;
-import static org.apache.taverna.databundle.DataBundles.getWorkflow;
-import static org.apache.taverna.databundle.DataBundles.getWorkflowBundle;
-import static org.apache.taverna.databundle.DataBundles.getWorkflowRunReport;
-import static org.apache.taverna.databundle.DataBundles.setWorkflowBundle;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Writer;
-import java.net.URI;
-import java.nio.charset.Charset;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.text.ParseException;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import org.apache.taverna.robundle.Bundle;
-import org.apache.taverna.robundle.manifest.Manifest.PathMixin;
-
-import uk.org.taverna.platform.report.ActivityReport;
-import uk.org.taverna.platform.report.Invocation;
-import uk.org.taverna.platform.report.ProcessorReport;
-import uk.org.taverna.platform.report.State;
-import uk.org.taverna.platform.report.StatusReport;
-import uk.org.taverna.platform.report.WorkflowReport;
-import org.apache.taverna.scufl2.api.activity.Activity;
-import org.apache.taverna.scufl2.api.common.URITools;
-import org.apache.taverna.scufl2.api.common.WorkflowBean;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Processor;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.io.ReaderException;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.fasterxml.jackson.databind.util.StdDateFormat;
-
-public class WorkflowReportJSON {
-	private static URITools uriTools = new URITools();
-	private static final StdDateFormat STD_DATE_FORMAT = new StdDateFormat();
-
-	public void save(WorkflowReport wfReport, Path path) throws IOException {
-		ObjectMapper om = makeObjectMapperForSave();
-		try (Writer w = newBufferedWriter(path, Charset.forName("UTF-8"),
-				WRITE, CREATE, TRUNCATE_EXISTING)) {
-			om.writeValue(w, wfReport);
-		}
-	}
-
-	protected static ObjectMapper makeObjectMapperForLoad() {
-		ObjectMapper om = new ObjectMapper();
-		om.disable(FAIL_ON_UNKNOWN_PROPERTIES);
-		return om;
-	}
-
-	protected static ObjectMapper makeObjectMapperForSave() {
-		ObjectMapper om = new ObjectMapper();
-		om.enable(INDENT_OUTPUT);
-		om.disable(FAIL_ON_EMPTY_BEANS);
-		om.enable(ORDER_MAP_ENTRIES_BY_KEYS);
-		om.disable(WRITE_EMPTY_JSON_ARRAYS);
-		om.disable(WRITE_NULL_MAP_VALUES);
-		om.disable(WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED);
-		om.disable(WRITE_DATES_AS_TIMESTAMPS);
-		om.disable(WRITE_NULL_MAP_VALUES);
-		om.addMixInAnnotations(Path.class, PathMixin.class);
-		om.setSerializationInclusion(NON_NULL);
-		return om;
-	}
-
-	@SuppressWarnings("unused")
-	private void injectContext(ObjectNode objNode) {
-		ObjectNode context = objNode.with("@context");
-		context.put("wfprov", "http://purl.org/wf4ever/wfprov#");
-		context.put("wfdesc", "http://purl.org/wf4ever/wfdesc#");
-		context.put("prov", "http://www.w3.org/ns/prov#");
-	}
-
-	public void save(WorkflowReport wfReport, Bundle dataBundle)
-			throws IOException {
-		Path path = getWorkflowRunReport(dataBundle);
-		save(wfReport, path);
-		if (!Files.exists(getWorkflow(dataBundle)))
-			// Usually already done by Run constructor
-			setWorkflowBundle(wfReport.getDataBundle(), wfReport.getSubject()
-					.getParent());
-	}
-
-	public WorkflowReport load(Bundle bundle) throws IOException,
-			ReaderException, ParseException {
-		Path path = getWorkflowRunReport(bundle);
-		WorkflowBundle workflow = getWorkflowBundle(bundle);
-		return load(path, workflow);
-	}
-
-	public WorkflowReport load(Path workflowReportJson,
-			WorkflowBundle workflowBundle) throws IOException, ParseException {
-		JsonNode json = loadWorkflowReportJson(workflowReportJson);
-		if (!json.isObject())
-			throw new IOException(
-					"Invalid workflow report, expected JSON Object:\n" + json);
-		return parseWorkflowReport(json, workflowReportJson, null,
-				workflowBundle);
-	}
-
-	protected WorkflowReport parseWorkflowReport(JsonNode reportJson,
-			Path workflowReportJson, ActivityReport actReport,
-			WorkflowBundle workflowBundle) throws ParseException {
-		Workflow wf = (Workflow) getSubject(reportJson, workflowBundle);
-		WorkflowReport workflowReport = new WorkflowReport(wf);
-		workflowReport.setParentReport(actReport);
-
-		parseDates(reportJson, workflowReport);
-
-		for (JsonNode invocJson : reportJson.path("invocations"))
-			// NOTE: Invocation constructor will add to parents
-			parseInvocation(invocJson, workflowReportJson, workflowReport);
-
-		for (JsonNode procJson : reportJson.path("processorReports")) {
-			ProcessorReport procReport = parseProcessorReport(procJson,
-					workflowReportJson, workflowReport, workflowBundle);
-			workflowReport.addProcessorReport(procReport);
-		}
-		return workflowReport;
-	}
-
-	protected ProcessorReport parseProcessorReport(JsonNode reportJson,
-			Path workflowReportJson, WorkflowReport workflowReport,
-			WorkflowBundle workflowBundle) throws ParseException {
-		Processor p = (Processor) getSubject(reportJson, workflowBundle);
-		ProcessorReport procReport = new ProcessorReport(p);
-		procReport.setParentReport(workflowReport);
-
-		procReport.setJobsQueued(reportJson.path("jobsQueued").asInt());
-		procReport.setJobsStarted(reportJson.path("jobsStarted").asInt());
-		procReport.setJobsCompleted(reportJson.path("jobsCompleted").asInt());
-		procReport.setJobsCompletedWithErrors(reportJson.path(
-				"jobsCompletedWithErrors").asInt());
-		// TODO: procReport properties
-
-		parseDates(reportJson, procReport);
-
-		for (JsonNode invocJson : reportJson.path("invocations"))
-			parseInvocation(invocJson, workflowReportJson, procReport);
-
-		for (JsonNode actJson : reportJson.path("activityReports")) {
-			ActivityReport activityReport = parseActivityReport(actJson,
-					workflowReportJson, procReport, workflowBundle);
-			procReport.addActivityReport(activityReport);
-		}
-		return procReport;
-	}
-
-	protected ActivityReport parseActivityReport(JsonNode actJson,
-			Path workflowReportJson, ProcessorReport procReport,
-			WorkflowBundle workflowBundle) throws ParseException {
-		Activity a = (Activity) getSubject(actJson, workflowBundle);
-		ActivityReport actReport = new ActivityReport(a);
-		actReport.setParentReport(procReport);
-
-		parseDates(actJson, actReport);
-
-		for (JsonNode invocJson : actJson.path("invocations"))
-			parseInvocation(invocJson, workflowReportJson, actReport);
-
-		JsonNode nestedWf = actJson.get("nestedWorkflowReport");
-		if (nestedWf != null)
-			actReport.setNestedWorkflowReport(parseWorkflowReport(nestedWf,
-					workflowReportJson, actReport, workflowBundle));
-		return actReport;
-	}
-
-	protected void parseInvocation(JsonNode json, Path workflowReportJson,
-			@SuppressWarnings("rawtypes") StatusReport report)
-			throws ParseException {
-		String name = json.path("name").asText();
-
-		String parentId = json.path("parent").asText();
-		Invocation parent = null;
-		if (!parentId.isEmpty()) {
-			@SuppressWarnings("rawtypes")
-			StatusReport parentReport = report.getParentReport();
-			if (parentReport != null)
-				parent = parentReport.getInvocation(parentId);
-		}
-
-		int[] index;
-		if (json.has("index")) {
-			ArrayNode array = (ArrayNode) json.get("index");
-			index = new int[array.size()];
-			for (int i = 0; i < index.length; i++)
-				index[i] = array.get(i).asInt();
-		} else
-			index = new int[0];
-
-		Invocation invocation = new Invocation(name, index, parent, report);
-		Date startedDate = getDate(json, "startedDate");
-		if (startedDate != null)
-			invocation.setStartedDate(startedDate);
-		Date completedDate = getDate(json, "completedDate");
-		if (completedDate != null)
-			invocation.setCompletedDate(completedDate);
-
-		invocation.setInputs(parseValues(json.path("inputs"),
-				workflowReportJson));
-		invocation.setOutputs(parseValues(json.path("outputs"),
-				workflowReportJson));
-	}
-
-	protected Map<String, Path> parseValues(JsonNode json, Path basePath) {
-		SortedMap<String, Path> values = new TreeMap<>();
-		for (String port : iterate(json.fieldNames())) {
-			String pathStr = json.get(port).asText();
-			Path value = basePath.resolve(pathStr);
-			values.put(port, value);
-		}
-		return values;
-	}
-
-	private static <T> Iterable<T> iterate(final Iterator<T> iterator) {
-		return new Iterable<T>() {
-			@Override
-			public Iterator<T> iterator() {
-				return iterator;
-			}
-		};
-	}
-
-	protected void parseDates(JsonNode json,
-			@SuppressWarnings("rawtypes") StatusReport report)
-			throws ParseException {
-		Date createdDate = getDate(json, "createdDate");
-		if (createdDate != null)
-			report.setCreatedDate(createdDate);
-
-		Date startedDate = getDate(json, "startedDate");
-		if (startedDate != null)
-			report.setStartedDate(startedDate);
-
-		// Special case for paused and resumed dates>
-		for (JsonNode s : json.path("pausedDates")) {
-			Date pausedDate = STD_DATE_FORMAT.parse(s.asText());
-			report.setPausedDate(pausedDate);
-		}
-		Date pausedDate = getDate(json, "pausedDate");
-		if (report.getPausedDates().isEmpty() && pausedDate != null) {
-			/*
-			 * "pausedDate" is normally redundant (last value of "pausedDates")
-			 * but here for some reason the list is missing, so we'll parse it
-			 * separately.
-			 * 
-			 * Note that if there was a list, we will ignore "pauseDate" no
-			 * matter its value
-			 */
-			report.setPausedDate(pausedDate);
-		}
-
-		for (JsonNode s : json.path("resumedDates")) {
-			Date resumedDate = STD_DATE_FORMAT.parse(s.asText());
-			report.setResumedDate(resumedDate);
-		}
-		Date resumedDate = getDate(json, "resumedDate");
-		if (report.getResumedDates().isEmpty() && resumedDate != null)
-			// Same fall-back as for "pausedDate" above
-			report.setResumedDate(resumedDate);
-
-		Date cancelledDate = getDate(json, "cancelledDate");
-		if (cancelledDate != null)
-			report.setCancelledDate(cancelledDate);
-
-		Date failedDate = getDate(json, "failedDate");
-		if (failedDate != null)
-			report.setFailedDate(failedDate);
-
-		Date completedDate = getDate(json, "completedDate");
-		if (completedDate != null)
-			report.setCompletedDate(completedDate);
-
-		try {
-			State state = State.valueOf(json.get("state").asText());
-			report.setState(state);
-		} catch (IllegalArgumentException ex) {
-			throw new ParseException("Invalid state: " + json.get("state"), -1);
-		}
-	}
-
-	protected Date getDate(JsonNode json, String name) throws ParseException {
-		String date = json.path(name).asText();
-		if (date.isEmpty())
-			return null;
-		return STD_DATE_FORMAT.parse(date);
-	}
-
-	private WorkflowBean getSubject(JsonNode reportJson,
-			WorkflowBundle workflowBundle) {
-		URI subjectUri = URI.create(reportJson.path("subject").asText());
-		return uriTools.resolveUri(subjectUri, workflowBundle);
-	}
-
-	protected JsonNode loadWorkflowReportJson(Path path) throws IOException,
-			JsonProcessingException {
-		ObjectMapper om = makeObjectMapperForLoad();
-		try (InputStream stream = Files.newInputStream(path)) {
-			return om.readTree(stream);
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-impl/src/main/resources/META-INF/spring/run-context-osgi.xml
----------------------------------------------------------------------
diff --git a/taverna-run-impl/src/main/resources/META-INF/spring/run-context-osgi.xml b/taverna-run-impl/src/main/resources/META-INF/spring/run-context-osgi.xml
index 739d06f..6e4ff35 100644
--- a/taverna-run-impl/src/main/resources/META-INF/spring/run-context-osgi.xml
+++ b/taverna-run-impl/src/main/resources/META-INF/spring/run-context-osgi.xml
@@ -7,9 +7,9 @@
                                  http://www.springframework.org/schema/osgi
                                  http://www.springframework.org/schema/osgi/spring-osgi.xsd">
 
-    <service ref="runService" interface="uk.org.taverna.platform.run.api.RunService"/>
+    <service ref="runService" interface="org.apache.taverna.platform.run.api.RunService"/>
 
-    <reference id="executionEnvironmentService" interface="uk.org.taverna.platform.execution.api.ExecutionEnvironmentService"/>
+    <reference id="executionEnvironmentService" interface="org.apache.taverna.platform.execution.api.ExecutionEnvironmentService"/>
 
 	<reference id="eventAdmin" interface="org.osgi.service.event.EventAdmin" />
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-impl/src/main/resources/META-INF/spring/run-context.xml
----------------------------------------------------------------------
diff --git a/taverna-run-impl/src/main/resources/META-INF/spring/run-context.xml b/taverna-run-impl/src/main/resources/META-INF/spring/run-context.xml
index d7b2d3a..094718b 100644
--- a/taverna-run-impl/src/main/resources/META-INF/spring/run-context.xml
+++ b/taverna-run-impl/src/main/resources/META-INF/spring/run-context.xml
@@ -4,7 +4,7 @@
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                            http://www.springframework.org/schema/beans/spring-beans.xsd">
 
-    <bean id="runService" class="uk.org.taverna.platform.run.impl.RunServiceImpl" >
+    <bean id="runService" class="org.apache.taverna.platform.run.impl.RunServiceImpl" >
     		<property name="executionEnvironmentService" ref="executionEnvironmentService"/>
     		<property name="eventAdmin" ref="eventAdmin"/>
     		<property name="workflowBundleIO" ref="workflowBundleIO"/>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-impl/src/test/java/org/apache/taverna/platform/run/impl/DummyWorkflowReport.java
----------------------------------------------------------------------
diff --git a/taverna-run-impl/src/test/java/org/apache/taverna/platform/run/impl/DummyWorkflowReport.java b/taverna-run-impl/src/test/java/org/apache/taverna/platform/run/impl/DummyWorkflowReport.java
new file mode 100644
index 0000000..661e725
--- /dev/null
+++ b/taverna-run-impl/src/test/java/org/apache/taverna/platform/run/impl/DummyWorkflowReport.java
@@ -0,0 +1,131 @@
+package org.apache.taverna.platform.run.impl;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+import java.util.UUID;
+
+import org.junit.Before;
+import org.apache.taverna.robundle.Bundle;
+
+import org.apache.taverna.databundle.DataBundles;
+import org.apache.taverna.platform.report.ActivityReport;
+import org.apache.taverna.platform.report.Invocation;
+import org.apache.taverna.platform.report.ProcessorReport;
+import org.apache.taverna.platform.report.WorkflowReport;
+import org.apache.taverna.scufl2.api.common.Scufl2Tools;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.Processor;
+import org.apache.taverna.scufl2.api.io.ReaderException;
+import org.apache.taverna.scufl2.api.io.WorkflowBundleIO;
+import org.apache.taverna.scufl2.api.profiles.ProcessorBinding;
+
+
+public class DummyWorkflowReport {
+    
+    private static TimeZone UTC = TimeZone.getTimeZone("UTC");
+
+    protected Bundle dataBundle;
+    
+    protected WorkflowReport wfReport;
+
+    protected static final Scufl2Tools scufl2Tools = new Scufl2Tools();
+    protected static final WorkflowBundleIO workflowBundleIO = new WorkflowBundleIO();
+    protected WorkflowBundle wfBundle;
+
+    @Before
+    public void loadWf() throws ReaderException, IOException {
+        wfBundle = workflowBundleIO.readBundle(getClass().getResource("/hello_anyone.wfbundle"), 
+                "application/vnd.taverna.scufl2.workflow-bundle");
+    }
+
+    protected Date date(int year, int month, int date, int hourOfDay, int minute) {
+        GregorianCalendar cal = new GregorianCalendar(UTC);
+        cal.setTimeInMillis(0);
+        cal.set(year, month-1, date, hourOfDay, minute);
+        return cal.getTime();
+    }
+    
+    @Before
+    public void dummyReport() throws Exception {
+        wfReport = new WorkflowReport(wfBundle.getMainWorkflow());
+        dataBundle = DataBundles.createBundle();
+        wfReport.setDataBundle(dataBundle);
+        wfReport.setCreatedDate(date(2013,1,2,13,37));
+        wfReport.setStartedDate(date(2013,1,2,14,50));        
+        Invocation wfInvocation = new Invocation("wf0", null, wfReport);
+        wfInvocation.setStartedDate(date(2013,1,2,14,51));
+        wfInvocation.setCompletedDate(date(2013,12,30,23,50));
+
+        wfReport.addInvocation(wfInvocation);
+        
+        Path name = DataBundles.getPort(DataBundles.getInputs(dataBundle), "name");
+        DataBundles.setStringValue(name, "John Doe");
+        wfInvocation.getInputs().put("name", name);
+        
+        Path greeting = DataBundles.getPort(DataBundles.getOutputs(dataBundle), "greeting");
+        DataBundles.setStringValue(greeting, "Hello, John Doe");
+        wfInvocation.getOutputs().put("greeting", greeting);
+        
+        Path helloValue = DataBundles.getIntermediate(dataBundle, UUID.randomUUID());
+        Path concatenateOutput = DataBundles.getIntermediate(dataBundle, UUID.randomUUID());
+        
+        for (Processor p : wfBundle.getMainWorkflow().getProcessors()) {
+            ProcessorReport processorReport = new ProcessorReport(p);
+            processorReport.setJobsQueued(1);
+            processorReport.setJobsStarted(5);
+            processorReport.setJobsCompleted(3);
+            processorReport.setJobsCompletedWithErrors(2);
+                        
+            wfReport.addProcessorReport(processorReport);
+
+            processorReport.setCreatedDate(date(2013,2,1,0,0));
+            processorReport.setStartedDate(date(2013,2,2,0,0));
+            processorReport.setPausedDate(date(2013,2,3,0,0));
+            processorReport.setResumedDate(date(2013,2,4,0,0));
+            processorReport.setPausedDate(date(2013,2,5,0,0));
+            processorReport.setResumedDate(date(2013,2,6,0,0));
+            
+            Invocation pInvocation = new Invocation("proc-" + p.getName() + "0", wfInvocation, processorReport);
+
+            pInvocation.setStartedDate(date(2013,2,2,11,0));
+            pInvocation.setCompletedDate(date(2013,2,2,13,0));
+
+            if (p.getName().equals("hello")) {
+                pInvocation.getOutputs().put("value", helloValue);
+                DataBundles.setStringValue(helloValue, "Hello, ");
+            } else if (p.getName().equals("Concatenate_two_strings")) {
+                pInvocation.getInputs().put("string1", helloValue);
+                pInvocation.getInputs().put("string2", name);
+                pInvocation.getOutputs().put("output", concatenateOutput);
+                DataBundles.setStringValue(concatenateOutput, "Hello, John Doe");
+            } else {
+                throw new Exception("Unexpected processor " + p);
+            }
+            processorReport.addInvocation(pInvocation);
+            
+            for (ProcessorBinding b : scufl2Tools.processorBindingsForProcessor(p, wfBundle.getMainProfile())) {
+                ActivityReport activityReport = new ActivityReport(b.getBoundActivity());
+                processorReport.addActivityReport(activityReport);
+                activityReport.setCreatedDate(date(2013,2,20,0,0));
+                activityReport.setStartedDate(date(2013,2,20,11,00));
+                activityReport.setCancelledDate(date(2013,2,21,11,30));
+                Invocation aInvocation = new Invocation("act-" + p.getName() + "0", pInvocation, activityReport);
+
+                aInvocation.setStartedDate(date(2013,2,20,11,30));
+//                aInvocation.setCompletedDate(date(2013,2,20,12,0));
+
+                activityReport.addInvocation(aInvocation);
+                aInvocation.getInputs().putAll(pInvocation.getInputs());
+                aInvocation.getOutputs().putAll(pInvocation.getOutputs());
+            }
+//            processorReport.setFailedDate(date(2013,7,28,23,59));
+            // In the summer to check that daylight saving does not sneak in
+            processorReport.setCompletedDate(date(2013,7,28,12,00));
+        }
+        wfReport.setCompletedDate(date(2013,12,31,0,0));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-impl/src/test/java/org/apache/taverna/platform/run/impl/RunTest.java
----------------------------------------------------------------------
diff --git a/taverna-run-impl/src/test/java/org/apache/taverna/platform/run/impl/RunTest.java b/taverna-run-impl/src/test/java/org/apache/taverna/platform/run/impl/RunTest.java
new file mode 100644
index 0000000..9108d62
--- /dev/null
+++ b/taverna-run-impl/src/test/java/org/apache/taverna/platform/run/impl/RunTest.java
@@ -0,0 +1,69 @@
+package org.apache.taverna.platform.run.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.UUID;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.apache.taverna.robundle.Bundle;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+import org.apache.taverna.databundle.DataBundles;
+import org.apache.taverna.platform.execution.api.ExecutionEnvironment;
+import org.apache.taverna.platform.execution.api.ExecutionService;
+import org.apache.taverna.platform.report.State;
+import org.apache.taverna.platform.run.api.RunProfile;
+import org.apache.taverna.scufl2.api.io.WorkflowBundleIO;
+
+public class RunTest extends DummyWorkflowReport {
+
+    private static final WorkflowBundleIO workflowBundleIO = new WorkflowBundleIO();
+    private Run run;
+
+    public ExecutionEnvironment mockExecution() throws Exception {
+        ExecutionService exService = mock(ExecutionService.class);
+        when(exService.createExecution(null,null,null,null,null)).thenReturn("id0");
+        ExecutionEnvironment execution = mock(ExecutionEnvironment.class);
+        when(execution.getExecutionService()).thenReturn(exService);
+        when(exService.getWorkflowReport(null)).thenReturn(wfReport);
+        return execution;
+    }
+    
+    @Before
+    public void makeRun() throws Exception {
+        RunProfile runProfile = new RunProfile(mockExecution(), wfBundle, dataBundle);
+        run = new Run(runProfile);
+    }
+
+    @Test
+    public void getID() throws Exception {
+        assertEquals(4, UUID.fromString(run.getID()).version());
+    }
+    
+    @Test
+    public void getBundle() throws Exception {
+        Bundle bundle = run.getDataBundle();
+        // Contains a copy of workflow
+        assertEquals(wfBundle.getGlobalBaseURI(),
+                DataBundles.getWorkflowBundle(bundle).getGlobalBaseURI());
+        // Contains a run report
+        Path runReport = DataBundles.getWorkflowRunReport(bundle);
+        assertTrue(Files.exists(runReport));
+        JsonNode runReportJson = DataBundles.getWorkflowRunReportAsJson(bundle);
+        assertEquals("COMPLETED", runReportJson.get("state").asText());
+    }
+    
+
+    @Test
+    public void getState() throws Exception {
+        assertEquals(State.COMPLETED, run.getState());
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-impl/src/test/java/org/apache/taverna/platform/run/impl/WorkflowReportJSONTest.java
----------------------------------------------------------------------
diff --git a/taverna-run-impl/src/test/java/org/apache/taverna/platform/run/impl/WorkflowReportJSONTest.java b/taverna-run-impl/src/test/java/org/apache/taverna/platform/run/impl/WorkflowReportJSONTest.java
new file mode 100644
index 0000000..6ba4802
--- /dev/null
+++ b/taverna-run-impl/src/test/java/org/apache/taverna/platform/run/impl/WorkflowReportJSONTest.java
@@ -0,0 +1,285 @@
+package org.apache.taverna.platform.run.impl;
+
+import static org.junit.Assert.*;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+
+import org.junit.After;
+import org.junit.Test;
+import org.apache.taverna.robundle.Bundle;
+
+import org.apache.taverna.databundle.DataBundles;
+import org.apache.taverna.platform.report.ActivityReport;
+import org.apache.taverna.platform.report.Invocation;
+import org.apache.taverna.platform.report.ProcessorReport;
+import org.apache.taverna.platform.report.State;
+import org.apache.taverna.platform.report.WorkflowReport;
+import org.apache.taverna.scufl2.api.common.URITools;
+import org.apache.taverna.scufl2.api.core.Processor;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class WorkflowReportJSONTest extends DummyWorkflowReport {
+    
+    private final WorkflowReportJSON workflowReportJson = new WorkflowReportJSON();
+
+
+    @Test
+    public void save() throws Exception {
+        workflowReportJson.save(wfReport, dataBundle);
+        Path path = wfReport.getDataBundle().getRoot().resolve("/workflowrun.json");
+        assertTrue("Did not save to expected path "  + path, Files.exists(path));
+
+//        System.out.println(DataBundles.getStringValue(path));
+        
+        JsonNode json;
+        try (InputStream jsonIn = Files.newInputStream(path)) {
+            json = new ObjectMapper().readTree(jsonIn);
+        }
+        assertEquals("COMPLETED", json.get("state").asText());
+        assertEquals("2013-01-02T13:37:00.000+0000", json.get("createdDate").asText());
+        assertEquals("2013-01-02T14:50:00.000+0000", json.get("startedDate").asText());
+        assertEquals("2013-12-31T00:00:00.000+0000", json.get("completedDate").asText());
+        String wfId = wfBundle.getGlobalBaseURI().toString();
+        assertEquals(wfId + "workflow/Hello_Anyone/", 
+                json.get("subject").asText());
+        
+        // workflow invocation
+        JsonNode wfInvoc = json.get("invocations").get(0);
+        assertEquals("wf0", wfInvoc.get("id").asText());
+        assertEquals("wf0", wfInvoc.get("name").asText());
+        
+        assertEquals("2013-01-02T14:51:00.000+0000", wfInvoc.get("startedDate").asText());
+        assertEquals("2013-12-30T23:50:00.000+0000", wfInvoc.get("completedDate").asText());
+
+        String inputsName = wfInvoc.get("inputs").get("name").asText();
+        assertEquals("/inputs/name", inputsName);
+        String outputsGreeting = wfInvoc.get("outputs").get("greeting").asText();
+        assertEquals("/outputs/greeting", outputsGreeting);
+        assertEquals(
+                "John Doe",
+                DataBundles.getStringValue(wfReport.getDataBundle().getRoot()
+                        .resolve(inputsName)));        
+        assertEquals(
+                "Hello, John Doe",
+                DataBundles.getStringValue(wfReport.getDataBundle().getRoot()
+                        .resolve(outputsGreeting)));        
+
+        // NOTE: This assumes alphabetical ordering when constructing
+        // processor reports - which generally is given as
+        // Workflow.getProcessors() is sorted.
+        JsonNode proc0 = json.get("processorReports").get(0);
+        assertEquals(wfId + "workflow/Hello_Anyone/processor/Concatenate_two_strings/",
+                proc0.get("subject").asText());
+        assertEquals("COMPLETED", proc0.get("state").asText());
+        assertEquals("2013-02-01T00:00:00.000+0000", proc0.get("createdDate").asText());
+        assertEquals("2013-02-02T00:00:00.000+0000", proc0.get("startedDate").asText());
+        assertEquals("2013-02-03T00:00:00.000+0000", proc0.get("pausedDates").get(0).asText());
+        assertEquals("2013-02-05T00:00:00.000+0000", proc0.get("pausedDates").get(1).asText());
+        assertEquals("2013-02-05T00:00:00.000+0000", proc0.get("pausedDate").asText());
+
+        assertEquals("2013-02-04T00:00:00.000+0000", proc0.get("resumedDates").get(0).asText());
+        assertEquals("2013-02-06T00:00:00.000+0000", proc0.get("resumedDates").get(1).asText());
+        assertEquals("2013-02-06T00:00:00.000+0000", proc0.get("resumedDate").asText());
+
+        assertEquals("2013-07-28T12:00:00.000+0000", proc0.get("completedDate").asText());
+
+        // processor invocations
+        JsonNode pInvoc0 = proc0.get("invocations").get(0);
+        assertEquals("proc-Concatenate_two_strings0", pInvoc0.get("name").asText());
+        assertEquals("wf0/proc-Concatenate_two_strings0", pInvoc0.get("id").asText());
+        assertEquals("wf0", pInvoc0.get("parent").asText());
+
+        String inputString1 = pInvoc0.get("inputs").get("string1").asText();
+        assertTrue(inputString1.startsWith("/intermediates/"));
+        assertEquals(
+                "Hello, ",
+                DataBundles.getStringValue(wfReport.getDataBundle().getRoot()
+                        .resolve(inputString1)));        
+        
+        String inputString2 = pInvoc0.get("inputs").get("string2").asText();
+        assertEquals("/inputs/name", inputString2);
+        String output = pInvoc0.get("outputs").get("output").asText();
+        assertTrue(output.startsWith("/intermediates/"));
+        assertEquals(
+                "Hello, John Doe",
+                DataBundles.getStringValue(wfReport.getDataBundle().getRoot()
+                        .resolve(output)));        
+
+        // Activity reports
+        JsonNode act0 = proc0.get("activityReports").get(0);
+        assertEquals("CANCELLED", act0.get("state").asText());
+        assertEquals(wfId + "profile/taverna-2.4.0/activity/Concatenate_two_strings/", 
+                act0.get("subject").asText());
+        
+        
+        // activity invocation
+        JsonNode aInvoc0 = act0.get("invocations").get(0);
+
+        assertEquals("act-Concatenate_two_strings0", aInvoc0.get("name").asText());
+        assertEquals("wf0/proc-Concatenate_two_strings0/act-Concatenate_two_strings0", aInvoc0.get("id").asText());
+        assertEquals("wf0/proc-Concatenate_two_strings0", aInvoc0.get("parent").asText());
+
+        String actInputString1 = aInvoc0.get("inputs").get("string1").asText();
+        assertTrue(actInputString1.startsWith("/intermediates/"));
+        assertEquals(
+                "Hello, ",
+                DataBundles.getStringValue(wfReport.getDataBundle().getRoot()
+                        .resolve(actInputString1)));        
+        
+        String actInputString2 = aInvoc0.get("inputs").get("string2").asText();
+        assertEquals("/inputs/name", actInputString2);
+        String actOutput = pInvoc0.get("outputs").get("output").asText();
+        assertTrue(actOutput.startsWith("/intermediates/"));
+        assertEquals(
+                "Hello, John Doe",
+                DataBundles.getStringValue(wfReport.getDataBundle().getRoot()
+                        .resolve(actOutput)));        
+
+        
+        
+        
+        JsonNode proc1 = json.get("processorReports").get(1);
+        assertEquals(wfId + "workflow/Hello_Anyone/processor/hello/",
+                proc1.get("subject").asText());
+        assertEquals("COMPLETED", proc1.get("state").asText());
+        assertEquals("2013-02-01T00:00:00.000+0000", proc1.get("createdDate").asText());
+        assertEquals("2013-02-02T00:00:00.000+0000", proc1.get("startedDate").asText());
+        // etc.
+
+        JsonNode pInvoc1 = proc1.get("invocations").get(0);
+
+        String value = pInvoc1.get("outputs").get("value").asText();
+        assertTrue(value.startsWith("/intermediates/"));
+        assertEquals(
+                "Hello, ",
+                DataBundles.getStringValue(wfReport.getDataBundle().getRoot()
+                        .resolve(value)));        
+        assertEquals(inputString1, value);
+    }
+    
+    @Test
+    public void load() throws Exception {
+        URI bundleUri = getClass().getResource("/workflowrun.bundle.zip").toURI();
+        Path bundlePath = Paths.get(bundleUri);
+        try (Bundle bundle = DataBundles.openBundle(bundlePath)) {
+            WorkflowReport wfReport = workflowReportJson.load(bundle);
+            assertEquals(State.COMPLETED, wfReport.getState());
+            assertNull(wfReport.getParentReport());
+            
+            assertEquals(wfBundle.getMainWorkflow().getName(), wfReport.getSubject().getName());
+            URI mainWf = new URITools().uriForBean(wfBundle.getMainWorkflow());
+            assertEquals(mainWf, wfReport.getSubjectURI());
+            
+            assertEquals(date(2013,1,2,13,37), wfReport.getCreatedDate());
+            assertEquals(date(2013,1,2,14,50), wfReport.getStartedDate());
+            assertEquals(date(2013,12,31,0,0), wfReport.getCompletedDate());
+            assertNull(wfReport.getCancelledDate());
+            assertNull(wfReport.getResumedDate());
+            assertNull(wfReport.getPausedDate());
+            assertTrue(wfReport.getResumedDates().isEmpty());
+            assertTrue(wfReport.getPausedDates().isEmpty());
+            
+            // wf invocation
+            assertEquals(1, wfReport.getInvocations().size());
+            Invocation wfInvov = wfReport.getInvocations().first();
+            assertEquals("wf0", wfInvov.getName());
+            assertEquals("wf0", wfInvov.getId());
+            assertNull(wfInvov.getParentId());
+            assertNull(wfInvov.getParent());
+            assertEquals(0, wfInvov.getIndex().length);
+            assertSame(wfReport, wfInvov.getReport());
+            assertEquals(State.COMPLETED, wfInvov.getState());
+
+            assertEquals(date(2013,1,2,14,51), wfInvov.getStartedDate());
+            assertEquals(date(2013,12,30,23,50), wfInvov.getCompletedDate());
+
+            // wf invocation in/out
+            assertEquals(1, wfInvov.getInputs().size());
+            assertEquals(1, wfInvov.getOutputs().size());
+            
+            Path name = wfInvov.getInputs().get("name");
+            assertEquals("/inputs/name", name.toString());
+            assertEquals("John Doe", DataBundles.getStringValue(name));
+            
+            Path greeting = wfInvov.getOutputs().get("greeting");
+            assertEquals("/outputs/greeting", greeting.toString());
+            assertEquals("Hello, John Doe", DataBundles.getStringValue(greeting));
+            
+            
+            // processor reports
+            assertEquals(2, wfReport.getProcessorReports().size());
+            for (ProcessorReport procRepo : wfReport.getProcessorReports()) {
+                Processor processor = procRepo.getSubject();
+                assertTrue(wfBundle.getMainWorkflow().getProcessors().containsName(processor.getName()));
+                assertEquals(1, procRepo.getJobsQueued());
+                assertEquals(2, procRepo.getJobsCompletedWithErrors());
+                assertEquals(3, procRepo.getJobsCompleted());
+                assertEquals(5, procRepo.getJobsStarted());
+                
+
+                assertEquals(date(2013,2,1,00,00), procRepo.getCreatedDate());
+                assertEquals(date(2013,2,2,00,00), procRepo.getStartedDate());
+                assertEquals(date(2013,7,28,12,0), procRepo.getCompletedDate());
+                assertEquals(date(2013,2,5,0,0), procRepo.getPausedDate());
+                assertEquals(Arrays.asList(date(2013,2,3,0,0), date(2013,2,5,0,0)),
+                        procRepo.getPausedDates());
+                assertEquals(date(2013,2,6,0,0), procRepo.getResumedDate());
+                assertEquals(Arrays.asList(date(2013,2,4,0,0), date(2013,2,6,0,0)),
+                        procRepo.getResumedDates());
+
+                assertEquals(date(2013,7,28,12,0), procRepo.getCompletedDate());
+                
+                assertEquals(1, procRepo.getInvocations().size());
+                Invocation pInvoc = procRepo.getInvocations().first();
+                assertEquals(date(2013,2,2,11,00), pInvoc.getStartedDate());
+                assertEquals(date(2013,2,2,13,00), pInvoc.getCompletedDate());
+                assertEquals(State.COMPLETED, pInvoc.getState());
+                assertEquals(wfInvov, pInvoc.getParent());
+                assertEquals("wf0", pInvoc.getParentId());                
+                if (processor.getName().equals("hello")) {
+                    assertEquals("proc-hello0", pInvoc.getName());
+                    assertEquals("wf0/proc-hello0", pInvoc.getId());
+                    assertEquals(0, pInvoc.getInputs().size());
+                    assertEquals(1, pInvoc.getOutputs().size());
+                    assertEquals("Hello, ", DataBundles.getStringValue(pInvoc.getOutputs().get("value")));
+                } else if (processor.getName().equals("Concatenate_two_strings")) {
+                    assertEquals("proc-Concatenate_two_strings0", pInvoc.getName());
+                    assertEquals("wf0/proc-Concatenate_two_strings0", pInvoc.getId());
+                    assertEquals(2, pInvoc.getInputs().size());
+                    assertEquals("Hello, ", DataBundles.getStringValue(pInvoc.getInputs().get("string1")));
+                    assertEquals("John Doe", DataBundles.getStringValue(pInvoc.getInputs().get("string2")));
+
+                    assertEquals(1, pInvoc.getOutputs().size());
+                    assertEquals("Hello, John Doe", DataBundles.getStringValue(pInvoc.getOutputs().get("output")));                    
+                } else {
+                    fail("Unknown processor: " + processor.getName());
+                }
+                
+                assertEquals(1, procRepo.getActivityReports().size());
+                for (ActivityReport actRepo : procRepo.getActivityReports()) {
+                    assertEquals(procRepo, actRepo.getParentReport());
+                    assertEquals(State.CANCELLED, actRepo.getState());
+                    assertEquals(date(2013,2,20,00,00), actRepo.getCreatedDate());
+                    assertEquals(date(2013,2,20,11,00), actRepo.getStartedDate());
+                    assertEquals(date(2013,2,21,11,30), actRepo.getCancelledDate());                   
+                    // TODO: Test nested workflow
+                }
+            }
+        }
+        
+    }
+    
+    @After
+    public void closeBundle() throws Exception {
+        Path saved = dataBundle.getSource().resolveSibling("workflowrun.bundle.zip");
+        DataBundles.closeAndSaveBundle(dataBundle, saved);
+        System.out.println("Saved to " + saved);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-impl/src/test/java/uk/org/taverna/platform/run/impl/DummyWorkflowReport.java
----------------------------------------------------------------------
diff --git a/taverna-run-impl/src/test/java/uk/org/taverna/platform/run/impl/DummyWorkflowReport.java b/taverna-run-impl/src/test/java/uk/org/taverna/platform/run/impl/DummyWorkflowReport.java
deleted file mode 100644
index b30b90b..0000000
--- a/taverna-run-impl/src/test/java/uk/org/taverna/platform/run/impl/DummyWorkflowReport.java
+++ /dev/null
@@ -1,131 +0,0 @@
-package uk.org.taverna.platform.run.impl;
-
-import java.io.IOException;
-import java.nio.file.Path;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-import java.util.UUID;
-
-import org.junit.Before;
-import org.apache.taverna.robundle.Bundle;
-
-import org.apache.taverna.databundle.DataBundles;
-import uk.org.taverna.platform.report.ActivityReport;
-import uk.org.taverna.platform.report.Invocation;
-import uk.org.taverna.platform.report.ProcessorReport;
-import uk.org.taverna.platform.report.WorkflowReport;
-import org.apache.taverna.scufl2.api.common.Scufl2Tools;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Processor;
-import org.apache.taverna.scufl2.api.io.ReaderException;
-import org.apache.taverna.scufl2.api.io.WorkflowBundleIO;
-import org.apache.taverna.scufl2.api.profiles.ProcessorBinding;
-
-
-public class DummyWorkflowReport {
-    
-    private static TimeZone UTC = TimeZone.getTimeZone("UTC");
-
-    protected Bundle dataBundle;
-    
-    protected WorkflowReport wfReport;
-
-    protected static final Scufl2Tools scufl2Tools = new Scufl2Tools();
-    protected static final WorkflowBundleIO workflowBundleIO = new WorkflowBundleIO();
-    protected WorkflowBundle wfBundle;
-
-    @Before
-    public void loadWf() throws ReaderException, IOException {
-        wfBundle = workflowBundleIO.readBundle(getClass().getResource("/hello_anyone.wfbundle"), 
-                "application/vnd.taverna.scufl2.workflow-bundle");
-    }
-
-    protected Date date(int year, int month, int date, int hourOfDay, int minute) {
-        GregorianCalendar cal = new GregorianCalendar(UTC);
-        cal.setTimeInMillis(0);
-        cal.set(year, month-1, date, hourOfDay, minute);
-        return cal.getTime();
-    }
-    
-    @Before
-    public void dummyReport() throws Exception {
-        wfReport = new WorkflowReport(wfBundle.getMainWorkflow());
-        dataBundle = DataBundles.createBundle();
-        wfReport.setDataBundle(dataBundle);
-        wfReport.setCreatedDate(date(2013,1,2,13,37));
-        wfReport.setStartedDate(date(2013,1,2,14,50));        
-        Invocation wfInvocation = new Invocation("wf0", null, wfReport);
-        wfInvocation.setStartedDate(date(2013,1,2,14,51));
-        wfInvocation.setCompletedDate(date(2013,12,30,23,50));
-
-        wfReport.addInvocation(wfInvocation);
-        
-        Path name = DataBundles.getPort(DataBundles.getInputs(dataBundle), "name");
-        DataBundles.setStringValue(name, "John Doe");
-        wfInvocation.getInputs().put("name", name);
-        
-        Path greeting = DataBundles.getPort(DataBundles.getOutputs(dataBundle), "greeting");
-        DataBundles.setStringValue(greeting, "Hello, John Doe");
-        wfInvocation.getOutputs().put("greeting", greeting);
-        
-        Path helloValue = DataBundles.getIntermediate(dataBundle, UUID.randomUUID());
-        Path concatenateOutput = DataBundles.getIntermediate(dataBundle, UUID.randomUUID());
-        
-        for (Processor p : wfBundle.getMainWorkflow().getProcessors()) {
-            ProcessorReport processorReport = new ProcessorReport(p);
-            processorReport.setJobsQueued(1);
-            processorReport.setJobsStarted(5);
-            processorReport.setJobsCompleted(3);
-            processorReport.setJobsCompletedWithErrors(2);
-                        
-            wfReport.addProcessorReport(processorReport);
-
-            processorReport.setCreatedDate(date(2013,2,1,0,0));
-            processorReport.setStartedDate(date(2013,2,2,0,0));
-            processorReport.setPausedDate(date(2013,2,3,0,0));
-            processorReport.setResumedDate(date(2013,2,4,0,0));
-            processorReport.setPausedDate(date(2013,2,5,0,0));
-            processorReport.setResumedDate(date(2013,2,6,0,0));
-            
-            Invocation pInvocation = new Invocation("proc-" + p.getName() + "0", wfInvocation, processorReport);
-
-            pInvocation.setStartedDate(date(2013,2,2,11,0));
-            pInvocation.setCompletedDate(date(2013,2,2,13,0));
-
-            if (p.getName().equals("hello")) {
-                pInvocation.getOutputs().put("value", helloValue);
-                DataBundles.setStringValue(helloValue, "Hello, ");
-            } else if (p.getName().equals("Concatenate_two_strings")) {
-                pInvocation.getInputs().put("string1", helloValue);
-                pInvocation.getInputs().put("string2", name);
-                pInvocation.getOutputs().put("output", concatenateOutput);
-                DataBundles.setStringValue(concatenateOutput, "Hello, John Doe");
-            } else {
-                throw new Exception("Unexpected processor " + p);
-            }
-            processorReport.addInvocation(pInvocation);
-            
-            for (ProcessorBinding b : scufl2Tools.processorBindingsForProcessor(p, wfBundle.getMainProfile())) {
-                ActivityReport activityReport = new ActivityReport(b.getBoundActivity());
-                processorReport.addActivityReport(activityReport);
-                activityReport.setCreatedDate(date(2013,2,20,0,0));
-                activityReport.setStartedDate(date(2013,2,20,11,00));
-                activityReport.setCancelledDate(date(2013,2,21,11,30));
-                Invocation aInvocation = new Invocation("act-" + p.getName() + "0", pInvocation, activityReport);
-
-                aInvocation.setStartedDate(date(2013,2,20,11,30));
-//                aInvocation.setCompletedDate(date(2013,2,20,12,0));
-
-                activityReport.addInvocation(aInvocation);
-                aInvocation.getInputs().putAll(pInvocation.getInputs());
-                aInvocation.getOutputs().putAll(pInvocation.getOutputs());
-            }
-//            processorReport.setFailedDate(date(2013,7,28,23,59));
-            // In the summer to check that daylight saving does not sneak in
-            processorReport.setCompletedDate(date(2013,7,28,12,00));
-        }
-        wfReport.setCompletedDate(date(2013,12,31,0,0));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-impl/src/test/java/uk/org/taverna/platform/run/impl/RunTest.java
----------------------------------------------------------------------
diff --git a/taverna-run-impl/src/test/java/uk/org/taverna/platform/run/impl/RunTest.java b/taverna-run-impl/src/test/java/uk/org/taverna/platform/run/impl/RunTest.java
deleted file mode 100644
index 38c2f8f..0000000
--- a/taverna-run-impl/src/test/java/uk/org/taverna/platform/run/impl/RunTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package uk.org.taverna.platform.run.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.UUID;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.apache.taverna.robundle.Bundle;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-import org.apache.taverna.databundle.DataBundles;
-import uk.org.taverna.platform.execution.api.ExecutionEnvironment;
-import uk.org.taverna.platform.execution.api.ExecutionService;
-import uk.org.taverna.platform.report.State;
-import uk.org.taverna.platform.run.api.RunProfile;
-import org.apache.taverna.scufl2.api.io.WorkflowBundleIO;
-
-public class RunTest extends DummyWorkflowReport {
-
-    private static final WorkflowBundleIO workflowBundleIO = new WorkflowBundleIO();
-    private Run run;
-
-    public ExecutionEnvironment mockExecution() throws Exception {
-        ExecutionService exService = mock(ExecutionService.class);
-        when(exService.createExecution(null,null,null,null,null)).thenReturn("id0");
-        ExecutionEnvironment execution = mock(ExecutionEnvironment.class);
-        when(execution.getExecutionService()).thenReturn(exService);
-        when(exService.getWorkflowReport(null)).thenReturn(wfReport);
-        return execution;
-    }
-    
-    @Before
-    public void makeRun() throws Exception {
-        RunProfile runProfile = new RunProfile(mockExecution(), wfBundle, dataBundle);
-        run = new Run(runProfile);
-    }
-
-    @Test
-    public void getID() throws Exception {
-        assertEquals(4, UUID.fromString(run.getID()).version());
-    }
-    
-    @Test
-    public void getBundle() throws Exception {
-        Bundle bundle = run.getDataBundle();
-        // Contains a copy of workflow
-        assertEquals(wfBundle.getGlobalBaseURI(),
-                DataBundles.getWorkflowBundle(bundle).getGlobalBaseURI());
-        // Contains a run report
-        Path runReport = DataBundles.getWorkflowRunReport(bundle);
-        assertTrue(Files.exists(runReport));
-        JsonNode runReportJson = DataBundles.getWorkflowRunReportAsJson(bundle);
-        assertEquals("COMPLETED", runReportJson.get("state").asText());
-    }
-    
-
-    @Test
-    public void getState() throws Exception {
-        assertEquals(State.COMPLETED, run.getState());
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-run-impl/src/test/java/uk/org/taverna/platform/run/impl/WorkflowReportJSONTest.java
----------------------------------------------------------------------
diff --git a/taverna-run-impl/src/test/java/uk/org/taverna/platform/run/impl/WorkflowReportJSONTest.java b/taverna-run-impl/src/test/java/uk/org/taverna/platform/run/impl/WorkflowReportJSONTest.java
deleted file mode 100644
index 4e566e2..0000000
--- a/taverna-run-impl/src/test/java/uk/org/taverna/platform/run/impl/WorkflowReportJSONTest.java
+++ /dev/null
@@ -1,288 +0,0 @@
-package uk.org.taverna.platform.run.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.*;
-
-import java.io.InputStream;
-import java.net.URI;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Arrays;
-
-import org.junit.After;
-import org.junit.Test;
-import org.apache.taverna.robundle.Bundle;
-
-import org.apache.taverna.databundle.DataBundles;
-import uk.org.taverna.platform.report.ActivityReport;
-import uk.org.taverna.platform.report.Invocation;
-import uk.org.taverna.platform.report.ProcessorReport;
-import uk.org.taverna.platform.report.State;
-import uk.org.taverna.platform.report.WorkflowReport;
-import org.apache.taverna.scufl2.api.common.URITools;
-import org.apache.taverna.scufl2.api.core.Processor;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class WorkflowReportJSONTest extends DummyWorkflowReport {
-    
-    private final WorkflowReportJSON workflowReportJson = new WorkflowReportJSON();
-
-
-    @Test
-    public void save() throws Exception {
-        workflowReportJson.save(wfReport, dataBundle);
-        Path path = wfReport.getDataBundle().getRoot().resolve("/workflowrun.json");
-        assertTrue("Did not save to expected path "  + path, Files.exists(path));
-
-//        System.out.println(DataBundles.getStringValue(path));
-        
-        JsonNode json;
-        try (InputStream jsonIn = Files.newInputStream(path)) {
-            json = new ObjectMapper().readTree(jsonIn);
-        }
-        assertEquals("COMPLETED", json.get("state").asText());
-        assertEquals("2013-01-02T13:37:00.000+0000", json.get("createdDate").asText());
-        assertEquals("2013-01-02T14:50:00.000+0000", json.get("startedDate").asText());
-        assertEquals("2013-12-31T00:00:00.000+0000", json.get("completedDate").asText());
-        String wfId = wfBundle.getGlobalBaseURI().toString();
-        assertEquals(wfId + "workflow/Hello_Anyone/", 
-                json.get("subject").asText());
-        
-        // workflow invocation
-        JsonNode wfInvoc = json.get("invocations").get(0);
-        assertEquals("wf0", wfInvoc.get("id").asText());
-        assertEquals("wf0", wfInvoc.get("name").asText());
-        
-        assertEquals("2013-01-02T14:51:00.000+0000", wfInvoc.get("startedDate").asText());
-        assertEquals("2013-12-30T23:50:00.000+0000", wfInvoc.get("completedDate").asText());
-
-        String inputsName = wfInvoc.get("inputs").get("name").asText();
-        assertEquals("/inputs/name", inputsName);
-        String outputsGreeting = wfInvoc.get("outputs").get("greeting").asText();
-        assertEquals("/outputs/greeting", outputsGreeting);
-        assertEquals(
-                "John Doe",
-                DataBundles.getStringValue(wfReport.getDataBundle().getRoot()
-                        .resolve(inputsName)));        
-        assertEquals(
-                "Hello, John Doe",
-                DataBundles.getStringValue(wfReport.getDataBundle().getRoot()
-                        .resolve(outputsGreeting)));        
-
-        // NOTE: This assumes alphabetical ordering when constructing
-        // processor reports - which generally is given as
-        // Workflow.getProcessors() is sorted.
-        JsonNode proc0 = json.get("processorReports").get(0);
-        assertEquals(wfId + "workflow/Hello_Anyone/processor/Concatenate_two_strings/",
-                proc0.get("subject").asText());
-        assertEquals("COMPLETED", proc0.get("state").asText());
-        assertEquals("2013-02-01T00:00:00.000+0000", proc0.get("createdDate").asText());
-        assertEquals("2013-02-02T00:00:00.000+0000", proc0.get("startedDate").asText());
-        assertEquals("2013-02-03T00:00:00.000+0000", proc0.get("pausedDates").get(0).asText());
-        assertEquals("2013-02-05T00:00:00.000+0000", proc0.get("pausedDates").get(1).asText());
-        assertEquals("2013-02-05T00:00:00.000+0000", proc0.get("pausedDate").asText());
-
-        assertEquals("2013-02-04T00:00:00.000+0000", proc0.get("resumedDates").get(0).asText());
-        assertEquals("2013-02-06T00:00:00.000+0000", proc0.get("resumedDates").get(1).asText());
-        assertEquals("2013-02-06T00:00:00.000+0000", proc0.get("resumedDate").asText());
-
-        assertEquals("2013-07-28T12:00:00.000+0000", proc0.get("completedDate").asText());
-
-        // processor invocations
-        JsonNode pInvoc0 = proc0.get("invocations").get(0);
-        assertEquals("proc-Concatenate_two_strings0", pInvoc0.get("name").asText());
-        assertEquals("wf0/proc-Concatenate_two_strings0", pInvoc0.get("id").asText());
-        assertEquals("wf0", pInvoc0.get("parent").asText());
-
-        String inputString1 = pInvoc0.get("inputs").get("string1").asText();
-        assertTrue(inputString1.startsWith("/intermediates/"));
-        assertEquals(
-                "Hello, ",
-                DataBundles.getStringValue(wfReport.getDataBundle().getRoot()
-                        .resolve(inputString1)));        
-        
-        String inputString2 = pInvoc0.get("inputs").get("string2").asText();
-        assertEquals("/inputs/name", inputString2);
-        String output = pInvoc0.get("outputs").get("output").asText();
-        assertTrue(output.startsWith("/intermediates/"));
-        assertEquals(
-                "Hello, John Doe",
-                DataBundles.getStringValue(wfReport.getDataBundle().getRoot()
-                        .resolve(output)));        
-
-        // Activity reports
-        JsonNode act0 = proc0.get("activityReports").get(0);
-        assertEquals("CANCELLED", act0.get("state").asText());
-        assertEquals(wfId + "profile/taverna-2.4.0/activity/Concatenate_two_strings/", 
-                act0.get("subject").asText());
-        
-        
-        // activity invocation
-        JsonNode aInvoc0 = act0.get("invocations").get(0);
-
-        assertEquals("act-Concatenate_two_strings0", aInvoc0.get("name").asText());
-        assertEquals("wf0/proc-Concatenate_two_strings0/act-Concatenate_two_strings0", aInvoc0.get("id").asText());
-        assertEquals("wf0/proc-Concatenate_two_strings0", aInvoc0.get("parent").asText());
-
-        String actInputString1 = aInvoc0.get("inputs").get("string1").asText();
-        assertTrue(actInputString1.startsWith("/intermediates/"));
-        assertEquals(
-                "Hello, ",
-                DataBundles.getStringValue(wfReport.getDataBundle().getRoot()
-                        .resolve(actInputString1)));        
-        
-        String actInputString2 = aInvoc0.get("inputs").get("string2").asText();
-        assertEquals("/inputs/name", actInputString2);
-        String actOutput = pInvoc0.get("outputs").get("output").asText();
-        assertTrue(actOutput.startsWith("/intermediates/"));
-        assertEquals(
-                "Hello, John Doe",
-                DataBundles.getStringValue(wfReport.getDataBundle().getRoot()
-                        .resolve(actOutput)));        
-
-        
-        
-        
-        JsonNode proc1 = json.get("processorReports").get(1);
-        assertEquals(wfId + "workflow/Hello_Anyone/processor/hello/",
-                proc1.get("subject").asText());
-        assertEquals("COMPLETED", proc1.get("state").asText());
-        assertEquals("2013-02-01T00:00:00.000+0000", proc1.get("createdDate").asText());
-        assertEquals("2013-02-02T00:00:00.000+0000", proc1.get("startedDate").asText());
-        // etc.
-
-        JsonNode pInvoc1 = proc1.get("invocations").get(0);
-
-        String value = pInvoc1.get("outputs").get("value").asText();
-        assertTrue(value.startsWith("/intermediates/"));
-        assertEquals(
-                "Hello, ",
-                DataBundles.getStringValue(wfReport.getDataBundle().getRoot()
-                        .resolve(value)));        
-        assertEquals(inputString1, value);
-    }
-    
-    @Test
-    public void load() throws Exception {
-        URI bundleUri = getClass().getResource("/workflowrun.bundle.zip").toURI();
-        Path bundlePath = Paths.get(bundleUri);
-        try (Bundle bundle = DataBundles.openBundle(bundlePath)) {
-            WorkflowReport wfReport = workflowReportJson.load(bundle);
-            assertEquals(State.COMPLETED, wfReport.getState());
-            assertNull(wfReport.getParentReport());
-            
-            assertEquals(wfBundle.getMainWorkflow().getName(), wfReport.getSubject().getName());
-            URI mainWf = new URITools().uriForBean(wfBundle.getMainWorkflow());
-            assertEquals(mainWf, wfReport.getSubjectURI());
-            
-            assertEquals(date(2013,1,2,13,37), wfReport.getCreatedDate());
-            assertEquals(date(2013,1,2,14,50), wfReport.getStartedDate());
-            assertEquals(date(2013,12,31,0,0), wfReport.getCompletedDate());
-            assertNull(wfReport.getCancelledDate());
-            assertNull(wfReport.getResumedDate());
-            assertNull(wfReport.getPausedDate());
-            assertTrue(wfReport.getResumedDates().isEmpty());
-            assertTrue(wfReport.getPausedDates().isEmpty());
-            
-            // wf invocation
-            assertEquals(1, wfReport.getInvocations().size());
-            Invocation wfInvov = wfReport.getInvocations().first();
-            assertEquals("wf0", wfInvov.getName());
-            assertEquals("wf0", wfInvov.getId());
-            assertNull(wfInvov.getParentId());
-            assertNull(wfInvov.getParent());
-            assertEquals(0, wfInvov.getIndex().length);
-            assertSame(wfReport, wfInvov.getReport());
-            assertEquals(State.COMPLETED, wfInvov.getState());
-
-            assertEquals(date(2013,1,2,14,51), wfInvov.getStartedDate());
-            assertEquals(date(2013,12,30,23,50), wfInvov.getCompletedDate());
-
-            // wf invocation in/out
-            assertEquals(1, wfInvov.getInputs().size());
-            assertEquals(1, wfInvov.getOutputs().size());
-            
-            Path name = wfInvov.getInputs().get("name");
-            assertEquals("/inputs/name", name.toString());
-            assertEquals("John Doe", DataBundles.getStringValue(name));
-            
-            Path greeting = wfInvov.getOutputs().get("greeting");
-            assertEquals("/outputs/greeting", greeting.toString());
-            assertEquals("Hello, John Doe", DataBundles.getStringValue(greeting));
-            
-            
-            // processor reports
-            assertEquals(2, wfReport.getProcessorReports().size());
-            for (ProcessorReport procRepo : wfReport.getProcessorReports()) {
-                Processor processor = procRepo.getSubject();
-                assertTrue(wfBundle.getMainWorkflow().getProcessors().containsName(processor.getName()));
-                assertEquals(1, procRepo.getJobsQueued());
-                assertEquals(2, procRepo.getJobsCompletedWithErrors());
-                assertEquals(3, procRepo.getJobsCompleted());
-                assertEquals(5, procRepo.getJobsStarted());
-                
-
-                assertEquals(date(2013,2,1,00,00), procRepo.getCreatedDate());
-                assertEquals(date(2013,2,2,00,00), procRepo.getStartedDate());
-                assertEquals(date(2013,7,28,12,0), procRepo.getCompletedDate());
-                assertEquals(date(2013,2,5,0,0), procRepo.getPausedDate());
-                assertEquals(Arrays.asList(date(2013,2,3,0,0), date(2013,2,5,0,0)),
-                        procRepo.getPausedDates());
-                assertEquals(date(2013,2,6,0,0), procRepo.getResumedDate());
-                assertEquals(Arrays.asList(date(2013,2,4,0,0), date(2013,2,6,0,0)),
-                        procRepo.getResumedDates());
-
-                assertEquals(date(2013,7,28,12,0), procRepo.getCompletedDate());
-                
-                assertEquals(1, procRepo.getInvocations().size());
-                Invocation pInvoc = procRepo.getInvocations().first();
-                assertEquals(date(2013,2,2,11,00), pInvoc.getStartedDate());
-                assertEquals(date(2013,2,2,13,00), pInvoc.getCompletedDate());
-                assertEquals(State.COMPLETED, pInvoc.getState());
-                assertEquals(wfInvov, pInvoc.getParent());
-                assertEquals("wf0", pInvoc.getParentId());                
-                if (processor.getName().equals("hello")) {
-                    assertEquals("proc-hello0", pInvoc.getName());
-                    assertEquals("wf0/proc-hello0", pInvoc.getId());
-                    assertEquals(0, pInvoc.getInputs().size());
-                    assertEquals(1, pInvoc.getOutputs().size());
-                    assertEquals("Hello, ", DataBundles.getStringValue(pInvoc.getOutputs().get("value")));
-                } else if (processor.getName().equals("Concatenate_two_strings")) {
-                    assertEquals("proc-Concatenate_two_strings0", pInvoc.getName());
-                    assertEquals("wf0/proc-Concatenate_two_strings0", pInvoc.getId());
-                    assertEquals(2, pInvoc.getInputs().size());
-                    assertEquals("Hello, ", DataBundles.getStringValue(pInvoc.getInputs().get("string1")));
-                    assertEquals("John Doe", DataBundles.getStringValue(pInvoc.getInputs().get("string2")));
-
-                    assertEquals(1, pInvoc.getOutputs().size());
-                    assertEquals("Hello, John Doe", DataBundles.getStringValue(pInvoc.getOutputs().get("output")));                    
-                } else {
-                    fail("Unknown processor: " + processor.getName());
-                }
-                
-                assertEquals(1, procRepo.getActivityReports().size());
-                for (ActivityReport actRepo : procRepo.getActivityReports()) {
-                    assertEquals(procRepo, actRepo.getParentReport());
-                    assertEquals(State.CANCELLED, actRepo.getState());
-                    assertEquals(date(2013,2,20,00,00), actRepo.getCreatedDate());
-                    assertEquals(date(2013,2,20,11,00), actRepo.getStartedDate());
-                    assertEquals(date(2013,2,21,11,30), actRepo.getCancelledDate());                   
-                    // TODO: Test nested workflow
-                }
-            }
-        }
-        
-    }
-    
-    @After
-    public void closeBundle() throws Exception {
-        Path saved = dataBundle.getSource().resolveSibling("workflowrun.bundle.zip");
-        DataBundles.closeAndSaveBundle(dataBundle, saved);
-        System.out.println("Saved to " + saved);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-services-api/src/main/java/org/apache/taverna/commons/services/ActivityTypeNotFoundException.java
----------------------------------------------------------------------
diff --git a/taverna-services-api/src/main/java/org/apache/taverna/commons/services/ActivityTypeNotFoundException.java b/taverna-services-api/src/main/java/org/apache/taverna/commons/services/ActivityTypeNotFoundException.java
new file mode 100644
index 0000000..b260f91
--- /dev/null
+++ b/taverna-services-api/src/main/java/org/apache/taverna/commons/services/ActivityTypeNotFoundException.java
@@ -0,0 +1,46 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.commons.services;
+
+/**
+ * Thrown when an activity type is not found.
+ *
+ * @author David Withers
+ */
+@SuppressWarnings("serial")
+public class ActivityTypeNotFoundException extends Exception {
+
+	public ActivityTypeNotFoundException() {
+		super();
+	}
+
+	public ActivityTypeNotFoundException(String message) {
+		super(message);
+	}
+
+	public ActivityTypeNotFoundException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+	public ActivityTypeNotFoundException(Throwable cause) {
+		super(cause);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-services-api/src/main/java/org/apache/taverna/commons/services/InvalidConfigurationException.java
----------------------------------------------------------------------
diff --git a/taverna-services-api/src/main/java/org/apache/taverna/commons/services/InvalidConfigurationException.java b/taverna-services-api/src/main/java/org/apache/taverna/commons/services/InvalidConfigurationException.java
new file mode 100644
index 0000000..35a1db8
--- /dev/null
+++ b/taverna-services-api/src/main/java/org/apache/taverna/commons/services/InvalidConfigurationException.java
@@ -0,0 +1,46 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.commons.services;
+
+/**
+ * Thrown when a Configuration is not valid for a Configurable.
+ *
+ * @author David Withers
+ */
+@SuppressWarnings("serial")
+public class InvalidConfigurationException extends Exception {
+
+	public InvalidConfigurationException() {
+		super();
+	}
+
+	public InvalidConfigurationException(String message) {
+		super(message);
+	}
+
+	public InvalidConfigurationException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+	public InvalidConfigurationException(Throwable cause) {
+		super(cause);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-services-api/src/main/java/org/apache/taverna/commons/services/ServiceRegistry.java
----------------------------------------------------------------------
diff --git a/taverna-services-api/src/main/java/org/apache/taverna/commons/services/ServiceRegistry.java b/taverna-services-api/src/main/java/org/apache/taverna/commons/services/ServiceRegistry.java
new file mode 100644
index 0000000..7411dd2
--- /dev/null
+++ b/taverna-services-api/src/main/java/org/apache/taverna/commons/services/ServiceRegistry.java
@@ -0,0 +1,88 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.commons.services;
+
+import java.net.URI;
+import java.util.Set;
+
+import org.apache.taverna.scufl2.api.port.InputActivityPort;
+import org.apache.taverna.scufl2.api.port.OutputActivityPort;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * Register of Taverna services.
+ *
+ * @author David Withers
+ */
+public interface ServiceRegistry {
+
+	/**
+	 * Returns the activity types in the registry.
+	 *
+	 * @return the activity types in the registry
+	 */
+	public Set<URI> getActivityTypes();
+
+	/**
+	 * Returns the JSON Schema for the configuration required by an activity.
+	 *
+	 * @param activityType
+	 *            the activity type
+	 * @return the JSON Schema for the configuration required by an activity
+	 * @throws ActivityTypeNotFoundException
+	 *             if the activity type is not in the registry
+	 */
+	public JsonNode getActivityConfigurationSchema(URI activityType)
+			throws InvalidConfigurationException, ActivityTypeNotFoundException;
+
+	/**
+	 * Returns the input ports that the activity type requires to be present in order to execute
+	 * with the specified configuration.
+	 * <p>
+	 * If the activity does not require any input port for the configuration then an empty set is
+	 * returned.
+	 *
+	 * @param configuration
+	 *            the activity configuration
+	 * @throws ActivityTypeNotFoundException
+	 *             if the activity type is not in the registry
+	 * @return the input ports that the activity requires to be present in order to execute
+	 */
+	public Set<InputActivityPort> getActivityInputPorts(URI activityType,
+			JsonNode configuration) throws InvalidConfigurationException, ActivityTypeNotFoundException;
+
+	/**
+	 * Returns the output ports that the activity type requires to be present in order to execute
+	 * with the specified configuration.
+	 * <p>
+	 * If the activity type does not require any output ports for the configuration then an empty
+	 * set is returned.
+	 *
+	 * @param configuration
+	 *            the activity configuration
+	 * @throws ActivityTypeNotFoundException
+	 *             if the activity type is not in the registry
+	 * @return the output ports that the activity requires to be present in order to execute
+	 */
+	public Set<OutputActivityPort> getActivityOutputPorts(URI activityType,
+			JsonNode configuration) throws InvalidConfigurationException, ActivityTypeNotFoundException;
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-services-api/src/main/java/uk/org/taverna/commons/services/ActivityTypeNotFoundException.java
----------------------------------------------------------------------
diff --git a/taverna-services-api/src/main/java/uk/org/taverna/commons/services/ActivityTypeNotFoundException.java b/taverna-services-api/src/main/java/uk/org/taverna/commons/services/ActivityTypeNotFoundException.java
deleted file mode 100644
index dafccd7..0000000
--- a/taverna-services-api/src/main/java/uk/org/taverna/commons/services/ActivityTypeNotFoundException.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.commons.services;
-
-/**
- * Thrown when an activity type is not found.
- *
- * @author David Withers
- */
-@SuppressWarnings("serial")
-public class ActivityTypeNotFoundException extends Exception {
-
-	public ActivityTypeNotFoundException() {
-		super();
-	}
-
-	public ActivityTypeNotFoundException(String message) {
-		super(message);
-	}
-
-	public ActivityTypeNotFoundException(String message, Throwable cause) {
-		super(message, cause);
-	}
-
-	public ActivityTypeNotFoundException(Throwable cause) {
-		super(cause);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-services-api/src/main/java/uk/org/taverna/commons/services/InvalidConfigurationException.java
----------------------------------------------------------------------
diff --git a/taverna-services-api/src/main/java/uk/org/taverna/commons/services/InvalidConfigurationException.java b/taverna-services-api/src/main/java/uk/org/taverna/commons/services/InvalidConfigurationException.java
deleted file mode 100644
index 0f118d6..0000000
--- a/taverna-services-api/src/main/java/uk/org/taverna/commons/services/InvalidConfigurationException.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.commons.services;
-
-/**
- * Thrown when a Configuration is not valid for a Configurable.
- *
- * @author David Withers
- */
-@SuppressWarnings("serial")
-public class InvalidConfigurationException extends Exception {
-
-	public InvalidConfigurationException() {
-		super();
-	}
-
-	public InvalidConfigurationException(String message) {
-		super(message);
-	}
-
-	public InvalidConfigurationException(String message, Throwable cause) {
-		super(message, cause);
-	}
-
-	public InvalidConfigurationException(Throwable cause) {
-		super(cause);
-	}
-
-}


[10/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/utils/Tools.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/utils/Tools.java b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/utils/Tools.java
new file mode 100644
index 0000000..cb4b3f2
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/java/org/apache/taverna/workflowmodel/utils/Tools.java
@@ -0,0 +1,794 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.utils;
+
+import static java.lang.Character.isLetterOrDigit;
+import static org.apache.taverna.workflowmodel.utils.AnnotationTools.addAnnotation;
+import static org.apache.taverna.workflowmodel.utils.AnnotationTools.getAnnotation;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import org.apache.taverna.annotation.annotationbeans.IdentificationAssertion;
+import org.apache.taverna.workflowmodel.CompoundEdit;
+import org.apache.taverna.workflowmodel.Dataflow;
+import org.apache.taverna.workflowmodel.DataflowInputPort;
+import org.apache.taverna.workflowmodel.DataflowOutputPort;
+import org.apache.taverna.workflowmodel.Datalink;
+import org.apache.taverna.workflowmodel.Edit;
+import org.apache.taverna.workflowmodel.EditException;
+import org.apache.taverna.workflowmodel.Edits;
+import org.apache.taverna.workflowmodel.EventForwardingOutputPort;
+import org.apache.taverna.workflowmodel.EventHandlingInputPort;
+import org.apache.taverna.workflowmodel.InputPort;
+import org.apache.taverna.workflowmodel.Merge;
+import org.apache.taverna.workflowmodel.MergeInputPort;
+import org.apache.taverna.workflowmodel.MergeOutputPort;
+import org.apache.taverna.workflowmodel.NamedWorkflowEntity;
+import org.apache.taverna.workflowmodel.OutputPort;
+import org.apache.taverna.workflowmodel.Port;
+import org.apache.taverna.workflowmodel.Processor;
+import org.apache.taverna.workflowmodel.ProcessorInputPort;
+import org.apache.taverna.workflowmodel.ProcessorOutputPort;
+import org.apache.taverna.workflowmodel.TokenProcessingEntity;
+import org.apache.taverna.workflowmodel.processor.activity.Activity;
+import org.apache.taverna.workflowmodel.processor.activity.ActivityConfigurationException;
+import org.apache.taverna.workflowmodel.processor.activity.ActivityInputPort;
+import org.apache.taverna.workflowmodel.processor.activity.ActivityOutputPort;
+import org.apache.taverna.workflowmodel.processor.activity.DisabledActivity;
+import org.apache.taverna.workflowmodel.processor.activity.NestedDataflow;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Various workflow model tools that can be helpful when constructing a
+ * dataflow.
+ * <p>
+ * Not to be confused with the @deprecated
+ * {@link org.apache.taverna.workflowmodel.impl.Tools}
+ * 
+ * @author David Withers
+ * @author Stian Soiland-Reyes
+ */
+public class Tools {
+	private static Logger logger = Logger.getLogger(Tools.class);
+
+	// private static Edits edits = new EditsImpl();
+
+	/**
+	 * Find (and possibly create) an EventHandlingInputPort.
+	 * <p>
+	 * If the given inputPort is an instance of {@link EventHandlingInputPort},
+	 * it is returned directly. If it is an ActivityInputPort - the owning
+	 * processors (found by searching the dataflow) will be searced for a mapped
+	 * input port. If this cannot be found, one will be created and mapped. The
+	 * edits for this will be added to the editList and needs to be executed by
+	 * the caller.
+	 * 
+	 * @see #findEventHandlingOutputPort(List, Dataflow, OutputPort)
+	 * @param editList
+	 *            List of {@link Edit}s to append any required edits (yet to be
+	 *            performed) to
+	 * @param dataflow
+	 *            Dataflow containing the processors
+	 * @param inputPort
+	 *            An EventHandlingInputPort or ActivityInputPort
+	 * @return The found or created EventHandlingInputPort
+	 */
+	protected static EventHandlingInputPort findEventHandlingInputPort(
+			List<Edit<?>> editList, Dataflow dataflow, InputPort inputPort,
+			Edits edits) {
+		if (inputPort instanceof EventHandlingInputPort)
+			return (EventHandlingInputPort) inputPort;
+		else if (!(inputPort instanceof ActivityInputPort))
+			throw new IllegalArgumentException("Unknown input port type for "
+					+ inputPort);
+
+		ActivityInputPort activityInput = (ActivityInputPort) inputPort;
+		Collection<Processor> processors = getProcessorsWithActivityInputPort(
+				dataflow, activityInput);
+		if (processors.isEmpty())
+			throw new IllegalArgumentException("Can't find ActivityInputPort "
+					+ activityInput.getName() + " in workflow " + dataflow);
+
+		// FIXME: Assumes only one matching processor
+		Processor processor = processors.iterator().next();
+		Activity<?> activity = null;
+		for (Activity<?> checkActivity : processor.getActivityList())
+			if (checkActivity.getInputPorts().contains(activityInput)) {
+				activity = checkActivity;
+				break;
+			}
+		if (activity == null)
+			throw new IllegalArgumentException("Can't find activity for port "
+					+ activityInput.getName() + "within processor " + processor);
+
+		ProcessorInputPort input = getProcessorInputPort(processor, activity,
+				activityInput);
+		if (input != null)
+			return input;
+		// port doesn't exist so create a processor port and map it
+		String processorPortName = uniquePortName(activityInput.getName(),
+				processor.getInputPorts());
+		ProcessorInputPort processorInputPort = edits.createProcessorInputPort(
+				processor, processorPortName, activityInput.getDepth());
+		editList.add(edits.getAddProcessorInputPortEdit(processor,
+				processorInputPort));
+		editList.add(edits.getAddActivityInputPortMappingEdit(activity,
+				processorPortName, activityInput.getName()));
+		return processorInputPort;
+	}
+
+	/**
+	 * Find (and possibly create) an EventForwardingOutputPort.
+	 * <p>
+	 * If the given outputPort is an instance of
+	 * {@link EventForwardingOutputPort}, it is returned directly. If it is an
+	 * ActivityOutputPort - the owning processors (found by searching the
+	 * dataflow) will be searced for a mapped output port. If this cannot be
+	 * found, one will be created and mapped. The edits for this will be added
+	 * to the editList and needs to be executed by the caller.
+	 * 
+	 * @see #findEventHandlingInputPort(List, Dataflow, InputPort)
+	 * @param editList
+	 *            List of {@link Edit}s to append any required edits (yet to be
+	 *            performed) to
+	 * @param dataflow
+	 *            Dataflow containing the processors
+	 * @param outputPort
+	 *            An EventForwardingOutputPort or ActivityOutputPort
+	 * @return The found or created EventForwardingOutputPort
+	 */
+	protected static EventForwardingOutputPort findEventHandlingOutputPort(
+			List<Edit<?>> editList, Dataflow dataflow, OutputPort outputPort,
+			Edits edits) {
+		if (outputPort instanceof EventForwardingOutputPort)
+			return (EventForwardingOutputPort) outputPort;
+		else if (!(outputPort instanceof ActivityOutputPort))
+			throw new IllegalArgumentException("Unknown output port type for "
+					+ outputPort);
+
+		ActivityOutputPort activityOutput = (ActivityOutputPort) outputPort;
+		Collection<Processor> processors = getProcessorsWithActivityOutputPort(
+				dataflow, activityOutput);
+		if (processors.isEmpty())
+			throw new IllegalArgumentException("Can't find ActivityOutputPort "
+					+ activityOutput.getName() + " in workflow " + dataflow);
+
+		// FIXME: Assumes only one matching processor
+		Processor processor = processors.iterator().next();
+		Activity<?> activity = null;
+		for (Activity<?> checkActivity : processor.getActivityList())
+			if (checkActivity.getOutputPorts().contains(activityOutput)) {
+				activity = checkActivity;
+				break;
+			}
+		if (activity == null)
+			throw new IllegalArgumentException("Can't find activity for port "
+					+ activityOutput.getName() + "within processor "
+					+ processor);
+
+		ProcessorOutputPort processorOutputPort = Tools.getProcessorOutputPort(
+				processor, activity, activityOutput);
+		if (processorOutputPort != null)
+			return processorOutputPort;
+
+		// port doesn't exist so create a processor port and map it
+		String processorPortName = uniquePortName(activityOutput.getName(),
+				processor.getOutputPorts());
+		processorOutputPort = edits.createProcessorOutputPort(processor,
+				processorPortName, activityOutput.getDepth(),
+				activityOutput.getGranularDepth());
+		editList.add(edits.getAddProcessorOutputPortEdit(processor,
+				processorOutputPort));
+		editList.add(edits.getAddActivityOutputPortMappingEdit(activity,
+				processorPortName, activityOutput.getName()));
+
+		return processorOutputPort;
+	}
+
+	/**
+	 * Creates an Edit that creates a Datalink between a source and sink port
+	 * and connects the Datalink.
+	 * 
+	 * If the sink port already has a Datalink connected this method checks if a
+	 * new Merge is required and creates and connects the required Datalinks.
+	 * 
+	 * @param dataflow
+	 *            the Dataflow to add the Datalink to
+	 * @param source
+	 *            the source of the Datalink
+	 * @param sink
+	 *            the source of the Datalink
+	 * @return an Edit that creates a Datalink between a source and sink port
+	 *         and connects the Datalink
+	 */
+	public static Edit<?> getCreateAndConnectDatalinkEdit(Dataflow dataflow,
+			EventForwardingOutputPort source, EventHandlingInputPort sink,
+			Edits edits) {
+		Edit<?> edit = null;
+
+		Datalink incomingLink = sink.getIncomingLink();
+		if (incomingLink == null) {
+			Datalink datalink = edits.createDatalink(source, sink);
+			edit = edits.getConnectDatalinkEdit(datalink);
+		} else {
+			List<Edit<?>> editList = new ArrayList<>();
+
+			Merge merge = null;
+			int counter = 0; // counter for merge input port names
+			if (incomingLink.getSource() instanceof MergeOutputPort)
+				merge = ((MergeOutputPort) incomingLink.getSource()).getMerge();
+			else {
+				merge = edits.createMerge(dataflow);
+				editList.add(edits.getAddMergeEdit(dataflow, merge));
+				editList.add(edits.getDisconnectDatalinkEdit(incomingLink));
+				MergeInputPort mergeInputPort = edits.createMergeInputPort(
+						merge,
+						getUniqueMergeInputPortName(merge,
+								incomingLink.getSource().getName() + "To"
+										+ merge.getLocalName() + "_input",
+								counter++), incomingLink.getSink().getDepth());
+				editList.add(edits.getAddMergeInputPortEdit(merge,
+						mergeInputPort));
+				Datalink datalink = edits.createDatalink(
+						incomingLink.getSource(), mergeInputPort);
+				editList.add(edits.getConnectDatalinkEdit(datalink));
+				datalink = edits.createDatalink(merge.getOutputPort(),
+						incomingLink.getSink());
+				editList.add(edits.getConnectDatalinkEdit(datalink));
+			}
+			MergeInputPort mergeInputPort = edits.createMergeInputPort(
+					merge,
+					getUniqueMergeInputPortName(merge, source.getName() + "To"
+							+ merge.getLocalName() + "_input", counter),
+					sink.getDepth());
+			editList.add(edits.getAddMergeInputPortEdit(merge, mergeInputPort));
+			Datalink datalink = edits.createDatalink(source, mergeInputPort);
+			editList.add(edits.getConnectDatalinkEdit(datalink));
+
+			edit = new CompoundEdit(editList);
+		}
+
+		return edit;
+	}
+
+	/**
+	 * Get an {@link Edit} that will link the given output port to the given
+	 * input port.
+	 * <p>
+	 * The output port can be an {@link EventForwardingOutputPort} (such as an
+	 * {@link ProcessorOutputPort}, or an {@link ActivityOutputPort}. The input
+	 * port can be an {@link EventHandlingInputPort} (such as an
+	 * {@link ProcessorInputPort}, or an {@link ActivityInputPort}.
+	 * <p>
+	 * If an input and/or output port is an activity port, processors in the
+	 * given dataflow will be searched for matching mappings, create the
+	 * processor port and mapping if needed, before constructing the edits for
+	 * adding the datalink.
+	 * 
+	 * @param dataflow
+	 *            Dataflow (indirectly) containing ports
+	 * @param outputPort
+	 *            An {@link EventForwardingOutputPort} or an
+	 *            {@link ActivityOutputPort}
+	 * @param inputPort
+	 *            An {@link EventHandlingInputPort} or an
+	 *            {@link ActivityInputPort}
+	 * @return A compound edit for creating and connecting the datalink and any
+	 *         neccessary processor ports and mappings
+	 */
+	public static Edit<?> getCreateAndConnectDatalinkEdit(Dataflow dataflow,
+			OutputPort outputPort, InputPort inputPort, Edits edits) {
+		List<Edit<?>> editList = new ArrayList<>();
+		EventHandlingInputPort sink = findEventHandlingInputPort(editList,
+				dataflow, inputPort, edits);
+		EventForwardingOutputPort source = findEventHandlingOutputPort(
+				editList, dataflow, outputPort, edits);
+		editList.add(getCreateAndConnectDatalinkEdit(dataflow, source, sink,
+				edits));
+		return new CompoundEdit(editList);
+	}
+
+	/**
+	 * Find a unique port name given a list of existing ports.
+	 * <p>
+	 * If needed, the returned port name will be prefixed with an underscore and
+	 * a number, starting from 2. (The original being 'number 1')
+	 * <p>
+	 * Although not strictly needed by Taverna, for added user friendliness the
+	 * case of the existing port names are ignored when checking for uniqueness.
+	 * 
+	 * @see #uniqueProcessorName(String, Dataflow)
+	 * 
+	 * @param suggestedPortName
+	 *            Port name suggested for new port
+	 * @param existingPorts
+	 *            Collection of existing {@link Port}s
+	 * @return A port name unique for the given collection of port
+	 */
+	public static String uniquePortName(String suggestedPortName,
+			Collection<? extends Port> existingPorts) {
+		// Make sure we have a unique port name
+		Set<String> existingNames = new HashSet<>();
+		for (Port existingPort : existingPorts)
+			existingNames.add(existingPort.getName().toLowerCase());
+		String candidateName = suggestedPortName;
+		long counter = 2;
+		while (existingNames.contains(candidateName.toLowerCase()))
+			candidateName = suggestedPortName + "_" + counter++;
+		return candidateName;
+	}
+
+	public static Edit<?> getMoveDatalinkSinkEdit(Dataflow dataflow,
+			Datalink datalink, EventHandlingInputPort sink, Edits edits) {
+		List<Edit<?>> editList = new ArrayList<>();
+		editList.add(edits.getDisconnectDatalinkEdit(datalink));
+		if (datalink.getSink() instanceof ProcessorInputPort)
+			editList.add(getRemoveProcessorInputPortEdit(
+					(ProcessorInputPort) datalink.getSink(), edits));
+		editList.add(getCreateAndConnectDatalinkEdit(dataflow,
+				datalink.getSource(), sink, edits));
+		return new CompoundEdit(editList);
+	}
+
+	public static Edit<?> getDisconnectDatalinkAndRemovePortsEdit(
+			Datalink datalink, Edits edits) {
+		List<Edit<?>> editList = new ArrayList<>();
+		editList.add(edits.getDisconnectDatalinkEdit(datalink));
+		if (datalink.getSource() instanceof ProcessorOutputPort) {
+			ProcessorOutputPort processorOutputPort = (ProcessorOutputPort) datalink
+					.getSource();
+			if (processorOutputPort.getOutgoingLinks().size() == 1)
+				editList.add(getRemoveProcessorOutputPortEdit(
+						processorOutputPort, edits));
+		}
+		if (datalink.getSink() instanceof ProcessorInputPort)
+			editList.add(getRemoveProcessorInputPortEdit(
+					(ProcessorInputPort) datalink.getSink(), edits));
+		return new CompoundEdit(editList);
+	}
+
+	public static Edit<?> getRemoveProcessorOutputPortEdit(
+			ProcessorOutputPort port, Edits edits) {
+		List<Edit<?>> editList = new ArrayList<>();
+		Processor processor = port.getProcessor();
+		editList.add(edits.getRemoveProcessorOutputPortEdit(
+				port.getProcessor(), port));
+		for (Activity<?> activity : processor.getActivityList())
+			editList.add(edits.getRemoveActivityOutputPortMappingEdit(activity,
+					port.getName()));
+		return new CompoundEdit(editList);
+	}
+
+	public static Edit<?> getRemoveProcessorInputPortEdit(
+			ProcessorInputPort port, Edits edits) {
+		List<Edit<?>> editList = new ArrayList<>();
+		Processor processor = port.getProcessor();
+		editList.add(edits.getRemoveProcessorInputPortEdit(port.getProcessor(),
+				port));
+		for (Activity<?> activity : processor.getActivityList())
+			editList.add(edits.getRemoveActivityInputPortMappingEdit(activity,
+					port.getName()));
+		return new CompoundEdit(editList);
+	}
+
+	public static Edit<?> getEnableDisabledActivityEdit(Processor processor,
+			DisabledActivity disabledActivity, Edits edits) {
+		List<Edit<?>> editList = new ArrayList<>();
+		Activity<?> brokenActivity = disabledActivity.getActivity();
+		try {
+			@SuppressWarnings("unchecked")
+			Activity<Object> ra = brokenActivity.getClass().newInstance();
+			Object lastConfig = disabledActivity.getLastWorkingConfiguration();
+			if (lastConfig == null)
+				lastConfig = disabledActivity.getActivityConfiguration();
+			ra.configure(lastConfig);
+
+			Map<String, String> portMapping = ra.getInputPortMapping();
+			Set<String> portNames = new HashSet<>();
+			portNames.addAll(portMapping.keySet());
+			for (String portName : portNames)
+				editList.add(edits.getRemoveActivityInputPortMappingEdit(ra,
+						portName));
+			portMapping = ra.getOutputPortMapping();
+			portNames.clear();
+			portNames.addAll(portMapping.keySet());
+			for (String portName : portNames)
+				editList.add(edits.getRemoveActivityOutputPortMappingEdit(ra,
+						portName));
+
+			portMapping = disabledActivity.getInputPortMapping();
+			for (String portName : portMapping.keySet())
+				editList.add(edits.getAddActivityInputPortMappingEdit(ra,
+						portName, portMapping.get(portName)));
+			portMapping = disabledActivity.getOutputPortMapping();
+			for (String portName : portMapping.keySet())
+				editList.add(edits.getAddActivityOutputPortMappingEdit(ra,
+						portName, portMapping.get(portName)));
+
+			editList.add(edits.getRemoveActivityEdit(processor,
+					disabledActivity));
+			editList.add(edits.getAddActivityEdit(processor, ra));
+		} catch (ActivityConfigurationException ex) {
+			logger.error("Configuration exception ", ex);
+			return null;
+		} catch (InstantiationException | IllegalAccessException e) {
+			return null;
+		}
+		return new CompoundEdit(editList);
+	}
+
+	public static ProcessorInputPort getProcessorInputPort(Processor processor,
+			Activity<?> activity, InputPort activityInputPort) {
+		ProcessorInputPort result = null;
+		for (Entry<String, String> mapEntry : activity.getInputPortMapping()
+				.entrySet())
+			if (mapEntry.getValue().equals(activityInputPort.getName())) {
+				for (ProcessorInputPort processorInputPort : processor
+						.getInputPorts())
+					if (processorInputPort.getName().equals(mapEntry.getKey())) {
+						result = processorInputPort;
+						break;
+					}
+				break;
+			}
+		return result;
+	}
+
+	public static ProcessorOutputPort getProcessorOutputPort(
+			Processor processor, Activity<?> activity,
+			OutputPort activityOutputPort) {
+		ProcessorOutputPort result = null;
+		for (Entry<String, String> mapEntry : activity.getOutputPortMapping()
+				.entrySet())
+			if (mapEntry.getValue().equals(activityOutputPort.getName())) {
+				for (ProcessorOutputPort processorOutputPort : processor
+						.getOutputPorts())
+					if (processorOutputPort.getName().equals(mapEntry.getKey())) {
+						result = processorOutputPort;
+						break;
+					}
+				break;
+			}
+		return result;
+	}
+
+	public static ActivityInputPort getActivityInputPort(Activity<?> activity,
+			String portName) {
+		ActivityInputPort activityInputPort = null;
+		for (ActivityInputPort inputPort : activity.getInputPorts())
+			if (inputPort.getName().equals(portName)) {
+				activityInputPort = inputPort;
+				break;
+			}
+		return activityInputPort;
+	}
+
+	public static OutputPort getActivityOutputPort(Activity<?> activity,
+			String portName) {
+		OutputPort activityOutputPort = null;
+		for (OutputPort outputPort : activity.getOutputPorts())
+			if (outputPort.getName().equals(portName)) {
+				activityOutputPort = outputPort;
+				break;
+			}
+		return activityOutputPort;
+	}
+
+	public static String getUniqueMergeInputPortName(Merge merge, String name,
+			int count) {
+		String uniqueName = name + count;
+		for (MergeInputPort mergeInputPort : merge.getInputPorts())
+			if (mergeInputPort.getName().equals(uniqueName))
+				return getUniqueMergeInputPortName(merge, name, ++count);
+		return uniqueName;
+	}
+
+	public static Collection<Processor> getProcessorsWithActivity(
+			Dataflow dataflow, Activity<?> activity) {
+		Set<Processor> processors = new HashSet<>();
+		for (Processor processor : dataflow.getProcessors())
+			if (processor.getActivityList().contains(activity))
+				processors.add(processor);
+		return processors;
+	}
+
+	public static Collection<Processor> getProcessorsWithActivityInputPort(
+			Dataflow dataflow, ActivityInputPort inputPort) {
+		Set<Processor> processors = new HashSet<>();
+		for (Processor processor : dataflow.getProcessors()) {
+			// Does it contain a nested workflow?
+			if (containsNestedWorkflow(processor))
+				// Get the nested workflow and check all its nested processors
+				processors.addAll(getProcessorsWithActivityInputPort(
+						getNestedWorkflow(processor), inputPort));
+
+			/*
+			 * Check all processor's activities (even if the processor contained
+			 * a nested workflow, as its dataflow activity still contains input
+			 * and output ports)
+			 */
+			for (Activity<?> activity : processor.getActivityList())
+				if (activity.getInputPorts().contains(inputPort))
+					processors.add(processor);
+		}
+		return processors;
+	}
+
+	public static Collection<Processor> getProcessorsWithActivityOutputPort(
+			Dataflow dataflow, OutputPort outputPort) {
+		Set<Processor> processors = new HashSet<>();
+		for (Processor processor : dataflow.getProcessors()) {
+			// Does it contain a nested workflow?
+			if (containsNestedWorkflow(processor))
+				// Get the nested workflow and check all its nested processors
+				processors.addAll(getProcessorsWithActivityOutputPort(
+						getNestedWorkflow(processor), outputPort));
+
+			/*
+			 * Check all processor's activities (even if the processor contained
+			 * a nested workflow, as its dataflow activity still contains input
+			 * and output ports)
+			 */
+			for (Activity<?> activity : processor.getActivityList())
+				if (activity.getOutputPorts().contains(outputPort))
+					processors.add(processor);
+		}
+		return processors;
+	}
+
+	/**
+	 * Get the TokenProcessingEntity (Processor, Merge or Dataflow) from the
+	 * workflow that contains the given EventForwardingOutputPort. This can be
+	 * an output port of a Processor or a Merge or an input port of a Dataflow
+	 * that has an internal EventForwardingOutputPort attached to it.
+	 * 
+	 * @param port
+	 * @param workflow
+	 * @return
+	 */
+	public static TokenProcessingEntity getTokenProcessingEntityWithEventForwardingOutputPort(
+			EventForwardingOutputPort port, Dataflow workflow) {
+		// First check the workflow's inputs
+		for (DataflowInputPort input : workflow.getInputPorts())
+			if (input.getInternalOutputPort().equals(port))
+				return workflow;
+
+		// Check workflow's merges
+		for (Merge merge : workflow.getMerges())
+			if (merge.getOutputPort().equals(port))
+				return merge;
+
+		// Check workflow's processors
+		for (Processor processor : workflow.getProcessors()) {
+			for (OutputPort output : processor.getOutputPorts())
+				if (output.equals(port))
+					return processor;
+
+			// If processor contains a nested workflow - descend into it
+			if (containsNestedWorkflow(processor)) {
+				TokenProcessingEntity entity = getTokenProcessingEntityWithEventForwardingOutputPort(
+						port, getNestedWorkflow(processor));
+				if (entity != null)
+					return entity;
+			}
+		}
+
+		return null;
+	}
+
+	/**
+	 * Get the TokenProcessingEntity (Processor, Merge or Dataflow) from the
+	 * workflow that contains the given target EventHandlingInputPort. This can
+	 * be an input port of a Processor or a Merge or an output port of a
+	 * Dataflow that has an internal EventHandlingInputPort attached to it.
+	 * 
+	 * @param port
+	 * @param workflow
+	 * @return
+	 */
+	public static TokenProcessingEntity getTokenProcessingEntityWithEventHandlingInputPort(
+			EventHandlingInputPort port, Dataflow workflow) {
+		// First check the workflow's outputs
+		for (DataflowOutputPort output : workflow.getOutputPorts())
+			if (output.getInternalInputPort().equals(port))
+				return workflow;
+
+		// Check workflow's merges
+		for (Merge merge : workflow.getMerges())
+			for (EventHandlingInputPort input : merge.getInputPorts())
+				if (input.equals(port))
+					return merge;
+
+		// Check workflow's processors
+		for (Processor processor : workflow.getProcessors()) {
+			for (EventHandlingInputPort output : processor.getInputPorts())
+				if (output.equals(port))
+					return processor;
+
+			// If processor contains a nested workflow - descend into it
+			if (containsNestedWorkflow(processor)) {
+				TokenProcessingEntity entity = getTokenProcessingEntityWithEventHandlingInputPort(
+						port, getNestedWorkflow(processor));
+				if (entity != null)
+					return entity;
+			}
+		}
+
+		return null;
+	}
+
+	/**
+	 * Returns true if processor contains a nested workflow.
+	 */
+	public static boolean containsNestedWorkflow(Processor processor) {
+		List<?> activities = processor.getActivityList();
+		return !activities.isEmpty()
+				&& activities.get(0) instanceof NestedDataflow;
+	}
+
+	/**
+	 * Get the workflow that is nested inside. Only call this if
+	 * {@link #containsNestedWorkflow()} returns true.
+	 */
+	private static Dataflow getNestedWorkflow(Processor processor) {
+		return ((NestedDataflow) processor.getActivityList().get(0))
+				.getNestedDataflow();
+	}
+
+	/**
+	 * Find the first processor that contains an activity that has the given
+	 * activity input port. See #get
+	 * 
+	 * @param dataflow
+	 * @param targetPort
+	 * @return
+	 */
+	public static Processor getFirstProcessorWithActivityInputPort(
+			Dataflow dataflow, ActivityInputPort targetPort) {
+		for (Processor processor : getProcessorsWithActivityInputPort(
+				dataflow, targetPort))
+			return processor;
+		return null;
+	}
+
+	public static Processor getFirstProcessorWithActivityOutputPort(
+			Dataflow dataflow, ActivityOutputPort targetPort) {
+		for (Processor processor : getProcessorsWithActivityOutputPort(
+				dataflow, targetPort))
+			return processor;
+		return null;
+	}
+
+	/**
+	 * Find a unique processor name for the supplied Dataflow, based upon the
+	 * preferred name. If needed, an underscore and a numeric suffix is added to
+	 * the preferred name, and incremented until it is unique, starting from 2.
+	 * (The original being 'number 1')
+	 * <p>
+	 * Note that this method checks the uniqueness against the names of all
+	 * {@link NamedWorkflowEntity}s, including {@link Merge}s.
+	 * <p>
+	 * Although not strictly needed by Taverna, for added user friendliness the
+	 * case of the existing port names are ignored when checking for uniqueness.
+	 * 
+	 * @param preferredName
+	 *            the preferred name for the Processor
+	 * @param dataflow
+	 *            the dataflow for which the Processor name needs to be unique
+	 * @return A unique processor name
+	 */
+	public static String uniqueProcessorName(String preferredName,
+			Dataflow dataflow) {
+		Set<String> existingNames = new HashSet<>();
+		for (NamedWorkflowEntity entity : dataflow
+				.getEntities(NamedWorkflowEntity.class))
+			existingNames.add(entity.getLocalName().toLowerCase());
+		return uniqueObjectName(preferredName, existingNames);
+	}
+
+	/**
+	 * Checks that the name does not have any characters that are invalid for a
+	 * Taverna name.
+	 * 
+	 * The name must contain only the chars[A-Za-z_0-9].
+	 * 
+	 * @param name
+	 *            the original name
+	 * @return the sanitised name
+	 */
+	public static String sanitiseName(String name) {
+		if (Pattern.matches("\\w++", name) == false) {
+			StringBuilder result = new StringBuilder(name.length());
+			for (char c : name.toCharArray())
+				result.append(isLetterOrDigit(c) || c == '_' ? c : "_");
+			return result.toString();
+		}
+		return name;
+	}
+
+	public static String uniqueObjectName(String preferredName,
+			Set<String> existingNames) {
+		String uniqueName = preferredName;
+		long suffix = 2;
+		while (existingNames.contains(uniqueName.toLowerCase()))
+			uniqueName = preferredName + "_" + suffix++;
+		return uniqueName;
+
+	}
+
+	/**
+	 * Add the identification of a Dataflow into its identification annotation
+	 * chain (if necessary)
+	 * 
+	 * @return Whether an identification needed to be added
+	 */
+	public static boolean addDataflowIdentification(Dataflow dataflow,
+			String internalId, Edits edits) {
+		IdentificationAssertion ia = (IdentificationAssertion) getAnnotation(
+				dataflow, IdentificationAssertion.class);
+		if (ia != null && ia.getIdentification().equals(internalId))
+			return false;
+		IdentificationAssertion newIa = new IdentificationAssertion();
+		newIa.setIdentification(internalId);
+		try {
+			addAnnotation(dataflow, newIa, edits).doEdit();
+			return true;
+		} catch (EditException e) {
+			return false;
+		}
+	}
+
+	/**
+	 * Return a path of processors where the last element is this processor and
+	 * previous ones are nested processors that contain this one all the way to
+	 * the top but excluding the top level workflow as this is only a list of
+	 * processors.
+	 */
+	public static List<Processor> getNestedPathForProcessor(
+			Processor processor, Dataflow dataflow) {
+		for (Processor proc : dataflow.getProcessors())
+			if (proc == processor) { // found it
+				List<Processor> list = new ArrayList<>();
+				list.add(processor);
+				return list;
+			} else if (containsNestedWorkflow(proc)) {
+				/*
+				 * check inside this nested processor
+				 */
+				List<Processor> nestedList = getNestedPathForProcessor(
+						processor, getNestedWorkflow(proc));
+				if (nestedList == null)
+					// processor not found in this nested workflow
+					continue;
+				// add this nested processor to the list
+				nestedList.add(0, proc);
+				return nestedList;
+			}
+		return null;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/resources/META-INF/services/net.sf.taverna.t2.visit.VisitKind
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/resources/META-INF/services/net.sf.taverna.t2.visit.VisitKind b/taverna-workflowmodel-api/src/main/resources/META-INF/services/net.sf.taverna.t2.visit.VisitKind
deleted file mode 100644
index 4ef9d66..0000000
--- a/taverna-workflowmodel-api/src/main/resources/META-INF/services/net.sf.taverna.t2.visit.VisitKind
+++ /dev/null
@@ -1 +0,0 @@
-net.sf.taverna.t2.workflowmodel.health.HealthCheck

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker b/taverna-workflowmodel-api/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
deleted file mode 100644
index e2708bc..0000000
--- a/taverna-workflowmodel-api/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
+++ /dev/null
@@ -1,2 +0,0 @@
-net.sf.taverna.t2.workflowmodel.health.DisabledActivityHealthChecker
-net.sf.taverna.t2.workflowmodel.health.UnrecognizedActivityHealthChecker

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/resources/META-INF/services/org.apache.taverna.visit.VisitKind
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/resources/META-INF/services/org.apache.taverna.visit.VisitKind b/taverna-workflowmodel-api/src/main/resources/META-INF/services/org.apache.taverna.visit.VisitKind
new file mode 100644
index 0000000..6568472
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/resources/META-INF/services/org.apache.taverna.visit.VisitKind
@@ -0,0 +1 @@
+org.apache.taverna.workflowmodel.health.HealthCheck

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/resources/META-INF/services/org.apache.taverna.workflowmodel.health.HealthChecker
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/resources/META-INF/services/org.apache.taverna.workflowmodel.health.HealthChecker b/taverna-workflowmodel-api/src/main/resources/META-INF/services/org.apache.taverna.workflowmodel.health.HealthChecker
new file mode 100644
index 0000000..46e84d8
--- /dev/null
+++ b/taverna-workflowmodel-api/src/main/resources/META-INF/services/org.apache.taverna.workflowmodel.health.HealthChecker
@@ -0,0 +1,2 @@
+org.apache.taverna.workflowmodel.health.DisabledActivityHealthChecker
+org.apache.taverna.workflowmodel.health.UnrecognizedActivityHealthChecker

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/resources/META-INF/spring/workflowmodel-api-context-osgi.xml
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/resources/META-INF/spring/workflowmodel-api-context-osgi.xml b/taverna-workflowmodel-api/src/main/resources/META-INF/spring/workflowmodel-api-context-osgi.xml
index 8fdabdf..9dea97c 100644
--- a/taverna-workflowmodel-api/src/main/resources/META-INF/spring/workflowmodel-api-context-osgi.xml
+++ b/taverna-workflowmodel-api/src/main/resources/META-INF/spring/workflowmodel-api-context-osgi.xml
@@ -6,20 +6,20 @@
                                  http://www.springframework.org/schema/osgi 
                                  http://www.springframework.org/schema/osgi/spring-osgi.xsd">
 
-	<service ref="author" interface="net.sf.taverna.t2.annotation.AnnotationBeanSPI" />
-	<service ref="descriptiveTitle" interface="net.sf.taverna.t2.annotation.AnnotationBeanSPI" />
-	<service ref="freeTextDescription" interface="net.sf.taverna.t2.annotation.AnnotationBeanSPI" />
-	<service ref="hostInstitution" interface="net.sf.taverna.t2.annotation.AnnotationBeanSPI" />
-	<!--<service ref="mimeType" interface="net.sf.taverna.t2.annotation.AnnotationBeanSPI" />-->
-	<service ref="documentationUrl" interface="net.sf.taverna.t2.annotation.AnnotationBeanSPI" />
-	<service ref="optional" interface="net.sf.taverna.t2.annotation.AnnotationBeanSPI" />
-	<service ref="exampleValue" interface="net.sf.taverna.t2.annotation.AnnotationBeanSPI" />
-	<service ref="semanticAnnotation" interface="net.sf.taverna.t2.annotation.AnnotationBeanSPI" />
-	<service ref="identificationAssertion" interface="net.sf.taverna.t2.annotation.AnnotationBeanSPI" />
+	<service ref="author" interface="org.apache.taverna.annotation.AnnotationBeanSPI" />
+	<service ref="descriptiveTitle" interface="org.apache.taverna.annotation.AnnotationBeanSPI" />
+	<service ref="freeTextDescription" interface="org.apache.taverna.annotation.AnnotationBeanSPI" />
+	<service ref="hostInstitution" interface="org.apache.taverna.annotation.AnnotationBeanSPI" />
+	<!--<service ref="mimeType" interface="org.apache.taverna.annotation.AnnotationBeanSPI" />-->
+	<service ref="documentationUrl" interface="org.apache.taverna.annotation.AnnotationBeanSPI" />
+	<service ref="optional" interface="org.apache.taverna.annotation.AnnotationBeanSPI" />
+	<service ref="exampleValue" interface="org.apache.taverna.annotation.AnnotationBeanSPI" />
+	<service ref="semanticAnnotation" interface="org.apache.taverna.annotation.AnnotationBeanSPI" />
+	<service ref="identificationAssertion" interface="org.apache.taverna.annotation.AnnotationBeanSPI" />
 
-	<service ref="healthCheck" interface="net.sf.taverna.t2.visit.VisitKind" />
+	<service ref="healthCheck" interface="org.apache.taverna.visit.VisitKind" />
 	
-	<service ref="disabledActivityHealthChecker" interface="net.sf.taverna.t2.workflowmodel.health.HealthChecker" />
-	<service ref="unrecognizedActivityHealthChecker" interface="net.sf.taverna.t2.workflowmodel.health.HealthChecker" />
+	<service ref="disabledActivityHealthChecker" interface="org.apache.taverna.workflowmodel.health.HealthChecker" />
+	<service ref="unrecognizedActivityHealthChecker" interface="org.apache.taverna.workflowmodel.health.HealthChecker" />
 
 </beans:beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/main/resources/META-INF/spring/workflowmodel-api-context.xml
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/main/resources/META-INF/spring/workflowmodel-api-context.xml b/taverna-workflowmodel-api/src/main/resources/META-INF/spring/workflowmodel-api-context.xml
index ea52514..f0c0b77 100644
--- a/taverna-workflowmodel-api/src/main/resources/META-INF/spring/workflowmodel-api-context.xml
+++ b/taverna-workflowmodel-api/src/main/resources/META-INF/spring/workflowmodel-api-context.xml
@@ -4,20 +4,20 @@
 	xsi:schemaLocation="http://www.springframework.org/schema/beans 
                            http://www.springframework.org/schema/beans/spring-beans.xsd">
                            
-	<bean id="author" class="net.sf.taverna.t2.annotation.annotationbeans.Author" />
-	<bean id="descriptiveTitle" class="net.sf.taverna.t2.annotation.annotationbeans.DescriptiveTitle" />
-	<bean id="freeTextDescription" class="net.sf.taverna.t2.annotation.annotationbeans.FreeTextDescription" />
-	<bean id="hostInstitution" class="net.sf.taverna.t2.annotation.annotationbeans.HostInstitution" />
-	<!--<bean id="mimeType" class="net.sf.taverna.t2.annotation.annotationbeans.MimeType" />-->
-	<bean id="documentationUrl" class="net.sf.taverna.t2.annotation.annotationbeans.DocumentationUrl" />
-	<bean id="optional" class="net.sf.taverna.t2.annotation.annotationbeans.Optional" />
-	<bean id="exampleValue" class="net.sf.taverna.t2.annotation.annotationbeans.ExampleValue" />
-	<bean id="semanticAnnotation" class="net.sf.taverna.t2.annotation.annotationbeans.SemanticAnnotation" />
-	<bean id="identificationAssertion" class="net.sf.taverna.t2.annotation.annotationbeans.IdentificationAssertion" />
+	<bean id="author" class="org.apache.taverna.annotation.annotationbeans.Author" />
+	<bean id="descriptiveTitle" class="org.apache.taverna.annotation.annotationbeans.DescriptiveTitle" />
+	<bean id="freeTextDescription" class="org.apache.taverna.annotation.annotationbeans.FreeTextDescription" />
+	<bean id="hostInstitution" class="org.apache.taverna.annotation.annotationbeans.HostInstitution" />
+	<!--<bean id="mimeType" class="org.apache.taverna.annotation.annotationbeans.MimeType" />-->
+	<bean id="documentationUrl" class="org.apache.taverna.annotation.annotationbeans.DocumentationUrl" />
+	<bean id="optional" class="org.apache.taverna.annotation.annotationbeans.Optional" />
+	<bean id="exampleValue" class="org.apache.taverna.annotation.annotationbeans.ExampleValue" />
+	<bean id="semanticAnnotation" class="org.apache.taverna.annotation.annotationbeans.SemanticAnnotation" />
+	<bean id="identificationAssertion" class="org.apache.taverna.annotation.annotationbeans.IdentificationAssertion" />
 
-	<bean id="healthCheck" class="net.sf.taverna.t2.workflowmodel.health.HealthCheck" />
+	<bean id="healthCheck" class="org.apache.taverna.workflowmodel.health.HealthCheck" />
 
-	<bean id="disabledActivityHealthChecker" class="net.sf.taverna.t2.workflowmodel.health.DisabledActivityHealthChecker" />
-	<bean id="unrecognizedActivityHealthChecker" class="net.sf.taverna.t2.workflowmodel.health.UnrecognizedActivityHealthChecker" />
+	<bean id="disabledActivityHealthChecker" class="org.apache.taverna.workflowmodel.health.DisabledActivityHealthChecker" />
+	<bean id="unrecognizedActivityHealthChecker" class="org.apache.taverna.workflowmodel.health.UnrecognizedActivityHealthChecker" />
 		
 </beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/monitor/TestMonitorManager.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/monitor/TestMonitorManager.java b/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/monitor/TestMonitorManager.java
deleted file mode 100644
index 8ce2b6e..0000000
--- a/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/monitor/TestMonitorManager.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.monitor;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
-
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.lang.observer.Observer;
-import net.sf.taverna.t2.monitor.MonitorManager.AddPropertiesMessage;
-import net.sf.taverna.t2.monitor.MonitorManager.DeregisterNodeMessage;
-import net.sf.taverna.t2.monitor.MonitorManager.MonitorMessage;
-import net.sf.taverna.t2.monitor.MonitorManager.RegisterNodeMessage;
-
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test {@link MonitorManager}.
- * 
- * @author Stian Soiland-Reyes
- *
- */
-public class TestMonitorManager {
-	private MonitorManager monitorManager;
-
-	@Test
-	public void addMonitor() {
-		TestMonitor testMonitor = new TestMonitor();
-		monitorManager.addObserver(testMonitor);
-		assertEquals(0, testMonitor.getCounts());
-		// Make a fake registration
-		Object workflowObject = "The workflow object as a string";
-		String[] owningProcess = { "dataflow0", "process4", "42424" };
-		Set<MonitorableProperty<?>> properties = new HashSet<>();
-		properties.add(new ExampleProperty());
-		monitorManager.registerNode(workflowObject, owningProcess, properties);
-
-		assertEquals(1, testMonitor.getCounts());
-		assertEquals(monitorManager, testMonitor.lastSender);
-		MonitorMessage lastMessage = testMonitor.lastMessage;
-		assertTrue("Owning process did not match", Arrays.equals(owningProcess,
-				lastMessage.getOwningProcess()));
-
-		assertTrue("Message was not a RegisterNodeMessage",
-				lastMessage instanceof RegisterNodeMessage);
-		RegisterNodeMessage registerNodeMessage = (RegisterNodeMessage) lastMessage;
-		assertSame("Workflow object was not same", workflowObject,
-				registerNodeMessage.getWorkflowObject());
-		assertEquals(properties, registerNodeMessage.getProperties());
-
-		assertEquals("Another event was received", 1, testMonitor.getCounts());
-	}
-
-	@Test
-	public void addProperties() {
-		TestMonitor testMonitor = new TestMonitor();
-		monitorManager.addObserver(testMonitor);
-		assertEquals(0, testMonitor.getCounts());
-		// Make a fake add properties
-		String[] owningProcess = { "dataflow0", "process4", "42424" };
-		Set<MonitorableProperty<?>> newProperties = new HashSet<>();
-		newProperties.add(new ExampleProperty());
-		monitorManager.addPropertiesToNode(owningProcess, newProperties);
-
-		assertEquals(1, testMonitor.getCounts());
-		assertEquals(monitorManager, testMonitor.lastSender);
-		MonitorMessage lastMessage = testMonitor.lastMessage;
-		assertTrue("Owning process did not match", Arrays.equals(owningProcess,
-				lastMessage.getOwningProcess()));
-
-		assertTrue("Message was not a AddPropertiesMessage",
-				lastMessage instanceof AddPropertiesMessage);
-		AddPropertiesMessage registerNodeMessage = (AddPropertiesMessage) lastMessage;
-		assertEquals(newProperties, registerNodeMessage.getNewProperties());
-
-		assertEquals("Another event was received", 1, testMonitor.getCounts());
-	}
-
-	@Before
-	public void findMonitorManager() {
-		monitorManager = MonitorManager.getInstance();
-	}
-
-	@Test
-	public void removeMonitor() {
-		TestMonitor testMonitor = new TestMonitor();
-		monitorManager.addObserver(testMonitor);
-		assertEquals(0, testMonitor.getCounts());
-
-		// Make a fake deregistration
-		String[] owningProcess = { "dataflow0", "process4", "1337" };
-		monitorManager.deregisterNode(owningProcess);
-
-		assertEquals(1, testMonitor.getCounts());
-		assertEquals(monitorManager, testMonitor.lastSender);
-		MonitorMessage lastMessage = testMonitor.lastMessage;
-		assertTrue("Owning process did not match", Arrays.equals(owningProcess,
-				lastMessage.getOwningProcess()));
-		assertTrue("Message was not a DeregisterNodeMessage",
-				lastMessage instanceof DeregisterNodeMessage);
-		assertEquals("Another event was received", 1, testMonitor.getCounts());
-	}
-
-	public class TestMonitor implements Observer<MonitorManager.MonitorMessage> {
-
-		private int counts = 0;
-		private MonitorMessage lastMessage;
-		private Observable<MonitorMessage> lastSender;
-
-		public int getCounts() {
-			return counts;
-		}
-
-		public MonitorMessage getMessage() {
-			return lastMessage;
-		}
-
-		public Observable<MonitorMessage> getSender() {
-			return lastSender;
-		}
-
-		@Override
-		public synchronized void notify(Observable<MonitorMessage> sender,
-				MonitorMessage message) throws Exception {
-			this.lastSender = sender;
-			this.lastMessage = message;
-			this.counts++;
-		}
-	}
-
-	private final class ExampleProperty implements MonitorableProperty<String> {
-		@Override
-		public Date getLastModified() {
-			return new Date();
-		}
-
-		@Override
-		public String[] getName() {
-			return new String[] { "monitor", "test", "example" };
-		}
-
-		@Override
-		public String getValue() throws NoSuchPropertyException {
-			return "Example property value";
-		}
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/health/DummyVisitKind.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/health/DummyVisitKind.java b/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/health/DummyVisitKind.java
deleted file mode 100644
index 7f8767f..0000000
--- a/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/health/DummyVisitKind.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * 
- */
-package net.sf.taverna.t2.workflowmodel.health;
-
-import net.sf.taverna.t2.visit.VisitKind;
-import net.sf.taverna.t2.visit.Visitor;
-
-/**
- * @author alanrw
- *
- */
-public class DummyVisitKind extends VisitKind {
-	@Override
-	public Class<? extends Visitor<?>> getVisitorClass() {
-		return null;
-	}
-
-	private static class Singleton {
-		private static DummyVisitKind instance = new DummyVisitKind();
-	}
-	
-	public static DummyVisitKind getInstance() {
-		return Singleton.instance;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/health/FloatHealthChecker.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/health/FloatHealthChecker.java b/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/health/FloatHealthChecker.java
deleted file mode 100644
index 228ed5d..0000000
--- a/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/health/FloatHealthChecker.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.health;
-
-import java.util.List;
-
-import net.sf.taverna.t2.visit.VisitReport;
-import net.sf.taverna.t2.workflowmodel.health.HealthChecker;
-
-public class FloatHealthChecker implements HealthChecker<Float> {
-
-	@Override
-	public boolean canVisit(Object subject) {
-		return subject!=null && subject instanceof Float;
-	}
-
-	@Override
-	public VisitReport visit(Float o, List<Object> ancestry) {
-		return null;
-	}
-
-	@Override
-	public boolean isTimeConsuming() {
-		return false;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/health/FloatHealthChecker2.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/health/FloatHealthChecker2.java b/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/health/FloatHealthChecker2.java
deleted file mode 100644
index 80acac8..0000000
--- a/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/health/FloatHealthChecker2.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.health;
-
-import java.util.List;
-
-import net.sf.taverna.t2.visit.VisitReport;
-
-public class FloatHealthChecker2 implements HealthChecker<Float> {
-
-	@Override
-	public boolean canVisit(Object subject) {
-		return subject!=null && subject instanceof Float;
-	}
-
-	@Override
-	public VisitReport visit(Float o, List<Object> ancestry) {
-		return null;
-	}
-
-	@Override
-	public boolean isTimeConsuming() {
-		return false;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/health/HealthReportTest.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/health/HealthReportTest.java b/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/health/HealthReportTest.java
deleted file mode 100644
index 9ee1fd9..0000000
--- a/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/health/HealthReportTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.health;
-
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import net.sf.taverna.t2.visit.VisitReport;
-import net.sf.taverna.t2.visit.VisitReport.Status;
-
-import org.junit.Before;
-import org.junit.Test;
-
-public class HealthReportTest {
-
-	VisitReport report;
-	
-	@Before
-	public void setUp() throws Exception {
-		List<VisitReport> subreports = new ArrayList<>();
-		subreports.add(new VisitReport(DummyVisitKind.getInstance(), "sub subject","this is a subreport",0,Status.OK));
-		report = new VisitReport(DummyVisitKind.getInstance(), "a subject","a message",0, Status.WARNING,subreports);
-	}
-
-	@Test
-	public void testActivityVisitReportStringStatus() {
-		report = new VisitReport(DummyVisitKind.getInstance(), "the subject","a string",0, Status.SEVERE);
-		assertEquals("a string",report.getMessage());
-		assertEquals(Status.SEVERE,report.getStatus());
-		assertEquals("the subject",report.getSubject());
-		assertEquals("the subreports should be an empty list",0,report.getSubReports().size());
-	}
-
-	@Test
-	public void testGetMessage() {
-		assertEquals("a message",report.getMessage());
-	}
-
-	@Test
-	public void testGetStatus() {
-		assertEquals(Status.WARNING,report.getStatus());
-	}
-	
-	@Test
-	public void testGetSubject() {
-		assertEquals("a subject",report.getSubject());
-	}
-	
-	@Test
-	public void testGetSubreports() {
-		Collection<VisitReport> subreports = report.getSubReports();
-		assertEquals("There should be 1 report",1,subreports.size());
-		assertEquals("Wrong subject","sub subject",subreports.iterator().next().getSubject());
-	}
-	
-	@Test 
-	public void testStatusHighestIncludingSubReports() {
-		report = new VisitReport(DummyVisitKind.getInstance(), "parent","set to ok",0, Status.OK);
-		assertEquals("should be OK",Status.OK,report.getStatus());
-		report.getSubReports().add(new VisitReport(DummyVisitKind.getInstance(), "child1","set to warning",0, Status.WARNING));
-		assertEquals("should be WARNING",Status.WARNING,report.getStatus());
-		report.getSubReports().add(new VisitReport(DummyVisitKind.getInstance(), "child1","set to severe",0, Status.SEVERE));
-		assertEquals("should be SEVERE",Status.SEVERE,report.getStatus());
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/health/StringHealthChecker.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/health/StringHealthChecker.java b/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/health/StringHealthChecker.java
deleted file mode 100644
index d550a40..0000000
--- a/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/health/StringHealthChecker.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.health;
-
-import java.util.List;
-
-import net.sf.taverna.t2.visit.VisitReport;
-import net.sf.taverna.t2.workflowmodel.health.HealthChecker;
-
-public class StringHealthChecker implements HealthChecker<String> {
-
-	@Override
-	public boolean canVisit(Object subject) {
-		return subject!=null && subject instanceof String;
-	}
-
-	@Override
-	public VisitReport visit(String o, List<Object> ancestry) {
-		return null;
-	}
-
-	@Override
-	public boolean isTimeConsuming() {
-		return false;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/processor/iteration/TestIterationStrategyNodes.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/processor/iteration/TestIterationStrategyNodes.java b/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/processor/iteration/TestIterationStrategyNodes.java
deleted file mode 100644
index 8cf8141..0000000
--- a/taverna-workflowmodel-api/src/test/java/net/sf/taverna/t2/workflowmodel/processor/iteration/TestIterationStrategyNodes.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.workflowmodel.processor.iteration;
-
-import static org.junit.Assert.*;
-
-import java.util.Arrays;
-import java.util.Enumeration;
-import java.util.Map;
-
-import javax.swing.tree.TreeNode;
-
-import net.sf.taverna.t2.invocation.Completion;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Job;
-
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test {@link AbstractIterationStrategyNode} implementations for
- * {@link TreeNode} behaviour.
- * 
- * @author Stian Soiland-Reyes
- * 
- */
-public class TestIterationStrategyNodes {
-
-	TerminalNode root;
-	private NamedInputPortNode input1;
-	private NamedInputPortNode input2;
-	private CrossProduct crossProduct1;
-	private CrossProduct crossProduct2;
-	private DotProduct dotProduct1;
-	private DotProduct dotProduct2;
-
-	@Test
-	public void addSingleChildToTerminal() throws Exception {
-		assertNull(input1.getParent());
-		assertEquals(0, root.getChildCount());
-		root.insert(input1);
-		assertEquals(root, input1.getParent());
-		assertEquals(1, root.getChildCount());
-		assertEquals(input1, root.getChildAt(0));
-		assertEquals(Arrays.asList(input1), root.getChildren());
-
-		root.insert(input1);
-		assertEquals(1, root.getChildCount());
-
-		root.insert(input1, 0);
-		assertEquals(1, root.getChildCount());
-	}
-
-	@Test(expected = IllegalStateException.class)
-	public void cantAddSeveralChildrenToTerminal() throws Exception {
-		root.insert(input1);
-		root.insert(input2);
-	}
-
-	@Test
-	public void addCrossProduct() throws Exception {
-		assertNull(crossProduct1.getParent());
-		crossProduct1.setParent(root);
-		assertEquals(root, crossProduct1.getParent());
-		assertEquals(1, root.getChildCount());
-		assertEquals(crossProduct1, root.getChildAt(0));
-		assertEquals(Arrays.asList(crossProduct1), root.getChildren());
-		assertEquals(0, crossProduct1.getChildCount());
-
-		crossProduct1.insert(input1);
-		assertEquals(input1, crossProduct1.getChildAt(0));
-		crossProduct1.insert(input2, 0);
-		assertEquals(input2, crossProduct1.getChildAt(0));
-		assertEquals(input1, crossProduct1.getChildAt(1));
-		assertEquals(2, crossProduct1.getChildCount());
-		assertEquals(Arrays.asList(input2, input1), crossProduct1.getChildren());
-
-		// A re-insert should move it
-		crossProduct1.insert(input2, 2);
-		assertEquals(2, crossProduct1.getChildCount());
-		assertEquals(Arrays.asList(input1, input2), crossProduct1.getChildren());
-
-		crossProduct1.insert(input2, 0);
-		assertEquals(Arrays.asList(input2, input1), crossProduct1.getChildren());
-
-		crossProduct1.insert(input1, 1);
-		assertEquals(Arrays.asList(input2, input1), crossProduct1.getChildren());
-	}
-
-	@Test
-	public void addCrossProductMany() {
-		crossProduct1.insert(dotProduct1);
-		crossProduct1.insert(dotProduct2);
-		crossProduct1.insert(input1);
-		crossProduct1.insert(input2);
-		crossProduct1.insert(crossProduct2);
-		assertEquals(5, crossProduct1.getChildCount());
-		assertEquals(Arrays.asList(dotProduct1, dotProduct2, input1, input2,
-				crossProduct2), crossProduct1.getChildren());
-		Enumeration<IterationStrategyNode> enumeration = crossProduct1
-				.children();
-		assertTrue(enumeration.hasMoreElements());
-		assertEquals(dotProduct1, enumeration.nextElement());
-		assertEquals(dotProduct2, enumeration.nextElement());
-		assertEquals(input1, enumeration.nextElement());
-		assertEquals(input2, enumeration.nextElement());
-		assertEquals(crossProduct2, enumeration.nextElement());
-		assertFalse(enumeration.hasMoreElements());
-	}
-
-	@Test
-	public void moveNodeToDifferentParent() {
-		crossProduct1.setParent(root);
-		crossProduct1.insert(input1);
-		crossProduct1.insert(dotProduct1);
-		dotProduct1.insert(input2);
-		dotProduct1.insert(crossProduct2);
-
-		// Check tree
-		assertEquals(crossProduct2, root.getChildAt(0).getChildAt(1)
-				.getChildAt(1));
-		assertEquals(Arrays.asList(input2, crossProduct2), dotProduct1
-				.getChildren());
-
-		crossProduct1.insert(crossProduct2, 1);
-		assertEquals(Arrays.asList(input1, crossProduct2, dotProduct1),
-				crossProduct1.getChildren());
-		assertEquals(crossProduct1, crossProduct2.getParent());
-		// Should no longer be in dotProduct1
-		assertEquals(Arrays.asList(input2), dotProduct1.getChildren());
-	}
-
-	@Test(expected = IllegalStateException.class)
-	public void cantAddToNamedInput() throws Exception {
-		input1.insert(dotProduct1);
-	}
-
-	@Test
-	public void cantAddSelf() throws Exception {
-		dotProduct1.setParent(crossProduct1);
-		try {
-			dotProduct1.insert(dotProduct1);
-			fail("Didn't throw IllegalArgumentException");
-		} catch (IllegalArgumentException ex) {
-			// Make sure we didn't loose our old parent and
-			// ended up in a funny state
-			assertEquals(crossProduct1, dotProduct1.getParent());
-			assertEquals(dotProduct1, crossProduct1.getChildAt(0));
-		}
-	}
-
-	@Test
-	public void cantSetSelfParent() throws Exception {
-		crossProduct1.insert(dotProduct1);
-		try {
-			dotProduct1.setParent(dotProduct1);
-			fail("Didn't throw IllegalArgumentException");
-		} catch (IllegalArgumentException ex) {
-			// Make sure we didn't loose our old parent and
-			// ended up in a funny state
-			assertEquals(crossProduct1, dotProduct1.getParent());
-			assertEquals(dotProduct1, crossProduct1.getChildAt(0));
-		}
-	}
-
-	@Before
-	public void makeNodes() throws Exception {
-		root = new DummyTerminalNode();
-		input1 = new NamedInputPortNode("input1", 1);
-		input2 = new NamedInputPortNode("input2", 2);
-		crossProduct1 = new CrossProduct();
-		crossProduct2 = new CrossProduct();
-		dotProduct1 = new DotProduct();
-		dotProduct2 = new DotProduct();
-	}
-
-	@SuppressWarnings("serial")
-	protected final class DummyTerminalNode extends TerminalNode {
-
-		@Override
-		public int getIterationDepth(Map<String, Integer> inputDepths)
-				throws IterationTypeMismatchException {
-			return 0;
-		}
-
-		@Override
-		public void receiveCompletion(int inputIndex, Completion completion) {
-		}
-
-		@Override
-		public void receiveJob(int inputIndex, Job newJob) {
-		}
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/test/java/org/apache/taverna/monitor/TestMonitorManager.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/test/java/org/apache/taverna/monitor/TestMonitorManager.java b/taverna-workflowmodel-api/src/test/java/org/apache/taverna/monitor/TestMonitorManager.java
new file mode 100644
index 0000000..93f7496
--- /dev/null
+++ b/taverna-workflowmodel-api/src/test/java/org/apache/taverna/monitor/TestMonitorManager.java
@@ -0,0 +1,172 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.monitor;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.taverna.lang.observer.Observable;
+import org.apache.taverna.lang.observer.Observer;
+import org.apache.taverna.monitor.MonitorManager.AddPropertiesMessage;
+import org.apache.taverna.monitor.MonitorManager.DeregisterNodeMessage;
+import org.apache.taverna.monitor.MonitorManager.MonitorMessage;
+import org.apache.taverna.monitor.MonitorManager.RegisterNodeMessage;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test {@link MonitorManager}.
+ * 
+ * @author Stian Soiland-Reyes
+ *
+ */
+public class TestMonitorManager {
+	private MonitorManager monitorManager;
+
+	@Test
+	public void addMonitor() {
+		TestMonitor testMonitor = new TestMonitor();
+		monitorManager.addObserver(testMonitor);
+		assertEquals(0, testMonitor.getCounts());
+		// Make a fake registration
+		Object workflowObject = "The workflow object as a string";
+		String[] owningProcess = { "dataflow0", "process4", "42424" };
+		Set<MonitorableProperty<?>> properties = new HashSet<>();
+		properties.add(new ExampleProperty());
+		monitorManager.registerNode(workflowObject, owningProcess, properties);
+
+		assertEquals(1, testMonitor.getCounts());
+		assertEquals(monitorManager, testMonitor.lastSender);
+		MonitorMessage lastMessage = testMonitor.lastMessage;
+		assertTrue("Owning process did not match", Arrays.equals(owningProcess,
+				lastMessage.getOwningProcess()));
+
+		assertTrue("Message was not a RegisterNodeMessage",
+				lastMessage instanceof RegisterNodeMessage);
+		RegisterNodeMessage registerNodeMessage = (RegisterNodeMessage) lastMessage;
+		assertSame("Workflow object was not same", workflowObject,
+				registerNodeMessage.getWorkflowObject());
+		assertEquals(properties, registerNodeMessage.getProperties());
+
+		assertEquals("Another event was received", 1, testMonitor.getCounts());
+	}
+
+	@Test
+	public void addProperties() {
+		TestMonitor testMonitor = new TestMonitor();
+		monitorManager.addObserver(testMonitor);
+		assertEquals(0, testMonitor.getCounts());
+		// Make a fake add properties
+		String[] owningProcess = { "dataflow0", "process4", "42424" };
+		Set<MonitorableProperty<?>> newProperties = new HashSet<>();
+		newProperties.add(new ExampleProperty());
+		monitorManager.addPropertiesToNode(owningProcess, newProperties);
+
+		assertEquals(1, testMonitor.getCounts());
+		assertEquals(monitorManager, testMonitor.lastSender);
+		MonitorMessage lastMessage = testMonitor.lastMessage;
+		assertTrue("Owning process did not match", Arrays.equals(owningProcess,
+				lastMessage.getOwningProcess()));
+
+		assertTrue("Message was not a AddPropertiesMessage",
+				lastMessage instanceof AddPropertiesMessage);
+		AddPropertiesMessage registerNodeMessage = (AddPropertiesMessage) lastMessage;
+		assertEquals(newProperties, registerNodeMessage.getNewProperties());
+
+		assertEquals("Another event was received", 1, testMonitor.getCounts());
+	}
+
+	@Before
+	public void findMonitorManager() {
+		monitorManager = MonitorManager.getInstance();
+	}
+
+	@Test
+	public void removeMonitor() {
+		TestMonitor testMonitor = new TestMonitor();
+		monitorManager.addObserver(testMonitor);
+		assertEquals(0, testMonitor.getCounts());
+
+		// Make a fake deregistration
+		String[] owningProcess = { "dataflow0", "process4", "1337" };
+		monitorManager.deregisterNode(owningProcess);
+
+		assertEquals(1, testMonitor.getCounts());
+		assertEquals(monitorManager, testMonitor.lastSender);
+		MonitorMessage lastMessage = testMonitor.lastMessage;
+		assertTrue("Owning process did not match", Arrays.equals(owningProcess,
+				lastMessage.getOwningProcess()));
+		assertTrue("Message was not a DeregisterNodeMessage",
+				lastMessage instanceof DeregisterNodeMessage);
+		assertEquals("Another event was received", 1, testMonitor.getCounts());
+	}
+
+	public class TestMonitor implements Observer<MonitorManager.MonitorMessage> {
+
+		private int counts = 0;
+		private MonitorMessage lastMessage;
+		private Observable<MonitorMessage> lastSender;
+
+		public int getCounts() {
+			return counts;
+		}
+
+		public MonitorMessage getMessage() {
+			return lastMessage;
+		}
+
+		public Observable<MonitorMessage> getSender() {
+			return lastSender;
+		}
+
+		@Override
+		public synchronized void notify(Observable<MonitorMessage> sender,
+				MonitorMessage message) throws Exception {
+			this.lastSender = sender;
+			this.lastMessage = message;
+			this.counts++;
+		}
+	}
+
+	private final class ExampleProperty implements MonitorableProperty<String> {
+		@Override
+		public Date getLastModified() {
+			return new Date();
+		}
+
+		@Override
+		public String[] getName() {
+			return new String[] { "monitor", "test", "example" };
+		}
+
+		@Override
+		public String getValue() throws NoSuchPropertyException {
+			return "Example property value";
+		}
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/health/DummyVisitKind.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/health/DummyVisitKind.java b/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/health/DummyVisitKind.java
new file mode 100644
index 0000000..4c7ef30
--- /dev/null
+++ b/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/health/DummyVisitKind.java
@@ -0,0 +1,42 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.health;
+
+import org.apache.taverna.visit.VisitKind;
+import org.apache.taverna.visit.Visitor;
+
+/**
+ * @author alanrw
+ *
+ */
+public class DummyVisitKind extends VisitKind {
+	@Override
+	public Class<? extends Visitor<?>> getVisitorClass() {
+		return null;
+	}
+
+	private static class Singleton {
+		private static DummyVisitKind instance = new DummyVisitKind();
+	}
+	
+	public static DummyVisitKind getInstance() {
+		return Singleton.instance;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/health/FloatHealthChecker.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/health/FloatHealthChecker.java b/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/health/FloatHealthChecker.java
new file mode 100644
index 0000000..d88aaac
--- /dev/null
+++ b/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/health/FloatHealthChecker.java
@@ -0,0 +1,43 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.health;
+
+import java.util.List;
+
+import org.apache.taverna.visit.VisitReport;
+
+public class FloatHealthChecker implements HealthChecker<Float> {
+
+	@Override
+	public boolean canVisit(Object subject) {
+		return subject!=null && subject instanceof Float;
+	}
+
+	@Override
+	public VisitReport visit(Float o, List<Object> ancestry) {
+		return null;
+	}
+
+	@Override
+	public boolean isTimeConsuming() {
+		return false;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/health/FloatHealthChecker2.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/health/FloatHealthChecker2.java b/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/health/FloatHealthChecker2.java
new file mode 100644
index 0000000..9a05080
--- /dev/null
+++ b/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/health/FloatHealthChecker2.java
@@ -0,0 +1,43 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.health;
+
+import java.util.List;
+
+import org.apache.taverna.visit.VisitReport;
+
+public class FloatHealthChecker2 implements HealthChecker<Float> {
+
+	@Override
+	public boolean canVisit(Object subject) {
+		return subject!=null && subject instanceof Float;
+	}
+
+	@Override
+	public VisitReport visit(Float o, List<Object> ancestry) {
+		return null;
+	}
+
+	@Override
+	public boolean isTimeConsuming() {
+		return false;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/health/HealthReportTest.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/health/HealthReportTest.java b/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/health/HealthReportTest.java
new file mode 100644
index 0000000..acd14a3
--- /dev/null
+++ b/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/health/HealthReportTest.java
@@ -0,0 +1,87 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.health;
+
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.taverna.visit.VisitReport;
+import org.apache.taverna.visit.VisitReport.Status;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class HealthReportTest {
+
+	VisitReport report;
+	
+	@Before
+	public void setUp() throws Exception {
+		List<VisitReport> subreports = new ArrayList<>();
+		subreports.add(new VisitReport(DummyVisitKind.getInstance(), "sub subject","this is a subreport",0,Status.OK));
+		report = new VisitReport(DummyVisitKind.getInstance(), "a subject","a message",0, Status.WARNING,subreports);
+	}
+
+	@Test
+	public void testActivityVisitReportStringStatus() {
+		report = new VisitReport(DummyVisitKind.getInstance(), "the subject","a string",0, Status.SEVERE);
+		assertEquals("a string",report.getMessage());
+		assertEquals(Status.SEVERE,report.getStatus());
+		assertEquals("the subject",report.getSubject());
+		assertEquals("the subreports should be an empty list",0,report.getSubReports().size());
+	}
+
+	@Test
+	public void testGetMessage() {
+		assertEquals("a message",report.getMessage());
+	}
+
+	@Test
+	public void testGetStatus() {
+		assertEquals(Status.WARNING,report.getStatus());
+	}
+	
+	@Test
+	public void testGetSubject() {
+		assertEquals("a subject",report.getSubject());
+	}
+	
+	@Test
+	public void testGetSubreports() {
+		Collection<VisitReport> subreports = report.getSubReports();
+		assertEquals("There should be 1 report",1,subreports.size());
+		assertEquals("Wrong subject","sub subject",subreports.iterator().next().getSubject());
+	}
+	
+	@Test 
+	public void testStatusHighestIncludingSubReports() {
+		report = new VisitReport(DummyVisitKind.getInstance(), "parent","set to ok",0, Status.OK);
+		assertEquals("should be OK",Status.OK,report.getStatus());
+		report.getSubReports().add(new VisitReport(DummyVisitKind.getInstance(), "child1","set to warning",0, Status.WARNING));
+		assertEquals("should be WARNING",Status.WARNING,report.getStatus());
+		report.getSubReports().add(new VisitReport(DummyVisitKind.getInstance(), "child1","set to severe",0, Status.SEVERE));
+		assertEquals("should be SEVERE",Status.SEVERE,report.getStatus());
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/health/StringHealthChecker.java
----------------------------------------------------------------------
diff --git a/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/health/StringHealthChecker.java b/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/health/StringHealthChecker.java
new file mode 100644
index 0000000..7bf6960
--- /dev/null
+++ b/taverna-workflowmodel-api/src/test/java/org/apache/taverna/workflowmodel/health/StringHealthChecker.java
@@ -0,0 +1,43 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.workflowmodel.health;
+
+import java.util.List;
+
+import org.apache.taverna.visit.VisitReport;
+
+public class StringHealthChecker implements HealthChecker<String> {
+
+	@Override
+	public boolean canVisit(Object subject) {
+		return subject!=null && subject instanceof String;
+	}
+
+	@Override
+	public VisitReport visit(String o, List<Object> ancestry) {
+		return null;
+	}
+
+	@Override
+	public boolean isTimeConsuming() {
+		return false;
+	}
+
+}


[31/51] [partial] incubator-taverna-engine git commit:

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineStringReferenceBuilder.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineStringReferenceBuilder.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineStringReferenceBuilder.java
deleted file mode 100644
index 66c5512..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineStringReferenceBuilder.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl.external.object;
-
-import static net.sf.taverna.t2.reference.impl.external.object.StreamToStringConverter.readFile;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.nio.charset.Charset;
-
-import net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI;
-import net.sf.taverna.t2.reference.ExternalReferenceConstructionException;
-import net.sf.taverna.t2.reference.ReferenceContext;
-
-/**
- * Build an InlineStringReference from an InputStream
- * 
- * @author Tom Oinn
- */
-public class InlineStringReferenceBuilder implements
-		ExternalReferenceBuilderSPI<InlineStringReference> {
-	private static final Charset UTF8 = Charset.forName("UTF-8");
-	
-	@Override
-	public InlineStringReference createReference(InputStream byteStream,
-			ReferenceContext context) {
-		try {
-			/*
-			 * UTF8 is a slightly saner default than system default for most
-			 * bytestreams
-			 */
-			String contents = readFile(new BufferedReader(
-					new InputStreamReader(byteStream, UTF8)));
-			InlineStringReference ref = new InlineStringReference();
-			ref.setContents(contents);
-			return ref;
-		} catch (IOException e) {
-			throw new ExternalReferenceConstructionException(e);
-		}
-	}
-
-	@Override
-	public float getConstructionCost() {
-		return 0.1f;
-	}
-
-	@Override
-	public Class<InlineStringReference> getReferenceType() {
-		return InlineStringReference.class;
-	}
-
-	@Override
-	public boolean isEnabled(ReferenceContext context) {
-		return true;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineStringToInlineByteTranslator.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineStringToInlineByteTranslator.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineStringToInlineByteTranslator.java
deleted file mode 100644
index e603a93..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineStringToInlineByteTranslator.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package net.sf.taverna.t2.reference.impl.external.object;
-
-import java.nio.charset.Charset;
-
-import net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-
-public class InlineStringToInlineByteTranslator implements
-		ExternalReferenceTranslatorSPI<InlineStringReference, InlineByteArrayReference> {
-	private static final Charset UTF8 = Charset.forName("UTF-8");
-	
-	@Override
-	public InlineByteArrayReference createReference(
-			InlineStringReference sourceReference, ReferenceContext context) {
-		byte[] bytes = sourceReference.getValue().getBytes(UTF8);
-		InlineByteArrayReference ref = new InlineByteArrayReference();
-		ref.setValue(bytes);	
-		return ref;
-	}
-
-	@Override
-	public Class<InlineStringReference> getSourceReferenceType() {
-		return InlineStringReference.class;
-	}
-
-	@Override
-	public Class<InlineByteArrayReference> getTargetReferenceType() {
-		return InlineByteArrayReference.class;
-	}
-
-	@Override
-	public boolean isEnabled(ReferenceContext context) {
-		return true;
-	}
-
-	@Override
-	public float getTranslationCost() {
-		return 0.001f;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/NumberToStringReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/NumberToStringReference.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/NumberToStringReference.java
deleted file mode 100644
index 58fbc09..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/NumberToStringReference.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl.external.object;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ValueToReferenceConversionException;
-import net.sf.taverna.t2.reference.ValueToReferenceConverterSPI;
-
-/**
- * Convert a java.lang.Number to a StringReference.
- * 
- * @author Alex Nenadic
- */
-public class NumberToStringReference implements ValueToReferenceConverterSPI {
-	/**
-	 * Can convert if the object is an instance of java.lang.Number
-	 */
-	@Override
-	public boolean canConvert(Object o, ReferenceContext context) {
-		return o instanceof Number;
-	}
-
-	/**
-	 * Return a new InlineStringReference wrapping the supplied String
-	 */
-	@Override
-	public ExternalReferenceSPI convert(Object o, ReferenceContext context)
-			throws ValueToReferenceConversionException {
-		InlineStringReference result = new InlineStringReference();
-		result.setContents(o.toString());
-		return result;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToBooleanConverter.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToBooleanConverter.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToBooleanConverter.java
deleted file mode 100644
index a26f4df..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToBooleanConverter.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * 
- */
-package net.sf.taverna.t2.reference.impl.external.object;
-
-import java.io.InputStream;
-
-import net.sf.taverna.t2.reference.ReferencedDataNature;
-import net.sf.taverna.t2.reference.StreamToValueConverterSPI;
-
-/**
- * @author alanrw
- */
-public class StreamToBooleanConverter implements
-		StreamToValueConverterSPI<Boolean> {
-	@Override
-	public Class<Boolean> getPojoClass() {
-		return Boolean.class;
-	}
-
-	@Override
-	public Boolean renderFrom(InputStream stream,
-			ReferencedDataNature dataNature, String charset) {
-		StreamToStringConverter stringConverter = new StreamToStringConverter();
-		String s = stringConverter.renderFrom(stream, dataNature, charset);
-		Boolean result = Boolean.valueOf(s.trim());
-		return result;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToByteArrayConverter.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToByteArrayConverter.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToByteArrayConverter.java
deleted file mode 100644
index e8c3a5a..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToByteArrayConverter.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl.external.object;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import net.sf.taverna.t2.reference.ReferencedDataNature;
-import net.sf.taverna.t2.reference.StreamToValueConverterSPI;
-
-/**
- * Build a byte[] from an InputStream
- * 
- * @author Tom Oinn
- */
-public class StreamToByteArrayConverter implements
-		StreamToValueConverterSPI<byte[]> {
-	private static final int CHUNK_SIZE = 4096;
-
-	static byte[] readFile(InputStream reader) throws IOException {
-		ByteArrayOutputStream bos = new ByteArrayOutputStream();
-		byte[] buf = new byte[CHUNK_SIZE];
-		int len;
-		while ((len = reader.read(buf)) > 0)
-			bos.write(buf, 0, len);
-		return bos.toByteArray();
-	}
-
-	@Override
-	public Class<byte[]> getPojoClass() {
-		return byte[].class;
-	}
-
-	@Override
-	public byte[] renderFrom(InputStream stream,
-			ReferencedDataNature dataNature, String charset) {
-		try {
-			return readFile(stream);
-		} catch (IOException e) {
-			throw new RuntimeException(e);
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToDoubleConverter.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToDoubleConverter.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToDoubleConverter.java
deleted file mode 100644
index 835c8cd..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToDoubleConverter.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * 
- */
-package net.sf.taverna.t2.reference.impl.external.object;
-
-import java.io.InputStream;
-
-import net.sf.taverna.t2.reference.ReferencedDataNature;
-import net.sf.taverna.t2.reference.StreamToValueConverterSPI;
-
-/**
- * @author alanrw
- */
-public class StreamToDoubleConverter implements
-		StreamToValueConverterSPI<Double> {
-	@Override
-	public Class<Double> getPojoClass() {
-		return Double.class;
-	}
-
-	@Override
-	public Double renderFrom(InputStream stream,
-			ReferencedDataNature dataNature, String charset) {
-		StreamToStringConverter stringConverter = new StreamToStringConverter();
-		String s = stringConverter.renderFrom(stream, dataNature, charset);
-		Double result = Double.valueOf(s.trim());
-		return result;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToIntegerConverter.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToIntegerConverter.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToIntegerConverter.java
deleted file mode 100644
index 2a42a24..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToIntegerConverter.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * 
- */
-package net.sf.taverna.t2.reference.impl.external.object;
-
-import java.io.InputStream;
-
-import net.sf.taverna.t2.reference.ReferencedDataNature;
-import net.sf.taverna.t2.reference.StreamToValueConverterSPI;
-
-/**
- * @author alanrw
- */
-public class StreamToIntegerConverter implements
-		StreamToValueConverterSPI<Integer> {
-	@Override
-	public Class<Integer> getPojoClass() {
-		return Integer.class;
-	}
-
-	@Override
-	public Integer renderFrom(InputStream stream,
-			ReferencedDataNature dataNature, String charset) {
-		StreamToStringConverter stringConverter = new StreamToStringConverter();
-		String s = stringConverter.renderFrom(stream, dataNature, charset);
-		Integer result = Integer.valueOf(s.trim());
-		return result;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToStringConverter.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToStringConverter.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToStringConverter.java
deleted file mode 100644
index 03edf56..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToStringConverter.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl.external.object;
-
-import static net.sf.taverna.t2.reference.ReferencedDataNature.TEXT;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.nio.charset.Charset;
-
-import net.sf.taverna.t2.reference.ReferencedDataNature;
-import net.sf.taverna.t2.reference.StreamToValueConverterSPI;
-
-/**
- * Build a String from an InputStream
- * 
- * @author Tom Oinn
- */
-public class StreamToStringConverter implements
-		StreamToValueConverterSPI<String> {
-	private static final int END_OF_FILE = -1;
-	private static final int CHUNK_SIZE = 4096;
-	private static final Charset UTF8 = Charset.forName("UTF-8");
-
-	/**
-	 * Reads a text file and returns a string.
-	 */
-	static String readFile(Reader reader) throws IOException {
-		BufferedReader br = new BufferedReader(reader);
-		StringBuilder buffer = new StringBuilder();
-		char[] chunk = new char[CHUNK_SIZE];
-		int character;
-		while ((character = br.read(chunk)) != END_OF_FILE)
-			buffer.append(chunk, 0, character);
-		return buffer.toString();
-	}
-
-	@Override
-	public Class<String> getPojoClass() {
-		return String.class;
-	}
-
-	@Override
-	public String renderFrom(InputStream stream,
-			ReferencedDataNature dataNature, String charset) {
-		try {
-			if (charset != null && dataNature.equals(TEXT))
-				try {
-					Charset c = Charset.forName(charset);
-					return readFile(new InputStreamReader(stream, c));
-				} catch (IllegalArgumentException e1) {
-					// Ignore; fallback below is good enough
-				}
-			return readFile(new InputStreamReader(stream, UTF8));
-		} catch (IOException e) {
-			throw new RuntimeException(e);
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToVMObjectReferenceConverter.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToVMObjectReferenceConverter.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToVMObjectReferenceConverter.java
deleted file mode 100644
index 45cbb5c..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StreamToVMObjectReferenceConverter.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl.external.object;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-
-import net.sf.taverna.t2.reference.ReferencedDataNature;
-import net.sf.taverna.t2.reference.StreamToValueConverterSPI;
-
-/**
- * Builds a VMObjectReference from an InputStream.
- * 
- * @author Alex Nenadic
- */
-public class StreamToVMObjectReferenceConverter implements
-		StreamToValueConverterSPI<VMObjectReference> {
-	@Override
-	public Class<VMObjectReference> getPojoClass() {
-		return VMObjectReference.class;
-	}
-
-	@Override
-	public VMObjectReference renderFrom(InputStream stream,
-			ReferencedDataNature dataNature, String charset) {
-		VMObjectReference vmRef = new VMObjectReference();
-		try {
-			ObjectInputStream in = new ObjectInputStream(stream);
-			vmRef = (VMObjectReference) in.readObject();
-			return vmRef;
-		} catch (IOException e) {
-			throw new RuntimeException(e);
-		} catch (ClassNotFoundException e) {
-			throw new RuntimeException(e);
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StringToStringReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StringToStringReference.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StringToStringReference.java
deleted file mode 100644
index 55b0573..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/StringToStringReference.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl.external.object;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ValueToReferenceConversionException;
-import net.sf.taverna.t2.reference.ValueToReferenceConverterSPI;
-
-/**
- * Convert a String to a StringReference
- * 
- * @author Tom Oinn
- */
-public class StringToStringReference implements ValueToReferenceConverterSPI {
-	/**
-	 * Can convert if the object is an instance of java.lang.String
-	 */
-	@Override
-	public boolean canConvert(Object o, ReferenceContext context) {
-		return o instanceof String;
-	}
-
-	/**
-	 * Return a new InlineStringReference wrapping the supplied String
-	 */
-	@Override
-	public ExternalReferenceSPI convert(Object o, ReferenceContext context)
-			throws ValueToReferenceConversionException {
-		InlineStringReference result = new InlineStringReference();
-		result.setContents((String) o);
-		return result;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/VMObjectReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/VMObjectReference.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/VMObjectReference.java
deleted file mode 100644
index 18b66f2..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/VMObjectReference.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program 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 program 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 program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl.external.object;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.nio.charset.Charset;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import net.sf.taverna.t2.reference.AbstractExternalReference;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-
-/**
- * Implementation of ExternalReferenceSPI used to refer to objects in the local
- * virtual machine.
- * 
- * @author Stian Soiland-Reyes
- * @author Alex Nenadic
- */
-public class VMObjectReference extends AbstractExternalReference implements
-		ExternalReferenceSPI, Serializable {
-	private static final long serialVersionUID = 6708284419760319684L;
-	private static final Charset UTF8 = Charset.forName("UTF-8");
-
-	/**
-	 * Mapping from objects to their UUIDs.
-	 */
-	private static Map<Object, UUID> objectToUUID = new HashMap<>();
-	/**
-	 * Mapping from UUIDs to objects.
-	 */
-	private static Map<UUID, Object> uuidToObject = new HashMap<>();
-
-	/**
-	 * Unique reference to the object.
-	 */
-	private String uuid;
-
-	@Override
-	public InputStream openStream(ReferenceContext context) {
-		return new ByteArrayInputStream(getObject().toString().getBytes(UTF8));
-	}
-
-	/**
-	 * Getter used by hibernate to retrieve the object uuid property.
-	 */
-	public String getUuid() {
-		return uuid;
-	}
-
-	/**
-	 * Setter used by hibernate to set the object uuid property.
-	 */
-	public void setUuid(String id) {
-		if (uuid != null)
-			throw new IllegalStateException("Can't set UUID of an object twice");
-		this.uuid = id;
-	}
-
-	public void setObject(Object object) {
-		if (uuid != null)
-			throw new IllegalStateException("Can't set UUID an object twice");
-		UUID knownUUID = objectToUUID.get(object);
-		if (knownUUID == null) {
-			// register object
-			knownUUID = UUID.randomUUID();
-			objectToUUID.put(object, knownUUID);
-			uuidToObject.put(knownUUID, object);
-		}
-		setUuid(knownUUID.toString());
-	}
-
-	public Object getObject() {
-		return uuidToObject.get(UUID.fromString(uuid));
-	}
-
-	@Override
-	public Long getApproximateSizeInBytes() {
-		// We do not know the object size
-		return new Long(-1);
-	}
-
-	@Override
-	public VMObjectReference clone() {
-		VMObjectReference result = new VMObjectReference();
-		result.setUuid(this.getUuid());
-		return result;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/package.html
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/package.html b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/package.html
deleted file mode 100644
index b5b3b72..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/package.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<body>
-Support for representation of inlined objects as references. Replaces
-the old Literal support
-</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/file/FileReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/file/FileReference.java b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/file/FileReference.java
new file mode 100644
index 0000000..75f8696
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/file/FileReference.java
@@ -0,0 +1,210 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program 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 program 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 program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package org.apache.taverna.reference.impl.external.file;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+
+import org.apache.taverna.reference.AbstractExternalReference;
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferencedDataNature;
+
+/**
+ * Implementation of ExternalReference used to refer to data held in a locally
+ * accessible file. Inherits from
+ * {@link org.apache.taverna.reference.AbstractExternalReference
+ * AbstractExternalReference} to enable hibernate based persistence.
+ * 
+ * @author Tom Oinn
+ */
+public class FileReference extends AbstractExternalReference implements
+		ExternalReferenceSPI {
+	private String filePathString = null;
+	private String charset = null;
+	private File file = null;
+	private String dataNatureName = ReferencedDataNature.UNKNOWN.name();
+
+	/**
+	 * Explicitly declare default constructor, will be used by hibernate when
+	 * constructing instances of this bean from the database.
+	 */
+	public FileReference() {
+		super();
+	}
+
+	/**
+	 * Construct a file reference pointed at the specified file and with no
+	 * character set defined.
+	 */
+	public FileReference(File theFile) {
+		super();
+		this.file = theFile.getAbsoluteFile();
+		this.filePathString = this.file.getPath();
+		this.charset = Charset.defaultCharset().name();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public InputStream openStream(ReferenceContext context) {
+		try {
+			return new FileInputStream(file);
+		} catch (FileNotFoundException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	/**
+	 * Setter used by hibernate to set the charset property of the file
+	 * reference
+	 */
+	public void setCharset(String charset) {
+		this.charset = charset;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public String getCharset() {
+		return this.charset;
+	}
+
+	/**
+	 * Setter used by hibernate to set the file path property of the file
+	 * reference
+	 */
+	public void setFilePath(String filePathString) {
+		this.filePathString = filePathString;
+		this.file = new File(filePathString).getAbsoluteFile();
+	}
+
+	/**
+	 * Getter used by hibernate to retrieve the file path string property
+	 */
+	public String getFilePath() {
+		return this.filePathString;
+	}
+
+	/**
+	 * Human readable string form for debugging, should not be regarded as
+	 * stable.
+	 */
+	@Override
+	public String toString() {
+		return "file{" + file.getAbsolutePath() + "}";
+	}
+
+	@Override
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + ((file == null) ? 0 : file.hashCode());
+		return result;
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (obj == null)
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		final FileReference other = (FileReference) obj;
+		if (file == null) {
+			if (other.file != null)
+				return false;
+		} else if (!file.equals(other.file))
+			return false;
+		return true;
+	}
+
+	@Override
+	public Long getApproximateSizeInBytes() {
+		return new Long(file.length());
+	}
+
+	/**
+	 * @return the dataNature
+	 */
+	@Override
+	public ReferencedDataNature getDataNature() {
+		return Enum.valueOf(ReferencedDataNature.class, getDataNatureName());
+	}
+
+	/**
+	 * @param dataNature
+	 *            the dataNature to set
+	 */
+	public void setDataNature(ReferencedDataNature dataNature) {
+		setDataNatureName(dataNature.name());
+	}
+
+	/**
+	 * @return the file
+	 */
+	public final File getFile() {
+		return file;
+	}
+
+	@Override
+	public float getResolutionCost() {
+		return (float) 100.0;
+	}
+
+	/**
+	 * @return the dataNatureName
+	 */
+	public String getDataNatureName() {
+		return dataNatureName;
+	}
+
+	/**
+	 * @param dataNatureName
+	 *            the dataNatureName to set
+	 */
+	public void setDataNatureName(String dataNatureName) {
+		this.dataNatureName = dataNatureName;
+	}
+
+	public void deleteData() {
+		try {
+			getFile().delete();
+		} catch (SecurityException e) {
+			// TODO
+		}
+	}
+
+	@Override
+	public FileReference clone() {
+		FileReference result = new FileReference();
+		result.setFilePath(this.getFilePath());
+		result.setCharset(this.getCharset());
+		result.setDataNature(this.getDataNature());
+		return result;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/file/FileToFileReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/file/FileToFileReference.java b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/file/FileToFileReference.java
new file mode 100644
index 0000000..67aba1a
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/file/FileToFileReference.java
@@ -0,0 +1,60 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl.external.file;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ValueToReferenceConversionException;
+import org.apache.taverna.reference.ValueToReferenceConverterSPI;
+
+/**
+ * Converts java.lang.File instances to FileReference reference type
+ * 
+ * @author Tom Oinn
+ */
+public class FileToFileReference implements ValueToReferenceConverterSPI {
+	/*
+	 * TODO - should probably do more sophisticated checks such as whether the
+	 * file is a file or directory etc etc, for now just checks whether the
+	 * specified object is a java.io.File
+	 */
+	@Override
+	public boolean canConvert(Object o, ReferenceContext context) {
+		return (o instanceof File);
+	}
+
+	/**
+	 * Return a FileReference
+	 */
+	@Override
+	public ExternalReferenceSPI convert(Object o, ReferenceContext context)
+			throws ValueToReferenceConversionException {
+		FileReference result = new FileReference();
+		try {
+			result.setFilePath(((File) o).getCanonicalPath());
+		} catch (IOException ioe) {
+			throw new ValueToReferenceConversionException(ioe);
+		}
+		return result;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/file/package.html
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/file/package.html b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/file/package.html
new file mode 100644
index 0000000..8be59b3
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/file/package.html
@@ -0,0 +1,4 @@
+<body>
+Support for references to a file on a local (or otherwise mounted)
+filesystem
+</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/http/HttpReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/http/HttpReference.java b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/http/HttpReference.java
new file mode 100644
index 0000000..45789a8
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/http/HttpReference.java
@@ -0,0 +1,216 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl.external.http;
+
+import static java.lang.System.currentTimeMillis;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Date;
+
+import org.apache.taverna.reference.AbstractExternalReference;
+import org.apache.taverna.reference.DereferenceException;
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ExternalReferenceValidationException;
+import org.apache.taverna.reference.ReferenceContext;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.HeadMethod;
+
+/**
+ * Implementation of ExternalReference used to refer to data held in a locally
+ * accessible file. Inherits from
+ * {@link org.apache.taverna.reference.AbstractExternalReference
+ * AbstractExternalReference} to enable hibernate based persistence.
+ * 
+ * @author Tom Oinn
+ */
+public class HttpReference extends AbstractExternalReference implements
+		ExternalReferenceSPI {
+	private String httpUrlString = null;
+	private URL httpUrl = null;
+	private String charsetName = null;
+	private boolean charsetFetched = false;
+	private transient Long cachedLength;
+	private transient Date cacheTime;
+
+	/**
+	 * Explicitly declare default constructor, will be used by hibernate when
+	 * constructing instances of this bean from the database.
+	 */
+	public HttpReference() {
+		super();
+	}
+
+	/**
+	 * Return the data at the {@link URL} represented by this external reference
+	 */
+	@Override
+	public InputStream openStream(ReferenceContext context)
+			throws DereferenceException {
+		try {
+			return httpUrl.openStream();
+		} catch (IOException e) {
+			throw new DereferenceException(e);
+		}
+	}
+
+	@Override
+	public String getCharset() throws DereferenceException {
+		if (charsetFetched)
+			return charsetName;
+		charsetFetched = true;
+		if (!httpUrl.getProtocol().equals("http")
+				&& !httpUrl.getProtocol().equals("https")) {
+			charsetName = null;
+			return null;
+		}
+		HeadMethod method = new HeadMethod(httpUrl.toExternalForm());
+		HttpClient httpClient = new HttpClient();
+		try {
+			httpClient.executeMethod(method);
+			charsetName = method.getResponseCharSet();
+			return charsetName;
+		} catch (HttpException e) {
+			// throw new DereferenceException(e);
+		} catch (IOException e) {
+			// throw new DereferenceException(e);
+		} finally {
+			method.releaseConnection();
+		}
+		charsetName = null;
+		return null;
+	}
+
+	/**
+	 * Setter used by hibernate to set the file path property of the file
+	 * reference
+	 * 
+	 * @throws ExternalReferenceValidationException
+	 *             if there is some problem parsing the supplied string as a URL
+	 */
+	public void setHttpUrlString(String httpUrlString) {
+		try {
+			this.httpUrlString = httpUrlString;
+			this.httpUrl = new URL(httpUrlString);
+		} catch (MalformedURLException e) {
+			throw new ExternalReferenceValidationException(e);
+		}
+	}
+
+	/**
+	 * Getter used by hibernate to retrieve the file path string property
+	 */
+	public String getHttpUrlString() {
+		return this.httpUrlString;
+	}
+
+	/**
+	 * Human readable string form for debugging, should not be regarded as
+	 * stable.
+	 */
+	@Override
+	public String toString() {
+		return "http{" + httpUrl.toExternalForm() + "}";
+	}
+
+	@Override
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result
+				+ ((httpUrl == null) ? 0 : httpUrl.toExternalForm().hashCode());
+		return result;
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (obj == null)
+			return false;
+		if (!(obj instanceof HttpReference))
+			return false;
+		final HttpReference other = (HttpReference) obj;
+		if (httpUrl == null) {
+			if (other.httpUrl != null)
+				return false;
+		} else if (!httpUrl.toExternalForm().equals(
+				other.httpUrl.toExternalForm()))
+			return false;
+		return true;
+	}
+
+	// One minute
+	private static final int CACHE_TIMEOUT = 60000;
+
+	@Override
+	public Long getApproximateSizeInBytes() {
+		long now = currentTimeMillis();
+		if (cachedLength != null && cacheTime != null
+				&& cacheTime.getTime() + CACHE_TIMEOUT > now)
+			return cachedLength;
+		try {
+			HttpURLConnection c = (HttpURLConnection) httpUrl.openConnection();
+			c.setRequestMethod("HEAD");
+			c.connect();
+			String lenString = c.getHeaderField("Content-Length");
+			if (lenString != null && !lenString.isEmpty()) {
+				cachedLength = new Long(lenString);
+				cacheTime = new Date(now);
+				return cachedLength;
+			}
+			// there is no Content-Length field so we cannot know the size
+		} catch (Exception e) {
+			// something went wrong, but we don't care what
+		}
+		cachedLength = null;
+		cacheTime = null;
+		return new Long(-1);
+	}
+
+	/**
+	 * @return the httpUrl
+	 */
+	public final URL getHttpUrl() {
+		return httpUrl;
+	}
+
+	@Override
+	public float getResolutionCost() {
+		return (float) 200.0;
+	}
+
+	public void deleteData() {
+		throw new UnsupportedOperationException(
+				"Cannot delete data referenced by a URL");
+	}
+
+	@Override
+	public HttpReference clone() {
+		HttpReference result = new HttpReference();
+		result.setHttpUrlString(this.getHttpUrlString());
+		return result;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/http/UrlToHttpReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/http/UrlToHttpReference.java b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/http/UrlToHttpReference.java
new file mode 100644
index 0000000..5556f1f
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/http/UrlToHttpReference.java
@@ -0,0 +1,61 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl.external.http;
+
+import java.net.URL;
+
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ValueToReferenceConversionException;
+import org.apache.taverna.reference.ValueToReferenceConverterSPI;
+
+/**
+ * Convert a URL with http protocol to a HttpReference reference type
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public class UrlToHttpReference implements ValueToReferenceConverterSPI {
+	/**
+	 * Can convert if the object is an instance of java.net.URL and the protocol
+	 * is HTTP
+	 */
+	@Override
+	public boolean canConvert(Object o, ReferenceContext context) {
+		if (o instanceof URL) {
+			String protocol = ((URL) o).getProtocol();
+			if (protocol.equalsIgnoreCase("http") || protocol.equals("https"))
+				return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Return a new HttpReference constructed from
+	 * <code>((URL)o).toExternalForm()</code>
+	 */
+	@Override
+	public ExternalReferenceSPI convert(Object o, ReferenceContext context)
+			throws ValueToReferenceConversionException {
+		HttpReference result = new HttpReference();
+		result.setHttpUrlString(((URL) o).toExternalForm());
+		return result;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/http/package.html
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/http/package.html b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/http/package.html
new file mode 100644
index 0000000..49d1d32
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/http/package.html
@@ -0,0 +1,3 @@
+<body>
+Support for references to a URL with the HTTP protocol
+</body>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/BooleanToStringReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/BooleanToStringReference.java b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/BooleanToStringReference.java
new file mode 100644
index 0000000..fe2278c
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/BooleanToStringReference.java
@@ -0,0 +1,52 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl.external.object;
+
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ValueToReferenceConversionException;
+import org.apache.taverna.reference.ValueToReferenceConverterSPI;
+
+/**
+ * Convert a java.lang.Boolean to a StringReference.
+ * 
+ * @author Alan R Williams
+ */
+public class BooleanToStringReference implements ValueToReferenceConverterSPI {
+	/**
+	 * Can convert if the object is an instance of java.lang.Boolean
+	 */
+	@Override
+	public boolean canConvert(Object o, ReferenceContext context) {
+		return o instanceof Boolean;
+	}
+
+	/**
+	 * Return a new InlineStringReference wrapping the supplied String
+	 */
+	@Override
+	public ExternalReferenceSPI convert(Object o, ReferenceContext context)
+			throws ValueToReferenceConversionException {
+		InlineStringReference result = new InlineStringReference();
+		String stringValue = ((Boolean) o).toString();
+		result.setContents(stringValue);
+		return result;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/ByteArrayToByteArrayReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/ByteArrayToByteArrayReference.java b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/ByteArrayToByteArrayReference.java
new file mode 100644
index 0000000..f430a8d
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/ByteArrayToByteArrayReference.java
@@ -0,0 +1,52 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl.external.object;
+
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ValueToReferenceConversionException;
+import org.apache.taverna.reference.ValueToReferenceConverterSPI;
+
+/**
+ * Convert a byte[] to a ByteArrayReference
+ * 
+ * @author Tom Oinn
+ */
+public class ByteArrayToByteArrayReference implements
+		ValueToReferenceConverterSPI {
+	/**
+	 * Can convert if the object is an instance of byte[]
+	 */
+	@Override
+	public boolean canConvert(Object o, ReferenceContext context) {
+		return (o instanceof byte[]);
+	}
+
+	/**
+	 * Return a new InlineByteArrayReference wrapping the supplied byte[]
+	 */
+	@Override
+	public ExternalReferenceSPI convert(Object o, ReferenceContext context)
+			throws ValueToReferenceConversionException {
+		InlineByteArrayReference result = new InlineByteArrayReference();
+		result.setValue((byte[]) o);
+		return result;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/CharacterToStringReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/CharacterToStringReference.java b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/CharacterToStringReference.java
new file mode 100644
index 0000000..50f2bf0
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/CharacterToStringReference.java
@@ -0,0 +1,52 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl.external.object;
+
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ValueToReferenceConversionException;
+import org.apache.taverna.reference.ValueToReferenceConverterSPI;
+
+/**
+ * Convert a {@link Character} to a StringReference.
+ * 
+ * @author Alan R Williams
+ */
+public class CharacterToStringReference implements ValueToReferenceConverterSPI {
+	/**
+	 * Can convert if the object is an instance of java.lang.Character
+	 */
+	@Override
+	public boolean canConvert(Object o, ReferenceContext context) {
+		return (o instanceof Character);
+	}
+
+	/**
+	 * Return a new {@link InlineStringReference} wrapping the supplied String
+	 */
+	@Override
+	public ExternalReferenceSPI convert(Object o, ReferenceContext context)
+			throws ValueToReferenceConversionException {
+		InlineStringReference result = new InlineStringReference();
+		String stringValue = ((Character) o).toString();
+		result.setContents(stringValue);
+		return result;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineByteArrayReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineByteArrayReference.java b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineByteArrayReference.java
new file mode 100644
index 0000000..b46be24
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineByteArrayReference.java
@@ -0,0 +1,92 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl.external.object;
+
+import static org.apache.commons.codec.binary.Base64.decodeBase64;
+import static org.apache.commons.codec.binary.Base64.encodeBase64;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+
+import org.apache.taverna.reference.AbstractExternalReference;
+import org.apache.taverna.reference.DereferenceException;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ValueCarryingExternalReference;
+
+/**
+ * A reference implementation that inlines an array of bytes. Rather
+ * unpleasantly this currently exposes the byte array to Hibernate through a
+ * textual value, as Derby allows long textual values but not long binary ones
+ * (yuck). As it uses a fixed character set (UTF-8) to store and load I believe
+ * this doesn't break things.
+ * <p>
+ * Unfortunately this does break things (binaries get corrupted) so I've added
+ * base64 encoding of the value as a workaround.
+ * 
+ * @author Tom Oinn
+ * @author David Withers
+ */
+public class InlineByteArrayReference extends AbstractExternalReference
+		implements ValueCarryingExternalReference<byte[]> {
+	private byte[] bytes = new byte[0];
+
+	public void setValue(byte[] newBytes) {
+		this.bytes = newBytes;
+	}
+
+	@Override
+	public byte[] getValue() {
+		return bytes;
+	}
+
+	@Override
+	public Class<byte[]> getValueType() {
+		return byte[].class;
+	}
+
+	@Override
+	public InputStream openStream(ReferenceContext context)
+			throws DereferenceException {
+		return new ByteArrayInputStream(bytes);
+	}
+
+	private static final Charset charset = Charset.forName("UTF-8");
+
+	public String getContents() {
+		return new String(encodeBase64(bytes), charset);
+	}
+
+	public void setContents(String contentsAsString) {
+		this.bytes = decodeBase64(contentsAsString.getBytes(charset));
+	}
+
+	@Override
+	public Long getApproximateSizeInBytes() {
+		return new Long(bytes.length);
+	}
+
+	@Override
+	public InlineByteArrayReference clone() {
+		InlineByteArrayReference result = new InlineByteArrayReference();
+		result.setValue(this.getValue().clone());
+		return result;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineByteArrayReferenceBuilder.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineByteArrayReferenceBuilder.java b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineByteArrayReferenceBuilder.java
new file mode 100644
index 0000000..286a385
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineByteArrayReferenceBuilder.java
@@ -0,0 +1,66 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl.external.object;
+
+import static org.apache.taverna.reference.impl.external.object.StreamToByteArrayConverter.readFile;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.taverna.reference.ExternalReferenceBuilderSPI;
+import org.apache.taverna.reference.ExternalReferenceConstructionException;
+import org.apache.taverna.reference.ReferenceContext;
+
+/**
+ * Build an InlineByteArrayReference from an InputStream
+ * 
+ * @author Tom Oinn
+ * 
+ */
+public class InlineByteArrayReferenceBuilder implements
+		ExternalReferenceBuilderSPI<InlineByteArrayReference> {
+	@Override
+	public InlineByteArrayReference createReference(InputStream byteStream,
+			ReferenceContext context) {
+		try {
+			byte[] contents = readFile(byteStream);
+			InlineByteArrayReference ref = new InlineByteArrayReference();
+			ref.setValue(contents);
+			return ref;
+		} catch (IOException e) {
+			throw new ExternalReferenceConstructionException(e);
+		}
+	}
+
+	@Override
+	public float getConstructionCost() {
+		return 0.1f;
+	}
+
+	@Override
+	public Class<InlineByteArrayReference> getReferenceType() {
+		return InlineByteArrayReference.class;
+	}
+
+	@Override
+	public boolean isEnabled(ReferenceContext context) {
+		return true;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineByteToInlineStringTranslator.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineByteToInlineStringTranslator.java b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineByteToInlineStringTranslator.java
new file mode 100644
index 0000000..6d21cae
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineByteToInlineStringTranslator.java
@@ -0,0 +1,70 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl.external.object;
+
+import java.io.UnsupportedEncodingException;
+
+import org.apache.taverna.reference.ExternalReferenceConstructionException;
+import org.apache.taverna.reference.ExternalReferenceTranslatorSPI;
+import org.apache.taverna.reference.ReferenceContext;
+
+public class InlineByteToInlineStringTranslator
+		implements
+		ExternalReferenceTranslatorSPI<InlineByteArrayReference, InlineStringReference> {
+	@Override
+	public InlineStringReference createReference(
+			InlineByteArrayReference sourceReference, ReferenceContext context) {
+		String contents;
+		try {
+			String charset = sourceReference.getCharset();
+			if (charset == null)
+				// usual fallback:
+				charset = "UTF-8";
+			contents = new String(sourceReference.getValue(), charset);
+		} catch (UnsupportedEncodingException e) {
+			String msg = "Unknown character set "
+					+ sourceReference.getCharset();
+			throw new ExternalReferenceConstructionException(msg, e);
+		}
+		InlineStringReference ref = new InlineStringReference();
+		ref.setContents(contents);
+		return ref;
+	}
+
+	@Override
+	public Class<InlineByteArrayReference> getSourceReferenceType() {
+		return InlineByteArrayReference.class;
+	}
+
+	@Override
+	public Class<InlineStringReference> getTargetReferenceType() {
+		return InlineStringReference.class;
+	}
+
+	@Override
+	public boolean isEnabled(ReferenceContext context) {
+		return true;
+	}
+
+	@Override
+	public float getTranslationCost() {
+		return 0.001f;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineStringReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineStringReference.java b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineStringReference.java
new file mode 100644
index 0000000..fde3a8c
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineStringReference.java
@@ -0,0 +1,132 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl.external.object;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.taverna.reference.AbstractExternalReference;
+import org.apache.taverna.reference.DereferenceException;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferencedDataNature;
+import org.apache.taverna.reference.ValueCarryingExternalReference;
+
+/**
+ * Contains and references a String value
+ * 
+ * @author Tom Oinn
+ */
+public class InlineStringReference extends AbstractExternalReference implements
+		ValueCarryingExternalReference<String> {
+	/**
+	 * Hold the 'value' of this reference, probably the simplest backing store
+	 * possible for an ExternalReferenceSPI implementation :)
+	 */
+	private String contents;
+	private transient Long length;
+
+	/**
+	 * Set the 'value' of this reference as a string. It's not really a
+	 * reference type in any true sense of the word, but it'll do for testing
+	 * the augmentation system. This method is really here so you can configure
+	 * test beans from spring.
+	 */
+	public void setContents(String contents) {
+		this.contents = contents;
+	}
+
+	/**
+	 * Get the 'value' of this reference as a string, really just returns the
+	 * internal string representation.
+	 */
+	public String getContents() {
+		return this.contents;
+	}
+
+	/**
+	 * Fakes a de-reference operation, returning a byte stream over the string
+	 * data.
+	 */
+	@Override
+	public InputStream openStream(ReferenceContext arg0) {
+		try {
+			return new ByteArrayInputStream(contents.getBytes(getCharset()));
+		} catch (UnsupportedEncodingException e) {
+			throw new DereferenceException(e);
+		}
+	}
+
+	/**
+	 * Default resolution cost of 0.0f whatever the contents
+	 */
+	@Override
+	public float getResolutionCost() {
+		return 0.0f;
+	}
+
+	/**
+	 * Data nature set to 'ReferencedDataNature.TEXT'
+	 */
+	@Override
+	public ReferencedDataNature getDataNature() {
+		return ReferencedDataNature.TEXT;
+	}
+
+	/**
+	 * Character encoding set to 'UTF-8' by default
+	 */
+	@Override
+	public String getCharset() {
+		return "UTF-8";
+	}
+
+	/**
+	 * String representation for testing, returns <code>string{CONTENTS}</code>
+	 */
+	@Override
+	public String toString() {
+		return "string{" + contents + "}";
+	}
+
+	@Override
+	public String getValue() {
+		return getContents();
+	}
+
+	@Override
+	public Class<String> getValueType() {
+		return String.class;
+	}
+
+	@Override
+	public Long getApproximateSizeInBytes() {
+		if (length == null)
+			length = new Long(contents.getBytes().length);
+		return length;
+	}
+
+	@Override
+	public InlineStringReference clone() {
+		InlineStringReference result = new InlineStringReference();
+		result.setContents(this.getContents());
+		return result;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineStringReferenceBuilder.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineStringReferenceBuilder.java b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineStringReferenceBuilder.java
new file mode 100644
index 0000000..2b2824d
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineStringReferenceBuilder.java
@@ -0,0 +1,75 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl.external.object;
+
+import static org.apache.taverna.reference.impl.external.object.StreamToStringConverter.readFile;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.Charset;
+
+import org.apache.taverna.reference.ExternalReferenceBuilderSPI;
+import org.apache.taverna.reference.ExternalReferenceConstructionException;
+import org.apache.taverna.reference.ReferenceContext;
+
+/**
+ * Build an InlineStringReference from an InputStream
+ * 
+ * @author Tom Oinn
+ */
+public class InlineStringReferenceBuilder implements
+		ExternalReferenceBuilderSPI<InlineStringReference> {
+	private static final Charset UTF8 = Charset.forName("UTF-8");
+	
+	@Override
+	public InlineStringReference createReference(InputStream byteStream,
+			ReferenceContext context) {
+		try {
+			/*
+			 * UTF8 is a slightly saner default than system default for most
+			 * bytestreams
+			 */
+			String contents = readFile(new BufferedReader(
+					new InputStreamReader(byteStream, UTF8)));
+			InlineStringReference ref = new InlineStringReference();
+			ref.setContents(contents);
+			return ref;
+		} catch (IOException e) {
+			throw new ExternalReferenceConstructionException(e);
+		}
+	}
+
+	@Override
+	public float getConstructionCost() {
+		return 0.1f;
+	}
+
+	@Override
+	public Class<InlineStringReference> getReferenceType() {
+		return InlineStringReference.class;
+	}
+
+	@Override
+	public boolean isEnabled(ReferenceContext context) {
+		return true;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineStringToInlineByteTranslator.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineStringToInlineByteTranslator.java b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineStringToInlineByteTranslator.java
new file mode 100644
index 0000000..75b9733
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/InlineStringToInlineByteTranslator.java
@@ -0,0 +1,59 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl.external.object;
+
+import java.nio.charset.Charset;
+
+import org.apache.taverna.reference.ExternalReferenceTranslatorSPI;
+import org.apache.taverna.reference.ReferenceContext;
+
+public class InlineStringToInlineByteTranslator implements
+		ExternalReferenceTranslatorSPI<InlineStringReference, InlineByteArrayReference> {
+	private static final Charset UTF8 = Charset.forName("UTF-8");
+	
+	@Override
+	public InlineByteArrayReference createReference(
+			InlineStringReference sourceReference, ReferenceContext context) {
+		byte[] bytes = sourceReference.getValue().getBytes(UTF8);
+		InlineByteArrayReference ref = new InlineByteArrayReference();
+		ref.setValue(bytes);	
+		return ref;
+	}
+
+	@Override
+	public Class<InlineStringReference> getSourceReferenceType() {
+		return InlineStringReference.class;
+	}
+
+	@Override
+	public Class<InlineByteArrayReference> getTargetReferenceType() {
+		return InlineByteArrayReference.class;
+	}
+
+	@Override
+	public boolean isEnabled(ReferenceContext context) {
+		return true;
+	}
+
+	@Override
+	public float getTranslationCost() {
+		return 0.001f;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/NumberToStringReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/NumberToStringReference.java b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/NumberToStringReference.java
new file mode 100644
index 0000000..1071fd0
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/NumberToStringReference.java
@@ -0,0 +1,51 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl.external.object;
+
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ValueToReferenceConversionException;
+import org.apache.taverna.reference.ValueToReferenceConverterSPI;
+
+/**
+ * Convert a java.lang.Number to a StringReference.
+ * 
+ * @author Alex Nenadic
+ */
+public class NumberToStringReference implements ValueToReferenceConverterSPI {
+	/**
+	 * Can convert if the object is an instance of java.lang.Number
+	 */
+	@Override
+	public boolean canConvert(Object o, ReferenceContext context) {
+		return o instanceof Number;
+	}
+
+	/**
+	 * Return a new InlineStringReference wrapping the supplied String
+	 */
+	@Override
+	public ExternalReferenceSPI convert(Object o, ReferenceContext context)
+			throws ValueToReferenceConversionException {
+		InlineStringReference result = new InlineStringReference();
+		result.setContents(o.toString());
+		return result;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToBooleanConverter.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToBooleanConverter.java b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToBooleanConverter.java
new file mode 100644
index 0000000..fc1e748
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToBooleanConverter.java
@@ -0,0 +1,45 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl.external.object;
+
+import java.io.InputStream;
+
+import org.apache.taverna.reference.ReferencedDataNature;
+import org.apache.taverna.reference.StreamToValueConverterSPI;
+
+/**
+ * @author alanrw
+ */
+public class StreamToBooleanConverter implements
+		StreamToValueConverterSPI<Boolean> {
+	@Override
+	public Class<Boolean> getPojoClass() {
+		return Boolean.class;
+	}
+
+	@Override
+	public Boolean renderFrom(InputStream stream,
+			ReferencedDataNature dataNature, String charset) {
+		StreamToStringConverter stringConverter = new StreamToStringConverter();
+		String s = stringConverter.renderFrom(stream, dataNature, charset);
+		Boolean result = Boolean.valueOf(s.trim());
+		return result;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToByteArrayConverter.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToByteArrayConverter.java b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToByteArrayConverter.java
new file mode 100644
index 0000000..34a5e6e
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToByteArrayConverter.java
@@ -0,0 +1,61 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl.external.object;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.taverna.reference.ReferencedDataNature;
+import org.apache.taverna.reference.StreamToValueConverterSPI;
+
+/**
+ * Build a byte[] from an InputStream
+ * 
+ * @author Tom Oinn
+ */
+public class StreamToByteArrayConverter implements
+		StreamToValueConverterSPI<byte[]> {
+	private static final int CHUNK_SIZE = 4096;
+
+	static byte[] readFile(InputStream reader) throws IOException {
+		ByteArrayOutputStream bos = new ByteArrayOutputStream();
+		byte[] buf = new byte[CHUNK_SIZE];
+		int len;
+		while ((len = reader.read(buf)) > 0)
+			bos.write(buf, 0, len);
+		return bos.toByteArray();
+	}
+
+	@Override
+	public Class<byte[]> getPojoClass() {
+		return byte[].class;
+	}
+
+	@Override
+	public byte[] renderFrom(InputStream stream,
+			ReferencedDataNature dataNature, String charset) {
+		try {
+			return readFile(stream);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToDoubleConverter.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToDoubleConverter.java b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToDoubleConverter.java
new file mode 100644
index 0000000..4d61697
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToDoubleConverter.java
@@ -0,0 +1,45 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl.external.object;
+
+import java.io.InputStream;
+
+import org.apache.taverna.reference.ReferencedDataNature;
+import org.apache.taverna.reference.StreamToValueConverterSPI;
+
+/**
+ * @author alanrw
+ */
+public class StreamToDoubleConverter implements
+		StreamToValueConverterSPI<Double> {
+	@Override
+	public Class<Double> getPojoClass() {
+		return Double.class;
+	}
+
+	@Override
+	public Double renderFrom(InputStream stream,
+			ReferencedDataNature dataNature, String charset) {
+		StreamToStringConverter stringConverter = new StreamToStringConverter();
+		String s = stringConverter.renderFrom(stream, dataNature, charset);
+		Double result = Double.valueOf(s.trim());
+		return result;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToIntegerConverter.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToIntegerConverter.java b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToIntegerConverter.java
new file mode 100644
index 0000000..7eacfa9
--- /dev/null
+++ b/taverna-reference-types/src/main/java/org/apache/taverna/reference/impl/external/object/StreamToIntegerConverter.java
@@ -0,0 +1,45 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl.external.object;
+
+import java.io.InputStream;
+
+import org.apache.taverna.reference.ReferencedDataNature;
+import org.apache.taverna.reference.StreamToValueConverterSPI;
+
+/**
+ * @author alanrw
+ */
+public class StreamToIntegerConverter implements
+		StreamToValueConverterSPI<Integer> {
+	@Override
+	public Class<Integer> getPojoClass() {
+		return Integer.class;
+	}
+
+	@Override
+	public Integer renderFrom(InputStream stream,
+			ReferencedDataNature dataNature, String charset) {
+		StreamToStringConverter stringConverter = new StreamToStringConverter();
+		String s = stringConverter.renderFrom(stream, dataNature, charset);
+		Integer result = Integer.valueOf(s.trim());
+		return result;
+	}
+}