summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/Section10.java3
-rw-r--r--sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/DeployedComposite.java16
-rw-r--r--sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java54
3 files changed, 42 insertions, 31 deletions
diff --git a/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/Section10.java b/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/Section10.java
index a4f3db5a4a..6d4b49d53d 100644
--- a/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/Section10.java
+++ b/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/Section10.java
@@ -146,9 +146,10 @@ public interface Section10 {
* 4612 Removes the deployed contribution identified by a supplied contribution URI.
*
* @param contributionURI
+ * @return List of contribution URIs (includes dependent contributions) which were removed
* @throws ActivationException
*/
- void removeContribution(String contributionURI) throws ActivationException;
+ List<String> removeContribution(String contributionURI) throws ActivationException;
/**
* 4677 10.7.1 add To Domain-Level Composite
diff --git a/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/DeployedComposite.java b/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/DeployedComposite.java
index 8f6f310477..09d59589d9 100644
--- a/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/DeployedComposite.java
+++ b/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/DeployedComposite.java
@@ -42,14 +42,14 @@ import org.oasisopen.sca.ServiceRuntimeException;
public class DeployedComposite {
+ private String uri;
private Composite c;
private InstalledContribution ic;
- private List<Contribution> dependentContributions;
- private String uri;
-
+ private List<Contribution> dependedOnContributionURIs;
+ private Composite domainComposite; // TODO: this is misleadingly named
+
private CompositeActivator compositeActivator;
private CompositeContext compositeContext;
- private Composite domainComposite; // TODO: this is a misleadingly named
private Deployer deployer;
private MonitorFactory monitorFactory;
private EndpointRegistry endpointRegistry;
@@ -57,7 +57,7 @@ public class DeployedComposite {
public DeployedComposite(Composite c,
InstalledContribution ic,
- List<Contribution> dependentContributions,
+ List<Contribution> dependedOnContributionURIs,
Deployer deployer,
CompositeActivator compositeActivator,
MonitorFactory monitorFactory,
@@ -65,7 +65,7 @@ public class DeployedComposite {
ExtensionPointRegistry extensionPointRegistry) throws ActivationException {
this.c = c;
this.ic = ic;
- this.dependentContributions = dependentContributions;
+ this.dependedOnContributionURIs = dependedOnContributionURIs;
this.deployer = deployer;
this.compositeActivator = compositeActivator;
this.monitorFactory = monitorFactory;
@@ -88,8 +88,8 @@ public class DeployedComposite {
Monitor monitor = monitorFactory.createMonitor();
Monitor tcm = monitorFactory.setContextMonitor(monitor);
try {
-
- domainComposite = deployer.build(contributions, dependentContributions, new HashMap<QName, List<String>>(), monitor);
+
+ domainComposite = deployer.build(contributions, dependedOnContributionURIs, new HashMap<QName, List<String>>(), monitor);
analyzeProblems(monitor);
} finally {
diff --git a/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java b/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java
index f41023e845..aa12fe8716 100644
--- a/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java
+++ b/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java
@@ -24,9 +24,11 @@ import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
@@ -84,6 +86,7 @@ public class Section10Impl implements Section10 {
Monitor monitor = deployer.createMonitor();
URL url = IOHelper.getLocationAsURL(contributionURL);
Contribution contribution = deployer.loadContribution(URI.create(uri), url, monitor);
+ // TODO: does this need to do check the monitor
InstalledContribution ic = new InstalledContribution(uri, url.toString(), contribution);
installedContributions.put(uri, ic);
if (autoDeploy) {
@@ -103,14 +106,7 @@ public class Section10Impl implements Section10 {
Composite composite = deployer.loadXMLDocument(compositeXML, monitor);
// TODO: does this need to do check the monitor
- String compositeArtifcatURI = composite.getName().getLocalPart() + ".composite";
- for (Artifact a : ic.getContribution().getArtifacts()) {
- if (compositeArtifcatURI.equals(a.getURI())) {
- throw new IllegalStateException("artifact '" + compositeArtifcatURI + "' already exists in contribution: " + contributionURI);
- }
- }
-
- deployer.attachDeploymentComposite(ic.getContribution(), composite, true);
+ String compositeArtifcatURI = deployer.attachDeploymentComposite(ic.getContribution(), composite, true);
deployComposite(composite, ic);
return compositeArtifcatURI;
}
@@ -124,8 +120,7 @@ public class Section10Impl implements Section10 {
String relativeURI = compositeURI.substring(contributionURI.length()+1);
for (Artifact a : ic.getContribution().getArtifacts()) {
if (a.getURI().equals(relativeURI)) {
- Composite c = (Composite) a.getModel();
- deployComposite(c, ic);
+ deployComposite((Composite) a.getModel(), ic);
return;
}
}
@@ -138,7 +133,6 @@ public class Section10Impl implements Section10 {
String relativeURI = compositeURI.substring(contributionURI.length()+1);
for (DeployedComposite dc : ic.getDeployedComposites()) {
if (relativeURI.equals(dc.getURI())) {
-// undeployComposite(dc, ic);
ic.getDeployedComposites().remove(dc);
dc.unDeploy();
return;
@@ -162,17 +156,20 @@ public class Section10Impl implements Section10 {
return null;
}
- public void removeContribution(String contributionURI) throws ActivationException {
- // TODO: what about dependent contributions
+ public List<String> removeContribution(String contributionURI) throws ActivationException {
+ List<String> removedContributionURIs = new ArrayList<String>();
InstalledContribution ic = installedContributions.remove(contributionURI);
- if (ic == null) {
- throw new IllegalArgumentException("Contribution not installed: " + contributionURI);
- }
- for (DeployedComposite dc : ic.getDeployedComposites()) {
-// undeployComposite(dc, ic);
- dc.unDeploy();
+ if (ic != null) {
+ removedContributionURIs.add(ic.getURI());
+ for (String dependent : getDependentContributions(contributionURI)) {
+ removedContributionURIs.addAll(removeContribution(dependent));
+ }
+ for (DeployedComposite dc : ic.getDeployedComposites()) {
+ dc.unDeploy();
+ }
+ ic.getDeployedComposites().clear();
}
- ic.getDeployedComposites().clear();
+ return removedContributionURIs;
}
public void updateContribution(String uri, String contributionURL) {
@@ -233,7 +230,6 @@ public class Section10Impl implements Section10 {
}
protected void deployComposite(Composite c, InstalledContribution ic) throws ActivationException {
-
List<Contribution> dependentContributions = new ArrayList<Contribution>();
for (InstalledContribution ics : installedContributions.values()) {
dependentContributions.add(ics.getContribution());
@@ -242,5 +238,19 @@ public class Section10Impl implements Section10 {
DeployedComposite dc = Helper.createDeployedComposite(c, ic, dependentContributions, getDomainName(), nodeFactory);
ic.getDeployedComposites().add(dc);
}
-
+
+ public Set<String> getDependentContributions(String contributionURI) {
+ InstalledContribution ic = installedContributions.get(contributionURI);
+ if (ic == null) {
+ throw new IllegalArgumentException("Contribution not installed: " + contributionURI);
+ }
+ Set<String> dependentContributionURIs = new HashSet<String>();
+ for (InstalledContribution icx : installedContributions.values()) {
+ List<Contribution> dependencies = icx.getContribution().getDependencies();
+ if (dependencies != null && dependencies.contains(ic.getContribution())) {
+ dependentContributionURIs.addAll(getDependentContributions(icx.getURI()));
+ }
+ }
+ return dependentContributionURIs;
+ }
}