You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2006/10/11 03:02:42 UTC

svn commit: r462653 - in /incubator/tuscany/java: samples/sca/helloworldws-async/src/main/java/helloworld/ sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/

Author: rfeng
Date: Tue Oct 10 18:02:41 2006
New Revision: 462653

URL: http://svn.apache.org/viewvc?view=rev&rev=462653
Log:
Apply a patch from Ignacio for the async ws

Modified:
    incubator/tuscany/java/samples/sca/helloworldws-async/src/main/java/helloworld/HelloWorldImpl.java
    incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java
    incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java
    incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java

Modified: incubator/tuscany/java/samples/sca/helloworldws-async/src/main/java/helloworld/HelloWorldImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/helloworldws-async/src/main/java/helloworld/HelloWorldImpl.java?view=diff&rev=462653&r1=462652&r2=462653
==============================================================================
--- incubator/tuscany/java/samples/sca/helloworldws-async/src/main/java/helloworld/HelloWorldImpl.java (original)
+++ incubator/tuscany/java/samples/sca/helloworldws-async/src/main/java/helloworld/HelloWorldImpl.java Tue Oct 10 18:02:41 2006
@@ -35,18 +35,15 @@
 
     @Callback
     public void setHelloWorldCallback(HelloWorldCallback helloWorldCallback) {
-        System.err.println("injecting @callback");
         this.helloWorldCallback = helloWorldCallback;
     }
 
     public String getGreetings(String name) {
-        System.out.println("In getGreetingsWithCallback, invoking callback");
         try {
-            helloWorldCallback.getGreetingsCallback("Alo " + name);
+            helloWorldCallback.getGreetingsCallback("Hola " + name);
         } catch (Throwable t) {
             t.printStackTrace();
         }
-        System.out.println("In getGreetingsWithCallback, invoked callback");
         return "This should not be seen";
     }
 
@@ -57,12 +54,10 @@
     }
 
     public void getGreetingsWithCallback(String name) {
-        System.out.println("In getGreetingsWithCallback, invoking callback: " + helloWorldCallback);
         try {
             helloWorldCallback.getGreetingsCallback("Alo " + name);
         } catch (Throwable t) {
             t.printStackTrace();
         }
-        System.out.println("In getGreetingsWithCallback, invoked callback");
     }
 }

Modified: incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java?view=diff&rev=462653&r1=462652&r2=462653
==============================================================================
--- incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java (original)
+++ incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java Tue Oct 10 18:02:41 2006
@@ -22,6 +22,7 @@
 import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.CountDownLatch;
 
 import javax.wsdl.Definition;
 import javax.wsdl.Operation;
@@ -266,13 +267,17 @@
         public org.apache.tuscany.spi.model.Operation<?> operation;
 
         public SOAPFactory soapFactory;
+        
+        public CountDownLatch doneSignal;
 
         public InvocationContext(MessageContext messageCtx,
                                  org.apache.tuscany.spi.model.Operation<?> operation,
-                                 SOAPFactory soapFactory) {
+                                 SOAPFactory soapFactory,
+                                 CountDownLatch doneSignal) {
             this.inMessageContext = messageCtx;
             this.operation = operation;
             this.soapFactory = soapFactory;
+            this.doneSignal = doneSignal;
         }
     }
 }

Modified: incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java?view=diff&rev=462653&r1=462652&r2=462653
==============================================================================
--- incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java (original)
+++ incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java Tue Oct 10 18:02:41 2006
@@ -64,6 +64,8 @@
             AxisEngine engine =
                 new AxisEngine(invCtx.inMessageContext.getOperationContext().getServiceContext().getConfigurationContext());
             engine.send(outMC);
+            
+            invCtx.doneSignal.countDown();
 
             service.removeMapping(this.currentCorrelationId);
         } catch (AxisFault e) {

Modified: incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java?view=diff&rev=462653&r1=462652&r2=462653
==============================================================================
--- incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java (original)
+++ incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java Tue Oct 10 18:02:41 2006
@@ -19,6 +19,7 @@
 package org.apache.tuscany.binding.axis2;
 
 import java.lang.reflect.InvocationTargetException;
+import java.util.concurrent.CountDownLatch;
 
 import org.apache.axiom.om.OMElement;
 import org.apache.axis2.AxisFault;
@@ -49,30 +50,6 @@
     public Axis2ServiceInOutAsyncMessageReceiver() {
     }
 
-    /*
-     * @Override public void invokeBusinessLogic(MessageContext inMC,
-     * MessageContext outMC) throws AxisFault { try { // Create a new message id
-     * and hand it to // JDKInboundInvocationHandler // via work context
-     * MessageId messageId = new MessageId();
-     * workContext.setCurrentMessageId(messageId); // Now use message id as
-     * index to context to be used by callback // target invoker
-     * InvocationContext invCtx = service.new InvocationContext(inMC, operation,
-     * getSOAPFactory(inMC)); service.addMapping(messageId, invCtx); OMElement
-     * requestOM = inMC.getEnvelope().getBody().getFirstElement(); Object[] args =
-     * new Object[] {requestOM}; // FIXME: It seems that the AsyncTargetInvoker
-     * always returns null OMElement responseOM =
-     * (OMElement)service.invokeTarget(operation, args); SOAPEnvelope
-     * soapEnvelope = getSOAPFactory(inMC).getDefaultEnvelope(); if (responseOM !=
-     * null) { soapEnvelope.getBody().addChild(responseOM); }
-     * outMC.setEnvelope(soapEnvelope);
-     * outMC.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN,
-     * Constants.VALUE_TRUE); } catch (InvocationTargetException e) { Throwable
-     * t = e.getCause(); if (t instanceof Exception) { throw
-     * AxisFault.makeFault((Exception)t); } throw new
-     * InvocationRuntimeException(e); } catch (Exception e) { throw
-     * AxisFault.makeFault(e); } }
-     */
-
     public final void receive(final MessageContext messageCtx) {
         try {
             // Create a new message id and hand it to
@@ -82,11 +59,18 @@
             workContext.setCurrentMessageId(messageId);
             // Now use message id as index to context to be used by callback
             // target invoker
+            CountDownLatch doneSignal = new CountDownLatch(1);
             InvocationContext invCtx =
-                service.new InvocationContext(messageCtx, operation, getSOAPFactory(messageCtx));
+                service.new InvocationContext(messageCtx, operation, getSOAPFactory(messageCtx), doneSignal);
             service.addMapping(messageId, invCtx);
 
             invokeBusinessLogic(messageCtx);
+            
+            try {
+                doneSignal.await();
+            } catch(InterruptedException e) {
+                e.printStackTrace();
+            }
         } catch (AxisFault e) {
             // log.error(e);
         }



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