diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2012-02-20 12:50:59 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2012-02-20 12:50:59 +0000 |
commit | 005ecc6b09c01be18cf558dfda84b316af6bb4b0 (patch) | |
tree | f543187851fbd66db79a7919881549e8eace20da /sca-java-2.x/trunk/modules | |
parent | 0ab7ca59190fe5ac1e37c0e0196d7701a765f478 (diff) |
TUSCANY-4016 - when a composite fails to start ensure that it is stopped and move it to the stopped list so that calls to remove unused contributions work.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1291234 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules')
-rw-r--r-- | sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java | 60 |
1 files changed, 40 insertions, 20 deletions
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 b56765f3c5..e95dd9f699 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 @@ -348,18 +348,34 @@ public class NodeImpl implements Node { throw new IllegalStateException("composite already started: " + compositeURI); } DeployedComposite dc = stoppedComposites.remove(key); - if (dc != null) { - dc.start(); - startedComposites.put(key, dc); - } else { - ContributionDescription cd = getInstalledContribution(contributionURI); - Contribution contribution = loadContribution(cd); - Composite composite = contribution.getArtifactModel(compositeURI); - List<Contribution> dependentContributions = calculateDependentContributions(cd); - dc = new DeployedComposite(composite, contribution, dependentContributions, deployer, compositeActivator, domainRegistry, extensionPointRegistry, endpointsIncludeDomainName); - dc.start(); - startedComposites.put(key, dc); - } + try { + if (dc != null) { + dc.start(); + startedComposites.put(key, dc); + } else { + ContributionDescription cd = getInstalledContribution(contributionURI); + Contribution contribution = loadContribution(cd); + Composite composite = contribution.getArtifactModel(compositeURI); + List<Contribution> dependentContributions = calculateDependentContributions(cd); + dc = new DeployedComposite(composite, contribution, dependentContributions, deployer, compositeActivator, domainRegistry, extensionPointRegistry, endpointsIncludeDomainName); + dc.start(); + startedComposites.put(key, dc); + } + }catch(ActivationException e){ + if(dc != null){ + try { + // try to stop the composite. This should have already happened + // in the activator if the composite failed to start but we're + // being sure + dc.stop(); + } catch (Exception ex) { + // do nothing as we are going to throw the + // original exception + } + stoppedComposites.put(key, dc); + } + throw e; + } if (logger.isLoggable(quietLogging? Level.FINE : Level.INFO)) logger.log(quietLogging? Level.FINE : Level.INFO, "startComposite: " + key); } @@ -395,18 +411,22 @@ public class NodeImpl implements Node { public void stopCompositeAndUninstallUnused(String contributionURI, String compositeURI) throws ActivationException { String key = contributionURI+"/"+compositeURI; DeployedComposite dc = startedComposites.remove(key); - if (dc == null) { - throw new IllegalArgumentException("No startd composite found: " + key); + if (dc != null) { + dc.stop(); + } else { + // check in the stopped list in case it stopped on failure during start + dc = stoppedComposites.get(key); } - dc.stop(); - loop: for (String curi : dc.getContributionURIs()) { - for (DeployedComposite started : startedComposites.values()) { - if (started.getContributionURIs().contains(curi)) { - continue loop; + if (dc != null) { + loop: for (String curi : dc.getContributionURIs()) { + for (DeployedComposite started : startedComposites.values()) { + if (started.getContributionURIs().contains(curi)) { + continue loop; + } } + uninstallContribution(curi); } - uninstallContribution(curi); } if (logger.isLoggable(quietLogging? Level.FINE : Level.INFO)) logger.log(quietLogging? Level.FINE : Level.INFO, "stopCompositeAndUninstallUnused: " + key); } |