You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ed...@apache.org on 2010/12/21 12:42:39 UTC
svn commit: r1051467 -
/tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java
Author: edwardsmj
Date: Tue Dec 21 11:42:38 2010
New Revision: 1051467
URL: http://svn.apache.org/viewvc?rev=1051467&view=rev
Log:
Enable binding.sca to support async invocation in the local case - as under TUSCANY-3811
Modified:
tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java
Modified: tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java?rev=1051467&r1=1051466&r2=1051467&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java Tue Dec 21 11:42:38 2010
@@ -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 I
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<RuntimeEndpointReference> respInvoker =
+ new AsyncResponseInvoker<RuntimeEndpointReference>(ep, null, epr, msgID);
+ msg.getHeaders().put("ASYNC_RESPONSE_INVOKER", respInvoker);
+ } // end if
return msg;
}
@@ -93,12 +104,23 @@ public class SCABindingInvoker extends I
} 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<RuntimeEndpointReference> respInvoker =
+ (AsyncResponseInvoker<RuntimeEndpointReference>)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;