1 23 24 38 39 package com.sun.enterprise.admin.monitor.registry.spi; 40 41 import java.util.Hashtable ; 42 import java.util.logging.Logger ; 43 import javax.management.ObjectName ; 44 import com.sun.enterprise.admin.monitor.registry.MonitoredObjectType; 45 import com.sun.enterprise.admin.common.constant.AdminConstants; import com.sun.enterprise.server.ApplicationServer; import com.sun.enterprise.admin.server.core.AdminService; import com.sun.enterprise.admin.AdminContext; 50 57 final class MonitoringObjectNames { 58 59 private static final String SERVER_ID = ApplicationServer.getServerContext().getInstanceName(); 60 private static final Logger logger = Logger.getLogger(AdminConstants.kLoggerName); 61 private static final String CATEGORY_PROPERTY = "category"; 62 private static final String CATEGORY_PROPERTY_VAL = "monitor"; 63 private static final String SERVER_PROPERTY = "server"; 64 65 private MonitoringObjectNames() { 66 } 68 private static ObjectName formObjectName(Hashtable t) { 69 70 final String domain = getDomainName(); 71 t.put(CATEGORY_PROPERTY, CATEGORY_PROPERTY_VAL); 72 t.put(SERVER_PROPERTY, SERVER_ID); 73 74 ObjectName on = null; 75 try { 76 on = new ObjectName (domain, t); 77 logger.fine("MonitoringObjectNames:formObjectName - ObjectName = " + on.toString()); 78 } 79 catch (Exception cause) { 80 throw new RuntimeException (cause); 82 } 83 return ( on ); } 85 86 private static String getDomainName() { 87 final AdminContext ac = AdminService.getAdminService().getAdminContext(); 88 return ( ac.getDomainName() ); 89 } 90 91 static ObjectName getRootObjectName() { 92 final Hashtable t = new Hashtable (); 93 t.put("type", MonitoredObjectType.ROOT.getTypeName()); 94 return ( formObjectName(t) ); 95 } 96 97 static ObjectName getEjbObjectName(String ejb, String module, String app) { 98 final Hashtable t = new Hashtable (); 99 t.put("type", MonitoredObjectType.EJB.getTypeName()); 100 t.put("name", ejb); 101 if (app != null) { 102 t.put(MonitoredObjectType.APPLICATION.getTypeName(), app); 103 t.put(MonitoredObjectType.EJBMODULE.getTypeName(), module); 104 } 105 else { 106 t.put(MonitoredObjectType.STANDALONE_EJBMODULE.getTypeName(), module); 107 } 108 return ( formObjectName(t) ); 109 } 110 111 130 static ObjectName 131 getWebServiceObjectNameForWeb( 132 final String endpoint, 133 final String app, 134 final String ctxRoot, 135 final String virtualServer ) { 136 final Hashtable t = new Hashtable (); 137 138 final ObjectName virtualServerObjectName = 140 getVirtualServerObjectName( app, ctxRoot, virtualServer ); 141 142 t.put("type", MonitoredObjectType.WEBSERVICE_ENDPOINT.getTypeName()); 143 t.put("name", endpoint); 144 145 t.put( 147 virtualServerObjectName.getKeyProperty( "type" ), 148 virtualServerObjectName.getKeyProperty( "name" ) ); 149 150 final String appPropName = MonitoredObjectType.APPLICATION.getTypeName(); 151 String appName = virtualServerObjectName.getKeyProperty( appPropName ); 152 if (appName == null) { 153 appName = "null"; 154 } 155 t.put(appPropName, appName); 156 157 return formObjectName(t); 158 } 159 160 static ObjectName getWebServiceObjectNameForEjb(String endpoint, 161 String module, String app) { 162 final Hashtable t = new Hashtable (); 163 t.put("type", MonitoredObjectType.WEBSERVICE_ENDPOINT.getTypeName()); 164 t.put("name", endpoint); 165 if (app != null) { 166 t.put(MonitoredObjectType.APPLICATION.getTypeName(), app); 167 t.put(MonitoredObjectType.EJBMODULE.getTypeName(), module); 168 } 169 else { 170 t.put(MonitoredObjectType.STANDALONE_EJBMODULE.getTypeName(), 171 module); 172 } 173 return ( formObjectName(t) ); 174 } 175 176 177 static ObjectName getEjbMethodsObjectName(String app, String module, String ejb) { 178 final Hashtable t = new Hashtable (); 179 t.put("type", MonitoredObjectType.BEAN_METHODS.getTypeName()); 180 t.put(MonitoredObjectType.EJB.getTypeName(), ejb); 181 if (app != null) { 182 t.put(MonitoredObjectType.APPLICATION.getTypeName(), app); 183 t.put(MonitoredObjectType.EJBMODULE.getTypeName(), module); 184 } 185 else { 186 t.put(MonitoredObjectType.STANDALONE_EJBMODULE.getTypeName(), module); 187 } 188 return ( formObjectName(t) ); 189 } 190 191 static ObjectName getEjbMethodObjectName(String method, String ejb, String module, String app) { 192 final Hashtable t = new Hashtable (); 193 t.put("type", MonitoredObjectType.BEAN_METHOD.getTypeName()); 194 t.put("name", method); 195 t.put(MonitoredObjectType.EJB.getTypeName(), ejb); 196 if (app != null) { 197 t.put(MonitoredObjectType.APPLICATION.getTypeName(), app); 198 t.put(MonitoredObjectType.EJBMODULE.getTypeName(), module); 199 } 200 else { 201 t.put(MonitoredObjectType.STANDALONE_EJBMODULE.getTypeName(), module); 202 } 203 return ( formObjectName(t) ); 204 } 205 static ObjectName getEjbPoolObjectName(String ejb, String module, String app) { 206 final Hashtable t = new Hashtable (); 207 t.put("type", MonitoredObjectType.BEAN_POOL.getTypeName()); 208 t.put("name", MonitoredObjectType.BEAN_POOL.getTypeName()); 209 t.put(MonitoredObjectType.EJB.getTypeName(), ejb); 210 if (app != null) { 211 t.put(MonitoredObjectType.APPLICATION.getTypeName(), app); 212 t.put(MonitoredObjectType.EJBMODULE.getTypeName(), module); 213 } 214 else { 215 t.put(MonitoredObjectType.STANDALONE_EJBMODULE.getTypeName(), module); 216 } 217 return ( formObjectName(t) ); 218 } 219 static ObjectName getEjbCacheObjectName(String ejb, String module, String app) { 220 final Hashtable t = new Hashtable (); 221 t.put("type", MonitoredObjectType.BEAN_CACHE.getTypeName()); 222 t.put("name", MonitoredObjectType.BEAN_CACHE.getTypeName()); 223 t.put(MonitoredObjectType.EJB.getTypeName(), ejb); 224 if (app != null) { 225 t.put(MonitoredObjectType.APPLICATION.getTypeName(), app); 226 t.put(MonitoredObjectType.EJBMODULE.getTypeName(), module); 227 } 228 else { 229 t.put(MonitoredObjectType.STANDALONE_EJBMODULE.getTypeName(), module); 230 } 231 return ( formObjectName(t) ); 232 } 233 static ObjectName getConnectionPoolObjectName(String name, MonitoredObjectType type) { 234 final Hashtable t = new Hashtable (); 235 if (type == MonitoredObjectType.CONNECTOR_CONN_POOL) 236 t.put("type", MonitoredObjectType.CONNECTOR_CONN_POOL.getTypeName()); 237 else 238 t.put("type", MonitoredObjectType.JDBC_CONN_POOL.getTypeName()); 239 t.put("name", name); 240 return ( formObjectName(t) ); 241 } 242 243 static ObjectName getOrbConnectionManagerObjectName(String name) { 244 final Hashtable t = new Hashtable (); 245 t.put("type", MonitoredObjectType.CONNECTION_MANAGER.getTypeName()); 246 t.put("name", name); 247 return ( formObjectName(t) ); 248 } 249 static ObjectName getThreadPoolObjectName(String name) { 250 final Hashtable t = new Hashtable (); 251 t.put("type", MonitoredObjectType.THREAD_POOL.getTypeName()); 252 t.put("name", name); 253 return ( formObjectName(t) ); 254 } 255 static ObjectName getTransactionServiceObjectName() { 256 final Hashtable t = new Hashtable (); 257 t.put("type", MonitoredObjectType.TRANSACTION_SERVICE.getTypeName()); 258 return ( formObjectName(t) ); 259 } 260 static ObjectName getJvmObjectName() { 261 final Hashtable t = new Hashtable (); 262 t.put("type", MonitoredObjectType.JVM.getTypeName()); 263 return ( formObjectName(t) ); 264 } 265 static ObjectName getJndiObjectName() { 266 final Hashtable t = new Hashtable (); 267 t.put("type", MonitoredObjectType.JNDI.getTypeName()); 268 return ( formObjectName(t) ); 269 } 270 static ObjectName getApplicationsObjectName() { 271 final Hashtable t = new Hashtable (); 272 t.put("type", MonitoredObjectType.APPLICATIONS.getTypeName()); 273 return ( formObjectName(t) ); 274 } 275 static ObjectName getThreadPoolsObjectName() { 276 final Hashtable t = new Hashtable (); 277 t.put("type", MonitoredObjectType.THREAD_POOLS.getTypeName()); 278 return ( formObjectName(t) ); 279 } 280 static ObjectName getOrbObjectName() { 281 final Hashtable t = new Hashtable (); 282 t.put("type", MonitoredObjectType.ORB.getTypeName()); 283 return ( formObjectName(t) ); 284 } 285 static ObjectName getHttpServiceObjectName() { 286 final Hashtable t = new Hashtable (); 287 t.put("type", MonitoredObjectType.HTTP_SERVICE.getTypeName()); 288 return ( formObjectName(t) ); 289 } 290 static ObjectName getResourcesObjectName() { 291 final Hashtable t = new Hashtable (); 292 t.put("type", MonitoredObjectType.RESOURCES.getTypeName()); 293 return ( formObjectName(t) ); 294 } 295 static ObjectName getConnectionManagersObjectName() { 296 final Hashtable t = new Hashtable (); 297 t.put("type", MonitoredObjectType.CONNECTION_MANAGERS.getTypeName()); 298 return ( formObjectName(t) ); 299 } 300 static ObjectName getVirtualServerObjectName(String vs) { 301 final Hashtable t = new Hashtable (); 302 t.put("type", MonitoredObjectType.VIRTUAL_SERVER.getTypeName()); 303 t.put("name", vs); 304 return ( formObjectName(t) ); 305 } 306 static ObjectName getHttpListenerObjectName(String vs, String ls) { 307 final Hashtable t = new Hashtable (); 308 t.put("type", MonitoredObjectType.HTTP_LISTENER.getTypeName()); 309 t.put(MonitoredObjectType.VIRTUAL_SERVER.getTypeName(), vs); 310 t.put("name", ls); 311 return ( formObjectName(t) ); 312 } 313 static ObjectName getApplicationObjectName(String app) { 314 final Hashtable t = new Hashtable (); 315 t.put("type", MonitoredObjectType.APPLICATION.getTypeName()); 316 t.put("name", app); 317 return ( formObjectName(t) ); 318 } 319 static ObjectName getEjbModuleObjectName(String app, String module) { 320 final Hashtable t = new Hashtable (); 321 t.put("name", module); 322 if (app != null) { 323 t.put(MonitoredObjectType.APPLICATION.getTypeName(), app); 324 t.put("type", MonitoredObjectType.EJBMODULE.getTypeName()); 325 } 326 else 327 t.put("type", MonitoredObjectType.STANDALONE_EJBMODULE.getTypeName()); 328 return ( formObjectName(t) ); 329 } 330 static ObjectName getWebModuleObjectName(String app, String ctxRoot, 331 String vs) { 332 333 String module = "//" + ((vs==null) ? "DEFAULT" : vs) + 334 (("".equals(ctxRoot)) ? "/" : ctxRoot); 335 336 final Hashtable t = new Hashtable (); 337 t.put("name", module); 338 339 if (app != null) { 340 t.put(MonitoredObjectType.APPLICATION.getTypeName(), app); 341 t.put("type", MonitoredObjectType.WEBMODULE.getTypeName()); 342 } 343 else 344 t.put("type", MonitoredObjectType.STANDALONE_WEBMODULE.getTypeName()); 345 return ( formObjectName(t) ); 346 } 347 348 static ObjectName getVirtualServerObjectName(String app, 349 String ctxRoot, 350 String vs) { 351 352 String module = "//" + ((vs==null) ? "DEFAULT" : vs) + 353 (("".equals(ctxRoot)) ? "/" : ctxRoot); 354 355 final Hashtable t = new Hashtable (); 356 t.put("name", module); 357 t.put("type", MonitoredObjectType.WEBAPP_VIRTUAL_SERVER.getTypeName()); 358 359 if (app != null) { 360 t.put(MonitoredObjectType.APPLICATION.getTypeName(), app); 361 } 362 return ( formObjectName(t) ); 363 } 364 365 static ObjectName getServletObjectName(String app, String ctxRoot, 366 String vs, String servlet) { 367 368 final ObjectName virtualServerObjectName = 369 getVirtualServerObjectName( app, ctxRoot, vs ); 370 371 final Hashtable t = new Hashtable (); 372 t.put("name", servlet); 373 t.put("type", MonitoredObjectType.SERVLET.getTypeName()); 374 t.put(MonitoredObjectType.WEBAPP_VIRTUAL_SERVER.getTypeName(), 375 virtualServerObjectName.getKeyProperty( "name" )); 376 377 if (app != null) { 378 t.put(MonitoredObjectType.APPLICATION.getTypeName(), app); 379 } 380 return ( formObjectName(t) ); 381 } 382 383 static ObjectName getConnectorServiceObjectName() { 385 386 final Hashtable t = new Hashtable (); 387 t.put("type",MonitoredObjectType.CONNECTOR_SERVICE.getTypeName()); 388 return (formObjectName(t)); 389 } 390 391 static ObjectName getJmsServiceObjectName() { 392 393 final Hashtable t = new Hashtable (); 394 t.put("type",MonitoredObjectType.JMS_SERVICE.getTypeName()); 395 return (formObjectName(t)); 396 } 397 398 static ObjectName getConnectorModuleObjectName(String j2eeAppName, String moduleName) { 399 400 final Hashtable t = new Hashtable (); 401 402 if (j2eeAppName != null) { 403 t.put("name", j2eeAppName + "#" + moduleName); 404 t.put("type", MonitoredObjectType.CONNECTOR_MODULE.getTypeName()); 405 } 406 else { 407 t.put("name", moduleName); 408 t.put("type", MonitoredObjectType.STANDALONE_CONNECTOR_MODULE.getTypeName()); 409 } 410 return( formObjectName(t)); 411 } 412 413 static ObjectName getConnectorWorkMgmtObjectName(String j2eeAppName, String moduleName, boolean isJms) { 414 415 final Hashtable t = new Hashtable (); 416 417 t.put("type", MonitoredObjectType.CONNECTOR_WORKMGMT.getTypeName()); 418 if(!isJms) { 419 if(j2eeAppName != null) { 420 t.put(MonitoredObjectType.CONNECTOR_MODULE.getTypeName(), j2eeAppName + "#" + moduleName); 421 } else 422 { 423 t.put(MonitoredObjectType.STANDALONE_CONNECTOR_MODULE.getTypeName(), moduleName); 424 } 425 } 426 return (formObjectName(t)); 427 } 428 429 static ObjectName getConnectionFactoriesObjectName() { 430 final Hashtable t = new Hashtable (); 431 t.put("type", MonitoredObjectType.CONNECTION_FACTORIES.getTypeName()); 432 return(formObjectName(t)); 433 } 434 435 static ObjectName getConnectionFactoryObjectName(String factoryName) { 436 final Hashtable t = new Hashtable (); 437 t.put("type", MonitoredObjectType.CONNECTION_FACTORY.getTypeName()); 438 t.put("name", factoryName); 439 return(formObjectName(t)); 440 } 441 442 static ObjectName getConnectionPoolsObjectName(String j2eeAppName, String moduleName) { 443 final Hashtable t = new Hashtable (); 444 t.put("type", MonitoredObjectType.CONNECTION_POOLS.getTypeName()); 445 if(j2eeAppName != null) { 446 t.put(MonitoredObjectType.CONNECTOR_MODULE.getTypeName(), j2eeAppName + "#" + moduleName); 447 } else 448 { 449 t.put(MonitoredObjectType.STANDALONE_CONNECTOR_MODULE.getTypeName(), moduleName); 450 } 451 return(formObjectName(t)); 452 } 453 454 static ObjectName getConnectionPoolObjectName(String poolName, String j2eeAppName, String moduleName) { 455 final Hashtable t = new Hashtable (); 456 t.put("type", MonitoredObjectType.CONNECTOR_CONN_POOL); 457 t.put("name", poolName); 458 if(j2eeAppName != null) { 459 t.put(MonitoredObjectType.CONNECTOR_MODULE.getTypeName(), j2eeAppName + "#" + moduleName); 460 } else 461 { 462 t.put(MonitoredObjectType.STANDALONE_CONNECTOR_MODULE.getTypeName(), moduleName); 463 } 464 return(formObjectName(t)); 465 } 466 467 static ObjectName getConnectionQueueObjectName() { 469 470 final Hashtable t = new Hashtable (); 471 t.put("type", MonitoredObjectType.CONNECTION_QUEUE.getTypeName()); 472 return(formObjectName(t)); 473 } 474 475 static ObjectName getDnsObjectName() { 476 477 final Hashtable t = new Hashtable (); 478 t.put("type", MonitoredObjectType.DNS.getTypeName()); 479 return(formObjectName(t)); 480 } 481 482 static ObjectName getKeepAliveObjectName() { 483 484 final Hashtable t = new Hashtable (); 485 t.put("type", MonitoredObjectType.KEEP_ALIVE.getTypeName()); 486 return(formObjectName(t)); 487 } 488 489 static ObjectName getPWCThreadPoolObjectName() { 490 491 final Hashtable t = new Hashtable (); 492 t.put("type", MonitoredObjectType.PWC_THREAD_POOL.getTypeName()); 493 return(formObjectName(t)); 494 } 495 496 static ObjectName getFileCacheObjectName() { 497 498 final Hashtable t = new Hashtable (); 499 t.put("type", MonitoredObjectType.FILE_CACHE.getTypeName()); 500 return(formObjectName(t)); 501 } 502 503 static ObjectName getRequestObjectName(String vsId) { 504 505 final Hashtable t = new Hashtable (); 506 t.put("type", MonitoredObjectType.REQUEST.getTypeName()); 507 t.put(MonitoredObjectType.VIRTUAL_SERVER.getTypeName(), vsId); 508 return(formObjectName(t)); 509 } 510 511 static ObjectName getStatefulSessionStoreObjectName(String ejbName, String moduleName, String j2eeAppName) { 512 513 final Hashtable t = new Hashtable (); 514 t.put("type", MonitoredObjectType.SESSION_STORE.getTypeName()); 515 t.put("name", MonitoredObjectType.SESSION_STORE.getTypeName()); 516 t.put(MonitoredObjectType.EJB.getTypeName(), ejbName); 517 if (j2eeAppName != null) { 518 t.put(MonitoredObjectType.APPLICATION.getTypeName(), j2eeAppName); 519 t.put(MonitoredObjectType.EJBMODULE.getTypeName(), moduleName); 520 } 521 else { 522 t.put(MonitoredObjectType.STANDALONE_EJBMODULE.getTypeName(), moduleName); 523 } 524 return ( formObjectName(t) ); 525 } 526 527 static ObjectName getTimerObjectName(String ejbName, String moduleName, String j2eeAppName) { 528 529 final Hashtable t = new Hashtable (); 530 t.put("type", MonitoredObjectType.TIMERS.getTypeName()); 531 t.put("name", MonitoredObjectType.TIMERS.getTypeName()); 532 t.put(MonitoredObjectType.EJB.getTypeName(), ejbName); 533 if (j2eeAppName != null) { 534 t.put(MonitoredObjectType.APPLICATION.getTypeName(), j2eeAppName); 535 t.put(MonitoredObjectType.EJBMODULE.getTypeName(), moduleName); 536 } 537 else { 538 t.put(MonitoredObjectType.STANDALONE_EJBMODULE.getTypeName(), moduleName); 539 } 540 return ( formObjectName(t) ); 541 } 542 543 static ObjectName getJVMCompilationObjectName() { 545 546 final Hashtable t = new Hashtable (); 547 t.put("type", MonitoredObjectType.JVM_COMPILATION.getTypeName()); 548 t.put("name", MonitoredObjectType.JVM_COMPILATION.getTypeName()); 549 return(formObjectName(t)); 550 } 551 552 static ObjectName getJVMClassLoadingObjectName() { 553 554 final Hashtable t = new Hashtable (); 555 t.put("type", MonitoredObjectType.JVM_CLASSLOADING.getTypeName()); 556 t.put("name", MonitoredObjectType.JVM_CLASSLOADING.getTypeName()); 557 return(formObjectName(t)); 558 } 559 560 static ObjectName getJVMRuntimeObjectName() { 561 562 final Hashtable t = new Hashtable (); 563 t.put("type", MonitoredObjectType.JVM_RUNTIME.getTypeName()); 564 t.put("name", MonitoredObjectType.JVM_RUNTIME.getTypeName()); 565 return(formObjectName(t)); 566 } 567 568 static ObjectName getJVMOSObjectName() { 569 570 final Hashtable t = new Hashtable (); 571 t.put("type", MonitoredObjectType.JVM_OS.getTypeName()); 572 t.put("name", MonitoredObjectType.JVM_OS.getTypeName()); 573 return(formObjectName(t)); 574 } 575 576 577 static ObjectName getJVMGCSSObjectName() { 578 579 final Hashtable t = new Hashtable (); 580 t.put("type", MonitoredObjectType.JVM_GCS.getTypeName()); 581 t.put("name", MonitoredObjectType.JVM_GCS.getTypeName()); 582 return(formObjectName(t)); 583 } 584 585 586 static ObjectName getJVMGCObjectName(String gcName) { 587 588 final Hashtable t = new Hashtable (); 589 t.put("type", MonitoredObjectType.JVM_GC.getTypeName()); 590 t.put("name", gcName); 591 return(formObjectName(t)); 592 } 593 594 static ObjectName getJVMMemoryObjectName() { 595 596 final Hashtable t = new Hashtable (); 597 t.put("type", MonitoredObjectType.JVM_MEMORY.getTypeName()); 598 t.put("name", MonitoredObjectType.JVM_MEMORY.getTypeName()); 599 return(formObjectName(t)); 600 } 601 602 static ObjectName getJVMThreadObjectName() { 603 604 final Hashtable t = new Hashtable (); 605 t.put("type", MonitoredObjectType.JVM_THREAD.getTypeName()); 606 t.put("name", MonitoredObjectType.JVM_THREAD.getTypeName()); 607 return(formObjectName(t)); 608 } 609 610 static ObjectName getJVMThreadInfoObjectName(String threadName) { 611 612 final Hashtable t = new Hashtable (); 613 t.put("type", MonitoredObjectType.JVM_THREAD_INFO.getTypeName()); 614 t.put("name", threadName); 615 return(formObjectName(t)); 616 } 617 } 619 | Popular Tags |