简体   繁体   中英

Why does JBoss JMX console not show descriptions of Spring-defined MBeans?

I have a Spring bean that is exposed via JMX using Spring annotations, but the parameter names remain blank and the operation and parameter descriptions don't show up. Can this be fixed without resorting to tedious XML definition files?

I implemented this closely following a blog post . Here's my simplified code:

import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedOperationParameter;
import org.springframework.jmx.export.annotation.ManagedOperationParameters;
import org.springframework.jmx.export.annotation.ManagedResource;

@ManagedResource(objectName="group:name=foo", description="Does a lot of fooing")
public class Foo {
    @ManagedOperation(description="Changes the period of the given task and applies it immediately if the task is enabled.")
    @ManagedOperationParameters({
        @ManagedOperationParameter(name="index", description="the 0-based index of the fizzle"),
        @ManagedOperationParameter(name="baz", description="the baz value to set on the fizzle")
    })
    public void changeFizzle(int index, long baz) {
        // impl
    }
}

The relevant spring application context definition is copied verbatim from the blog post linked above.

You need to define the correct MetadataMBeanInfoAssembler like this for the MBeanExporter:

<property name="assembler">
  <bean id="assembler" class="org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler">
    <property name="attributeSource">
      <bean class="org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource" />
    </property>
  </bean>
</property>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM