Script activities

Script activities are used to run inline Java code as an activity of the process. The Java code can access all BPEL variables, correlation properties, and partner links, as well as process and activity contexts.

You can also use inline Java code for conditions. Each Java code snippet for activities or conditions is run in its own Java method. These methods belong to an enterprise bean that is created for the process. The run-time environment of the Java code is the Java 2 Platform Enterprise Edition (J2EE) environment of regular Enterprise JavaBeans (EJB).

The following BPEL code snippet shows a script activity with inline Java code for an activity:
<bpel:invoke  ....>
  <wpc:script>

   <wpc:javaCode>
     EObject myCustomer = getPurchaseOrder().eGet("customer") ;
     EObject account = getAccount() ;
     account.eSet("ID", myCustomer.eGet("accountID") ) ;
     setAccount(account) ;
   </wpc:javaCode>
  </wpc:script>

 <!-- standard activity elements go here --> 
</bpel:invoke>  
The following BPEL code snippet shows a script activity with inline Java code for a condition:
<bpel:while>
  <wpc:condition>
   <wpc:javaCode>
     return getCounter().getValue() > 0 ;
   </wpc:javaCode>
  </wpc:condition>

 <!-- loop activity goes here --> 
</bpel:while>  

Copyright IBM Corp. 2003, 2005