From 7aa399607671e79b5724cdc52a4a82bd9929c02e Mon Sep 17 00:00:00 2001 From: edwardsmj Date: Tue, 21 Dec 2010 11:42:38 +0000 Subject: Enable binding.sca to support async invocation in the local case - as under TUSCANY-3811 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1051467 13f79535-47bb-0310-9956-ffa450edef68 --- .../binding/sca/provider/SCABindingInvoker.java | 36 +++++++++++++++++----- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'sca-java-2.x/trunk/modules') diff --git a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java index a131c88a0c..8ea754c8fc 100644 --- a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java +++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java @@ -19,6 +19,7 @@ package org.apache.tuscany.sca.binding.sca.provider; +import org.apache.tuscany.sca.core.invocation.AsyncResponseInvoker; import org.apache.tuscany.sca.core.invocation.InterceptorAsyncImpl; import org.apache.tuscany.sca.databinding.Mediator; import org.apache.tuscany.sca.interfacedef.Operation; @@ -73,14 +74,24 @@ public class SCABindingInvoker extends InterceptorAsyncImpl { public Message processRequest(Message msg){ if (passByValue) { msg.setBody(mediator.copyInput(msg.getBody(), sourceOperation, targetOperation)); - } - + } // end if + ep.getInvocationChains(); if ( !ep.getCallbackEndpointReferences().isEmpty() ) { RuntimeEndpointReference asyncEPR = (RuntimeEndpointReference) ep.getCallbackEndpointReferences().get(0); // Place a link to the callback EPR into the message headers... msg.getHeaders().put("ASYNC_CALLBACK", asyncEPR ); - } + } // end if + + if( ep.isAsyncInvocation() ) { + // Get the message ID + String msgID = (String)msg.getHeaders().get("MESSAGE_ID"); + + // Create a response invoker and add it to the message headers + AsyncResponseInvoker respInvoker = + new AsyncResponseInvoker(ep, null, epr, msgID); + msg.getHeaders().put("ASYNC_RESPONSE_INVOKER", respInvoker); + } // end if return msg; } @@ -93,12 +104,23 @@ public class SCABindingInvoker extends InterceptorAsyncImpl { } else { if (sourceOperation.getOutputType() != null) { msg.setBody(mediator.copyOutput(msg.getBody(), sourceOperation, targetOperation)); - } - } - } + } // end if + } // end if + } // end if + + // Handle async response Relates_To message ID value + @SuppressWarnings("unchecked") + AsyncResponseInvoker respInvoker = + (AsyncResponseInvoker)msg.getHeaders().get("ASYNC_RESPONSE_INVOKER"); + if( respInvoker != null ) { + RuntimeEndpointReference responseEPR = respInvoker.getResponseTargetAddress(); + msg.setFrom(responseEPR); + String msgID = respInvoker.getRelatesToMsgID(); + msg.getHeaders().put("RELATES_TO", msgID); + } // end if return msg; - } + } // end method processResponse public boolean isLocalSCABIndingInvoker() { return true; -- cgit v1.2.3