public static void initJMXBean ( JawrApplicationConfigManager appConfigMgr , ServletContext servletContext , String resourceType , String mBeanPrefix ) { try { MBeanServer mbs = ManagementFactory . getPlatformMBeanServer ( ) ; if ( mbs != null ) { ObjectName jawrConfigMgrObjName = JmxUtils . getMBeanObjectName ( servletContext , resourceType , mBeanPrefix ) ; // register the jawrApplicationConfigManager if it's not already // done ObjectName appJawrMgrObjectName = JmxUtils . getAppJawrConfigMBeanObjectName ( servletContext , mBeanPrefix ) ; if ( ! mbs . isRegistered ( appJawrMgrObjectName ) ) { mbs . registerMBean ( appConfigMgr , appJawrMgrObjectName ) ; } if ( mbs . isRegistered ( jawrConfigMgrObjName ) ) { LOGGER . warn ( "The MBean '" + jawrConfigMgrObjName . getCanonicalName ( ) + "' already exists. It will be unregisterd and registered with the new JawrConfigManagerMBean." ) ; mbs . unregisterMBean ( jawrConfigMgrObjName ) ; } JawrConfigManagerMBean configMgr = appConfigMgr . getConfigMgr ( resourceType ) ; mbs . registerMBean ( configMgr , jawrConfigMgrObjName ) ; } } catch ( InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException | InstanceNotFoundException e ) { LOGGER . error ( "Unable to instanciate the Jawr MBean for resource type '" + resourceType + "'" , e ) ; } }
Initialize the JMX Bean