diff options
author | bdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68> | 2010-09-08 00:18:50 +0000 |
---|---|---|
committer | bdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68> | 2010-09-08 00:18:50 +0000 |
commit | 1315e46609bf6beb0c275c59176c846c17b3c614 (patch) | |
tree | b1366a4d3eca86b7d384459953a6cd9774d18688 /sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org | |
parent | 27e3cec43d8effa06ba8710907e416539b332096 (diff) |
TUSCANY-3673 Update JMS binding model to separate out type/priority/deliveryMode/timeToLive attributes originating from the uri, operation prop headers, and headers. Also use that information in the runtime to correctly determine the value that is used when more than one is specified.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@993564 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org')
3 files changed, 61 insertions, 67 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderReferenceInterceptor.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderReferenceInterceptor.java index 9afce4243d..8f8c27a135 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderReferenceInterceptor.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderReferenceInterceptor.java @@ -28,7 +28,6 @@ import javax.jms.Destination; import javax.jms.JMSException; import javax.naming.NamingException; -import org.apache.tuscany.sca.assembly.WireFormat; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.JMSBindingException; @@ -53,22 +52,15 @@ public class HeaderReferenceInterceptor implements Interceptor { private Invoker next; private RuntimeEndpointReference runtimeWire; - private JMSResourceFactory jmsResourceFactory; private JMSBinding jmsBinding; private JMSMessageProcessor requestMessageProcessor; - private JMSMessageProcessor responseMessageProcessor; - private String correlationScheme; - private WireFormat requestWireFormat; - private WireFormat responseWireFormat; + public HeaderReferenceInterceptor(ExtensionPointRegistry extensions, JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeEndpointReference runtimeWire) { super(); this.jmsBinding = jmsBinding; - this.runtimeWire = runtimeWire; - this.jmsResourceFactory = jmsResourceFactory; - this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(extensions, jmsBinding); - this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(extensions, jmsBinding); - this.correlationScheme = jmsBinding.getCorrelationScheme(); + this.runtimeWire = runtimeWire; + this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(extensions, jmsBinding); } @@ -92,25 +84,31 @@ public class HeaderReferenceInterceptor implements Interceptor { // @nativeOperation here on the reference side. requestMessageProcessor.setOperationName(operationName, jmsMsg); - if (jmsBinding.getOperationJMSDeliveryMode(operationName) != null) { - if (jmsBinding.getOperationJMSDeliveryMode(operationName)) { - jmsMsg.setJMSDeliveryMode(DeliveryMode.PERSISTENT); - } else { - jmsMsg.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT); - } - } - - if (jmsBinding.getOperationJMSCorrelationId(operationName) != null) { - jmsMsg.setJMSCorrelationID(jmsBinding.getOperationJMSCorrelationId(operationName)); - } + + + if (jmsBinding.getEffectiveJMSDeliveryMode(operationName) != null) { + if (jmsBinding.getEffectiveJMSDeliveryMode(operationName)) { + jmsMsg.setJMSDeliveryMode(DeliveryMode.PERSISTENT); + } else { + jmsMsg.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT); + } + } - if (jmsBinding.getOperationJMSPriority(operationName) != null) { - jmsMsg.setJMSPriority(jmsBinding.getOperationJMSPriority(operationName)); - } + if (jmsBinding.getEffectiveJMSPriority(operationName) != null) { + jmsMsg.setJMSPriority(jmsBinding.getEffectiveJMSPriority(operationName)); + } - if (jmsBinding.getOperationJMSType(operationName) != null) { - jmsMsg.setJMSType(jmsBinding.getOperationJMSType(operationName)); + if ( jmsBinding.getEffectiveJMSType(operationName) != null ) { + jmsMsg.setJMSType(jmsBinding.getEffectiveJMSType(operationName)); + } + + if ( jmsBinding.getEffectiveJMSTimeToLive(operationName) != null ) { + jmsMsg.setJMSExpiration(jmsBinding.getEffectiveJMSTimeToLive(operationName)); } + + if (jmsBinding.getOperationJMSCorrelationId(operationName) != null) { + jmsMsg.setJMSCorrelationID(jmsBinding.getOperationJMSCorrelationId(operationName)); + } if (tuscanyMsg.getFrom().getCallbackEndpoint() != null) { @@ -137,11 +135,11 @@ public class HeaderReferenceInterceptor implements Interceptor { } } - if (jmsBinding.getOperationJMSTimeToLive(operationName) != null) { - context.setTimeToLive(jmsBinding.getOperationJMSTimeToLive(operationName) * 2); + if (jmsBinding.getEffectiveJMSTimeToLive(operationName) != null) { + context.setTimeToLive(jmsBinding.getEffectiveJMSTimeToLive(operationName) * 2); } else { context.setTimeToLive(JMSBindingConstants.DEFAULT_TIME_TO_LIVE); - } + } return tuscanyMsg; } catch (JMSException e) { diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java index 9668333ebd..6681870612 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java @@ -18,6 +18,7 @@ */ package org.apache.tuscany.sca.binding.jms.transport; +import javax.jms.DeliveryMode; import javax.jms.JMSException; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; @@ -41,15 +42,13 @@ import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; */ public class TransportReferenceInterceptor implements Interceptor { - private Invoker next; - private RuntimeEndpointReference runtimeWire; + private Invoker next; private JMSResourceFactory jmsResourceFactory; private JMSBinding jmsBinding; public TransportReferenceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeEndpointReference runtimeWire) { super(); - this.jmsBinding = jmsBinding; - this.runtimeWire = runtimeWire; + this.jmsBinding = jmsBinding; this.jmsResourceFactory = jmsResourceFactory; } @@ -78,20 +77,20 @@ public class TransportReferenceInterceptor implements Interceptor { // Set JMS header attributes in producer, not message. String opName = msg.getOperation().getName(); - if (jmsBinding.getOperationJMSTimeToLive(msg.getOperation().getName()) != null) { - producer.setTimeToLive(jmsBinding.getOperationJMSTimeToLive(msg.getOperation().getName())); - } - Integer priority = jmsBinding.getOperationJMSPriority( opName ); + if (jmsBinding.getEffectiveJMSTimeToLive(opName) != null) { + producer.setTimeToLive(jmsBinding.getEffectiveJMSTimeToLive(msg.getOperation().getName()).longValue()); + } + + Integer priority = jmsBinding.getEffectiveJMSPriority(opName); if (priority != null) { - producer.setPriority(priority.intValue()); + producer.setPriority(priority.intValue()); } - Boolean deliveryModePersistent = jmsBinding.getOperationJMSDeliveryMode(opName); + + Boolean deliveryModePersistent = jmsBinding.getEffectiveJMSDeliveryMode(opName); if (deliveryModePersistent != null) { - if (deliveryModePersistent.booleanValue()) - producer.setDeliveryMode(javax.jms.DeliveryMode.PERSISTENT); - else - producer.setDeliveryMode(javax.jms.DeliveryMode.NON_PERSISTENT); - } + producer.setDeliveryMode( deliveryModePersistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT); + } + try { producer.send((javax.jms.Message)msg.getBody()); 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 4ba33695e4..d371bbba86 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 @@ -54,11 +54,9 @@ import org.apache.tuscany.sca.runtime.RuntimeEndpoint; public class TransportServiceInterceptor implements Interceptor { private static final Logger logger = Logger.getLogger(TransportServiceInterceptor.class.getName()); - private Invoker next; - private RuntimeEndpoint endpoint; + private Invoker next; private JMSResourceFactory jmsResourceFactory; - private JMSBinding jmsBinding; - private JMSMessageProcessor requestMessageProcessor; + private JMSBinding jmsBinding; private JMSMessageProcessor responseMessageProcessor; private RuntimeComponentService service; private String correlationScheme; @@ -67,10 +65,8 @@ public class TransportServiceInterceptor implements Interceptor { public TransportServiceInterceptor(ExtensionPointRegistry registry, JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeEndpoint endpoint) { super(); - this.jmsBinding = jmsBinding; - this.endpoint = endpoint; - this.jmsResourceFactory = jmsResourceFactory; - this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding); + this.jmsBinding = jmsBinding; + this.jmsResourceFactory = jmsResourceFactory; this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding); this.service = (RuntimeComponentService)endpoint.getService(); this.correlationScheme = jmsBinding.getCorrelationScheme(); @@ -100,9 +96,7 @@ public class TransportServiceInterceptor implements Interceptor { } public Message invokeRequest(Message msg) { -// try { - JMSBindingContext context = msg.getBindingContext(); - javax.jms.Message requestJMSMsg = context.getJmsMsg(); +// try { EndpointReference from = assemblyFactory.createEndpointReference(); Endpoint fromEndpoint = assemblyFactory.createEndpoint(); @@ -153,21 +147,22 @@ public class TransportServiceInterceptor implements Interceptor { return msg; } - if (msg.getOperation() != null) { + if ((msg.getOperation() != null)) { String operationName = msg.getOperation().getName(); - if (jmsBinding.getOperationJMSPriority(operationName) != null) { - responseJMSMsg.setJMSPriority(jmsBinding.getOperationJMSPriority(operationName)); + if (jmsBinding.getEffectiveJMSPriority(operationName) != null) { + responseJMSMsg.setJMSPriority(jmsBinding.getEffectiveJMSPriority(operationName)); } - if (jmsBinding.getOperationJMSType(operationName) != null) { - responseJMSMsg.setJMSType(jmsBinding.getOperationJMSType(operationName)); + if ( jmsBinding.getEffectiveJMSType(operationName) != null) { + responseJMSMsg.setJMSType(jmsBinding.getEffectiveJMSType(operationName)); } - if (jmsBinding.getOperationJMSDeliveryMode(operationName) != null) { - if (jmsBinding.getOperationJMSDeliveryMode(operationName)) { - responseJMSMsg.setJMSDeliveryMode(DeliveryMode.PERSISTENT); - } else { - responseJMSMsg.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT); - } + + if ((jmsBinding.getEffectiveJMSDeliveryMode(operationName) != null)) { + responseJMSMsg.setJMSDeliveryMode(jmsBinding.getEffectiveJMSDeliveryMode(operationName) ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT); + } + + if ((jmsBinding.getEffectiveJMSTimeToLive(operationName) != null)) { + responseJMSMsg.setJMSExpiration(jmsBinding.getEffectiveJMSTimeToLive(operationName).longValue()); } } @@ -185,6 +180,8 @@ public class TransportServiceInterceptor implements Interceptor { producer.setDeliveryMode(deliveryMode); int deliveryPriority = requestJMSMsg.getJMSPriority(); producer.setPriority(deliveryPriority); + long timeToLive = requestJMSMsg.getJMSExpiration(); + producer.setTimeToLive(timeToLive); producer.send((javax.jms.Message)msg.getBody()); |