我在其中实现的MBean Java项目工作,我需要的是拦截MBean并更改/注册表前添加它们的属性。 例如:
则domainName:名称= myMBean - >则domainName:名称= myMBean1,类型=的myType
我发现这个链接呈现如何应用拦截其他则默认拦截器,但我不知道如何在代码中做到这一点。
提前致谢。
我在其中实现的MBean Java项目工作,我需要的是拦截MBean并更改/注册表前添加它们的属性。 例如:
则domainName:名称= myMBean - >则domainName:名称= myMBean1,类型=的myType
我发现这个链接呈现如何应用拦截其他则默认拦截器,但我不知道如何在代码中做到这一点。
提前致谢。
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.