private HashSet findNestedDependencies()

in taverna-beanshell-activity/src/main/java/org/apache/taverna/activities/dependencyactivity/AbstractAsynchronousDependencyActivity.java [349:409]


	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;
	}