From d732ec25dea1575cf5ddcfd211a76b5ac4adfacc Mon Sep 17 00:00:00 2001 From: antelder Date: Wed, 26 May 2010 20:14:58 +0000 Subject: Add an analyzeProblems method to Monitor git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@948567 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tuscany/sca/monitor/Monitor.java | 21 ++++++++++++ .../tuscany/sca/monitor/ValidationException.java | 40 ++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/ValidationException.java (limited to 'sca-java-2.x') 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); + } +} -- cgit v1.2.3