在春天从xml本身替换@managed操作 [英] Replacing @managed operation from xml itself in spring

查看:78
本文介绍了在春天从xml本身替换@managed操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用春季版2.5的JMX,其中我正在使用JMX 如下所示.

I am using JMX of spring Version 2.5 in which I am using JMX as shown below..

@ManagedOperation(description = "Mark the Entry corresponding ABC flow")
@ManagedOperationParameters(value = {
        @ManagedOperationParameter(name = "def", description = "Ids of the entries that needs to be STOP"),
        @ManagedOperationParameter(name = "Comments", description = "Note on why these entries are being marked as stop") })
public void abcstop(String def, String gtr){
    StringBuffer gfhtrPresent= jmxService.abcd(Ids, comments);
    if(idsNotPresent.length()>0) 
        throw new IOARuntimeException("<font color=red><b>No data found for the following id/id's </b></font>"+idsNotPresent);
}

现在,我想删除@Managedoperation声明并想在XML中进行配置,请注意如何配置@Managedoperation,因为我希望从xml本身运行相同的功能,请告知. 亲朋好友,请告知我,我们将不胜感激

Now I want to remove the @Managedoperation annaotation and want to configure it with in XML , please advsie how can I configure the @Managedoperation , as i wan the same functionality to be run from xml itself, Please advise. Folks please advise as I am stuck up any help would be appreciated

推荐答案

您可以使用XML导出MBean-请参见

You can export the MBean using XML - see the documentation. But, AFAIK, there's no way with standard components to add descriptions like that.

您将必须实现自己的MBeanInfoAssembler(或子类化标准的之一).

You would have to implement your own MBeanInfoAssembler (or subclass one of the standard ones).

例如,AbstractReflectiveMBeanInfoAssembler

For example, the AbstractReflectiveMBeanInfoAssembler gets the operation description in createModelMBeanOperationInfo by calling getOperationDescription(). By default, this just returns the method name. The MetadataMBeanInfoAssembler (used for the annotations) overrides this method to get the description from the annotation.

因此,您可以将MethodNameBasedMBeanInfoAssembler子类化并实现getOperationDescription()方法,以从所需的任何位置(可能是XML中的另一个属性)获取描述.

So, you could subclass the MethodNameBasedMBeanInfoAssembler and implement the getOperationDescription() method to get the description from wherever you want (perhaps another property in the XML).

类似地,操作参数描述是在getOperationParameters()中设置的,因此您将覆盖它们以构建它们.参见

Similarly, the operation parameter descriptions are set up in getOperationParameters() so you would override that to build them. See the MetadataMBeanInfoAssembler to see how he does it from the annotation.

这篇关于在春天从xml本身替换@managed操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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