diff options
author | edwardsmj <edwardsmj@13f79535-47bb-0310-9956-ffa450edef68> | 2010-12-21 11:42:38 +0000 |
---|---|---|
committer | edwardsmj <edwardsmj@13f79535-47bb-0310-9956-ffa450edef68> | 2010-12-21 11:42:38 +0000 |
commit | 7aa399607671e79b5724cdc52a4a82bd9929c02e (patch) | |
tree | e75de91bd8e9e07e5b9518c0715d88a8a3ac0592 /sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java | |
parent | 73b4ab12bdbb33822b709c5225145bfde66dde32 (diff) |
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
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java')
-rw-r--r-- | sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java | 36 |
1 files changed, 29 insertions, 7 deletions
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<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 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<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; |