How to Embed Java Code Snippets in a BPEL 2.0 Process
The examples in this chapter focus primarily on how to embed Java code snippets with the bpelx:exec
extension. For BPEL projects that support version 2.0 of the BPEL specification, the syntax is slightly different. The bpelx:exec
extension and Java code are wrapped in an <extensionActivity>
element. The following example provides details.
<extensionActivity> <bpelx:exec language="java"> <![CDATA[ java code ]]> </bpelx:exec> </extensionActivity>
When you drag a Java Embedding activity into a BPEL process in Oracle BPEL Designer, the <extensionActivity>
element and bpelx:exec
tag are automatically added.
The following example shows the import syntax for BPEL 2.0:
<import location="class/package name" importType="http://schemas.oracle.com/bpel/extension/java"/>
Note:
The BPEL 2.0 import syntax differs from BPEL 1.1, which uses the following syntax:
<bpelx:exec import="class/package name"/>
The following example shows a BPEL file with two Java embedding activities for a project that supports BPEL version 2.0.
<process name="Test" targetNamespace="http://samples.otn.com/bpel2.0/ch10.9" . . . . . . <import location="oracle.xml.parser.v2.XMLElement" importType="http://schemas.oracle.com/bpel/extension/java"/> . . . <sequence> . . . <extensionActivity> <bpelx:exec language="java"> XMLElement elem = (XMLElement) getVariableData("output", "payload"); elem.setTextContent("set by java exec"); </bpelx:exec> </extensionActivity> <extensionActivity> <bpelx:exec language="java"> <![CDATA[XMLElement elem = (XMLElement) getVariableData("output", "payload"); String t = elem.getTextContent(); elem.setTextContent(t + ", set by java exec 2");]]> </bpelx:exec> </extensionActivity> . . . </sequence> </process>
For information about using this activity, see Using Java Embedding in a BPEL Process in .