diff options
Diffstat (limited to '')
9 files changed, 315 insertions, 102 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListenerFactory.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListenerFactory.java index 1976d687b6..f829e15f04 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListenerFactory.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListenerFactory.java @@ -43,10 +43,8 @@ public class DefaultJMSServiceListenerFactory implements JMSServiceListenerFacto RuntimeComponentService service = (RuntimeComponentService) jmsSLD.getEndpoint().getService(); MessageListener listener = new DefaultServiceInvoker(jmsSLD.getEndpoint(), jmsSLD.getTargetBinding(), jmsSLD.getMessageFactory(), rf); - -// return new ASFListener(listener, service.getName(), service.isCallback(), jmsSLD.getJmsBinding(), workScheduler, rf); -// TODO: 2.x migration, service.isCallback() - return new DefaultJMSServiceListener(listener, service.getName(), false, jmsSLD.getJmsBinding(), workScheduler, rf); + + return new DefaultJMSServiceListener(listener, service.getName(), service.isForCallback(), jmsSLD.getJmsBinding(), workScheduler, rf); } catch (NamingException e) { throw new JMSBindingException(e); diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java index 610be6cc56..ff96f56759 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java @@ -29,6 +29,8 @@ 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.CallbackHandler; +import org.apache.tuscany.sca.core.invocation.Constants; import org.apache.tuscany.sca.core.invocation.InterceptorAsyncImpl; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.interfacedef.util.FaultException; @@ -274,6 +276,13 @@ public class RRBJMSBindingInvoker extends InterceptorAsyncImpl { if (tuscanyMsg.getFrom().getTargetEndpoint() != null) { if (tuscanyMsg.getFrom().getTargetEndpoint().getBinding() != null) { this.jmsBinding = (JMSBinding)tuscanyMsg.getFrom().getTargetEndpoint().getBinding(); + +/* TUSCANY-4011 - we could delay until this point until setting the callback destination + CallbackHandler callbackHandler = (CallbackHandler)tuscanyMsg.getHeaders().get(Constants.CALLBACK); + if (callbackHandler != null && callbackHandler.getCallbackTargetURI() != null){ + this.jmsBinding.setDestinationName(callbackHandler.getCallbackTargetURI()); + } +*/ requestDestination = lookupDestination(); } } diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java index 0dc137cf5e..549be1552d 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java @@ -126,11 +126,6 @@ public class TransportServiceInterceptor extends InterceptorAsyncImpl { from.setTargetEndpoint(fromEndpoint); from.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED); msg.setFrom(from); - Endpoint callbackEndpoint = assemblyFactory.createEndpoint(); - // binding is set into the callback endpoint in the CallbackDesitnationInterceptor - callbackEndpoint.setUnresolved(true); - from.setCallbackEndpoint(callbackEndpoint); - return msg; } // end method invokeRequest diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/CallbackDestinationInterceptor.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/CallbackDestinationInterceptor.java index 1bce6e8842..8eaa414ae3 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/CallbackDestinationInterceptor.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/CallbackDestinationInterceptor.java @@ -27,6 +27,8 @@ 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.CallbackHandler; +import org.apache.tuscany.sca.core.invocation.Constants; import org.apache.tuscany.sca.core.invocation.InterceptorAsyncImpl; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; @@ -81,15 +83,20 @@ public class CallbackDestinationInterceptor extends InterceptorAsyncImpl { if (!callbackdestName.startsWith("jms:jndi:")) { throw new JMSBindingException("message property " + JMSBindingConstants.CALLBACK_Q_PROPERTY + " does not start with 'jms:jndi:' found: " + callbackdestName); } else { - callbackdestName = callbackdestName.substring(9); - } // end if + callbackdestName = "jms:queue:" + callbackdestName.substring(9); + } } else { // If there is no Callback destination name header present, but the service is a callback, use the JMS ReplyTo header + // as per the spec this will override anything specified by the user in SCDL if (service.getInterfaceContract().getCallbackInterface() != null) { if ( ( jmsMsg.getJMSReplyTo() != null ) && msg.getOperation().isNonBlocking() ) { Destination replyTo = jmsMsg.getJMSReplyTo(); if (replyTo != null) { - callbackdestName = (replyTo instanceof Queue) ? ((Queue) replyTo).getQueueName() : ((Topic) replyTo).getTopicName(); + if (replyTo instanceof Queue){ + callbackdestName = "jms:queue:" + ((Queue) replyTo).getQueueName(); + } else { + callbackdestName = "jms:topic:" + ((Topic) replyTo).getTopicName(); + } } } // end if } // end if @@ -97,22 +104,7 @@ public class CallbackDestinationInterceptor extends InterceptorAsyncImpl { // Place the Callback destination name into the Callback EPRs for the service endpoint if (callbackdestName != null) { - 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); - // the "from" EPR model is created in the TransportServiceInterceptor - // not sure which this destination calculation is not performed - // there as well - msg.getFrom().getCallbackEndpoint().setBinding(callbackBinding); -// msg.getHeaders().put("CALLBACK_BINDING", callbackBinding); - } - } + msg.getHeaders().put(Constants.CALLBACK, new CallbackHandler(callbackdestName)); } // end if // Callback ID not used at present diff --git a/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java b/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java index d8e7b24a36..7d91df8e09 100644 --- a/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java +++ b/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java @@ -24,6 +24,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.StringTokenizer; import java.util.TreeSet; import javax.xml.namespace.QName; @@ -35,6 +36,9 @@ import org.apache.tuscany.sca.assembly.Extension; import org.apache.tuscany.sca.assembly.OperationSelector; import org.apache.tuscany.sca.assembly.OperationsConfigurator; import org.apache.tuscany.sca.assembly.WireFormat; +import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.monitor.Problem; +import org.apache.tuscany.sca.monitor.Problem.Severity; import org.apache.tuscany.sca.policy.ExtensionType; import org.apache.tuscany.sca.policy.Intent; import org.apache.tuscany.sca.policy.PolicySet; @@ -180,6 +184,11 @@ public class JMSBinding implements Binding, PolicySubject, OperationsConfigurato public void setURI(String uri) { this.uri = uri; + if (uri != null){ + parseURI(uri); + } else { + setDestinationName(null); + } } public String getName() { @@ -1108,5 +1117,52 @@ public class JMSBinding implements Binding, PolicySubject, OperationsConfigurato public List<Extension> getAttributeExtensions() { return attributeExtensions; } + + public void parseURI(String uri) { + JMSBinding jmsBinding = this; + if (uri == null || + !(uri.startsWith("jms:jndi:") || uri.startsWith("jms:queue:") || uri.startsWith("jms:topic:"))) { + return; + } + + int i = uri.indexOf('?'); + if (i >= 0) { + StringTokenizer st = new StringTokenizer(uri.substring(i+1),"&"); + while (st.hasMoreTokens()) { + String s = st.nextToken(); + if (s.startsWith("jndiConnectionFactoryName=")) { + jmsBinding.setConnectionFactoryName(s.substring(26)); + } else if (s.startsWith("deliveryMode=")) { + jmsBinding.setURIJMSDeliveryMode("persistent".equals(s.substring(13))); + } else if (s.startsWith("priority=")) { + jmsBinding.setURIJMSPriority(Integer.parseInt(s.substring(9))); + } else if (s.startsWith("timeToLive=")) { + jmsBinding.setURIJMSTimeToLive(Long.parseLong(s.substring(11))); + } else if (s.startsWith("selector='")) { + String selector = s.substring(10); + if (selector.startsWith("\"") || selector.startsWith("'")) { + selector = selector.substring(1, selector.length()); + } + if (selector.endsWith("\"") || selector.endsWith("'")) { + selector = selector.substring(0, selector.length() - 1); + } + jmsBinding.setURIJMSSelector(selector); + } else if (s.startsWith("type")) { + String type = s.substring(5); + jmsBinding.setJMSURIType(type); + } else { + return; + } + } + int j=uri.indexOf(':', 4); + jmsBinding.setDestinationName(uri.substring(j+1, i)); + jmsBinding.setDestinationType(uri.substring(4, j)); + } else { + int j=uri.indexOf(':', 4); + jmsBinding.setDestinationName(uri.substring(j+1)); + jmsBinding.setDestinationType(uri.substring(4, j)); + } + jmsBinding.setJMSURI(uri); + } } 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 61f9b7e2cb..b0561303a8 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 @@ -18,8 +18,9 @@ */ package org.apache.tuscany.sca.core.context.impl; -import java.net.URI; import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.assembly.Endpoint; @@ -29,28 +30,86 @@ import org.apache.tuscany.sca.assembly.builder.BindingBuilder; import org.apache.tuscany.sca.assembly.builder.BuilderContext; import org.apache.tuscany.sca.context.CompositeContext; import org.apache.tuscany.sca.context.ThreadMessageContext; +import org.apache.tuscany.sca.core.invocation.CallbackHandler; import org.apache.tuscany.sca.core.invocation.Constants; import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; import org.oasisopen.sca.ServiceRuntimeException; +/** + * Represent the reference to the callback service. This class basically wraps a Tuscany EndpointReference. + * The callback EPR is selected based on the are 3 basic scenarios we are trying to cater for + * + * A/ <component name="MyComponent"> + * <service name="MyService> + * blank OR <binding.sca/> + * </service> + * </component> + * + * B/ <component name="MyComponent"> + * <service name="MyService> + * <binding.someremotebinding/> + * </service> + * </component> + * + * C/ <component name="MyComponent"> + * <service name="MyService> + * some binding + * <callback> + * <binding.someremotebinding/> + * </callback> + * </service> + * </component> + * + * A - the callback binding will default to binding.sca and the expectation is that + * the callback endpoint will be established by looking it up in the registry + * hence the forward call must contain the SCA target name referring to the + * callback service + * + * B - the callback binding defaults to be the forward binding taking all of its + * configuration. The callback target URI is taken from the forward message and + * put into the callback binding URI + * + * C - the callback binding is as specified by the user. If the user has not specified + * a binding URI then the URI from the forward message will be placed in the + * callback binding URI. This may or may not lead to happiness depending on whether + * the forward and callback bindings are compatible + * + * The callback proxy, and this class, is instantiated whenever a new callback proxy is + * required as follows: + * + * If the service component implementation is STATELESS then each incoming message + * creates a new service instance and hence a new set of callback proxies + * + * If the service component implementation is COMPOSITE then only a single instance + * of the component implementation will exist and the callback proxy will be retrieved + * via the RequestContext. + * + * Following the Tuscany runtime model for normal references we don't cache callback + * proxies across component implementation instances. Hence there will be one + * instance of this class for each callback proxy, however created, and the class + * will refer to a single callback service. To put it another way, messages from + * multiple clients (presenting different callback services) will be called back to + * via different callback proxies and hence a single instance of this class will + * not be required to handle more than one callback address. + * + */ public class CallbackServiceReferenceImpl<B> extends ServiceReferenceImpl<B> { + private static final Logger logger = Logger.getLogger(CallbackServiceReferenceImpl.class.getName()); private RuntimeEndpointReference callbackEPR; private List<? extends EndpointReference> callbackEPRs; private Endpoint resolvedEndpoint; // Holds the ID of the Message that caused the creation of this CallbackServiceReference private String msgID; - - /** - * Gets the message ID associated with this callback reference - * @return the message ID - */ - public String getMsgID() { - return msgID; - } + + // Holds the URI of the target callback service from the Message that caused the + // creation of this CallbackServiceReference + private CallbackHandler callbackHandler; /* * Public constructor for Externalizable serialization/deserialization + * TODO - we need to serialize the msgID and callbackURI */ public CallbackServiceReferenceImpl() { super(); @@ -60,9 +119,69 @@ public class CallbackServiceReferenceImpl<B> extends ServiceReferenceImpl<B> { List<? extends EndpointReference> callbackEPRs) { super(interfaze, null, getCompositeContext(callbackEPRs)); this.callbackEPRs = callbackEPRs; - init(); + + Message msgContext = ThreadMessageContext.getMessageContext(); + + // Capture the Message ID from the message which caused the creation of this + // CallBackServiceReference + this.msgID = (String) msgContext.getHeaders().get(Constants.MESSAGE_ID); + + // Capture the callback URI from the message which caused the creation of this + // CallBackServiceReference. This code is more complex that needs be for the time being + // to cater for bindings that still use the approach of constructing a callback endpoint + // to model the callback URI. With these changes the binding can just set a CallbackHandler + // in the forward message to get the same effect. Some bindings don't do that hence + // the various checks + this.resolvedEndpoint = msgContext.getFrom().getCallbackEndpoint(); + if (resolvedEndpoint != null && resolvedEndpoint.getBinding() != null){ + if (resolvedEndpoint.getBinding().getType().equals(SCABinding.TYPE)){ + this.callbackHandler = new CallbackHandler(resolvedEndpoint.getURI()); + } else { + this.callbackHandler = new CallbackHandler(resolvedEndpoint.getBinding().getURI()); + } + } else { + this.callbackHandler = (CallbackHandler)msgContext.getHeaders().get(Constants.CALLBACK); + + if (callbackHandler == null){ + this.callbackHandler = new CallbackHandler(null); + } + } + + if (callbackHandler.getCallbackTargetURI() != null){ + logger.log(Level.FINE, "Selecting callback EPR using address from forward message: " + callbackHandler.getCallbackTargetURI()); + } else { + logger.log(Level.FINE, "Selecting callback EPR using address but callback URI is null"); + } + + // Work out which callback EPR to use + callbackEPR = selectCallbackEPR(msgContext); + if (callbackEPR == null) { + throw new ServiceRuntimeException("No callback binding found for " + msgContext.getTo().toString()); + } + + // configure the callback EPR with the callback address + if (callbackHandler.getCallbackTargetURI() != null) { + callbackEPR = setCallbackAddress(callbackEPR); + } + + this.resolvedEndpoint = callbackEPR.getTargetEndpoint(); + } + + public CallbackHandler getCallbackHandler() { + return callbackHandler; } + /** + * Gets the message ID associated with this callback reference. All calls through the proxy backed by + * this CallbackServiceReference will use the same msgID + * + * @return the message ID + */ + public String getMsgID() { + return msgID; + } + + private static CompositeContext getCompositeContext(List<? extends EndpointReference> callbackEPRs) { if(!callbackEPRs.isEmpty()) { RuntimeEndpointReference epr = (RuntimeEndpointReference) callbackEPRs.get(0); @@ -71,29 +190,13 @@ public class CallbackServiceReferenceImpl<B> extends ServiceReferenceImpl<B> { return null; } - public void init() { - Message msgContext = ThreadMessageContext.getMessageContext(); - callbackEPR = selectCallbackEPR(msgContext); - if (callbackEPR == null) { - throw new ServiceRuntimeException("No callback binding found for " + msgContext.getTo().toString()); - } - resolvedEndpoint = msgContext.getFrom().getCallbackEndpoint(); - - // Capture the Message ID from the message which caused the creation of this CallBackServiceReference - this.msgID = (String) msgContext.getHeaders().get(Constants.MESSAGE_ID); - } - @Override protected B createProxy() throws Exception { return proxyFactory.createCallbackProxy(this); } public RuntimeEndpointReference getCallbackEPR() { - if (resolvedEndpoint == null) { - return null; - } else { - return cloneAndBind(callbackEPR); - } + return callbackEPR; } public Endpoint getResolvedEndpoint() { @@ -101,6 +204,7 @@ public class CallbackServiceReferenceImpl<B> extends ServiceReferenceImpl<B> { } private RuntimeEndpointReference selectCallbackEPR(Message msgContext) { + // look for callback binding with same name as service binding Endpoint to = msgContext.getTo(); if (to == null) { @@ -124,56 +228,58 @@ public class CallbackServiceReferenceImpl<B> extends ServiceReferenceImpl<B> { return null; } - private RuntimeEndpointReference cloneAndBind(RuntimeEndpointReference endpointReference) { - if (resolvedEndpoint != null) { - - try { - RuntimeEndpointReference epr = (RuntimeEndpointReference)endpointReference.clone(); - epr.setTargetEndpoint(resolvedEndpoint); + private RuntimeEndpointReference setCallbackAddress(RuntimeEndpointReference endpointReference) { + try { + + RuntimeEndpointReference epr = endpointReference; + + if (callbackHandler.getCloneCallbackWire()){ + epr = (RuntimeEndpointReference)endpointReference.clone(); + } + + // 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 + // for binding.sca, will expect to deal with absolute URLs so flip the + // callback endpoint back to force the lookup to happen + if (epr.getBinding().getType().equals(SCABinding.TYPE)){ + // A/ create a callback endpoint to allow the + // callback lookup to take place + epr.setStatus(EndpointReference.Status.WIRED_TARGET_NOT_FOUND); + + // if an endpoint it provided in the forward message use it or + // if not create one + if (resolvedEndpoint == null ){ + RuntimeEndpoint callbackEndpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint(); + callbackEndpoint.setURI(callbackHandler.getCallbackTargetURI()); + callbackEndpoint.setUnresolved(true); + epr.setTargetEndpoint(callbackEndpoint); + } else { + epr.setTargetEndpoint(resolvedEndpoint); + } + } else { + // B/ and C/ assume that the callback EPR is already resolved + // and set the binding URI if one is provided with the + // forward message. Some bindings may want to do other + // things to determine the callback URI to the + // CallbackHandler will be sent in the callback message + // header. This is particularly true if the clone isn't + // called above because resetting the URI will not + // be thread safe. + epr.setStatus(EndpointReference.Status.RESOLVED_BINDING); - // 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 - // for binding.sca, will expect to deal with absolute URLs so flip the - // callback endpoint back to force the lookup to happen - if (epr.getBinding().getType().equals(SCABinding.TYPE)){ - epr.setStatus(EndpointReference.Status.WIRED_TARGET_NOT_FOUND); + if ( callbackHandler.getCallbackTargetURI() != null ){ + epr.getBinding().setURI(callbackHandler.getCallbackTargetURI()); } else { - // just copy the callback binding from the callback endpoint to the - // callback EPR as the EPR is effectively already resolved - epr.setStatus(EndpointReference.Status.RESOLVED_BINDING); - Binding callbackBinding = resolvedEndpoint.getBinding(); - if ( callbackBinding != null){ - epr.setBinding(callbackBinding); - // make sure that the chains are recreated for - // this new binding - epr.setBindingProvider(null); - epr.rebuild(); - } else { - // do nothing and rely on whatever the user has configured - // in the SCDL - } + // do nothing and rely on whatever the user has configured + // in the SCDL } - - return epr; - } catch (CloneNotSupportedException e) { - // will not happen - throw new ServiceRuntimeException(e); } - } else { - return null; - } - } - - private void build(EndpointReference endpointReference) { - BindingBuilder builder = builders.getBindingBuilder(endpointReference.getBinding().getType()); - if (builder != null) { - builder.build(endpointReference.getComponent(), - endpointReference.getReference(), - endpointReference.getBinding(), - new BuilderContext(registry), - false); + + return epr; + } catch (CloneNotSupportedException e) { + // will not happen + throw new ServiceRuntimeException(e); } - } - + } } diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackHandler.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackHandler.java new file mode 100644 index 0000000000..bccce0d20a --- /dev/null +++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackHandler.java @@ -0,0 +1,53 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.core.invocation;
+
+/**
+ * Models callback information arriving in the forward message
+ */
+public class CallbackHandler {
+ private String callbackTargetURI;
+ private boolean cloneCallbackWire = true;
+
+ public CallbackHandler(String callbackTargetURI){
+ setCallbackTargetURI(callbackTargetURI);
+ }
+
+ public CallbackHandler(String callbackTargetURI, boolean cloneCallbackWire){
+ setCallbackTargetURI(callbackTargetURI);
+ setCloneCallbackWire(cloneCallbackWire);
+ }
+
+ public String getCallbackTargetURI() {
+ return callbackTargetURI;
+ }
+
+ public boolean getCloneCallbackWire() {
+ return cloneCallbackWire;
+ }
+
+ public void setCallbackTargetURI(String callbackTargetURI) {
+ this.callbackTargetURI = callbackTargetURI;
+ }
+
+ public void setCloneCallbackWire(boolean cloneCallbackWire) {
+ this.cloneCallbackWire = cloneCallbackWire;
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/Constants.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/Constants.java index d84ef752ac..00c650ada6 100644 --- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/Constants.java +++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/Constants.java @@ -28,6 +28,7 @@ public interface Constants { public static final String RELATES_TO = "RELATES_TO";
public static final String ASYNC_RESPONSE_INVOKER = "ASYNC_RESPONSE_INVOKER";
public static final String ASYNC_CALLBACK = "ASYNC_CALLBACK";
+ public static final String CALLBACK = "CALLBACK";
/**
* If you've set the TCCL in your binding impl according to OASIS rules you can prevent
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java index c35b70ad74..bde3e92c27 100644 --- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java +++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java @@ -105,6 +105,9 @@ public class JDKCallbackInvocationHandler extends JDKInvocationHandler { msg.setTo(((RuntimeEndpointReference)source).getTargetEndpoint()); } } + + msg.getHeaders().put(Constants.CALLBACK, ((CallbackServiceReferenceImpl)callableReference).getCallbackHandler()); + Invoker headInvoker = chain.getHeadInvoker(); Operation operation = null; |