1 23 24 28 29 package com.sun.appserv.management.event; 30 31 import java.util.Map ; 32 import java.util.HashMap ; 33 import javax.management.Notification ; 34 35 36 40 public class TraceEventHelper { 41 42 public static final String REQUEST_ID = 43 "com.sun.appserv.management.event.trace.requestid"; 44 45 public static final String REQUEST_TYPE = 46 "com.sun.appserv.management.event.trace.requesttype"; 47 48 public static final String CALLER_IPADDRESS = 49 "com.sun.appserv.management.event.trace.callerip"; 50 51 public static final String CALLER_PRINCIPAL = 52 "com.sun.appserv.management.event.trace.callerprincipal"; 53 54 public static final String NANO_TIME = 55 "com.sun.appserv.management.event.trace.nanotime"; 56 57 public static final String THREAD_ID = 58 "com.sun.appserv.management.event.trace.threadid"; 59 60 public static final String METHOD_NAME = 61 "com.sun.appserv.management.event.trace.methodname"; 62 63 public static final String COMPONENT_TYPE = 64 "com.sun.appserv.management.event.trace.componenttype"; 65 66 public static final String COMPONENT_NAME = 67 "com.sun.appserv.management.event.trace.componentname"; 68 69 public static final String APPLICATION_NAME = 70 "com.sun.appserv.management.event.trace.applicationname"; 71 72 public static final String MODULE_NAME = 73 "com.sun.appserv.management.event.trace.modulename"; 74 75 public static final String TRANSACTION_ID = 76 "com.sun.appserv.management.event.trace.transactionid"; 77 78 public static final String SECURITY_ID = 79 "com.sun.appserv.management.event.trace.securityid"; 80 81 public static final String EXCEPTION = 82 "com.sun.appserv.management.event.trace.exception"; 83 84 public static final String EXCEPTION_OBJECT = 85 "com.sun.appserv.management.event.trace.exceptionobject"; 86 87 public static final String REQUEST_START = "trace.request_start"; 89 public static final String REQUEST_END = "trace.request_end"; 90 public static final String WEB_COMPONENT_METHOD_ENTRY = 91 "trace.web_component_method_entry"; 92 public static final String WEB_COMPONENT_METHOD_EXIT = 93 "trace.web_component_method_exit"; 94 public static final String EJB_COMPONENT_METHOD_ENTRY = 95 "trace.ejb_component_method_entry"; 96 public static final String EJB_COMPONENT_METHOD_EXIT = 97 "trace.ejb_component_method_exit"; 98 99 100 101 102 public TraceEventHelper(Notification notif) { 103 if (notif.getUserData() == null) 104 throw new IllegalArgumentException (); 105 Object uData = notif.getUserData(); 106 if (!(uData instanceof Map )) { 107 throw new IllegalArgumentException (); 108 } 109 this.userData = (HashMap )((HashMap )uData).clone(); 110 } 111 112 public TraceEventHelper(Map userData) { 113 this.userData = (HashMap )((HashMap )userData).clone(); 114 } 115 116 public String getRequestId() { 117 return (String )userData.get(REQUEST_ID); 118 } 119 120 public String getRequestId(Notification notification) { 121 Object userData = notification.getUserData(); 122 if (userData != null) { 123 return (String )((Map )userData).get(REQUEST_ID); 124 } else { 125 return null; 126 } 127 } 128 129 public String getRequestType() { 130 return (String )userData.get(REQUEST_TYPE); 131 } 132 133 public static String getRequestType(Notification notification) { 134 Object userData = notification.getUserData(); 135 if (userData != null) { 136 return (String )((Map )userData).get(REQUEST_TYPE); 137 } else { 138 return null; 139 } 140 } 141 142 public String getCallerIP() { 143 return (String )userData.get(CALLER_IPADDRESS); 144 } 145 146 public static String getCallerIP(Notification notification) { 147 Object userData = notification.getUserData(); 148 if (userData != null) { 149 return (String )((Map )userData).get(CALLER_IPADDRESS); 150 } else { 151 return null; 152 } 153 } 154 155 public String getCallerPrincipal() { 156 return (String )userData.get(CALLER_PRINCIPAL); 157 } 158 159 public static String getCallerPrincipal(Notification notification) { 160 Object userData = notification.getUserData(); 161 if (userData != null) { 162 return (String )((Map )userData).get(CALLER_PRINCIPAL); 163 } else { 164 return null; 165 } 166 } 167 168 public Long getNanoTime() { 169 return (Long )userData.get(NANO_TIME); 170 } 171 172 public static Long getNanoTime(Notification notification) { 173 Object userData = notification.getUserData(); 174 if (userData != null) { 175 return (Long )((Map )userData).get(NANO_TIME); 176 } else { 177 return -1L; 178 } 179 } 180 181 public String getThreadID() { 182 return (String )userData.get(THREAD_ID); 183 } 184 185 public static String getThreadId(Notification notification) { 186 Object userData = notification.getUserData(); 187 if (userData != null) { 188 return (String )((Map )userData).get(THREAD_ID); 189 } else { 190 return null; 191 } 192 } 193 194 public String getMethodName() { 195 return (String )userData.get(METHOD_NAME); 196 } 197 198 public static String getMethodName(Notification notification) { 199 Object userData = notification.getUserData(); 200 if (userData != null) { 201 return (String )((Map )userData).get(METHOD_NAME); 202 } else { 203 return null; 204 } 205 } 206 207 public String getComponentType() { 208 return (String )userData.get(COMPONENT_TYPE); 209 } 210 211 public static String getComponentType(Notification notification) { 212 Object userData = notification.getUserData(); 213 if (userData != null) { 214 return (String )((Map )userData).get(COMPONENT_TYPE); 215 } else { 216 return null; 217 } 218 } 219 220 public String getComponentName() { 221 return (String )userData.get(COMPONENT_NAME); 222 } 223 224 public static String getComponentName(Notification notification) { 225 Object userData = notification.getUserData(); 226 if (userData != null) { 227 return (String )((Map )userData).get(COMPONENT_NAME); 228 } else { 229 return null; 230 } 231 } 232 233 public String getApplicationName() { 234 return (String )userData.get(APPLICATION_NAME); 235 } 236 237 public static String getApplicationName(Notification notification) { 238 Object userData = notification.getUserData(); 239 if (userData != null) { 240 return (String )((Map )userData).get(APPLICATION_NAME); 241 } else { 242 return null; 243 } 244 } 245 246 public String getModuleName() { 247 return (String )userData.get(MODULE_NAME); 248 } 249 250 public static String getModuleName(Notification notification) { 251 Object userData = notification.getUserData(); 252 if (userData != null) { 253 return (String )((Map )userData).get(MODULE_NAME); 254 } else { 255 return null; 256 } 257 } 258 259 public String getTransactionID() { 260 return (String )userData.get(TRANSACTION_ID); 261 } 262 263 public static String getTransactionID(Notification notification) { 264 Object userData = notification.getUserData(); 265 if (userData != null) { 266 return (String )((Map )userData).get(TRANSACTION_ID); 267 } else { 268 return null; 269 } 270 } 271 272 public String getSecurityID() { 273 return (String )userData.get(SECURITY_ID); 274 } 275 276 public static String getSecurityID(Notification notification) { 277 Object userData = notification.getUserData(); 278 if (userData != null) { 279 return (String )((Map )userData).get(SECURITY_ID); 280 } else { 281 return null; 282 } 283 } 284 285 public String getExceptionString() { 286 return (String )userData.get(EXCEPTION); 287 } 288 289 public static String getExceptionString(Notification notification) { 290 Object userData = notification.getUserData(); 291 if (userData != null) { 292 return (String )((Map )userData).get(EXCEPTION); 293 } else { 294 return null; 295 } 296 } 297 298 public Throwable getExceptionObject() { 299 return (Throwable )userData.get(EXCEPTION_OBJECT); 300 } 301 302 public static Throwable getExceptionObject(Notification notification) { 303 Object userData = notification.getUserData(); 304 if (userData != null) { 305 return (Throwable )((Map )userData).get(EXCEPTION_OBJECT); 306 } else { 307 return null; 308 } 309 } 310 311 private Map userData = null; 312 313 } 314 | Popular Tags |