OSWorkflow supports BeanShell as a scripting language. You can find out more about BeanShell at the BeanShell website. Reading the documentation for BeanShell should be more than enough to get started with scripting for your own workflow definition file. There are a few behaviors that you should be aware of before starting, however: The type that must be chosen for BeanShell functions is beanshell. There is one required argument: script. The value for this argument is the actual script that is to be executed. Example: <function type="beanshell"> <arg name="script"> System.out.println("Hello, World!"); </arg> </function> There are three variables in the expression scope at all times: entry context, and store. The variable "entry" is an object that implements com.opensymphony.workflow.spi.WorkflowEntry and represents the workflow instance. The variable "context" is an object of type com.opensymphony.workflow.WorkflowContext which allows for BeanShell functions to roll back transactions or determine the caller name. The "store" variable is of type com.opensymphony.workflow.WorkflowStore Just like 3.4.1 Java-based Functions, there are three variables that can be used and are automatically set in the BeanShell scope: transientVars, args, and propertySet. The same rules that apply to Java functions also apply here. Example: <function type="beanshell"> <arg name="script"> propertySet.setString("world", "Earth"); </arg> </function> <function type="beanshell"> <arg name="script"> System.out.println("Hello, "+propertySet.getString("world")); </arg> </function> The output of these two scripts would be "Hello, Earth". This is because any variable stored in the propertySet is persisted for use in functions later in the workflow.
|