What is ScriptRunnerProxy?

ScriptRunnerProxy is a component that requests execution of script.
You can use ScriptRunnerProxy from your Java application by using Java API.
For more information about Java API, refer to "API Document(Javadoc)".

Use of ScriptRunnerProxy

Environment Settings

To use ScriptRunnerProxy, following environments are required for ScriptRunnerProxy. Install the following environments before ScriptRunnerProxy executes.

Required information for using

To use ScriptRunnerProxy, the following information is needed.

Flow of use

The flow of use of ScriptRunnerProxy is as follows.
  1. Create Java application by using Java API.

  2. Compile the created Java application.

  3. Execute the created Java application.

Use from Java program

Class path

To use ScriptRunnerProxy by Java, you should add classpath of following module.

Flow of program

  1. Get the instance of ScriptRunnerConnectionManager.

  2. Generate ScriptRunnerConnectionFactory from ScriptRunnerConnectionManager.

  3. Set information required for the connection in ScriptRunnerConnectionFactory.
    Host name, port number, execution user, and execution user's passwords are required for the connection.

  4. Generate ScriptRunnerConnection from ScriptRunnerConnectionFactory.ScriptRunnerConnection is a class that connect to DataSpiderServer, that is execution engine of the script.

  5. Generate ScriptRunnerParam.Set various parameters to ScriptRunnerParam when the whereabouts of the script and the script of argument information etc. are executed.

  6. Generate ScriptPK. ScriptPK is a class that uniquely shows the script.Set the service name and the script name to ScriptPK.

  7. Set ScriptPK in ScriptRunnerParam.Information that executed the script was set in the parameter by this.

  8. Set ScriptRunnerParam in ScriptRunnerConnection.To execute the script by this, the required preliminary was completed.

  9. Execute the script by ScriptRunnerConnection#execute().

  10. Get execution result from ScriptRunnerResult.

Sample program

An example of creating a Java program is as follows.

class ScriptRunnerTest {
	public static void main (String[] args) throws Exception {
		// Get instance of ScriptRunnerConnectionManager
		ScriptRunnerConnectionManager manager = ScriptRunnerConnectionManager.getInstance();

		// Generate ScriptRunnerConnectionFactory
		ScriptRunnerConnectionFactory factory = manager.createConnectionFactory();

		// Set hostname
		// Set port number
		// Set execution user
		// Set execution user's password
		// Set whether to use HTTPS

		ScriptRunnerConnection conn = null;
		try {
			// Generate ScriptRunnerConnection
			conn = factory.newConnection();

			// Generate ScriptRunnerParam
			ScriptRunnerParam param = new ScriptRunnerParam();

			// Generate ScriptPK
			// First argument is "service name", second argument is "script name"
			// The default form of service name is "user-name@project name"
			ScriptPK pk = new ScriptPK("test@project", "script");

			// Create arguments
			// When the argument is not passed, it is not required.
 			Map<String, Object> input = new HashMap<String, Object>();
			// The input variable of string type is set
			// Take String type
			input.put("in.string", "test");
			// The input variable of integer type is set
			// Take Integer type
			input.put("in.integer", Integer.valueOf(111));
			// The input variable of decimal type is set
			// Take BigDecimal type
			input.put("in.decimal", new BigDecimal(222));
			// The input variable of date type is set
			// Take Date type
			input.put("", new Date());
			// The input variable of boolean type is set
			// Take Boolean type
			input.put("in.boolean", Boolean.valueOf("true"));
			// The input variable of binary type is set
			// Take byte[] type
			input.put("in.binary", new byte[]{0x42, 0x43});
			// The input variable of XML type is set
			// Take the string representation of the XML document
			input.put("in.xml", "<?xml version=\"1.0\"?><root />");

			// Create options
			// When you don't set any option, it is not required.
			ScriptRunnerOption option = new ScriptRunnerOption();
			option.setType(ExecutionTypes.TYPE_PRODUCTION); // Execute by the type for real part. When omitting it, Execute script with ExecutionTypes.TYPE_DEFAULT.
			// Option.setType ("<user specified type>"); // Execute script by the user specified type.Specify type directly.

			// Execute and get result
			ScriptRunnerResult result = conn.execute(param);

			// Get exit status
			System.out.println("Exit Status: " + result.getExitStatus());
			if (result.isSucceeded()) {
				// When processing is succeeded
				Map output = result.getResultData();
				for (Object key : output.keySet()) {
					Object value = output.get(key);
					if (value == null) {
						System.out.println(key + "(null): " + value);
					} else {
						System.out.println(key + "(" + value.getClass().getName() + "): " + value);
			} else {
				// When processing is failed
				for (Failure f = result.getFailure(); f != null; f = {
		} finally {
			if (conn != null) conn.close();

Setting method of argument

Set information on the argument to ScriptRunnerParam when you pass the script the argument.Store information on the argument in Map.

Make the name of the input variable defined by the script a key and set the value to Map.The value should agree with the type of the variable defined as an input variable.The correspondence of the type of the input variable when passing it as a value of the argument and the type of Java is as follows.

Type of input variable Type of Java that can be set Remarks
String java.lang.String  
Integer java.lang.Integer  
Decimal java.math.BigDecimal  
Date/Time java.util.Date  
Boolean java.lang.Boolean  
Binary byte[]  
XML byte[] or java.lang.String  

Method of specifying option

The option when the script is executed can be specified for ScriptRunnerParam.Make and set ScriptRunnerOption to set the option.
The option that can be specified is as follows.

Key Value Description Remarks
TYPE - Specify the type when ScriptRunnerProxy executes script.  
default Execute script by "Default" type.
Also when TYPE is not explicitly specified, "Default" is used at runtime.
test Execute script by "Test" type.  
production Execute script by "Production" type.  
<User-specified type> Execute script when you register service by the type that the user arbitrarily specified when a global resource is made.  
ENABLE_TYPE_SWITCH - Set whether to switch and retrieve the type again when a global resource of the specified type doesn't exist.  
true Retrieve it again by "Default" type when a global resource of the specified type doesn't exist.  
false When a global resource of the specified type doesn't exist, raise error.
When ENABLE_TYPE_SWITCH is omitted It operates as false.
ENABLE_XML_LOG - Set ON/OFF of the XML log.  
true Output the XML log.  
false Do not output the XML log. (default)  
LOG_LEVEL - Specify Log Level  
NOTICE Logs severe errors that cause premature termination or unexpected conditions that are critical.(default)  
INFO Logs informative runtime events occurred but the messages are kept at its minimum.  
FINFO Logs informative runtime events occurred.  
FINEST Shows more detailed messages than FINFO Log Level.  
DEBUG Provides messages useful for debugging.  

Method of getting execution result

Take out the execution result of ScriptRunnerResult.Map that results in the getResultData method can be gotten.

The result data can be gotten by making the output variable of the script a key when the result is taken out of Map.The correspondence of the type of the script output variable and the type of the Java of the result data is as follows.

Type of output variable Type of Java that can be set Remarks
String java.lang.String  
Integer java.lang.Integer  
Decimal java.math.BigDecimal  
Date/Time java.util.Date  
Boolean java.lang.Boolean  
Binary byte[]  
XML Byte[] or org.w3c.dom.Document
  • Assume gotten byte[] to be XML when the XML data is returned as byte[] and do Perth.
    Convert byte[] into once to assume byte[] to be XML and to do Perth, and pass it to org.xml.sax.InputSource.

Assertion of XML tuype result data

To assert data as a result of the XML type, XmlAssert is prepared.Refer to API document for details.

Method of setting time-out of script execution

Waiting time (timeout period) from the script to returning of the execution result can be set.
When the time-out is not set, waiting time is unrestricted.

Specify the following properties in the option of the Java start to set the time-out.

Key Description Remarks A timeout value in milliseconds until the script execution expires
  • Defaults to -1.Script execution never expires if 0 or less is specified.
  • Specify an integer number no fewer than "1000".
  • Specify it in milliseconds
  • Example:

Sample program

The sample program is stored in $DATASPIDER_HOME/<server|client>/doc/scriptrunnerproxy/en/sample directory.

It is an easy program to call the script.

Confirm the following information to execute the sample program, and change.

Execute from command line (batch)

  1. Specify the installation directory of DataSpiderServer in the DS_HOME variable of setenvscriptrunner.bat.
    Example: When space is included in the installation directory, it is required to bundle it by a double quotation.

  2. Specify the Java file name that compiles to "compilescriptrunner.bat".
    (In the initial state, "" is specified.)
    e.g.:javac -encoding %SRC_ENCODING% -cp %CP%

  3. Specify the class name to be executed for "execscriptrunner.bat".
    (In the initial state, "ScriptRunnerTest" is specified.)
    e.g.:java -cp %CP%;. ScriptRunnerTest

  4. Execute "compilescriptrunner" to compile Java file.

  5. Execute "execscriptrunner" to execute script.
The example of setting the time-out when the sample program is executed is as follows.
Specify the option for the java command of execscriptrunner.bat.
REM Set the time-out in ten minutes.
java -cp %CP%;. ScriptRunnerTest

Execute from ant

  1. Specify the installation directory of DataSpiderServer at dataspider.install.dir in the
    Example; Replace the path delimiter "\" with "/" in the

  2. Specify the class name to be executed at the classname element in java task for build.xml.
    In the initial state, "ScriptRunnerTest" is specified.

  3. Move to the sample directory and execute ant. The compilation will succeed with the default task.

  4. Execute "ant execute" to execute the script.
The example of setting the time-out is as follows.
Add the jvmarg element to the java task of build.xml, and specify the option.
<target name="execute">
  <java classname="ScriptRunnerTest" fork="yes" classpathref="class.path">
      <pathelement path="." />
    <!-- Set the time-out in ten minutes. -->
    <jvmarg value=""/>