From 399df0e96559b977ef2a880f5f81b0f0eaac189c Mon Sep 17 00:00:00 2001 From: slaws Date: Tue, 22 Sep 2009 15:55:52 +0000 Subject: Dump out nested composites also. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@817709 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tuscany/sca/node/impl/NodeImpl.java | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java index 9d8f4eeb99..fa9c2dcc1f 100644 --- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java +++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java @@ -34,6 +34,7 @@ import org.apache.tuscany.sca.assembly.ComponentService; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.CompositeService; import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.assembly.Implementation; import org.apache.tuscany.sca.assembly.Service; import org.apache.tuscany.sca.common.java.io.IOHelper; import org.apache.tuscany.sca.contribution.Contribution; @@ -304,17 +305,31 @@ public class NodeImpl implements Node, Client { StAXArtifactProcessorExtensionPoint xmlProcessors = getExtensionPoints().getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); StAXArtifactProcessor compositeProcessor = - xmlProcessors.getProcessor(Composite.class); - + xmlProcessors.getProcessor(Composite.class); + + return writeComposite(getDomainComposite(), compositeProcessor); + } + + private String writeComposite(Composite composite, StAXArtifactProcessor compositeProcessor){ ByteArrayOutputStream bos = new ByteArrayOutputStream(); XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); try { - compositeProcessor.write(getDomainComposite(), outputFactory.createXMLStreamWriter(bos)); + compositeProcessor.write(composite, outputFactory.createXMLStreamWriter(bos)); } catch(Exception ex) { return ex.toString(); } - return bos.toString(); + String result = bos.toString(); + + // write out and nested composites + for(Component component : composite.getComponents()){ + if (component.getImplementation() instanceof Composite) { + result += "\n\n" + + writeComposite((Composite)component.getImplementation(), compositeProcessor); + } + } + + return result; } } -- cgit v1.2.3