tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r529787 - /incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/
Date Tue, 17 Apr 2007 22:08:07 GMT
Author: antelder
Date: Tue Apr 17 15:08:05 2007
New Revision: 529787

URL: http://svn.apache.org/viewvc?view=rev&rev=529787
Log:
Axis2 binding, more code tidy up

Modified:
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncTargetInvoker.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2OneWayTargetInvoker.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBinding.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2TargetInvoker.java

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncTargetInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncTargetInvoker.java?view=diff&rev=529787&r1=529786&r2=529787
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncTargetInvoker.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncTargetInvoker.java
Tue Apr 17 15:08:05 2007
@@ -41,11 +41,11 @@
     public Axis2AsyncTargetInvoker(ServiceClient serviceClient,
                                    QName wsdlOperationName,
                                    Options options,
-                                   SOAPFactory soapFactory, WorkContext workContext) {
-        super(serviceClient, wsdlOperationName, options, soapFactory, workContext);
+                                   SOAPFactory soapFactory) {
+        super(serviceClient, wsdlOperationName, options, soapFactory);
     }
 
-    public Object invokeTarget(final Object payload, final short sequence) throws InvocationTargetException
{
+    public Object invokeTarget(final Object payload, final short sequence, WorkContext workContext)
throws InvocationTargetException {
         throw new InvocationTargetException(new InvocationRuntimeException("Operation not
supported"));
     }
 
@@ -53,7 +53,7 @@
         throws InvocationTargetException {
         try {
             Object[] args = (Object[]) payload;
-            OperationClient operationClient = createOperationClient(args);
+            OperationClient operationClient = createOperationClient(args, null);
             callbackInvoker.setCallbackRoutingChain(callbackRoutingChain);
             Axis2ReferenceCallback callback = new Axis2ReferenceCallback(callbackInvoker);
             operationClient.setCallback(callback);
@@ -76,17 +76,6 @@
         } catch (AxisFault e) {
             throw new InvocationTargetException(e);
         }
-    }
-
-    public Message invoke(Message msg) throws InvocationRuntimeException {
-        try {
-//            Object resp = invokeTarget(msg.getBody(), msg.getCallbackRoutingChain()); //
TODO: getCallbackRoutingChain no longer exists
-            Object resp = invokeTarget(msg.getBody(), null);
-            msg.setBody(resp);
-        } catch (Throwable e) {
-            msg.setBodyWithFault(e);
-        }
-        return msg;
     }
 
     public void setCallbackTargetInvoker(Axis2ReferenceCallbackTargetInvoker callbackInvoker)
{

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2OneWayTargetInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2OneWayTargetInvoker.java?view=diff&rev=529787&r1=529786&r2=529787
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2OneWayTargetInvoker.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2OneWayTargetInvoker.java
Tue Apr 17 15:08:05 2007
@@ -22,37 +22,33 @@
 
 import javax.xml.namespace.QName;
 
-import org.apache.axiom.om.OMElement;
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.client.OperationClient;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.client.ServiceClient;
 import org.apache.tuscany.spi.component.WorkContext;
-import org.apache.tuscany.spi.wire.InvocationRuntimeException;
-import org.apache.tuscany.spi.wire.Message;
 
 public class Axis2OneWayTargetInvoker extends Axis2TargetInvoker {
 
-    protected static final OMElement RESPONSE = null;
-
     public Axis2OneWayTargetInvoker(ServiceClient serviceClient,
                                     QName wsdlOperationName,
                                     Options options,
-                                    SOAPFactory soapFactory, WorkContext workContext) {
+                                    SOAPFactory soapFactory) {
 
-        super(serviceClient, wsdlOperationName, options, soapFactory, workContext);
+        super(serviceClient, wsdlOperationName, options, soapFactory);
     }
 
-    public Object invokeTarget(final Object payload, final short sequence) throws InvocationTargetException
{
+    public Object invokeTarget(final Object payload, final short sequence, WorkContext workContext)
throws InvocationTargetException {
         try {
             Object[] args = (Object[]) payload;
-            OperationClient operationClient = createOperationClient(args);
 
+            OperationClient operationClient = createOperationClient(args, workContext);
             operationClient.execute(false);
 
             // REVIEW it seems ok to return null
-            return RESPONSE;
+            return null;
+
         } catch (AxisFault e) {
             throw new InvocationTargetException(e);
         } catch (Throwable t) {
@@ -60,13 +56,4 @@
         }
     }
 
-    public Message invoke(Message msg) throws InvocationRuntimeException {
-        try {
-            Object resp = invokeTarget(msg.getBody(), NONE);
-            msg.setBody(resp);
-        } catch (Throwable e) {
-            msg.setBodyWithFault(e);
-        }
-        return msg;
-    }
 }

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBinding.java?view=diff&rev=529787&r1=529786&r2=529787
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBinding.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBinding.java
Tue Apr 17 15:08:05 2007
@@ -156,11 +156,11 @@
 
         Axis2TargetInvoker invoker;
         if (hasCallback) {
-            invoker = new Axis2AsyncTargetInvoker(serviceClient, wsdlOperationQName, options,
soapFactory, workContext);
+            invoker = new Axis2AsyncTargetInvoker(serviceClient, wsdlOperationQName, options,
soapFactory);
         } else if (isOneWay) {
-            invoker = new Axis2OneWayTargetInvoker(serviceClient, wsdlOperationQName, options,
soapFactory, workContext);
+            invoker = new Axis2OneWayTargetInvoker(serviceClient, wsdlOperationQName, options,
soapFactory);
         } else {
-            invoker = new Axis2TargetInvoker(serviceClient, wsdlOperationQName, options,
soapFactory, workContext);
+            invoker = new Axis2TargetInvoker(serviceClient, wsdlOperationQName, options,
soapFactory);
         }
 
         return invoker;

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java?view=diff&rev=529787&r1=529786&r2=529787
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java
Tue Apr 17 15:08:05 2007
@@ -18,6 +18,8 @@
  */
 package org.apache.tuscany.binding.axis2;
 
+import java.lang.reflect.InvocationTargetException;
+
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axis2.AxisFault;
@@ -25,6 +27,7 @@
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver;
 import org.apache.tuscany.interfacedef.Operation;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
 
 public class Axis2ServiceInOutSyncMessageReceiver extends AbstractInOutSyncMessageReceiver
{
 
@@ -32,15 +35,14 @@
 
     private Axis2ServiceBinding axis2Service;
 
+    public Axis2ServiceInOutSyncMessageReceiver() {
+    }
+
     public Axis2ServiceInOutSyncMessageReceiver(Axis2ServiceBinding service, Operation operation)
{
         this.axis2Service = service;
         this.operation = operation;
     }
 
-    public Axis2ServiceInOutSyncMessageReceiver() {
-
-    }
-
     @Override
     public void invokeBusinessLogic(MessageContext inMC, MessageContext outMC) throws AxisFault
{
         try {
@@ -58,13 +60,13 @@
             outMC.setEnvelope(soapEnvelope);
             outMC.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN, Constants.VALUE_TRUE);
 
-//        } catch (InvocationTargetException e) {
-//            e.printStackTrace();
-//            Throwable t = e.getCause();
-//            if (t instanceof Exception) {
-//                throw AxisFault.makeFault((Exception)t);
-//            }
-//            throw new InvocationRuntimeException(e);
+        } catch (InvocationTargetException e) {
+            e.printStackTrace();
+            Throwable t = e.getCause();
+            if (t instanceof Exception) {
+                throw AxisFault.makeFault((Exception)t);
+            }
+            throw new InvocationRuntimeException(e);
         } catch (Exception e) {
             e.printStackTrace();
             throw AxisFault.makeFault(e);

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2TargetInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2TargetInvoker.java?view=diff&rev=529787&r1=529786&r2=529787
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2TargetInvoker.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2TargetInvoker.java
Tue Apr 17 15:08:05 2007
@@ -39,61 +39,46 @@
 import org.apache.tuscany.spi.Scope;
 import org.apache.tuscany.spi.component.WorkContext;
 import org.apache.tuscany.spi.extension.TargetInvokerExtension;
-import org.apache.tuscany.spi.wire.InvocationRuntimeException;
-import org.apache.tuscany.spi.wire.Message;
 
 /**
  * Axis2TargetInvoker uses an Axis2 OperationClient to invoke a remote web service
  */
 public class Axis2TargetInvoker extends TargetInvokerExtension {
 
+    private ServiceClient serviceClient;
     private QName wsdlOperationName;
-
     private Options options;
-
     private SOAPFactory soapFactory;
 
-    private ServiceClient serviceClient;
-
-    private WorkContext workContext;
-
     public static final QName CONVERSATION_ID_REFPARM_QN = new QName(Constants.SCA10_NS,"conversationID");
     
-    public Axis2TargetInvoker(ServiceClient serviceClient, QName wsdlOperationName, Options
options,
-                              SOAPFactory soapFactory, WorkContext workContext) {
+    public Axis2TargetInvoker(ServiceClient serviceClient, QName wsdlOperationName, Options
options, SOAPFactory soapFactory) {
+        this.serviceClient = serviceClient;
         this.wsdlOperationName = wsdlOperationName;
         this.options = options;
         this.soapFactory = soapFactory;
-        this.serviceClient = serviceClient;
-        this.workContext = workContext;
     }
 
-    /**
-     * Invoke a WS operation
-     *
-     * @param payload
-     * @param sequence
-     * @return
-     * @throws InvocationTargetException
-     */
-    public Object invokeTarget(final Object payload, final short sequence) throws InvocationTargetException
{
+
+    public Object invokeTarget(final Object payload, final short sequence, WorkContext workContext)
throws InvocationTargetException {
         try {
+
             Object[] args = (Object[]) payload;
-            OperationClient operationClient = createOperationClient(args);
+            OperationClient operationClient = createOperationClient(args, workContext);
 
             operationClient.execute(true);
 
             MessageContext responseMC = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+
             return responseMC.getEnvelope().getBody().getFirstElement();
 
         } catch (AxisFault e) {
             throw new InvocationTargetException(e);
         }
-
     }
 
     @SuppressWarnings("deprecation")
-    protected OperationClient createOperationClient(Object[] args) throws AxisFault {
+    protected OperationClient createOperationClient(Object[] args, WorkContext workContext)
throws AxisFault {
         SOAPEnvelope env = soapFactory.getDefaultEnvelope();
         if (args != null && args.length > 0) {
             SOAPBody body = env.getBody();
@@ -108,10 +93,10 @@
         }
         MessageContext requestMC = new MessageContext();
         requestMC.setEnvelope(env);
+
         // Axis2 operationClients can not be shared so create a new one for each request
         OperationClient operationClient = serviceClient.createClient(wsdlOperationName);
-        
-        
+
         if(workContext != null){
             String conversationId = (String) workContext.getIdentifier(Scope.CONVERSATION);
             if(conversationId != null && conversationId.length()!=0){
@@ -126,49 +111,12 @@
                 OMElement el= fromEPR.toOM(AddressingConstants.Final.WSA_NAMESPACE,AddressingConstants.WSA_FROM,AddressingConstants.WSA_DEFAULT_PREFIX);
                 sh.addChild(el);
             }
-
         }
 
-                
         operationClient.setOptions(options);
         operationClient.addMessageContext(requestMC);
-        return operationClient;
-    }
 
-    public Message invoke(Message msg) throws InvocationRuntimeException {
-        try {
-            Object resp = invokeTarget(msg.getBody(), NONE);
-            msg.setBody(resp);
-        } catch (Throwable e) {
-            msg.setBodyWithFault(e);
-        }
-        return msg;
-    }
-
-    public Axis2TargetInvoker clone() throws CloneNotSupportedException {
-        try {
-            return (Axis2TargetInvoker) super.clone();
-        } catch (CloneNotSupportedException e) {
-            // will not happen
-            return null;
-        }
-    }
-
-    public boolean isCacheable() {
-        return true;
-    }
-
-    public void setCacheable(boolean cacheable) {
-
-    }
-
-    public boolean isOptimizable() {
-        return false;
-    }
-
-    public Object invokeTarget(Object payload, short sequence, WorkContext workContext) throws
InvocationTargetException {
-        // TODO Auto-generated method stub
-        return null;
+        return operationClient;
     }
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message