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

[16/50] incubator-taverna-common-activities git commit: Removed Raven class loading of artifact dependencies.

Removed Raven class loading of artifact dependencies.

git-svn-id: http://taverna.googlecode.com/svn/taverna/engine/net.sf.taverna.t2.activities/trunk/dependency-activity@11938 bf327186-88b3-11dd-a302-d386e5130c1c


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/commit/f3a8212f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/tree/f3a8212f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/diff/f3a8212f

Branch: refs/heads/master
Commit: f3a8212fcb9e88b80b319484c99d305acf0198bc
Parents: 0c88ecf
Author: david@mygrid.org.uk <da...@bf327186-88b3-11dd-a302-d386e5130c1c>
Authored: Mon Nov 15 16:59:32 2010 +0000
Committer: david@mygrid.org.uk <da...@bf327186-88b3-11dd-a302-d386e5130c1c>
Committed: Mon Nov 15 16:59:32 2010 +0000

----------------------------------------------------------------------
 .../AbstractAsynchronousDependencyActivity.java | 156 +++++++++----------
 .../DependencyActivityConfigurationBean.java    |  58 +------
 2 files changed, 78 insertions(+), 136 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/f3a8212f/src/main/java/net/sf/taverna/t2/activities/dependencyactivity/AbstractAsynchronousDependencyActivity.java
----------------------------------------------------------------------
diff --git a/src/main/java/net/sf/taverna/t2/activities/dependencyactivity/AbstractAsynchronousDependencyActivity.java b/src/main/java/net/sf/taverna/t2/activities/dependencyactivity/AbstractAsynchronousDependencyActivity.java
index 37a9503..f5fe2ab 100644
--- a/src/main/java/net/sf/taverna/t2/activities/dependencyactivity/AbstractAsynchronousDependencyActivity.java
+++ b/src/main/java/net/sf/taverna/t2/activities/dependencyactivity/AbstractAsynchronousDependencyActivity.java
@@ -25,24 +25,15 @@ import java.io.FilenameFilter;
 import java.lang.ref.WeakReference;
 import java.net.URL;
 import java.net.URLClassLoader;
-import java.util.Arrays;
 import java.util.HashSet;
-import java.util.Set;
 import java.util.WeakHashMap;
 
-import net.sf.taverna.raven.appconfig.ApplicationRuntime;
-import net.sf.taverna.raven.prelauncher.BootstrapClassLoader;
-import net.sf.taverna.raven.prelauncher.PreLauncher;
-import net.sf.taverna.raven.repository.BasicArtifact;
-import net.sf.taverna.raven.repository.impl.LocalArtifactClassLoader;
-import net.sf.taverna.raven.repository.impl.LocalRepository;
 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 net.sf.taverna.t2.workflowmodel.utils.Tools;
 
 import org.apache.log4j.Logger;
 
@@ -89,7 +80,8 @@ public abstract class AbstractAsynchronousDependencyActivity<ConfigType> extends
 	 * The location of the <code>lib</code> directory in TAVERNA_HOME,
 	 * where local JAR files the activity depends on should be located.
 	 */
-	public static File libDir = new File(ApplicationRuntime.getInstance().getApplicationHomeDir(), "lib");
+//	public static File libDir = new File(ApplicationRuntime.getInstance().getApplicationHomeDir(), "lib");
+	public static File libDir = null;
 
 	/**
 	 * Different ways to share a class loader among activities:
@@ -144,24 +136,24 @@ public abstract class AbstractAsynchronousDependencyActivity<ConfigType> extends
 			}
 		}
 		if (classLoaderSharing == ClassLoaderSharing.system) {
-			if (systemClassLoader == null)
-				systemClassLoader = PreLauncher.getInstance().getLaunchingClassLoader();
+//			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{
+//			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);
@@ -179,10 +171,10 @@ public abstract class AbstractAsynchronousDependencyActivity<ConfigType> extends
 			String workflowID) {
 		
 		// Find all artifact dependencies
-		HashSet<URL> urls = findDependencies(ARTIFACTS, configurationBean, workflowID);
+//		HashSet<URL> urls = findDependencies(ARTIFACTS, configurationBean, workflowID);
 		
 		// Add all local jar dependencies
-		urls.addAll(findDependencies(LOCAL_JARS, configurationBean, workflowID));
+		HashSet<URL> urls = findDependencies(LOCAL_JARS, configurationBean, workflowID);
 		
 		// Create the classloader capable of loading both local jar and artifact dependencies
 		ClassLoader parent = this.getClass().getClassLoader(); // this will be a LocalArtifactClassLoader
@@ -210,24 +202,24 @@ public abstract class AbstractAsynchronousDependencyActivity<ConfigType> extends
 	 * 
 	 * @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);
-		}		
-	}
+//	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 
@@ -260,7 +252,7 @@ public abstract class AbstractAsynchronousDependencyActivity<ConfigType> extends
 			// as this activity
 			for (Processor proc : wf.getProcessors()) {
 				// Nested workflow case
-				if (Tools.containsNestedWorkflow(proc)){		
+				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, configurationBean, nestedWorkflow));
@@ -270,7 +262,7 @@ public abstract class AbstractAsynchronousDependencyActivity<ConfigType> extends
 					if (activity instanceof AbstractAsynchronousDependencyActivity){
 						if (((DependencyActivityConfigurationBean) activity
 								.getConfiguration()).getClassLoaderSharing() == classLoaderSharing) {
-							if (dependencyType.equals(LOCAL_JARS)){
+//							if (dependencyType.equals(LOCAL_JARS)){
 								// Collect the files of all found local dependencies
 								for (String jar : ((DependencyActivityConfigurationBean)activity.getConfiguration()).getLocalDependencies()) {
 									try {
@@ -280,22 +272,22 @@ public abstract class AbstractAsynchronousDependencyActivity<ConfigType> extends
 										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 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 (dependencyType.equals(LOCAL_JARS)){
 				for (String jar : configurationBean.getLocalDependencies()) {
 					try {
 						dependencies.add(new File(libDir, jar));
@@ -304,23 +296,23 @@ public abstract class AbstractAsynchronousDependencyActivity<ConfigType> extends
 						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
-				}
-			}
+//			}
+//			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
@@ -352,7 +344,7 @@ public abstract class AbstractAsynchronousDependencyActivity<ConfigType> extends
 		
 		for (Processor proc : nestedWorkflow.getProcessors()) {
 			// Another nested workflow
-			if (Tools.containsNestedWorkflow(proc)){		
+			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, configurationBean, nestedNestedWorkflow));
@@ -364,7 +356,7 @@ public abstract class AbstractAsynchronousDependencyActivity<ConfigType> extends
 					if (((DependencyActivityConfigurationBean) activity
 							.getConfiguration()).getClassLoaderSharing() == classLoaderSharing) {
 						
-						if (dependencyType.equals(LOCAL_JARS)){
+//						if (dependencyType.equals(LOCAL_JARS)){
 							// Collect the files of all found local dependencies
 							for (String jar : ((DependencyActivityConfigurationBean)activity.getConfiguration()).getLocalDependencies()) {
 								try {
@@ -373,16 +365,16 @@ public abstract class AbstractAsynchronousDependencyActivity<ConfigType> extends
 									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));
 							}
-						}						
+//						} 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));
+//							}
+//						}						
 					}
 				}
 			}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/f3a8212f/src/main/java/net/sf/taverna/t2/activities/dependencyactivity/DependencyActivityConfigurationBean.java
----------------------------------------------------------------------
diff --git a/src/main/java/net/sf/taverna/t2/activities/dependencyactivity/DependencyActivityConfigurationBean.java b/src/main/java/net/sf/taverna/t2/activities/dependencyactivity/DependencyActivityConfigurationBean.java
index 8b63590..aab3a6c 100644
--- a/src/main/java/net/sf/taverna/t2/activities/dependencyactivity/DependencyActivityConfigurationBean.java
+++ b/src/main/java/net/sf/taverna/t2/activities/dependencyactivity/DependencyActivityConfigurationBean.java
@@ -20,19 +20,17 @@
  ******************************************************************************/
 package net.sf.taverna.t2.activities.dependencyactivity;
 
-import java.net.URL;
 import java.util.LinkedHashSet;
 
-import net.sf.taverna.raven.repository.BasicArtifact;
 import net.sf.taverna.t2.activities.dependencyactivity.AbstractAsynchronousDependencyActivity.ClassLoaderSharing;
 import net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityPortsDefinitionBean;
 
 /**
- * Parent configuration bean for activities that have local JAR or artifact dependencies,
+ * Parent configuration bean for activities that have local JAR,
  * such as API Consumer and Beanshell activity.
  * 
  * @author Alex Nenadic
- *
+ * @author David Withers
  */
 public class DependencyActivityConfigurationBean extends
 		ActivityPortsDefinitionBean {
@@ -48,28 +46,13 @@ public class DependencyActivityConfigurationBean extends
 	 * and the paths should be relative.
 	 */
 	private LinkedHashSet<String> localDependencies ;//= new LinkedHashSet<String>();
-	
-	/**
-	 * Artifact dependencies. These artifacts should be available from
-	 * the centrally known repositories or from one of the listed repositories in
-	 * {@link #repositories}.
-	 */
-	private LinkedHashSet<BasicArtifact> artifactDependencies ;//= new LinkedHashSet<BasicArtifact>();
-	
-	/**
-	 * Repositoryies to use when searching for artifacts. In addition, the system
-	 * repositories will be searched.
-	 */
-	@Deprecated
-	private LinkedHashSet<URL> repositories ;//= new LinkedHashSet<URL>();
-		
+			
 	/**
 	 * Constructor.
 	 */
 	public DependencyActivityConfigurationBean(){
 		classLoaderSharing = ClassLoaderSharing.workflow;
 		localDependencies = new LinkedHashSet<String>();
-		artifactDependencies = new LinkedHashSet<BasicArtifact>();
 	}
 	
 	/**
@@ -84,9 +67,6 @@ public class DependencyActivityConfigurationBean extends
 		if (localDependencies == null) 
 			localDependencies = new LinkedHashSet<String>();
 
-		if (artifactDependencies == null)
-			artifactDependencies = new LinkedHashSet<BasicArtifact>();
-
 			return this;
 	}
 	
@@ -133,36 +113,6 @@ public class DependencyActivityConfigurationBean extends
 	public void removeLocalDependency(String dep){
 		localDependencies.remove(dep);
 	}
-	
-	/**
-	 * @return the artifactDependencies
-	 */
-	public LinkedHashSet<BasicArtifact> getArtifactDependencies() {
-		return artifactDependencies;
-	}
-	
-	/**
-	 * @param artifactDependencies the artifactDependencies to set
-	 */
-	public void setArtifactDependencies(LinkedHashSet<BasicArtifact> artifactDependencies) {
-		this.artifactDependencies = artifactDependencies;
-	}
-	
-	/**
-	 * Adds an artifact dependency to the list of local dependencies.
-	 * @param dep
-	 */
-	public void addArtifactDependency(BasicArtifact dep){
-		artifactDependencies.add(dep);
-	}
-
-	/**
-	 * Removes an artifact dependency from the list of local dependencies.
-	 * @param dep
-	 */
-	public void removeArtifacteDependency(BasicArtifact dep){
-		artifactDependencies.remove(dep);
-	}
-	
+		
 }