插入MBean拦截器 [英] Insert MBean interceptor

查看:135
本文介绍了插入MBean拦截器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个实现MBean的java项目中工作,我需要拦截MBean并在注册表之前更改/添加它们的属性。示例:

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

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

I找到此链接,其中介绍了如何申请拦截器,然后默认拦截器,但我不知道如何在代码中。

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.

提前谢谢。

推荐答案

一旦你注册了bean,显然已经太晚了。最简单的方法是更改​​注册的完成方式。如果你向我们展示你用来注册bean的框架,那么我将能够提供更多帮助。

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);

因此,您可以提供不同的 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.

顺便说一句,我不确定你是否可以切换到使用不同的JMX框架,但我已经对我的简单的JMX系统最近。它允许对象以编程方式命名自己什么时候出版。

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.

这篇关于插入MBean拦截器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆