public DependentLoaderImplementation cloneLoader( DependentLoader loader, String aditionalDependency) { DependentLoaderImplementation otherAsImplementation = (DependentLoaderImplementation) loader; DependentLoaderImplementation newLoader = new DependentLoaderImplementation( otherAsImplementation.artifact, loader.getURLs(), exposed, otherAsImplementation.parent); newLoader.dependencies = otherAsImplementation.dependencies; if (!"".equals(aditionalDependency)) { DependentLoaderImplementation dependency = enshureDependencyJarLoaded(otherAsImplementation.artifact, aditionalDependency); ArrayList<DependentLoaderImplementation> depList = new ArrayList<DependentLoaderImplementation>(); for (DependentLoaderImplementation dependentLoaderImplementation : newLoader.dependencies) { depList.add(dependentLoaderImplementation); } depList.add(dependency); newLoader.setDependencies(depList.toArray(new DependentLoaderImplementation[depList.size()])); } visitLoader(newLoader); return newLoader; }
public void connect(String connectThis, String toThis) { List<DependentLoaderImplementation> connectLoaders = new ArrayList<DependentLoaderImplementation>(); List<DependentLoaderImplementation> toLoaders = new ArrayList<DependentLoaderImplementation>(); for (String stringKey : loaderMap.keySet()) { if (stringKey.startsWith(connectThis)) { connectLoaders.add(loaderMap.get(stringKey)); } if (stringKey.startsWith(toThis)) { toLoaders.add(loaderMap.get(stringKey)); } } for (DependentLoaderImplementation connectLoader : connectLoaders) { DependentLoaderImplementation[] newDependents = new DependentLoaderImplementation[connectLoader.dependencies.length + toLoaders.size()]; int i = 0; for (DependentLoaderImplementation oldDependency : connectLoader.dependencies) { newDependents[i++] = oldDependency; } for (DependentLoaderImplementation toLoader : toLoaders) { newDependents[i++] = toLoader; } connectLoader.dependencies = newDependents; } }