1 23 24 package com.sun.enterprise.admin.common; 25 import javax.management.ObjectName ; 27 import javax.management.MalformedObjectNameException ; 28 import com.sun.enterprise.admin.util.Debug; 30 import com.sun.enterprise.admin.util.Logger; 31 import com.sun.enterprise.util.SystemPropertyConstants; 32 33 46 public class ObjectNames 47 { 48 public static final String kDefaultIASDomainName = "ias"; 49 50 public static final char kWildcardChar = '*'; 51 public static final char kDomainNameSeparatorChar = ':'; 52 public static final char kPropertySeparatorChar = ','; 53 public static final char kNameValueSeparatorChar = '='; 54 public static final char kSingleMatchChar = '?'; 55 56 public static final String kDomainNameInvalidatorString = 57 "" + kWildcardChar + kDomainNameSeparatorChar + kPropertySeparatorChar + 58 kNameValueSeparatorChar + kSingleMatchChar; 59 public static final String kTypeKeyName = "type"; 61 public static final String kNameKeyName = "name"; 62 public static final String kGroupIdKeyName = "group"; 63 public static final String kCategoryKeyName = "category"; 64 public static final String kClassIdKeyName = "class"; 65 public static final String kServerIdKeyName = "server"; 66 public static final String kDeployment = "deployment-service"; 67 public static final String kModuleTypeKeyName = "module-type"; 68 public static final String kServerInstanceKeyName = "instance-name"; 69 public static final String kApplicationNameKeyName = "app-name"; 70 public static final String kModuleNameKeyName = "module-name"; 71 public static final String kController = "controller"; 73 public static final String kConfig = "config"; 74 public static final String kServer = "server"; 75 public static final String kGenericConfigurator = "configurator"; 76 public static final String kSystemServices = "system-services"; 77 public static final String kServerInstance = "server-instance"; 78 public static final String kApplication = "application"; 79 public static final String kModule = "module"; 80 public static final String kJMSAdminHandler = "jms-service"; 81 public static final String kLogService = "log-service"; 82 83 public static final String kComponentKeyName = "component"; public static final String kOrbType = "orb"; 85 public static final String kOrbListenerType = "orblistener"; 86 87 public static final String kHTTPServiceType = "httpservice"; 88 public static final String kHTTPListenerType = "httplistener"; 89 public static final String kHTTPListenerIdKeyName = "http-listener-id"; 90 public static final String kSecurityServiceType = "securityservice"; 92 93 public static final String kVirtualServerClassType = "virtual-server-class"; 94 public static final String kVirtualServerClassDefaultName = "defaultclass"; public static final String kVirtualServerClassIdKeyName = "virtual-server-class-id"; 96 public static final String kVirtualServerType = "virtual-server"; 97 public static final String kVirtualServerIdKeyName = "virtual-server-id"; 98 99 public static final String kMimeType = "mime"; 100 public static final String kMimeIdKeyName = "mime-id"; 101 public static final String kAclType = "acl"; 102 public static final String kAclIdKeyName = "acl-id"; 103 public static final String kAuthDbType = "authdb"; 104 public static final String kAuthDbIdKeyName = "authdbId"; 105 public static final String kAuthRealmType = "authrealm"; 106 public static final String kHTTPQosType = "http-qos"; 107 108 public static final String kJdbcConnectionPoolType = "jdbcpool"; 109 public static final String kJdbcResourceType = "jdbc-resource"; 110 public static final String kMailResourceType = "mail-resource"; 111 public static final String kJmsResourceType = "jms-resource"; 112 public static final String kJndiResourceType = "jndi-resource"; 113 public static final String kCustomResourceType = "custom-resource"; 114 public static final String kPersistenceManagerFactoryResourceType = 115 "persistence-manager-factory-resource"; 116 117 public static final String kWebContainer = "web-container"; 118 public static final String kEjbContainer = "ejb-container"; 119 public static final String kMdbContainer = "mdb-container"; 120 121 public static final String kJtsComponent = "transaction-service"; 122 public static final String kJvmType = "java-config"; 123 124 public static final String kEjbModule = "ejb-module"; 125 public static final String kWebModule = "web-module"; 126 public static final String kStandaloneEjbModule = "standalone-ejb-module"; public static final String kStandaloneWebModule = "standalone-web-module"; 129 public static final String kConnectorModule = "connector-module"; 130 public static final String kLifecycleModule = "lifecycle-module"; 131 132 public static final String kEjbType = "ejb"; 133 public static final String kServletType = "servlet"; 134 135 public static final String kMonitoringType = "monitor"; 136 public static final String kMonitoringClassName = "mclass"; 137 public static final String kMonitoringRootClass = "root"; 138 139 public static final String kProfiler = "profiler"; 140 141 144 private ObjectNames() 145 { 146 } 147 148 155 public static ObjectName getControllerObjectName() 156 { 157 return ( getObjectName(kDefaultIASDomainName, 158 new String []{kTypeKeyName}, 159 new String []{kController}) ); 160 } 161 162 167 public static ObjectName getServerObjectName( String serverName ) 168 { 169 return ( getObjectName(kDefaultIASDomainName, 170 new String []{kTypeKeyName, kNameKeyName, kCategoryKeyName}, 171 new String []{kServer, serverName, kConfig}) ); 172 } 173 174 177 178 public static ObjectName getGenericConfiguratorObjectName() 179 { 180 return ( getObjectName(kDefaultIASDomainName, 181 new String []{kTypeKeyName}, 182 new String []{kGenericConfigurator}) ); 183 } 184 195 public static ObjectName getSystemServicesObjectName() 196 { 197 return ( getPerInstanceSystemServicesObjectName(SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME) ); 198 } 199 200 205 public static ObjectName getPerInstanceSystemServicesObjectName(final String instanceId) 206 { 207 final ObjectName on = getObjectName(kDefaultIASDomainName, 208 new String []{kTypeKeyName, kServerIdKeyName}, 209 new String []{kSystemServices, instanceId}) ; 210 return ( on ); 212 } 213 214 221 public static final String kDottedNameDomainName = "com.sun.appserv"; public static final String kDottedNameType = "dotted-name-support"; 223 public static final String kDottedNameRegistryNameKeyName = "dotted-name-registry"; 224 public static final String kDottedNameMonitoringRegistryNameKeyName = "dotted-name-monitoring-registry"; 225 public static final String kDottedNameGetSetNameKeyName = "dotted-name-get-set"; 226 227 private static ObjectName getDottedNameObjectName( final String name ) 228 { 229 return( getObjectName( kDottedNameDomainName, 230 new String [] { kNameKeyName, kTypeKeyName }, 231 new String [] { name, kDottedNameType } ) 232 ); 233 } 234 235 public static ObjectName getDottedNameRegistryObjectName() 236 { 237 return( getDottedNameObjectName( kDottedNameRegistryNameKeyName ) ); 238 } 239 240 public static ObjectName getDottedNameMonitoringRegistryObjectName() 241 { 242 return( getDottedNameObjectName( kDottedNameMonitoringRegistryNameKeyName ) ); 243 } 244 245 public static ObjectName getDottedNameGetSetObjectName() 246 { 247 return( getDottedNameObjectName( kDottedNameGetSetNameKeyName ) ); 248 } 249 250 251 252 253 261 public static ObjectName getJMSAdminHandlerObjectName(String instanceName) 262 { 263 return ( getObjectName(kDefaultIASDomainName, 264 new String []{kTypeKeyName, kServerInstanceKeyName}, 265 new String []{kJMSAdminHandler, instanceName}) ); 266 } 267 268 270 public static ObjectName getJMSAdminHandlerObjectName() 271 { 272 Debug.println("This method is deprecated. Use the overloaded method" + 273 " instead.", Debug.LOW); 274 return ( getObjectName(kDefaultIASDomainName, 275 new String []{kTypeKeyName}, 276 new String []{kJMSAdminHandler}) ); 277 } 278 279 285 public static ObjectName getServerInstanceObjectName(String instanceName) 286 { 287 return ( getObjectName (kDefaultIASDomainName, 288 new String []{kTypeKeyName, kNameKeyName}, 289 new String []{kServerInstance, instanceName}) ); 290 } 291 292 294 public static ObjectName getServerInstanceObjectNamePattern() 295 { 296 ObjectName pattern = null; 297 ObjectName tmp = getObjectName(kDefaultIASDomainName, 298 new String [] {kTypeKeyName}, new String [] {kServerInstance}); 299 if (tmp != null) 300 { 301 String strPattern = tmp.toString() + kPropertySeparatorChar; 302 strPattern += kWildcardChar; 303 try 304 { 305 pattern = new ObjectName (strPattern); 306 } 307 catch (MalformedObjectNameException mfone) 308 { 309 pattern = null; 310 Debug.printStackTrace(mfone); 311 } 312 } 313 return pattern; 314 } 315 316 321 private static final String USE_DEPLOYMENT_MBEAN ="com.sun.aas.deployment.UseDeploymentMBean"; 322 323 328 public static ObjectName getDeploymentServiceObjectName(String instanceName) 329 { 330 if(System.getProperty(USE_DEPLOYMENT_MBEAN,"false").equals("true")) 331 { 332 return ( getObjectName (kDefaultIASDomainName, 333 new String []{kTypeKeyName, kServerInstanceKeyName}, 334 new String []{kDeployment, instanceName})); 335 } 336 else { 337 return getServerInstanceObjectName(instanceName); 338 } 339 } 340 341 342 350 public static ObjectName getApplicationObjectName(String instanceName, 351 String appName) 352 { 353 return ( getObjectName (kDefaultIASDomainName, 354 new String []{kTypeKeyName, kNameKeyName, 355 kServerInstanceKeyName}, 356 new String []{kApplication, appName, instanceName}) ); 357 } 358 359 374 public static ObjectName getApplicationObjectNamePattern( 375 String instanceName) 376 { 377 ObjectName pattern = null; 378 ObjectName tmp = getObjectName(kDefaultIASDomainName, 379 new String [] {kTypeKeyName, kServerInstanceKeyName}, 380 new String [] {kApplication, instanceName}); 381 if (tmp != null) 382 { 383 String strPattern = tmp.toString() + kPropertySeparatorChar; 384 strPattern += kWildcardChar; 385 try 386 { 387 pattern = new ObjectName (strPattern); 388 } 389 catch (MalformedObjectNameException mfone) 390 { 391 Debug.printStackTrace(mfone); 392 pattern = null; 393 } 394 } 395 return pattern; 396 } 397 398 409 public static ObjectName getModuleObjectName(String instanceName, 410 String appName, String moduleName) 411 { 412 return ( getObjectName (kDefaultIASDomainName, 413 new String []{kTypeKeyName, kNameKeyName, kApplicationNameKeyName, 414 kServerInstanceKeyName}, 415 new String []{kModule, moduleName, appName, instanceName}) ); 416 } 417 418 public static ObjectName getEjbModuleObjectName(String instanceName, 419 String moduleName) 420 { 421 return ( getObjectName (kDefaultIASDomainName, 422 new String []{kTypeKeyName, kNameKeyName, 423 kServerInstanceKeyName, kModuleTypeKeyName}, 424 new String []{kModule, moduleName, instanceName, kEjbModule}) ); 425 } 426 427 public static ObjectName getEjbModuleObjectName(String instanceName, 428 String moduleName, 429 String applicationName) 430 { 431 return ( getObjectName (kDefaultIASDomainName, 432 new String []{kTypeKeyName, kNameKeyName, 433 kServerInstanceKeyName, kModuleTypeKeyName, 434 kApplicationNameKeyName}, 435 new String []{kModule, moduleName, instanceName, kEjbModule, 436 applicationName}) ); 437 } 438 439 public static ObjectName getWebModuleObjectName(String instanceName, 440 String moduleName) 441 { 442 return ( getObjectName (kDefaultIASDomainName, 443 new String []{kTypeKeyName, kNameKeyName, 444 kServerInstanceKeyName, kModuleTypeKeyName}, 445 new String []{kModule, moduleName, instanceName, kWebModule}) ); 446 } 447 448 public static ObjectName getWebModuleObjectName(String instanceName, 449 String moduleName, 450 String applicationName) 451 { 452 return ( getObjectName (kDefaultIASDomainName, 453 new String []{kTypeKeyName, kNameKeyName, 454 kServerInstanceKeyName, kModuleTypeKeyName, 455 kApplicationNameKeyName}, 456 new String []{kModule, moduleName, instanceName, kWebModule, 457 applicationName}) ); 458 } 459 460 public static ObjectName getConnectorModuleObjectName(String instanceName, 461 String moduleName) 462 { 463 return ( getObjectName (kDefaultIASDomainName, 464 new String []{kTypeKeyName, kNameKeyName, 465 kServerInstanceKeyName, kModuleTypeKeyName}, 466 new String []{kModule, moduleName, instanceName, 467 kConnectorModule}) ); 468 } 469 470 public static ObjectName getConnectorModuleObjectName( 471 String instanceName, 472 String moduleName, 473 String applicationName) 474 { 475 return ( getObjectName (kDefaultIASDomainName, 476 new String []{kTypeKeyName, kNameKeyName, 477 kServerInstanceKeyName, kModuleTypeKeyName, 478 kApplicationNameKeyName}, 479 new String []{kModule, moduleName, instanceName, 480 kConnectorModule, applicationName}) ); 481 } 482 483 485 public static ObjectName getModuleObjectNamePattern(String instanceName, 486 String appName) 487 { 488 ObjectName pattern = null; 489 490 ObjectName tmp = getObjectName(kDefaultIASDomainName, 491 new String [] {kTypeKeyName, kServerInstanceKeyName, 492 kApplicationNameKeyName}, 493 new String [] {kModule, instanceName, appName}); 494 495 if (tmp != null) 496 { 497 String strPattern = tmp.toString() + kPropertySeparatorChar; 498 strPattern += kWildcardChar; 499 try 500 { 501 pattern = new ObjectName (strPattern); 502 } 503 catch (MalformedObjectNameException mfone) 504 { 505 pattern = null; 506 } 507 } 508 return pattern; 509 } 510 511 521 public static ObjectName getModuleObjectName(String instanceName, 522 String moduleName) 523 { 524 return ( getObjectName (kDefaultIASDomainName, 525 new String []{kTypeKeyName, kNameKeyName, kServerInstanceKeyName}, 526 new String []{kModule, moduleName, instanceName}) ); 527 } 528 529 531 public static ObjectName getModuleObjectNamePattern(String instanceName) 532 { 533 ObjectName pattern = null; 534 ObjectName tmp = getObjectName(kDefaultIASDomainName, 535 new String [] {kTypeKeyName, kServerInstanceKeyName}, 536 new String [] {kModule, instanceName}); 537 if (tmp != null) 538 { 539 try 540 { 541 String strPattern = tmp.toString() + kPropertySeparatorChar; 542 strPattern += kWildcardChar; 543 pattern = new ObjectName (strPattern); 544 } 545 catch (MalformedObjectNameException mfone) 546 { 547 pattern = null; 548 Debug.printStackTrace(mfone); 549 } 550 } 551 return pattern; 552 } 553 554 public static ObjectName getORBObjectName(String instanceName) 555 { 556 return ( getObjectName (kDefaultIASDomainName, 557 new String []{kTypeKeyName, kServerInstanceKeyName}, 558 new String []{kOrbType, instanceName})); 559 } 560 561 public static ObjectName getIiopListenerObjectName(String instanceName, 562 String listenerId) 563 { 564 return ( getObjectName (kDefaultIASDomainName, 565 new String []{kTypeKeyName, 566 kServerInstanceKeyName, 567 kNameKeyName}, 568 new String []{kOrbListenerType, instanceName, listenerId})); 569 } 570 571 public static ObjectName 572 getJDBCConnectionPoolObjectName(String instanceName, String poolName) 573 { 574 return ( getObjectName (kDefaultIASDomainName, 575 new String []{kTypeKeyName, 576 kServerInstanceKeyName, 577 kNameKeyName}, 578 new String []{kJdbcConnectionPoolType, instanceName, poolName})); 579 } 580 581 public static ObjectName 582 getJDBCResourceObjectName(String instanceName, String jndiName) 583 { 584 return ( getObjectName (kDefaultIASDomainName, 585 new String []{kTypeKeyName, 586 kServerInstanceKeyName, 587 kNameKeyName}, 588 new String []{kJdbcResourceType, instanceName, jndiName})); 589 } 590 591 public static ObjectName 592 getJNDIResourceObjectName(String instanceName, String jndiName) 593 { 594 return ( getObjectName (kDefaultIASDomainName, 595 new String []{kTypeKeyName, 596 kServerInstanceKeyName, 597 kNameKeyName}, 598 new String []{kJndiResourceType, instanceName, jndiName})); 599 } 600 601 public static ObjectName 602 getJMSResourceObjectName(String instanceName, String jndiName) 603 { 604 return ( getObjectName (kDefaultIASDomainName, 605 new String []{kTypeKeyName, 606 kServerInstanceKeyName, 607 kNameKeyName}, 608 new String []{kJmsResourceType, instanceName, jndiName})); 609 } 610 611 public static ObjectName 612 getPersistenceManagerFactoryResourceObjectName(String instanceName, 613 String jndiName) 614 { 615 return ( getObjectName (kDefaultIASDomainName, 616 new String []{kTypeKeyName, 617 kServerInstanceKeyName, 618 kNameKeyName}, 619 new String []{kPersistenceManagerFactoryResourceType, 620 instanceName, jndiName})); 621 } 622 623 public static ObjectName 624 getMailResourceObjectName(String instanceName, String jndiName) 625 { 626 return ( getObjectName (kDefaultIASDomainName, 627 new String []{kTypeKeyName, 628 kServerInstanceKeyName, 629 kNameKeyName}, 630 new String []{kMailResourceType, instanceName, jndiName})); 631 } 632 633 public static ObjectName 634 getCustomResourceObjectName(String instanceName, String jndiName) 635 { 636 return ( getObjectName (kDefaultIASDomainName, 637 new String []{kTypeKeyName, 638 kServerInstanceKeyName, 639 kNameKeyName}, 640 new String []{kCustomResourceType, instanceName, jndiName})); 641 } 642 643 public static ObjectName getWebContainerObjectName(String instanceName) 644 { 645 return ( getObjectName (kDefaultIASDomainName, 646 new String []{kTypeKeyName, 647 kServerInstanceKeyName}, 648 new String []{kWebContainer, instanceName})); 649 } 650 651 public static ObjectName getEjbContainerObjectName(String instanceName) 652 { 653 return ( getObjectName (kDefaultIASDomainName, 654 new String []{kTypeKeyName, 655 kServerInstanceKeyName}, 656 new String []{kEjbContainer, instanceName})); 657 } 658 659 public static ObjectName getMdbContainerObjectName(String instanceName) 660 { 661 return ( getObjectName (kDefaultIASDomainName, 662 new String []{kTypeKeyName, 663 kServerInstanceKeyName}, 664 new String []{kMdbContainer, instanceName})); 665 } 666 667 public static ObjectName getJVMComponentObjectName(String instanceName) 668 { 669 return ( getObjectName (kDefaultIASDomainName, 670 new String [] {kTypeKeyName, 671 kServerInstanceKeyName}, 672 new String [] {kJvmType, instanceName})); 673 } 674 675 public static ObjectName getJTSComponentObjectName(String instanceName) 676 { 677 return ( getObjectName (kDefaultIASDomainName, 678 new String []{kTypeKeyName, 679 kServerInstanceKeyName}, 680 new String []{kJtsComponent, instanceName})); 681 } 682 683 public static ObjectName getLogServiceObjectName(String instanceName) 684 { 685 return ( getObjectName (kDefaultIASDomainName, 686 new String []{kTypeKeyName, 687 kServerInstanceKeyName}, 688 new String []{kLogService, instanceName})); 689 } 690 691 public static ObjectName getSecurityServiceObjectName(String instanceName) 692 { 693 return ( getObjectName (kDefaultIASDomainName, 694 new String []{kTypeKeyName, 695 kServerInstanceKeyName}, 696 new String []{kSecurityServiceType, instanceName})); 697 } 698 699 public static ObjectName getHttpListenerObjectName(String instanceName, 700 String id) 701 { 702 return ( getObjectName (kDefaultIASDomainName, 703 new String []{kTypeKeyName, kNameKeyName, 704 kServerInstanceKeyName}, 705 new String []{kHTTPListenerType, id, instanceName})); 706 } 707 708 720 public static ObjectName getHttpServiceObjectName(String instanceName) 721 { 722 return ( getObjectName (kDefaultIASDomainName, 723 new String []{kTypeKeyName, kServerInstanceKeyName}, 724 new String []{kHTTPServiceType, instanceName})); 725 } 726 727 public static ObjectName getVirtualServerClassObjectName( 728 String instanceName, 729 String classId) 730 { 731 return ( getObjectName (kDefaultIASDomainName, 732 new String []{kTypeKeyName, 733 kNameKeyName, 734 kServerInstanceKeyName}, 735 new String []{kVirtualServerClassType, classId, instanceName})); 736 } 737 738 public static ObjectName getVirtualServerObjectName( 739 String instanceName, 740 String virtualServerClassId, 741 String virtualServerId) 742 { 743 return ( getObjectName (kDefaultIASDomainName, 744 new String []{kTypeKeyName, kNameKeyName, 745 kVirtualServerClassIdKeyName, 746 kServerInstanceKeyName}, 747 new String []{kVirtualServerType, 748 virtualServerId, 749 virtualServerClassId, 750 instanceName})); 751 } 752 753 public static ObjectName 754 getVirtualServerAuthDBObjectName(String instanceName, 755 String virtualServerClassId, 756 String virtualServerId, 757 String authDBId) 758 { 759 return ( getObjectName (kDefaultIASDomainName, 760 new String []{kTypeKeyName, 761 kNameKeyName, 762 kVirtualServerIdKeyName, 763 kVirtualServerClassIdKeyName, 764 kServerInstanceKeyName}, 765 new String []{kAuthDbType, 766 authDBId, 767 virtualServerId, 768 virtualServerClassId, 769 instanceName})); 770 } 771 772 public static ObjectName 773 getMimeObjectName(String instanceName, String id) 774 { 775 return ( getObjectName (kDefaultIASDomainName, 776 new String []{kTypeKeyName, kNameKeyName, 777 kServerInstanceKeyName}, 778 new String []{kMimeType, id, 779 instanceName})); 780 } 781 782 public static ObjectName 783 getAclObjectName(String instanceName, String id) 784 { 785 return ( getObjectName (kDefaultIASDomainName, 786 new String []{kTypeKeyName, kNameKeyName, 787 kServerInstanceKeyName}, 788 new String []{kAclType, id, 789 instanceName})); 790 } 791 792 public static ObjectName 793 getLifeCycleModuleObjectName(String instanceName, String name) 794 { 795 return ( getObjectName (kDefaultIASDomainName, 796 new String []{kTypeKeyName, kNameKeyName, 797 kServerInstanceKeyName}, 798 new String []{kLifecycleModule, name, 799 instanceName})); 800 } 801 802 public static ObjectName getEjbObjectName(String instanceName, 803 String moduleName, 804 String ejbName) 805 { 806 return ( getObjectName (kDefaultIASDomainName, 807 new String []{kTypeKeyName, kNameKeyName, kModuleNameKeyName, 808 kServerInstanceKeyName}, 809 new String []{kEjbType, ejbName, moduleName, instanceName})); 810 } 811 812 public static ObjectName getEjbObjectName(String instanceName, 813 String appName, 814 String moduleName, 815 String ejbName) 816 { 817 return ( getObjectName (kDefaultIASDomainName, 818 new String []{kTypeKeyName, kNameKeyName, kModuleNameKeyName, 819 kApplicationNameKeyName, kServerInstanceKeyName}, 820 new String []{kEjbType, ejbName, moduleName, appName, 821 instanceName})); 822 } 823 824 public static ObjectName getServletObjectName(String instanceName, 825 String moduleName, 826 String servletName) 827 { 828 return ( getObjectName (kDefaultIASDomainName, 829 new String []{kTypeKeyName, kNameKeyName, kModuleNameKeyName, 830 kServerInstanceKeyName}, 831 new String []{kServletType, servletName, moduleName, 832 instanceName})); 833 } 834 835 public static ObjectName getServletObjectName(String instanceName, 836 String appName, 837 String moduleName, 838 String servletName) 839 { 840 return ( getObjectName (kDefaultIASDomainName, 841 new String []{kTypeKeyName, kNameKeyName, kModuleNameKeyName, 842 kApplicationNameKeyName, kServerInstanceKeyName}, 843 new String []{kServletType, servletName, moduleName, appName, 844 instanceName})); 845 } 846 847 852 public static ObjectName getRootMonitorMBeanName(String instanceName) 853 { 854 return ( getObjectName (kDefaultIASDomainName, 855 new String []{kTypeKeyName, kMonitoringClassName, 856 kServerInstanceKeyName, kNameKeyName}, 857 new String []{kMonitoringType, kMonitoringRootClass, 858 instanceName, kMonitoringRootClass})); 859 } 860 861 863 public static ObjectName getProfilerObjectName(String instanceName) 864 { 865 return ( getObjectName (kDefaultIASDomainName, 866 new String []{kTypeKeyName, kServerInstanceKeyName}, 867 new String []{kProfiler, instanceName})); 868 } 869 870 872 public static ObjectName getAuthRealmObjectName(String instanceName, 873 String realmName) 874 { 875 return ( getObjectName (kDefaultIASDomainName, 876 new String []{kTypeKeyName, kServerInstanceKeyName, 877 kNameKeyName}, 878 new String []{kAuthRealmType, instanceName, realmName})); 879 } 880 881 892 public static ObjectName getObjectName(String domainName, 893 String [] keyNames, String [] keyValues) 894 { 895 ObjectName validObjectName = null; 896 897 try 898 { 899 if (domainName == null || 900 !isDomainNameValid(domainName) || 901 keyNames == null || 902 keyValues == null || 903 keyNames.length < 1 || 904 keyNames.length != keyValues.length) 905 { 906 throw new IllegalArgumentException (); 907 } 908 StringBuffer nameBuffer = new StringBuffer (); 909 nameBuffer.append(domainName); 910 nameBuffer.append(kDomainNameSeparatorChar); 911 for (int i = 0 ; i < keyNames.length ; i++) 912 { 913 if (keyNames[i] == null || keyValues[i] == null) 914 { 915 throw new IllegalArgumentException (); 916 } 917 nameBuffer.append(keyNames[i]); 918 nameBuffer.append(kNameValueSeparatorChar); 919 nameBuffer.append(keyValues[i]); 920 if (i != (keyNames.length-1)) 921 { 922 nameBuffer.append(kPropertySeparatorChar); 923 } 924 } 925 validObjectName = new ObjectName (nameBuffer.toString()); 926 } 927 catch(Exception e) 928 { 929 Debug.printStackTrace(e); 930 } 931 return ( validObjectName ); 932 } 933 934 public static ObjectName getAllObjectNamesPattern() 935 { 936 String name = kDefaultIASDomainName + kDomainNameSeparatorChar + kWildcardChar; 937 try 938 { 939 return new ObjectName (name); 940 } 941 catch (Exception e) 942 { 943 return null; 944 } 945 } 946 947 private static boolean isDomainNameValid(String name) 948 { 949 boolean isValid = false; 950 951 isValid = (name.indexOf(kWildcardChar) == -1) && 952 (name.indexOf(kDomainNameSeparatorChar) == -1) && 953 (name.indexOf(kPropertySeparatorChar) == -1) && 954 (name.indexOf(kNameValueSeparatorChar) == -1) && 955 (name.indexOf(kSingleMatchChar) == -1); 956 957 return ( isValid ); 958 } 959 960 public static void main(String [] args) throws Exception 961 { 962 Logger.log(ObjectNames.getServerInstanceObjectName("ias1")); 963 Logger.log(ObjectNames.getApplicationObjectName("ias1", "app1")); 964 Logger.log(ObjectNames.getControllerObjectName()); 965 Logger.log(ObjectNames.getModuleObjectName("ias1", "standalone")); 966 Logger.log(ObjectNames.getModuleObjectName("ias1", "app1", "inner")); 967 Logger.log(ObjectNames.getObjectName("ias111", 968 new String []{"key1", "key2", "key3"}, 969 new String []{"v1", "v2", "v3"})); 970 971 ObjectName pattern = 973 ObjectNames.getServerInstanceObjectNamePattern(); 974 Logger.log("" + pattern.isPropertyPattern()); 975 pattern = ObjectNames.getApplicationObjectNamePattern("ias1"); 976 Logger.log("" + pattern.isPropertyPattern()); 977 pattern = ObjectNames.getModuleObjectNamePattern("ias1"); 978 Logger.log("" + pattern.isPropertyPattern()); 979 pattern = ObjectNames.getModuleObjectNamePattern("ias1", "bank"); 980 Logger.log("" + pattern.isPropertyPattern()); 981 982 ObjectName jmsObjectName = 983 ObjectNames.getJMSAdminHandlerObjectName("ias1"); 984 Logger.log("JMS Objectname = " + jmsObjectName.toString()); 985 jmsObjectName = ObjectNames.getJMSAdminHandlerObjectName(); 986 Logger.log("JMS Objectname = " + jmsObjectName.toString()); 987 988 ObjectName httpListener = ObjectNames.getHttpListenerObjectName( 989 "ias1", "listener1"); 990 Logger.log("Http listener object name = " + httpListener); 991 992 993 ObjectName mime = ObjectNames.getMimeObjectName("ias1", "text/html"); 994 Logger.log("Mime object name = " + mime); 995 996 ObjectName acl = ObjectNames.getAclObjectName("ias1", "acl1"); 997 Logger.log("ACL object name = " + acl); 998 999 } 1000} 1001 | Popular Tags |