diff options
3 files changed, 40 insertions, 0 deletions
diff --git a/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java index da85607ccb..b3ca4be92a 100644 --- a/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java +++ b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java @@ -100,6 +100,7 @@ public class JMSBinding implements Binding { private Map<String, Boolean> operationJMSDeliveryModes = new HashMap<String, Boolean>(); private Map<String, Long> operationJMSTimeToLives = new HashMap<String, Long>(); private Map<String, Integer> operationJMSPriorities = new HashMap<String, Integer>(); + private String jmsSelector; public JMSBinding() { super(); @@ -474,4 +475,11 @@ public class JMSBinding implements Binding { operationJMSPriorities.put(opName, p); } + public String getJMSSelector() { + return jmsSelector; + } + public void setJMSSelector(String jmsSelector) { + this.jmsSelector = jmsSelector; + } + } diff --git a/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java index b6ec04eeb8..8a0e1b1096 100644 --- a/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java +++ b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java @@ -237,6 +237,8 @@ public class JMSBindingProcessor implements StAXArtifactProcessor<JMSBinding> { parseHeaders(reader, jmsBinding); } else if ("operationProperties".equals(elementName)) { parseOperationProperties(reader, jmsBinding); + } else if ("subscriptionHeaders".equals(elementName)) { + parseSubscriptionHeaders (reader, jmsBinding); } reader.next(); break; @@ -625,6 +627,13 @@ public class JMSBindingProcessor implements StAXArtifactProcessor<JMSBinding> { } } + private void parseSubscriptionHeaders(XMLStreamReader reader, JMSBinding jmsBinding) { + String jmsSelector = reader.getAttributeValue(null, "JMSSelector"); + if (jmsSelector != null && jmsSelector.length() > 0) { + jmsBinding.setJMSSelector(jmsSelector); + } + } + /** * The validation rules for the JMS model are relatively complicated to they all live together here */ diff --git a/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java b/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java index 4f13ae78c3..86f2a8fce8 100644 --- a/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java +++ b/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java @@ -108,6 +108,19 @@ public class JMSBindingProcessorTestCase extends TestCase { + " </component>"
+ "</composite>";
+ private static final String SELECTOR =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:testQueue\" >"
+ + " <subscriptionHeaders JMSSelector=\"prop1 = 2\" />"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
private XMLInputFactory inputFactory;
private StAXArtifactProcessor<Object> staxProcessor;
private Monitor monitor;
@@ -185,4 +198,14 @@ public class JMSBindingProcessorTestCase extends TestCase { assertEquals(77, ((Integer)op2Props.get("intProp")).intValue());
}
+ public void testSubscriptionHeaders () throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(SELECTOR));
+
+ Composite composite = (Composite)staxProcessor.read(reader);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+
+ assertEquals("prop1 = 2", binding.getJMSSelector());
+ }
}
|