質問

I'm trying to register mbeans by spring annotation. The beans were showing correctly in the jconsole but the attributes and methods defined in the class didn't show up. What's wrong with it?

here's one mbean for example:

@ManagedResource(objectName="com.xormedia.aqua.mbean:name=AuthenticationServer",description="AuthenticationServerSummary")
public class AuthenticationServerSummaryMbean implements MonitorMXBean {
private String ip;
private String port;

@ManagedAttribute
public String getIp() {
    return ip;
}
public void setIp(String ip) {
    this.ip = ip;
}

@ManagedOperation(description="show port number")
public String getPort() {
    return port;
}
public void setPort(String port) {
    this.port = port;
}
}

I followed the guides online, configuring the spring xml but there are only mbeans without any tree structure for the attributes and methods.

Just like this.Mbean without attributes and methods

役に立ちましたか?

解決

Try to change your approach into the following:

Add <context:mbean-export/> in your spring config.

Change your class a bit:

@ManagedResource(
        objectName = "com.xormedia.aqua.mbean:name=AuthenticationServer",
        description = "AuthenticationServerSummary",
        log = true,
        logFile = "jmx.log",
        currencyTimeLimit = 1)
public class AuthenticationServerSummaryMbean {
    private String ip;
    private String port;

    @ManagedAttribute(description = "IP Address", currencyTimeLimit = 1)
    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    @ManagedAttribute(description = "Port number", currencyTimeLimit = 1)
    public String getPort() {
        return port;
    }

    public void setPort(String port) {
        this.port = port;
    }
}

Register your mBean:

<bean id="mBeanService" class="yourpackage.AuthenticationServerSummaryMbean"/>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top