From 7250f4158b1bdfa9f82760cebf0269a40ad21acd Mon Sep 17 00:00:00 2001 From: antelder Date: Sat, 22 May 2010 06:49:50 +0000 Subject: Update with code to deploy composites, add getInstalledContributions and getDeployedComposites. Refactor code to have a separate DeployedComposite class git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@947252 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tuscany/sca/something/Section10.java | 23 +-- .../sca/something/impl/DeployedComposite.java | 158 +++++++++++++++++++ .../apache/tuscany/sca/something/impl/Helper.java | 57 +++++++ .../sca/something/impl/InstalledContribution.java | 5 +- .../tuscany/sca/something/impl/Section10Impl.java | 172 ++++++--------------- 5 files changed, 273 insertions(+), 142 deletions(-) create mode 100644 sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/DeployedComposite.java create mode 100644 sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/Helper.java (limited to 'sca-java-2.x/contrib/modules/section10/src/main') 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 d351426c13..dcdc8f71ab 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 @@ -20,13 +20,13 @@ package org.apache.tuscany.sca.something; import java.io.Reader; -import java.net.MalformedURLException; import java.util.List; import javax.xml.namespace.QName; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.contribution.processor.ContributionReadException; +import org.apache.tuscany.sca.runtime.ActivationException; import org.oasisopen.sca.NoSuchServiceException; public interface Section10 { @@ -56,17 +56,17 @@ public interface Section10 { * 4598 this list to be generated by tooling. * * @param uri * @param contributionURL - * @throws MalformedURLException * @throws ContributionReadException + * @throws ActivationException */ - void installContribution(String uri, String contributionURL, List dependentContributionURIs) throws ContributionReadException, MalformedURLException; + void installContribution(String uri, String contributionURL, List dependentContributionURIs) throws ContributionReadException, ActivationException; /* and i'd expect short forms of that for when you don't care or have the others:*/ - String installContribution(String contributionURL) throws ContributionReadException, MalformedURLException; - void installContribution(String uri, String contributionURL) throws ContributionReadException, MalformedURLException; + String installContribution(String contributionURL) throws ContributionReadException, ActivationException; + void installContribution(String uri, String contributionURL) throws ContributionReadException, ActivationException; /* autoDeploy indicates whether or not to automatically deploy the deployables defined in sca-contribution.xml */ - String installContribution(String contributionURL, boolean autoDeploy) throws ContributionReadException, MalformedURLException; - void installContribution(String uri, String contributionURL, List dependentContributionURIs, boolean autoDeploy) throws ContributionReadException, MalformedURLException; + String installContribution(String contributionURL, boolean autoDeploy) throws ContributionReadException, ActivationException; + void installContribution(String uri, String contributionURL, List dependentContributionURIs, boolean autoDeploy) throws ContributionReadException, ActivationException; /** * 4577 10.5.1 install Contribution & update Contribution @@ -148,8 +148,9 @@ public interface Section10 { * 4612 Removes the deployed contribution identified by a supplied contribution URI. * * @param contributionURI + * @throws ActivationException */ - void removeContribution(String contributionURI); + void removeContribution(String contributionURI) throws ActivationException; /** * 4677 10.7.1 add To Domain-Level Composite @@ -163,8 +164,9 @@ public interface Section10 { * 4686 outside the domain composite, the usual idea of promotion has no utility. * * @param compositeURI + * @throws ActivationException */ - void addToDomainLevelComposite(String compositeURI); + void addToDomainLevelComposite(String compositeURI) throws ActivationException; /** * 4687 10.7.2 remove From Domain-Level Composite @@ -172,8 +174,9 @@ public interface Section10 { * 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. * * @param compositeURI + * @throws ActivationException */ - void removeFromDomainLevelComposite(String compositeURI); + void removeFromDomainLevelComposite(String compositeURI) throws ActivationException; /** * 10.7.3 get 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 new file mode 100644 index 0000000000..226d3c2b87 --- /dev/null +++ b/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/DeployedComposite.java @@ -0,0 +1,158 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.something.impl; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.context.CompositeContext; +import org.apache.tuscany.sca.contribution.Artifact; +import org.apache.tuscany.sca.contribution.Contribution; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +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.monitor.Problem; +import org.apache.tuscany.sca.monitor.Problem.Severity; +import org.apache.tuscany.sca.runtime.ActivationException; +import org.apache.tuscany.sca.runtime.CompositeActivator; +import org.apache.tuscany.sca.runtime.EndpointRegistry; +import org.oasisopen.sca.ServiceRuntimeException; + +public class DeployedComposite { + + private Composite c; + private InstalledContribution ic; + private List dependentContributions; + private String uri; + + private CompositeActivator compositeActivator; + private CompositeContext compositeContext; + private Composite domainComposite; // TODO: this is a misleadingly named + private Deployer deployer; + private MonitorFactory monitorFactory; + private EndpointRegistry endpointRegistry; + private ExtensionPointRegistry extensionPointRegistry; + + public DeployedComposite(Composite c, + InstalledContribution ic, + List dependentContributions, + Deployer deployer, + CompositeActivator compositeActivator, + MonitorFactory monitorFactory, + EndpointRegistry endpointRegistry, + ExtensionPointRegistry extensionPointRegistry) throws ActivationException { + this.c = c; + this.ic = ic; + this.dependentContributions = dependentContributions; + this.deployer = deployer; + this.compositeActivator = compositeActivator; + this.monitorFactory = monitorFactory; + this.endpointRegistry = endpointRegistry; + this.extensionPointRegistry = extensionPointRegistry; + try { + init(); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + protected void init() throws Throwable { + + List contributions = new ArrayList(); + contributions.add(ic.getContribution()); + contributions.get(0).getDeployables().clear(); + contributions.get(0).getDeployables().add(c); + + Monitor monitor = monitorFactory.createMonitor(); + Monitor tcm = monitorFactory.setContextMonitor(monitor); + try { + + domainComposite = deployer.build(contributions, dependentContributions, new HashMap>(), monitor); + analyzeProblems(monitor); + + } finally { + monitorFactory.setContextMonitor(tcm); + } + + compositeContext = new CompositeContext(extensionPointRegistry, + endpointRegistry, + domainComposite, + null, // nothing appears to use the domain name in CompositeContext + null, // don't need node uri + deployer.getSystemDefinitions()); + + CompositeContext.setThreadCompositeContext(compositeContext); // TODO: what is this doing? + + compositeActivator.activate(compositeContext, domainComposite); + compositeActivator.start(compositeContext, domainComposite); + + this.uri = getCompositeURI(c, ic); + } + + + public void unDeploy() throws ActivationException { + compositeActivator.stop(compositeContext, domainComposite); + compositeActivator.deactivate(domainComposite); + } + + public String getURI() { + return uri; + } + + /** + * Deployable composites don't have the uri set so get it from the artifact in the contribution + */ + protected String getCompositeURI(Composite c, InstalledContribution ic) { + for (Artifact a : ic.getContribution().getArtifacts()) { + if (a.getModel() != null) { + if (a.getModel() instanceof Composite) { + Composite cm = a.getModel(); + if (c.getName().equals(cm.getName())) { + return cm.getURI(); + } + } + } + } + // shouldn't ever happen + throw new IllegalStateException("can't determine composte uri"); + } + + protected void analyzeProblems(Monitor monitor) throws Throwable { + try { + for (Problem problem : monitor.getProblems()) { + if ((problem.getSeverity() == Severity.ERROR)) { + if (problem.getCause() != null) { + throw problem.getCause(); + } else { + throw new ServiceRuntimeException(problem.toString()); + } + } + } + } finally { + // FIXME: Clear problems so that the monitor is clean again + monitor.reset(); + } + } +} diff --git a/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/Helper.java b/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/Helper.java new file mode 100644 index 0000000000..a8a06ed00b --- /dev/null +++ b/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/Helper.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.something.impl; + +import java.util.List; + +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.contribution.Contribution; +import org.apache.tuscany.sca.core.UtilityExtensionPoint; +import org.apache.tuscany.sca.monitor.MonitorFactory; +import org.apache.tuscany.sca.node.impl.NodeFactoryImpl; +import org.apache.tuscany.sca.runtime.ActivationException; +import org.apache.tuscany.sca.runtime.CompositeActivator; +import org.apache.tuscany.sca.runtime.DomainRegistryFactory; +import org.apache.tuscany.sca.runtime.EndpointRegistry; +import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory; + +public class Helper { + + public static DeployedComposite createDeployedComposite(Composite composite, + InstalledContribution ic, + List dependentContributions, + String domainName, + NodeFactoryImpl nodeFactory) throws ActivationException { + + // TODO: have this code as a separate static method for now to keep the impl class clean while its worked out what it needs + + UtilityExtensionPoint utilities = nodeFactory.getExtensionPointRegistry().getExtensionPoint(UtilityExtensionPoint.class); + CompositeActivator compositeActivator = utilities.getUtility(CompositeActivator.class); + MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class); + + DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(nodeFactory.getExtensionPointRegistry()); + EndpointRegistry endpointRegistry = domainRegistryFactory.getEndpointRegistry("default", domainName); + + return new DeployedComposite(composite, ic, dependentContributions, nodeFactory.getDeployer(), + compositeActivator, monitorFactory, endpointRegistry, + nodeFactory.getExtensionPointRegistry()); + } + +} diff --git a/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/InstalledContribution.java b/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/InstalledContribution.java index 90f81724cf..3fbad6091c 100644 --- a/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/InstalledContribution.java +++ b/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/InstalledContribution.java @@ -22,7 +22,6 @@ package org.apache.tuscany.sca.something.impl; import java.util.ArrayList; import java.util.List; -import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.contribution.Contribution; public class InstalledContribution { @@ -32,7 +31,7 @@ public class InstalledContribution { private String uri; private String url; private Contribution contribution; - private List deployedComposites = new ArrayList(); + private List deployedComposites = new ArrayList(); public InstalledContribution(String uri, String url, Contribution contribution) { this.uri = uri; @@ -51,7 +50,7 @@ public class InstalledContribution { public String getURL() { return url; } - public List getDeployedComposites() { + public List getDeployedComposites() { return deployedComposites; } 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 4130af2a94..608a131505 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 @@ -19,7 +19,6 @@ package org.apache.tuscany.sca.something.impl; -import java.io.ByteArrayOutputStream; import java.io.File; import java.io.Reader; import java.net.MalformedURLException; @@ -32,33 +31,19 @@ import java.util.Map; import java.util.Properties; import javax.xml.namespace.QName; -import javax.xml.stream.XMLOutputFactory; -import org.apache.tuscany.sca.assembly.Component; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.common.java.io.IOHelper; -import org.apache.tuscany.sca.context.CompositeContext; 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.contribution.processor.ProcessorContext; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -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.monitor.Problem; import org.apache.tuscany.sca.monitor.Problem.Severity; import org.apache.tuscany.sca.node.NodeFactory; -import org.apache.tuscany.sca.node.configuration.NodeConfiguration; import org.apache.tuscany.sca.node.impl.NodeFactoryImpl; -import org.apache.tuscany.sca.runtime.CompositeActivator; -import org.apache.tuscany.sca.runtime.DomainRegistryFactory; -import org.apache.tuscany.sca.runtime.EndpointRegistry; -import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory; +import org.apache.tuscany.sca.runtime.ActivationException; import org.apache.tuscany.sca.something.Section10; import org.oasisopen.sca.NoSuchDomainException; import org.oasisopen.sca.NoSuchServiceException; @@ -75,25 +60,25 @@ public class Section10Impl implements Section10 { ((NodeFactoryImpl)nodeFactory).start(); } - public String installContribution(String contributionURL) throws ContributionReadException, MalformedURLException { + public String installContribution(String contributionURL) throws ContributionReadException, ActivationException { installContribution(contributionURL, contributionURL, null, true); return contributionURL; } - public String installContribution(String contributionURL, boolean autoDeploy) throws ContributionReadException, MalformedURLException { + public String installContribution(String contributionURL, boolean autoDeploy) throws ContributionReadException, ActivationException { installContribution(contributionURL, contributionURL, null, autoDeploy); return contributionURL; } - public void installContribution(String uri, String contributionURL) throws ContributionReadException, MalformedURLException { + public void installContribution(String uri, String contributionURL) throws ContributionReadException, ActivationException { installContribution(uri, contributionURL, null, true); } - public void installContribution(String uri, String contributionURL, List dependentContributionURIs) throws ContributionReadException, MalformedURLException { + public void installContribution(String uri, String contributionURL, List dependentContributionURIs) throws ContributionReadException, ActivationException { installContribution(uri, contributionURL, dependentContributionURIs, true); } - public void installContribution(String uri, String contributionURL, List dependentContributionURIs, boolean autoDeploy) throws ContributionReadException, MalformedURLException { + public void installContribution(String uri, String contributionURL, List dependentContributionURIs, boolean autoDeploy) throws ContributionReadException, ActivationException { Deployer deployer = nodeFactory.getDeployer(); Monitor monitor = deployer.createMonitor(); URL url = getLocationAsURL(contributionURL); @@ -102,12 +87,7 @@ public class Section10Impl implements Section10 { installedContributions.put(uri, ic); if (autoDeploy) { for (Composite c : contribution.getDeployables()) { - try { - deployComposite(c, ic); - } catch (Throwable e) { - // TODO tidy up the exceptions - throw new RuntimeException(e); - } + deployComposite(c, ic); } } } @@ -122,7 +102,7 @@ public class Section10Impl implements Section10 { return null; } - public void addToDomainLevelComposite(String compositeURI) { + public void addToDomainLevelComposite(String compositeURI) throws ActivationException { String contributionURI = getContributionUriForArtifact(compositeURI); InstalledContribution ic = installedContributions.get(contributionURI); if (ic == null) { @@ -132,25 +112,22 @@ public class Section10Impl implements Section10 { for (Artifact a : ic.getContribution().getArtifacts()) { if (a.getURI().equals(relativeURI)) { Composite c = (Composite) a.getModel(); - try { - deployComposite(c, ic); - } catch (Throwable e) { - // TODO tidy up the exceptions - throw new RuntimeException(e); - } + deployComposite(c, ic); return; } } throw new IllegalArgumentException("composite not found: " + compositeURI); } - public void removeFromDomainLevelComposite(String compositeURI) { + public void removeFromDomainLevelComposite(String compositeURI) throws ActivationException { String contributionURI = getContributionUriForArtifact(compositeURI); InstalledContribution ic = installedContributions.get(contributionURI); String relativeURI = compositeURI.substring(contributionURI.length()+1); - for (Composite c : ic.getDeployedComposites()) { - if (relativeURI.equals(c.getURI())) { - undeployComposite(c, ic); + for (DeployedComposite dc : ic.getDeployedComposites()) { + if (relativeURI.equals(dc.getURI())) { +// undeployComposite(dc, ic); + ic.getDeployedComposites().remove(dc); + dc.unDeploy(); return; } } @@ -163,9 +140,8 @@ public class Section10Impl implements Section10 { } public String getDomainLevelCompositeAsString() { - StAXArtifactProcessorExtensionPoint xmlProcessors = getExtensionRegistry().getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - StAXArtifactProcessor compositeProcessor = xmlProcessors.getProcessor(Composite.class); - return writeComposite(getDomainLevelComposite(), compositeProcessor); + // TODO Auto-generated method stub + return null; } public Object getQNameDefinition(String contributionURI, QName definition, QName symbolSpace) { @@ -173,15 +149,17 @@ public class Section10Impl implements Section10 { return null; } - public void removeContribution(String contributionURI) { + public void removeContribution(String contributionURI) throws ActivationException { // TODO: what about dependent contributions InstalledContribution ic = installedContributions.remove(contributionURI); if (ic == null) { throw new IllegalArgumentException("Contribution not installed: " + contributionURI); } - for (Composite c : ic.getDeployedComposites()) { - undeployComposite(c, ic); + for (DeployedComposite dc : ic.getDeployedComposites()) { +// undeployComposite(dc, ic); + dc.unDeploy(); } + ic.getDeployedComposites().clear(); } public void updateContribution(String uri, String contributionURL) { @@ -220,13 +198,17 @@ public class Section10Impl implements Section10 { } public List getDeployedCompostes(String contributionURI) { - // TODO Auto-generated method stub - return null; + ArrayList compositeURIs = new ArrayList(); + for (InstalledContribution ic : installedContributions.values()) { + for (DeployedComposite dc : ic.getDeployedComposites()) { + compositeURIs.add(ic.getURI() + "/" + dc.getURI()); + } + } + return compositeURIs; } - public List getInstalledContributions(String contributionURI) { - // TODO Auto-generated method stub - return null; + public List getInstalledContributions() { + return new ArrayList(installedContributions.keySet()); } protected String getContributionUriForArtifact(String artifactURI) { @@ -243,95 +225,27 @@ public class Section10Impl implements Section10 { return contributionURI; } - protected void deployComposite(Composite c, InstalledContribution ic) throws Throwable { - // TODO Auto-generated method stub - - UtilityExtensionPoint utilities = getExtensionRegistry().getExtensionPoint(UtilityExtensionPoint.class); - CompositeActivator compositeActivator = utilities.getUtility(CompositeActivator.class); - MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class); - - DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(getExtensionRegistry()); - EndpointRegistry endpointRegistry = domainRegistryFactory.getEndpointRegistry("default", getDomainName()); - - Monitor monitor = monitorFactory.createMonitor(); - ProcessorContext context = new ProcessorContext(monitor); - - Composite domainComposite; - CompositeContext compositeContext; - Monitor tcm = monitorFactory.setContextMonitor(monitor); - try { - - NodeConfiguration configuration; - List allContributions = new ArrayList(); - for (InstalledContribution ics : installedContributions.values()) { - allContributions.add(ics.getContribution()); - } - - List contributions = new ArrayList(); - contributions.add(ic.getContribution()); - contributions.get(0).getDeployables().clear(); - contributions.get(0).getDeployables().add(c); - domainComposite = nodeFactory.getDeployer().build(contributions, allContributions, new HashMap>(), monitor); - analyzeProblems(monitor); + protected void deployComposite(Composite c, InstalledContribution ic) throws ActivationException { - compositeContext = new CompositeContext(getExtensionRegistry(), - endpointRegistry, - domainComposite, - getDomainName(), - "whatIsThisURIfor", - nodeFactory.getDeployer().getSystemDefinitions()); - - CompositeContext.setThreadCompositeContext(compositeContext); - } finally { - monitorFactory.setContextMonitor(tcm); + List dependentContributions = new ArrayList(); + for (InstalledContribution ics : installedContributions.values()) { + dependentContributions.add(ics.getContribution()); } - - compositeActivator.activate(compositeContext, domainComposite); - compositeActivator.start(compositeContext, domainComposite); - - ic.getDeployedComposites().add(c); - } - - protected void undeployComposite(Composite c, InstalledContribution ic) { - ic.getDeployedComposites().remove(c); - // TODO Auto-generated method stub - } - - protected ExtensionPointRegistry getExtensionRegistry() { - ExtensionPointRegistry reg = nodeFactory.getExtensionPointRegistry(); - return reg; - } - protected String writeComposite(Composite composite, StAXArtifactProcessor compositeProcessor){ - XMLOutputFactory outputFactory = getExtensionRegistry().getExtensionPoint(FactoryExtensionPoint.class).getFactory(XMLOutputFactory.class); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - try { - compositeProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), new ProcessorContext(getExtensionRegistry())); - } catch(Exception e) { - throw new RuntimeException(e); - } - - String result = bos.toString(); - - // write out and nested composites - for (Component component : composite.getComponents()) { - if (component.getImplementation() instanceof Composite) { - result += "\n\n"; - result += writeComposite((Composite)component.getImplementation(), compositeProcessor); - } - } - - return result; + DeployedComposite dc = Helper.createDeployedComposite(c, ic, dependentContributions, getDomainName(), nodeFactory); + ic.getDeployedComposites().add(dc); } - protected URL getLocationAsURL(String location) throws MalformedURLException { + protected URL getLocationAsURL(String location) throws ContributionReadException { URI uri = IOHelper.createURI(location); if (uri.getScheme() == null) { uri = new File(location).toURI(); } - URL url = uri.toURL(); - return url; + try { + return uri.toURL(); + } catch (MalformedURLException e) { + throw new ContributionReadException(e); + } } protected void analyzeProblems(Monitor monitor) throws Throwable { -- cgit v1.2.3