Replacing @managed operation from xml itself in spring

巧了我就是萌 提交于 2019-12-13 04:38:54

问题


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

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


回答1:


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

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

EDIT:

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.

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

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.



来源:https://stackoverflow.com/questions/21179066/replacing-managed-operation-from-xml-itself-in-spring

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