KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > annotation > impl > AnnotationUtils


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.deployment.annotation.impl;
24
25 import java.util.logging.Logger JavaDoc;
26 import java.util.logging.*;
27 import java.util.ResourceBundle JavaDoc;
28 import java.text.MessageFormat JavaDoc;
29
30 import com.sun.enterprise.deployment.annotation.ErrorHandler;
31
32 /**
33  * Bag for utility methods
34  *
35  * @author Jerome Dochez
36  */

37 public class AnnotationUtils {
38     
39     private static Logger JavaDoc logger;
40     private static String JavaDoc whatToLog="";
41     private static ResourceBundle JavaDoc resourceBundle;
42     
43     /** Creates a new instance of AnnotationUtils */
44     private AnnotationUtils() {
45         resourceBundle = ResourceBundle.getBundle("LocalStrings");
46     }
47     
48     public static Logger JavaDoc getLogger() {
49         if (logger==null) {
50             logger = Logger.global;
51         }
52         return logger;
53     }
54
55     public static void setLogger(Logger JavaDoc lg) {
56         logger = lg;
57     }
58     
59     public static void setLoggerTarget(String JavaDoc what) {
60         whatToLog = what;
61     }
62     
63     public static String JavaDoc getLoggerTarget() {
64         return whatToLog;
65     }
66     
67     public static boolean shouldLog(String JavaDoc 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 JavaDoc getLocalString(String JavaDoc key, String JavaDoc defaultString, Object JavaDoc... arguments){
79         String JavaDoc 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