How do you embed Java code in your JPDL ?

Please note that this tutorial has been written for old versions of jBPM (jBPM 3/4). We recommend to migrate your applications to jBPM 7 and use a different approach to run Java code in your processes.

The following tutorial discusses jBPM 7 best practices, including strategies to run Java code in your Processes: JBPM best practices

How to run Java code in jPDL processes (jBPM 3/4)

You can use a BeanShell expression to add’ a Java script’ in your JPDL process definition, you can use the <script> tag

‘  <event type=”node-enter”>
‘ ‘ ‘  <script>
‘ ‘ ‘ ‘ ‘  System.out.println(“Entered node”+node);
‘ ‘ ‘  </script>

‘  </event>
‘  …
You can use in your script’ all process variables created plus the following process variables :

  • executionContext
  • token
  • node
  • task
  • taskInstance