JMX CompositeDataSupport 属性在 JConsole 中始终是只读的吗?

发布于 2024-10-16 23:35:10 字数 423 浏览 7 评论 0原文

遵循 Java SE 6 中的 MXBean:在没有特殊 JMX 客户端配置的情况下捆绑值 I设法实现一个 MXBean,它公开一个 Map 以获取配置参数列表。它按预期出现在 JConsole 中,但所有值都是只读的。

在 MXBEans 文章中,此插图显示了一个示例,其中属性是只读的,因为它们是内存使用值,因此有意义。

在此处输入图像描述

有没有办法使属性在 JConsole 中可编辑?

Following MXBeans in Java SE 6: Bundling Values Without Special JMX Client Configurations I managed to implement a MXBean which exposes a Map<String, String> for a list of configuration parameters. It appears in JConsole as expected, but all values are readonly.

In the MXBEans article, this illustration shows an example where it makes sense that the attributes are read-only as they are memory usage values.

enter image description here

Is there a way to make the attributes editable in JConsole?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

○愚か者の日 2024-10-23 23:35:10

尝试使用 Spring MBeanExporter。
我不确定这对你来说是否可行。
但这很容易。 这里是一个很好的例子。

谢谢。

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

Thanks.

拥醉 2024-10-23 23:35:10

要使属性可从 JConsole 写入,您还需要在 MBean 接口中公开 setter 方法。

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); 

在此名称中为只读

,cacheSize 既可读取也可写入。

To make attributes writable from JConsole, you need to expose the setter methods also 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 is readOnly, cacheSize is read as well as write enabled.

ゝ杯具 2024-10-23 23:35:10

我不认为你可以使单个元素可写(从远程API的角度考虑,复合类型只是一个DTO,mbean是远程接口),但我确实认为你可以使整个复合属性可写,例如:

public Map<String,String> getConfig() {}

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

也就是说,我不确定 jconsole 是否支持编辑复合属性,即使它们是可写的。

I don't think you can make the individual elements writable (think about it from a remote API perspective, the compound type is simply a DTO, the mbean is the remote interface), but i do think you can make the whole compound attribute writable, e.g.:

public Map<String,String> getConfig() {}

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文