summaryrefslogtreecommitdiffstats
path: root/branches
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-02-06 14:38:46 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-02-06 14:38:46 +0000
commitbd73f180b9e90af262061cf2f329a6d8612d9c53 (patch)
treeae437700146c1b36626267e5c76f61d9b9a1c8cb /branches
parentf2769645b0d134a0518d583e7fd6e5899200edab (diff)
Add support for operation property properties to binding.jms
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@741575 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches')
-rw-r--r--branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java9
-rw-r--r--branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java46
-rw-r--r--branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java38
3 files changed, 78 insertions, 15 deletions
diff --git a/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java b/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java
index fcb640398d..e804d5058c 100644
--- a/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java
+++ b/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java
@@ -119,6 +119,8 @@ public class JMSBinding implements BindingRRB, PolicySetAttachPoint {
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 Map<String, Map<String, BindingProperty>> operationPropertiesProperties = new HashMap<String, Map<String,BindingProperty>>();
+
private String jmsSelector;
private String requestConnectionName;
private String responseConnectionName;
@@ -645,4 +647,11 @@ public class JMSBinding implements BindingRRB, PolicySetAttachPoint {
return responseConnectionFactoryProperties;
}
+ public Map<String, BindingProperty> getOperationPropertiesProperties(String opName) {
+ if (operationPropertiesProperties.get(opName)==null) {
+ operationPropertiesProperties.put(opName, new HashMap<String, BindingProperty>());
+ }
+ return operationPropertiesProperties.get(opName);
+ }
+
}
diff --git a/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java b/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java
index eb50c11843..b7540e804d 100644
--- a/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java
+++ b/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java
@@ -620,14 +620,24 @@ public class JMSBindingProcessor implements StAXArtifactProcessor<JMSBinding> {
case START_ELEMENT:
if (reader.getName().getLocalPart().equals("headers")) {
parseOperationHeaders(reader, jmsBinding, opName);
+ } else if (reader.getName().getLocalPart().equals("property")) {
+ jmsBinding.getOperationPropertiesProperties(opName).putAll(parseBindingProperties(reader));
}
- break;
+// break;
case END_ELEMENT:
- QName x = reader.getName();
- if (x.getLocalPart().equals("operationProperties")) {
- return;
- } else {
- error("UnexpectedResponseElement", reader, x.toString());
+ if (reader.isEndElement()) {
+ QName x = reader.getName();
+ if (x.getLocalPart().equals("headers")) {
+ break;
+ }
+ if (x.getLocalPart().equals("property")) {
+ break;
+ }
+ if (x.getLocalPart().equals("operationProperties")) {
+ return;
+ } else {
+ error("UnexpectedResponseElement", reader, x.toString());
+ }
}
}
}
@@ -723,18 +733,14 @@ public class JMSBindingProcessor implements StAXArtifactProcessor<JMSBinding> {
private Map<String, BindingProperty> parseBindingProperties(XMLStreamReader reader) throws XMLStreamException {
Map<String, BindingProperty> props = new HashMap<String, BindingProperty>();
+ if ("property".equals(reader.getName().getLocalPart())) {
+ processProperty(reader, props);
+ }
while (true) {
switch (reader.next()) {
case START_ELEMENT:
- String elementName = reader.getName().getLocalPart();
- if ("property".equals(elementName)) {
- String name = reader.getAttributeValue(null, "name");
- if (name == null || name.length() < 1) {
- error("InvalidPropertyElement", reader, elementName);
- }
- String type = reader.getAttributeValue(null, "type");
- String value = reader.getElementText();
- props.put(name, new BindingProperty(name, type, value));
+ if ("property".equals(reader.getName().getLocalPart())) {
+ processProperty(reader, props);
}
break;
case END_ELEMENT:
@@ -743,6 +749,16 @@ public class JMSBindingProcessor implements StAXArtifactProcessor<JMSBinding> {
}
}
+ private void processProperty(XMLStreamReader reader, Map<String, BindingProperty> props) throws XMLStreamException {
+ String name = reader.getAttributeValue(null, "name");
+ if (name == null || name.length() < 1) {
+ error("InvalidPropertyElement", reader);
+ }
+ String type = reader.getAttributeValue(null, "type");
+ String value = reader.getElementText();
+ props.put(name, new BindingProperty(name, type, value));
+ }
+
/**
* Preserve an existing public method. The method validate() is a legacy method
* that was called from reading am XML stream via the read(XMLStreamReader) method above.
diff --git a/branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java b/branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java
index b715d4997c..202666278f 100644
--- a/branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java
+++ b/branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java
@@ -274,6 +274,26 @@ public class JMSBindingProcessorTestCase extends TestCase {
+ " </component>"
+ "</composite>";
+ private static final String OP_PROPS_PROPS =
+ "<?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>"
+ + " <operationProperties name=\"op1\">"
+ + " <property name=\"xxx\" type=\"yyy\">"
+ + " some value text"
+ + " </property>"
+ + " <property name=\"two\">"
+ + " bla"
+ + " </property>"
+ + " </operationProperties >"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
private XMLInputFactory inputFactory;
private StAXArtifactProcessor<Object> staxProcessor;
private Monitor monitor;
@@ -502,4 +522,22 @@ public class JMSBindingProcessorTestCase extends TestCase {
assertEquals(null, bp2.getType());
assertEquals("bla", bp2.getValue().toString().trim());
}
+ public void testOperationPropertiesProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OP_PROPS_PROPS));
+
+ Composite composite = (Composite)staxProcessor.read(reader);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertNotNull(binding.getOperationPropertiesProperties("op1"));
+ assertEquals(2, binding.getOperationPropertiesProperties("op1").size());
+ BindingProperty bp = binding.getOperationPropertiesProperties("op1").get("xxx");
+ assertEquals("xxx", bp.getName());
+ assertEquals("yyy", bp.getType());
+ assertEquals("some value text", bp.getValue().toString().trim());
+ BindingProperty bp2 = binding.getOperationPropertiesProperties("op1").get("two");
+ assertEquals("two", bp2.getName());
+ assertEquals(null, bp2.getType());
+ assertEquals("bla", bp2.getValue().toString().trim());
+ }
}