From a871befa60fe48f8e699dc68ae910eb6c4b612a6 Mon Sep 17 00:00:00 2001 From: antelder Date: Sat, 7 May 2011 07:32:55 +0000 Subject: Update to support setting the domain uri in the runComposite method git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1100473 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/tuscany/sca/TuscanyRuntime.java | 18 ++++++++---------- .../tuscany/sca/runtime/TuscanyRuntimeTestCase.java | 5 ++--- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/TuscanyRuntime.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/TuscanyRuntime.java index 7ce919799b..4cacbb8c56 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/TuscanyRuntime.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/TuscanyRuntime.java @@ -22,6 +22,7 @@ package org.apache.tuscany.sca; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.net.URI; import java.net.URL; import java.util.Properties; @@ -79,7 +80,7 @@ public class TuscanyRuntime { } /** - * A helper method to run a standalone SCA composite + * A helper method to run a standalone SCA composite in the default standalone SCA domain. * @param compositeURI URI within the contribution of a composite to run * if compositeURI is null then all deployable composites in the contribution will be run * @param contributionURL URL of the contribution @@ -91,9 +92,8 @@ public class TuscanyRuntime { } /** - * A helper method to run a standalone SCA composite - * @param runtime a TuscanyRuntime instance which will be used to run the composite - * this allows sharing a runtime instance to run multiple composites + * A helper method to run a standalone SCA composite in a SCA domain + * @param domainURI the URI of the SCA domain * @param compositeURI URI within the contribution of a composite to run * if compositeURI is null then all deployable composites in the contribution will be run * @param contributionURL URL of the contribution @@ -101,14 +101,12 @@ public class TuscanyRuntime { * @return a Node with installed contributions * TODO: keep this helper method? Maybe say you should just create/use Node directly */ - public static Node runComposite(TuscanyRuntime runtime, String compositeURI, String contributionURL, String... dependentContributionURLs) { + public static Node runComposite(URI domainURI, String compositeURI, String contributionURL, String... dependentContributionURLs) { try { - boolean sharedRuntime = runtime != null; - if (runtime == null) { - runtime = newInstance(); - } + TuscanyRuntime runtime = newInstance(); + String domain = domainURI == null ? "default" : domainURI.toString(); EndpointRegistry endpointRegistry = new EndpointRegistryImpl(runtime.extensionPointRegistry, null, null); - NodeImpl node = new NodeImpl("default", runtime.deployer, runtime.compositeActivator, endpointRegistry, runtime.extensionPointRegistry, sharedRuntime? null : runtime); + NodeImpl node = new NodeImpl(domain, runtime.deployer, runtime.compositeActivator, endpointRegistry, runtime.extensionPointRegistry, runtime); if (dependentContributionURLs != null) { for (int i=dependentContributionURLs.length-1; i>-1; i--) { diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TuscanyRuntimeTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TuscanyRuntimeTestCase.java index d588f91d6a..99f51a2604 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TuscanyRuntimeTestCase.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TuscanyRuntimeTestCase.java @@ -19,6 +19,7 @@ package org.apache.tuscany.sca.runtime; import java.net.MalformedURLException; +import java.net.URI; import java.util.List; import junit.framework.Assert; @@ -175,14 +176,12 @@ public class TuscanyRuntimeTestCase { @Test public void testRunCompositeSharedRuntime() throws NoSuchServiceException { - TuscanyRuntime runtime = TuscanyRuntime.newInstance(); - Node node = TuscanyRuntime.runComposite(runtime, "helloworld.composite", "src/test/resources/sample-helloworld.jar"); + Node node = TuscanyRuntime.runComposite(URI.create("default"), "helloworld.composite", "src/test/resources/sample-helloworld.jar"); try { Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent"); Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); } finally { node.stop(); } - runtime.stop(); } } -- cgit v1.2.3