protected void registerUnregisterJMX ( boolean doRegister ) { if ( this . mbs == null ) { // this way makes it easier for mocking. this . mbs = ManagementFactory . getPlatformMBeanServer ( ) ; } try { String suffix = "" ; if ( this . config . getPoolName ( ) != null ) { suffix = "-" + this . config . getPoolName ( ) ; } ObjectName name = new ObjectName ( MBEAN_BONECP + suffix ) ; ObjectName configname = new ObjectName ( MBEAN_CONFIG + suffix ) ; if ( doRegister ) { if ( ! this . mbs . isRegistered ( name ) ) { this . mbs . registerMBean ( this . statistics , name ) ; } if ( ! this . mbs . isRegistered ( configname ) ) { this . mbs . registerMBean ( this . config , configname ) ; } } else { if ( this . mbs . isRegistered ( name ) ) { this . mbs . unregisterMBean ( name ) ; } if ( this . mbs . isRegistered ( configname ) ) { this . mbs . unregisterMBean ( configname ) ; } } } catch ( Exception e ) { logger . error ( "Unable to start/stop JMX" , e ) ; } }
Initialises JMX stuff .