The named beans property allow values to be passed to and from the script.
beans | A named bean which is made available to the script. |
classLoader | ClassLoader to load the Script Engine. |
input | The script provided as input from file or buffer etc. |
invocable | Allow a scripted function to be evaluated from elsewhere in Oddjob. |
language | The name of the language the script is in. |
name | A name, can be any text. |
redirectStderr | Combine stdin and stderr. |
result | The result of executing the script or the script variable chosen as the result variable with the resultVariable property. |
resultForState | If true then use the result to determine the completion state of the job. |
resultVariable | The variable in the script that will be used to provide the result. |
script | The script provided as text. |
stderr | An output to where stderr of the script will be written. |
stdin | An input stream which will act as stdin for the script. |
stdout | An output to where stdout for the script will be written. |
stop | This flag is set by the stop method and should be examined by any Stoppable jobs in their processing loops. |
variables | Provide access to variables declared within the script. |
Example 1 | Hello World. |
Example 2 | Variables from and to Oddjob. |
Example 3 | Using a script to set a property on a Job elsewhere in Oddjob. |
Example 4 | Invoking a script to provide a substring function. |
Example 5 | Setting the script job to not complete. |
Configured By | ELEMENT |
Access | READ_WRITE |
Required | No. |
A named bean which is made available to the script.
Configured By | ELEMENT |
Access | READ_WRITE |
Required | No. Automatically set to the current Oddjob class loader. |
ClassLoader to load the Script Engine.
Configured By | ELEMENT |
Access | READ_WRITE |
Required | Yes, if script isn't. |
The script provided as input from file or buffer etc.
Access | READ_ONLY |
Allow a scripted function to be evaluated from elsewhere in Oddjob.
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No. Defaults to JavaScript. |
The name of the language the script is in.
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No. |
A name, can be any text.
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No. |
Combine stdin and stderr.
Access | READ_ONLY |
The result of executing the script or the script variable chosen as the result variable with the resultVariable property.
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No, defaults to false. |
If true then use the result to determine the completion state of the job. If the result is not a number this property will have no affect. If the result is a number and 0 the job will COMPLETE, any other value and the job will be INCOMPLETE.
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No. |
The variable in the script that will be used to provide the result. The property is designed for use with scripting languages who's execution does not produce a result. If, however the script does produce a result and this property is set, the variable will override the scripts return value.
Configured By | TEXT |
Access | READ_WRITE |
Required | Yes, if input isn't. |
The script provided as text.
Configured By | ELEMENT |
Access | READ_WRITE |
Required | No, defaults to none. |
An output to where stderr of the script will be written.
Configured By | ELEMENT |
Access | READ_WRITE |
Required | No, defaults to none. |
An input stream which will act as stdin for the script.
Configured By | ELEMENT |
Access | READ_WRITE |
Required | No, defaults to none. |
An output to where stdout for the script will be written.
Access | READ_ONLY |
Required | Read Only. |
This flag is set by the stop method and should be examined by any Stoppable jobs in their processing loops.
Access | READ_ONLY |
Provide access to variables declared within the script.
Hello World.
<oddjob> <job> <script id="s" language="JavaScript"> <input> <buffer>print ("hello world\n");</buffer> </input> </script> </job> </oddjob>
Variables from and to Oddjob.
<oddjob> <job> <sequential> <jobs> <script id="s" language="JavaScript"> <input> <buffer> var snack = fruit; </buffer> </input> <beans> <value key="fruit" value="apple"/> </beans> </script> <echo id="e">${s.variables(fruit)}</echo> </jobs> </sequential> </job> </oddjob>
Using a script to set a property on a Job elsewhere in Oddjob.
<oddjob> <job> <sequential> <jobs> <script id="s" language="JavaScript"> <input> <buffer> vars.set('today', new java.util.Date()); </buffer> </input> <beans> <value key="vars" value="${v}"/> </beans> </script> <variables id="v"> <formattedToday> <format date="${v.today}" format="yyyyMMdd"/> </formattedToday> </variables> </jobs> </sequential> </job> </oddjob>
Invoking a script to provide a substring function.
<oddjob> <job> <sequential> <jobs> <script id="substr" language="JavaScript"> <input> <buffer>function substr(string, from, to) { return string.substring(from, to); }</buffer> </input> </script> <properties id="properties"> <values> <value key="text.before" value="Apples and Oranges"/> <invoke function="substr" key="text.after"> <parameters> <value value="${text.before}"/> <value value="0"/> <value value="6"/> </parameters> <source> <value value="${substr.invocable}"/> </source> </invoke> </values> </properties> </jobs> </sequential> </job> </oddjob>
Setting the script job to not complete.
<oddjob> <job> <script language="JavaScript" resultVariable="result" resultForState="true"> <input> <buffer> var result = 1; </buffer> </input> </script> </job> </oddjob>