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:38:01 UTC

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

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>