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 2007/05/08 22:54:00 UTC

svn commit: r536323 - /incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/

Author: antelder
Date: Tue May  8 13:53:59 2007
New Revision: 536323

URL: http://svn.apache.org/viewvc?view=rev&rev=536323
Log:
TUSCANY-1253, apply patch from Simon Nash converting the Axis2 binding to the latest SPIs

Added:
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncBindingInvoker.java   (with props)
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingFactory.java   (with props)
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingInvoker.java   (with props)
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingProviderFactory.java   (with props)
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2OneWayBindingInvoker.java   (with props)
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBindingProvider.java   (with props)
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceBindingProvider.java   (with props)
Removed:
    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/Axis2BindingBuilder.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/Axis2ServiceBinding.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/Axis2CallbackInvocationHandler.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ModuleActivator.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallback.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInMessageReceiver.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.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/Axis2ServiceServlet.java

Added: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncBindingInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncBindingInvoker.java?view=auto&rev=536323
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncBindingInvoker.java (added)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncBindingInvoker.java Tue May  8 13:53:59 2007
@@ -0,0 +1,79 @@
+/*
+ * 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.InvocationTargetException;
+import java.net.URI;
+import java.util.LinkedList;
+import java.util.concurrent.CountDownLatch;
+
+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.invocation.Message;
+import org.apache.tuscany.spi.component.WorkContext;
+
+public class Axis2AsyncBindingInvoker extends Axis2BindingInvoker {
+
+    private Axis2ReferenceCallbackTargetInvoker callbackInvoker;
+
+    public Axis2AsyncBindingInvoker(ServiceClient serviceClient,
+                                    QName wsdlOperationName,
+                                    Options options,
+                                    SOAPFactory soapFactory) {
+        super(serviceClient, wsdlOperationName, options, soapFactory);
+    }
+
+    private Object invokeTarget(final Object payload, LinkedList<URI> callbackRoutingChain)
+        throws InvocationTargetException {
+        try {
+            Object[] args = (Object[]) payload;
+            OperationClient operationClient = createOperationClient(args, null);
+            callbackInvoker.setCallbackRoutingChain(callbackRoutingChain);
+            Axis2ReferenceCallback callback = new Axis2ReferenceCallback(callbackInvoker);
+            operationClient.setCallback(callback);
+
+            // FIXME Synchronize with callback thread to get return value
+            CountDownLatch doneSignal = new CountDownLatch(1);
+            callbackInvoker.setSignal(doneSignal);
+
+            operationClient.execute(false);
+
+            try {
+                doneSignal.await();
+            } catch(InterruptedException e) {
+                e.printStackTrace();
+            }
+
+            // FIXME returning value from callback thread
+            Object response = callbackInvoker.getReturnPayload();
+            return response;
+        } catch (AxisFault e) {
+            throw new InvocationTargetException(e);
+        }
+    }
+
+    public void setCallbackTargetInvoker(Axis2ReferenceCallbackTargetInvoker callbackInvoker) {
+        this.callbackInvoker = callbackInvoker;
+    }
+}

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

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

Added: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingFactory.java?view=auto&rev=536323
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingFactory.java (added)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingFactory.java Tue May  8 13:53:59 2007
@@ -0,0 +1,40 @@
+/*
+ * 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 org.apache.tuscany.binding.ws.WebServiceBinding;
+import org.apache.tuscany.binding.ws.WebServiceBindingFactory;
+import org.apache.tuscany.http.ServletHost;
+
+/**
+ * A factory for the WSDL model.
+ */
+public class Axis2BindingFactory implements WebServiceBindingFactory {
+
+    private ServletHost servletHost;
+
+    public Axis2BindingFactory(ServletHost servletHost) {
+        this.servletHost = servletHost;
+    }
+
+    public WebServiceBinding createWebServiceBinding() {
+        return new Axis2BindingProviderFactory(servletHost);
+    }
+
+}

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

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

Added: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingInvoker.java?view=auto&rev=536323
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingInvoker.java (added)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingInvoker.java Tue May  8 13:53:59 2007
@@ -0,0 +1,152 @@
+/*
+ * 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.InvocationTargetException;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.OperationClient;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.tuscany.assembly.xml.Constants;
+import org.apache.tuscany.invocation.Invoker;
+import org.apache.tuscany.invocation.Message;
+import org.apache.tuscany.scope.Scope;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.axis2.transport.http.HTTPConstants;
+
+/**
+ * Axis2BindingInvoker uses an Axis2 OperationClient to invoke a remote web service
+ */
+public class Axis2BindingInvoker implements Invoker {
+
+    private ServiceClient serviceClient;
+    private QName wsdlOperationName;
+    private Options options;
+    private SOAPFactory soapFactory;
+
+    public static final QName CONVERSATION_ID_REFPARM_QN = new QName(Constants.SCA10_NS,"conversationID");
+    
+    public Axis2BindingInvoker(ServiceClient serviceClient, QName wsdlOperationName,
+                               Options options, SOAPFactory soapFactory) {
+        this.serviceClient = serviceClient;
+        this.wsdlOperationName = wsdlOperationName;
+        this.options = options;
+        this.soapFactory = soapFactory;
+    }
+
+    public Message invoke(Message msg) {
+        try {
+            Object messageId = msg.getMessageID();
+            WorkContext workContext = msg.getWorkContext();
+            if (messageId != null) {
+                workContext.setCorrelationId(messageId);
+            }
+            // getCallbackUris() has been removed from the Message interface 
+            // LinkedList<URI> callbackRoutingChain = msg.getCallbackUris();
+            // if (callbackRoutingChain != null) {
+            //     workContext.setCallbackUris(callbackRoutingChain);
+            // }
+            Object resp = invokeTarget(msg.getBody(), msg.getConversationSequence(), workContext);
+            msg.setBody(resp);
+        } catch (InvocationTargetException e) {
+            msg.setFaultBody(e.getCause());
+        } catch (Throwable e) {
+            msg.setFaultBody(e);
+        }
+        return msg;
+    }
+
+    protected Object invokeTarget(final Object payload, final short sequence, WorkContext workContext) throws InvocationTargetException {
+        try {
+
+            Object[] args = (Object[]) payload;
+            OperationClient operationClient = createOperationClient(args, workContext);
+
+            // ensure connections are tracked so that they can be closed by the reference binding
+            MessageContext requestMC = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+            requestMC.getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
+            
+            operationClient.execute(true);
+
+            MessageContext responseMC = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+            
+            operationClient.complete(requestMC);
+
+            return responseMC.getEnvelope().getBody().getFirstElement();
+
+        } catch (AxisFault e) {
+            throw new InvocationTargetException(e);
+        }
+    }
+
+    @SuppressWarnings("deprecation")
+    protected OperationClient createOperationClient(Object[] args, WorkContext workContext) throws AxisFault {
+        SOAPEnvelope env = soapFactory.getDefaultEnvelope();
+        if (args != null && args.length > 0) {
+            SOAPBody body = env.getBody();
+            for (Object bc : args) {
+                if (bc instanceof OMElement) {
+                    body.addChild((OMElement) bc);
+                } else {
+                    throw new IllegalArgumentException(
+                        "Can't handle mixed payloads betweem OMElements and other types.");
+                }
+            }
+        }
+        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){
+                EndpointReference fromEPR = new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL);
+                fromEPR.addReferenceParameter(CONVERSATION_ID_REFPARM_QN, conversationId);
+                options.setFrom(fromEPR);
+                requestMC.setFrom(fromEPR); //who knows why two ways ?
+            
+                //For now do this the brute force method. Need to figure out how to do axis addressing .. configure mar in flow.
+                SOAPEnvelope sev = requestMC.getEnvelope();
+                SOAPHeader sh = sev.getHeader();
+                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;
+    }
+
+}

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

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

Added: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingProviderFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingProviderFactory.java?view=auto&rev=536323
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingProviderFactory.java (added)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingProviderFactory.java Tue May  8 13:53:59 2007
@@ -0,0 +1,51 @@
+/*
+ * 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 org.apache.tuscany.binding.ws.impl.WebServiceBindingImpl;
+import org.apache.tuscany.core.RuntimeComponent;
+import org.apache.tuscany.core.RuntimeComponentReference;
+import org.apache.tuscany.core.RuntimeComponentService;
+import org.apache.tuscany.http.ServletHost;
+import org.apache.tuscany.provider.BindingProviderFactory;
+import org.apache.tuscany.provider.ReferenceBindingProvider;
+import org.apache.tuscany.provider.ServiceBindingProvider;
+
+/**
+ * Axis2BindingProviderFactory
+ *
+ * @version $Rev$ $Date$
+ */
+
+public class Axis2BindingProviderFactory extends WebServiceBindingImpl implements BindingProviderFactory {
+
+    private ServletHost servletHost;
+
+    public Axis2BindingProviderFactory(ServletHost servletHost) {
+        this.servletHost = servletHost;
+    }
+
+    public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component, RuntimeComponentReference reference) {
+        return new Axis2ReferenceBindingProvider(component, reference, this);
+    }
+
+    public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component, RuntimeComponentService service) {
+        return new Axis2ServiceBindingProvider(component, service, this, servletHost);
+    }
+}

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

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

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2CallbackInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2CallbackInvocationHandler.java?view=diff&rev=536323&r1=536322&r2=536323
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2CallbackInvocationHandler.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2CallbackInvocationHandler.java Tue May  8 13:53:59 2007
@@ -23,13 +23,13 @@
 
 import org.apache.tuscany.interfacedef.Operation;
 import org.apache.tuscany.invocation.AbstractInvocationHandler;
-import org.apache.tuscany.invocation.Wire;
+import org.apache.tuscany.core.RuntimeWire;
 
 public class Axis2CallbackInvocationHandler extends AbstractInvocationHandler {
 
-    private Wire wire;
+    private RuntimeWire wire;
 
-    public Axis2CallbackInvocationHandler(Wire wire) {
+    public Axis2CallbackInvocationHandler(RuntimeWire wire) {
         this.wire = wire;
     }
 

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ModuleActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ModuleActivator.java?view=diff&rev=536323&r1=536322&r2=536323
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ModuleActivator.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ModuleActivator.java Tue May  8 13:53:59 2007
@@ -23,52 +23,35 @@
 
 import org.apache.tuscany.assembly.AssemblyFactory;
 import org.apache.tuscany.assembly.DefaultAssemblyFactory;
-import org.apache.tuscany.binding.ws.DefaultWebServiceBindingFactory;
 import org.apache.tuscany.binding.ws.WebServiceBindingFactory;
 import org.apache.tuscany.binding.ws.xml.WebServiceBindingProcessor;
 import org.apache.tuscany.contribution.processor.StAXArtifactProcessorExtensionPoint;
 import org.apache.tuscany.core.ExtensionPointRegistry;
 import org.apache.tuscany.core.ModuleActivator;
 import org.apache.tuscany.http.ServletHost;
-import org.apache.tuscany.interfacedef.wsdl.DefaultWSDLFactory;
 import org.apache.tuscany.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.interfacedef.wsdl.DefaultWSDLFactory;
 import org.apache.tuscany.interfacedef.wsdl.introspect.DefaultWSDLInterfaceIntrospector;
 import org.apache.tuscany.interfacedef.wsdl.introspect.WSDLInterfaceIntrospector;
-import org.apache.tuscany.policy.DefaultPolicyFactory;
 import org.apache.tuscany.policy.PolicyFactory;
+import org.apache.tuscany.policy.DefaultPolicyFactory;
 
 public class Axis2ModuleActivator implements ModuleActivator {
 
-    private Axis2BindingBuilder builder;
-
     public void start(ExtensionPointRegistry registry) {
 
         StAXArtifactProcessorExtensionPoint processors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
         AssemblyFactory assemblyFactory = new DefaultAssemblyFactory();
         PolicyFactory policyFactory = new DefaultPolicyFactory();
-        WebServiceBindingFactory wsFactory = new DefaultWebServiceBindingFactory();
+        ServletHost servletHost = registry.getExtensionPoint(ServletHost.class);
+        WebServiceBindingFactory wsFactory = new Axis2BindingFactory(servletHost);
         WSDLFactory wsdlFactory = new DefaultWSDLFactory();
         WSDLInterfaceIntrospector introspector = new DefaultWSDLInterfaceIntrospector(wsdlFactory);
-        processors.addArtifactProcessor(new WebServiceBindingProcessor(
-                                                                              assemblyFactory, policyFactory, wsFactory,
-                                                                              wsdlFactory, introspector));
-
-        ServletHost servletHost = registry.getExtensionPoint(ServletHost.class);
-        
-        BuilderRegistry builderRegistry = registry.getExtensionPoint(BuilderRegistry.class);
-        builder = new Axis2BindingBuilder();
-        builder.setBuilderRegistry(builderRegistry);
-        builder.setServletHost(servletHost);
-        builder.init();
-
+        processors.addArtifactProcessor(new WebServiceBindingProcessor(assemblyFactory, policyFactory, wsFactory,
+                                                                       wsdlFactory, introspector));
     }
 
     public void stop(ExtensionPointRegistry registry) {
-        //FIXME
-        // release resources held by bindings
-        // needed because the stop methods in ReferenceImpl and ServiceImpl aren't being called
-        // TODO: revisit this as part of the lifecycle work
-        builder.destroy(); // release connections
     }
 
     public Map<Class, Object> getExtensionPoints() {

Added: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2OneWayBindingInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2OneWayBindingInvoker.java?view=auto&rev=536323
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2OneWayBindingInvoker.java (added)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2OneWayBindingInvoker.java Tue May  8 13:53:59 2007
@@ -0,0 +1,59 @@
+/*
+ * 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.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.spi.component.WorkContext;
+
+public class Axis2OneWayBindingInvoker extends Axis2BindingInvoker {
+
+    public Axis2OneWayBindingInvoker(ServiceClient serviceClient,
+                                         QName wsdlOperationName,
+                                         Options options,
+                                         SOAPFactory soapFactory) {
+
+        super(serviceClient, wsdlOperationName, options, soapFactory);
+    }
+
+    protected Object invokeTarget(final Object payload, final short sequence, WorkContext workContext) throws InvocationTargetException {
+        try {
+            Object[] args = (Object[]) payload;
+
+            OperationClient operationClient = createOperationClient(args, workContext);
+            operationClient.execute(false);
+
+            // REVIEW it seems ok to return null
+            return null;
+
+        } catch (AxisFault e) {
+            throw new InvocationTargetException(e);
+        } catch (Throwable t) {
+            throw new InvocationTargetException(t);
+        }
+    }
+
+}

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

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

Added: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBindingProvider.java?view=auto&rev=536323
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBindingProvider.java (added)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBindingProvider.java Tue May  8 13:53:59 2007
@@ -0,0 +1,246 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  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.util.List;
+
+import javax.wsdl.Binding;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.Definition;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap.SOAPOperation;
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.tuscany.binding.ws.WebServiceBinding;
+import org.apache.tuscany.core.RuntimeComponent;
+import org.apache.tuscany.core.RuntimeComponentReference;
+import org.apache.tuscany.core.RuntimeWire;
+import org.apache.tuscany.interfacedef.InterfaceContract;
+import org.apache.tuscany.interfacedef.Operation;
+import org.apache.tuscany.invocation.Invoker;
+import org.apache.tuscany.provider.ReferenceBindingProvider;
+
+public class Axis2ReferenceBindingProvider implements ReferenceBindingProvider {
+
+    private RuntimeComponent component;
+    private RuntimeComponentReference reference;
+    private WebServiceBinding wsBinding;
+    private ConfigurationContext configContext;
+    private ServiceClient serviceClient;
+
+    public Axis2ReferenceBindingProvider(RuntimeComponent component,
+                                         RuntimeComponentReference reference,
+                                         WebServiceBinding wsBinding) {
+
+        // TODO: before the SPI changes, a composite reference was passed to the builder.
+        // Is the change to a component reference OK?
+
+        this.component = component;
+        this.reference = reference;
+        this.wsBinding = wsBinding;
+
+        try {
+            TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator();
+            configContext = tuscanyAxisConfigurator.getConfigurationContext();
+        } catch (AxisFault e) {
+            throw new RuntimeException(e); // TODO: better exception
+        }
+    }
+
+    // methods for ReferenceBindingActivator
+
+    public void start() {
+
+        InterfaceContract contract = wsBinding.getBindingInterfaceContract();
+        if (contract == null) {
+            contract = reference.getInterfaceContract();
+            wsBinding.setBindingInterfaceContract(contract);
+        }
+
+        // Set to use the Axiom data binding 
+        contract.getInterface().setDefaultDataBinding(OMElement.class.getName());        
+
+        // ??? following line was in Axis2BindingBuilder before the SPI changes and code reorg
+        //
+        // URI targetURI = wsBinding.getURI() != null ? URI.create(wsBinding.getURI()) : URI.create("foo");
+        //
+        // targetURI was passed to the ReferenceBindingExtension constructor and apparently was unused
+        // Do we still need a targetURI?
+
+        wsBinding.setURI(component.getURI() + "#" + reference.getName());
+
+        // create an Axis2 ServiceClient
+        serviceClient = createServiceClient();
+    }
+
+    public void stop() {
+
+        // close all connections that we have initiated, so that the jetty server
+        // can be restarted without seeing ConnectExceptions
+        HttpClient httpClient = (HttpClient)serviceClient.getServiceContext().getConfigurationContext()
+                .getProperty(HTTPConstants.CACHED_HTTP_CLIENT);
+        if (httpClient != null)
+            ((MultiThreadedHttpConnectionManager)httpClient.getHttpConnectionManager()).shutdown();
+    }
+
+    /**
+     * Create an Axis2 ServiceClient
+     */
+    protected ServiceClient createServiceClient() {
+        try {
+            QName serviceQName = wsBinding.getServiceName();
+            String portName = wsBinding.getPortName();
+            Definition wsdlDefinition = wsBinding.getWSDLDefinition().getDefinition();
+            AxisService axisService = AxisService.createClientSideAxisService(wsdlDefinition, serviceQName, portName, new Options());
+
+            return new ServiceClient(configContext, axisService);
+        } catch (AxisFault e) {
+            throw new RuntimeException(e); // TODO: better exception
+        }
+    }
+
+    // methods for ReferenceBindingProvider
+
+    public InterfaceContract getBindingInterfaceContract() {
+        return wsBinding.getBindingInterfaceContract();
+    }
+
+    public Invoker createInvoker(Operation operation, boolean isCallback) {
+        Axis2BindingInvoker invoker;
+
+        InterfaceContract contract = wsBinding.getBindingInterfaceContract();
+        if (contract == null) {
+            contract = reference.getInterfaceContract();
+            wsBinding.setBindingInterfaceContract(contract);
+        }
+ 
+        if (wsBinding.getBindingInterfaceContract().getCallbackInterface() == null) {
+            invoker = createOperationInvoker(serviceClient, operation, false, operation.isNonBlocking());
+        } else {
+            // FIXME: SDODataBinding needs to pass in TypeHelper and classLoader as parameters.
+
+            // 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
+
+            RuntimeWire wire = reference.getRuntimeWire(wsBinding);
+            Operation callbackOperation = findCallbackOperation(wire);
+            Axis2CallbackInvocationHandler invocationHandler = new Axis2CallbackInvocationHandler(wire);
+            Axis2ReferenceCallbackTargetInvoker callbackInvoker =
+                new Axis2ReferenceCallbackTargetInvoker(callbackOperation, wire, invocationHandler);
+
+            Axis2AsyncBindingInvoker asyncInvoker = 
+                (Axis2AsyncBindingInvoker)createOperationInvoker(serviceClient, operation, true, false);
+            asyncInvoker.setCallbackTargetInvoker(callbackInvoker);
+            invoker = asyncInvoker;
+        }
+
+        return invoker;
+    }
+
+    private Operation findCallbackOperation(RuntimeWire wire) {
+        InterfaceContract contract = wire.getTarget().getInterfaceContract(); // TODO: which end?
+        List callbackOperations = contract.getCallbackInterface().getOperations();
+        if (callbackOperations.size() != 1) {
+            throw new RuntimeException("Can only handle one callback operation");
+        }
+        Operation callbackOperation = (Operation) callbackOperations.get(0);
+        return callbackOperation;
+    }
+
+    /**
+     * Create and configure an Axis2BindingInvoker for each operation
+     */
+    private Axis2BindingInvoker createOperationInvoker(ServiceClient serviceClient,
+                                                       Operation operation,
+                                                       boolean hasCallback,
+                                                       boolean isOneWay) {
+
+        Options options = new Options();
+        options.setTo(getPortLocationEPR());
+        options.setProperty(HTTPConstants.CHUNKED, Boolean.FALSE);
+
+        String operationName = operation.getName();
+
+        String soapAction = getSOAPAction(operationName);
+        if (soapAction != null && soapAction.length() > 1) {
+            options.setAction(soapAction);
+        }
+
+        options.setTimeOutInMilliSeconds(30 * 1000); // 30 seconds
+
+        SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
+        QName wsdlOperationQName = new QName(operationName);
+
+        Axis2BindingInvoker invoker;
+        if (hasCallback) {
+            invoker = new Axis2AsyncBindingInvoker(serviceClient, wsdlOperationQName, options, soapFactory);
+        } else if (isOneWay) {
+            invoker = new Axis2OneWayBindingInvoker(serviceClient, wsdlOperationQName, options, soapFactory);
+        } else {
+            invoker = new Axis2BindingInvoker(serviceClient, wsdlOperationQName, options, soapFactory);
+        }
+
+        return invoker;
+    }
+    
+    protected EndpointReference getPortLocationEPR() {
+        String ep = wsBinding.getURI();
+        if (ep == null && wsBinding.getPort() != null) {
+            List wsdlPortExtensions = wsBinding.getPort().getExtensibilityElements();
+            for (final Object extension : wsdlPortExtensions) {
+                if (extension instanceof SOAPAddress) {
+                    ep = ((SOAPAddress) extension).getLocationURI();
+                    break;
+                }
+            }
+        }
+        return new EndpointReference(ep);
+    }
+
+    protected String getSOAPAction(String operationName) {
+        Binding binding = wsBinding.getBinding();
+        if (binding != null) {
+            for (Object o : binding.getBindingOperations()) {
+                BindingOperation bop = (BindingOperation) o;
+                if (bop.getName().equalsIgnoreCase(operationName)) {
+                    for (Object o2 : bop.getExtensibilityElements()) {
+                        if (o2 instanceof SOAPOperation) {
+                            return ((SOAPOperation)o2).getSoapActionURI();
+                        }
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
+}

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

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

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallback.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallback.java?view=diff&rev=536323&r1=536322&r2=536323
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallback.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallback.java Tue May  8 13:53:59 2007
@@ -24,8 +24,7 @@
 import org.apache.axis2.client.async.AsyncResult;
 import org.apache.axis2.client.async.Callback;
 import org.apache.axis2.context.MessageContext;
-import org.apache.tuscany.implementation.java.invocation.TargetInvoker;
-import org.apache.tuscany.invocation.InvocationRuntimeException;
+import org.apache.tuscany.invocation.ConversationSequence;
 
 public class Axis2ReferenceCallback extends Callback {
 
@@ -39,10 +38,10 @@
         MessageContext responseMC = result.getResponseMessageContext();
         OMElement responseOM = responseMC.getEnvelope().getBody().getFirstElement();
         try {
-            targetInvoker.invokeTarget(new Object[] {responseOM}, TargetInvoker.NONE, null);
+            targetInvoker.invokeTarget(new Object[] {responseOM}, ConversationSequence.NONE, null);
         } catch (InvocationTargetException e) {
             // FIXME what is the appropriate exception here?
-            throw new InvocationRuntimeException(e);
+            throw new RuntimeException(e);
         }
     }
 
@@ -51,6 +50,6 @@
     }
 
     public void onError(Exception e) {
-        throw new InvocationRuntimeException(e);
+        throw new RuntimeException(e);
     }
 }

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java?view=diff&rev=536323&r1=536322&r2=536323
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java Tue May  8 13:53:59 2007
@@ -23,16 +23,16 @@
 import java.util.LinkedList;
 import java.util.concurrent.CountDownLatch;
 
-import org.apache.tuscany.assembly.Wire;
-import org.apache.tuscany.implementation.java.invocation.TargetInvoker;
 import org.apache.tuscany.interfacedef.Operation;
-import org.apache.tuscany.invocation.Message;
 import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.invocation.ConversationSequence;
+import org.apache.tuscany.invocation.Message;
+import org.apache.tuscany.core.RuntimeWire;
 
-public class Axis2ReferenceCallbackTargetInvoker implements TargetInvoker {
+public class Axis2ReferenceCallbackTargetInvoker {
 
     private Operation operation;
-    private Wire inboundWire;
+    private RuntimeWire inboundWire;
     private LinkedList<URI> callbackRoutingChain;
     private boolean cacheable;
     Axis2CallbackInvocationHandler invocationHandler;
@@ -40,7 +40,7 @@
     private Object returnPayload;
 
     public Axis2ReferenceCallbackTargetInvoker(Operation operation,
-                                               Wire inboundWire,
+                                               RuntimeWire inboundWire,
                                                Axis2CallbackInvocationHandler invocationHandler) {
 
         this.operation = operation;
@@ -68,9 +68,9 @@
         }
     }
 
-    public Message invoke(Message msg) throws InvocationRuntimeException {
+    public Message invoke(Message msg) {
         try {
-            Object resp = invokeTarget(msg.getBody(), NONE, null);
+            Object resp = invokeTarget(msg.getBody(), ConversationSequence.NONE, null);
             msg.setBody(resp);
         } catch (InvocationTargetException e) {
             msg.setFaultBody(e.getCause());
@@ -86,6 +86,10 @@
 
     public void setCacheable(boolean cacheable) {
         this.cacheable = cacheable;
+    }
+
+    public boolean isOptimizable() {
+        return isCacheable(); // we only need to check if the scopes are correct
     }
 
     public Axis2ReferenceCallbackTargetInvoker clone() throws CloneNotSupportedException {

Added: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceBindingProvider.java?view=auto&rev=536323
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceBindingProvider.java (added)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceBindingProvider.java Tue May  8 13:53:59 2007
@@ -0,0 +1,474 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  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.net.URI;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.extensions.soap.SOAPAddress;
+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.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.WSDL2Constants;
+import org.apache.axis2.description.WSDLToAxisServiceBuilder;
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.tuscany.binding.ws.WebServiceBinding;
+import org.apache.tuscany.core.RuntimeComponent;
+import org.apache.tuscany.core.RuntimeComponentService;
+import org.apache.tuscany.core.RuntimeWire;
+import org.apache.tuscany.http.ServletHost;
+import org.apache.tuscany.interfacedef.InterfaceContract;
+import org.apache.tuscany.interfacedef.Operation;
+import org.apache.tuscany.invocation.ConversationSequence;
+import org.apache.tuscany.invocation.InvocationChain;
+import org.apache.tuscany.invocation.Invoker;
+import org.apache.tuscany.invocation.Message;
+import org.apache.tuscany.invocation.MessageImpl;
+import org.apache.tuscany.provider.ServiceBindingProvider;
+import org.apache.tuscany.scope.Scope;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.component.WorkContextTunnel;
+
+public class Axis2ServiceBindingProvider implements ServiceBindingProvider {
+
+    private RuntimeComponent component;
+    private RuntimeComponentService service;
+    private WebServiceBinding wsBinding;
+    private ServletHost servletHost;
+    private ConfigurationContext configContext;
+    private RuntimeWire serviceWire;
+
+    public Axis2ServiceBindingProvider(RuntimeComponent component, RuntimeComponentService service,
+                                       WebServiceBinding wsBinding, ServletHost servletHost) {
+
+        // TODO: before the SPI changes, a composite service was passed to the builder.
+        // Is the change to a component service OK?
+
+        this.component = component;
+        this.service = service;
+        this.wsBinding = wsBinding;
+        this.servletHost = servletHost;
+
+        try {
+            TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator();
+            configContext = tuscanyAxisConfigurator.getConfigurationContext();
+        } catch (AxisFault e) {
+            throw new RuntimeException(e); // TODO: better exception
+        }
+    }
+
+    // methods for ServiceBindingActivator
+
+    // TODO: what to do about the base URI?
+    private static final String BASE_URI = "http://localhost:8080/";
+
+    public void start() {
+
+        InterfaceContract contract = wsBinding.getBindingInterfaceContract();
+        if (contract == null) {
+            contract = service.getInterfaceContract();
+            wsBinding.setBindingInterfaceContract(contract);
+        }
+
+        // Set to use the Axiom data binding 
+        contract.getInterface().setDefaultDataBinding(OMElement.class.getName());
+
+        URI uri = computeActualURI(BASE_URI, component, service).normalize();
+        wsBinding.setURI(uri.toString());
+        
+        // ??? following line was in Axis2BindingBuilder before the SPI changes and code reorg
+        //
+        // TODO: if <binding.ws> specifies the wsdl service then should create a service for every port
+        //
+        // is this still a valid to-do?
+
+        serviceWire = service.getRuntimeWire(wsBinding);
+
+        try {
+            configContext.getAxisConfiguration().addService(createAxisService());
+        } catch (AxisFault e) {
+            throw new RuntimeException(e);
+        }
+
+        Axis2ServiceServlet servlet = new Axis2ServiceServlet();
+        servlet.init(configContext);
+        String servletURI = wsBinding.getURI();
+        configContext.setContextRoot(servletURI);
+        servletHost.addServletMapping(servletURI, servlet);
+    }
+
+    public void stop() {
+        servletHost.removeServletMapping(wsBinding.getURI());
+        try {
+            configContext.getAxisConfiguration().removeService(wsBinding.getURI());
+        } catch (AxisFault e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * Compute the endpoint URI based on section 2.1.1 of the WS binding spec
+     * 1. The URIs in the endpoint(s) of the referenced WSDL, which may be relative
+     * 2. The URI specified by the wsa:Address element of the wsa:EndpointReference, which may be relative
+     * 3. The explicitly stated URI in the "uri" attribute of the binding.ws element, which may be relative,
+     * 4. The implicit URI as defined by in section 1.7 in the SCA Assembly spec 
+     * If the <binding.ws> has no wsdlElement but does have a uri attribute then the uri takes precidence
+     * over any implicitly used WSDL.
+     * @param parent 
+     */
+    protected URI computeActualURI(String baseURI, RuntimeComponent component, RuntimeComponentService service) {
+
+        // TODO: before the SPI changes, a CompositeService was passed to the builder.
+        // Is the change to ComponentService OK?
+
+        // TODO: support wsa:Address
+
+        URI wsdlURI = null;         
+        if (wsBinding.getServiceName() != null && wsBinding.getBindingName() == null) {
+            // <binding.ws> explicitly points at a wsdl port, may be a relative URI
+            wsdlURI = getEndpoint(wsBinding.getPort());
+        }
+        if (wsdlURI != null && wsdlURI.isAbsolute()) {
+            if (wsBinding.getURI() != null && (wsBinding.getServiceName() != null && wsBinding.getBindingName() == null)) {
+                throw new IllegalArgumentException("binding URI cannot be used with absolute WSDL endpoint URI");
+            }
+            return URI.create(wsdlURI.toString());
+        }
+        
+        // either there is no wsdl port endpoint URI or that URI is relative
+        
+        URI bindingURI = null;
+        if (wsBinding.getURI() != null) {
+            bindingURI = URI.create(wsBinding.getURI());
+        }
+        if (bindingURI != null && bindingURI.isAbsolute()) {
+            // there is an absoulte uri specified on the binding: <binding.ws uri="xxx"
+            if (wsdlURI != null) {
+                // there is a relative URI in the wsdl port
+                return URI.create(bindingURI + "/" + wsdlURI);
+            } else {
+                return bindingURI;
+            }
+        }
+        
+        // both the WSDL endpoint and binding uri are either unspecified or relative so
+        // the endpoint is based on the component name and service binding URI
+ 
+        URI componentURI = URI.create(component.getName());
+        
+        String actualURI;
+        if (componentURI.isAbsolute()) {
+            actualURI = componentURI.toString();
+        } else {
+            actualURI = baseURI + "/" + componentURI;
+        }
+        
+        // with multiple services the default binding URI is the binding name
+        if (bindingURI == null && component.getServices().size() > 1) {
+            // if the binding doesn't have a name use the name of the service (assumption, not in spec)
+            if (wsBinding.getName() != null) {
+                bindingURI = URI.create(wsBinding.getName());
+            } else {
+                bindingURI = URI.create(service.getName());
+            }
+        }
+
+        // add any relative binding URI
+        if (bindingURI != null) {
+            actualURI += "/" + bindingURI;
+         }
+
+        // add any relative WSDL port URI
+        if (wsdlURI != null) {
+            actualURI += "/" + wsdlURI.toString();
+        }
+
+        // Axis2 fails if the endpoint has a trailing slash
+        if (actualURI.endsWith("/")) {
+            actualURI = actualURI.substring(0, actualURI.length() -1);
+        }
+        
+        return URI.create(actualURI);
+    }
+
+    /**
+     * Returns the endpoint of a given port.
+     */
+    protected URI getEndpoint(Port wsdlPort) {
+        if (wsdlPort != null) {
+            List wsdlPortExtensions = wsdlPort.getExtensibilityElements();
+            for (Object extension : wsdlPortExtensions) {
+                if (extension instanceof SOAPAddress) {
+                    return URI.create(((SOAPAddress) extension).getLocationURI());
+                }
+            }
+        }
+        return null;
+    }
+
+    private AxisService createAxisService() throws AxisFault {
+        Definition definition = wsBinding.getWSDLDefinition().getDefinition();
+
+        // WSDLToAxisServiceBuilder only uses the service and port to find the wsdl4J Binding
+        // An SCA service with binding.ws does not require a service or port so we may not have these
+        // but 
+
+        WSDLToAxisServiceBuilder builder = new WSDL11ToAxisServiceBuilder(definition, wsBinding.getServiceName(), wsBinding.getPortName());
+        builder.setServerSide(true);
+        AxisService axisService = builder.populateService();
+
+        String path = wsBinding.getURI();
+        if (path != null && path.length() > 1 && path.startsWith("/")) {
+            path = path.substring(1);
+        }
+        axisService.setName(path);
+        axisService.setServiceDescription("Tuscany configured AxisService for service: " + wsBinding.getURI());
+
+        // Use the existing WSDL
+        Parameter wsdlParam = new Parameter(WSDLConstants.WSDL_4_J_DEFINITION, null);
+        wsdlParam.setValue(definition);
+        axisService.addParameter(wsdlParam);
+        Parameter userWSDL = new Parameter("useOriginalwsdl", "true");
+        axisService.addParameter(userWSDL);
+
+        for (Iterator i = axisService.getOperations(); i.hasNext();) {
+            AxisOperation axisOp = (AxisOperation) i.next();
+            Operation op = getOperation(axisOp);
+            if (op != null) {
+
+                if (op.isNonBlocking()) {
+                    axisOp.setMessageExchangePattern(WSDL2Constants.MEP_URI_IN_ONLY);
+                } else {
+                    axisOp.setMessageExchangePattern(WSDL2Constants.MEP_URI_IN_OUT);
+                }
+
+                MessageReceiver msgrec = null;
+                if (wsBinding.getBindingInterfaceContract().getCallbackInterface() != null) {
+                    msgrec = new Axis2ServiceInOutAsyncMessageReceiver(this, op);
+                } else if (op.isNonBlocking()) {
+                    msgrec = new Axis2ServiceInMessageReceiver(this, op);
+                } else {
+                    msgrec = new Axis2ServiceInOutSyncMessageReceiver(this, op);
+                }
+                axisOp.setMessageReceiver(msgrec);
+            }
+        }
+
+        return axisService;
+    }
+
+    protected Operation getOperation(AxisOperation axisOp) {
+        String operationName = axisOp.getName().getLocalPart();
+        for (Operation op : wsBinding.getBindingInterfaceContract().getInterface().getOperations()) {
+           if (op.getName().equalsIgnoreCase(operationName)) {
+               return op;
+           }
+        }
+        return null;
+    }
+
+    // methods for ServiceBindingProvider
+
+    public InterfaceContract getBindingInterfaceContract() {
+        return wsBinding.getBindingInterfaceContract();
+    }
+
+    // other methods that were previously in Axis2ServiceBinding
+    // TODO: are these still needed?
+
+    private Map<Object, InvocationContext> invCtxMap = new HashMap<Object, InvocationContext>();
+    private Set<String> seenConversations = Collections.synchronizedSet(new HashSet<String>());
+
+    public Invoker createTargetInvoker(InterfaceContract contract, Operation operation) {
+//        if (!operation.isCallback()) { TODO: no isCallback methjod yet?
+//            throw new UnsupportedOperationException();
+//        } else {
+            return new Axis2ServiceCallbackTargetInvoker(this);
+//        }
+    }
+
+    public void addMapping(Object msgId, InvocationContext invCtx) {
+        this.invCtxMap.put(msgId, invCtx);
+    }
+
+    public InvocationContext retrieveMapping(Object msgId) {
+        return this.invCtxMap.get(msgId);
+    }
+
+    public void removeMapping(Object msgId) {
+        this.invCtxMap.remove(msgId);
+    }
+
+    /**
+     * @param inMC
+     * @return
+     */
+    protected static String getConversationID(MessageContext inMC) {
+        String conversationID = null;
+        Iterator i = inMC.getEnvelope().getHeader()
+            .getChildrenWithName(new QName("http://www.w3.org/2005/08/addressing", "From"));
+        for (; i.hasNext();) {
+            Object a = i.next();
+            if (a instanceof OMElement) {
+                OMElement ao = (OMElement) a;
+                for (Iterator rpI =
+                    ao.getChildrenWithName(new QName("http://www.w3.org/2005/08/addressing", "ReferenceParameters"));
+                     rpI.hasNext();) {
+                    OMElement rpE = (OMElement) rpI.next();
+                    for (
+                        Iterator cidI = rpE.getChildrenWithName(Axis2BindingInvoker.CONVERSATION_ID_REFPARM_QN);
+                        cidI.hasNext();) {
+                        OMElement cidE = (OMElement) cidI.next();
+                        conversationID = cidE.getText();
+                    }
+                }
+
+            }
+
+        }
+        return conversationID;
+    }
+
+    public Object invokeTarget(Operation op, Object[] args, Object messageId, String conversationID) throws InvocationTargetException {
+        InvocationChain chain = null;
+        for (InvocationChain ic : serviceWire.getInvocationChains()) {
+            if (ic.getSourceOperation().equals(op)) {
+                chain = ic;
+            }
+        }
+        if (chain == null) {
+            throw new IllegalStateException("no InvocationChain on wire for operation " + op);
+        }
+        
+        Invoker headInvoker = chain.getHeadInvoker();
+        WorkContext workContext = WorkContextTunnel.getThreadWorkContext();
+        String oldConversationID = (String) workContext.getIdentifier(Scope.CONVERSATION);
+        if (isConversational() && conversationID != null) {
+            workContext.setIdentifier(Scope.CONVERSATION, conversationID);
+        } else {
+            workContext.clearIdentifier(Scope.CONVERSATION);
+        }
+        try {
+            if (headInvoker == null) {
+                // can no longer occur because TargetInvoker has been merged with Interceptor   
+                throw new AssertionError("No target invoker interceptor [" + chain.getTargetOperation().getName() + "]");
+
+                // short-circuit the dispatch and invoke the target directly
+                // TargetInvoker targetInvoker = chain.getTargetInvoker();
+                // if (targetInvoker == null) {
+                //     throw new AssertionError("No target invoker [" + chain.getTargetOperation().getName() + "]");
+                // }
+                // return targetInvoker.invokeTarget(args, TargetInvoker.NONE, null);
+            } else {
+
+                Message msg = new MessageImpl();
+                // no target invokers any more
+                // msg.setTargetInvoker(chain.getTargetInvoker());
+                // msg.pushFromAddress(getFromAddress()); // TODO : method gone in the TRUNK???
+                if (messageId != null) {
+                    msg.setMessageID(messageId);
+                }
+                msg.setBody(args);
+                msg.setWorkContext(workContext);
+
+                Message resp;
+
+                if (isConversational()) {
+
+
+                    Operation.ConversationSequence opSeq = op.getConversationSequence();
+                    if (opSeq == Operation.ConversationSequence.CONVERSATION_END) {
+                        assert seenConversations
+                            .contains(conversationID) : "End of conversation called when no conversation existed";
+                        msg.setConversationSequence(ConversationSequence.END);
+                        seenConversations.remove(conversationID); //if a fault occurs does the conversation end?
+                        //how do I know if a component called locally another opeation that ended this conversation?
+
+                    } else {
+                        boolean ec = seenConversations.contains(conversationID);
+                        if (ec) {
+
+                            msg.setConversationSequence(ConversationSequence.CONTINUE);
+                        } else {
+                            seenConversations.add(conversationID);
+                            msg.setConversationSequence(ConversationSequence.START);
+                        }
+                    }
+
+                }
+                // dispatch the wire down the chain and get the response
+                resp = headInvoker.invoke(msg);
+                Object body = resp.getBody();
+                if (resp.isFault()) {
+                    throw new InvocationTargetException((Throwable) body);
+                }
+                return body;
+            }
+        } finally {
+            if (null != oldConversationID) {
+                workContext.setIdentifier(Scope.CONVERSATION, conversationID);
+            } else {
+                workContext.clearIdentifier(Scope.CONVERSATION);
+            }
+        }
+    }
+
+    protected class InvocationContext {
+        public MessageContext inMessageContext;
+
+        public Operation operation;
+
+        public SOAPFactory soapFactory;
+
+        public CountDownLatch doneSignal;
+
+        public InvocationContext(MessageContext messageCtx,
+                                 Operation operation,
+                                 SOAPFactory soapFactory,
+                                 CountDownLatch doneSignal) {
+            this.inMessageContext = messageCtx;
+            this.operation = operation;
+            this.soapFactory = soapFactory;
+            this.doneSignal = doneSignal;
+        }
+    }
+
+    public boolean isConversational() {
+        return wsBinding.getBindingInterfaceContract().getInterface().isConversational();
+    }
+
+}

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

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

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java?view=diff&rev=536323&r1=536322&r2=536323
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java Tue May  8 13:53:59 2007
@@ -27,26 +27,21 @@
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.engine.AxisEngine;
 import org.apache.axis2.util.Utils;
-import org.apache.tuscany.binding.axis2.Axis2ServiceBinding.InvocationContext;
-import org.apache.tuscany.implementation.java.invocation.TargetInvoker;
-import org.apache.tuscany.invocation.InvocationRuntimeException;
+import org.apache.tuscany.binding.axis2.Axis2ServiceBindingProvider.InvocationContext;
+import org.apache.tuscany.invocation.Invoker;
 import org.apache.tuscany.invocation.Message;
 import org.apache.tuscany.spi.component.WorkContext;
 
-public class Axis2ServiceCallbackTargetInvoker implements TargetInvoker {
+public class Axis2ServiceCallbackTargetInvoker implements Invoker {
 
-    private Axis2ServiceBinding service;
+    private Axis2ServiceBindingProvider service;
     
     protected static final OMElement RESPONSE = null;
 
-    public Axis2ServiceCallbackTargetInvoker(Axis2ServiceBinding service) {
+    public Axis2ServiceCallbackTargetInvoker(Axis2ServiceBindingProvider service) {
         this.service = service;
     }
 
-    public Object invokeTarget(final Object payload, final short sequence, WorkContext workContext) throws InvocationTargetException {
-        throw new InvocationTargetException(new InvocationRuntimeException("Operation not supported"));
-    }
-
     private Object invokeTarget(final Object payload, Object correlationId) throws InvocationTargetException {
         try {
             // Use current correlation id as index to retrieve inv context
@@ -83,14 +78,16 @@
         return RESPONSE;
     }
 
-    public Message invoke(Message msg) throws InvocationRuntimeException {
+    public Message invoke(Message msg) {
         try {
             Object correlationId = msg.getCorrelationID();
             if (correlationId == null) {
-                throw new InvocationRuntimeException("Missing correlation id");
+                throw new RuntimeException("Missing correlation id");
             }
             Object resp = invokeTarget(msg.getBody(), correlationId);
             msg.setBody(resp);
+        } catch (InvocationTargetException e) {
+            msg.setFaultBody(e.getCause());
         } catch (Throwable e) {
             msg.setFaultBody(e);
         }
@@ -104,14 +101,6 @@
             // will not happen
             return null;
         }
-    }
-
-    public boolean isCacheable() {
-        return true;
-    }
-
-    public void setCacheable(boolean cacheable) {
-
     }
 
 }

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInMessageReceiver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInMessageReceiver.java?view=diff&rev=536323&r1=536322&r2=536323
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInMessageReceiver.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInMessageReceiver.java Tue May  8 13:53:59 2007
@@ -28,10 +28,10 @@
 
     protected Operation operation;
 
-    private Axis2ServiceBinding axis2Service;
+    private Axis2ServiceBindingProvider provider;
 
-    public Axis2ServiceInMessageReceiver(Axis2ServiceBinding service, Operation operation) {
-        this.axis2Service = service;
+    public Axis2ServiceInMessageReceiver(Axis2ServiceBindingProvider provider, Operation operation) {
+        this.provider = provider;
         this.operation = operation;
     }
 
@@ -44,7 +44,7 @@
         try {
             OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
             Object[] args = new Object[] {requestOM};
-            String conversationID = axis2Service.isConversational() ?  Axis2ServiceBinding.getConversationID(inMC) : null;
+            String conversationID = provider.isConversational() ?  Axis2ServiceBindingProvider.getConversationID(inMC) : null;
 
 //            axis2Service.invokeTarget(operation, args, null, conversationID);
 

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java?view=diff&rev=536323&r1=536322&r2=536323
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java Tue May  8 13:53:59 2007
@@ -25,19 +25,18 @@
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.receivers.AbstractMessageReceiver;
 import org.apache.tuscany.interfacedef.Operation;
-import org.apache.tuscany.invocation.MessageId;
 
 public class Axis2ServiceInOutAsyncMessageReceiver extends AbstractMessageReceiver {
 
     private Operation operation;
 
-    private Axis2ServiceBinding service;
+    private Axis2ServiceBindingProvider provider;
 
-    public Axis2ServiceInOutAsyncMessageReceiver(Axis2ServiceBinding service,
+    public Axis2ServiceInOutAsyncMessageReceiver(Axis2ServiceBindingProvider provider,
                                                  Operation operation) {
+        this.provider = provider;
         this.operation = operation;
-        this.service = service;
-    }
+   }
 
     public Axis2ServiceInOutAsyncMessageReceiver() {
     }
@@ -72,7 +71,7 @@
         try {
             OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
             Object[] args = new Object[] {requestOM};
-            String conversationID = service.isConversational() ?  Axis2ServiceBinding.getConversationID(inMC) : null;
+            String conversationID = provider.isConversational() ?  Axis2ServiceBindingProvider.getConversationID(inMC) : null;
 //            service.invokeTarget(operation, args, messageId, conversationID);
 //        } catch (InvocationTargetException e) {
 //            Throwable t = e.getCause();
@@ -85,4 +84,45 @@
         }
 
     }
+
+    /**
+     * A unique identifier for a message flowing on a wire, potentially end-to-end (ie, through more than one SCAObject to
+     * SCAObject hop).
+     *
+     * This used to be in the org.apache.tuscany.spi.wire package
+     */
+    public class MessageId {
+
+        private long timestamp;
+
+        public MessageId() {
+            this.timestamp = System.currentTimeMillis();
+        }
+
+        public long getTimestamp() {
+            return timestamp;
+        }
+
+        public String toString() {
+            return "MsgId[" + timestamp + "]";
+        }
+
+        public boolean equals(Object o) {
+            if (this == o) {
+                return true;
+            }
+            if (o == null || getClass() != o.getClass()) {
+                return false;
+            }
+
+            final MessageId messageId = (MessageId) o;
+            return timestamp == messageId.timestamp;
+        }
+
+        public int hashCode() {
+            return (int) (timestamp ^ (timestamp >>> 32));
+        }
+
+    }
+
 }

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=536323&r1=536322&r2=536323
==============================================================================
--- 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 May  8 13:53:59 2007
@@ -27,19 +27,18 @@
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver;
 import org.apache.tuscany.interfacedef.Operation;
-import org.apache.tuscany.invocation.InvocationRuntimeException;
 
 public class Axis2ServiceInOutSyncMessageReceiver extends AbstractInOutSyncMessageReceiver {
 
     protected Operation operation;
 
-    private Axis2ServiceBinding axis2Service;
+    private Axis2ServiceBindingProvider provider;
 
     public Axis2ServiceInOutSyncMessageReceiver() {
     }
 
-    public Axis2ServiceInOutSyncMessageReceiver(Axis2ServiceBinding service, Operation operation) {
-        this.axis2Service = service;
+    public Axis2ServiceInOutSyncMessageReceiver(Axis2ServiceBindingProvider provider, Operation operation) {
+        this.provider = provider;
         this.operation = operation;
     }
 
@@ -49,9 +48,9 @@
             OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
             Object[] args = new Object[] {requestOM};
             
-            String conversationID = axis2Service.isConversational() ?  Axis2ServiceBinding.getConversationID(inMC) : null;
+            String conversationID = provider.isConversational() ?  Axis2ServiceBindingProvider.getConversationID(inMC) : null;
 
-            OMElement responseOM = (OMElement) axis2Service.invokeTarget(operation, args, null, conversationID);
+            OMElement responseOM = (OMElement) provider.invokeTarget(operation, args, null, conversationID);
 
             SOAPEnvelope soapEnvelope = getSOAPFactory(inMC).getDefaultEnvelope();
             if(null != responseOM ){
@@ -66,7 +65,7 @@
             if (t instanceof Exception) {
                 throw AxisFault.makeFault((Exception)t);
             }
-            throw new InvocationRuntimeException(e);
+            throw new RuntimeException(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/Axis2ServiceServlet.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceServlet.java?view=diff&rev=536323&r1=536322&r2=536323
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceServlet.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceServlet.java Tue May  8 13:53:59 2007
@@ -43,7 +43,6 @@
 import org.apache.axis2.transport.http.ListingAgent;
 import org.apache.axis2.transport.http.server.HttpUtils;
 import org.apache.tuscany.scope.Scope;
-import org.apache.tuscany.spi.bootstrap.ComponentNames;
 import org.apache.tuscany.spi.component.WorkContext;
 import org.apache.tuscany.spi.component.WorkContextImpl;
 import org.apache.tuscany.spi.component.WorkContextTunnel;



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