Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Loading new artifacts from inside a Taverna Beanshell
import net.sf.taverna.raven.repository.Artifact;
import net.sf.taverna.raven.repository.BasicArtifact;
import net.sf.taverna.raven.repository.impl.LocalArtifactClassLoader;
LocalArtifactClassLoader cl = (LocalArtifactClassLoader) getClass().getClassLoader();
Artifact a = new BasicArtifact("com.example", "fred", "0.1.0");
cl.getRepository().addArtifact(a);
cl.getRepository().update(); // force any download and resolution
// Now we can get his classloader
ClassLoader hisCl = cl.getRepository().getLoader(a, cl);
Object fred = hisCl.loadClass("com.example.Fred").newInstance();
// In Beanshell we don't need to do further introspection and can do:
fred.doStuff();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.