summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/TuscanyRuntime.java (renamed from sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/NodeFactory.java)45
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/impl/NodeImpl.java12
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DeployerTestCase.java (renamed from sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/DeployerTestCase.java)16
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/NodeTestCase.java (renamed from sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeTestCase.java)26
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/NodeXMLTestCase.java (renamed from sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeXMLTestCase.java)6
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TwoNodesTestCase.java (renamed from sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/TwoNodesTestCase.java)8
6 files changed, 67 insertions, 46 deletions
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/NodeFactory.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/TuscanyRuntime.java
index 2e8e29a05b..b2181ef1f4 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/NodeFactory.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/TuscanyRuntime.java
@@ -49,7 +49,7 @@ import org.apache.tuscany.sca.runtime.impl.NodeImpl;
import org.apache.tuscany.sca.work.WorkScheduler;
import org.oasisopen.sca.ServiceRuntimeException;
-public class NodeFactory {
+public class TuscanyRuntime {
private Deployer deployer;
private ExtensionPointRegistry extensionPointRegistry;
@@ -57,26 +57,39 @@ public class NodeFactory {
private ExtensibleDomainRegistryFactory domainRegistryFactory;
private RuntimeAssemblyFactory assemblyFactory;
- public static NodeFactory newInstance() {
- return new NodeFactory(null);
+ public static TuscanyRuntime newInstance() {
+ return new TuscanyRuntime(null);
}
- public static NodeFactory newInstance(Properties config) {
- return new NodeFactory(config);
+ public static TuscanyRuntime newInstance(Properties config) {
+ return new TuscanyRuntime(config);
}
/**
- * A helper method to simplify creating a standalone Node
+ * A helper method to run a standalone SCA composite
* @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
* @param dependentContributionURLs optional URLs of dependent contributions
* @return a Node with installed contributions
*/
- public static Node createStandaloneNode(String compositeURI, String contributionURL, String... dependentContributionURLs) {
+ public static Node runComposite(String compositeURI, String contributionURL, String... dependentContributionURLs) {
+ return runComposite(newInstance(), compositeURI, contributionURL, dependentContributionURLs);
+ }
+
+ /**
+ * 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
+ * @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
+ * @param dependentContributionURLs optional URLs of dependent contributions
+ * @return a Node with installed contributions
+ */
+ public static Node runComposite(TuscanyRuntime runtime, String compositeURI, String contributionURL, String... dependentContributionURLs) {
try {
- NodeFactory nodeFactory = newInstance();
- EndpointRegistry endpointRegistry = new EndpointRegistryImpl(nodeFactory.extensionPointRegistry, null, null);
- NodeImpl node = new NodeImpl("default", nodeFactory.deployer, nodeFactory.compositeActivator, endpointRegistry, nodeFactory.extensionPointRegistry, nodeFactory);
+ EndpointRegistry endpointRegistry = new EndpointRegistryImpl(runtime.extensionPointRegistry, null, null);
+ NodeImpl node = new NodeImpl("default", runtime.deployer, runtime.compositeActivator, endpointRegistry, runtime.extensionPointRegistry, runtime);
if (dependentContributionURLs != null) {
for (int i=dependentContributionURLs.length-1; i>-1; i--) {
@@ -95,7 +108,7 @@ public class NodeFactory {
}
}
- protected NodeFactory(Properties config) {
+ protected TuscanyRuntime(Properties config) {
init(config);
}
@@ -122,7 +135,6 @@ public class NodeFactory {
}
public void stop() {
- deployer.stop();
extensionPointRegistry.stop();
}
@@ -152,6 +164,15 @@ public class NodeFactory {
this.domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionPointRegistry);
}
+
+ /**
+ * Get the ExtensionPointRegistry used by this runtime
+ * @return extensionPointRegistry
+ */
+ public ExtensionPointRegistry getExtensionPointRegistry() {
+ return extensionPointRegistry;
+ }
+
/**
* Get the Deployer. The Deployer can be used to create contribution artifacts
* when configuring a Node programatically.
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/impl/NodeImpl.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/impl/NodeImpl.java
index 32f01698bf..347d63f625 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/impl/NodeImpl.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/impl/NodeImpl.java
@@ -63,7 +63,7 @@ import org.apache.tuscany.sca.runtime.ActivationException;
import org.apache.tuscany.sca.runtime.CompositeActivator;
import org.apache.tuscany.sca.runtime.EndpointRegistry;
import org.apache.tuscany.sca.runtime.Node;
-import org.apache.tuscany.sca.runtime.NodeFactory;
+import org.apache.tuscany.sca.runtime.TuscanyRuntime;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
@@ -78,17 +78,17 @@ public class NodeImpl implements Node {
private CompositeActivator compositeActivator;
private EndpointRegistry endpointRegistry;
private ExtensionPointRegistry extensionPointRegistry;
- private NodeFactory nodeFactory;
+ private TuscanyRuntime tuscanyRuntime;
private static Map<String, Node> allNodes = new HashMap<String, Node>();
- public NodeImpl(String domainName, Deployer deployer, CompositeActivator compositeActivator, EndpointRegistry endpointRegistry, ExtensionPointRegistry extensionPointRegistry, NodeFactory nodeFactory) {
+ public NodeImpl(String domainName, Deployer deployer, CompositeActivator compositeActivator, EndpointRegistry endpointRegistry, ExtensionPointRegistry extensionPointRegistry, TuscanyRuntime tuscanyRuntime) {
this.domainName = domainName;
this.deployer = deployer;
this.compositeActivator = compositeActivator;
this.endpointRegistry = endpointRegistry;
this.extensionPointRegistry = extensionPointRegistry;
- this.nodeFactory = nodeFactory;
+ this.tuscanyRuntime = tuscanyRuntime;
allNodes.put(domainName, this);
}
@@ -273,8 +273,8 @@ public class NodeImpl implements Node {
e.printStackTrace();
}
}
- if (nodeFactory != null) {
- nodeFactory.stop();
+ if (tuscanyRuntime != null) {
+ tuscanyRuntime.stop();
}
allNodes.remove(this.domainName);
}
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/DeployerTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DeployerTestCase.java
index 6d4467a895..bea340c7db 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/DeployerTestCase.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DeployerTestCase.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.sca.node2;
+package org.apache.tuscany.sca.runtime;
import java.io.File;
import java.net.MalformedURLException;
@@ -35,7 +35,7 @@ import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.ValidationException;
import org.apache.tuscany.sca.runtime.ActivationException;
import org.apache.tuscany.sca.runtime.Node;
-import org.apache.tuscany.sca.runtime.NodeFactory;
+import org.apache.tuscany.sca.runtime.TuscanyRuntime;
import org.junit.Test;
import org.oasisopen.sca.NoSuchDomainException;
import org.oasisopen.sca.NoSuchServiceException;
@@ -44,10 +44,10 @@ public class DeployerTestCase {
@Test
public void testInstalledContribution() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException {
- NodeFactory nodeFactory = NodeFactory.newInstance();
- Node node = nodeFactory.createNode("myDomain");
+ TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
+ Node node = tuscanyRuntime.createNode("myDomain");
- Deployer deployer = nodeFactory.getDeployer();
+ Deployer deployer = tuscanyRuntime.getDeployer();
Monitor monitor = deployer.createMonitor();
Contribution contribution = deployer.loadContribution(URI.create("foo"), new File("src/test/resources/sample-helloworld-nodeployable.jar").toURI().toURL(), monitor);
monitor.analyzeProblems();
@@ -60,12 +60,12 @@ public class DeployerTestCase {
@Test
public void testAddDeploymentComposite() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException, XMLStreamException {
- NodeFactory nodeFactory = NodeFactory.newInstance();
- Node node = nodeFactory.createNode("myDomain");
+ TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
+ Node node = tuscanyRuntime.createNode("myDomain");
node.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true);
- Deployer deployer = nodeFactory.getDeployer();
+ Deployer deployer = tuscanyRuntime.getDeployer();
Monitor monitor = deployer.createMonitor();
Composite composite = deployer.loadXMLDocument(new File("src/test/resources/helloworld2.composite").toURI().toURL(), monitor);
monitor.analyzeProblems();
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/NodeTestCase.java
index 2fd1cb7a4e..6787804f06 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeTestCase.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/NodeTestCase.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.sca.node2;
+package org.apache.tuscany.sca.runtime;
import java.net.MalformedURLException;
import java.util.List;
@@ -27,7 +27,7 @@ import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.monitor.ValidationException;
import org.apache.tuscany.sca.runtime.ActivationException;
import org.apache.tuscany.sca.runtime.Node;
-import org.apache.tuscany.sca.runtime.NodeFactory;
+import org.apache.tuscany.sca.runtime.TuscanyRuntime;
import org.apache.tuscany.sca.runtime.impl.NodeImpl;
import org.junit.Ignore;
import org.junit.Test;
@@ -40,7 +40,7 @@ public class NodeTestCase {
@Test
public void testInstallDeployable() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
- Node node = NodeFactory.newInstance().createNode("default");
+ Node node = TuscanyRuntime.newInstance().createNode("default");
node.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null, true);
Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent");
@@ -49,7 +49,7 @@ public class NodeTestCase {
@Test
public void testStopStart() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
- Node node = NodeFactory.newInstance().createNode("default");
+ Node node = TuscanyRuntime.newInstance().createNode("default");
node.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null, true);
String ci = node.getStartedCompositeURIs("helloworld").get(0);
@@ -72,7 +72,7 @@ public class NodeTestCase {
@Test
@Ignore("Depdends on itest/T3558 which isn't in the build?")
public void testInstallWithDependent() throws NoSuchServiceException, ContributionReadException, ActivationException, ValidationException {
- Node node = NodeFactory.newInstance().createNode("default");
+ Node node = TuscanyRuntime.newInstance().createNode("default");
node.installContribution("store", "../../itest/T3558/src/test/resources/sample-store.jar", null, null, true);
node.installContribution("store-client", "../../itest/T3558/src/test/resources/sample-store-client.jar", null, null, true);
@@ -82,7 +82,7 @@ public class NodeTestCase {
@Test
public void testInstallNoDeployable() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
- Node node = NodeFactory.newInstance().createNode("default");
+ Node node = TuscanyRuntime.newInstance().createNode("default");
node.installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true);
try {
@@ -99,7 +99,7 @@ public class NodeTestCase {
@Test
public void testGetInstalledContributions() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
- Node node = NodeFactory.newInstance().createNode("default");
+ Node node = TuscanyRuntime.newInstance().createNode("default");
node.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true);
List<String> ics = node.getInstalledContributionURIs();
Assert.assertEquals(1, ics.size());
@@ -108,7 +108,7 @@ public class NodeTestCase {
@Test
public void testGetDeployedCompostes() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, MalformedURLException, ActivationException, ValidationException {
- Node node = NodeFactory.newInstance().createNode("default");
+ Node node = TuscanyRuntime.newInstance().createNode("default");
node.installContribution("foo", "src/test/resources/sample-helloworld.jar", null, null, true);
List<String> dcs = node.getStartedCompositeURIs("foo");
Assert.assertEquals(1, dcs.size());
@@ -117,7 +117,7 @@ public class NodeTestCase {
@Test
public void testRemoveComposte() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, MalformedURLException, ActivationException, ValidationException {
- Node node = NodeFactory.newInstance().createNode("default");
+ Node node = TuscanyRuntime.newInstance().createNode("default");
node.installContribution("foo", "src/test/resources/sample-helloworld.jar", null, null, true);
node.stop("foo", "helloworld.composite");
List<String> dcs = node.getStartedCompositeURIs("foo");
@@ -126,7 +126,7 @@ public class NodeTestCase {
@Test
public void testInstallWithMetaData() throws ContributionReadException, ActivationException, ValidationException, NoSuchServiceException {
- Node node = NodeFactory.newInstance().createNode("default");
+ Node node = TuscanyRuntime.newInstance().createNode("default");
((NodeImpl)node).installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar", "src/test/resources/sca-contribution-generated.xml", null, true);
List<String> dcs = node.getStartedCompositeURIs("helloworld");
@@ -139,14 +139,14 @@ public class NodeTestCase {
@Test
public void testURI() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
- Node node = NodeFactory.newInstance().createNode("default");
+ Node node = TuscanyRuntime.newInstance().createNode("default");
String uri = node.installContribution("src/test/resources/sample-helloworld.jar");
Assert.assertEquals("sample-helloworld", uri);
}
@Test
public void testStaticCreate() {
- Node node = NodeFactory.createStandaloneNode("helloworld.composite", "src/test/resources/sample-helloworld.jar");
+ Node node = TuscanyRuntime.runComposite("helloworld.composite", "src/test/resources/sample-helloworld.jar");
List<String> cs = node.getInstalledContributionURIs();
Assert.assertEquals(1, cs.size());
List<String> dcs = node.getStartedCompositeURIs(cs.get(0));
@@ -156,7 +156,7 @@ public class NodeTestCase {
@Test
public void testStaticCreateWithNullComposite() {
- Node node = NodeFactory.createStandaloneNode(null, "src/test/resources/sample-helloworld.jar");
+ Node node = TuscanyRuntime.runComposite(null, "src/test/resources/sample-helloworld.jar");
List<String> cs = node.getInstalledContributionURIs();
Assert.assertEquals(1, cs.size());
List<String> dcs = node.getStartedCompositeURIs(cs.get(0));
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeXMLTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/NodeXMLTestCase.java
index 694b0b6f6a..02a1ba1a5a 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeXMLTestCase.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/NodeXMLTestCase.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.sca.node2;
+package org.apache.tuscany.sca.runtime;
import java.util.List;
@@ -26,14 +26,14 @@ import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.monitor.ValidationException;
import org.apache.tuscany.sca.runtime.ActivationException;
import org.apache.tuscany.sca.runtime.Node;
-import org.apache.tuscany.sca.runtime.NodeFactory;
+import org.apache.tuscany.sca.runtime.TuscanyRuntime;
import org.junit.Test;
public class NodeXMLTestCase {
@Test
public void testHelloworldXML() throws ContributionReadException, ActivationException, ValidationException {
- Node node = NodeFactory.newInstance().createNodeFromXML("src/test/resources/helloworldNode.xml");
+ Node node = TuscanyRuntime.newInstance().createNodeFromXML("src/test/resources/helloworldNode.xml");
Assert.assertEquals("helloworld", node.getDomainName());
List<String> cs = node.getInstalledContributionURIs();
Assert.assertEquals(1, cs.size());
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/TwoNodesTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TwoNodesTestCase.java
index 42949e2924..82ffff93d8 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/TwoNodesTestCase.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TwoNodesTestCase.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.sca.node2;
+package org.apache.tuscany.sca.runtime;
import junit.framework.Assert;
@@ -24,7 +24,7 @@ import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.monitor.ValidationException;
import org.apache.tuscany.sca.runtime.ActivationException;
import org.apache.tuscany.sca.runtime.Node;
-import org.apache.tuscany.sca.runtime.NodeFactory;
+import org.apache.tuscany.sca.runtime.TuscanyRuntime;
import org.junit.Test;
import org.oasisopen.sca.NoSuchDomainException;
import org.oasisopen.sca.NoSuchServiceException;
@@ -36,11 +36,11 @@ public class TwoNodesTestCase {
@Test
public void testInstallDeployable() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
// Node node1 = NodeFactory.newInstance().createNode("uri:TwoNodesTestCase?multicast=off&bind=127.0.0.1:44331");
- Node node1 = NodeFactory.newInstance().createNode("uri:TwoNodesTestCase");
+ Node node1 = TuscanyRuntime.newInstance().createNode("uri:TwoNodesTestCase");
node1.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null, true);
// Node node2 = NodeFactory.newInstance().createNode("uri:TwoNodesTestCase?multicast=off&bind=127.0.0.1:44332&wka=127.0.0.1:44331");
- Node node2 = NodeFactory.newInstance().createNode("uri:TwoNodesTestCase");
+ Node node2 = TuscanyRuntime.newInstance().createNode("uri:TwoNodesTestCase");
Helloworld helloworldService = node2.getService(Helloworld.class, "HelloworldComponent");
Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));