Author: rfeng
Date: Wed May 13 00:09:21 2009
New Revision: 774146
URL: http://svn.apache.org/viewvc?rev=774146&view=rev
Log:
Add the StAX processor for NodeConfiguration
Added:
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/
- copied from r773715,
tuscany/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/xml/
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/XMLStreamSerializer.java
tuscany/java/sca/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
tuscany/java/sca/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory
tuscany/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/configuration/
tuscany/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/configuration/xml/
tuscany/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessorTestCase.java
tuscany/java/sca/modules/node-impl/src/test/resources/org/
tuscany/java/sca/modules/node-impl/src/test/resources/org/apache/
tuscany/java/sca/modules/node-impl/src/test/resources/org/apache/tuscany/
tuscany/java/sca/modules/node-impl/src/test/resources/org/apache/tuscany/sca/
tuscany/java/sca/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/
tuscany/java/sca/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/
- copied from r773611,
tuscany/java/sca/modules/implementation-node/src/test/resources/org/apache/tuscany/sca/node/configuration/
tuscany/java/sca/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml
- copied, changed from r773715,
tuscany/java/sca/modules/implementation-node/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml
Removed:
tuscany/java/sca/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node2.xml
Modified:
tuscany/java/sca/modules/node-impl/META-INF/MANIFEST.MF
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java
Modified: tuscany/java/sca/modules/node-impl/META-INF/MANIFEST.MF
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl/META-INF/MANIFEST.MF?rev=774146&r1=774145&r2=774146&view=diff
==============================================================================
--- tuscany/java/sca/modules/node-impl/META-INF/MANIFEST.MF (original)
+++ tuscany/java/sca/modules/node-impl/META-INF/MANIFEST.MF Wed May 13 00:09:21
2009
@@ -34,6 +34,7 @@
org.apache.tuscany.sca.definitions.xml;version="2.0.0",
org.apache.tuscany.sca.monitor;version="2.0.0",
org.apache.tuscany.sca.node;version="2.0.0",
+ org.apache.tuscany.sca.node.configuration;version="2.0.0",
org.apache.tuscany.sca.node.impl;version="2.0.0",
org.apache.tuscany.sca.policy;version="2.0.0",
org.apache.tuscany.sca.provider;version="2.0.0",
Modified:
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java?rev=774146&r1=773715&r2=774146&view=diff
==============================================================================
---
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java
(original)
+++
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java
Wed May 13 00:09:21 2009
@@ -20,16 +20,18 @@
import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import java.io.StringReader;
+import java.io.StringWriter;
import java.util.StringTokenizer;
import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import
org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
@@ -61,15 +63,17 @@
private static final QName COMPOSITE = new QName(SCA11_NS, "composite");
private StAXArtifactProcessor processor;
- private AssemblyFactory assemblyFactory;
private NodeConfigurationFactory nodeConfigurationFactory;
+ private XMLInputFactory xmlInputFactory;
+ private XMLOutputFactory xmlOutputFactory;
public NodeConfigurationProcessor(FactoryExtensionPoint modelFactories,
StAXArtifactProcessor processor,
Monitor monitor) {
- this.assemblyFactory =
modelFactories.getFactory(AssemblyFactory.class);
this.nodeConfigurationFactory =
modelFactories.getFactory(NodeConfigurationFactory.class);
this.processor = processor;
+ this.xmlInputFactory =
modelFactories.getFactory(XMLInputFactory.class);
+ this.xmlOutputFactory =
modelFactories.getFactory(XMLOutputFactory.class);
}
public QName getArtifactType() {
@@ -121,10 +125,18 @@
contribution.getDeploymentComposites().add(composite);
}
} else if (COMPOSITE.equals(name)) {
+ /*
Object model = processor.read(reader);
if (model instanceof Composite) {
- composite.setComposite((Composite)model);
+ // FIXME: We need to capture the text here
+ // composite.setComposite((Composite)model);
}
+ */
+ StringWriter sw = new StringWriter();
+ XMLStreamWriter writer =
xmlOutputFactory.createXMLStreamWriter(sw);
+ new XMLStreamSerializer().serialize(reader, writer);
+ writer.flush();
+ composite.setContent(sw.toString());
}
break;
@@ -164,6 +176,20 @@
CONTRIBUTION.getLocalPart(),
new XAttr("uri", c.getURI()),
new XAttr("location", c.getLocation()));
+ for (DeploymentComposite dc : c.getDeploymentComposites()) {
+ writeStart(writer,
+ DEPLOYMENT_COMPOSITE.getNamespaceURI(),
+ DEPLOYMENT_COMPOSITE.getLocalPart(),
+ new XAttr("location", dc.getLocation()),
+ new XAttr("contribution", dc.getContributionURI()));
+ if (dc.getContent() != null) {
+ XMLStreamReader reader =
xmlInputFactory.createXMLStreamReader(new StringReader(dc.getContent()));
+ reader.nextTag(); // Move to the first element
+ new XMLStreamSerializer().serialize(reader, writer);
+ reader.close();
+ }
+ writeEnd(writer);
+ }
writeEnd(writer);
}
Added:
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/XMLStreamSerializer.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/XMLStreamSerializer.java?rev=774146&view=auto
==============================================================================
---
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/XMLStreamSerializer.java
(added)
+++
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/XMLStreamSerializer.java
Wed May 13 00:09:21 2009
@@ -0,0 +1,287 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.node.configuration.xml;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * The XMLStreamSerializer pulls events from the XMLStreamReader and dumps
into the XMLStreamWriter
+ *
+ * @version $Rev: 656146 $ $Date: 2008-05-14 01:22:08 -0700 (Wed, 14 May 2008)
$
+ */
+public class XMLStreamSerializer implements XMLStreamConstants {
+ public static final String NAMESPACE_PREFIX = "ns";
+ private static int namespaceSuffix;
+
+ /*
+ * The behavior of the Serializer is such that it returns when it
encounters the starting element for the second
+ * time. The depth variable tracks the depth of the Serializer and tells
it when to return. Note that it is assumed
+ * that this Serialization starts on an Element.
+ */
+
+ /**
+ * Field depth
+ */
+ private int depth;
+
+ /**
+ * Generates a unique namespace prefix that is not in the scope of the
NamespaceContext
+ *
+ * @param nsCtxt
+ * @return string
+ */
+ private String generateUniquePrefix(NamespaceContext nsCtxt) {
+ String prefix = NAMESPACE_PREFIX + namespaceSuffix++;
+ // null should be returned if the prefix is not bound!
+ while (nsCtxt.getNamespaceURI(prefix) != null) {
+ prefix = NAMESPACE_PREFIX + namespaceSuffix++;
+ }
+
+ return prefix;
+ }
+
+ /**
+ * Method serialize.
+ *
+ * @param node
+ * @param writer
+ * @throws XMLStreamException
+ */
+ public void serialize(XMLStreamReader node, XMLStreamWriter writer) throws
XMLStreamException {
+ serializeNode(node, writer);
+ }
+
+ /**
+ * @param reader
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeAttributes(XMLStreamReader reader, XMLStreamWriter
writer) throws XMLStreamException {
+ int count = reader.getAttributeCount();
+ String prefix;
+ String namespaceName;
+ String writerPrefix;
+ for (int i = 0; i < count; i++) {
+ prefix = reader.getAttributePrefix(i);
+ namespaceName = reader.getAttributeNamespace(i);
+ /*
+ * Due to parser implementations returning null as the namespace
URI (for the empty namespace) we need to
+ * make sure that we deal with a namespace name that is not null.
The best way to work around this issue is
+ * to set the namespace URI to "" if it is null
+ */
+ if (namespaceName == null) {
+ namespaceName = "";
+ }
+
+ writerPrefix = writer.getPrefix(namespaceName);
+
+ if (!"".equals(namespaceName)) {
+ // prefix has already being declared but this particular
+ // attrib has a
+ // no prefix attached. So use the prefix provided by the
+ // writer
+ if (writerPrefix != null && (prefix == null ||
prefix.equals(""))) {
+ writer.writeAttribute(writerPrefix, namespaceName,
reader.getAttributeLocalName(i), reader
+ .getAttributeValue(i));
+
+ // writer prefix is available but different from the
+ // current
+ // prefix of the attrib. We should be declaring the new
+ // prefix
+ // as a namespace declaration
+ } else if (prefix != null && !"".equals(prefix) &&
!prefix.equals(writerPrefix)) {
+ writer.writeNamespace(prefix, namespaceName);
+ writer.writeAttribute(prefix, namespaceName,
reader.getAttributeLocalName(i), reader
+ .getAttributeValue(i));
+
+ // prefix is null (or empty), but the namespace name is
+ // valid! it has not
+ // being written previously also. So we need to generate
+ // a prefix
+ // here
+ } else if (prefix == null || prefix.equals("")) {
+ prefix =
generateUniquePrefix(writer.getNamespaceContext());
+ writer.writeNamespace(prefix, namespaceName);
+ writer.writeAttribute(prefix, namespaceName,
reader.getAttributeLocalName(i), reader
+ .getAttributeValue(i));
+ } else {
+ writer.writeAttribute(prefix, namespaceName,
reader.getAttributeLocalName(i), reader
+ .getAttributeValue(i));
+ }
+ } else {
+ // empty namespace is equal to no namespace!
+ writer.writeAttribute(reader.getAttributeLocalName(i),
reader.getAttributeValue(i));
+ }
+
+ }
+ }
+
+ /**
+ * Method serializeCData.
+ *
+ * @param reader
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeCData(XMLStreamReader reader, XMLStreamWriter
writer) throws XMLStreamException {
+ writer.writeCData(reader.getText());
+ }
+
+ /**
+ * Method serializeComment.
+ *
+ * @param reader
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeComment(XMLStreamReader reader, XMLStreamWriter
writer) throws XMLStreamException {
+ writer.writeComment(reader.getText());
+ }
+
+ /**
+ * @param reader
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeElement(XMLStreamReader reader, XMLStreamWriter
writer) throws XMLStreamException {
+ String prefix = reader.getPrefix();
+ String nameSpaceName = reader.getNamespaceURI();
+ if (nameSpaceName != null) {
+ String writerPrefix = writer.getPrefix(nameSpaceName);
+ if (writerPrefix != null) {
+ writer.writeStartElement(nameSpaceName, reader.getLocalName());
+ } else {
+ if (prefix != null) {
+ writer.writeStartElement(prefix, reader.getLocalName(),
nameSpaceName);
+ writer.writeNamespace(prefix, nameSpaceName);
+ // writer.setPrefix(prefix, nameSpaceName);
+ } else {
+ // [rfeng] We need to set default NS 1st before calling
writeStateElement
+ writer.setDefaultNamespace(nameSpaceName);
+ writer.writeStartElement(nameSpaceName,
reader.getLocalName());
+ writer.writeDefaultNamespace(nameSpaceName);
+ }
+ }
+ } else {
+ writer.writeStartElement(reader.getLocalName());
+ }
+
+ // add the namespaces
+ int count = reader.getNamespaceCount();
+ String namespacePrefix;
+ for (int i = 0; i < count; i++) {
+ namespacePrefix = reader.getNamespacePrefix(i);
+ // [rfeng] The following is commented out to allow to default ns
+ // if (namespacePrefix != null && namespacePrefix.length() == 0) {
+ // continue;
+ // }
+
+ serializeNamespace(namespacePrefix, reader.getNamespaceURI(i),
writer);
+ }
+
+ // add attributes
+ serializeAttributes(reader, writer);
+
+ }
+
+ /**
+ * Method serializeEndElement.
+ *
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeEndElement(XMLStreamWriter writer) throws
XMLStreamException {
+ writer.writeEndElement();
+ }
+
+ /**
+ * Method serializeNamespace.
+ *
+ * @param prefix
+ * @param uri
+ * @param writer
+ * @throws XMLStreamException
+ */
+ private void serializeNamespace(String prefix, String uri, XMLStreamWriter
writer) throws XMLStreamException {
+ String prefix1 = writer.getPrefix(uri);
+ if (prefix1 == null) {
+ writer.writeNamespace(prefix, uri);
+ // writer.setPrefix(prefix, uri);
+ }
+ }
+
+ /**
+ * Method serializeNode.
+ *
+ * @param reader
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeNode(XMLStreamReader reader, XMLStreamWriter
writer) throws XMLStreamException {
+ while (true) {
+ int event = reader.getEventType();
+ if (event == START_ELEMENT) {
+ serializeElement(reader, writer);
+ depth++;
+ } else if (event == ATTRIBUTE) {
+ serializeAttributes(reader, writer);
+ } else if (event == CHARACTERS) {
+ serializeText(reader, writer);
+ } else if (event == COMMENT) {
+ serializeComment(reader, writer);
+ } else if (event == CDATA) {
+ serializeCData(reader, writer);
+ } else if (event == END_ELEMENT) {
+ serializeEndElement(writer);
+ depth--;
+ } else if (event == START_DOCUMENT) {
+ depth++; // if a start document is found then increment
+ writer.writeStartDocument();
+ // the depth
+ } else if (event == END_DOCUMENT) {
+ if (depth != 0) {
+ depth--; // for the end document - reduce the depth
+ }
+ writer.writeEndDocument();
+ }
+ if (depth == 0) {
+ break;
+ }
+ if (reader.hasNext()) {
+ reader.next();
+ } else {
+ break;
+ }
+ }
+ }
+
+ /**
+ * @param reader
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeText(XMLStreamReader reader, XMLStreamWriter
writer) throws XMLStreamException {
+ writer.writeCharacters(reader.getText());
+ }
+}
Added:
tuscany/java/sca/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor?rev=774146&view=auto
==============================================================================
---
tuscany/java/sca/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
(added)
+++
tuscany/java/sca/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
Wed May 13 00:09:21 2009
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+org.apache.tuscany.sca.node.configuration.xml.NodeConfigurationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#node,model=org.apache.tuscany.sca.node.configuration.NodeConfiguration
Added:
tuscany/java/sca/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory?rev=774146&view=auto
==============================================================================
---
tuscany/java/sca/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory
(added)
+++
tuscany/java/sca/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory
Wed May 13 00:09:21 2009
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+org.apache.tuscany.sca.node.configuration.DefaultNodeConfigurationFactory
Added:
tuscany/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessorTestCase.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessorTestCase.java?rev=774146&view=auto
==============================================================================
---
tuscany/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessorTestCase.java
(added)
+++
tuscany/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessorTestCase.java
Wed May 13 00:09:21 2009
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.node.configuration.xml;
+
+import java.io.InputStream;
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import
org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class NodeConfigurationProcessorTestCase {
+ private static FactoryExtensionPoint factories;
+ private static StAXArtifactProcessor processor;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ factories = new DefaultFactoryExtensionPoint(registry);
+ StAXArtifactProcessorExtensionPoint processors =
+
registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ processor = processors.getProcessor(NodeConfiguration.class);
+ }
+
+ @Test
+ public void testRead() throws Exception {
+ InputStream is =
getClass().getResourceAsStream("/org/apache/tuscany/sca/node/configuration/node1.xml");
+ XMLInputFactory xmlInputFactory =
factories.getFactory(XMLInputFactory.class);
+ XMLStreamReader reader = xmlInputFactory.createXMLStreamReader(is);
+ is.close();
+ reader.nextTag();
+ NodeConfiguration config = (NodeConfiguration) processor.read(reader);
+ StringWriter sw = new StringWriter();
+ XMLOutputFactory xmlOutputFactory =
factories.getFactory(XMLOutputFactory.class);
+ XMLStreamWriter writer = xmlOutputFactory.createXMLStreamWriter(sw);
+ processor.write(config, writer);
+ writer.flush();
+ // System.out.println(sw.toString());
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+}
Copied:
tuscany/java/sca/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml
(from r773715,
tuscany/java/sca/modules/implementation-node/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml)
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml?p2=tuscany/java/sca/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml&p1=tuscany/java/sca/modules/implementation-node/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml&r1=773715&r2=774146&rev=774146&view=diff
==============================================================================
---
tuscany/java/sca/modules/implementation-node/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml
(original)
+++
tuscany/java/sca/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml
Wed May 13 00:09:21 2009
@@ -36,10 +36,16 @@
<!-- Can we have more than one deployment composites -->
<deploymentComposite>
<sca:composite>
+ <sca:component name="Component1"> <!-- first component -->
+ <sca:implementation.java class="a.b.Component1Impl"/>
+ <sca:reference name="ref1">
+ <tuscany:binding.rmi/>
+ </sca:reference>
+ </sca:component>
</sca:composite>
</deploymentComposite>
</contribution>
- <contribution uri="http://c3" location="http://locahost/repo/c.jar"/>
+ <contribution uri="http://c3" location="http://locahost/repo/c.jar">
<deploymentComposite location="test/Test.composite">
</deploymentComposite>
</contribution>