private void initJmxExpose() {
		final String packageName = getClass().getName().substring(0,
				getClass().getName().length() - getClass().getSimpleName().length() - 1);
		String webapp = Parameters.getContextPath(Parameters.getServletContext());
		if (webapp.length() >= 1 && webapp.charAt(0) == '/') {
			webapp = webapp.substring(1, webapp.length());
		}
		final List<Counter> counters = collector.getCounters();
		final MBeanServer platformMBeanServer = MBeans.getPlatformMBeanServer();
		try {
			for (final Counter counter : counters) {
				if (!Parameters.isCounterHidden(counter.getName())) {
					final CounterRequestMXBean.CounterRequestMXBeanImpl mxBean = new CounterRequestMXBean.CounterRequestMXBeanImpl(
							counter);
					final ObjectName name = new ObjectName(
							packageName + ":type=CounterRequest,context=" + webapp + ",name="
									+ counter.getName());
					platformMBeanServer.registerMBean(mxBean, name);
					jmxNames.add(name);
				}
			}
			LOG.debug("JMX mbeans registered");
		} catch (final JMException e) {
			LOG.warn("failed to register JMX mbeans", e);
		}
	}
private void initJmxExpose ( ) { final String packageName = getClass ( ) . getName ( ) . substring ( 0 , getClass ( ) . getName ( ) . length ( ) - getClass ( ) . getSimpleName ( ) . length ( ) - 1 ) ; String webapp = Parameters . getContextPath ( Parameters . getServletContext ( ) ) ; if ( webapp . length ( ) >= 1 && webapp . charAt ( 0 ) == '/' ) { webapp = webapp . substring ( 1 , webapp . length ( ) ) ; } final List < Counter > counters = collector . getCounters ( ) ; final MBeanServer platformMBeanServer = MBeans . getPlatformMBeanServer ( ) ; try { for ( final Counter counter : counters ) { if ( ! Parameters . isCounterHidden ( counter . getName ( ) ) ) { final CounterRequestMXBean . CounterRequestMXBeanImpl mxBean = new CounterRequestMXBean . CounterRequestMXBeanImpl ( counter ) ; final ObjectName name = new ObjectName ( packageName + ":type=CounterRequest,context=" + webapp + ",name=" + counter . getName ( ) ) ; platformMBeanServer . registerMBean ( mxBean , name ) ; jmxNames . add ( name ) ; } } LOG . debug ( "JMX mbeans registered" ) ; } catch ( final JMException e ) { LOG . warn ( "failed to register JMX mbeans" , e ) ; } }
Registers CounterRequestMXBean beans for each of the enabled counters.
The beans are registered under "net.bull.javamelody:type=CounterRequest,context=<webapp>,name=<counter name>" names.
@author Alexey Pushkin