diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2008-09-16 14:51:24 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2008-09-16 14:51:24 +0000 |
commit | 109b9298884b8fb99af43dbcd912202e62ded87e (patch) | |
tree | b69933b97ed814bcd7acf0e671f776423e46bde0 /java/sca/modules/binding-jms-runtime/src | |
parent | 532c261558444c338d2d48391e7d543fee086746 (diff) |
Add in policies to support JMS message header setting. Also add in reliability intents. No policies or implementation changes to support these reliability intents here.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@695928 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/binding-jms-runtime/src')
-rw-r--r-- | java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java index 5d8053e02d..cfa099e875 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java @@ -35,6 +35,7 @@ import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; import org.apache.tuscany.sca.binding.jms.policy.authentication.token.JMSTokenAuthenticationPolicy; +import org.apache.tuscany.sca.binding.jms.policy.header.JMSHeaderPolicy; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.interfacedef.java.JavaInterface; import org.apache.tuscany.sca.invocation.DataExchangeSemantics; @@ -64,6 +65,7 @@ public class JMSBindingInvoker implements Invoker, DataExchangeSemantics { protected Destination bindingReplyDest; protected RuntimeComponentReference reference; protected JMSTokenAuthenticationPolicy jmsTokenAuthenticationPolicy = null; + protected JMSHeaderPolicy jmsHeaderPolicy = null; public JMSBindingInvoker(JMSBinding jmsBinding, Operation operation, JMSResourceFactory jmsResourceFactory, RuntimeComponentReference reference) { @@ -83,7 +85,9 @@ public class JMSBindingInvoker implements Invoker, DataExchangeSemantics { for (Object p : ps.getPolicies()) { if (JMSTokenAuthenticationPolicy.class.isInstance(p)) { jmsTokenAuthenticationPolicy = (JMSTokenAuthenticationPolicy)p; - }else { + }else if (JMSTokenAuthenticationPolicy.class.isInstance(p)) { + jmsHeaderPolicy = (JMSHeaderPolicy)p; + } else { // etc. check for other types of policy being present } } @@ -321,7 +325,15 @@ public class JMSBindingInvoker implements Invoker, DataExchangeSemantics { requestMessageProcessor.setOperationName(jmsBinding.getNativeOperationName(operationName), jmsMsg); - if (jmsBinding.getOperationJMSDeliveryMode(operationName) != null) { + if ((jmsHeaderPolicy != null) && + (jmsHeaderPolicy.getDeliveryModePersistent() != null)) { + if (jmsHeaderPolicy.getDeliveryModePersistent()) { + jmsMsg.setJMSDeliveryMode(DeliveryMode.PERSISTENT); + } else { + jmsMsg.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT); + } + + } else if (jmsBinding.getOperationJMSDeliveryMode(operationName) != null) { if (jmsBinding.getOperationJMSDeliveryMode(operationName)) { jmsMsg.setJMSDeliveryMode(DeliveryMode.PERSISTENT); } else { @@ -329,15 +341,24 @@ public class JMSBindingInvoker implements Invoker, DataExchangeSemantics { } } - if (jmsBinding.getOperationJMSCorrelationId(operationName) != null) { + if ((jmsHeaderPolicy != null) && + (jmsHeaderPolicy.getJmsCorrelationId() != null)) { + jmsMsg.setJMSCorrelationID(jmsHeaderPolicy.getJmsCorrelationId()); + } else if (jmsBinding.getOperationJMSCorrelationId(operationName) != null) { jmsMsg.setJMSCorrelationID(jmsBinding.getOperationJMSCorrelationId(operationName)); } - if (jmsBinding.getOperationJMSPriority(operationName) != null) { + if ((jmsHeaderPolicy != null) && + (jmsHeaderPolicy.getJmsPriority() != null)) { + jmsMsg.setJMSPriority(jmsHeaderPolicy.getJmsPriority()); + } else if (jmsBinding.getOperationJMSPriority(operationName) != null) { jmsMsg.setJMSPriority(jmsBinding.getOperationJMSPriority(operationName)); } - if (jmsBinding.getOperationJMSType(operationName) != null) { + if ((jmsHeaderPolicy != null) && + (jmsHeaderPolicy.getJmsType() != null)) { + jmsMsg.setJMSType(jmsHeaderPolicy.getJmsType()); + } else if (jmsBinding.getOperationJMSType(operationName) != null) { jmsMsg.setJMSType(jmsBinding.getOperationJMSType(operationName)); } @@ -360,6 +381,12 @@ public class JMSBindingInvoker implements Invoker, DataExchangeSemantics { } } + if (jmsHeaderPolicy != null){ + for (String propName : jmsHeaderPolicy.getProperties().keySet()) { + jmsMsg.setObjectProperty(propName, jmsHeaderPolicy.getProperties().get(propName)); + } + } + for (String propName : jmsBinding.getPropertyNames()) { Object value = jmsBinding.getProperty(propName); jmsMsg.setObjectProperty(propName, value); @@ -394,7 +421,10 @@ public class JMSBindingInvoker implements Invoker, DataExchangeSemantics { MessageConsumer consumer = session.createConsumer(replyToDest, msgSelector); long receiveWait; - if (jmsBinding.getOperationJMSTimeToLive(operationName) != null) { + if ((jmsHeaderPolicy != null) && + (jmsHeaderPolicy.getTimeToLive() != null)) { + receiveWait = jmsHeaderPolicy.getTimeToLive(); + } else if (jmsBinding.getOperationJMSTimeToLive(operationName) != null) { receiveWait = jmsBinding.getOperationJMSTimeToLive(operationName) * 2; } else { receiveWait = JMSBindingConstants.DEFAULT_TIME_TO_LIVE; |