diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-05-22 07:48:18 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-05-22 07:48:18 +0000 |
commit | 3e7ef6020669f2b275e34a693411cc90081181f5 (patch) | |
tree | 07020a66283450818f91092cafb39761d78bb2d5 /sca-java-2.x/contrib/modules/section10/src/main/java/org | |
parent | 89c41da4671379c7db43c1df91dc074760e0dbfd (diff) |
Start adding code for addDeploymentComposite
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@947265 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/contrib/modules/section10/src/main/java/org')
2 files changed, 32 insertions, 21 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 dcdc8f71ab..a4f3db5a4a 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 @@ -23,6 +23,7 @@ import java.io.Reader; import java.util.List;
import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
@@ -114,11 +115,11 @@ public interface Section10 { * @param uri
* @param compositeXML
* @return
+ * @throws XMLStreamException
+ * @throws ContributionReadException
+ * @throws ActivationException
*/
- String addDeploymentComposite(String contriubutionURI, String compositeXML);
-
- /* perhaps you may want other forms of that too, eg: */
- String addDeploymentComposite(String contriubutionURI, Reader compositeXML);
+ String addDeploymentComposite(String contriubutionURI, Reader compositeXML) throws ContributionReadException, XMLStreamException, ActivationException;
/**
* 4599 10.5.2 add Deployment Composite & update Deployment Composite
@@ -138,9 +139,6 @@ public interface Section10 { * @param compositeXML
* @return
*/
- String updateDeploymentComposite(String uri, String compositeXML);
-
- /* and similar alternate form: */
String updateDeploymentComposite(String uri, Reader compositeXML);
/**
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 1f6f7d84f2..8f13a35494 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 @@ -31,14 +31,17 @@ import java.util.Map; import java.util.Properties;
import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.common.java.io.IOHelper;
import org.apache.tuscany.sca.contribution.Artifact;
import org.apache.tuscany.sca.contribution.Contribution;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.deployment.Deployer;
import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
import org.apache.tuscany.sca.node.NodeFactory;
import org.apache.tuscany.sca.node.impl.NodeFactoryImpl;
import org.apache.tuscany.sca.runtime.ActivationException;
@@ -50,11 +53,15 @@ import org.oasisopen.sca.client.SCAClientFactory; public class Section10Impl implements Section10 {
protected NodeFactoryImpl nodeFactory;
+ protected Deployer deployer;
protected Map<String, InstalledContribution> installedContributions = new HashMap<String, InstalledContribution>();
+ protected MonitorFactory monitorFactory;
public Section10Impl(Properties config) {
this.nodeFactory = (NodeFactoryImpl)NodeFactory.newInstance(config);
((NodeFactoryImpl)nodeFactory).start();
+ this.deployer = nodeFactory.getDeployer();
+ this.monitorFactory = nodeFactory.getExtensionPointRegistry().getExtensionPoint(UtilityExtensionPoint.class).getUtility(MonitorFactory.class);
}
public String installContribution(String contributionURL) throws ContributionReadException, ActivationException {
@@ -76,7 +83,6 @@ public class Section10Impl implements Section10 { }
public void installContribution(String uri, String contributionURL, List<String> dependentContributionURIs, boolean autoDeploy) throws ContributionReadException, ActivationException {
- Deployer deployer = nodeFactory.getDeployer();
Monitor monitor = deployer.createMonitor();
URL url = getLocationAsURL(contributionURL);
Contribution contribution = deployer.loadContribution(URI.create(uri), url, monitor);
@@ -89,14 +95,27 @@ public class Section10Impl implements Section10 { }
}
- public String addDeploymentComposite(String contriubutionURI, String compositeXML) {
- // TODO Auto-generated method stub
- return null;
- }
+ public String addDeploymentComposite(String contributionURI, Reader compositeXML) throws ContributionReadException, XMLStreamException, ActivationException {
+ InstalledContribution ic = installedContributions.get(contributionURI);
+ if (ic == null) {
+ throw new IllegalArgumentException("contribution not installed: " + contributionURI);
+ }
- public String addDeploymentComposite(String contriubutionURI, Reader compositeXML) {
- // TODO Auto-generated method stub
- return null;
+ Monitor monitor = monitorFactory.createMonitor();
+ Composite composite = deployer.loadXMLDocument(compositeXML, 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);
+
+ deployComposite(composite, ic);
+
+ return compositeArtifcatURI;
}
public void addToDomainLevelComposite(String compositeURI) throws ActivationException {
@@ -164,12 +183,6 @@ public class Section10Impl implements Section10 { // is this just removeContribution/installContribution?
}
- public String updateDeploymentComposite(String uri, String compositeXML) {
- // TODO Auto-generated method stub
- // is this removeFromDomainLevelComposite/addDeploymentComposite
- return null;
- }
-
public String updateDeploymentComposite(String uri, Reader compositeXML) {
// TODO Auto-generated method stub
// is this removeFromDomainLevelComposite/addDeploymentComposite
|