You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2009/07/02 01:54:45 UTC

svn commit: r790423 - /tuscany/java/sca/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELInvoker.java

Author: rfeng
Date: Wed Jul  1 23:54:45 2009
New Revision: 790423

URL: http://svn.apache.org/viewvc?rev=790423&view=rev
Log:
Add the fault explanation to the error message

Modified:
    tuscany/java/sca/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELInvoker.java

Modified: tuscany/java/sca/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELInvoker.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELInvoker.java?rev=790423&r1=790422&r2=790423&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELInvoker.java (original)
+++ tuscany/java/sca/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELInvoker.java Wed Jul  1 23:54:45 2009
@@ -6,15 +6,15 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *   http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
- * under the License.    
+ * under the License.
  */
 
 package org.apache.tuscany.sca.implementation.bpel.ode.provider;
@@ -33,7 +33,6 @@
 import org.apache.ode.bpel.iapi.MessageExchange.Status;
 import org.apache.ode.utils.DOMUtils;
 import org.apache.ode.utils.GUID;
-import org.apache.ode.utils.Properties;
 import org.apache.tuscany.sca.implementation.bpel.ode.EmbeddedODEServer;
 import org.apache.tuscany.sca.interfacedef.Interface;
 import org.apache.tuscany.sca.interfacedef.Operation;
@@ -47,27 +46,27 @@
 
 /**
  * Implements a target invoker for BPEL component implementations.
- * 
+ *
  * The target invoker is responsible for dispatching invocations to the particular
  * component implementation logic. In this example we are simply delegating the
  * CRUD operation invocations to the corresponding methods on our fake
  * resource manager.
- * 
+ *
  * @version $Rev$ $Date$
  */
 public class BPELInvoker implements Invoker {
     protected final Log __log = LogFactory.getLog(getClass());
-    
+
     private EmbeddedODEServer odeServer;
     private TransactionManager txMgr;
-    
+
     private RuntimeComponentService service;
     private Operation operation;
     private QName bpelServiceName;
     private String bpelOperationName;
     private Part bpelOperationInputPart;
     private Part bpelOperationOutputPart;
-    
+
     public BPELInvoker(RuntimeComponent component, RuntimeComponentService service, Operation operation, EmbeddedODEServer odeServer, TransactionManager txMgr) {
         this.service = service;
         this.operation = operation;
@@ -78,28 +77,28 @@
         initializeInvocation();
     }
 
-    
+
     private void initializeInvocation() {
-      
+
         __log.debug("Initializing BPELInvoker");
 
         Interface interfaze = operation.getInterface();
         if(interfaze instanceof WSDLInterface){
             WSDLInterface wsdlInterface = null;
             wsdlInterface = (WSDLInterface) interfaze;
-            
+
             // The following commented out code is bogus and is replaced by what follows - Mike Edwards
-            // Service serviceDefinition = (Service) wsdlInterface.getWsdlDefinition().getDefinition().getAllServices().values().iterator().next(); 
+            // Service serviceDefinition = (Service) wsdlInterface.getWsdlDefinition().getDefinition().getAllServices().values().iterator().next();
             // bpelServiceName = serviceDefinition.getQName();
             //
             // Fetch the service name from the service object
             bpelServiceName = new QName( "http://tuscany.apache.org", service.getName() );
-                
+
             bpelOperationInputPart = (Part) wsdlInterface.getPortType().getOperation(bpelOperationName,null,null).getInput().getMessage().getParts().values().iterator().next();
             bpelOperationOutputPart = (Part) wsdlInterface.getPortType().getOperation(bpelOperationName,null,null).getOutput().getMessage().getParts().values().iterator().next();
         }
     }
-    
+
     public Message invoke(Message msg) {
         try {
             Object[] args = msg.getBody();
@@ -113,14 +112,14 @@
 
     public Object doTheWork(Object[] args) throws InvocationTargetException {
         Element response = null;
-        
+
         if(! (operation.getInterface() instanceof WSDLInterface)) {
             throw new InvocationTargetException(null,"Unsupported service contract");
         }
-        
+
         org.apache.ode.bpel.iapi.MyRoleMessageExchange mex = null;
         Future<?> onhold = null;
-        
+
         //Process the BPEL process invocation
         try {
             txMgr.begin();
@@ -129,7 +128,7 @@
                                                                               bpelOperationName);
             mex.setProperty("isTwoWay", "true");
             onhold = mex.invoke(createInvocationMessage(mex, args));
-            
+
             txMgr.commit();
         } catch (Exception e) {
             try {
@@ -138,7 +137,7 @@
 
             }
             throw new InvocationTargetException(e, "Error invoking BPEL process : " + e.getMessage());
-        } 
+        }
 
 
         // Waiting until the reply is ready in case the engine needs to continue in a different thread
@@ -158,19 +157,21 @@
             mex = (MyRoleMessageExchange)odeServer.getBpelServer().getEngine().getMessageExchange(mex.getMessageExchangeId());
 
             Status status = mex.getStatus();
-            
+
             if (__log.isDebugEnabled()) {
                 Element invocationResponse = mex.getResponse().getMessage();
                 __log.debug(">>>Invocation status:" + status.name());
                 __log.debug(">>>Response:\n" + DOMUtils.domToString(invocationResponse));
                 __log.debug(">>>Response:\n" + DOMUtils.domToString(invocationResponse));
             } // end if
-            
+
             switch (status) {
             case FAULT:
                 if (__log.isDebugEnabled())
                     __log.debug("Fault response message: " + mex.getFault());
-                throw new ODEInvocationException("FAULT received from BPEL process : " + mex.getFault());
+                    throw new ODEInvocationException("FAULT received from BPEL process : " + mex.getFault()
+                        + " "
+                        + mex.getFaultExplanation());
             case ASYNC:
             case RESPONSE:
                 //process the method invocation result
@@ -185,7 +186,7 @@
             default:
                 throw new ODEInvocationException("FAILURE received from BPEL process : " + mex.getFault());
             } // end switch
-            
+
             txMgr.commit();
             // end of transaction two
         } catch (Exception e) {
@@ -196,14 +197,14 @@
             }
             throw new InvocationTargetException(e, "Error retrieving BPEL process invocation status : " + e.getMessage());
         }
-    
-    
+
+
         return response;
     }
 
     /**
      * Create BPEL Invocation message
-     * 
+     *
      *  BPEL invocation message like :
      *  <message>
      *     <TestPart>
@@ -215,22 +216,22 @@
      */
     private org.apache.ode.bpel.iapi.Message createInvocationMessage(org.apache.ode.bpel.iapi.MyRoleMessageExchange mex, Object[] args) {
         Document dom = DOMUtils.newDocument();
-        
+
         Element contentMessage = dom.createElement("message");
         Element contentPart = dom.createElement(bpelOperationInputPart.getName());
         Element payload = null;
-        
+
         //TUSCANY-2321 - Properly handling Document or Element types
         if(args[0] instanceof Document) {
             payload = (Element) ((Document) args[0]).getFirstChild();
         } else {
             payload = (Element) args[0];
         }
-        
+
         contentPart.appendChild(dom.importNode(payload, true));
         contentMessage.appendChild(contentPart);
         dom.appendChild(contentMessage);
-        
+
         if (__log.isDebugEnabled()) {
             __log.debug("Creating invocation message:");
             __log.debug(">> args.....: " + DOMUtils.domToString(payload));
@@ -239,25 +240,25 @@
 
         org.apache.ode.bpel.iapi.Message request = mex.createMessage(new QName("", ""));
         request.setMessage(dom.getDocumentElement());
-                
+
         return request;
     }
-    
+
     /**
      * Process BPEL response
-     * 
+     *
      *  <message>
      *     <TestPart>
      *        <hello xmlns="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl">World</hello>
      *     </TestPart>
-     *   </message> 
-     * 
+     *   </message>
+     *
      * @param response
      * @return
      */
     private Element processResponse(Element response) {
     	return (Element) DOMUtils.findChildByName(response, new QName("",bpelOperationOutputPart.getName())).getFirstChild();
-    	
+
     	// MJE, 12/06/2009 - changed to return the message without the PART wrapper element, since this element is not
     	// transmitted in the SOAP messages on the wire
     	//return (Element) DOMUtils.findChildByName(response, new QName("",bpelOperationOutputPart.getName()));