Announcement Announcement Module
No announcement yet.
JMX @ManagedOperation behaviour Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • JMX @ManagedOperation behaviour

    Maybe it's my fault, but I don't understand how.
    I exported to JMX some classes with some methods that I marked with @ManagedOperation(description="bla..."), and parameters are marked with @ManagedOperationParameters({@ManagedOperationPara meter(name="parm", description="desc...")}).
    What's funny, is that when I get into JConsole, all operations have the correct description for all parameters, but some of them have no description on the operation name, but the method name itself, instead of the one I put.
    Further more I see also exported operations even if no @ManagedOperation nor @ManagedAttribute annotations have been put on the corresponding methods.
    This strange behaviour is happens in all exported beans, but I didn't find any apparent rule.

    This is my exporter:
    <bean id="exporter" class="org.springframework.jmx.export.MBeanExporte r" lazy-init="false">
    <property name="beans">
    ..... beans ...
    <property name="assembler">
    <bean class="org.springframework.jmx.export.assembler.Me tadataMBeanInfoAssembler">
    <property name="attributeSource" ref="jmxAttributeSource"/>
    <property name="registrationBehaviorName" value="REGISTRATION_REPLACE_EXISTING"/>

  • #2
    I solved my problem creating my own class MetadataMBeanInfoAssembler extending original one: org.springframework.jmx.export.assembler. MetadataMBeanInfoAssembler.
    I overrode getOperationDescription method checking ManagedOperation first, instead of checking whether a PropertyDescriptor was not found as the original method does. This way:

    protected String getOperationDescription(Method method, String beanKey) {
    ManagedOperation mo = this.attributeSource.getManagedOperation(method);
    if (mo != null && StringUtils.hasText(mo.getDescription())) {
    return mo.getDescription();
    PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
    if (pd != null) {
    ManagedAttribute ma = this.attributeSource.getManagedAttribute(method);
    if (ma != null && StringUtils.hasText(ma.getDescription())) {
    return ma.getDescription();
    ManagedMetric metric = this.attributeSource.getManagedMetric(method);
    if (metric != null && StringUtils.hasText(metric.getDescription())) {
    return metric.getDescription();
    return method.getName();
    } else {
    return method.getName();