You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2010/05/26 22:14:58 UTC

svn commit: r948567 - in /tuscany/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor: Monitor.java ValidationException.java

Author: antelder
Date: Wed May 26 20:14:58 2010
New Revision: 948567

URL: http://svn.apache.org/viewvc?rev=948567&view=rev
Log:
Add an analyzeProblems method to Monitor

Added:
    tuscany/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/ValidationException.java
Modified:
    tuscany/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java

Modified: tuscany/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java?rev=948567&r1=948566&r2=948567&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java Wed May 26 20:14:58 2010
@@ -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();
+        }
+    }
 }

Added: tuscany/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/ValidationException.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/ValidationException.java?rev=948567&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/ValidationException.java (added)
+++ tuscany/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/ValidationException.java Wed May 26 20:14:58 2010
@@ -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);
+    }
+}