From f5d98d5e2a84c66a931d877df4bb4c7bf851b376 Mon Sep 17 00:00:00 2001 From: slaws Date: Fri, 26 Aug 2011 12:41:11 +0000 Subject: TUSCANY-3932 - sample of how the structural URI could be passed over a remote binding (in this case binding.ws) and picked up on the service side in the binding.sca case. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1162090 13f79535-47bb-0310-9956-ffa450edef68 --- .../context/impl/CallbackServiceReferenceImpl.java | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'sca-java-2.x/trunk/modules/core') diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java index e10ecf178b..9dba10f605 100644 --- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java +++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java @@ -24,6 +24,7 @@ import java.util.List; import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.assembly.SCABinding; import org.apache.tuscany.sca.assembly.builder.BindingBuilder; import org.apache.tuscany.sca.assembly.builder.BuilderContext; import org.apache.tuscany.sca.context.CompositeContext; @@ -130,6 +131,26 @@ public class CallbackServiceReferenceImpl extends ServiceReferenceImpl { RuntimeEndpointReference epr = (RuntimeEndpointReference)endpointReference.clone(); epr.setTargetEndpoint(resolvedEndpoint); + // TUSCANY-3932 + // If it's the default binding then we're going to look the callback endpoint + // up in the registry. Most remote protocols, which may be used as delegates + // or binding.sca will deal in absolution callback address and send the + // callback enbdpoint strutural URL separately. In this case flip the binding + // back to the structure URL. + // TODO - all this creation of endpoints by the binding to represent callbacks + // is confusing. Code here will change if we tidy it up. + if (epr.getBinding().getType().equals(SCABinding.TYPE)){ + // assume that we're going to look up the callback endpoint in the + // registry + Message msgContext = ThreadMessageContext.getMessageContext(); + if (msgContext != null){ + String callbackEPURI = (String)msgContext.getHeaders().get("CALLBACK_EP_URI"); + if (callbackEPURI != null){ + resolvedEndpoint.setURI(callbackEPURI); + } + } + } +/* // TUSCANY-3932 // If the resolved endpoint has a binding with a absolute URI then assume // that URL has been passed in in the forward message and really treat it @@ -151,7 +172,7 @@ public class CallbackServiceReferenceImpl extends ServiceReferenceImpl { epr.setUnresolved(false); } } - +*/ return epr; } catch (CloneNotSupportedException e) { // will not happen -- cgit v1.2.3