Question: Is using a java embedding in BPEL considered bad practice, and why if so?
In my job I frequently use Java embeddings as BPEL components in order to get certain work done. It can be very easy stuff which is just comfortable for me in Java, or things that are impossible (in my knowledge) to do with other components in BPEL.
Example of simple java embedding in 12c BPEL source:
<bpelx:exec name="TruncateBlankNamespace" language="java" version="1.5">
<![CDATA[String origHeader = (String)getVariableData("randomHeader"); try { String replacedvalue = origHeader.replaceAll(" xmlns=\"\"", ""); setVariableData("randomHeader_something", replacedvalue) ;} catch (Exception exception) { exception.printStackTrace(); }]]>
</bpelx:exec>
Another example that I use it for is to encode and decode payloads into base64 and back,
Example of base64 ecoding embedding in 11c BPEL source:
<bpelx:exec import="oracle.soa.common.util.Base64Encoder"/>
<variables>
<variable name="DecodedMessage" type="xsd:string"/>
<variable name="EncodedMessage" type="xsd:base64Binary"/>
<variables/>
<bpelx:exec name="EncodePayload" language="java" version="1.5">String decodedMessage = (String)getVariableData("DecodedMessage"); try { String encodedMessage = Base64Encoder.encode(decodedMessage.getBytes()); setVariableData("EncodedMessage", encodedMessage);} catch (Exception exception) { exception.printStackTrace(); }</bpelx:exec>
Now I find embeddings very useful tools in working around certain problems, and fixing issues quickly without having to do the additional homework in the tool you are using. However it has been brought to my attention that using java embeddings in Oracle Soa suite/BPEL is bad practice.
I am a beginner middleware developer, and new to stack overflow, so please excuse me if I'm not being thorough, please point out everything wrong with this post, and feel free to edit :D!
Thank you very much!
Jesper