1 23 package com.sun.enterprise.deployment.annotation.impl; 24 25 import java.util.logging.Logger ; 26 import java.util.logging.*; 27 import java.util.ResourceBundle ; 28 import java.text.MessageFormat ; 29 30 import com.sun.enterprise.deployment.annotation.ErrorHandler; 31 32 37 public class AnnotationUtils { 38 39 private static Logger logger; 40 private static String whatToLog=""; 41 private static ResourceBundle resourceBundle; 42 43 44 private AnnotationUtils() { 45 resourceBundle = ResourceBundle.getBundle("LocalStrings"); 46 } 47 48 public static Logger getLogger() { 49 if (logger==null) { 50 logger = Logger.global; 51 } 52 return logger; 53 } 54 55 public static void setLogger(Logger lg) { 56 logger = lg; 57 } 58 59 public static void setLoggerTarget(String what) { 60 whatToLog = what; 61 } 62 63 public static String getLoggerTarget() { 64 return whatToLog; 65 } 66 67 public static boolean shouldLog(String what) { 68 69 if (logger.isLoggable(Level.FINER)) { 70 if (whatToLog.indexOf(what)!=-1) 71 return true; 72 if ("*".equals(whatToLog)) 73 return true; 74 } 75 return false; 76 } 77 78 public static String getLocalString(String key, String defaultString, Object ... arguments){ 79 String value = defaultString; 80 if (resourceBundle!=null && resourceBundle.getString(key)!=null){ 81 value = resourceBundle.getString(key); 82 } 83 return MessageFormat.format(value, arguments); 84 } 85 } 86 | Popular Tags |