diff options
Diffstat (limited to 'sca-java-2.x')
3 files changed, 26 insertions, 41 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 845145718c..0704de8f35 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 @@ -27,6 +27,7 @@ import javax.xml.stream.XMLStreamException; import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.monitor.ValidationException;
import org.apache.tuscany.sca.runtime.ActivationException;
import org.oasisopen.sca.NoSuchServiceException;
@@ -59,15 +60,16 @@ public interface Section10 { * @param contributionURL
* @throws ContributionReadException
* @throws ActivationException
+ * @throws ValidationException
*/
- void installContribution(String uri, String contributionURL, List<String> dependentContributionURIs) throws ContributionReadException, ActivationException;
+ void installContribution(String uri, String contributionURL, List<String> dependentContributionURIs) throws ContributionReadException, ActivationException, ValidationException;
/* and i'd expect short forms of that for when you don't care or have the others:*/
- String installContribution(String contributionURL) throws ContributionReadException, ActivationException;
- void installContribution(String uri, String contributionURL) throws ContributionReadException, ActivationException;
+ String installContribution(String contributionURL) throws ContributionReadException, ActivationException, ValidationException;
+ void installContribution(String uri, String contributionURL) throws ContributionReadException, ActivationException, ValidationException;
/* autoDeploy indicates whether or not to automatically deploy the deployables defined in sca-contribution.xml */
- String installContribution(String contributionURL, boolean autoDeploy) throws ContributionReadException, ActivationException;
- void installContribution(String uri, String contributionURL, List<String> dependentContributionURIs, boolean autoDeploy) throws ContributionReadException, ActivationException;
+ String installContribution(String contributionURL, boolean autoDeploy) throws ContributionReadException, ActivationException, ValidationException;
+ void installContribution(String uri, String contributionURL, List<String> dependentContributionURIs, boolean autoDeploy) throws ContributionReadException, ActivationException, ValidationException;
/**
* 4577 10.5.1 install Contribution & update Contribution
@@ -118,8 +120,9 @@ public interface Section10 { * @throws XMLStreamException
* @throws ContributionReadException
* @throws ActivationException
+ * @throws ValidationException
*/
- String addDeploymentComposite(String contriubutionURI, Reader compositeXML) throws ContributionReadException, XMLStreamException, ActivationException;
+ String addDeploymentComposite(String contriubutionURI, Reader compositeXML) throws ContributionReadException, XMLStreamException, ActivationException, ValidationException;
/**
* 4599 10.5.2 add Deployment Composite & update Deployment 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 4f6f3f8b9f..0ac3162122 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 @@ -26,19 +26,19 @@ import java.util.List; import javax.xml.namespace.QName;
import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
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.ContributionResolveException;
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.monitor.ValidationException;
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 {
@@ -73,12 +73,12 @@ public class DeployedComposite { this.extensionPointRegistry = extensionPointRegistry;
try {
init();
- } catch (Throwable e) {
- throw new RuntimeException(e);
+ } catch (Exception e) {
+ throw new ActivationException(e);
}
}
- protected void init() throws Throwable {
+ protected void init() throws ValidationException, ContributionResolveException, CompositeBuilderException, ActivationException {
List<Contribution> contribution = new ArrayList<Contribution>();
contribution.add(installedContribution.getContribution());
@@ -90,7 +90,7 @@ public class DeployedComposite { try {
domainComposite = deployer.build(contribution, dependedOnContributions, new HashMap<QName, List<String>>(), monitor);
- analyzeProblems(monitor);
+ monitor.analyzeProblems();
} finally {
monitorFactory.setContextMonitor(tcm);
@@ -138,23 +138,4 @@ public class DeployedComposite { // shouldn't ever happen
throw new IllegalStateException("can't determine composte uri");
}
-
- /**
- * // TODO: this method should be on the Monitor class
- */
- 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 {
- monitor.reset();
- }
- }
}
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 183591e9bf..09675a1292 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 @@ -41,6 +41,7 @@ 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.ValidationException;
import org.apache.tuscany.sca.runtime.ActivationException;
import org.apache.tuscany.sca.runtime.CompositeActivator;
import org.apache.tuscany.sca.runtime.EndpointRegistry;
@@ -68,29 +69,29 @@ public class Section10Impl implements Section10 { this.extensionPointRegistry = extensionPointRegistry;
}
- public String installContribution(String contributionURL) throws ContributionReadException, ActivationException {
+ public String installContribution(String contributionURL) throws ContributionReadException, ActivationException, ValidationException {
installContribution(contributionURL, contributionURL, null, true);
return contributionURL;
}
- public String installContribution(String contributionURL, boolean autoDeploy) throws ContributionReadException, ActivationException {
+ public String installContribution(String contributionURL, boolean autoDeploy) throws ContributionReadException, ActivationException, ValidationException {
installContribution(contributionURL, contributionURL, null, autoDeploy);
return contributionURL;
}
- public void installContribution(String uri, String contributionURL) throws ContributionReadException, ActivationException {
+ public void installContribution(String uri, String contributionURL) throws ContributionReadException, ActivationException, ValidationException {
installContribution(uri, contributionURL, null, true);
}
- public void installContribution(String uri, String contributionURL, List<String> dependentContributionURIs) throws ContributionReadException, ActivationException {
+ public void installContribution(String uri, String contributionURL, List<String> dependentContributionURIs) throws ContributionReadException, ActivationException, ValidationException {
installContribution(uri, contributionURL, dependentContributionURIs, true);
}
- public void installContribution(String uri, String contributionURL, List<String> dependentContributionURIs, boolean autoDeploy) throws ContributionReadException, ActivationException {
- Monitor monitor = deployer.createMonitor();
+ public void installContribution(String uri, String contributionURL, List<String> dependentContributionURIs, boolean autoDeploy) throws ContributionReadException, ActivationException, ValidationException {
URL url = IOHelper.getLocationAsURL(contributionURL);
+ Monitor monitor = deployer.createMonitor();
Contribution contribution = deployer.loadContribution(URI.create(uri), url, monitor);
- // TODO: does this need to do check the monitor
+ monitor.analyzeProblems();
InstalledContribution ic = new InstalledContribution(uri, url.toString(), contribution);
installedContributions.put(uri, ic);
if (autoDeploy) {
@@ -100,7 +101,7 @@ public class Section10Impl implements Section10 { }
}
- public String addDeploymentComposite(String contributionURI, Reader compositeXML) throws ContributionReadException, XMLStreamException, ActivationException {
+ public String addDeploymentComposite(String contributionURI, Reader compositeXML) throws ContributionReadException, XMLStreamException, ActivationException, ValidationException {
InstalledContribution ic = installedContributions.get(contributionURI);
if (ic == null) {
throw new IllegalArgumentException("contribution not installed: " + contributionURI);
@@ -108,7 +109,7 @@ public class Section10Impl implements Section10 { Monitor monitor = monitorFactory.createMonitor();
Composite composite = deployer.loadXMLDocument(compositeXML, monitor);
- // TODO: does this need to do check the monitor
+ monitor.analyzeProblems();
String compositeArtifcatURI = deployer.attachDeploymentComposite(ic.getContribution(), composite, true);
deployComposite(composite, ic);
|