Are JMX CompositeDataSupport attributes always read-only in JConsole?

After MXBeans in Java SE 6: Explaining Values โ€‹โ€‹Without Special JMX Client Configurations I managed to implement an MXBean that provides a Map<String, String> for a list of configuration parameters. It appears in JConsole, as expected, but all values โ€‹โ€‹are read-only.

The MXBEans article in this figure shows an example where it makes sense that attributes are read-only because they are memory usage values.

enter image description here

Is there a way to make attributes editable in JConsole?

+4
source share
3 answers

Try using Spring MBeanExporter.
I am not sure if this is possible with you or not.
But it is very easy. Here is a very good example.

Thanks.

0
source

To make attributes writable from JConsole, you also need to open the configuration methods in your MBean interface.

 package com.example; public interface HelloMBean { public void sayHello(); public int add(int x, int y); public String getName(); public int getCacheSize(); public void setCacheSize(int size); 

}

In this name readOnly, cacheSize is read in the same way as a record.

0
source

I donโ€™t think that you can make individual elements writable (think about it from the point of view of the remote API, the complex type is just DTO, mbean is the remote interface), but I think you can make all the compound attribute available, for example :

 public Map<String,String> getConfig() {} public void setConfig(Map<String,String> newConfig) {} 

which said, I'm not sure jconsole supports editing compound attributes, even if they are writable.

0
source

Source: https://habr.com/ru/post/1339548/


All Articles