1 23 24 package com.sun.enterprise.tools.verifier; 25 26 import java.lang.reflect.Method ; 27 import java.lang.reflect.InvocationTargetException ; 28 import com.sun.enterprise.util.LocalStringManagerImpl; 29 import java.util.logging.*; 30 import com.sun.logging.*; 31 32 36 public class VerifierResultsImpl implements VerifierResults { 37 38 static Logger _logger=LogDomains.getLogger(LogDomains.APPVERIFY_LOGGER); 39 40 private static LocalStringManagerImpl localStrings = 41 new LocalStringManagerImpl(VerifierResultsImpl.class); 42 43 private static Class resultsReportClass=null; 44 private static Method failedCountMethod=null; 45 private static Method errorCountMethod=null; 46 private static Method warningCountMethod=null; 47 48 private Object resultObj; 49 50 public VerifierResultsImpl(Object result) { 51 resultObj = result; 52 } 53 54 55 public int getFailedCount() { 56 57 init(); 58 if ((failedCountMethod == null) || (resultObj == null)) { 59 return -1; 60 } 61 String name = resultsReportClass.getName(); 62 63 try { 64 Object result = failedCountMethod.invoke(resultObj,null); 65 return ((Integer )result).intValue(); 66 } catch (IllegalAccessException e) { 67 _logger.log(Level.SEVERE,"verification.class.access.error", new Object [] {name}); 68 } catch (InvocationTargetException e) { 69 _logger.log(Level.SEVERE,"verification.method.error", new Object [] {"verifyEar", 70 e.getMessage()}); 71 } 72 73 return -1; 74 } 75 76 77 public int getWarningCount() { 78 init(); 79 if ((warningCountMethod == null) || (resultObj == null)) { 80 return -1; 81 } 82 String name = resultsReportClass.getName(); 83 84 try { 85 Object result = warningCountMethod.invoke(resultObj,null); 86 return ((Integer )result).intValue(); 87 } catch (IllegalAccessException e) { 88 _logger.log(Level.SEVERE,"verification.class.access.error", new Object [] {name}); 89 } catch (InvocationTargetException e) { 90 _logger.log(Level.SEVERE,"verification.method.error", new Object [] {"verifyEar", 91 e.getMessage()}); 92 } 93 94 return -1; 95 } 96 97 98 public int getErrorCount() { 99 init(); 100 if ((errorCountMethod == null) || (resultObj == null)) { 101 return -1; 102 } 103 104 String name = resultsReportClass.getName(); 105 106 try { 107 Object result = errorCountMethod.invoke(resultObj,null); 108 return ((Integer )result).intValue(); 109 } catch (IllegalAccessException e) { 110 _logger.log(Level.SEVERE,"verification.class.access.error", new Object [] {name}); 111 } catch (InvocationTargetException e) { 112 _logger.log(Level.SEVERE,"verification.method.error", new Object [] {"verifyEar", 113 e.getMessage()}); 114 } 115 116 return -1; 117 } 118 119 private void init() { 120 121 if (resultsReportClass != null) { 122 return; 123 } 124 String name = null; 125 try { 126 name = System.getProperty("j2ee.verifier.ResultsReport", 127 "com.sun.enterprise.tools.verifier.ResultsReport"); 128 resultsReportClass = Class.forName(name); 129 warningCountMethod = resultsReportClass.getDeclaredMethod("getWarningCount",null); 130 failedCountMethod = resultsReportClass.getDeclaredMethod("getFailedCount",null); 131 errorCountMethod = resultsReportClass.getDeclaredMethod("getErrorCount",null); 132 133 } catch (ClassNotFoundException e) { 134 _logger.log(Level.SEVERE,"verification.class.notfound", new Object [] {name}); 135 } 136 catch (NoSuchMethodException e) { 137 _logger.log(Level.SEVERE,"verification.method.notfound", new Object [] {e.getMessage() , name}); 138 } 139 } 140 141 } 142 143 | Popular Tags |