Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Scripting Client 0.8

danbim edited this page Jul 27, 2012 · 2 revisions

The Scripting Client provides an easy way to script interactions with the WISEBED Web Service APIs to e.g. automate experiments.

It consists of an executable JAR that takes a source file and passes it to a BeanShell interpreter instance for execution. Prior to execution some additional environment setup (i.e. importing packages, importing static helper functions, ...) is done (see details below).

The scripts are being developed in a Java 1.4-like language (no generics supported!). The big advantage of the scripting client is that you can execute it whereever Java is installed and the only thing you practically need is shell access. You don't even have to compile the scripts as they're interpreted by the BeanShell interpreter.

Basic Usage

The Scripting Client is an executable jar file that you can start by executing:

java -jar tr.scripting-client-$VERSION-onejar.jar

Command Line Parameters

Short Long Arguments Comment Optional
f file $FILE The bean shell script to execute false
p properties $PROPERTIES A .properties file with key/value pairs to pass to the script false
v verbose Verbose logging output true
h help Print help true

The filename that is passed in the properties argument is expected to correspond to what is defined for the Java Properties class. Example:

testbed.snaa.endpointurl = http://wisebed.itm.uni-luebeck.de:8890/snaa
testbed.rs.endpointurl   = http://wisebed.itm.uni-luebeck.de:8889/rs
testbed.sm.endpointurl   = http://wisebed.itm.uni-luebeck.de:8888/sessions
testbed.urnprefixes      = urn:wisebed:uzl1:

All properties will be set as environment variables in the JVM environment. This is basically the same effect as if starting the JVM with e.g., java -Dpropertyname=propertyvalue .... Please note that this can be done additionaly. This way (either through command line arguments to the JVM or through the properties file) you can pass arguments to your script. In the script itself you will then be able to read the arguments e.g., like this:

String snaaEndpointUrl = System.getProperty("testbed.snaa.endpointurl");

Environment

Pre-Imported Classes

For your comfort the scripting environment is prepared with a number of classes imports so that you don't have to import every class in every script yourself. Additional classes may still be imported, however.

Web Service API Binding Classes

Web Service Helpers

  • eu.wisebed.testbed.api.wsn.WSNServiceHelper
  • eu.wisebed.testbed.api.rs.RSServiceHelper
  • eu.wisebed.testbed.api.snaa.helpers.SNAAServiceHelper

Additional Helpers specifically for the Scripting Client

  • de.uniluebeck.itm.wisebed.cmdlineclient.*
  • de.uniluebeck.itm.wisebed.cmdlineclient.jobs.*
  • de.uniluebeck.itm.wisebed.cmdlineclient.protobuf.*
  • de.uniluebeck.itm.wisebed.cmdlineclient.wrapper.*

Other Utility Classes

Pre-Initialized Variables

Additionally to pre-imported packages there are some variables available to your script that are already initialized:

Variable Name Class Description
log org.slf4j.Logger Logging facility
helper de.uniluebeck.itm.wisebed.cmdlineclient.BeanShellHelper Static helper methods

The BeanShellHelper class contains a set of static methods that make writing the scripts less cumbersome.

Importing Additional Classes in Your Scripts

You can easily import additional classes in your scripts. The set of importable classes is defined through the dependencies that are packaged into the scripting-client jar and the jars you might add to the classpath of the scripting-client environment upon execution. The bundled dependencies can be found in the scripting-client pom.xml. To see all (transitive) dependencies please run mvn dependency:tree in the scripting-client directory.

Source

See the Scripting Client module source code to get the most precise "documentation".

Example Scripts

The best examples are to be found within scripts that are actually used on a daily basis. Therefore, please take a look at the scripts in the Experimentation Scripts assembly. Please, also take a look at Experimentation Scripts 0.8.