final MBeanServer server = LocalMBeanServer.get();
// Create stats interceptor
if (StatsInterceptor.isStatsActivated()) {
StatsInterceptor stats = null;
for (final InterceptorInstance interceptor : beanContext.getUserAndSystemInterceptors()) {
if (interceptor.getInterceptor() instanceof StatsInterceptor) {
stats = (StatsInterceptor) interceptor.getInterceptor();
}
}
if (stats == null) { // normally useless
stats = new StatsInterceptor(beanContext.getBeanClass());
beanContext.addFirstSystemInterceptor(stats);
}
// register the invocation stats interceptor
try {