diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-05-26 20:14:58 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-05-26 20:14:58 +0000 |
commit | d732ec25dea1575cf5ddcfd211a76b5ac4adfacc (patch) | |
tree | e97166e26e2c8a63aa7dbab593df7dd26c37b2f8 /sca-java-2.x/trunk/modules/monitor | |
parent | 142168eae3c0ca47bdb22bb539b746b7b2607888 (diff) |
Add an analyzeProblems method to Monitor
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@948567 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/monitor')
2 files changed, 61 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java b/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java index 0dc646d216..3eda98ee23 100644 --- a/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java +++ b/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java @@ -340,4 +340,25 @@ public abstract class Monitor { public abstract void setArtifactName(String artifactName); // ===================================================== + + /** + * Checks the Monitor for any Problems with s severity of ERROR and + * if one is found then throw a ValidationException. + * This will also call reset() on this Monitor. + */ + public void analyzeProblems() throws ValidationException { + try { + for (Problem problem : getProblems()) { + if ((problem.getSeverity() == Severity.ERROR)) { + if (problem.getCause() != null) { + throw new ValidationException(problem.getCause()); + } else { + throw new ValidationException(problem.toString()); + } + } + } + } finally { + reset(); + } + } } diff --git a/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/ValidationException.java b/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/ValidationException.java new file mode 100644 index 0000000000..47975870bf --- /dev/null +++ b/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/ValidationException.java @@ -0,0 +1,40 @@ +/*
+ * 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.monitor;
+
+public class ValidationException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public ValidationException() {
+ super();
+ }
+
+ public ValidationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ValidationException(String message) {
+ super(message);
+ }
+
+ public ValidationException(Throwable cause) {
+ super(cause);
+ }
+}
|