Difference between revisions of "Script"
(Created page with "==Description== <div class="version_lt3.5"> The content defines a JavaScript script. This script is applied to the current GVBuffer object. Within a node ChangeGVBuffer...") |
(→Description) |
||
Line 11: | Line 11: | ||
Following an example of a script implementing the toUpperCase service: | Following an example of a script implementing the toUpperCase service: | ||
− | |||
<syntaxhighlight lang="xml"> | <syntaxhighlight lang="xml"> | ||
<GVOperationNode class="it.greenvulcano.gvesb.core.flow.GVOperationNode" | <GVOperationNode class="it.greenvulcano.gvesb.core.flow.GVOperationNode" | ||
− | + | id="call_server" id-system="GVESB" input="input" | |
− | + | next-node-id="end" op-type="call" | |
− | + | operation-name="echo_call" output="output" | |
− | + | point-x="186" point-y="152" type="flow-node"> | |
− | + | <OutputServices> | |
− | + | <java-script-service critical="yes" internal="yes" type="service"> | |
− | + | <java-script-call class="it.greenvulcano.gvesb.virtual.internal.JSCallOperation" | |
− | + | name="toupper" type="call"> | |
− | + | <Script>root.setObject(root.getObject().toUpperCase());</Script> | |
− | + | </java-script-call> | |
− | + | </java-script-service> | |
− | + | </OutputServices> | |
</GVOperationNode> | </GVOperationNode> | ||
</syntaxhighlight> | </syntaxhighlight> |
Latest revision as of 10:19, 2 January 2015
Description
The content defines a JavaScript script. This script is applied to the current GVBuffer object.
Within a node ChangeGVBuffer is used for script execution, execution environment map is added to the script context as 'environment' property and the current input object is added as 'data' property.
The element value cannot be null.
The Script Element is used by ChangeGVBuffer and java-script-call.
Following an example of a script implementing the toUpperCase service:
<GVOperationNode class="it.greenvulcano.gvesb.core.flow.GVOperationNode"
id="call_server" id-system="GVESB" input="input"
next-node-id="end" op-type="call"
operation-name="echo_call" output="output"
point-x="186" point-y="152" type="flow-node">
<OutputServices>
<java-script-service critical="yes" internal="yes" type="service">
<java-script-call class="it.greenvulcano.gvesb.virtual.internal.JSCallOperation"
name="toupper" type="call">
<Script>root.setObject(root.getObject().toUpperCase());</Script>
</java-script-call>
</java-script-service>
</OutputServices>
</GVOperationNode>
The content defines a generic script. This script is applied to the current GVBuffer object or other objects, depending the containing context.
Within a node ChangeGVBuffer is used for script execution, execution environment map is added to the script context as 'environment' property and the current input object is added as 'data' property. The properties access syntax is language-dependent.
The element value cannot be null. If defined the 'file' attribute overrides the contained script.
The Script Element is used by ChangeGVBuffer, script-call, ResultProcessor, ScriptCondition, ScriptDecoder, ScriptEncoder.
The following table shows the Script element's attributes:
Attribute | Type | Description |
---|---|---|
lang | required | The script engine to use. References a GVScriptConfig Engine. |
base-context | optional | This attribute defines the 'context' to be used for script execution. If not set, the default context is inherited from the specific 'lang' configuration. References a GVScriptConfig BaseContext. |
file | optional | This attribute is the name of a file containing the script to execute. The file path must be relative to $GV_HOME/scripts. |
Following an example of a JavaScript script implementing the toUpperCase service:
<GVOperationNode class="it.greenvulcano.gvesb.core.flow.GVOperationNode"
id="call_server" id-system="GVESB" input="input"
next-node-id="end" op-type="call"
operation-name="echo_call" output="output"
point-x="186" point-y="152" type="flow-node">
<OutputServices>
<script-service critical="yes" internal="yes" type="service">
<script-call class="it.greenvulcano.gvesb.virtual.internal.ScriptCallOperation"
name="toupper" type="call">
<Script lang="js">data.setObject(data.getObject().toUpperCase());</Script>
</script-call>
</script-service>
</OutputServices>
</GVOperationNode>
The previous example using a OGNL script:
<GVOperationNode class="it.greenvulcano.gvesb.core.flow.GVOperationNode"
id="call_server" id-system="GVESB" input="input"
next-node-id="end" op-type="call"
operation-name="echo_call" output="output"
point-x="186" point-y="152" type="flow-node">
<OutputServices>
<script-service critical="yes" internal="yes" type="service">
<script-call class="it.greenvulcano.gvesb.virtual.internal.ScriptCallOperation"
name="toupper" type="call">
<Script lang="ognl">#data.object = #data.object.toUpperCase()</Script>
</script-call>
</script-service>
</OutputServices>
</GVOperationNode>