summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java21
-rw-r--r--sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/ValidationException.java40
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);
+ }
+}