首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

JBoss MBean兑现方法

2012-11-10 
JBoss MBean实现方法JBoss MBean实现方法public interface XXMBean{...}public class XX extends ServiceM

JBoss MBean实现方法

JBoss MBean实现方法public interface XXMBean{...}public class XX extends ServiceMBeanSupport implements XXMBean{ ...}public class XX extends StandardMBean implements SomeIntf{ ...}?
META-INF/jboss-service.xml中的配置项
<mbean code="实现类全名路径"  name="xxx.xxx.xxx:service=xxxxMBean"/>
?XX-xmbean.xml内容
<mbean><description>Demo</description><descriptors><interceptors><interceptor code="test.MyInterceptor"/></interceptors> </descriptors><class>XX</class>
?package test;import org.jboss.mx.interceptor.AbstractInterceptor;import org.jboss.mx.interceptor.Interceptor;import org.jboss.mx.server.Invocation;public class MyInterceptor extends AbstractInterceptor {public Object invoke(Invocation invocation) throws Throwable{ log.info("Invocation: " + invocation);AbstractInterceptor ic = invocation.nextInterceptor();if( ic == null ){return invocation.dispatch();}else{long start = System.currentTimeMillis();try{return ic.invoke( invocation );}catch(Exception e){ e.printStackTrace();return null;} //I can wrapp some exceptionfinally{log.info("call time : " + ( System.currentTimeMillis() - start ) );}} }}?这样就可以捕获MBean方法调用了,这个例子是显示MBean方法的调用时间

热点排行