Embedding Service Data Objects with bpelx:exec
You can embed SDO code in the .bpel
file with the bpelx:exec
tag. In the syntax provided in the following example, mytest.apps.SDOHelper
is a Java class that modifies SDOs.
</bpelx:exec> <bpelx:exec name="ModifyInternalSDO" version="1.5" language="java"> <![CDATA[try{ Object o = getVariableData("VarSDO"); Object out = getVariableData("ExtSDO"); System.out.println("BPEL:Modify VarSDO... " + o + " ExtSDO: " + out); mytest.apps.SDOHelper.print(o); mytest.apps.SDOHelper.print(out); mytest.apps.SDOHelper.modifySDO(o); System.out.println("BPEL:After Modify VarSDO... " + o + " ExtSDO: " + out); mytest.apps.SDOHelper.print(o); mytest.apps.SDOHelper.print(out); }catch(Exception e) { e.printStackTrace(); }]]> </bpelx:exec>
The following provides an example of the Java classes modifySDO(o)
and print(o)
that are embedded in the BPEL file:
public static void modifySDO(Object o){ if(o instanceof commonj.sdo.DataObject) { ((DataObject)o).getChangeSummary().beginLogging(); SDOType type = (SDOType)((DataObject)o).getType(); HelperContext hCtx = type.getHelperContext(); List<DataObject> lines = (List<DataObject>)((DataObject)o).get("line"); for (DataObject line: lines) { line.set("eligibilityStatus", "Y"); } } else { System.out.println("SDOHelper.modifySDO(): " + o + " is not a DataObject!"); } } . . . . . . public static void print(Object o) { try{ if(o instanceof commonj.sdo.DataObject) { DataObject sdo = (commonj.sdo.DataObject)o; SDOType type = (SDOType) sdo.getType(); HelperContext hCtx = type.getHelperContext(); System.out.println(hCtx.getXMLHelper().save(sdo, type.getURI(), type.getName())); } else { System.out.println("SDOHelper.print(): Not a sdo " + o); } }catch(Exception e) { e.printStackTrace(); } }