tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r609115 - /openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReportValidationResults.java
Date Sat, 05 Jan 2008 10:00:52 GMT
Author: dblevins
Date: Sat Jan  5 02:00:29 2008
New Revision: 609115

URL: http://svn.apache.org/viewvc?rev=609115&view=rev
Log:
Ability to set the validation output level

Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReportValidationResults.java

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReportValidationResults.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReportValidationResults.java?rev=609115&r1=609114&r2=609115&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReportValidationResults.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReportValidationResults.java
Sat Jan  5 02:00:29 2008
@@ -17,6 +17,7 @@
 package org.apache.openejb.config;
 
 import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.util.Logger;
 import org.apache.openejb.util.LogCategory;
 
@@ -25,21 +26,46 @@
  */
 public class ReportValidationResults implements DynamicDeployer {
 
+    private static final String VALIDATION_LEVEL = "openejb.validation.level";
+
+    private enum Level {
+        UNUSED,
+        TERSE,
+        MEDIUM,
+        VERBOSE
+    }
+
     public AppModule deploy(AppModule appModule) throws OpenEJBException {
+        String levelString = SystemInstance.get().getProperty(VALIDATION_LEVEL, Level.MEDIUM.toString());
+
+        Level level;
+        try {
+            level = Level.valueOf(levelString);
+        } catch (IllegalArgumentException noSuchEnumConstant) {
+            try {
+                int i = Integer.parseInt(levelString);
+                level = Level.values()[i];
+            } catch (NumberFormatException e) {
+                level = Level.MEDIUM;
+            }
+        }
+        
+        if (level == Level.UNUSED) level = Level.MEDIUM;
+
         if (!appModule.hasErrors() && !appModule.hasFailures()) return appModule;
 
         ValidationFailedException validationFailedException = null;
 
 
         for (DeploymentModule module : appModule.getEjbModules()) {
-            validationFailedException = logResults(module, validationFailedException);
+            validationFailedException = logResults(module, validationFailedException, level);
         }
 
         for (DeploymentModule module : appModule.getClientModules()) {
-            validationFailedException = logResults(module, validationFailedException);
+            validationFailedException = logResults(module, validationFailedException, level);
         }
 
-        validationFailedException = logResults(appModule, validationFailedException);
+        validationFailedException = logResults(appModule, validationFailedException, level);
 
         if (validationFailedException != null)
             throw validationFailedException;
@@ -47,7 +73,7 @@
         return appModule;
     }
 
-    private ValidationFailedException logResults(DeploymentModule module, ValidationFailedException
validationFailedException) {
+    private ValidationFailedException logResults(DeploymentModule module, ValidationFailedException
validationFailedException, Level level) {
         ValidationResults results = module.getValidation();
 
         if (results.hasErrors() || results.hasFailures()) {
@@ -57,12 +83,12 @@
             for (int j = 0; j < errors.length; j++) {
                 ValidationError e = errors[j];
                 String ejbName = e.getComponentName();
-                logger.error(e.getPrefix() + " ... " + ejbName + ":\t" + e.getMessage(2));
+                logger.error(e.getPrefix() + " ... " + ejbName + ":\t" + e.getMessage(level.ordinal()));
             }
             ValidationFailure[] failures = results.getFailures();
             for (int j = 0; j < failures.length; j++) {
                 ValidationFailure e = failures[j];
-                logger.error(e.getPrefix() + " ... " + e.getComponentName() + ":\t" + e.getMessage(2));
+                logger.error(e.getPrefix() + " ... " + e.getComponentName() + ":\t" + e.getMessage(level.ordinal()));
             }
 
             validationFailedException = new ValidationFailedException("Module failed validation.
"+results.getModuleType()+"(path="+results.getJarPath()+")", results, validationFailedException);



Mime
View raw message