Last active
August 29, 2015 14:02
-
-
Save stain/aaf5bc710defc36f5d16 to your computer and use it in GitHub Desktop.
Loading new artifacts from inside a Taverna Beanshell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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