diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-19 12:59:50 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-19 12:59:50 +0000 |
commit | d3c3c29329142b6f05b22c141ae616bb42c773ed (patch) | |
tree | 07b62089e3b14b6140442a6658065c52acf4767e /sca-java-2.x/trunk/modules | |
parent | f20ddb18c5425b2dae9abc90a8a1c0f3f1d7b71a (diff) |
Move the code for getDomainComposite from NodeImpl to the domain registry
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1124724 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules')
5 files changed, 33 insertions, 16 deletions
diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/BaseDomainRegistry.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/BaseDomainRegistry.java index bb20ae5337..4e5f81502f 100644 --- a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/BaseDomainRegistry.java +++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/BaseDomainRegistry.java @@ -26,9 +26,15 @@ import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; import java.util.logging.Logger; +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.Base; +import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.core.LifeCycleListener; /** @@ -164,4 +170,21 @@ public abstract class BaseDomainRegistry implements DomainRegistry, LifeCycleLis public void removeContributionListener(ContributionListener listener) { contributionlisteners.remove(listener); } + + public Composite getDomainComposite() { + FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class); + AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class); + Composite domainComposite = assemblyFactory.createComposite(); + domainComposite.setName(new QName(Base.SCA11_TUSCANY_NS, getDomainURI())); + domainComposite.setAutowire(false); + domainComposite.setLocal(false); + List<Composite> domainIncludes = domainComposite.getIncludes(); + Map<String, List<String>> runningCompositeURIs = getRunningCompositeURIs(); + for (String curi : runningCompositeURIs.keySet()) { + for (String compositeURI : runningCompositeURIs.get(curi)) { + domainIncludes.add(getRunningComposite(curi, compositeURI)); + } + } + return domainComposite; + } } diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistry.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistry.java index 08fbb62f0d..85d5c80d10 100644 --- a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistry.java +++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistry.java @@ -99,4 +99,5 @@ public interface DomainRegistry { String getRunningMember(String contributionURI, String compositeURI); String remoteCommand(String memberName, Callable<String> command); + public Composite getDomainComposite(); } diff --git a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java index ad13ba4bd3..d30797dc31 100644 --- a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java +++ b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java @@ -594,6 +594,7 @@ public class HazelcastDomainRegistry extends BaseDomainRegistry implements Domai Map<String, String> cs = runningComposites.get(contributionURI); if (cs != null) { String compositeXML = cs.get(compositeURI); + // TODO: cache the Composite locally so that it doesn't get deserialized multiple times return readComposite(compositeXML); } return null; 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 7cfe60a543..2682ec493b 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 @@ -265,20 +265,7 @@ public class NodeImpl implements Node { } public Composite getDomainComposite() { - FactoryExtensionPoint factories = extensionPointRegistry.getExtensionPoint(FactoryExtensionPoint.class); - AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class); - Composite domainComposite = assemblyFactory.createComposite(); - domainComposite.setName(new QName(Base.SCA11_TUSCANY_NS, domainName)); - domainComposite.setAutowire(false); - domainComposite.setLocal(false); - List<Composite> domainIncludes = domainComposite.getIncludes(); - Map<String, List<String>> runningCompositeURIs = domainRegistry.getRunningCompositeURIs(); - for (String curi : runningCompositeURIs.keySet()) { - for (String compositeURI : runningCompositeURIs.get(curi)) { - domainIncludes.add(domainRegistry.getRunningComposite(curi, compositeURI)); - } - } - return domainComposite; + return domainRegistry.getDomainComposite(); } public <T> T getService(Class<T> interfaze, String serviceURI) throws NoSuchServiceException { @@ -374,10 +361,13 @@ public class NodeImpl implements Node { return dcURIs; } - // TODO: this is used by the shell to endpoint detail, should it be on the Node interface? + // TODO: these are used by the shell, should they be on the Node interface? public DomainRegistry getEndpointRegistry() { return domainRegistry; } + public ExtensionPointRegistry getExtensionPointRegistry() { + return extensionPointRegistry; + } public void stop() { for (DeployedComposite dc : startedComposites.values()) { diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DomainCompositeTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DomainCompositeTestCase.java index 6edd6d454a..97910aaf37 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DomainCompositeTestCase.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DomainCompositeTestCase.java @@ -23,7 +23,9 @@ import junit.framework.Assert; import org.apache.tuscany.sca.Node;
import org.apache.tuscany.sca.TuscanyRuntime;
import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.xml.Utils;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.impl.NodeImpl;
import org.apache.tuscany.sca.monitor.ValidationException;
import org.junit.Test;
import org.oasisopen.sca.NoSuchDomainException;
@@ -57,7 +59,7 @@ public class DomainCompositeTestCase { Assert.assertEquals("helloworld", c.getName().getLocalPart());
// String s = node.getDomainLevelCompositeAsString();
-// System.out.println(s);
+ System.out.println(Utils.modelToXML(node.getDomainComposite(), true, ((NodeImpl)node).getExtensionPointRegistry()));
// Assert.assertTrue(s.contains(":helloworld\""));
node.stopComposite("helloworld", "helloworld.composite");
|