You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2006/09/14 17:08:06 UTC

svn commit: r443381 - in /incubator/tuscany/java/sca/bindings/binding.axis2/src: main/java/org/apache/tuscany/binding/axis2/ test/java/org/apache/tuscany/binding/axis2/ test/resources/wsdl/

Author: antelder
Date: Thu Sep 14 08:08:05 2006
New Revision: 443381

URL: http://svn.apache.org/viewvc?view=rev&rev=443381
Log:
TUSCANY-721, Apply patch from Ignacio for binding async support

Added:
    incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncTargetInvoker.java   (with props)
    incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallback.java   (with props)
    incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java   (with props)
    incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java   (with props)
    incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java   (with props)
    incubator/tuscany/java/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/GreetingCallback.java   (with props)
Modified:
    incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java
    incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Reference.java
    incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java
    incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2TargetInvoker.java
    incubator/tuscany/java/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ReferenceTestCase.java
    incubator/tuscany/java/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ServiceTestCase.java
    incubator/tuscany/java/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Greeter.java
    incubator/tuscany/java/sca/bindings/binding.axis2/src/test/resources/wsdl/hello_world_doc_lit.wsdl

Added: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncTargetInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncTargetInvoker.java?view=auto&rev=443381
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncTargetInvoker.java (added)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncTargetInvoker.java Thu Sep 14 08:08:05 2006
@@ -0,0 +1,131 @@
+/**
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed 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.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.xml.namespace.QName;
+
+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.binding.axis2.util.SDODataBinding;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+public class Axis2AsyncTargetInvoker extends Axis2TargetInvoker {
+
+    protected static final Message RESPONSE = new ImmutableMessage();
+
+    private InboundWire wire;
+    private Object messageId;
+    private Axis2ReferenceCallbackTargetInvoker callbackInvoker;
+
+    public Axis2AsyncTargetInvoker(ServiceClient serviceClient,
+            QName wsdlOperationName,
+            Options options,
+            SDODataBinding dataBinding,
+            SOAPFactory soapFactory,
+            InboundWire wire) {
+        super(serviceClient, wsdlOperationName, options, dataBinding, soapFactory);
+        this.wire = wire;
+    }
+
+    public Object invokeTarget(final Object payload) throws InvocationTargetException {
+        try {
+            OperationClient operationClient = createOperationClientWithMessageContext(payload);
+            callbackInvoker.setCorrelationId(messageId);
+            Axis2ReferenceCallback callback = new Axis2ReferenceCallback(callbackInvoker, getDataBinding(), isPureOMelement());
+            operationClient.setCallback(callback);
+            
+            operationClient.execute(false);
+
+            return RESPONSE;
+        } catch (AxisFault e) {
+            throw new InvocationTargetException(e);
+        }
+    }
+    
+    public Message invoke(Message msg) throws InvocationRuntimeException {
+        try {
+            wire.addMapping(msg.getMessageId(), msg.getFromAddress());
+            messageId = msg.getMessageId();
+            Object resp = invokeTarget(msg.getBody());
+            msg.setBody(resp);
+        } catch (Throwable e) {
+            msg.setBody(e);
+        }
+        return msg;
+    }
+    
+    public void setCallbackTargetInvoker(Axis2ReferenceCallbackTargetInvoker callbackInvoker) {
+        this.callbackInvoker = callbackInvoker;
+    }
+
+    /**
+     * A dummy message passed back on an invocation
+     */
+    private static class ImmutableMessage implements Message {
+
+        public Object getBody() {
+            return null;
+        }
+
+        public void setBody(Object body) {
+            throw new UnsupportedOperationException();
+        }
+
+        public void setTargetInvoker(TargetInvoker invoker) {
+            throw new UnsupportedOperationException();
+        }
+
+        public TargetInvoker getTargetInvoker() {
+            return null;
+        }
+
+        public Message getRelatedCallbackMessage() {
+            return null;
+        }
+
+        public Object getFromAddress() {
+            return null;
+        }
+
+        public void setFromAddress(Object fromAddress) {
+            throw new UnsupportedOperationException();
+        }
+
+        public Object getMessageId() {
+            return null;
+        }
+
+        public void setMessageId(Object messageId) {
+            throw new UnsupportedOperationException();
+        }
+
+        public Object getCorrelationId() {
+            return null;
+        }
+
+        public void setCorrelationId(Object correlationId) {
+            throw new UnsupportedOperationException();
+        }
+    }
+}

Propchange: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncTargetInvoker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncTargetInvoker.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java?view=diff&rev=443381&r1=443380&r2=443381
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java Thu Sep 14 08:08:05 2006
@@ -26,6 +26,7 @@
 import org.apache.tuscany.spi.component.CompositeComponent;
 import org.apache.tuscany.spi.component.Reference;
 import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.WorkContext;
 import org.apache.tuscany.spi.deployer.DeploymentContext;
 import org.apache.tuscany.spi.extension.BindingBuilderExtension;
 import org.apache.tuscany.spi.host.ServletHost;
@@ -44,6 +45,8 @@
     private ServletHost servletHost;
 
     private ConfigurationContext configContext;
+    
+    private WorkContext workContext;
 
     public Axis2BindingBuilder() {
         initAxis();
@@ -54,6 +57,11 @@
         this.servletHost = servletHost;
     }
 
+    @Autowire
+    public void setWorkContext(WorkContext workContext) {
+        this.workContext = workContext;
+    }
+
     @SuppressWarnings("unchecked")
     public Service build(CompositeComponent parent, BoundServiceDefinition<WebServiceBinding> serviceDefinition, DeploymentContext deploymentContext) {
 
@@ -62,7 +70,15 @@
         TypeHelper typeHelper = (TypeHelper) deploymentContext.getExtension(TypeHelper.class.getName());
         if(typeHelper==null) typeHelper = TypeHelper.INSTANCE;
 
-        return new Axis2Service(serviceDefinition.getName(), interfaze, parent, wireService, wsBinding, servletHost, configContext, typeHelper);
+        return new Axis2Service(serviceDefinition.getName(),
+                interfaze,
+                parent,
+                wireService,
+                wsBinding,
+                servletHost,
+                configContext,
+                typeHelper,
+                workContext);
     }
 
     @SuppressWarnings("unchecked")
@@ -73,7 +89,13 @@
         TypeHelper typeHelper = (TypeHelper) deploymentContext.getExtension(TypeHelper.class.getName());
         if(typeHelper==null) typeHelper = TypeHelper.INSTANCE;
 
-        return new Axis2Reference(boundReferenceDefinition.getName(), parent, wireService, wsBinding, boundReferenceDefinition.getServiceContract(), typeHelper);
+        return new Axis2Reference(boundReferenceDefinition.getName(),
+                parent,
+                wireService,
+                wsBinding,
+                boundReferenceDefinition.getServiceContract(),
+                typeHelper,
+                workContext);
     }
 
     protected Class<WebServiceBinding> getBindingType() {

Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Reference.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Reference.java?view=diff&rev=443381&r1=443380&r2=443381
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Reference.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Reference.java Thu Sep 14 08:08:05 2006
@@ -19,14 +19,17 @@
 package org.apache.tuscany.binding.axis2;
 
 
+import java.lang.reflect.Method;
 import java.util.List;
 import javax.wsdl.Definition;
 import javax.xml.namespace.QName;
 
 import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.WorkContext;
 import org.apache.tuscany.spi.extension.ReferenceExtension;
 import org.apache.tuscany.spi.model.Operation;
 import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.OutboundWire;
 import org.apache.tuscany.spi.wire.TargetInvoker;
 import org.apache.tuscany.spi.wire.WireService;
 
@@ -54,6 +57,7 @@
     private WebServicePortMetaData wsPortMetaData;
     private ServiceClient serviceClient;
     private TypeHelper typeHelper;
+    private WorkContext workContext;
 
     @SuppressWarnings("unchecked")
     public Axis2Reference(String theName,
@@ -61,7 +65,8 @@
                           WireService wireService,
                           WebServiceBinding wsBinding,
                           ServiceContract contract,
-                          TypeHelper typeHelper) {
+                          TypeHelper typeHelper,
+                          WorkContext workContext) {
         super(theName, (Class<T>) contract.getInterfaceClass(), parent, wireService);
         try {
             Definition wsdlDefinition = wsBinding.getWSDLDefinition();
@@ -69,6 +74,7 @@
                 new WebServicePortMetaData(wsdlDefinition, wsBinding.getWSDLPort(), wsBinding.getURI(), false);
             serviceClient = createServiceClient(wsdlDefinition, wsPortMetaData);
             this.typeHelper = typeHelper;
+            this.workContext = workContext;
         } catch (AxisFault e) {
             e.printStackTrace();
             throw new RuntimeException(e);
@@ -79,7 +85,7 @@
         Axis2TargetInvoker invoker;
         try {
             //FIXME: SDODataBinding needs to pass in TypeHelper and classLoader as parameters.
-            invoker = createOperationInvoker(serviceClient, operation, typeHelper, wsPortMetaData);
+            invoker = createOperationInvoker(serviceClient, operation, typeHelper, wsPortMetaData, false);
         } catch (AxisFault e) {
             e.printStackTrace();
             throw new RuntimeException(e);
@@ -87,6 +93,34 @@
         return invoker;
     }
 
+    public TargetInvoker createAsyncTargetInvoker(OutboundWire wire, Operation operation) {
+        Axis2AsyncTargetInvoker invoker;
+        try {
+            //FIXME: SDODataBinding needs to pass in TypeHelper and classLoader as parameters.
+            invoker =
+                (Axis2AsyncTargetInvoker)createOperationInvoker(serviceClient, operation, typeHelper, wsPortMetaData, true);
+            //FIXME: This makes the (BIG) assumption that there is only one callback method
+            // Relaxing this assumption, however, does not seem to be trivial, it may depend on knowledge
+            // of what actual callback method was invoked by the service at the other end
+            Method callbackMethod = findCallbackMethod();
+            Axis2ReferenceCallbackTargetInvoker callbackInvoker =
+                new Axis2ReferenceCallbackTargetInvoker(callbackMethod,
+                        inboundWire.getServiceContract(),
+                        inboundWire,
+                        wireService,
+                        workContext);
+            invoker.setCallbackTargetInvoker(callbackInvoker);
+        } catch (AxisFault e) {
+            e.printStackTrace();
+            throw new RuntimeException(e);
+        }
+        return invoker;
+    }
+    
+    private Method findCallbackMethod() {
+        return inboundWire.getServiceContract().getCallbackClass().getDeclaredMethods()[0];
+    }
+
     /**
      * Create an Axis2 ServiceClient
      */
@@ -108,7 +142,8 @@
     private Axis2TargetInvoker createOperationInvoker(ServiceClient serviceClient,
                                                       Operation m,
                                                       TypeHelper typeHelper,
-                                                      WebServicePortMetaData wsPortMetaData)
+                                                      WebServicePortMetaData wsPortMetaData,
+                                                      boolean isAsync)
         throws AxisFault {
         SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
         String portTypeNS = wsPortMetaData.getPortTypeName().getNamespaceURI();
@@ -135,7 +170,14 @@
 
         QName wsdlOperationQName = new QName(portTypeNS, wsdlOperationName);
 
-        return new Axis2TargetInvoker(serviceClient, wsdlOperationQName, options, dataBinding, soapFactory);
+        Axis2TargetInvoker invoker;
+        if (isAsync) {
+            invoker = new Axis2AsyncTargetInvoker(serviceClient, wsdlOperationQName, options, dataBinding, soapFactory, inboundWire);
+        } else {
+            invoker = new Axis2TargetInvoker(serviceClient, wsdlOperationQName, options, dataBinding, soapFactory);
+        }
+        
+        return invoker;
     }
 
 }

Added: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallback.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallback.java?view=auto&rev=443381
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallback.java (added)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallback.java Thu Sep 14 08:08:05 2006
@@ -0,0 +1,74 @@
+/**
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed 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.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.client.async.AsyncResult;
+import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.context.MessageContext;
+import org.apache.tuscany.binding.axis2.util.SDODataBinding;
+
+public class Axis2ReferenceCallback extends Callback {
+    
+    private Axis2ReferenceCallbackTargetInvoker targetInvoker;
+    private SDODataBinding dataBinding;
+    private boolean pureOMelement;
+    
+    public Axis2ReferenceCallback(Axis2ReferenceCallbackTargetInvoker targetInvoker,
+            SDODataBinding dataBinding,
+            boolean pureOMelement) {
+        this.targetInvoker = targetInvoker;
+        this.dataBinding = dataBinding;
+        this.pureOMelement = pureOMelement;
+    }
+
+    public void onComplete(AsyncResult result) {
+        MessageContext responseMC = result.getResponseMessageContext();
+        OMElement responseOM = responseMC.getEnvelope().getBody().getFirstElement();
+
+        Object[] os = null;
+        if (responseOM != null) {
+            os = dataBinding.fromOMElement(responseOM);
+        }
+
+        Object response;
+        if (pureOMelement) {
+            response = responseOM;
+        } else {
+            if (os == null || os.length < 1) {
+                response = null;
+            } else {
+                response = os[0];
+            }
+        }
+
+        try {
+            targetInvoker.invokeTarget(response);
+        } catch(InvocationTargetException e) {
+            // FIXME what is the appropriate exception here?
+            throw new RuntimeException(e);
+        }
+    }
+
+    public void setComplete(boolean complete) {
+        super.setComplete(complete);
+    }
+
+    public void onError(Exception e) {
+    }
+}

Propchange: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallback.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallback.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java?view=auto&rev=443381
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java (added)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java Thu Sep 14 08:08:05 2006
@@ -0,0 +1,71 @@
+/**
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed 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.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.core.wire.PojoTargetInvoker;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.WireService;
+
+public class Axis2ReferenceCallbackTargetInvoker extends PojoTargetInvoker {
+    
+    private ServiceContract<?> contract;
+    private InboundWire inboundWire;
+    private WireService wireService;
+    private WorkContext workContext;
+    private Object correlationId;
+    
+    public Axis2ReferenceCallbackTargetInvoker(Method operation,
+            ServiceContract contract,
+            InboundWire inboundWire,
+            WireService wireService,
+            WorkContext workContext) {
+        super(operation);
+        this.contract = contract;
+        this.inboundWire = inboundWire;
+        this.wireService = wireService;
+        this.workContext = workContext;
+    }
+
+    public Object invokeTarget(final Object payload) throws InvocationTargetException {
+        workContext.setCurrentMessageId(null);
+        workContext.setCurrentCorrelationId(correlationId);
+        return super.invokeTarget(payload);
+    }
+    
+    public Axis2ReferenceCallbackTargetInvoker clone() throws CloneNotSupportedException {
+        Axis2ReferenceCallbackTargetInvoker invoker = (Axis2ReferenceCallbackTargetInvoker) super.clone();
+        invoker.contract = this.contract;
+        invoker.inboundWire = this.inboundWire;
+        invoker.wireService = this.wireService;
+        invoker.workContext = this.workContext;
+        invoker.correlationId = this.correlationId;
+        return invoker;
+    }
+    
+    public void setCorrelationId(Object correlationId) {
+        this.correlationId = correlationId;
+    }
+
+    protected Object getInstance() throws TargetException {
+        return wireService.createCallbackProxy(contract, inboundWire);
+    }
+}

Propchange: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java?view=diff&rev=443381&r1=443380&r2=443381
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java Thu Sep 14 08:08:05 2006
@@ -19,19 +19,25 @@
 package org.apache.tuscany.binding.axis2;
 
 import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
 
 import javax.wsdl.Definition;
 import javax.wsdl.Operation;
+import javax.wsdl.Part;
 import javax.wsdl.PortType;
 import javax.xml.namespace.QName;
 
+import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
 import org.apache.axis2.description.WSDLToAxisServiceBuilder;
+import org.apache.axis2.engine.MessageReceiver;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.axis2.wsdl.WSDLConstants.WSDL20_2004Constants;
 import org.apache.tuscany.binding.axis2.util.SDODataBinding;
@@ -39,8 +45,12 @@
 import org.apache.tuscany.binding.axis2.util.WebServicePortMetaData;
 import org.apache.tuscany.spi.builder.BuilderConfigException;
 import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.WorkContext;
 import org.apache.tuscany.spi.extension.ServiceExtension;
 import org.apache.tuscany.spi.host.ServletHost;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.MessageId;
+import org.apache.tuscany.spi.wire.TargetInvoker;
 import org.apache.tuscany.spi.wire.WireService;
 import org.osoa.sca.annotations.Destroy;
 
@@ -61,8 +71,12 @@
     
     private TypeHelper typeHelper;
 
+    private WorkContext workContext;
+    
+    private Map<MessageId, InvocationContext> invCtxMap = new HashMap<MessageId, InvocationContext>();
+
     public Axis2Service(String theName, Class<?> interfaze, CompositeComponent parent, WireService wireService, WebServiceBinding binding,
-            ServletHost servletHost, ConfigurationContext configContext, TypeHelper typeHelper) {
+            ServletHost servletHost, ConfigurationContext configContext, TypeHelper typeHelper, WorkContext workContext) {
 
         super(theName, interfaze, parent, wireService);
 
@@ -70,6 +84,7 @@
         this.servletHost = servletHost;
         this.configContext = configContext;
         this.typeHelper = typeHelper;
+        this.workContext = workContext;
     }
 
     public void start() {
@@ -126,14 +141,22 @@
             Object entryPointProxy = this.getServiceInstance();
 
             WebServiceOperationMetaData omd = wsdlPortInfo.getOperationMetaData(operationName);
-            QName responseQN = omd.getOutputPart(0).getElementName();
+            QName responseQN = null;
+            Part outputPart = omd.getOutputPart(0);
+            if (outputPart != null) {
+                responseQN = outputPart.getElementName();
+            }
 
             Method operationMethod = getMethod(serviceInterface, operationName);
             // outElementQName is not needed when calling fromOMElement method, and we can not get elementQName for
             // oneway operation.
             SDODataBinding dataBinding = new SDODataBinding(typeHelper, omd.isDocLitWrapped(), responseQN);
-            Axis2ServiceInOutSyncMessageReceiver msgrec = new Axis2ServiceInOutSyncMessageReceiver(entryPointProxy, operationMethod,
-                    dataBinding);
+            MessageReceiver msgrec = null;
+            if (inboundWire.getCallbackReferenceName() != null) {
+                msgrec = new Axis2ServiceInOutAsyncMessageReceiver(entryPointProxy, operationMethod, dataBinding, this, workContext);
+            } else {
+                msgrec = new Axis2ServiceInOutSyncMessageReceiver(entryPointProxy, operationMethod, dataBinding);
+            }
 
             AxisOperation axisOp = axisService.getOperation(operationQN);
             axisOp.setMessageExchangePattern(WSDL20_2004Constants.MEP_URI_IN_OUT);
@@ -167,4 +190,34 @@
         return typeHelper;
     }
 
+    public TargetInvoker createCallbackTargetInvoker(ServiceContract contract, org.apache.tuscany.spi.model.Operation operation) {
+
+        return new Axis2ServiceCallbackTargetInvoker(workContext, this);
+    }
+    
+    public void addMapping(MessageId msgId, InvocationContext invCtx) {
+        this.invCtxMap.put(msgId, invCtx);
+    }
+    
+    public InvocationContext retrieveMapping(MessageId msgId) {
+        return this.invCtxMap.get(msgId);
+    }
+    
+    public void removeMapping(MessageId msgId) {
+        this.invCtxMap.remove(msgId);
+    }
+    
+    protected class InvocationContext {
+        public MessageContext inMessageContext;
+        public Method operationMethod;
+        public SDODataBinding dataBinding;
+        public SOAPFactory soapFactory;
+        
+        public InvocationContext(MessageContext messageCtx, Method operationMethod, SDODataBinding dataBinding, SOAPFactory soapFactory) {
+            this.inMessageContext = messageCtx;
+            this.operationMethod = operationMethod;
+            this.dataBinding = dataBinding;
+            this.soapFactory = soapFactory;
+        }
+    }
 }

Added: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java?view=auto&rev=443381
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java (added)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java Thu Sep 14 08:08:05 2006
@@ -0,0 +1,111 @@
+/**
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed 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.
+ */
+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;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.util.Utils;
+import org.apache.tuscany.binding.axis2.Axis2Service.InvocationContext;
+import org.apache.tuscany.binding.axis2.Axis2AsyncTargetInvoker;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageId;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+public class Axis2ServiceCallbackTargetInvoker implements TargetInvoker {
+    
+    private WorkContext workContext;
+    private Axis2Service service;
+    
+    public Axis2ServiceCallbackTargetInvoker(WorkContext workContext, Axis2Service service) {
+        this.workContext = workContext;
+        this.service = service;
+    }
+
+    public Object invokeTarget(final Object payload) throws InvocationTargetException {
+        try {
+            // Use correlation id in context as index to retrieve inv context
+            MessageId correlationId = (MessageId)workContext.getCurrentCorrelationId();
+            InvocationContext invCtx = service.retrieveMapping(correlationId);
+            
+            MessageContext outMC = Utils.createOutMessageContext(invCtx.inMessageContext);
+            outMC.getOperationContext().addMessageContext(invCtx.inMessageContext);  // REVIEW was adding newmsgCtx !
+
+            OMElement responseOM = null;
+            Class<?>[] parameterTypes = invCtx.operationMethod.getParameterTypes();
+            // Try to guess if it's passing OMElements
+            if(parameterTypes.length>0 && OMElement.class.isAssignableFrom(parameterTypes[0])) {    
+                responseOM = (OMElement) payload;
+            } else {
+                // Assumming it's SDO then
+                responseOM = invCtx.dataBinding.toOMElement(new Object[] {payload} );
+            }
+
+            SOAPEnvelope soapEnvelope = invCtx.soapFactory.getDefaultEnvelope();
+            soapEnvelope.getBody().addChild(responseOM);
+            outMC.setEnvelope(soapEnvelope);
+            outMC.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN, Constants.VALUE_TRUE);
+
+            AxisEngine engine =
+                new AxisEngine(invCtx.inMessageContext.getOperationContext().getServiceContext().getConfigurationContext());
+            engine.send(outMC);
+            
+            service.removeMapping(correlationId);
+        } catch(AxisFault e) {
+            throw new InvocationTargetException(e);
+        }
+        
+        return Axis2AsyncTargetInvoker.RESPONSE;
+    }
+
+    public Message invoke(Message msg) throws InvocationRuntimeException {
+        try {
+            Object resp = invokeTarget(msg.getBody());
+            msg.setBody(resp);
+        } catch (Throwable e) {
+            msg.setBody(e);
+        }
+        return msg;
+    }
+
+    public Axis2ServiceCallbackTargetInvoker clone() throws CloneNotSupportedException {
+        try {
+            return (Axis2ServiceCallbackTargetInvoker) 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;
+    }
+}

Propchange: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java?view=auto&rev=443381
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java (added)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java Thu Sep 14 08:08:05 2006
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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.    
+ */
+package org.apache.tuscany.binding.axis2;
+
+import java.lang.reflect.Method;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+//import org.apache.axis2.receivers.AbstractInOutAsyncMessageReceiver;
+import org.apache.axis2.receivers.AbstractMessageReceiver;
+//import org.apache.commons.logging.Log;
+//import org.apache.commons.logging.LogFactory;
+import org.apache.tuscany.binding.axis2.Axis2Service.InvocationContext;
+import org.apache.tuscany.binding.axis2.util.SDODataBinding;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.MessageId;
+
+public class Axis2ServiceInOutAsyncMessageReceiver extends AbstractMessageReceiver {
+    // private static final Log log = LogFactory.getLog(AbstractInOutAsyncMessageReceiver.class);
+
+    protected Method operationMethod;
+    protected SDODataBinding dataBinding;
+    private Object entryPointProxy;
+    private WorkContext workContext;
+    private Axis2Service service;
+
+    public Axis2ServiceInOutAsyncMessageReceiver(Object entryPointProxy,
+                                                        Method operationMethod,
+                                                        SDODataBinding dataBinding,
+                                                        Axis2Service service,
+                                                        WorkContext workContext) {
+        this.entryPointProxy = entryPointProxy;
+        this.operationMethod = operationMethod;
+        this.dataBinding = dataBinding;
+        this.workContext = workContext;
+        this.service = service;
+    }
+
+    public final void receive(final MessageContext messageCtx) {
+        
+        Runnable theadedTask = new Runnable() {
+            public void run() {
+                try {
+                    // Create a new message id and hand it to JDKInboundInvocationHandler
+                    // via work context
+                    MessageId messageId = new MessageId();
+                    workContext.setCurrentMessageId(messageId);
+                    // Now use message id as index to context to be used by callback target invoker
+                    InvocationContext invCtx =
+                        service.new InvocationContext(messageCtx, operationMethod, dataBinding, getSOAPFactory(messageCtx));
+                    service.addMapping(messageId, invCtx);
+                    
+                    invokeBusinessLogic(messageCtx);
+                } catch (AxisFault e) {
+                    // log.error(e);
+                }
+            }
+        };
+        messageCtx.getConfigurationContext().getThreadPool().execute(theadedTask);
+    }
+
+    public void invokeBusinessLogic(MessageContext inMC) throws AxisFault {
+        
+        try {
+
+            OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
+            Class<?>[] parameterTypes = operationMethod.getParameterTypes();
+            // Try to guess if it's passing OMElements
+            if(parameterTypes.length>0 && OMElement.class.isAssignableFrom(parameterTypes[0])) {    
+                operationMethod.invoke(entryPointProxy, requestOM);
+            } else {
+                // Assumming it's SDO then
+                Object[] args = dataBinding.fromOMElement(requestOM);
+                operationMethod.invoke(entryPointProxy, args);
+            }
+        } catch (InvocationRuntimeException e) {
+            Throwable t = e.getCause();
+            if (t instanceof Exception) {
+                throw AxisFault.makeFault((Exception) t);
+            }
+            throw e;
+        } catch (Exception e) {
+            throw AxisFault.makeFault(e);
+        }
+
+    }
+}

Propchange: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2TargetInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2TargetInvoker.java?view=diff&rev=443381&r1=443380&r2=443381
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2TargetInvoker.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2TargetInvoker.java Thu Sep 14 08:08:05 2006
@@ -50,6 +50,8 @@
     private SOAPFactory soapFactory;
 
     private ServiceClient serviceClient;
+    
+    private boolean pureOMelement;
 
     public Axis2TargetInvoker(ServiceClient serviceClient, QName wsdlOperationName, Options options, SDODataBinding dataBinding, SOAPFactory soapFactory) {
         this.wsdlOperationName = wsdlOperationName;
@@ -68,37 +70,10 @@
      */
     public Object invokeTarget(final Object payload) throws InvocationTargetException {
         try {
-            // Axis2 operationClients can not be shared so create a new one for each request
-            OperationClient operationClient = serviceClient.createClient(wsdlOperationName);
-            operationClient.setOptions(options);
-            boolean pureOMelement = false;
-
-            SOAPEnvelope env = soapFactory.getDefaultEnvelope();
-
-            if (payload != null && payload.getClass().isArray() && ((Object[]) payload).length > 0) {
-                // OMElement requestOM = dataBinding.toOMElement((Object[]) payload);
-                // env.getBody().addChild(requestOM);
-                // TODO HACK
-                if (((Object[]) payload)[0] instanceof OMElement) {
-                    SOAPBody body = env.getBody();
-                    for (Object bc : ((Object[]) payload)) {
-                        if (bc instanceof OMElement) {
-                            body.addChild((OMElement) bc);
-                        } else {
-                            throw new IllegalArgumentException("Can't handle mixed payloads betweem OMElements and other types.");
-                        }
-                    }
-                } else {
-                    OMElement requestOM = dataBinding.toOMElement((Object[]) payload);
-                    env.getBody().addChild(requestOM);
-                }
-
-            }
-
-            MessageContext requestMC = new MessageContext();
-            requestMC.setEnvelope(env);
+            pureOMelement = false;
+            
+            OperationClient operationClient = createOperationClientWithMessageContext(payload);
 
-            operationClient.addMessageContext(requestMC);
             // Class loader switching is taken out 8/15/06 .. we shouldn't require this any more
             // ClassLoader tccl = Thread.currentThread().getContextClassLoader();
             // ClassLoader scl = this.getClass().getClassLoader();
@@ -173,4 +148,47 @@
         return false;
     }
 
+    protected OperationClient createOperationClientWithMessageContext(final Object payload) throws AxisFault {
+        
+        // Axis2 operationClients can not be shared so create a new one for each request
+        OperationClient operationClient = serviceClient.createClient(wsdlOperationName);
+        operationClient.setOptions(options);
+
+        SOAPEnvelope env = soapFactory.getDefaultEnvelope();
+
+        if (payload != null && payload.getClass().isArray() && ((Object[]) payload).length > 0) {
+            // OMElement requestOM = dataBinding.toOMElement((Object[]) payload);
+            // env.getBody().addChild(requestOM);
+            // TODO HACK
+            if (((Object[]) payload)[0] instanceof OMElement) {
+                SOAPBody body = env.getBody();
+                for (Object bc : ((Object[]) payload)) {
+                    if (bc instanceof OMElement) {
+                        body.addChild((OMElement) bc);
+                    } else {
+                        throw new IllegalArgumentException("Can't handle mixed payloads betweem OMElements and other types.");
+                    }
+                }
+            } else {
+                OMElement requestOM = dataBinding.toOMElement((Object[]) payload);
+                env.getBody().addChild(requestOM);
+            }
+
+        }
+
+        MessageContext requestMC = new MessageContext();
+        requestMC.setEnvelope(env);
+
+        operationClient.addMessageContext(requestMC);
+        
+        return operationClient;
+    }
+    
+    protected SDODataBinding getDataBinding() {
+        return dataBinding;
+    }
+    
+    protected boolean isPureOMelement() {
+        return pureOMelement;
+    }
 }

Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ReferenceTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ReferenceTestCase.java?view=diff&rev=443381&r1=443380&r2=443381
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ReferenceTestCase.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ReferenceTestCase.java Thu Sep 14 08:08:05 2006
@@ -30,13 +30,17 @@
 import org.xml.sax.InputSource;
 
 import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
 import org.apache.tuscany.spi.model.Operation;
 import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundWire;
 import org.apache.tuscany.spi.wire.TargetInvoker;
 import org.apache.tuscany.spi.wire.WireService;
 
 import commonj.sdo.helper.TypeHelper;
 import junit.framework.TestCase;
+
 import org.apache.tuscany.idl.wsdl.WSDLServiceContract;
 import org.easymock.classextension.EasyMock;
 
@@ -49,6 +53,21 @@
         assertNotNull(targetInvoker);
     }
 
+    public void testAsyncTargetInvoker() throws Exception {
+        Axis2Reference axis2Reference = createAxis2Reference("testWebAppName", "testServiceName");
+        //Create a mocked InboundWire, make the call of ServiceExtension.getInterface() returns a Class
+        InboundWire inboundWire = EasyMock.createNiceMock(InboundWire.class);
+        JavaServiceContract contract = new JavaServiceContract(Greeter.class);
+        contract.setCallbackClass(GreetingCallback.class);
+        EasyMock.expect(inboundWire.getServiceContract()).andReturn(contract).anyTimes();
+        EasyMock.replay(inboundWire);
+
+        axis2Reference.setInboundWire(inboundWire);
+        Operation operation = new Operation<Type>("sayHi", null, null, null, true, null);
+        TargetInvoker asyncTargetInvoker = axis2Reference.createAsyncTargetInvoker(null, operation);
+        assertNotNull(asyncTargetInvoker);
+    }
+
     private Axis2Reference createAxis2Reference(String webAppName, String serviceName) throws Exception {
         //Create WebServiceBinding
         String wsdlLocation = "/wsdl/hello_world_doc_lit.wsdl";
@@ -72,6 +91,14 @@
         // TODO figure out what to do with the service contract
         ServiceContract contract = new WSDLServiceContract();
         contract.setInterfaceClass(Greeter.class);
-        return new Axis2Reference(serviceName, parent, wireService, wsBinding, contract, TypeHelper.INSTANCE);
+        WorkContext workContext = EasyMock.createNiceMock(WorkContext.class);
+        EasyMock.replay(workContext);
+        return new Axis2Reference(serviceName,
+                parent,
+                wireService,
+                wsBinding,
+                contract,
+                TypeHelper.INSTANCE,
+                workContext);
     }
 }

Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ServiceTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ServiceTestCase.java?view=diff&rev=443381&r1=443380&r2=443381
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ServiceTestCase.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ServiceTestCase.java Thu Sep 14 08:08:05 2006
@@ -31,6 +31,9 @@
 
 import org.xml.sax.InputSource;
 
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.tuscany.binding.axis2.util.TuscanyAxisConfigurator;
+import org.apache.tuscany.spi.component.WorkContext;
 import org.apache.tuscany.spi.host.ServletHost;
 import org.apache.tuscany.spi.idl.java.JavaServiceContract;
 import org.apache.tuscany.spi.wire.InboundWire;
@@ -43,11 +46,11 @@
 public class Axis2ServiceTestCase extends TestCase {
 
     public void testInvokeService() throws Exception {
-        if (true) return;
         TestServletHost tomcatHost = new TestServletHost();
-        Axis2Service axis2Service = createAxis2Service("testWebAppName", "testServiceName", tomcatHost);
+        Axis2Service axis2Service = createAxis2Service("testWebAppName", "testServiceName", tomcatHost, false);
         axis2Service.start();
 
+        if (true) return;
         Servlet servlet = tomcatHost.getMapping("testWebAppName/services/testServiceName");
         assertNotNull(servlet);
 
@@ -56,7 +59,14 @@
 
     }
 
-    private Axis2Service createAxis2Service(String webAppName, String serviceName, ServletHost tomcatHost)
+    public void testAsyncMessageReceiver() throws Exception {
+
+        TestServletHost tomcatHost = new TestServletHost();
+        Axis2Service axis2Service = createAxis2Service("testWebAppName", "testServiceName", tomcatHost, true);
+        axis2Service.start();
+    }
+
+    private Axis2Service createAxis2Service(String webAppName, String serviceName, ServletHost tomcatHost, boolean callback)
         throws Exception {
         //Create WebServiceBinding
         String wsdlLocation = "/wsdl/hello_world_doc_lit.wsdl";
@@ -84,8 +94,15 @@
         InboundWire inboundWire = EasyMock.createNiceMock(InboundWire.class);
         JavaServiceContract contract = new JavaServiceContract(Greeter.class);
         EasyMock.expect(inboundWire.getServiceContract()).andReturn(contract).anyTimes();
+        if (callback) {
+            EasyMock.expect(inboundWire.getCallbackReferenceName()).andReturn("").anyTimes();
+        }
         EasyMock.replay(inboundWire);
 
+        TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator();
+        ConfigurationContext configurationContext = tuscanyAxisConfigurator.getConfigurationContext();
+        WorkContext workContext = EasyMock.createNiceMock(WorkContext.class);
+        EasyMock.replay(workContext);
         Axis2Service axis2Service =
             new Axis2Service(serviceName,
                 Greeter.class,
@@ -93,8 +110,9 @@
                 wireService,
                 wsBinding,
                 tomcatHost,
-                null,
-                TypeHelper.INSTANCE);
+                configurationContext,
+                TypeHelper.INSTANCE,
+                workContext);
         axis2Service.setInboundWire(inboundWire);
 
         return axis2Service;

Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Greeter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Greeter.java?view=diff&rev=443381&r1=443380&r2=443381
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Greeter.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Greeter.java Thu Sep 14 08:08:05 2006
@@ -26,4 +26,6 @@
 
     void greetMeOneWay(String requestType);
 
+    void greetMeWithCallback(String requestType);
+
 }

Added: incubator/tuscany/java/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/GreetingCallback.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/GreetingCallback.java?view=auto&rev=443381
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/GreetingCallback.java (added)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/GreetingCallback.java Thu Sep 14 08:08:05 2006
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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.    
+ */
+package org.apache.tuscany.binding.axis2;
+
+public interface GreetingCallback {
+
+    void greetMeCallback(String greetMeResponse);
+}

Propchange: incubator/tuscany/java/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/GreetingCallback.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/GreetingCallback.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/test/resources/wsdl/hello_world_doc_lit.wsdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.axis2/src/test/resources/wsdl/hello_world_doc_lit.wsdl?view=diff&rev=443381&r1=443380&r2=443381
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/test/resources/wsdl/hello_world_doc_lit.wsdl (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/test/resources/wsdl/hello_world_doc_lit.wsdl Thu Sep 14 08:08:05 2006
@@ -95,6 +95,11 @@
             <wsdl:input message="tns:greetMeOneWayRequest" name="greetMeOneWayRequest"/>
         </wsdl:operation>
 
+        <wsdl:operation name="greetMeWithCallback">
+            <wsdl:input message="tns:greetMeRequest" name="greetMeRequest"/>
+            <wsdl:output message="tns:greetMeResponse" name="greetMeResponse"/>
+        </wsdl:operation>
+        
     </wsdl:portType>
     <wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter">
         <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
@@ -126,6 +131,16 @@
             </wsdl:input>
         </wsdl:operation>
        
+        <wsdl:operation name="greetMeWithCallback">
+            <soap:operation soapAction="" style="document"/>
+            <wsdl:input name="greetMeRequest">
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output name="greetMeResponse">
+                <soap:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+        
     </wsdl:binding>
     <wsdl:service name="SOAPService">
         <wsdl:port binding="tns:Greeter_SOAPBinding" name="SoapPort">



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