OSWorkflow requires BeanShell to work properly. This is because of the tight integration with the BeanShell project. More information about BeanShell in general can be found at http://www.beanshell.org. Reading the documentation for BeanShell should be more than enough to get started with scripting your own workflow definition file. There are a few behaviors that you should be aware of before starting, however:
There are two variables in the expression scope at all times: entry and session. The variable "entry" is an object that implementscom.opensymphony.workflow.persistence.WorkflowEntry and represents the workflow instance. The variable "session" is an object of type javax.ejb.SessionContext which allows for BeanShell functions to roll back transactions or determine the caller name.
There are other variables in scope, but these are only there for convenience: all entries in the workflow entry PropertySet are represented as a variable already in scope. For example, if a String in the PropertySet was defined with the code entry.getPropertySet().setString("foo", "bar"), then the variable "foo" would also be in scope. Variable state is saved back in to the PropertySet after the BeanShell code has been executed. So, if your script was foo = "baz", it would be the equivalent of entry.getPropertySet().setString("foo", "baz").
For example, assume your XML snipplet is this:
<pre-functions> <function type="beanshell"> String foo = "this is a test"; </function> <function type="beanshell"> System.out.println(foo); </function> </pre-functions>
... the output of these two functions would print out the contents of "foo",
even though these are different functions. In fact, these functions could be
called weeks apart from each other in different steps and actions. The variables
in functions (both beanshell and classes) stay persisted through the workflow
lifecycle.