简体   繁体   中英

How to modify an attribute which have a no-primitive data type with JMX?

I would like to know if it's possible to modify java.awt.Color attribute through the jConsole. I have a class like this :

public class MyColor implements MyColorMBean {
    private Color background;

    public Color getBackground() {
        return background;
    }

    public void setBackground(Color background) {
        this.background = background;
    }
}

which implements this MBean :

public interface MyColorMBean {
    public Color getBackground();
    public void setBackground(Color background);
}

and when I try to set another value for background (like Color.GREEN for example), it doesn't work... but when I set the type of background to String, it works!

Is it possible to change a no-primitive data type with JMX?

Thanks :)

This is a limitation in console. If you used a programmatic interface, it would work. I would add Color and String type methods to the Mean (with different names).

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