KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > appverification > factory > AppVerification


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
24 package com.sun.enterprise.appverification.factory;
25
26 import com.sun.enterprise.util.LocalStringManagerImpl;
27
28 //START OF IASRI 4660742
29
import java.util.logging.*;
30 import com.sun.logging.*;
31 //END OF IASRI 4660742
32

33 /**
34  *
35  * @author Qingqing Ouyang
36  */

37 public abstract class AppVerification {
38
39     // START OF IASRI 4660742
40
static Logger _logger=LogDomains.getLogger(LogDomains.APPVERIFY_LOGGER);
41     // END OF IASRI 4660742
42

43     private static boolean instrument_on = false;
44     private static boolean redeploy = false;
45
46     private static InstrumentLogger instrumentLogger;
47     private static LocalStringManagerImpl localStrings =
48         new LocalStringManagerImpl(AppVerification.class);
49     
50     public static void redeploy (boolean hasRedeploy) {
51         redeploy = hasRedeploy;
52     }
53     
54     public static boolean hasRedeployed () {
55         return redeploy;
56     }
57     
58     public static void setInstrument (boolean on) {
59         if (on && getInstrumentLogger() == null) {
60             instrument_on = false;
61              /** IASRI 4660742
62             System.out.println(
63                     localStrings.getLocalString(
64                             "appverification.instrument.on.failed",
65                             "J2EE instrumentation implementation class NOT defined."));
66             System.out.println(
67                     localStrings.getLocalString(
68                             "appverification.instrument.off",
69                             "J2EE Application Verification is OFF..."));
70              **/

71              // START OF IASRI 4660742
72
if (_logger.isLoggable(Level.FINE)){
73              _logger.log(Level.FINE,localStrings.getLocalString(
74                             "appverification.instrument.on.failed",
75                             "J2EE instrumentation implementation class NOT defined."));
76              _logger.log(Level.FINE,localStrings.getLocalString(
77                             "appverification.instrument.off",
78                             "J2EE Application Verification is OFF..."));
79
80                     }
81              // END OF IASRI 4660742
82
} else {
83             instrument_on = on;
84             if (instrument_on) {
85                     /** IASRI 4660742
86                 System.out.println(
87                         localStrings.getLocalString(
88                                 "appverification.instrument.on",
89                                 "J2EE Application Verification {0} is ON...",
90                                 new Object[] {instrumentLogger.getVersion()}));
91                     **/

92                   // START OF IASRI 4660742
93
if (_logger.isLoggable(Level.FINE))
94                     _logger.log(Level.FINE,localStrings.getLocalString(
95                                 "appverification.instrument.on",
96                                 "J2EE Application Verification {0} is ON...",
97                                 new Object JavaDoc[] {instrumentLogger.getVersion()}));
98                   // END OF IASRI 4660742
99
}
100         }
101     }
102     
103     public static boolean doInstrument() {
104         return instrument_on;
105     }
106     
107     public static InstrumentLogger getInstrumentLogger() {
108         if (instrumentLogger == null) {
109             String JavaDoc name = null;
110             Class JavaDoc cls = null;
111             try {
112                 name = System.getProperty(
113                         "j2ee.instrument.logger",
114                         "com.sun.enterprise.appverification.tools.InstrumentLoggerImpl");
115                 cls = Class.forName(name);
116                 if (cls != null) {
117                     instrumentLogger = (InstrumentLogger)cls.newInstance();
118                 }
119             } catch (ClassNotFoundException JavaDoc e) {
120                     /** IASRI 4660742
121                 System.err.println(
122                         localStrings.getLocalString(
123                                 "appverification.class.notfound",
124                                 "Class {0} not found",
125                                 new Object[] {name}));
126                     **/

127                   // START OF IASRI 4660742
128
_logger.log(Level.SEVERE,"appverification.class_notfound", new Object JavaDoc[] {name});
129                   // END OF IASRI 4660742
130
} catch (InstantiationException JavaDoc e) {
131                     /** IASRI 4660742
132                 System.err.println(
133                         localStrings.getLocalString(
134                                 "appverification.class.instantiate.error",
135                                 "Could not instantiate class {0}",
136                                 new Object[] {name}));
137                     **/

138                   // START OF IASRI 4660742
139
_logger.log(Level.SEVERE,"appverification.class_instantiate_error", new Object JavaDoc[] {name});
140                   // END OF IASRI 4660742
141
} catch (IllegalAccessException JavaDoc e) {
142                     /** IASRI 4660742
143                 System.err.println(
144                         localStrings.getLocalString(
145                                 "appverification.class.access.error",
146                                 "Could not access class {0}",
147                                 new Object[] {name}));
148                     **/

149                   // START OF IASRI 4660742
150
_logger.log(Level.SEVERE,"appverification.class_access_error", new Object JavaDoc[] {name});
151
152                    // END OF IASRI 4660742
153
}
154         }
155         return instrumentLogger;
156     }
157 }
158
Popular Tags