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/19 14:44:02 UTC

[34/35] incubator-taverna-common-activities git commit: package names changed to org.apache.taverna.*

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/433612be/taverna-beanshell-activity/src/main/java/org/apache/taverna/activities/dependencyactivity/AbstractAsynchronousDependencyActivity.java
----------------------------------------------------------------------
diff --git a/taverna-beanshell-activity/src/main/java/org/apache/taverna/activities/dependencyactivity/AbstractAsynchronousDependencyActivity.java b/taverna-beanshell-activity/src/main/java/org/apache/taverna/activities/dependencyactivity/AbstractAsynchronousDependencyActivity.java
new file mode 100644
index 0000000..1feb73c
--- /dev/null
+++ b/taverna-beanshell-activity/src/main/java/org/apache/taverna/activities/dependencyactivity/AbstractAsynchronousDependencyActivity.java
@@ -0,0 +1,442 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.dependencyactivity;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.lang.ref.WeakReference;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.HashSet;
+import java.util.WeakHashMap;
+
+import net.sf.taverna.t2.facade.WorkflowInstanceFacade;
+import net.sf.taverna.t2.workflowmodel.Dataflow;
+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.NestedDataflow;
+
+import org.apache.log4j.Logger;
+
+import uk.org.taverna.configuration.app.ApplicationConfiguration;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * A parent abstract class for activities that require dependency management, such as
+ * API Consumer and Beanshell. Defines dependencies on local JAR files
+ * and Raven artifacts.
+ *
+ * @author Alex Nenadic
+ * @author Tom Oinn
+ * @author Stian Soiland-Reyes
+ */
+public abstract class AbstractAsynchronousDependencyActivity extends AbstractAsynchronousActivity<JsonNode> {
+
+	private static final String LOCAL_JARS = "Local jars";
+
+	private static Logger logger = Logger.getLogger(AbstractAsynchronousDependencyActivity.class);
+
+	/**
+	 * For persisting class loaders across a whole workflow run (when classloader sharing
+	 * is set to 'workflow'). The key in the map is the workflow run ID and we are using
+	 * a WeakHashMap so we don't keep up references to classloaders of old workflow runs.
+	 */
+	private static WeakHashMap<String, ClassLoader> workflowClassLoaders =
+		new WeakHashMap<String, ClassLoader>();
+
+	/**
+	 * System classloader, in case when classloader sharing is set to 'system'.
+	 */
+	private static ClassLoader systemClassLoader = null;
+
+	/**
+	 * Classloader to be used for 'executing' this activity, depending on the activity's
+	 * class loader sharing policy.
+	 */
+	protected ClassLoader classLoader = null;
+
+	/**
+	 * The location of the <code>lib</code> directory in TAVERNA_HOME,
+	 * where local JAR files the activity depends on should be located.
+	 */
+	public File libDir;
+
+	/**
+	 * Different ways to share a class loader among activities:
+	 *
+	 * <dl>
+	 * <dt>workflow</dt>
+	 * <dd>Same classloader for all activities using the <code>workflow</code> classloader sharing policy</dd>
+	 * <dt>system</dt>
+	 * <dd>System classloader</dd>
+	 * </dl>
+	 *
+	 */
+	public static enum ClassLoaderSharing {
+	    workflow, system;
+	    public static final ClassLoaderSharing DEFAULT = workflow;
+	    public static ClassLoaderSharing fromString(String str) {
+	        if (str == null || str.isEmpty()) {
+	            return DEFAULT;
+	        }
+	        return valueOf(str.toLowerCase());
+	    }
+	}
+
+	public AbstractAsynchronousDependencyActivity(ApplicationConfiguration applicationConfiguration) {
+		if (applicationConfiguration != null) {
+			libDir = new File(applicationConfiguration.getApplicationHomeDir(), "lib");
+		}
+	}
+
+	/**
+	 * Finds or constructs the classloader. The classloader depends on the
+	 * current classloader sharing policy as defined by {@link #ClassLoaderSharing}.
+	 * <p>
+	 * If the classloader sharing is {@link ClassLoaderSharing#workflow}, a
+	 * common classloader will be used for the whole workflow for all activities
+	 * with the same (i.e. {@link ClassLoaderSharing#workflow}) policy.
+	 * The dependencies will be constructed as union of local and artifact dependencies
+	 * of all 'workflow' classloader sharing activities at the point of the first
+	 * call to {@link #getClassLoader()}.
+ 	 * <p>
+	 * If the classloader sharing is {@link ClassLoaderSharing#system}, the
+	 * system classloader will be used. Note that both local and artifact dependencies
+	 * configured on the activity will be ignored. Local dependencies can be set by
+	 * using <code>-classpath</code> when starting the workbench.
+	 * This is useful in combination with JNI based libraries, which would also
+	 * require <code>-Djava.library.path</code> and possibly the operating
+	 * system's PATH / LD_LIBRARY_PATH / DYLD_LIBRARY_PATH environment variable.
+	 * @param classLoaderSharing
+	 *
+	 * @return A new or existing {@link ClassLoader} according to the
+	 *         classloader sharing policy
+	 */
+	protected ClassLoader findClassLoader(JsonNode json, String workflowRunID) throws RuntimeException{
+		ClassLoaderSharing classLoaderSharing;
+		if (json.has("classLoaderSharing")) {
+			classLoaderSharing = ClassLoaderSharing.fromString(json.get("classLoaderSharing").textValue());
+		} else {
+			classLoaderSharing = ClassLoaderSharing.workflow;
+		}
+
+		if (classLoaderSharing == ClassLoaderSharing.workflow) {
+			synchronized (workflowClassLoaders) {
+				ClassLoader cl = workflowClassLoaders.get(workflowRunID);
+				if (cl == null) {
+					cl = makeClassLoader(json, workflowRunID);
+					workflowClassLoaders.put(workflowRunID, cl);
+				}
+				return cl;
+			}
+		}
+		if (classLoaderSharing == ClassLoaderSharing.system) {
+//			if (systemClassLoader == null)
+//				systemClassLoader = PreLauncher.getInstance().getLaunchingClassLoader();
+
+//			if (systemClassLoader instanceof BootstrapClassLoader){
+//				// Add local and artifact dependencies to the classloader
+//				updateBootstrapClassLoader(
+//						(BootstrapClassLoader) systemClassLoader,
+//						configurationBean, workflowRunID);
+//				return systemClassLoader;
+//			}
+//			else{
+				// Local dependencies will have to be set with the -classpath option
+				// We cannot have artifact dependencies in this case
+				String message = "System classloader is not Taverna's BootstrapClassLoader, so local dependencies " +
+						"have to defined with -classpath. Artifact dependencies are ignored completely.";
+				logger.warn(message);
+				return systemClassLoader;
+//			}
+		}
+		String message = "Unknown classloader sharing policy named '"+ classLoaderSharing+ "' for " + this.getClass();
+		logger.error(message);
+		throw new RuntimeException(message);
+	}
+
+	/**
+	 * Constructs a classloader capable of finding both local jar and artifact dependencies.
+	 * Called when classloader sharing policy is set to 'workflow'.
+	 *
+	 * @return A {@link ClassLoader} capable of accessing all the dependencies (both local jar and artifact)
+	 */
+	private ClassLoader makeClassLoader(JsonNode json, String workflowID) {
+		// Find all artifact dependencies
+//		HashSet<URL> urls = findDependencies(ARTIFACTS, configurationBean, workflowID);
+
+		// Add all local jar dependencies
+		HashSet<URL> urls = findDependencies(LOCAL_JARS, json, workflowID);
+
+		// Create the classloader capable of loading both local jar and artifact dependencies
+		ClassLoader parent = this.getClass().getClassLoader(); // this will be a LocalArtifactClassLoader
+
+		return new URLClassLoader(urls.toArray(new URL[0]), parent) {
+
+			// For finding native libraries that have to be stored in TAVERNA_HOME/lib
+			@Override
+			protected String findLibrary(String libname) {
+				String filename = System.mapLibraryName(libname);
+				File libraryFile = new File(libDir, filename);
+				if (libraryFile.isFile()) {
+					logger.info("Found library " + libname + ": " + libraryFile.getAbsolutePath());
+					return libraryFile.getAbsolutePath();
+				}
+				return super.findLibrary(libname);
+			}
+		};
+	}
+
+	/**
+	 * Adds local or artifact dependencies identified by {@link #findDependencies()} to the
+	 * {@link BootstrapClassLoader} system classloader.
+	 * Called when classloader sharing policy is set to 'system'.
+	 *
+	 * @param loader The augmented BootstrapClassLoader system classloader
+	 */
+//	private void updateBootstrapClassLoader(BootstrapClassLoader loader,
+//			DependencyActivityConfigurationBean configurationBean,
+//			String workflowRunID) {
+//
+//		HashSet<URL> depsURLs = new HashSet<URL>();
+//		depsURLs.addAll(findDependencies(LOCAL_JARS, configurationBean, workflowRunID));
+//		depsURLs.addAll(findDependencies(ARTIFACTS, configurationBean, workflowRunID));
+//
+//		Set<URL> exists = new HashSet<URL>(Arrays.asList(loader.getURLs()));
+//		for (URL url : depsURLs) {
+//			if (exists.contains(url)) {
+//				continue;
+//			}
+//			logger.info("Registering with system classloader: " + url);
+//			loader.addURL(url);
+//			exists.add(url);
+//		}
+//	}
+
+	/**
+	 * Finds either local jar or artifact dependencies' URLs for the given classloader
+	 * sharing policy (passed inside configuration bean) and a workflowRunID (used to
+	 * retrieve the workflow) that will be added to this activity classloader's list of URLs.
+	 */
+	private HashSet<URL> findDependencies(String dependencyType, JsonNode json, String workflowRunID) {
+		ClassLoaderSharing classLoaderSharing;
+		if (json.has("classLoaderSharing")) {
+			classLoaderSharing = ClassLoaderSharing.fromString(json.get("classLoaderSharing").textValue());
+		} else {
+			classLoaderSharing = ClassLoaderSharing.workflow;
+		}
+ 		// Get the WorkflowInstanceFacade which contains the current workflow
+		WeakReference<WorkflowInstanceFacade> wfFacadeRef = WorkflowInstanceFacade.workflowRunFacades.get(workflowRunID);
+		WorkflowInstanceFacade wfFacade = null;
+		if (wfFacadeRef != null) {
+			wfFacade = wfFacadeRef.get();
+		}
+		Dataflow wf = null;
+		if (wfFacade != null) {
+			wf = wfFacade.getDataflow();
+		}
+
+		// Files of dependencies for all activities in the workflow that share the classloading policy
+		HashSet<File> dependencies = new HashSet<File>();
+		// Urls of all dependencies
+		HashSet<URL> dependenciesURLs = new HashSet<URL>();
+
+		if (wf != null){
+			// Merge in dependencies from all activities that have the same classloader-sharing
+			// as this activity
+			for (Processor proc : wf.getProcessors()) {
+				// Nested workflow case
+				if (!proc.getActivityList().isEmpty() && proc.getActivityList().get(0) instanceof NestedDataflow){
+					// Get the nested workflow
+					Dataflow nestedWorkflow = ((NestedDataflow) proc.getActivityList().get(0)).getNestedDataflow();
+					dependenciesURLs.addAll(findNestedDependencies(dependencyType, json, nestedWorkflow));
+				}
+				else{ // Not nested - go through all of the processor's activities
+					Activity<?> activity = proc.getActivityList().get(0);
+					if (activity instanceof AbstractAsynchronousDependencyActivity){
+						AbstractAsynchronousDependencyActivity dependencyActivity = (AbstractAsynchronousDependencyActivity) activity;
+//							if (dependencyType.equals(LOCAL_JARS)){
+								// Collect the files of all found local dependencies
+							if (dependencyActivity.getConfiguration().has("localDependency")) {
+								for (JsonNode jar : dependencyActivity.getConfiguration().get("localDependency")) {
+									try {
+										dependencies.add(new File(libDir, jar.textValue()));
+									} catch (Exception ex) {
+										logger.warn("Invalid URL for " + jar, ex);
+										continue;
+									}
+								}
+							}
+//							} else if (dependencyType.equals(ARTIFACTS) && this.getClass().getClassLoader() instanceof LocalArtifactClassLoader){
+//								LocalArtifactClassLoader cl = (LocalArtifactClassLoader) this.getClass().getClassLoader(); // this class is always loaded with LocalArtifactClassLoader
+//								// Get the LocalReposotpry capable of finding artifact jar files
+//								LocalRepository rep  = (LocalRepository) cl.getRepository();
+//								for (BasicArtifact art : ((DependencyActivityConfigurationBean) activity
+//												.getConfiguration())
+//												.getArtifactDependencies()){
+//									dependencies.add(rep.jarFile(art));
+//								}
+//							}
+					}
+				}
+			}
+		} else { // Just add dependencies for this activity since we can't get hold of the whole workflow
+//			if (dependencyType.equals(LOCAL_JARS)){
+			if (json.has("localDependency")) {
+				for (JsonNode jar : json.get("localDependency")) {
+					try {
+						dependencies.add(new File(libDir, jar.textValue()));
+					} catch (Exception ex) {
+						logger.warn("Invalid URL for " + jar, ex);
+						continue;
+					}
+				}
+			}
+//			}
+//			else if (dependencyType.equals(ARTIFACTS)){
+//				if (this.getClass().getClassLoader() instanceof LocalArtifactClassLoader){ // This should normally be the case
+//					LocalArtifactClassLoader cl = (LocalArtifactClassLoader)this.getClass().getClassLoader();
+//					LocalRepository rep  = (LocalRepository)cl.getRepository();
+//					if (rep != null){
+//						for (BasicArtifact art : configurationBean.getArtifactDependencies()){
+//							dependencies.add(rep.jarFile(art));
+//						}
+//					}
+//				}
+//				else{
+//					// Tests will not be loaded using the LocalArtifactClassLoader as athey are loaded
+//					// outside Raven so there is nothing we can do about this - some tests
+//					// with dependencies will probably fail
+//				}
+//			}
+		}
+
+		// Collect the URLs of all found dependencies
+		for (File file: dependencies){
+			try{
+				dependenciesURLs.add(file.toURI().toURL());
+			}
+			catch(Exception ex){
+				logger.warn("Invalid URL for " + file.getAbsolutePath(), ex);
+				continue;
+			}
+		}
+		return dependenciesURLs;
+	}
+
+	/**
+	 * Finds dependencies for a nested workflow.
+	 */
+	private HashSet<URL> findNestedDependencies(String dependencyType, JsonNode json, Dataflow nestedWorkflow) {
+		ClassLoaderSharing classLoaderSharing;
+		if (json.has("classLoaderSharing")) {
+			classLoaderSharing = ClassLoaderSharing.fromString(json.get("classLoaderSharing").textValue());
+		} else {
+			classLoaderSharing = ClassLoaderSharing.workflow;
+		}
+
+		// Files of dependencies for all activities in the nested workflow that share the classloading policy
+		HashSet<File> dependencies = new HashSet<File>();
+		// Urls of all dependencies
+		HashSet<URL> dependenciesURLs = new HashSet<URL>();
+
+		for (Processor proc : nestedWorkflow.getProcessors()) {
+			// Another nested workflow
+			if (!proc.getActivityList().isEmpty() && proc.getActivityList().get(0) instanceof NestedDataflow){
+				// Get the nested workflow
+				Dataflow nestedNestedWorkflow = ((NestedDataflow) proc.getActivityList().get(0)).getNestedDataflow();
+				dependenciesURLs.addAll(findNestedDependencies(dependencyType, json, nestedNestedWorkflow));
+			}
+			else{ // Not nested - go through all of the processor's activities
+				Activity<?> activity = proc.getActivityList().get(0);
+				if (activity instanceof AbstractAsynchronousDependencyActivity){
+					AbstractAsynchronousDependencyActivity dependencyActivity = (AbstractAsynchronousDependencyActivity) activity;
+//						if (dependencyType.equals(LOCAL_JARS)){
+							// Collect the files of all found local dependencies
+							if (dependencyActivity.getConfiguration().has("localDependency")) {
+								for (JsonNode jar : dependencyActivity.getConfiguration().get("localDependency")) {
+									try {
+										dependencies.add(new File(libDir, jar.textValue()));
+									} catch (Exception ex) {
+										logger.warn("Invalid URL for " + jar, ex);
+										continue;
+									}
+								}
+							}
+//						} else if (dependencyType.equals(ARTIFACTS) && this.getClass().getClassLoader() instanceof LocalArtifactClassLoader){
+//							LocalArtifactClassLoader cl = (LocalArtifactClassLoader) this.getClass().getClassLoader(); // this class is always loaded with LocalArtifactClassLoader
+//							LocalRepository rep  = (LocalRepository) cl.getRepository();
+//							for (BasicArtifact art : ((DependencyActivityConfigurationBean) activity
+//											.getConfiguration())
+//											.getArtifactDependencies()){
+//								dependencies.add(rep.jarFile(art));
+//							}
+//						}
+				}
+			}
+		}
+
+		// Collect the URLs of all found dependencies
+		for (File file: dependencies){
+			try{
+				dependenciesURLs.add(file.toURI().toURL());
+			}
+			catch(Exception ex){
+				logger.warn("Invalid URL for " + file.getAbsolutePath(), ex);
+				continue;
+			}
+		}
+		return dependenciesURLs;
+	}
+
+	/**
+	 * File filter.
+	 */
+	public static class FileExtFilter implements FilenameFilter {
+
+		String ext = null;
+
+		public FileExtFilter(String ext) {
+			this.ext = ext;
+		}
+
+		public boolean accept(File dir, String name) {
+			return name.endsWith(ext);
+		}
+	}
+
+	/**
+	 * @param classLoader the classLoader to set
+	 */
+	public void setClassLoader(ClassLoader classLoader) {
+		this.classLoader = classLoader;
+	}
+
+	/**
+	 * @return the classLoader
+	 */
+	public ClassLoader getClassLoader() {
+		return classLoader;
+	}
+}
+
+

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/433612be/taverna-beanshell-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
----------------------------------------------------------------------
diff --git a/taverna-beanshell-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker b/taverna-beanshell-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
index 3fbf5a8..b6ed6cb 100644
--- a/taverna-beanshell-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
+++ b/taverna-beanshell-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
@@ -1 +1 @@
-net.sf.taverna.t2.activities.beanshell.BeanshellActivityHealthChecker
\ No newline at end of file
+org.apache.taverna.activities.beanshell.BeanshellActivityHealthChecker
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/433612be/taverna-beanshell-activity/src/main/resources/META-INF/spring/beanshell-activity-context.xml
----------------------------------------------------------------------
diff --git a/taverna-beanshell-activity/src/main/resources/META-INF/spring/beanshell-activity-context.xml b/taverna-beanshell-activity/src/main/resources/META-INF/spring/beanshell-activity-context.xml
index c6cc552..0e7de0a 100644
--- a/taverna-beanshell-activity/src/main/resources/META-INF/spring/beanshell-activity-context.xml
+++ b/taverna-beanshell-activity/src/main/resources/META-INF/spring/beanshell-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="beanshellActivityHealthChecker" class="net.sf.taverna.t2.activities.beanshell.BeanshellActivityHealthChecker" />
+	<bean id="beanshellActivityHealthChecker" class="org.apache.taverna.activities.beanshell.BeanshellActivityHealthChecker" />
 
-	<bean id="beanshellActivityFactory" class="net.sf.taverna.t2.activities.beanshell.BeanshellActivityFactory">
+	<bean id="beanshellActivityFactory" class="org.apache.taverna.activities.beanshell.BeanshellActivityFactory">
 		<property name="applicationConfiguration" ref="applicationConfiguration" />
 	</bean>
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/433612be/taverna-beanshell-activity/src/main/resources/schema.json
----------------------------------------------------------------------
diff --git a/taverna-beanshell-activity/src/main/resources/schema.json b/taverna-beanshell-activity/src/main/resources/schema.json
index a9d195b..d71b94d 100644
--- a/taverna-beanshell-activity/src/main/resources/schema.json
+++ b/taverna-beanshell-activity/src/main/resources/schema.json
@@ -16,7 +16,7 @@
             "type": "string",
             "required": true,
             "default": ""
-        }
+        },
         "classLoaderSharing": {
             "title": "ClassLoader Sharing Policy",
             "description": "Policy for sharing class loaders across multiple beanshell activities",

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/433612be/taverna-beanshell-activity/src/test/java/net/sf/taverna/t2/activities/beanshell/BeanshellActivityFactoryTest.java
----------------------------------------------------------------------
diff --git a/taverna-beanshell-activity/src/test/java/net/sf/taverna/t2/activities/beanshell/BeanshellActivityFactoryTest.java b/taverna-beanshell-activity/src/test/java/net/sf/taverna/t2/activities/beanshell/BeanshellActivityFactoryTest.java
deleted file mode 100644
index 32290ac..0000000
--- a/taverna-beanshell-activity/src/test/java/net/sf/taverna/t2/activities/beanshell/BeanshellActivityFactoryTest.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.beanshell;
-
-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 BeanshellActivityFactoryTest {
-
-	private BeanshellActivityFactory factory;
-
-	/**
-	 * @throws java.lang.Exception
-	 */
-	@Before
-	public void setUp() throws Exception {
-		factory = new BeanshellActivityFactory();
-	}
-
-	/**
-	 * Test method for {@link net.sf.taverna.t2.activities.beanshell.BeanshellActivityFactory#createActivity()}.
-	 */
-	@Test
-	public void testCreateActivity() {
-		BeanshellActivity createActivity = factory.createActivity();
-		assertNotNull(createActivity);
-	}
-
-	/**
-	 * Test method for {@link net.sf.taverna.t2.activities.beanshell.BeanshellActivityFactory#getActivityType()}.
-	 */
-	@Test
-	public void testGetActivityURI() {
-		assertEquals(URI.create(BeanshellActivity.URI), factory.getActivityType());
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/433612be/taverna-beanshell-activity/src/test/java/net/sf/taverna/t2/activities/beanshell/BeanshellActivityHealthCheckerTest.java
----------------------------------------------------------------------
diff --git a/taverna-beanshell-activity/src/test/java/net/sf/taverna/t2/activities/beanshell/BeanshellActivityHealthCheckerTest.java b/taverna-beanshell-activity/src/test/java/net/sf/taverna/t2/activities/beanshell/BeanshellActivityHealthCheckerTest.java
deleted file mode 100644
index 0b4b5ff..0000000
--- a/taverna-beanshell-activity/src/test/java/net/sf/taverna/t2/activities/beanshell/BeanshellActivityHealthCheckerTest.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.activities.beanshell;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import net.sf.taverna.t2.activities.testutils.ActivityInvoker;
-import net.sf.taverna.t2.visit.VisitReport;
-import net.sf.taverna.t2.visit.VisitReport.Status;
-import net.sf.taverna.t2.workflowmodel.Edits;
-import net.sf.taverna.t2.workflowmodel.impl.EditsImpl;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * BeanshellActivityHealthChecker tests
- *
- * @author Stian Soiland-Reyes
- *
- */
-public class BeanshellActivityHealthCheckerTest {
-
-	private Edits edits = new EditsImpl();
-
-	private ObjectNode configuration;
-
-	@Before
-	public void setup() throws Exception {
-		configuration = JsonNodeFactory.instance.objectNode();
-		configuration.put("classLoaderSharing", "workflow");
-	}
-
-	@Test
-	public void oneLinerNoSemicolon() throws Exception {
-		BeanshellActivity activity = new BeanshellActivity(null);
-		configuration.put("script", "a = 5+3");
-		// Notice lack of ;
-		activity.configure(configuration);
-
-		Map<String,Object> inputs = new HashMap<String, Object>();
-		Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>();
-		ActivityInvoker.invokeAsyncActivity(activity, inputs, expectedOutputs);
-
-		BeanshellActivityHealthChecker healthChecker = new BeanshellActivityHealthChecker();
-		assertTrue(healthChecker.canVisit(activity));
-		ArrayList<Object> ancestors = new ArrayList<Object>();
-
-		ancestors.add(edits.createProcessor("beanie"));
-		VisitReport visit = healthChecker.visit(activity, ancestors);
-		assertEquals(Status.OK, visit.getStatus());
-	}
-
-	@Test
-	public void oneLiner() throws Exception {
-		BeanshellActivity activity = new BeanshellActivity(null);
-		configuration.put("script", "System.out.println(\"Hello\");");
-		activity.configure(configuration);
-
-		Map<String,Object> inputs = new HashMap<String, Object>();
-		Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>();
-		ActivityInvoker.invokeAsyncActivity(activity, inputs, expectedOutputs);
-
-		BeanshellActivityHealthChecker healthChecker = new BeanshellActivityHealthChecker();
-		assertTrue(healthChecker.canVisit(activity));
-		ArrayList<Object> ancestors = new ArrayList<Object>();
-
-		ancestors.add(edits.createProcessor("beanie"));
-		VisitReport visit = healthChecker.visit(activity, ancestors);
-		assertEquals(Status.OK, visit.getStatus());
-	}
-
-	@Test
-	public void threeLines() throws Exception {
-		BeanshellActivity activity = new BeanshellActivity(null);
-		configuration.put("script", "if (2>1) {\n" +
-				"  new Integer(4);\n" +
-				"}");
-		activity.configure(configuration);
-
-		Map<String,Object> inputs = new HashMap<String, Object>();
-		Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>();
-		ActivityInvoker.invokeAsyncActivity(activity, inputs, expectedOutputs);
-
-		BeanshellActivityHealthChecker healthChecker = new BeanshellActivityHealthChecker();
-		assertTrue(healthChecker.canVisit(activity));
-		ArrayList<Object> ancestors = new ArrayList<Object>();
-
-		ancestors.add(edits.createProcessor("beanie"));
-		VisitReport visit = healthChecker.visit(activity, ancestors);
-		assertEquals(Status.OK, visit.getStatus());
-
-
-
-	}
-
-	@Test
-	public void invalidScript() throws Exception {
-		BeanshellActivity activity = new BeanshellActivity(null);
-		configuration.put("script", "invalid script 5 +");
-		activity.configure(configuration);
-
-		Map<String,Object> inputs = new HashMap<String, Object>();
-		Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>();
-		try {
-			ActivityInvoker.invokeAsyncActivity(activity, inputs, expectedOutputs);
-			fail("Script should not be valid");
-		} catch (RuntimeException ex) {
-			// expected to fail
-		}
-
-
-		BeanshellActivityHealthChecker healthChecker = new BeanshellActivityHealthChecker();
-		assertTrue(healthChecker.canVisit(activity));
-		ArrayList<Object> ancestors = new ArrayList<Object>();
-
-		ancestors.add(edits.createProcessor("beanie"));
-		VisitReport visit = healthChecker.visit(activity, ancestors);
-		assertEquals(Status.SEVERE, visit.getStatus());
-	}
-
-	@Test
-	public void strangeWhitespace() throws Exception {
-		BeanshellActivity activity = new BeanshellActivity(null);
-		configuration.put("script", "b = \"fish\";\n" +
-				"a = 2+3\n" +
-				"\n" +
-				"\n" +
-				"  +5   ");
-		// Notice lots of whitespace, but still valid
-		activity.configure(configuration);
-
-		Map<String,Object> inputs = new HashMap<String, Object>();
-		Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>();
-		ActivityInvoker.invokeAsyncActivity(activity, inputs, expectedOutputs);
-
-		BeanshellActivityHealthChecker healthChecker = new BeanshellActivityHealthChecker();
-		assertTrue(healthChecker.canVisit(activity));
-		ArrayList<Object> ancestors = new ArrayList<Object>();
-
-		ancestors.add(edits.createProcessor("beanie"));
-		VisitReport visit = healthChecker.visit(activity, ancestors);
-		System.out.println(visit);
-		assertEquals(Status.OK, visit.getStatus());
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/433612be/taverna-beanshell-activity/src/test/java/net/sf/taverna/t2/activities/beanshell/BeanshellActivityTest.java
----------------------------------------------------------------------
diff --git a/taverna-beanshell-activity/src/test/java/net/sf/taverna/t2/activities/beanshell/BeanshellActivityTest.java b/taverna-beanshell-activity/src/test/java/net/sf/taverna/t2/activities/beanshell/BeanshellActivityTest.java
deleted file mode 100644
index 8d724a5..0000000
--- a/taverna-beanshell-activity/src/test/java/net/sf/taverna/t2/activities/beanshell/BeanshellActivityTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public License
- *  as published by the Free Software Foundation; either version 2.1 of
- *  the License, or (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this 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.beanshell;
-
-import static org.junit.Assert.assertEquals;
-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.AbstractPort;
-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;
-
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Beanshell Activity Tests
- * @author Stuart Owen
- *
- */
-public class BeanshellActivityTest {
-
-	private ObjectNode configuration;
-
-	@Before
-	public void setup() throws Exception {
-		configuration = JsonNodeFactory.instance.objectNode();
-		configuration.put("classLoaderSharing", "workflow");
-	}
-
-	/**
-	 * Tests a simple script (String output = input + "_returned") to ensure the script is invoked correctly.
-	 * @throws Exception
-	 */
-	@Test
-	public void simpleScript() throws Exception {
-		BeanshellActivity activity = new BeanshellActivity(null);
-		Edits edits = new EditsImpl();
-		edits.getAddActivityInputPortEdit(activity, new ActivityInputPortImpl("input", 0, false, null, String.class)).doEdit();
-		edits.getAddActivityOutputPortEdit(activity, new ActivityOutputPortImpl("output", 0, 0)).doEdit();
-
-		configuration.put("script", "String output = input + \"_returned\";");
-
-		activity.configure(configuration);
-		assertEquals("There should be 1 input port",1,activity.getInputPorts().size());
-		assertEquals("There should be 1 output port",1,activity.getOutputPorts().size());
-
-		assertEquals("The input should be called input", "input",((AbstractPort)activity.getInputPorts().toArray()[0]).getName());
-		assertEquals("The output should be called output", "output",((AbstractPort)activity.getOutputPorts().toArray()[0]).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_returned","aString_returned",outputs.get("output"));
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/433612be/taverna-beanshell-activity/src/test/java/org/apache/taverna/activities/beanshell/BeanshellActivityFactoryTest.java
----------------------------------------------------------------------
diff --git a/taverna-beanshell-activity/src/test/java/org/apache/taverna/activities/beanshell/BeanshellActivityFactoryTest.java b/taverna-beanshell-activity/src/test/java/org/apache/taverna/activities/beanshell/BeanshellActivityFactoryTest.java
new file mode 100644
index 0000000..05f675e
--- /dev/null
+++ b/taverna-beanshell-activity/src/test/java/org/apache/taverna/activities/beanshell/BeanshellActivityFactoryTest.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.beanshell;
+
+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 BeanshellActivityFactoryTest {
+
+	private BeanshellActivityFactory factory;
+
+	/**
+	 * @throws java.lang.Exception
+	 */
+	@Before
+	public void setUp() throws Exception {
+		factory = new BeanshellActivityFactory();
+	}
+
+	/**
+	 * Test method for {@link net.sf.taverna.t2.activities.beanshell.BeanshellActivityFactory#createActivity()}.
+	 */
+	@Test
+	public void testCreateActivity() {
+		BeanshellActivity createActivity = factory.createActivity();
+		assertNotNull(createActivity);
+	}
+
+	/**
+	 * Test method for {@link net.sf.taverna.t2.activities.beanshell.BeanshellActivityFactory#getActivityType()}.
+	 */
+	@Test
+	public void testGetActivityURI() {
+		assertEquals(URI.create(BeanshellActivity.URI), factory.getActivityType());
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/433612be/taverna-beanshell-activity/src/test/java/org/apache/taverna/activities/beanshell/BeanshellActivityHealthCheckerTest.java
----------------------------------------------------------------------
diff --git a/taverna-beanshell-activity/src/test/java/org/apache/taverna/activities/beanshell/BeanshellActivityHealthCheckerTest.java b/taverna-beanshell-activity/src/test/java/org/apache/taverna/activities/beanshell/BeanshellActivityHealthCheckerTest.java
new file mode 100644
index 0000000..6abd66f
--- /dev/null
+++ b/taverna-beanshell-activity/src/test/java/org/apache/taverna/activities/beanshell/BeanshellActivityHealthCheckerTest.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.activities.beanshell;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import net.sf.taverna.t2.activities.testutils.ActivityInvoker;
+import net.sf.taverna.t2.visit.VisitReport;
+import net.sf.taverna.t2.visit.VisitReport.Status;
+import net.sf.taverna.t2.workflowmodel.Edits;
+import net.sf.taverna.t2.workflowmodel.impl.EditsImpl;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * BeanshellActivityHealthChecker tests
+ *
+ * @author Stian Soiland-Reyes
+ *
+ */
+public class BeanshellActivityHealthCheckerTest {
+
+	private Edits edits = new EditsImpl();
+
+	private ObjectNode configuration;
+
+	@Before
+	public void setup() throws Exception {
+		configuration = JsonNodeFactory.instance.objectNode();
+		configuration.put("classLoaderSharing", "workflow");
+	}
+
+	@Test
+	public void oneLinerNoSemicolon() throws Exception {
+		BeanshellActivity activity = new BeanshellActivity(null);
+		configuration.put("script", "a = 5+3");
+		// Notice lack of ;
+		activity.configure(configuration);
+
+		Map<String,Object> inputs = new HashMap<String, Object>();
+		Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>();
+		ActivityInvoker.invokeAsyncActivity(activity, inputs, expectedOutputs);
+
+		BeanshellActivityHealthChecker healthChecker = new BeanshellActivityHealthChecker();
+		assertTrue(healthChecker.canVisit(activity));
+		ArrayList<Object> ancestors = new ArrayList<Object>();
+
+		ancestors.add(edits.createProcessor("beanie"));
+		VisitReport visit = healthChecker.visit(activity, ancestors);
+		assertEquals(Status.OK, visit.getStatus());
+	}
+
+	@Test
+	public void oneLiner() throws Exception {
+		BeanshellActivity activity = new BeanshellActivity(null);
+		configuration.put("script", "System.out.println(\"Hello\");");
+		activity.configure(configuration);
+
+		Map<String,Object> inputs = new HashMap<String, Object>();
+		Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>();
+		ActivityInvoker.invokeAsyncActivity(activity, inputs, expectedOutputs);
+
+		BeanshellActivityHealthChecker healthChecker = new BeanshellActivityHealthChecker();
+		assertTrue(healthChecker.canVisit(activity));
+		ArrayList<Object> ancestors = new ArrayList<Object>();
+
+		ancestors.add(edits.createProcessor("beanie"));
+		VisitReport visit = healthChecker.visit(activity, ancestors);
+		assertEquals(Status.OK, visit.getStatus());
+	}
+
+	@Test
+	public void threeLines() throws Exception {
+		BeanshellActivity activity = new BeanshellActivity(null);
+		configuration.put("script", "if (2>1) {\n" +
+				"  new Integer(4);\n" +
+				"}");
+		activity.configure(configuration);
+
+		Map<String,Object> inputs = new HashMap<String, Object>();
+		Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>();
+		ActivityInvoker.invokeAsyncActivity(activity, inputs, expectedOutputs);
+
+		BeanshellActivityHealthChecker healthChecker = new BeanshellActivityHealthChecker();
+		assertTrue(healthChecker.canVisit(activity));
+		ArrayList<Object> ancestors = new ArrayList<Object>();
+
+		ancestors.add(edits.createProcessor("beanie"));
+		VisitReport visit = healthChecker.visit(activity, ancestors);
+		assertEquals(Status.OK, visit.getStatus());
+
+
+
+	}
+
+	@Test
+	public void invalidScript() throws Exception {
+		BeanshellActivity activity = new BeanshellActivity(null);
+		configuration.put("script", "invalid script 5 +");
+		activity.configure(configuration);
+
+		Map<String,Object> inputs = new HashMap<String, Object>();
+		Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>();
+		try {
+			ActivityInvoker.invokeAsyncActivity(activity, inputs, expectedOutputs);
+			fail("Script should not be valid");
+		} catch (RuntimeException ex) {
+			// expected to fail
+		}
+
+
+		BeanshellActivityHealthChecker healthChecker = new BeanshellActivityHealthChecker();
+		assertTrue(healthChecker.canVisit(activity));
+		ArrayList<Object> ancestors = new ArrayList<Object>();
+
+		ancestors.add(edits.createProcessor("beanie"));
+		VisitReport visit = healthChecker.visit(activity, ancestors);
+		assertEquals(Status.SEVERE, visit.getStatus());
+	}
+
+	@Test
+	public void strangeWhitespace() throws Exception {
+		BeanshellActivity activity = new BeanshellActivity(null);
+		configuration.put("script", "b = \"fish\";\n" +
+				"a = 2+3\n" +
+				"\n" +
+				"\n" +
+				"  +5   ");
+		// Notice lots of whitespace, but still valid
+		activity.configure(configuration);
+
+		Map<String,Object> inputs = new HashMap<String, Object>();
+		Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>();
+		ActivityInvoker.invokeAsyncActivity(activity, inputs, expectedOutputs);
+
+		BeanshellActivityHealthChecker healthChecker = new BeanshellActivityHealthChecker();
+		assertTrue(healthChecker.canVisit(activity));
+		ArrayList<Object> ancestors = new ArrayList<Object>();
+
+		ancestors.add(edits.createProcessor("beanie"));
+		VisitReport visit = healthChecker.visit(activity, ancestors);
+		System.out.println(visit);
+		assertEquals(Status.OK, visit.getStatus());
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/433612be/taverna-beanshell-activity/src/test/java/org/apache/taverna/activities/beanshell/BeanshellActivityTest.java
----------------------------------------------------------------------
diff --git a/taverna-beanshell-activity/src/test/java/org/apache/taverna/activities/beanshell/BeanshellActivityTest.java b/taverna-beanshell-activity/src/test/java/org/apache/taverna/activities/beanshell/BeanshellActivityTest.java
new file mode 100644
index 0000000..e0aae68
--- /dev/null
+++ b/taverna-beanshell-activity/src/test/java/org/apache/taverna/activities/beanshell/BeanshellActivityTest.java
@@ -0,0 +1,85 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.beanshell;
+
+import static org.junit.Assert.assertEquals;
+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.AbstractPort;
+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;
+
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * Beanshell Activity Tests
+ * @author Stuart Owen
+ *
+ */
+public class BeanshellActivityTest {
+
+	private ObjectNode configuration;
+
+	@Before
+	public void setup() throws Exception {
+		configuration = JsonNodeFactory.instance.objectNode();
+		configuration.put("classLoaderSharing", "workflow");
+	}
+
+	/**
+	 * Tests a simple script (String output = input + "_returned") to ensure the script is invoked correctly.
+	 * @throws Exception
+	 */
+	@Test
+	public void simpleScript() throws Exception {
+		BeanshellActivity activity = new BeanshellActivity(null);
+		Edits edits = new EditsImpl();
+		edits.getAddActivityInputPortEdit(activity, new ActivityInputPortImpl("input", 0, false, null, String.class)).doEdit();
+		edits.getAddActivityOutputPortEdit(activity, new ActivityOutputPortImpl("output", 0, 0)).doEdit();
+
+		configuration.put("script", "String output = input + \"_returned\";");
+
+		activity.configure(configuration);
+		assertEquals("There should be 1 input port",1,activity.getInputPorts().size());
+		assertEquals("There should be 1 output port",1,activity.getOutputPorts().size());
+
+		assertEquals("The input should be called input", "input",((AbstractPort)activity.getInputPorts().toArray()[0]).getName());
+		assertEquals("The output should be called output", "output",((AbstractPort)activity.getOutputPorts().toArray()[0]).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_returned","aString_returned",outputs.get("output"));
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/433612be/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInput.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInput.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInput.java
index a9f97b0..bdb85cc 100644
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInput.java
+++ b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInput.java
@@ -22,7 +22,7 @@ package de.uni_luebeck.inb.knowarc.usecases;
 
 import java.nio.charset.Charset;
 
-import net.sf.taverna.t2.activities.externaltool.ExternalToolActivity;
+import org.apache.taverna.activities.externaltool.ExternalToolActivity;
 import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationBean;
 import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationProperty;
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/433612be/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputStatic.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputStatic.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputStatic.java
index 4e108b9..121f73e 100644
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputStatic.java
+++ b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputStatic.java
@@ -20,7 +20,7 @@
 
 package de.uni_luebeck.inb.knowarc.usecases;
 
-import net.sf.taverna.t2.activities.externaltool.ExternalToolActivity;
+import org.apache.taverna.activities.externaltool.ExternalToolActivity;
 import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationBean;
 import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationProperty;
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/433612be/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputUser.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputUser.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputUser.java
index 858b7fa..1627311 100644
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputUser.java
+++ b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputUser.java
@@ -21,7 +21,7 @@
 package de.uni_luebeck.inb.knowarc.usecases;
 import java.util.ArrayList;
 
-import net.sf.taverna.t2.activities.externaltool.ExternalToolActivity;
+import org.apache.taverna.activities.externaltool.ExternalToolActivity;
 import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationBean;
 import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationProperty;
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/433612be/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptOutput.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptOutput.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptOutput.java
index fe63cc9..3408dbf 100644
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptOutput.java
+++ b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptOutput.java
@@ -21,7 +21,7 @@
 package de.uni_luebeck.inb.knowarc.usecases;
 import java.util.ArrayList;
 
-import net.sf.taverna.t2.activities.externaltool.ExternalToolActivity;
+import org.apache.taverna.activities.externaltool.ExternalToolActivity;
 import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationBean;
 import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationProperty;
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/433612be/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/UseCaseDescription.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/UseCaseDescription.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/UseCaseDescription.java
index 217eae5..fa3a7f8 100644
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/UseCaseDescription.java
+++ b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/UseCaseDescription.java
@@ -34,7 +34,7 @@ import java.util.Set;
 
 import javax.swing.ImageIcon;
 
-import net.sf.taverna.t2.activities.externaltool.ExternalToolActivity;
+import org.apache.taverna.activities.externaltool.ExternalToolActivity;
 import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationBean;
 import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationProperty;
 import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationProperty.OrderPolicy;

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/433612be/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/ssh/SshNode.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/ssh/SshNode.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/ssh/SshNode.java
index 92b065e..7cd0f90 100644
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/ssh/SshNode.java
+++ b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/ssh/SshNode.java
@@ -20,7 +20,7 @@
 
 package de.uni_luebeck.inb.knowarc.usecases.invocation.ssh;
 
-import net.sf.taverna.t2.activities.externaltool.manager.InvocationMechanism;
+import org.apache.taverna.activities.externaltool.manager.InvocationMechanism;
 
 public class SshNode {
 	

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/433612be/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/ssh/SshReference.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/ssh/SshReference.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/ssh/SshReference.java
index 0431153..db8f8a7 100644
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/ssh/SshReference.java
+++ b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/ssh/SshReference.java
@@ -5,7 +5,7 @@ package de.uni_luebeck.inb.knowarc.usecases.invocation.ssh;
 
 import java.io.InputStream;
 
-import net.sf.taverna.t2.activities.externaltool.RetrieveLoginFromTaverna;
+import org.apache.taverna.activities.externaltool.RetrieveLoginFromTaverna;
 import net.sf.taverna.t2.reference.AbstractExternalReference;
 import net.sf.taverna.t2.reference.DereferenceException;
 import net.sf.taverna.t2.reference.ExternalReferenceSPI;

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/433612be/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/ssh/SshUseCaseInvocation.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/ssh/SshUseCaseInvocation.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/ssh/SshUseCaseInvocation.java
index 29e475d..8622ad4 100755
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/ssh/SshUseCaseInvocation.java
+++ b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/ssh/SshUseCaseInvocation.java
@@ -44,7 +44,7 @@ import java.util.Set;
 import java.util.Vector;
 import java.util.regex.Matcher;
 
-import net.sf.taverna.t2.activities.externaltool.RetrieveLoginFromTaverna;
+import org.apache.taverna.activities.externaltool.RetrieveLoginFromTaverna;
 import net.sf.taverna.t2.reference.AbstractExternalReference;
 import net.sf.taverna.t2.reference.ErrorDocument;
 import net.sf.taverna.t2.reference.ErrorDocumentServiceException;

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/433612be/taverna-external-tool-activity/src/main/java/net/sf/taverna/t2/activities/externaltool/ExternalToolActivity.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/net/sf/taverna/t2/activities/externaltool/ExternalToolActivity.java b/taverna-external-tool-activity/src/main/java/net/sf/taverna/t2/activities/externaltool/ExternalToolActivity.java
deleted file mode 100755
index 1e6ef77..0000000
--- a/taverna-external-tool-activity/src/main/java/net/sf/taverna/t2/activities/externaltool/ExternalToolActivity.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2009 Hajo Nils Krabbenhoeft, INB, University of Luebeck
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public License
- *  as published by the Free Software Foundation; either version 2.1 of
- *  the License, or (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this 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.externaltool;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import net.sf.taverna.t2.activities.externaltool.manager.InvocationGroup;
-import net.sf.taverna.t2.activities.externaltool.manager.InvocationMechanism;
-import net.sf.taverna.t2.annotation.Annotated;
-import net.sf.taverna.t2.annotation.annotationbeans.MimeType;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceService;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.WorkflowRunIdEntity;
-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.ActivityInputPort;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityOutputPort;
-import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback;
-
-import org.apache.log4j.Logger;
-
-import de.uni_luebeck.inb.knowarc.usecases.ScriptInput;
-import de.uni_luebeck.inb.knowarc.usecases.ScriptInputUser;
-import de.uni_luebeck.inb.knowarc.usecases.ScriptOutput;
-import de.uni_luebeck.inb.knowarc.usecases.UseCaseDescription;
-import de.uni_luebeck.inb.knowarc.usecases.invocation.InvocationException;
-import de.uni_luebeck.inb.knowarc.usecases.invocation.UseCaseInvocation;
-
-/**
- * This is the main class of the use case activity plugin. Here we store the
- * configuration and the description of a use case activity, configure the input
- * and output port and provide use case activity invocation
- *
- * @author Hajo Nils Krabbenhoeft
- */
-public class ExternalToolActivity extends AbstractAsynchronousActivity<ExternalToolActivityConfigurationBean> {
-
-	public static final String URI = "http://ns.taverna.org.uk/2010/activity/tool";
-
-	private static final String STDERR = "STDERR";
-
-	private static final String STDOUT = "STDOUT";
-
-	private static final String STDIN = "STDIN";
-
-	private static Logger logger = Logger.getLogger(ExternalToolActivity.class);
-
-	private ExternalToolActivityConfigurationBean configurationBean;
-	private UseCaseDescription mydesc;
-
-	private List<InvocationCreator> invocationCreators;
-
-	/**
-	 * Add the given MIME types to the given input/output port.
-	 *
-	 * @param annotated
-	 *            The port to which to add the MIME types.
-	 * @param mimeTypes
-	 *            A list of Strings specifying the MIME types to add.
-	 */
-	private void addMimeTypes(Annotated<?> annotated, List<String> mimeTypes) {
-		for (String mimeType : mimeTypes) {
-			MimeType mimeTypeAnnotation = new MimeType();
-			mimeTypeAnnotation.setText(mimeType);
-			try {
-				getEdits().getAddAnnotationChainEdit(annotated, mimeTypeAnnotation).doEdit();
-			} catch (EditException e) {
-				Logger.getLogger(ExternalToolActivity.class).error(e);
-			}
-		}
-	}
-
-	/**
-	 * Create a new input port with the given name, depth, element class and
-	 * MIME types.
-	 *
-	 * @param portName
-	 *            Name of the new port
-	 * @param portDepth
-	 *            Depth of the new port
-	 * @param translatedElementClass
-	 *            Which class of elements would this port like?
-	 * @param mimeTypes
-	 *            Accepted mime types for this port
-	 */
-	private void addInputWithMime(String portName, int portDepth, Class<?> translatedElementClass, List<String> mimeTypes) {
-		List<Class<? extends ExternalReferenceSPI>> handledReferenceSchemes = Collections.emptyList();
-		ActivityInputPort inputPort = getEdits().createActivityInputPort(portName, portDepth, true, handledReferenceSchemes,
-				translatedElementClass);
-		inputPorts.add(inputPort);
-		if (mimeTypes != null) {
-			addMimeTypes(inputPort, mimeTypes);
-		}
-	}
-
-	/**
-	 * Create a new output port with the given MIME types
-	 *
-	 * @param portName
-	 *            Name of the new port
-	 * @param portDepth
-	 *            Depth of the new port
-	 * @param mimeTypes
-	 *            Accepted mime types for this port
-	 */
-	private void addOutputWithMime(String portName, int portDepth, List<String> mimeTypes) {
-		ActivityOutputPort outputPort = getEdits().createActivityOutputPort(portName, portDepth, portDepth);
-		outputPorts.add(outputPort);
-		addMimeTypes(outputPort, mimeTypes);
-	}
-
-	@Override
-	public void configure(ExternalToolActivityConfigurationBean bean) throws ActivityConfigurationException {
-		this.configurationBean = bean;
-
-		try {
-			mydesc = bean.getUseCaseDescription();
-
-			inputPorts.clear();
-			outputPorts.clear();
-
-			if (mydesc != null) {
-
-			// loop through all script inputs and add them as taverna activity
-			// input ports
-			for (Map.Entry<String, ScriptInput> cur : mydesc.getInputs().entrySet()) {
-				ScriptInputUser scriptInputUser = (ScriptInputUser) cur.getValue();
-				// if the input port is a list, depth is 1 otherwise it is a
-				// single element, therefore depth 0
-				// if the input port is binary, we would like byte arrays,
-				// otherwise we require strings
-				addInputWithMime(cur.getKey(), scriptInputUser.isList() ? 1 : 0, cur.getValue().isBinary() ? byte[].class : String.class, scriptInputUser.getMime());
-
-			}
-			// loop through all script outputs and add them to taverna
-			for (Map.Entry<String, ScriptOutput> cur : mydesc.getOutputs().entrySet()) {
-				addOutputWithMime(cur.getKey(), 0, cur.getValue().getMime());
-			}
-			}
-
-			if (mydesc.isIncludeStdIn()) {
-				addInputWithMime(STDIN, 0, byte[].class, null);
-			}
-			if (mydesc.isIncludeStdOut()) {
-				addOutput(STDOUT, 0);
-			}
-			if (mydesc.isIncludeStdErr()) {
-				addOutput(STDERR, 0);
-			}
-		} catch (Exception e) {
-			throw new ActivityConfigurationException("Couldn't create ExternalTool Activity", e);
-		}
-	}
-
-	@Override
-	public ExternalToolActivityConfigurationBean getConfiguration() {
-		if (configurationBean != null) {
-			InvocationGroup invocationGroup = configurationBean.getInvocationGroup();
-			if (invocationGroup == null) {
-				if (configurationBean.getMechanism() != null) {
-					configurationBean.convertMechanismToDetails();
-				}
-			} else {
-				if (invocationGroup.getMechanism() != null) {
-					invocationGroup.convertMechanismToDetails();
-				}
-			}
-		}
-		return configurationBean;
-	}
-
-	public ExternalToolActivityConfigurationBean getConfigurationNoConversion() {
-		return configurationBean;
-	}
-
-	public InvocationMechanism recreateMechanism() {
-		if (configurationBean.getInvocationGroup() != null) {
-			if (configurationBean.getInvocationGroup().getMechanism() == null) {
-				configurationBean.getInvocationGroup().convertDetailsToMechanism();
-			}
-			return configurationBean.getInvocationGroup().getMechanism();
-		} else {
-			if (configurationBean.getMechanism() == null) {
-				configurationBean.convertDetailsToMechanism();
-			}
-			return configurationBean.getMechanism();
-		}
-	}
-
-	@Override
-	public void executeAsynch(final Map<String, T2Reference> data, final AsynchronousActivityCallback callback) {
-
-		callback.requestRun(new Runnable() {
-
-			public void run() {
-				ReferenceService referenceService = callback.getContext().getReferenceService();
-				UseCaseInvocation invoke = null;
-
-				/**
-				 * Note that retrying needs to be either done via Taverna's retry mechanism or as part of the specific invocation
-				 */
-				try {
-
-					invoke = getInvocation(recreateMechanism(),
-							configurationBean.getUseCaseDescription(), data, referenceService);
-					if (invoke == null) {
-						logger.error("Invoke is null");
-						callback.fail("No invocation mechanism found");
-					}
-					String runId = callback.getContext()
-							.getEntities(WorkflowRunIdEntity.class).get(0)
-							.getWorkflowRunId();
-					logger.info("Run id is " + runId);
-					invoke.rememberRun(runId);
-
-					invoke.setContext(callback.getContext());
-
-					// look at every use dynamic case input
-					for (String cur : invoke.getInputs()) {
-						if (!cur.equals(STDIN)) {
-							invoke.setInput(cur, referenceService,
-									data.get(cur));
-						}
-					}
-
-					if (mydesc.isIncludeStdIn() && (data.get(STDIN) != null)) {
-						invoke.setStdIn(referenceService, data.get(STDIN));
-					}
-
-					// submit the use case to its invocation mechanism
-					invoke.submit_generate_job(referenceService);
-
-					// retrieve the result.
-					Map<String, Object> downloads = invoke
-							.submit_wait_fetch_results(referenceService);
-					Map<String, T2Reference> result = new HashMap<String, T2Reference>();
-					for (Map.Entry<String, Object> cur : downloads.entrySet()) {
-						Object value = cur.getValue();
-
-						// register the result value with taverna
-						T2Reference reference = referenceService.register(
-								value, 0, true, callback.getContext());
-
-						// store the reference into the activity result
-						// set
-						result.put(cur.getKey(), reference);
-					}
-					callback.receiveResult(result, new int[0]);
-				} catch (InvocationException e) {
-					callback.fail(e.getMessage(), e);
-				}
-			}
-
-		});
-
-	}
-
-	public void setInvocationCreators(List<InvocationCreator> invocationCreators) {
-		this.invocationCreators = invocationCreators;
-	}
-
-	private UseCaseInvocation getInvocation(InvocationMechanism mechanism, UseCaseDescription description, Map<String, T2Reference> data, ReferenceService referenceService) {
-		UseCaseInvocation result = null;
-		InvocationCreator creator = null;
-		for (InvocationCreator c : invocationCreators) {
-			if (c.canHandle(mechanism.getType())) {
-				creator = c;
-				break;
-			}
-		}
-		if (creator != null) {
-			result = creator.convert(mechanism, description, data, referenceService);
-		}
-		return result;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/433612be/taverna-external-tool-activity/src/main/java/net/sf/taverna/t2/activities/externaltool/ExternalToolActivityConfigurationBean.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/net/sf/taverna/t2/activities/externaltool/ExternalToolActivityConfigurationBean.java b/taverna-external-tool-activity/src/main/java/net/sf/taverna/t2/activities/externaltool/ExternalToolActivityConfigurationBean.java
deleted file mode 100755
index ce3387b..0000000
--- a/taverna-external-tool-activity/src/main/java/net/sf/taverna/t2/activities/externaltool/ExternalToolActivityConfigurationBean.java
+++ /dev/null
@@ -1,194 +0,0 @@
-package net.sf.taverna.t2.activities.externaltool;
-
-import java.util.List;
-
-import net.sf.taverna.t2.activities.externaltool.manager.InvocationGroup;
-import net.sf.taverna.t2.activities.externaltool.manager.InvocationMechanism;
-import net.sf.taverna.t2.activities.externaltool.manager.MechanismCreator;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationBean;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationProperty;
-import de.uni_luebeck.inb.knowarc.usecases.UseCaseDescription;
-
-@ConfigurationBean(uri = ExternalToolActivity.URI + "#Config")
-public final class ExternalToolActivityConfigurationBean {
-
-	private InvocationGroup group;
-
-	private String mechanismType;
-
-	private String mechanismName;
-
-	private String mechanismXML;
-
-	private transient InvocationMechanism mechanism;
-
-	protected String repositoryUrl;
-	protected String externaltoolid;
-	protected UseCaseDescription useCaseDescription = null;
-	private boolean edited = false;
-
-	private List<MechanismCreator> mechanismCreators;
-
-    public boolean isEdited() {
-		return edited;
-	}
-
-	public ExternalToolActivityConfigurationBean() {
-	}
-
-	public InvocationGroup getInvocationGroup() {
-	    return group;
-	}
-
-	@ConfigurationProperty(name = "invocationGroup", label = "InvocationGroup", required=false)
-	public void setInvocationGroup(
-			InvocationGroup group) {
-		this.group = group;
-		clearMechanismInformation();
-	}
-
-	private void clearMechanismInformation() {
-		this.mechanismType = null;
-		this.mechanismName = null;
-		this.mechanismXML = null;
-		this.mechanism = null;
-	}
-
-	/**
-	 * @return the repositoryUrl
-	 */
-	public String getRepositoryUrl() {
-		return repositoryUrl;
-	}
-
-	/**
-	 * @param repositoryUrl the repositoryUrl to set
-	 */
-	@ConfigurationProperty(name = "repositoryUrl", label = "Repository URL", required=false)
-	public void setRepositoryUrl(String repositoryUrl) {
-		this.repositoryUrl = repositoryUrl;
-	}
-
-	/**
-	 * @return the externaltoolid
-	 */
-	public String getExternaltoolid() {
-		return externaltoolid;
-	}
-
-	/**
-	 * @param externaltoolid the externaltoolid to set
-	 */
-	@ConfigurationProperty(name = "toolId", label = "Tool ID")
-	public void setExternaltoolid(String externaltoolid) {
-		this.externaltoolid = externaltoolid;
-	}
-
-	/**
-	 * @return the useCaseDescription
-	 */
-	public UseCaseDescription getUseCaseDescription() {
-		return useCaseDescription;
-	}
-
-	/**
-	 * @param useCaseDescription the useCaseDescription to set
-	 */
-	@ConfigurationProperty(name = "toolDescription", label = "Tool Description")
-	public void setUseCaseDescription(UseCaseDescription useCaseDescription) {
-		this.useCaseDescription = useCaseDescription;
-	}
-
-	@ConfigurationProperty(name = "edited", label = "Edited", required=false)
-	public void setEdited(boolean b) {
-		this.edited  = b;
-	}
-
-	/**
-	 * Note this also sets the details
-	 *
-	 * @param mechanism the mechanism to set
-	 */
-	public void setMechanism(InvocationMechanism mechanism) {
-		this.mechanism = mechanism;
-		convertMechanismToDetails();
-		this.group = null;
-	}
-
-	public void convertMechanismToDetails() {
-		if (mechanism != null) {
-			this.setMechanismXML(mechanism.getXML());
-			this.setMechanismName(mechanism.getName());
-			this.setMechanismType(mechanism.getType());
-		}
-	}
-
-	/**
-	 * @param mechanismType the mechanismType to set
-	 */
-	@ConfigurationProperty(name = "mechanismType", label = "Mechanism Type", required=false)
-	public void setMechanismType(String mechanismType) {
-		this.mechanismType = mechanismType;
-	}
-
-	/**
-	 * @param mechanismName the mechanismName to set
-	 */
-	@ConfigurationProperty(name = "mechanismName", label = "Mechanism Name", required=false)
-	public void setMechanismName(String mechanismName) {
-		this.mechanismName = mechanismName;
-	}
-
-	/**
-	 * @param mechanismXML the mechanismXML to set
-	 */
-	@ConfigurationProperty(name = "mechanismXML", label = "Mechanism XML", required=false)
-	public void setMechanismXML(String mechanismXML) {
-		this.mechanismXML = mechanismXML;
-	}
-
-	public void convertDetailsToMechanism() {
-		if (mechanismXML != null) {
-			for (MechanismCreator mc : mechanismCreators) {
-				if (mc.canHandle(getMechanismType())) {
-					mechanism = mc.convert(getMechanismXML(), getMechanismName());
-					break;
-				}
-			}
-		}
-	}
-
-	/**
-	 * @return the mechanism
-	 */
-	public InvocationMechanism getMechanism() {
-
-		return mechanism;
-	}
-
-	/**
-	 * @return the mechanismType
-	 */
-	public String getMechanismType() {
-		return mechanismType;
-	}
-
-	/**
-	 * @return the mechanismName
-	 */
-	public String getMechanismName() {
-		return mechanismName;
-	}
-
-	/**
-	 * @return the mechanismXML
-	 */
-	public String getMechanismXML() {
-		return mechanismXML;
-	}
-
-	public void setMechanismCreators(List<MechanismCreator> mechanismCreators) {
-		this.mechanismCreators = mechanismCreators;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/433612be/taverna-external-tool-activity/src/main/java/net/sf/taverna/t2/activities/externaltool/ExternalToolActivityFactory.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/net/sf/taverna/t2/activities/externaltool/ExternalToolActivityFactory.java b/taverna-external-tool-activity/src/main/java/net/sf/taverna/t2/activities/externaltool/ExternalToolActivityFactory.java
deleted file mode 100644
index dc27b11..0000000
--- a/taverna-external-tool-activity/src/main/java/net/sf/taverna/t2/activities/externaltool/ExternalToolActivityFactory.java
+++ /dev/null
@@ -1,100 +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.activities.externaltool;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.List;
-import java.util.Set;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import net.sf.taverna.t2.activities.externaltool.manager.MechanismCreator;
-import net.sf.taverna.t2.workflowmodel.Edits;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityConfigurationException;
-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;
-
-/**
- * An {@link ActivityFactory} for creating <code>ExternalToolActivity</code>.
- *
- * @author David Withers
- */
-public class ExternalToolActivityFactory implements ActivityFactory {
-
-	private List<InvocationCreator> invocationCreators;
-
-	private List<MechanismCreator> mechanismCreators;
-
-        private Edits edits;
-
-	@Override
-	public ExternalToolActivity createActivity() {
-		ExternalToolActivity activity = new ExternalToolActivity();
-		activity.setInvocationCreators(invocationCreators);
-                activity.setEdits(edits);
-		return activity;
-	}
-
-	@Override
-	public URI getActivityType() {
-		return URI.create(ExternalToolActivity.URI);
-	}
-
-	@Override
-	public JsonNode getActivityConfigurationSchema() {
-		ObjectMapper objectMapper = new ObjectMapper();
-		try {
- 			return objectMapper.readTree(getClass().getResource("/schema.json"));
-		} catch (IOException e) {
-			return objectMapper.createObjectNode();
-		}
-	}
-
-	public void setInvocationCreators(List<InvocationCreator> invocationCreators) {
-		this.invocationCreators = invocationCreators;
-	}
-
-	public void setMechanismCreators(List<MechanismCreator> mechanismCreators) {
-		this.mechanismCreators = mechanismCreators;
-	}
-
-	@Override
-	public Set<ActivityInputPort> getInputPorts(JsonNode configuration)
-			throws ActivityConfigurationException {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public Set<ActivityOutputPort> getOutputPorts(JsonNode configuration)
-			throws ActivityConfigurationException {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-        public void setEdits(Edits edits) {
-		this.edits = edits;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/433612be/taverna-external-tool-activity/src/main/java/net/sf/taverna/t2/activities/externaltool/ExternalToolActivityHealthChecker.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/net/sf/taverna/t2/activities/externaltool/ExternalToolActivityHealthChecker.java b/taverna-external-tool-activity/src/main/java/net/sf/taverna/t2/activities/externaltool/ExternalToolActivityHealthChecker.java
deleted file mode 100755
index b65da68..0000000
--- a/taverna-external-tool-activity/src/main/java/net/sf/taverna/t2/activities/externaltool/ExternalToolActivityHealthChecker.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2009 Hajo Nils Krabbenhoeft, INB, University of Luebeck
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public License
- *  as published by the Free Software Foundation; either version 2.1 of
- *  the License, or (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this 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.externaltool;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-
-import net.sf.taverna.t2.activities.externaltool.manager.InvocationGroup;
-import net.sf.taverna.t2.activities.externaltool.manager.InvocationGroupManager;
-import net.sf.taverna.t2.activities.externaltool.manager.InvocationMechanism;
-import net.sf.taverna.t2.visit.VisitReport;
-import net.sf.taverna.t2.visit.VisitReport.Status;
-import net.sf.taverna.t2.workflowmodel.health.HealthCheck;
-import net.sf.taverna.t2.workflowmodel.health.HealthChecker;
-import net.sf.taverna.t2.workflowmodel.utils.Tools;
-
-public class ExternalToolActivityHealthChecker implements HealthChecker<ExternalToolActivity> {
-
-	private InvocationGroupManager invocationGroupManager;
-	private ExternalToolActivity activity;
-
-	public boolean canVisit(Object subject) {
-		return subject != null && subject instanceof ExternalToolActivity;
-	}
-
-	public VisitReport visit(ExternalToolActivity activity, List<Object> ancestry) {
-		this.activity = activity;
-		ExternalToolActivityConfigurationBean configuration = activity.getConfigurationNoConversion();
-		List<VisitReport> reports = new ArrayList<VisitReport>();
-
-		VisitReport locationReport = checkLocation(configuration);
-		if (locationReport != null) {
-			reports.add(locationReport);
-		}
-
-		VisitReport report = new VisitReport(HealthCheck.getInstance(), activity, "External tool service", HealthCheck.NO_PROBLEM, reports);
-
-		return report;
-	}
-
-
-	private VisitReport checkLocation(
-			ExternalToolActivityConfigurationBean configuration) {
-
-		if (!updateLocation(configuration)) {
-			return new VisitReport(HealthCheck.getInstance(), activity, "Unmanaged invocation mechanism", HealthCheck.UNMANAGED_LOCATION, Status.WARNING);
-		} else {
-			return null;
-		}
-	}
-
-	public boolean updateLocation(ExternalToolActivityConfigurationBean configuration) {
-		InvocationGroup invocationGroup = configuration.getInvocationGroup();
-		String invocationGroupSpecification = null;
-		String invocationMechanismSpecification = null;
-		if (invocationGroup != null) {
-			if (invocationGroupManager.containsGroup(invocationGroup)) {
-				return true;
-			}
-			InvocationGroup replacementGroup = invocationGroupManager.getGroupReplacement(invocationGroup);
-			if (replacementGroup != null) {
-				configuration.setInvocationGroup(replacementGroup);
-				return true;
-			}
-			invocationGroupSpecification = invocationGroup.getName() + ":" + invocationGroup.getMechanismXML();
-			InvocationGroup importedGroup = invocationGroupManager.getImportedGroup(invocationGroupSpecification);
-			if (importedGroup != null) {
-				configuration.setInvocationGroup(importedGroup);
-				return true;
-			}
-		}
-
-		InvocationMechanism invocationMechanism = configuration.getMechanism();
-		if (invocationMechanism != null) {
-			if (invocationGroupManager.containsMechanism(invocationMechanism)) {
-				return true;
-			}
-		}
-		String mechanismXML = null;
-		String mechanismName = null;
-
-		if (invocationGroup != null) {
-			mechanismXML = invocationGroup.getMechanismXML();
-			mechanismName = invocationGroup.getMechanismName();
-		} else {
-			mechanismXML = configuration.getMechanismXML();
-			mechanismName = configuration.getMechanismName();
-		}
-		invocationMechanismSpecification = mechanismName + ":" + mechanismXML;
-
-		InvocationMechanism foundMechanism = null;
-		HashSet<String> mechanismNames = new HashSet<String>();
-		for (InvocationMechanism mechanism : invocationGroupManager.getMechanisms()) {
-			mechanismNames.add(mechanism.getName());
-			if (mechanism.getName().equals(mechanismName) && (mechanism.getXML().equals(mechanismXML))) {
-				if (invocationMechanism != mechanism) {
-					foundMechanism = mechanism;
-				}
-			}
-		}
-
-		if (foundMechanism == null) {
-			foundMechanism = invocationGroupManager.getMechanismReplacement(invocationMechanismSpecification);
-			if (foundMechanism == null) {
-				foundMechanism = invocationGroupManager.getImportedMechanism(invocationMechanismSpecification);
-			}
-		}
-
-		if (foundMechanism != null) {
-			if (invocationGroup != null) {
-				invocationGroup.setMechanism(foundMechanism);
-				// Cannot return because invocationGroup is still unknown
-			} else {
-				configuration.setMechanism(foundMechanism);
-				return true;
-			}
-		}
-
-		if (foundMechanism == null) {
-			InvocationMechanism createdMechanism;
-			if (invocationGroup != null) {
-				invocationGroup.convertDetailsToMechanism();
-				createdMechanism = invocationGroup.getMechanism();
-			} else {
-				configuration.convertDetailsToMechanism();
-				createdMechanism = configuration.getMechanism();
-			}
-
-			String chosenMechanismName = Tools.uniqueObjectName(mechanismName,
-					mechanismNames);
-			createdMechanism.setName(chosenMechanismName);
-			if (invocationGroup != null) {
-				invocationGroup.setMechanism(createdMechanism);
-			} else {
-				configuration.setMechanism(createdMechanism);
-			}
-			invocationGroupManager.importMechanism(invocationMechanismSpecification, createdMechanism);
-
-
-			if (invocationGroup == null) {
-				return true;
-			}
-		}
-
-		InvocationGroup foundGroup = null;
-		HashSet<String> groupNames = new HashSet<String>();
-		for (InvocationGroup group : invocationGroupManager.getInvocationGroups()) {
-			groupNames.add(group.getName());
-			if (group.getName().equals(invocationGroup.getName()) && (group.getMechanism() == invocationGroup.getMechanism())) {
-				foundGroup = group;
-			}
-		}
-		if (foundGroup != null) {
-			configuration.setInvocationGroup(foundGroup);
-			return true;
-		}
-		invocationGroup.setName(Tools.uniqueObjectName(invocationGroup.getName(), groupNames));
-		invocationGroupManager.importInvocationGroup(invocationGroupSpecification, invocationGroup);
-		return true;
-	}
-
-	public boolean isTimeConsuming() {
-		return false;
-	}
-
-	/**
-	 * Sets the invocationGroupManager.
-	 *
-	 * @param invocationGroupManager the new value of invocationGroupManager
-	 */
-	public void setInvocationGroupManager(InvocationGroupManager invocationGroupManager) {
-		this.invocationGroupManager = invocationGroupManager;
-	}
-
-}