BPEL Process Embed Java Codes

Now I will demonstrate how you can embed sections of Java code into a BPEL process. This is particularly useful when there is already Java code that can perform the desired function, and you want to use the existing code rather than start over with BPEL.
 
I.      When should us use embed Java codes.
 
If you have an existed Java bean, and the result of this bean depends on some variable data of the process, under this situation, you can use the embedding Java.
 
II.      How to use embedding Java.
  
1. Embedding Java Code in BPEL
 
One way to make use of Java in a BPEL process is to embed the code directly into the BPEL process using the Java BPEL exec extension bpelx: exec.  The benefits of this approach are speed and transactional. However, only fairly small segments of code can be incorporated.
 
The bpelx: exec Tag
The BPEL tag bpelx: exec enables you to embed a snippet of Java code within a BPEL process. The server executes any snippet of Java code contained within a bpelx: exec activity, within its JTA transaction context. Java exceptions are converted into BPEL faults and put into a BPEL process. The Java snippet can propagate its JTA transaction to session and entity beans that it calls.
 
You can design your process in JDeveloper as below:
 
First, drag the activity into the platform 
                           
Then double-click the Activity  , you can see a screen  , just add code in it.
 
 
 
 
2. Using Java Code with WSIF Binding
 
Java code can be used from the BPEL process if the Java application has a   BPEL compatible interface. Two compatible interfaces are as follows:
 
a. WSIF binding
b. Wrapping as a SOAP service
 
 
 
a.      WSIF binding
 
WSIF Binding is the most common way of using Java code in a BPEL process. WSIF binding enables a BPEL process to invoke an EJB through native J2EE   protocol (local or RMI).With WSIF binding, a section of the WSDL file defines the protocol for communicating between Java and XML. This approach maintains Java’s transactionality and does not sacrifice performance, but has less interoperability (each application server needs a specific binding) and currently less tool support than SOAP services. The binding must currently be written by hand.
  
b.     Using Java Code Wrapped as a SOAP Service
 
A Java application wrapped as a SOAP service appears as any other Web service, which can be used by many different kinds of applications. There are also tools available for writing SOAP wrappers. However, a Java application wrapped as a SOAP service will:
 
** Sacrifices performance, because interactions are constantly being mapped back and forth between the Java code and the SOAP wrapper
 
** Loses interoperability, that is, the ability to perform several operations in an
all-or-none mode (such as debiting one bank account while crediting another, where either both transactions must be completed, or neither of them)
 
   
III.      Summary
 
This section demonstrates how you can embed sections of Java code into a BPEL process. One way to integrate an existing Java component into a BPEL process is by including an inline code snippet using bpelx: exec. This snippet is executed within the transaction context of Oracle BPEL Server. This method allows you to propagate that transaction to your own session and entity beans. A set of built-in methods enable the bpelx: exec snippet to read and update variables, change instance meta data, and throw faults.
An XML facade can be used within code to simplify DOM manipulation.
 
 
 
 
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值