Insert MBean interceptor

五迷三道 提交于 2019-12-08 04:28:17

问题


I am working in a java project which implements MBeans and my need is to intercept MBean and change/add their properties before registry. Example :

domainName:name=myMBean --> domainName:name=myMBean1,type=myType

I found this link which presents how to apply an interceptor other then default interceptor but I have no idea to how do that in code.

Thanks in advance.


回答1:


Once you register the bean obviously it is too late. The easiest thing to do is to change how the registration is done. If you show us what framework you are using to register the bean then I'll be able to help more.

Typically whatever is doing the actual registration is doing something like:

private MBeanServer mbeanServer;
...
mbeanServer.registerMBean(mbean, objectName);

You can therefore provide a different ObjectName:

ObjectName objectName = new ObjectName("domainName:name=myMBean1,type=myType");

But I assume you are not doing the registration yourself.


As an aside, I'm not sure you can switch to use a different JMX framework but I've put the finishing touches on my Simple JMX system recently. It allows objects to name themselves programmatically when they are published.



来源:https://stackoverflow.com/questions/10029678/insert-mbean-interceptor

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!