From 9f501ca23162abcd3c4c632901a5515adac297ae Mon Sep 17 00:00:00 2001 From: rfeng Date: Fri, 15 May 2009 22:38:11 +0000 Subject: Adding support for element of binding base uri configuration git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@775370 13f79535-47bb-0310-9956-ffa450edef68 --- .../configuration/xml/NodeConfigurationProcessor.java | 17 ++++++++++++++++- .../xml/NodeConfigurationProcessorTestCase.java | 2 +- .../org/apache/tuscany/sca/node/configuration/node1.xml | 3 +++ 3 files changed, 20 insertions(+), 2 deletions(-) (limited to 'java') diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java index 889ea6f118..fb16cf461d 100644 --- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java +++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java @@ -57,6 +57,7 @@ public class NodeConfigurationProcessor extends BaseStAXArtifactProcessor implem private static final QName NODE = new QName(SCA11_TUSCANY_NS, "node"); private static final QName CONTRIBUTION = new QName(SCA11_TUSCANY_NS, "contribution"); private static final QName BINDING = new QName(SCA11_TUSCANY_NS, "binding"); + private static final QName BASE_URI = new QName(SCA11_TUSCANY_NS, "baseURI"); private static final QName DEPLOYMENT_COMPOSITE = new QName(SCA11_TUSCANY_NS, "deploymentComposite"); private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903"; @@ -100,6 +101,7 @@ public class NodeConfigurationProcessor extends BaseStAXArtifactProcessor implem NodeConfiguration node = null; ContributionConfiguration contribution = null; DeploymentComposite composite = null; + BindingConfiguration binding = null; // Skip to end element while (true) { @@ -117,7 +119,7 @@ public class NodeConfigurationProcessor extends BaseStAXArtifactProcessor implem contribution.setLocation(reader.getAttributeValue(null, "location")); node.getContributions().add(contribution); } else if (BINDING.equals(name)) { - BindingConfiguration binding = nodeConfigurationFactory.createBindingConfiguration(); + binding = nodeConfigurationFactory.createBindingConfiguration(); binding.setBindingType(getQName(reader, "name")); String baseURIs = reader.getAttributeValue(null, "baseURIs"); if (baseURIs != null) { @@ -133,6 +135,15 @@ public class NodeConfigurationProcessor extends BaseStAXArtifactProcessor implem if (contribution != null) { contribution.getDeploymentComposites().add(composite); } + } else if(BASE_URI.equals(name)) { + // We also support element + String baseURI = reader.getElementText(); + if (baseURI != null && binding != null) { + baseURI = baseURI.trim(); + binding.addBaseURI(baseURI); + } + // getElementText() moves the event to END_ELEMENT + continue; } else if (COMPOSITE.equals(name)) { /* Object model = processor.read(reader); @@ -155,6 +166,10 @@ public class NodeConfigurationProcessor extends BaseStAXArtifactProcessor implem return node; } else if (CONTRIBUTION.equals(name)) { contribution = null; + } else if (DEPLOYMENT_COMPOSITE.equals(name)) { + composite = null; + } else if (BINDING.equals(name)) { + binding = null; } } if (reader.hasNext()) { diff --git a/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessorTestCase.java b/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessorTestCase.java index 5f1f8373d4..f76aabe034 100644 --- a/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessorTestCase.java +++ b/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessorTestCase.java @@ -70,7 +70,7 @@ public class NodeConfigurationProcessorTestCase { XMLStreamWriter writer = xmlOutputFactory.createXMLStreamWriter(sw); processor.write(config, writer); writer.flush(); - // System.out.println(sw.toString()); + System.out.println(sw.toString()); } /** diff --git a/java/sca/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml b/java/sca/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml index 787cd68a60..40961a22b7 100644 --- a/java/sca/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml +++ b/java/sca/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml @@ -27,6 +27,9 @@ + + http://localhost:8080/jsonrpc + -- cgit v1.2.3