0

我正在使用 Spring 2.5 版的 JMX,其中我正在使用 JMX,如下所示。

@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 本身运行相同的功能,请告知。人们请告知,因为我被困住了,任何帮助将不胜感激

4

1 回答 1

1

您可以使用 XML 导出 MBean - 请参阅文档。但是,AFAIK,标准组件无法添加这样的描述。

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

编辑:

例如,通过调用createModelMBeanOperationInfoAbstractReflectiveMBeanInfoAssembler获取操作描述。默认情况下,这只是返回方法名称。(用于注释)覆盖此方法以从注释中获取描述。getOperationDescription()MetadataMBeanInfoAssembler

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

类似地,操作参数描述是在其中设置的,getOperationParameters()因此您可以覆盖它来构建它们。请参阅MetadataMBeanInfoAssembler以了解他如何从注释中执行此操作。

于 2014-01-17T13:56:21.130 回答