From be32381f21467ea121234b8196ec25f695170508 Mon Sep 17 00:00:00 2001 From: antelder Date: Thu, 25 Nov 2010 15:54:43 +0000 Subject: Update node2 api to more closely match the commands the Shell has git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1039077 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/tuscany/sca/node2/Node.java | 26 ++++++++++----------- .../org/apache/tuscany/sca/node2/NodeFactory.java | 2 +- .../apache/tuscany/sca/node2/impl/NodeImpl.java | 27 +++++++++++----------- .../apache/tuscany/sca/node2/DeployerTestCase.java | 2 +- .../org/apache/tuscany/sca/node2/NodeTestCase.java | 4 ++-- 5 files changed, 30 insertions(+), 31 deletions(-) (limited to 'sca-java-2.x') diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/Node.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/Node.java index 9cf0e90d7d..5abde420de 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/Node.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/Node.java @@ -44,15 +44,15 @@ public interface Node { * of the Assembly Specification. May be null. * @param dependentContributionURIs specifies the contributions that are used to resolve the dependencies of the * root contribution and other dependent contributions. May be null. - * @param runDeployables true if the composites defined as deployable in the contributions sca-contribution.xml - * file or supplied metaData file should be run, false if they should not be. + * @param start true if the composites defined as deployable in the contribution's sca-contribution.xml + * file or supplied metaData file should be started, false if they should not be. * @return the URI of the installed contribution * * @throws ContributionReadException * @throws ActivationException * @throws ValidationException */ - String installContribution(String uri, String contributionURL, String metaDataURL, List dependentContributionURIs, boolean runDeployables) throws ContributionReadException, ActivationException, ValidationException; + String installContribution(String uri, String contributionURL, String metaDataURL, List dependentContributionURIs, boolean start) throws ContributionReadException, ActivationException, ValidationException; /** * Creates an installed contribution from a supplied Contribution object. @@ -61,20 +61,20 @@ public interface Node { * @param contribution the Contribution object * @param dependentContributionURIs specifies the contributions that are used to resolve the dependencies of the * root contribution and other dependent contributions. May be null. - * @param runDeployables true if the composites defined as deployable in the contributions sca-contribution.xml - * file or supplied metaData file should be run, false if they should not be. + * @param start true if the composites defined as deployable in the contribution's sca-contribution.xml + * file or supplied metaData file should be started, false if they should not be. * @return the URI of the installed contribution * * @throws ContributionReadException * @throws ActivationException * @throws ValidationException */ - String installContribution(Contribution contribution, List dependentContributionURIs, boolean runDeployables) throws ContributionReadException, ActivationException, ValidationException; + String installContribution(Contribution contribution, List dependentContributionURIs, boolean start) throws ContributionReadException, ActivationException, ValidationException; /** * Creates an installed contribution from a supplied root contribution URL. - * See section 10.5.1 of the Assembly Specification. This version of - * installContribution automatically runs deployable composites + * See section 10.5.1 of the Assembly Specification. This method is the same + * as calling installContribution(null, contributionURL, null, null, true) * * @param contributionURL the URL where the contribution is located * @return the URI of the installed contribution @@ -137,8 +137,8 @@ public interface Node { * @throws ActivationException * @throws ValidationException */ - String addDeploymentComposite(String contributionURI, Reader compositeXML) throws ContributionReadException, XMLStreamException, ActivationException, ValidationException; - String addDeploymentComposite(String contributionURI, Composite composite) throws ActivationException, ValidationException; + String start(String contributionURI, Reader compositeXML) throws ContributionReadException, XMLStreamException, ActivationException, ValidationException; + String start(String contributionURI, Composite composite) throws ActivationException, ValidationException; /** * 4599 10.5.2 add Deployment Composite & update Deployment Composite @@ -187,18 +187,18 @@ public interface Node { * @throws ActivationException * @throws ValidationException */ - void addToDomainLevelComposite(String contributionURI, String compositeURI) throws ActivationException, ValidationException; + void start(String contributionURI, String compositeURI) throws ActivationException, ValidationException; /** * 4687 10.7.2 remove From Domain-Level Composite * 4688 Removes from the Domain Level composite the elements corresponding to the composite identified by a * 4689 supplied composite URI. This means that the removal of the components, wires, services and references - * 4690 originally added to the domain level composite by the identified composite. * + * 4690 originally added to the domain level composite by the identified composite. * @param contributionURI * @param compositeURI * @throws ActivationException */ - void removeFromDomainLevelComposite(String contributionURI, String compositeURI) throws ActivationException; + void stop(String contributionURI, String compositeURI) throws ActivationException; /** * 10.7.3 get Domain-Level Composite diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/NodeFactory.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/NodeFactory.java index c7b8db235a..999311b05d 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/NodeFactory.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/NodeFactory.java @@ -86,7 +86,7 @@ public class NodeFactory { String curi = node.installContribution(null, contributionURL, null, null, compositeURI == null); if (compositeURI != null) { - node.addToDomainLevelComposite(curi, compositeURI); + node.start(curi, compositeURI); } return node; diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/NodeImpl.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/NodeImpl.java index 459aa5e50c..7fe46764ed 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/NodeImpl.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/NodeImpl.java @@ -74,7 +74,7 @@ public class NodeImpl implements Node { return installContribution(null, contributionURL, null, null, true); } - public String installContribution(String uri, String contributionURL, String metaDataURL, List dependentContributionURIs, boolean runDeployables) throws ContributionReadException, ActivationException, ValidationException { + public String installContribution(String uri, String contributionURL, String metaDataURL, List dependentContributionURIs, boolean startDeployables) throws ContributionReadException, ActivationException, ValidationException { if (uri == null) { uri = getDefaultContributionURI(contributionURL); } @@ -84,7 +84,7 @@ public class NodeImpl implements Node { if (metaDataURL != null) { mergeContributionMetaData(metaDataURL, contribution); } - installContribution(contribution, dependentContributionURIs, runDeployables); + installContribution(contribution, dependentContributionURIs, startDeployables); return uri; } @@ -102,12 +102,12 @@ public class NodeImpl implements Node { contribution.getExports().addAll(metaData.getExports()); } - public String installContribution(Contribution contribution, List dependentContributionURIs, boolean runDeployables) throws ContributionReadException, ActivationException, ValidationException { + public String installContribution(Contribution contribution, List dependentContributionURIs, boolean startDeployables) throws ContributionReadException, ActivationException, ValidationException { InstalledContribution ic = new InstalledContribution(contribution.getURI(), contribution.getLocation(), contribution, dependentContributionURIs); installedContributions.put(contribution.getURI(), ic); - if (runDeployables) { + if (startDeployables) { for (Composite c : ic.getDefaultDeployables()) { - runComposite(c, ic); + startComposite(c, ic); } } else { contribution.getDeployables().clear(); @@ -144,32 +144,31 @@ public class NodeImpl implements Node { return dependentContributions; } - public String addDeploymentComposite(String contributionURI, Reader compositeXML) throws ContributionReadException, XMLStreamException, ActivationException, ValidationException { + public String start(String contributionURI, Reader compositeXML) throws ContributionReadException, XMLStreamException, ActivationException, ValidationException { Monitor monitor = deployer.createMonitor(); Composite composite = deployer.loadXMLDocument(compositeXML, monitor); monitor.analyzeProblems(); - return addDeploymentComposite(contributionURI, composite); + return start(contributionURI, composite); } - public String addDeploymentComposite(String contributionURI, Composite composite) throws ActivationException, ValidationException { + public String start(String contributionURI, Composite composite) throws ActivationException, ValidationException { InstalledContribution ic = installedContributions.get(contributionURI); if (ic == null) { throw new IllegalArgumentException("contribution not installed: " + contributionURI); } String compositeArtifcatURI = deployer.attachDeploymentComposite(ic.getContribution(), composite, true); - runComposite(composite, ic); + startComposite(composite, ic); return compositeArtifcatURI; } - @Override - public void addToDomainLevelComposite(String contributionURI, String compositeURI) throws ActivationException, ValidationException { + public void start(String contributionURI, String compositeURI) throws ActivationException, ValidationException { InstalledContribution ic = installedContributions.get(contributionURI); if (ic == null) { throw new IllegalArgumentException("Contribution not installed: " + contributionURI); } for (Artifact a : ic.getContribution().getArtifacts()) { if (a.getURI().equals(compositeURI)) { - runComposite((Composite) a.getModel(), ic); + startComposite((Composite) a.getModel(), ic); return; } } @@ -177,7 +176,7 @@ public class NodeImpl implements Node { } @Override - public void removeFromDomainLevelComposite(String contributionURI, String compositeURI) throws ActivationException { + public void stop(String contributionURI, String compositeURI) throws ActivationException { InstalledContribution ic = installedContributions.get(contributionURI); if (ic == null) { throw new IllegalArgumentException("Contribution not installed: " + contributionURI); @@ -307,7 +306,7 @@ public class NodeImpl implements Node { return contributionURI; } - protected void runComposite(Composite c, InstalledContribution ic) throws ActivationException, ValidationException { + protected void startComposite(Composite c, InstalledContribution ic) throws ActivationException, ValidationException { List dependentContributions = calculateDependentContributions(ic); DeployedComposite dc = new DeployedComposite(c, ic, dependentContributions, deployer, compositeActivator, endpointRegistry, extensionPointRegistry); 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/node2/DeployerTestCase.java index 4d0d4abfd2..9c4de1c2bd 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/node2/DeployerTestCase.java @@ -68,7 +68,7 @@ public class DeployerTestCase { Composite composite = deployer.loadXMLDocument(new File("src/test/resources/helloworld2.composite").toURI().toURL(), monitor); monitor.analyzeProblems(); composite.setURI("helloworld2.composite"); - node.addDeploymentComposite("foo", composite); + node.start("foo", composite); List dcs = node.getDeployedComposites("foo"); Assert.assertEquals(1, dcs.size()); Assert.assertEquals("helloworld2.composite", dcs.get(0)); 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/node2/NodeTestCase.java index cdf8b02688..f050ad36a1 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/node2/NodeTestCase.java @@ -67,7 +67,7 @@ public class NodeTestCase { // // expected as there is no deployables // } - node.addToDomainLevelComposite("helloworld", "helloworld.composite"); + node.start("helloworld", "helloworld.composite"); // Helloworld helloworldService = scaClientFactory.getService(Helloworld.class, "HelloworldComponent"); // Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); } @@ -94,7 +94,7 @@ public class NodeTestCase { public void testRemoveComposte() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, MalformedURLException, ActivationException, ValidationException { Node node = NodeFactory.newInstance().createNode("default"); node.installContribution("foo", "src/test/resources/sample-helloworld.jar", null, null, true); - node.removeFromDomainLevelComposite("foo", "helloworld.composite"); + node.stop("foo", "helloworld.composite"); List dcs = node.getDeployedComposites("foo"); Assert.assertEquals(0, dcs.size()); } -- cgit v1.2.3