diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-05 11:56:21 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-05 11:56:21 +0000 |
commit | 3087674e655366810687d97fb6e86e2ef13a8e42 (patch) | |
tree | 48e8c74730253a33743f89ba46aab48438caf206 | |
parent | 1f0ee8be3a36865b39e7809d482300307b5e9de2 (diff) |
Add support for subscriptionHeaders to the jms binding model
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@682682 13f79535-47bb-0310-9956-ffa450edef68
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());
+ }
}
|