Author: antelder
Date: Mon Sep 12 12:56:21 2011
New Revision: 1169722

URL: http://svn.apache.org/viewvc?rev=1169722&view=rev
Log:
Fix the setting of the JMS callback destination from request properties for the 
JMS binding

Modified:
    
tuscany/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/CallbackDestinationInterceptor.java
    
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java

Modified: 
tuscany/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/CallbackDestinationInterceptor.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/CallbackDestinationInterceptor.java?rev=1169722&r1=1169721&r2=1169722&view=diff
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/CallbackDestinationInterceptor.java
 (original)
+++ 
tuscany/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/CallbackDestinationInterceptor.java
 Mon Sep 12 12:56:21 2011
@@ -18,25 +18,23 @@
  */
 package org.apache.tuscany.sca.binding.jms.wire;
 
-import java.util.List;
-
 import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.Queue;
 import javax.jms.Topic;
 
-import org.apache.tuscany.sca.assembly.EndpointReference;
 import org.apache.tuscany.sca.binding.jms.JMSBinding;
 import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
 import org.apache.tuscany.sca.binding.jms.JMSBindingException;
 import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
 import org.apache.tuscany.sca.core.invocation.InterceptorAsyncImpl;
-import org.apache.tuscany.sca.invocation.Interceptor;
 import org.apache.tuscany.sca.invocation.Invoker;
 import org.apache.tuscany.sca.invocation.Message;
 import org.apache.tuscany.sca.runtime.RuntimeComponentService;
 import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
 
+import org.apache.tuscany.sca.assembly.Binding;
+
 /**
  * JMS Binding Interceptor class that deals with a callback destination 
address on the service side
  *
@@ -99,13 +97,25 @@ public class CallbackDestinationIntercep
                 
             // Place the Callback destination name into the Callback EPRs for 
the service endpoint
             if (callbackdestName != null) {
-               List<EndpointReference> refs = 
endpoint.getCallbackEndpointReferences();
-               for (EndpointReference ref : refs ) {
-                       if  (ref.getBinding() instanceof JMSBinding ) {
-                               JMSBinding callbackBinding = (JMSBinding) 
ref.getBinding();
-                               
callbackBinding.setDestinationName(callbackdestName);
-                       } // end if
-               } // end for
+                for (Binding b : service.getCallback().getBindings()) {
+                    if (b instanceof JMSBinding) {
+                        JMSBinding callbackBinding;
+                        try {
+                            callbackBinding = 
(JMSBinding)((JMSBinding)b).clone();
+                        } catch (CloneNotSupportedException e) {
+                            throw new RuntimeException(e);
+                        }
+                        callbackBinding.setDestinationName(callbackdestName);
+                        msg.getHeaders().put("CALLBACK_BINDING", 
callbackBinding);
+                    }
+                }
+//             List<EndpointReference> refs = 
endpoint.getCallbackEndpointReferences();
+//             for (EndpointReference ref : refs ) {
+//                     if  (ref.getBinding() instanceof JMSBinding ) {
+//                             JMSBinding callbackBinding = (JMSBinding) 
ref.getBinding();
+//                             
callbackBinding.setDestinationName(callbackdestName);
+//                     } // end if
+//             } // end for
             } // end if  
 
 // Callback ID not used at present            

Modified: 
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java?rev=1169722&r1=1169721&r2=1169722&view=diff
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java
 (original)
+++ 
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java
 Mon Sep 12 12:56:21 2011
@@ -150,7 +150,20 @@ public class CallbackServiceReferenceImp
                         }
                     }
                 }
-/*                
+
+                // This is used by the JMS binding to enable setting the JMS 
callback destination from the
+                // request, see CallbackDestinationInterceptor in the JMS 
binding module. It gets the JMS
+                // compliance tests passing again but doesn't seem like the 
perfect fix, when the changes
+                // mentioned below for TUSCANY-3932 happen it should fix this 
properly.
+                Message msgContext = ThreadMessageContext.getMessageContext();
+                if (msgContext != null){
+                    Binding b = 
(Binding)msgContext.getHeaders().get("CALLBACK_BINDING");
+                    if (b != null) {
+                        endpointReference.setBinding(b);
+                    }
+                }
+                
+                /*                
                 // 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


Reply via email to