|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.taverna.example.WorkflowLauncherWrapper
public class WorkflowLauncherWrapper
A simplified example application demonstrating how to invoke the Taverna API through Raven, without the need to bootstrap the application.
Its main point is to demonstrate populating an Repository instance
with the system artifacts and external artifacts required to execute a
workflow. Workflow execution is the most popular request, but this technique
can also be applied to access other parts of the Taverna API.
The system artifacts relate to the artifacts that already exist within the
applications classpath. Correctly defining these ensures that the
applications classloader is used to create instances of classes contained
within these artifacts. This prevents Raven creating instances through its
own classloaders leading to ClassCastException or similar errors. These
artifacts are defined in
buildSystemArtifactSet()
Since you necessarily will be accessing parts of Taverna's API, you will need
to include the relevant artifacts on your application's classpath to be able
to access the classes. If you access other parts of Taverna than this example
shows, you will need to add those artifacts to
buildSystemArtifactSet() as well.
For instance, if you are constructing a new workflow using the API, and you
need access to a
SoaplabProcessor, you will
need to both list taverna-soaplab-processor as a system artifact and include
it and its dependencies in your application's classpath.
The external artifacts relate to artifacts that exist outside of the
application as SPI plugin points, ie. artifacts that are not
on the application's classpath. For the purpose of this example this is the
Processors that are needed during workflow execution. These artifacts
are defined in buildExternalArtifactSet().
Depending on which parts of Taverna's API you are invoking, you might have to
include more artifacts from Taverna's distribution profile.
Because these artifacts are not defined in the application they, and their
dependencies, need to be downloaded when the application is first run and are
downloaded to the local repository location defined by the method
getRepositoryBaseFile(), and ultimately the
runtime argument -basedir if provided.
The external artifacts are downloaded from the remote repository locations
defined in buildRepositoryLocationSet().
The key to this approach is initialising a Repository using the API
call:
Repository repository = LocalRepository.getRepository(localrepository,
applicationClassloader, systemArtifacts);
Then making sure the local repository is up to date with a call:
repository.update();
The repository is then registered with the TavernaSPIRegistry with
the call:
TavernaSPIRegistry.setRepository(repository);
This all takes place within
initialiseRepository()
Note that for simplicity in this example the external artifacts and remote repositories have been hardcoded and would normally be better defined separately in a file. For the same reason, exception handling has also been kept to a minimum.
There is nothing requiring you to use this mechanism from an
main(String[]) method started from the command line, this is just to
make this example self-contained and simple. As long as you include the
necessary dependencies this example should be easily ported to be used within
a servlet container such as Tomcat.
First build using maven together with the appassembler plugin:
mvn package appassembler:assemble
Then navigate to the target/appassembler/bin directory and run
the runme[.bat] command:
runme [-inputdoc <path to input doc>
-outputdoc <path to output doc>
-basedir <path to local repository download dir>]
-workflow <path to workflow scufl file>.
| Field Summary | |
|---|---|
static java.lang.String |
TAVERNA_BASE_VERSION
The version of Taverna core components that is used, for instance 1.6.2.0. |
| Constructor Summary | |
|---|---|
WorkflowLauncherWrapper()
|
|
| Method Summary | |
|---|---|
static void |
main(java.lang.String[] args)
|
void |
run(java.lang.String[] args)
The execution entry point, called by main(String[]) |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String TAVERNA_BASE_VERSION
1.6.2.0.
(Note that although processors and plugins might be updated by their
minor-minor version, say a
SoaplabProcessor can
be in version 1.6.2.1, the core components listed by
buildSystemArtifactSet() would still be 1.6.2.0,
and thus this constant would also be 1.6.2.0. You might have
to update use of TAVERNA_BASE_VERSION in
buildExternalArtifactSet() if you want a newer version of a
processor or similar.)
This version has to match the version of the real dependency you have to Taverna libraries on your classpath (ie. the pom.xml dependencies).
| Constructor Detail |
|---|
public WorkflowLauncherWrapper()
| Method Detail |
|---|
public static void main(java.lang.String[] args)
public void run(java.lang.String[] args)
throws java.lang.Exception
main(String[])
args - the arguments as passed to main(String[])
java.lang.Exception - if anything goes wrong
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||