1 25 26 package org.objectweb.jonas.jmx; 27 28 import javax.management.MalformedObjectNameException ; 29 import javax.management.ObjectName ; 30 31 40 public class JonasObjectName { 41 42 45 private static String domain = null; 46 47 48 52 public static void setDomain(String domainName) { 53 if (domain != null) { 54 throw new IllegalStateException ("The setDomain method can be called only once."); 55 } 56 domain = domainName; 57 } 58 59 62 private static String getDomain() { 63 if (domain == null) { 64 throw new IllegalStateException ("The domain was not previously set, cannot return it."); 65 } 66 return domain; 67 } 68 69 75 public static ObjectName jmxConnectorServer(String protocol, String connectorName) { 76 try { 77 return ObjectName.getInstance("connectors:protocol=" + protocol + ",name=" + connectorName); 78 } catch (MalformedObjectNameException e) { 79 return null; 81 } 82 } 83 84 87 public static ObjectName serverConfig() { 88 try { 89 return ObjectName.getInstance(getDomain() + ":type=management,name=reconfigManager"); 90 } catch (MalformedObjectNameException e) { 91 return null; 93 } 94 } 95 96 public static ObjectName wwwService() { 97 try { 98 return ObjectName.getInstance(getDomain() + ":type=webContainer,name=Jetty"); 99 } catch (MalformedObjectNameException e) { 100 return null; 102 } 103 } 104 105 public static ObjectName wsService(){ 106 try { 108 return ObjectName.getInstance(getDomain() + ":type=WebService,*"); 109 } catch (MalformedObjectNameException e) { 110 return null; 112 } 113 } 114 115 public static ObjectName ejbService() { 116 try { 117 return ObjectName.getInstance(getDomain() + ":type=service,name=ejbContainers"); 118 } catch (MalformedObjectNameException e) { 119 return null; 121 } 122 } 123 124 128 public static ObjectName earService() { 129 try { 130 return ObjectName.getInstance(getDomain() + ":type=service,name=ear"); 131 } catch (MalformedObjectNameException e) { 132 return null; 134 } 135 } 136 137 141 public static ObjectName mailService() { 142 try { 143 return ObjectName.getInstance(getDomain() + ":type=service,name=mail"); 144 } catch (MalformedObjectNameException e) { 145 return null; 147 } 148 } 149 150 154 public static ObjectName webContainerService() { 155 try { 156 return ObjectName.getInstance(getDomain() + ":type=service,name=webContainers"); 157 } catch (MalformedObjectNameException e) { 158 return null; 160 } 161 } 162 163 public static ObjectName databaseService() { 164 try { 165 return ObjectName.getInstance(getDomain() + ":type=service,name=database"); 166 } catch (MalformedObjectNameException e) { 167 return null; 169 } 170 } 171 172 public static ObjectName resourceService() { 173 try { 174 return ObjectName.getInstance(getDomain() + ":type=service,name=resource"); 175 } catch (MalformedObjectNameException e) { 176 return null; 178 } 179 } 180 181 public static ObjectName transactionService() { 182 try { 183 return ObjectName.getInstance(getDomain() + ":type=service,name=jtm"); 184 } catch (MalformedObjectNameException e) { 185 return null; 187 } 188 } 189 190 public static ObjectName logService(String filename) { 191 try { 192 return ObjectName.getInstance(getDomain() + ":type=service,name=log,fname=" 193 + fileNameForObjectName(filename)); 194 } catch (MalformedObjectNameException e) { 195 return null; 197 } 198 } 199 203 public static ObjectName discoveryService() { 204 try { 205 return ObjectName.getInstance(getDomain() + ":type=service,name=discovery"); 206 } catch (MalformedObjectNameException e) { 207 return null; 209 } 210 } 211 212 public static ObjectName allLogServices() { 213 try { 214 return ObjectName.getInstance(getDomain() + ":type=service,name=log,*"); 215 } catch (MalformedObjectNameException e) { 216 return null; 218 } 219 } 220 221 public static ObjectName allServices() { 222 try { 223 return ObjectName.getInstance(getDomain() + ":type=service,*"); 224 } catch (MalformedObjectNameException e) { 225 return null; 227 } 228 } 229 230 public static ObjectName jmsService() { 231 try { 232 return ObjectName.getInstance(getDomain() + ":type=service,name=jms"); 233 } catch (MalformedObjectNameException e) { 234 return null; 236 } 237 } 238 239 public static ObjectName jmsService1() { 240 try { 241 return ObjectName.getInstance(getDomain() + ":type=service,name=jms"); 242 } catch (MalformedObjectNameException e) { 243 return null; 245 } 246 } 247 248 public static ObjectName securityService() { 249 try { 250 return ObjectName.getInstance(getDomain() + ":type=service,name=security"); 251 } catch (MalformedObjectNameException e) { 252 return null; 254 } 255 } 256 257 public static ObjectName jmxService() { 258 try { 259 return ObjectName.getInstance("JMImplementation:type=MBeanServerDelegate"); 260 } catch (MalformedObjectNameException e) { 261 return null; 263 } 264 } 265 266 public static ObjectName www(String subtype) 267 throws MalformedObjectNameException { 268 return ObjectName.getInstance(getDomain() + ":type=www,subtype=" + subtype); 269 } 270 271 public static ObjectName rar(String filename) 272 throws MalformedObjectNameException { 273 return ObjectName.getInstance(getDomain() + ":type=resource,fname=" + fileNameForObjectName(filename)); 274 } 275 276 public static ObjectName war(String filename) 277 throws MalformedObjectNameException { 278 return ObjectName.getInstance(getDomain() + ":type=war,fname=" + fileNameForObjectName(filename)); 279 } 280 281 public static ObjectName datasource(String name) 282 throws MalformedObjectNameException { 283 return ObjectName.getInstance(getDomain() + ":type=datasource,name=" + name); 284 } 285 286 292 public static ObjectName sessionMailFactory(String name) 293 throws MalformedObjectNameException { 294 return ObjectName.getInstance(getDomain() + ":type=sessionmailfactory,name=" + name); 295 } 296 297 302 public static ObjectName workManager() 303 throws MalformedObjectNameException { 304 return ObjectName.getInstance(getDomain() + ":type=workmanager"); 305 } 306 307 313 public static ObjectName mimeMailFactory(String name) 314 throws MalformedObjectNameException { 315 return ObjectName.getInstance(getDomain() + ":type=mimemailfactory,name=" + name); 316 } 317 318 324 public static ObjectName securityMemoryFactory(String name) 325 throws MalformedObjectNameException { 326 return ObjectName.getInstance(getDomain() + ":type=securityfactory,subtype=memory,name=" + name); 327 } 328 329 335 public static ObjectName securityDatasourceFactory(String name) 336 throws MalformedObjectNameException { 337 return ObjectName.getInstance(getDomain() + ":type=securityfactory,subtype=datasource,name=" + name); 338 } 339 340 346 public static ObjectName securityLdapFactory(String name) 347 throws MalformedObjectNameException { 348 return ObjectName.getInstance(getDomain() + ":type=securityfactory,subtype=ldap,name=" + name); 349 } 350 351 358 public static ObjectName user(String resource, String username) 359 throws MalformedObjectNameException { 360 return ObjectName.getInstance(getDomain() + ":type=security,subtype=users,resource=" + resource 361 + ",name=" + username); 362 } 363 364 369 public static ObjectName allUsers() { 370 try { 371 return ObjectName.getInstance(getDomain() + ":type=security,subtype=users,*"); 372 } 373 catch (MalformedObjectNameException e) { 374 return null; 376 } 377 } 378 379 386 public static ObjectName group(String resource, String groupname) 387 throws MalformedObjectNameException { 388 return ObjectName.getInstance(getDomain() + ":type=security,subtype=groups,resource=" + resource 389 + ",name=" + groupname); 390 } 391 392 397 public static ObjectName allGroups() { 398 try { 399 return ObjectName.getInstance(getDomain() + ":type=security,subtype=groups,*"); 400 } 401 catch (MalformedObjectNameException e) { 402 return null; 404 } 405 } 406 407 414 public static ObjectName role(String resource, String rolename) 415 throws MalformedObjectNameException { 416 return ObjectName.getInstance(getDomain() + ":type=security,subtype=roles,resource=" + resource 417 + ",name=" + rolename); 418 } 419 420 425 public static ObjectName allRoles() { 426 try { 427 return ObjectName.getInstance(getDomain() + ":type=security,subtype=roles,*"); 428 } 429 catch (MalformedObjectNameException e) { 430 return null; 432 } 433 } 434 435 public static ObjectName resourceAdapters() 436 throws MalformedObjectNameException { 437 return ObjectName.getInstance(getDomain() + ":type=resourceadapter,*"); 438 } 439 440 public static ObjectName resourceAdapter(String name) 441 throws MalformedObjectNameException { 442 return ObjectName.getInstance(getDomain() + ":type=resourceadapter,name=" + name); 443 } 444 445 public static ObjectName rmiConnector() { 446 try { 447 return ObjectName.getInstance(getDomain() + ":type=connector,name=rmiconnector"); 448 } 449 catch (MalformedObjectNameException e) { 450 return null; 452 } 453 } 454 455 public static ObjectName allWWW() { 456 try { 457 return ObjectName.getInstance(getDomain() + ":type=service,name=www,*"); 458 } 459 catch (MalformedObjectNameException e) { 460 return null; 462 } 463 } 464 465 public static ObjectName allEars() { 466 try { 467 return ObjectName.getInstance(getDomain() + ":type=ear,*"); 468 } 469 catch (MalformedObjectNameException e) { 470 return null; 472 } 473 } 474 475 public static ObjectName allRars() { 476 try { 477 return ObjectName.getInstance(getDomain() + ":type=resource,*"); 478 } catch (MalformedObjectNameException e) { 479 return null; 481 } 482 } 483 484 public static ObjectName allWars() { 485 try { 486 return ObjectName.getInstance(getDomain() + ":type=war,*"); 487 } catch (MalformedObjectNameException e) { 488 return null; 490 } 491 } 492 493 public static ObjectName allDatasources() { 494 try { 495 return ObjectName.getInstance(getDomain() + ":type=datasource,*"); 496 } catch (MalformedObjectNameException e) { 497 return null; 499 } 500 } 501 502 506 public static ObjectName allSessionMailFactories() { 507 try { 508 return ObjectName.getInstance(getDomain() + ":type=sessionmailfactory,*"); 509 } catch (MalformedObjectNameException e) { 510 return null; 512 } 513 } 514 515 519 public static ObjectName allMimeMailFactories() { 520 try { 521 return ObjectName.getInstance(getDomain() + ":type=mimemailfactory,*"); 522 } catch (MalformedObjectNameException e) { 523 return null; 525 } 526 } 527 528 public static ObjectName allResourceAdaptors() { 529 try { 530 return ObjectName.getInstance(getDomain() + ":type=resourceadapter,*"); 531 } catch (MalformedObjectNameException e) { 532 return null; 534 } 535 } 536 537 public static String getType(ObjectName obj) { 538 return obj.getKeyProperty("type"); 539 } 540 541 public static String fileNameForObjectName(String fileName) { 542 return fileName.replace(':', '|'); 543 } 544 545 552 public static ObjectName securityFactories(String pName) 553 throws MalformedObjectNameException { 554 return ObjectName.getInstance(JonasObjectName.getDomain() + ":type=securityfactory,name=" + pName); 555 } 556 557 563 public static ObjectName allSecurityFactories() 564 throws MalformedObjectNameException { 565 return ObjectName.getInstance(JonasObjectName.getDomain() + ":type=securityfactory,*"); 566 } 567 568 574 public static ObjectName allSecurityMemoryFactories() 575 throws MalformedObjectNameException { 576 return ObjectName.getInstance(JonasObjectName.getDomain() + ":type=securityfactory,subtype=memory,*"); 577 } 578 579 585 public static ObjectName allSecurityDatasourceFactories() 586 throws MalformedObjectNameException { 587 return ObjectName.getInstance(JonasObjectName.getDomain() + ":type=securityfactory,subtype=datasource,*"); 588 } 589 590 596 public static ObjectName allSecurityLdapFactories() 597 throws MalformedObjectNameException { 598 return ObjectName.getInstance(JonasObjectName.getDomain() + ":type=securityfactory,subtype=ldap,*"); 599 } 600 601 608 public static ObjectName allUsers(String pResource) 609 throws MalformedObjectNameException { 610 return ObjectName.getInstance(JonasObjectName.getDomain() + ":type=security,subtype=users,resource=" 611 + pResource + ",*"); 612 } 613 614 621 public static ObjectName allRoles(String pResource) 622 throws MalformedObjectNameException { 623 return ObjectName.getInstance(JonasObjectName.getDomain() + ":type=security,subtype=roles,resource=" 624 + pResource + ",*"); 625 } 626 627 634 public static ObjectName allGroups(String pResource) 635 throws MalformedObjectNameException { 636 return ObjectName.getInstance(JonasObjectName.getDomain() + ":type=security,subtype=groups,resource=" 637 + pResource + ",*"); 638 } 639 640 646 public String toString() { 647 return super.toString(); 648 } 649 650 656 public static ObjectName joramLocalServer() throws MalformedObjectNameException { 657 return ObjectName.getInstance("joram:type=JMSlocalServer"); 658 } 659 660 666 public static ObjectName joramRemoteServer(String id) throws MalformedObjectNameException { 667 return ObjectName.getInstance("joram:type=JMSremoteServer,id=" + id); 668 } 669 670 676 public static ObjectName joramQueue(String name) throws MalformedObjectNameException { 677 return ObjectName.getInstance("joram:type=JMSqueue,name=" + name); 678 } 679 680 686 public static ObjectName joramTopic(String name) throws MalformedObjectNameException { 687 return ObjectName.getInstance("joram:type=JMStopic,name=" + name); 688 } 689 690 694 public static ObjectName discoveryManager() throws MalformedObjectNameException { 695 return ObjectName.getInstance(getDomain() + ":type=management,name=discoveryManager,server=JOnAS"); 696 } 697 698 702 public static ObjectName discoveryClient() throws MalformedObjectNameException { 703 return ObjectName.getInstance(getDomain() + ":type=management,name=discoveryClient,server=JOnAS"); 704 } 705 709 public static ObjectName discoveryEnroller() throws MalformedObjectNameException { 710 return ObjectName.getInstance(getDomain() + ":type=management,name=discoveryEnroller,server=JOnAS"); 711 } 712 713 718 public static ObjectName catalinaConnectorFactory(String pDomain) throws MalformedObjectNameException { 719 return new ObjectName (pDomain + ":type=ConnectorFactory"); 720 } 721 722 727 public static ObjectName webModuleProxy(String pDomain) throws MalformedObjectNameException { 728 return new ObjectName (pDomain + ":type=WebModuleProxy"); 729 } 730 } 731 | Popular Tags |