MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
ObjectName name = new ObjectName("twitter4j.mbean:type=APIStatistics");
ObjectName name2 = new ObjectName("twitter4j.mbean:type=APIStatisticsOpenMBean");
APIStatistics statsMBean = new APIStatistics(100);
mbs.registerMBean(statsMBean, name);
APIStatisticsOpenMBean openMBean = new APIStatisticsOpenMBean(statsMBean);
mbs.registerMBean(openMBean, name2);
for (int i = 0; i < 10; i++) {
statsMBean.methodCalled("foo", 5, true);
statsMBean.methodCalled("bar", 2, true);