StatsInterceptor stats = new StatsInterceptor(deploymentInfo.getBeanClass());
deploymentInfo.addSystemInterceptor(stats);
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
ObjectNameBuilder jmxName = new ObjectNameBuilder("openejb.management");
jmxName.set("J2EEServer", "openejb");
jmxName.set("J2EEApplication", null);
jmxName.set("EJBModule", deploymentInfo.getModuleID());
jmxName.set("StatelessSessionBean", deploymentInfo.getEjbName());
jmxName.set("j2eeType", "");
jmxName.set("name", deploymentInfo.getEjbName());
// register the invocation stats interceptor
try {
ObjectName objectName = jmxName.set("j2eeType", "Invocations").build();
server.registerMBean(new ManagedMBean(stats), objectName);
data.add(objectName);
} catch (Exception e) {
logger.error("Unable to register MBean ", e);
}
// register the pool
try {
ObjectName objectName = jmxName.set("j2eeType", "Pool").build();
server.registerMBean(new ManagedMBean(data.pool), objectName);
data.add(objectName);
} catch (Exception e) {
logger.error("Unable to register MBean ", e);
}