tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r528802 - /incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/
Date Sat, 14 Apr 2007 13:02:04 GMT
Author: antelder
Date: Sat Apr 14 06:02:03 2007
New Revision: 528802

URL: http://svn.apache.org/viewvc?view=rev&rev=528802
Log:
More Axis2 binding bringup. the helloworld-om-client testcase now works

Modified:
    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/Axis2ReferenceBinding.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/Axis2TargetInvoker.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2WSReference.java

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java?view=diff&rev=528802&r1=528801&r2=528802
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java
Sat Apr 14 06:02:03 2007
@@ -18,6 +18,8 @@
  */
 package org.apache.tuscany.binding.axis2;
 
+import java.net.URI;
+
 import org.apache.axiom.om.OMElement;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.ConfigurationContext;
@@ -65,7 +67,8 @@
     public ReferenceBinding build(CompositeReference boundReferenceDefinition,
                                   WebServiceBinding bindingDefinition,
                                   DeploymentContext context) throws BuilderException {
-      return new Axis2WSReference(null, null);
+        URI targetURI = bindingDefinition.getURI() != null ? URI.create(bindingDefinition.getURI())
: URI.create("foo");
+        return new Axis2WSReference(URI.create(context.getComponentId() + "#" + bindingDefinition.getName()),
targetURI, bindingDefinition);
     }
     
 //    @SuppressWarnings("unchecked")

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBinding.java?view=diff&rev=528802&r1=528801&r2=528802
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBinding.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBinding.java
Sat Apr 14 06:02:03 2007
@@ -39,6 +39,7 @@
 import org.apache.tuscany.binding.axis2.util.WebServiceOperationMetaData;
 import org.apache.tuscany.binding.axis2.util.WebServicePortMetaData;
 import org.apache.tuscany.binding.ws.WebServiceBinding;
+import org.apache.tuscany.interfacedef.InterfaceContract;
 import org.apache.tuscany.interfacedef.Operation;
 import org.apache.tuscany.spi.component.TargetInvokerCreationException;
 import org.apache.tuscany.spi.component.WorkContext;
@@ -48,40 +49,47 @@
 /**
  * Axis2Reference uses Axis2 to invoke a remote web service
  */
-public class Axis2ReferenceBinding<T> extends ReferenceBindingExtension {
+public class Axis2ReferenceBinding extends ReferenceBindingExtension {
     private static final QName BINDING_WS = new QName(SCA_NS, "binding.ws");
 
     private WebServicePortMetaData wsPortMetaData;
     private ServiceClient serviceClient;
+
     private WorkContext workContext;
 
-    @SuppressWarnings("unchecked")
-    public Axis2ReferenceBinding(URI uri,
-                                 WebServiceBinding wsBinding,
-//                                 ServiceContract contract,
-//                                 ServiceContract<?> bindingServiceContract,
-                                 WorkContext workContext) {
-        super(uri, uri); // TODO: what should these be
-        this.bindingServiceContract = bindingServiceContract;
-        this.workContext = workContext;
-        try {
-            Definition wsdlDefinition = wsBinding.getWSDLDefinition();
-            wsPortMetaData =
-                new WebServicePortMetaData(wsdlDefinition, wsBinding.getWSDLPort(), wsBinding.getURI(),
false);
-            serviceClient = createServiceClient(wsdlDefinition, wsPortMetaData);
-        } catch (AxisFault e) {
-            throw new Axis2BindingRunTimeException(e);
-        }
+//    public Axis2ReferenceBinding(URI uri,
+//                                 WebServiceBinding wsBinding
+////                                 ServiceContract contract,
+////                                 ServiceContract<?> bindingServiceContract) {
+//        super(uri, uri); // TODO: what should these be
+//        try {
+//            Definition wsdlDefinition = wsBinding.getWSDLDefinition();
+//            wsPortMetaData =
+//                new WebServicePortMetaData(wsdlDefinition, wsBinding.getWSDLPort(), wsBinding.getURI(),
false);
+//            serviceClient = createServiceClient(wsdlDefinition, wsPortMetaData);
+//        } catch (AxisFault e) {
+//            throw new Axis2BindingRunTimeException(e);
+//        }
+//    }
+    public Axis2ReferenceBinding(URI name, URI targetUri, WebServiceBinding wsBinding) {
+       super(name, targetUri);
+       this.wsPortMetaData = new WebServicePortMetaData(wsBinding.getWSDLDefinition().getDefinition(),
wsBinding.getPort(), wsBinding.getURI(), false);
+       this.serviceClient = createServiceClient(wsBinding.getWSDLDefinition().getDefinition(),
wsPortMetaData);
     }
 
     public QName getBindingType() {
         return BINDING_WS;
     }
 
-    public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation)
{
+    public TargetInvoker createTargetInvoker(String targetName, Operation operation, boolean
isCallback) throws TargetInvokerCreationException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public TargetInvoker createTargetInvoker(InterfaceContract contract, Operation operation,
boolean isCallback) {
         Axis2TargetInvoker invoker;
         try {
-            boolean operationHasCallback = contract.getCallbackName() != null;
+            boolean operationHasCallback = contract.getCallbackInterface() != null;
             if (operationHasCallback) {
                 // FIXME: SDODataBinding needs to pass in TypeHelper and classLoader
                 // as parameters.
@@ -97,7 +105,8 @@
                 // it may depend on knowledge
                 // of what actual callback method was invoked by the service at the
                 // other end
-                Operation callbackOperation = findCallbackOperation();
+//                Operation callbackOperation = findCallbackOperation();
+                Operation callbackOperation = null;
                 Axis2CallbackInvocationHandler invocationHandler =
                     new Axis2CallbackInvocationHandler(wire);
                 Axis2ReferenceCallbackTargetInvoker callbackInvoker =
@@ -115,31 +124,35 @@
         return invoker;
     }
 
-    private Operation findCallbackOperation() {
-        ServiceContract contract = wire.getTargetContract(); // TODO: which end?
-        Operation callbackOperation = null;
-        Collection callbackOperations = contract.getCallbackOperations().values();
-        if (callbackOperations.size() != 1) {
-            throw new Axis2BindingRunTimeException("Can only handle one callback operation");
-        } else {
-            callbackOperation = (Operation) callbackOperations.iterator().next();
-        }
-        return callbackOperation;
-    }
+//    private Operation findCallbackOperation() {
+//        ServiceContract contract = wire.getTargetContract(); // TODO: which end?
+//        Operation callbackOperation = null;
+//        Collection callbackOperations = contract.getCallbackOperations().values();
+//        if (callbackOperations.size() != 1) {
+//            throw new Axis2BindingRunTimeException("Can only handle one callback operation");
+//        } else {
+//            callbackOperation = (Operation) callbackOperations.iterator().next();
+//        }
+//        return callbackOperation;
+//    }
 
     /**
      * Create an Axis2 ServiceClient
      */
-    private ServiceClient createServiceClient(Definition wsdlDefinition, WebServicePortMetaData
wsPortMetaData)
-        throws AxisFault {
+    protected ServiceClient createServiceClient(Definition wsdlDefinition, WebServicePortMetaData
wsPortMetaData) {
+        try {
 
-        TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator();
-        ConfigurationContext configurationContext = tuscanyAxisConfigurator.getConfigurationContext();
-        QName serviceQName = wsPortMetaData.getServiceName();
-        String portName = wsPortMetaData.getPortName().getLocalPart();
-        AxisService axisService =
-            AxisService.createClientSideAxisService(wsdlDefinition, serviceQName, portName,
new Options());
-        return new ServiceClient(configurationContext, axisService);
+            TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator();
+            ConfigurationContext configurationContext = tuscanyAxisConfigurator.getConfigurationContext();
+            QName serviceQName = wsPortMetaData.getServiceName();
+            String portName = wsPortMetaData.getPortName().getLocalPart();
+            AxisService axisService = AxisService.createClientSideAxisService(wsdlDefinition,
serviceQName, portName, new Options());
+
+            return new ServiceClient(configurationContext, axisService);
+
+        } catch (AxisFault e) {
+            throw new RuntimeException(e); // TODO: better exception
+        }
     }
 
     /**
@@ -184,16 +197,6 @@
         }
 
         return invoker;
-    }
-
-    public TargetInvoker createTargetInvoker(String targetName, Operation operation) throws
TargetInvokerCreationException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public TargetInvoker createTargetInvoker(String targetName, PhysicalOperationDefinition
operation) throws TargetInvokerCreationException {
-        // TODO Auto-generated method stub
-        return null;
     }
 
 }

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=528802&r1=528801&r2=528802
==============================================================================
--- 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
Sat Apr 14 06:02:03 2007
@@ -23,7 +23,8 @@
 import java.util.LinkedList;
 import java.util.concurrent.CountDownLatch;
 
-import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.interfacedef.Operation;
+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.TargetInvoker;
@@ -48,7 +49,7 @@
         this.invocationHandler = invocationHandler;
     }
 
-    public Object invokeTarget(final Object payload, final short sequence) throws InvocationTargetException
{
+    public Object invokeTarget(final Object payload, final short sequence, WorkContext workContext)
throws InvocationTargetException {
         Object[] args;
         if (payload != null && !payload.getClass().isArray()) {
             args = new Object[]{payload};
@@ -60,7 +61,8 @@
         // FIXME synchronize with forward thread to return value
         signal.countDown();
         try {
-            return invocationHandler.invoke(operation, args, callbackRoutingChain);
+//            return invocationHandler.invoke(operation, args, callbackRoutingChain);
+            return null; // TODO ???
         } catch (Throwable t) {
             t.printStackTrace();
             throw new InvocationTargetException(t);
@@ -69,7 +71,7 @@
 
     public Message invoke(Message msg) throws InvocationRuntimeException {
         try {
-            Object resp = invokeTarget(msg.getBody(), NONE);
+            Object resp = invokeTarget(msg.getBody(), NONE, null);
             msg.setBody(resp);
         } catch (InvocationTargetException e) {
             msg.setBodyWithFault(e.getCause());
@@ -112,4 +114,5 @@
     public Object getReturnPayload() {
         return returnPayload;
     }
+
 }

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2TargetInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2TargetInvoker.java?view=diff&rev=528802&r1=528801&r2=528802
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2TargetInvoker.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2TargetInvoker.java
Sat Apr 14 06:02:03 2007
@@ -35,6 +35,7 @@
 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.spi.Scope;
 import org.apache.tuscany.spi.component.WorkContext;
 import org.apache.tuscany.spi.extension.TargetInvokerExtension;
@@ -56,6 +57,8 @@
 
     private WorkContext workContext;
 
+    public static final QName CONVERSATION_ID_REFPARM_QN = new QName(Constants.SCA10_NS,"conversationID");
+    
     public Axis2TargetInvoker(ServiceClient serviceClient, QName wsdlOperationName, Options
options,
                               SOAPFactory soapFactory, WorkContext workContext) {
         this.wsdlOperationName = wsdlOperationName;
@@ -113,7 +116,7 @@
             String conversationId = (String) workContext.getIdentifier(Scope.CONVERSATION);
             if(conversationId != null && conversationId.length()!=0){
                 EndpointReference fromEPR= new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL);
-                fromEPR.addReferenceParameter(WebServiceBindingDefinition.CONVERSATION_ID_REFPARM_QN,
conversationId);
+                fromEPR.addReferenceParameter(CONVERSATION_ID_REFPARM_QN, conversationId);
                 options.setFrom(fromEPR);
                 requestMC.setFrom(fromEPR); //who knows why two ways ?
             

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2WSReference.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2WSReference.java?view=diff&rev=528802&r1=528801&r2=528802
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2WSReference.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2WSReference.java
Sat Apr 14 06:02:03 2007
@@ -36,6 +36,7 @@
 import org.apache.tuscany.binding.axis2.util.TuscanyAxisConfigurator;
 import org.apache.tuscany.binding.axis2.util.WebServiceOperationMetaData;
 import org.apache.tuscany.binding.axis2.util.WebServicePortMetaData;
+import org.apache.tuscany.binding.ws.WebServiceBinding;
 import org.apache.tuscany.binding.ws.xml.WebServiceConstants;
 import org.apache.tuscany.interfacedef.Operation;
 import org.apache.tuscany.spi.component.TargetInvokerCreationException;
@@ -46,9 +47,14 @@
 public class Axis2WSReference extends ReferenceBindingExtension {
 
     private WorkContext workContext;
+    private WebServicePortMetaData wsPortMetaData;
+    private WebServiceBinding wsBinding;
+    private ServiceClient serviceClient;
 
-    public Axis2WSReference(URI name, URI targetUri) {
+    public Axis2WSReference(URI name, URI targetUri, WebServiceBinding wsBinding) {
         super(name, targetUri);
+        this.wsPortMetaData = new WebServicePortMetaData(wsBinding.getWSDLDefinition().getDefinition(),
wsBinding.getPort(), wsBinding.getURI(), false);
+        this.serviceClient = createServiceClient(wsBinding.getWSDLDefinition().getDefinition(),
wsPortMetaData);
     }
 
     public QName getBindingType() {
@@ -56,43 +62,45 @@
     }
 
     public TargetInvoker createTargetInvoker(String targetName, Operation operation, boolean
isCallback) throws TargetInvokerCreationException {
-        Options options = null;
-        SOAPFactory soapFactory = null;
-        QName wsdlOperationQName = null;
-        ServiceClient serviceClient = null;
-        Axis2TargetInvoker invoker = new Axis2TargetInvoker(serviceClient, wsdlOperationQName,
options, soapFactory, workContext);
-        return invoker;
+            boolean isOneWay = operation.isNonBlocking();
+            Axis2TargetInvoker invoker = createOperationInvoker(serviceClient, operation,
wsPortMetaData, false, isOneWay);
+            return invoker;
     }
 
     /**
      * Create an Axis2 ServiceClient
      */
-    private ServiceClient createServiceClient(Definition wsdlDefinition, WebServicePortMetaData
wsPortMetaData)
-        throws AxisFault {
+    protected ServiceClient createServiceClient(Definition wsdlDefinition, WebServicePortMetaData
wsPortMetaData) {
+        try {
 
-        TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator();
-        ConfigurationContext configurationContext = tuscanyAxisConfigurator.getConfigurationContext();
-        QName serviceQName = wsPortMetaData.getServiceName();
-        String portName = wsPortMetaData.getPortName().getLocalPart();
-        AxisService axisService =
-            AxisService.createClientSideAxisService(wsdlDefinition, serviceQName, portName,
new Options());
-        return new ServiceClient(configurationContext, axisService);
+            TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator();
+            ConfigurationContext configurationContext = tuscanyAxisConfigurator.getConfigurationContext();
+            QName serviceQName = wsPortMetaData.getServiceName();
+            String portName = wsPortMetaData.getPortName().getLocalPart();
+            AxisService axisService = AxisService.createClientSideAxisService(wsdlDefinition,
serviceQName, portName, new Options());
+
+            return new ServiceClient(configurationContext, axisService);
+
+        } catch (AxisFault e) {
+            throw new RuntimeException(e); // TODO: better exception
+        }
     }
 
     /**
      * Create and configure an Axis2TargetInvoker for each operations
      */
-    private Axis2TargetInvoker createOperationInvoker(ServiceClient serviceClient,
-                                                      Operation m,
+    protected Axis2TargetInvoker createOperationInvoker(ServiceClient serviceClient,
+                                                      Operation operation,
                                                       WebServicePortMetaData wsPortMetaData,
                                                       boolean hasCallback,
-                                                      boolean isOneWay) throws AxisFault
{
+                                                      boolean isOneWay) {
+
         SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
         String portTypeNS = wsPortMetaData.getPortTypeName().getNamespaceURI();
 
-        String methodName = m.getName();
+        String operationName = operation.getName();
 
-        WebServiceOperationMetaData operationMetaData = wsPortMetaData.getOperationMetaData(methodName);
+        WebServiceOperationMetaData operationMetaData = wsPortMetaData.getOperationMetaData(operationName);
 
         Options options = new Options();
         options.setTo(new EndpointReference(wsPortMetaData.getEndpoint()));
@@ -111,11 +119,9 @@
 
         Axis2TargetInvoker invoker;
         if (hasCallback) {
-            invoker =
-                new Axis2AsyncTargetInvoker(serviceClient, wsdlOperationQName, options, soapFactory,
workContext);
+            invoker = new Axis2AsyncTargetInvoker(serviceClient, wsdlOperationQName, options,
soapFactory, workContext);
         } else if (isOneWay) {
-            invoker =
-                new Axis2OneWayTargetInvoker(serviceClient, wsdlOperationQName, options,
soapFactory, workContext);
+            invoker = new Axis2OneWayTargetInvoker(serviceClient, wsdlOperationQName, options,
soapFactory, workContext);
         } else {
             invoker = new Axis2TargetInvoker(serviceClient, wsdlOperationQName, options,
soapFactory, workContext);
         }



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


Mime
View raw message