1 23 package com.sun.enterprise.admin.server.core; 24 25 import com.sun.enterprise.admin.event.MBeanElementChangeEvent; 27 import com.sun.enterprise.admin.event.MBeanElementChangeEventListener; 28 import java.io.File ; 29 import java.util.Properties ; 30 31 import javax.management.MBeanServer ; 33 import javax.management.MalformedObjectNameException ; 34 import javax.management.ObjectName ; 35 import com.sun.enterprise.admin.common.MBeanServerFactory; 37 import com.sun.enterprise.admin.server.core.jmx.SunoneInterceptor; 38 39 import com.sun.enterprise.admin.event.AdminEventListenerRegistry; 40 import com.sun.enterprise.admin.event.AdminEventListener; 41 import com.sun.enterprise.admin.event.tx.TransactionsRecoveryEventListener; 42 import com.sun.enterprise.admin.event.tx.TransactionsRecoveryEvent; 43 import com.sun.enterprise.admin.event.WebConfigChangeEventListener; 44 import com.sun.enterprise.admin.event.DynamicReconfigEvent; 45 import com.sun.enterprise.admin.event.DynamicReconfigEventListener; 46 import com.sun.enterprise.admin.monitor.GenericMonitorMBean; 47 import com.sun.enterprise.admin.server.core.channel.AdminChannel; 48 import com.sun.enterprise.instance.ServerManager; 49 import com.sun.enterprise.admin.common.constant.AdminConstants; 50 import com.sun.enterprise.instance.InstanceEnvironment; 51 52 import com.sun.enterprise.server.Constants; 53 import com.sun.enterprise.server.ServerContext; 54 import com.sun.enterprise.server.ServerContextImpl; 55 56 import com.sun.appserv.server.ServerLifecycleException; 57 import com.sun.appserv.server.ServerLifecycle; 58 59 import com.sun.enterprise.config.ConfigContext; 60 import com.sun.enterprise.config.ConfigException; 61 import com.sun.enterprise.config.serverbeans.ServerHelper; 62 import com.sun.enterprise.config.serverbeans.ServerBeansFactory; 63 64 import com.sun.enterprise.web.PEWebContainer; 65 66 import java.util.logging.Level ; 68 import java.util.logging.Logger ; 69 import com.sun.logging.LogDomains; 70 71 import com.sun.enterprise.util.io.FileUtils; 73 import com.sun.enterprise.util.i18n.StringManager; 74 75 import com.sun.enterprise.deployment.autodeploy.AutoDeployControllerImpl; 77 import com.sun.enterprise.deployment.autodeploy.AutoDeployController; 78 import com.sun.enterprise.deployment.autodeploy.AutoDeployConstants; 79 import com.sun.enterprise.deployment.autodeploy.AutoDeploymentException; 80 import com.sun.enterprise.deployment.autodeploy.AutoDeployControllerFactroy; 81 import com.sun.enterprise.deployment.autodeploy.AutoDeployControllerFactroyImpl; 82 83 import com.sun.enterprise.webservice.WsUtil; 85 86 import com.sun.enterprise.admin.AdminContext; 87 import com.sun.enterprise.admin.meta.MBeanRegistry; 88 import com.sun.enterprise.admin.meta.MBeanRegistryFactory; 89 import com.sun.enterprise.admin.server.core.jmx.AppServerMBeanServerFactory; 90 import com.sun.enterprise.admin.common.ObjectNames; 91 import com.sun.enterprise.admin.server.core.channel.RRStateFactory; 92 93 96 import com.sun.enterprise.Switch; 97 import com.sun.enterprise.admin.monitor.callflow.Agent; 98 import com.sun.enterprise.admin.monitor.callflow.AgentAdapter; 99 100 104 public class AdminService { 105 106 111 public static final String TYPE_DASD = "das-and-server"; 112 113 117 public static final String TYPE_DAS = "das"; 118 119 123 public static final String TYPE_SERVER = "server"; 124 125 130 public static final boolean ENABLE_PERFORMANCE_THREAD = true; 131 132 133 136 public static final Logger sLogger 137 = LogDomains.getLogger(AdminConstants.kLoggerName); 138 139 private static StringManager localStrings = 140 StringManager.getManager(AdminService.class); 141 142 private static AdminService adminService = null; 143 144 145 private static final String ADMIN_DOMAIN_NAME_PREFIX = "com.sun.appserv."; 146 147 148 private static final String DEF_ADMIN_DOMAIN_NAME="com.sun.appserv.server"; 149 150 private static String kTempDirNamePrefix = "s1astemp"; 151 private static String kGUITempDirName = "gui"; 152 private static String kTempDirNameSuffix = 153 "" + ((System.getProperty(Constants.IAS_ROOT) != null) ? 154 System.getProperty(Constants.IAS_ROOT).hashCode() : 0); 155 158 private static int sMBeanServerID; 159 public static final int kDefaultImpl = 0; 160 private static final String SS_MBEAN_CLASS = "com.sun.enterprise.admin.mbeans.SystemServicesMBean"; 161 private String adminServiceType; 162 private ServerContext context; 163 private AdminContext adminContext; 164 private ServerLifecycle adminChannel; 165 private String mTempDirPath; 166 private String mGUITempDirPath; 167 private AutoDeployController autoDeployController; 168 169 171 public static final String PRIVATE_MBEAN_DOMAIN_NAME = "com.sun.appserv"; 172 public static final String DAS_DIAGNOSTIC_MBEAN_CLASS_NAME = 173 "com.sun.enterprise.admin.mbeans.DomainDiagnostics"; 174 175 176 180 private AdminService() { 181 sMBeanServerID = kDefaultImpl; } 183 184 188 static AdminService createAdminService(ServerContext sc) { 189 System.setProperty("com.sun.aas.admin.logger.name", 190 AdminConstants.kLoggerName); 191 String type = TYPE_SERVER; 192 if (ServerManager.ADMINSERVER_ID.equals(sc.getInstanceName())) { 193 type = TYPE_DAS; 194 } 195 ConfigContext cc = sc.getConfigContext(); 196 try { 197 com.sun.enterprise.config.serverbeans.AdminService as = 198 ServerBeansFactory.getConfigBean(cc).getAdminService(); 199 if (as != null) { 200 type = as.getType(); 201 } 202 } catch (ConfigException ce) { 203 ce.printStackTrace(); 204 sLogger.log(Level.WARNING, "core.admin_service_default_config", 205 type); 206 } 207 AdminService as = instantiateAdminService(type); 208 as.setContext(sc); 209 AdminContext ac = sc.getPluggableFeatureFactory().getAdminContext(); 210 if (ac instanceof AdminContextImpl) { 211 ((AdminContextImpl)ac).setServerContext((ServerContextImpl)sc); 212 } 213 as.setAdminContext(ac); 214 setAdminService(as); 215 return as; 216 } 217 218 223 private static AdminService instantiateAdminService(String type) { 224 AdminService as = null; 225 if (TYPE_DASD.equals(type) || TYPE_DAS.equals(type) 226 || TYPE_SERVER.equals(type)) { 227 as = new AdminService(); 228 as.setType(type); 229 } else { 230 throw new RuntimeException (localStrings.getString( 231 "admin.server.core.unknown_admin_service_type", type)); 232 } 233 return as; 234 } 235 236 241 private static void setAdminService(AdminService srv) { 242 adminService = srv; 243 } 244 245 249 public static AdminService getAdminService() { 250 return adminService; 251 } 252 253 263 void init() throws ServerLifecycleException { 264 265 if (isDas()) { 266 RRStateFactory.removeStateFile(); 268 } 269 adminChannel = new AdminChannelLifecycle(); 270 adminChannel.onInitialization(context); 271 272 MBeanServer mbs = null; 273 274 try { 275 if (sMBeanServerID == kDefaultImpl) { 276 SunoneInterceptor.setAdminContext(adminContext); 277 mbs = SunoneInterceptor.getMBeanServerInstance(); 278 MBeanServerFactory.initialize(this, mbs); 279 } else { 280 throw new RuntimeException (localStrings.getString( 281 "admin.server.core.mbs_init_error")); 282 } 283 if (adminContext != null) { 284 adminContext.setMBeanServer(mbs); 285 } 286 sLogger.log(Level.INFO, "core.mbs_init_ok"); 287 initCallFlow(); 288 } 289 catch (Throwable t) { 290 sLogger.log(Level.FINEST, t.getMessage(), t); 291 if (isDas()) { 292 sLogger.log(Level.SEVERE, "core.mbs_init_exception", t); 293 } 294 else { 295 sLogger.log(Level.WARNING, "core.mbs_init_exception", t); 296 } 297 throw new ServerLifecycleException(t.getMessage()); 298 } 299 } 300 301 private void initCallFlow() { 302 try { 303 Class cl = Class.forName( 304 "com.sun.enterprise.admin.monitor.callflow.AgentImpl"); 305 Agent agent = (Agent) cl.newInstance(); 306 Switch.getSwitch().setCallFlowAgent(agent); 307 } catch (Throwable t) { 308 sLogger.log(Level.SEVERE, "core.callflow_agent_init_failed", t); 309 Switch.getSwitch().setCallFlowAgent(new AgentAdapter()); 310 } 311 } 312 313 318 void start() throws ServerLifecycleException { 319 com.sun.enterprise.ManagementObjectManager mgmtObjManager = com.sun.enterprise.Switch.getSwitch().getManagementObjectManager(); 320 if (isDas()) { 321 startAdminInstance(); 322 mgmtObjManager.registerJ2EEDomain(); 323 } 324 325 initializeAMXMBeans( isDas() ); 326 327 mgmtObjManager.registerJVM(); 329 mgmtObjManager.registerJ2EEServer(); 330 331 if (isDas()) { 332 mgmtObjManager.registerDasJ2EEServers(); 336 mgmtObjManager.registerAllJ2EEClusters(); 337 } 338 339 if (canRunUserApps()) { 340 startNormalInstance(); 341 } 342 343 344 initializePerInstanceSystemService(); 345 initializeDottedNames(); 348 registerTransactionsRecoveryEventMBean(); 349 mgmtObjManager.registerTransactionService(); 350 351 WsUtil.start(); 353 createDASDiagnosticMBean(); 355 356 } 357 358 361 void ready() throws ServerLifecycleException { 362 if (isDas()) { 363 startAutoDeployService(); 365 } 366 if (adminChannel != null) { 367 adminChannel.onReady(context); 368 } 369 initiateCustomMBeanLoading(); 370 registerJVMMonitoringMBeans(); 371 372 notifyAMXThatAdminServiceIsReady(); 375 } 376 377 380 void stop() throws ServerLifecycleException { 381 if (adminChannel != null) { 382 adminChannel.onShutdown(); 383 } 384 com.sun.enterprise.ManagementObjectManager mgmtObjManager = com.sun.enterprise.Switch.getSwitch().getManagementObjectManager(); 385 386 389 if (isDas()) { 390 if(ENABLE_PERFORMANCE_THREAD) ManualChangeTracker.stop(); 392 stopAdminInstance(); 393 } 394 if (canRunUserApps()) { 395 stopAutoDeployService(); 397 stopNormalInstance(); 398 } 399 } 401 402 405 void destroy() throws ServerLifecycleException { 406 } 407 408 411 public ServerContext getContext() { 412 return ((adminService == null) ? null : adminService.context); 413 } 414 415 419 void setContext(ServerContext ctx) { 420 context = ctx; 421 } 422 423 426 public AdminContext getAdminContext() { 427 return adminContext; 428 } 429 430 437 public String getAdministrativeDomainName() throws ConfigException { 438 439 String serverName = adminContext.getServerName(); 440 ConfigContext ctx = adminContext.getAdminConfigContext(); 441 String aDomainName = 442 ServerHelper.getAdministrativeDomainName(ctx, serverName); 443 444 if ( (aDomainName == null) || ("".equals(aDomainName)) ) { 447 return DEF_ADMIN_DOMAIN_NAME; 448 } else { 449 return ADMIN_DOMAIN_NAME_PREFIX + aDomainName; 450 } 451 } 452 453 456 protected void setAdminContext(AdminContext ctx) { 457 adminContext = ctx; 458 } 459 460 463 public String getInstanceName() { 464 return ((context == null) ? null : context.getInstanceName()); 465 } 466 467 471 public GenericMonitorMBean getRootMonitorMBean() { 472 return GenericMonitorMBean.getRoot(); 473 } 474 475 478 private void startAdminInstance() throws ServerLifecycleException { 479 setAdminInstanceProperties(); 480 createTempDir(); 485 } 486 487 490 private void stopAdminInstance() throws ServerLifecycleException { 491 deleteTempDir(); 492 } 493 494 497 private void startNormalInstance() throws ServerLifecycleException { 498 initLogManagerReconfigSupport(); 499 registerTransactionsRecoveryEventListener(); 500 } 503 504 507 private void stopNormalInstance() throws ServerLifecycleException { 508 } 509 510 517 public boolean isAdminInstance() { 518 if (ServerManager.ADMINSERVER_ID.equals(context.getInstanceName())) { 519 return true; 520 } else { 521 return false; 522 } 523 } 524 525 532 public boolean isDas() { 533 if (TYPE_DASD.equals(adminServiceType) 534 || TYPE_DAS.equals(adminServiceType)) { 535 return true; 536 } else { 537 return false; 538 } 539 } 540 541 550 public boolean canRunUserApps() { 551 if (TYPE_DAS.equals(adminServiceType)) { 552 return false; 553 } else { 554 return true; 555 } 556 } 557 558 563 public String getType() { 564 return adminServiceType; 565 } 566 567 570 private void setType(String type) { 571 adminServiceType = type; 572 } 573 574 578 private void createTimeStampFilesForInstances() { 579 String [] instanceIds = ServerManager.instance().getInstanceNames(true); 580 for (int i = 0 ; i < instanceIds.length ; i ++) { 581 try { 582 String instanceId = instanceIds[i]; 583 InstanceEnvironment ie = new InstanceEnvironment(instanceId); 584 ie.createTimeStampFiles(); 585 sLogger.log(Level.FINE, "core.ts_files_ok", instanceId); 586 } 587 catch (Exception e) { 588 sLogger.log(Level.WARNING, "core.ts_files_failed", e); 590 } 591 } 592 593 } 594 595 603 public String getTempDirPath() { 604 if (mTempDirPath == null) { 605 612 createTempDir(); 613 } 614 615 return ( mTempDirPath ); 616 } 617 618 626 public String getGUITempDirPath() { 627 if (mGUITempDirPath == null) { 628 635 createTempDir(); 636 } 637 else { 638 final File gd = new File (mGUITempDirPath); 639 if (!gd.exists()) { 640 final boolean s = gd.mkdirs(); 641 if (!s) { 642 final String msg = localStrings.getString("admin.server.core.gui_dir_failure", mGUITempDirPath); 643 throw new RuntimeException (msg); 644 } 645 } 646 } 647 648 return ( mGUITempDirPath ); 649 } 650 651 private void createTempDir() { 652 try { 653 String domainName = ServerManager.instance().getDomainName(); 654 String localTmpDir = System.getProperty("java.io.tmpdir"); 655 String asTempDirName = kTempDirNamePrefix + domainName + 656 context.getInstanceName() + kTempDirNameSuffix; 657 658 File tempFolder = new File (localTmpDir, asTempDirName); 659 mTempDirPath = tempFolder.getCanonicalPath(); 660 661 662 File guiTempFolder = new File (mTempDirPath, kGUITempDirName); 663 mGUITempDirPath = guiTempFolder.getCanonicalPath(); 664 if (tempFolder.exists()) { 665 671 sLogger.log(Level.FINEST, "core.tmp_folder_exists", 672 mTempDirPath); 673 return; 674 } 675 676 boolean couldCreate = tempFolder.mkdirs(); 677 if (! couldCreate) { 678 sLogger.log(Level.WARNING, "core.tmp_folder_creation_failed", 679 mTempDirPath); 680 } 681 else { 682 sLogger.log(Level.FINEST, "core.tmp_folder_created_ok", 683 mTempDirPath); 684 } 685 686 couldCreate = guiTempFolder.mkdirs(); 687 if (! couldCreate) { 688 sLogger.log(Level.WARNING, "core.gui_tmp_folder_creation_failed", 689 mGUITempDirPath); 690 } 691 else { 692 sLogger.log(Level.FINEST, "core.gui_tmp_folder_created_ok", 693 mGUITempDirPath); 694 } 695 } 696 catch(Throwable t) { 697 sLogger.log(Level.WARNING, "core.tmp_folder_creation_failed", t); 698 } 699 } 700 701 private void deleteTempDir() { 702 try { 703 FileUtils.whack(new File (mTempDirPath)); 704 sLogger.log(Level.FINEST, "core.tmp_folder_deleted_ok", 705 mTempDirPath); 706 } 707 catch(Throwable t) { 708 sLogger.log(Level.WARNING, "core.tmp_folder_deletion_failed", 709 mTempDirPath); 710 } 711 } 712 713 719 private void setAdminInstanceProperties() { 720 try { 721 String adminJavaRoot = System.getProperty(ADMIN_JAVAROOT); 722 String pluginJavaRoot = System.getProperty(PLUGIN_JAVAROOT); 723 if (adminJavaRoot == null) { 724 if (pluginJavaRoot != null) { 725 System.setProperty(ADMIN_JAVAROOT, pluginJavaRoot); 726 } else { 727 sLogger.log(Level.WARNING, "core.no_java_home"); 728 } 729 } 730 } catch (Throwable t) { 731 sLogger.log(Level.WARNING, "core.set_admin_property_failed"); 732 sLogger.log(Level.FINE, "general.unexpected_exception", t); 733 } 734 } 735 736 private static final String ADMIN_JAVAROOT = "com.sun.aas.javaRoot"; 737 private static final String PLUGIN_JAVAROOT = "JAVA_HOME"; 738 739 742 private void startAutoDeployService(){ 743 try { 744 AutoDeployControllerFactroy controllerFactory = new AutoDeployControllerFactroyImpl(); 745 autoDeployController = controllerFactory.createAutoDeployController(context); 746 if(autoDeployController !=null ) { 747 autoDeployController.enableAutoDeploy(); 748 } 749 } catch(Throwable tw) { 750 sLogger.log(Level.FINE, "general.unexpected_exception", tw); 751 } 752 } 753 754 757 private void stopAutoDeployService(){ 758 try { 759 if(autoDeployController !=null) { 760 autoDeployController.disableAutoDeploy(); 761 autoDeployController=null; 762 } 763 } catch(Throwable tw) { 764 sLogger.log(Level.FINE, "general.unexpected_exception", tw); 765 } 766 } 767 768 781 private void initializeDottedNames() { 782 try { 783 MBeanRegistry mr = MBeanRegistryFactory.getAdminMBeanRegistry(); 784 mr.generateAndRegisterAllDottedNames(context.getConfigContext(), 785 context.getDefaultDomainName()); 786 } catch (Throwable t) { 787 sLogger.log(Level.WARNING, "admin.dotted_names_init_exception", t); 788 } 789 } 790 791 private void registerTransactionsRecoveryEventListener() { 792 try 793 { 794 AdminEventListenerRegistry.addEventListener( 795 TransactionsRecoveryEvent.eventType, 796 (AdminEventListener)(new com.sun.enterprise.transaction.TransactionsRecoveryEventListenerImpl())); 797 } 798 catch (Throwable t) 799 { 800 sLogger.log(Level.WARNING, "admin.transactions_recovery_listener_registration_exception", t); 801 } 802 803 } 804 private void registerTransactionsRecoveryEventMBean() { 805 try { 806 MBeanRegistryFactory.getAdminMBeanRegistry().instantiateMBean( 807 "transactions-recovery", new String []{adminContext.getDomainName()}, null, null, true ); 808 } catch (Throwable t) { 809 sLogger.log(Level.FINE, "core.transactions_recovery_mbean_register_error", t); 810 } 811 } 812 813 814 private void initLogManagerReconfigSupport() { 815 registerLogManagerMBean(); 816 registerLogManagerEventListener(); 817 registerDynamicReconfigEventListener(); 818 } 819 820 private void registerLogManagerMBean() { 821 MBeanServer mbs = adminContext.getMBeanServer(); 822 try { 823 Object mbean = 824 com.sun.enterprise.server.logging.LogMBean.getInstance(); 825 mbs.registerMBean(mbean, getLogManagerMBeanName()); 826 } catch (Throwable t) { 827 sLogger.log(Level.WARNING, "core.logmgr_mbean_not_registered"); 828 sLogger.log(Level.FINE, "core.logmgr_mbean_register_error", t); 829 } 830 } 831 832 private ObjectName getLogManagerMBeanName() 833 throws MalformedObjectNameException { 834 Properties props = new Properties (); 835 props.put("server", adminContext.getServerName()); 836 props.put("category", "runtime"); 837 props.put("name", "logmanager"); 838 ObjectName on = new ObjectName (adminContext.getDomainName(), props); 839 return on; 840 } 841 842 private void registerLogManagerEventListener() { 843 AdminEventListenerRegistry.addLogLevelChangeEventListener( 844 new com.sun.enterprise.server.logging.LogLevelChangeEventListenerImpl()); 845 } 846 847 private void registerDynamicReconfigEventListener() { 848 AdminEventListenerRegistry.addEventListener( 849 DynamicReconfigEvent.eventType, new 850 com.sun.enterprise.admin.server.core.channel.DynamicReconfigEventListenerImpl()); 851 } 852 861 private void initializePerInstanceSystemService() throws ServerLifecycleException { 862 ObjectName on = null; 863 try { 864 final MBeanServer mbs = getMBeanServer(); 865 on = ObjectNames.getPerInstanceSystemServicesObjectName(this.getInstanceName()); 866 final Object impl = Class.forName(SS_MBEAN_CLASS).newInstance(); 867 mbs.registerMBean(impl, on); 868 sLogger.finer("Admin Message: System Services MBean Registered with on: " + on.toString()); 869 if (isDas()) { 870 mbs.registerMBean(impl, new ObjectName ("ias:type=system-services")); 873 sLogger.finer("Admin Message: System Services MBean Registered with sibling name: " + on.toString()); 874 } 875 } 876 catch (final Exception e) { 877 throw new ServerLifecycleException(e); 878 } 879 } 880 881 882 883 private static final String AMX_DAS_LOADER_CLASSNAME = 884 "com.sun.enterprise.management.support.Loader"; 885 886 private static final String AMX_NON_DAS_LOADER_CLASSNAME = 887 "com.sun.enterprise.management.support.NonDASLoader"; 888 889 public static final String AMX_LOADER_DEFAULT_OBJECTNAME = 890 "amx-support:name=mbean-loader"; 891 892 private ObjectName mAMXLoaderObjectName = null; 893 894 898 private void initializeAMXMBeans( boolean isDAS ) { 899 try { 900 final String loaderClassname = 903 isDAS ? AMX_DAS_LOADER_CLASSNAME : AMX_NON_DAS_LOADER_CLASSNAME; 904 905 final Class loaderClass = Class.forName( loaderClassname ); 906 final Object loader = loaderClass.newInstance(); 907 ObjectName tempObjectName = new ObjectName ( AMX_LOADER_DEFAULT_OBJECTNAME ); 908 909 mAMXLoaderObjectName = 910 getMBeanServer().registerMBean( loader, tempObjectName ).getObjectName(); 911 912 sLogger.log(Level.INFO, "mbean.init_amx_success"); 913 } 914 catch(Exception e) { 915 sLogger.log(Level.SEVERE, "mbean.init_amx_failed", e); 917 throw new Error ( e ); 919 } 920 } 921 922 private MBeanServer 923 getMBeanServer() { 924 try { 925 return AppServerMBeanServerFactory.getMBeanServerInstance(); 926 } 927 catch( Exception e ) { 928 throw new RuntimeException ( e ); 929 } 930 } 931 932 933 937 private void notifyAMXThatAdminServiceIsReady() { 938 try { 939 getMBeanServer().invoke( mAMXLoaderObjectName, "adminServiceReady", null, null ); 940 } 941 catch( Exception e ) { 942 throw new RuntimeException ( e ); 943 } 944 } 945 946 947 private void initiateCustomMBeanLoading() throws ServerLifecycleException { 948 try { 949 final MBeanServer mbs = adminContext.getMBeanServer(); 950 final ConfigContext cc = context.getConfigContext(); 951 new CustomMBeanRegistrationHelper(mbs, cc).registerMBeans(); 952 } catch (final Exception e) { 953 e.printStackTrace(); 954 throw new ServerLifecycleException(e); } 956 initializeMBeanEventListeners(); 957 } 958 private void registerJVMMonitoringMBeans() { 959 try { 960 final ObjectName dummy1 = new ObjectName ("foo:bar=bar1"), dummy2 = new ObjectName ("foo:bar=bar2"); 962 if (this.isDas()) { 963 final Object jvmic = Class.forName("com.sun.enterprise.admin.mbeans.jvm.JVMInformationCollector").newInstance(); 964 com.sun.enterprise.admin.common.MBeanServerFactory.getMBeanServer().registerMBean(jvmic, dummy1); 965 } 966 final Object jvmi = Class.forName("com.sun.enterprise.admin.mbeans.jvm.JVMInformation").newInstance(); 967 com.sun.enterprise.admin.common.MBeanServerFactory.getMBeanServer().registerMBean(jvmi, dummy2); 968 } catch (final Exception e) { 969 e.printStackTrace(); 970 } 971 } 972 973 private void createDASDiagnosticMBean() { 975 try { 976 final MBeanServer mbs = getMBeanServer(); 977 ObjectName on = new ObjectName ( 978 PRIVATE_MBEAN_DOMAIN_NAME + ":" + 979 "type=DomainDiagnostics,name=" + getInstanceName() + ",category=monitor"); 980 Class cl = Class.forName(DAS_DIAGNOSTIC_MBEAN_CLASS_NAME); 981 mbs.registerMBean(cl.newInstance(), on); 982 } catch (Throwable t) { 983 t.printStackTrace(); 984 sLogger.log(Level.INFO, "core.das_diag__mbean_not_registered", t.getMessage()); 985 } 986 } 987 private void initializeMBeanEventListeners() { 988 try { 989 Class c = null; if (this.isDas()) { 991 c = Class.forName("com.sun.enterprise.admin.mbeans.custom.InProcessMBeanElementChangeEventListenerImpl"); 992 } 993 else { 994 c = Class.forName("com.sun.enterprise.ee.admin.mbeans.RemoteMBeanElementChangeEventListenerImpl"); 995 } 996 final Object o = c.newInstance(); 997 AdminEventListenerRegistry.addEventListener(MBeanElementChangeEvent.EVENT_TYPE, (MBeanElementChangeEventListener)o); 998 } catch (final Exception e) { 999 e.printStackTrace(); } 1001 } 1002} 1003 | Popular Tags |