diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-09 14:00:59 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-09 14:00:59 +0000 |
commit | 65145ace6c12a703bb3a8f9063d338d2703d86f0 (patch) | |
tree | f957508b62db2737a073d555a12f00bd3288e622 /sca-java-2.x/trunk/modules/domain-node/src/main | |
parent | 3947e373c50dc536f99547d3d03a224bee34a769 (diff) |
Start looking at support for a Shell command to show the domain level composite, this includes adding info about the running composites to the domain registry and a the new shell command to access it.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1101031 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/domain-node/src/main')
2 files changed, 31 insertions, 5 deletions
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java index 923a12c9b1..1b3b244d08 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java @@ -85,6 +85,7 @@ public class DeployedComposite { Monitor monitor = deployer.createMonitor(); builtComposite = deployer.build(contribution, dependedOnContributions, new HashMap<QName, List<String>>(), monitor); + builtComposite.setName(composite.getName()); monitor.analyzeProblems(); compositeContext = new CompositeContext(extensionPointRegistry, @@ -100,9 +101,11 @@ public class DeployedComposite { public void start() throws ActivationException { compositeActivator.activate(compositeContext, builtComposite); compositeActivator.start(compositeContext, builtComposite); + endpointRegistry.addRunningComposite(builtComposite); } public void stop() throws ActivationException { + endpointRegistry.removeRunningComposite(builtComposite.getName()); compositeActivator.stop(compositeContext, builtComposite); compositeActivator.deactivate(builtComposite); } diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java index b1d1c97e61..38d06b6f59 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java @@ -19,6 +19,7 @@ package org.apache.tuscany.sca.impl; +import java.io.ByteArrayOutputStream; import java.io.File; import java.io.Reader; import java.util.ArrayList; @@ -29,11 +30,13 @@ import java.util.Map; import java.util.Set; import javax.xml.namespace.QName; +import javax.xml.stream.XMLOutputFactory; import javax.xml.stream.XMLStreamException; import org.apache.tuscany.sca.Node; import org.apache.tuscany.sca.TuscanyRuntime; import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.Base; import org.apache.tuscany.sca.assembly.Component; import org.apache.tuscany.sca.assembly.ComponentReference; import org.apache.tuscany.sca.assembly.ComponentService; @@ -48,6 +51,9 @@ import org.apache.tuscany.sca.contribution.Artifact; import org.apache.tuscany.sca.contribution.Contribution; import org.apache.tuscany.sca.contribution.ContributionMetadata; import org.apache.tuscany.sca.contribution.processor.ContributionReadException; +import org.apache.tuscany.sca.contribution.processor.ProcessorContext; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory; @@ -209,15 +215,32 @@ public class NodeImpl implements Node { } public Composite getDomainLevelComposite() { - // TODO Auto-generated method stub - return null; + FactoryExtensionPoint factories = extensionPointRegistry.getExtensionPoint(FactoryExtensionPoint.class); + AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class); + Composite domainComposite = assemblyFactory.createComposite(); + domainComposite.setName(new QName(Base.SCA11_TUSCANY_NS, "domainCompoiste")); + List<Composite> domainIncludes = domainComposite.getIncludes(); + for (Composite composite : endpointRegistry.getRunningComposites()) { + domainIncludes.add(composite); + } + return domainComposite; } public String getDomainLevelCompositeAsString() { - // TODO Auto-generated method stub - return null; - } + StAXArtifactProcessorExtensionPoint xmlProcessors = extensionPointRegistry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); + StAXArtifactProcessor<Composite> compositeProcessor = xmlProcessors.getProcessor(Composite.class); + XMLOutputFactory outputFactory = extensionPointRegistry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(XMLOutputFactory.class); + + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + try { + compositeProcessor.write(getDomainLevelComposite(), outputFactory.createXMLStreamWriter(bos), new ProcessorContext(extensionPointRegistry)); + } catch(Exception e) { + throw new RuntimeException(e); + } + String result = bos.toString(); + return result; + } public Object getQNameDefinition(String contributionURI, QName definition, QName symbolSpace) { // TODO Auto-generated method stub return null; |