用于管理动态属性集的 JMX MBean
这个问题听起来可能与许多已解决的问题类似,但我还没有射击这个目标。
我即将创建一个 MBean,它允许我指定动态的键值对集。
(创建一个解决方案来指定预定义的参数集很容易。但是动态参数集又如何呢)
我能找到的最相关的代码片段是使用 CompositeData
、TabularData
The api is next:
applyNewProperties(Properties props)
UI接下来是:
mbean 方法 applyNewProperties
参数: props
name1 value1
name2 value2
name3 value3
.....
namen value n
目的是 jmx-connsole 将以表格形式显示它:
input name 1 input value 1
input name 2 input value 2
input name 3 input value 3
....
input name n input value n
The problem might sound similar to many resolved ones, but I did not shoot this target yet.
I am about to create a MBean that will allow me to specify dynamic set of key-value pairs.
(It is easy to create a solution to specify pre-defined set of params. But what about dynamic ones)
The most relevant code snippets i could find was usage of CompositeData
, TabularData
The api is next:
applyNewProperties(Properties props)
UI is next:
mbean method applyNewProperties
Parameters: props
name1 value1
name2 value2
name3 value3
.....
namen value n
The purpose is that jmx-connsole would show it in table form:
input name 1 input value 1
input name 2 input value 2
input name 3 input value 3
....
input name n input value n
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最简单的方法可能是创建一个 MXBean (这是从 Java 6 开始可用),它允许您返回地图等对象(或完全自定义的对象),然后将这些对象映射到 CompositeData 或 TabularData 实例等开放类型。
The easiest approach would probably be to create an MXBean (which is available since Java 6) which allows you to return objects like maps (or completely custom objects) which are then mapped into Open Types like CompositeData or TabularData instances.
Java 7 为我们带来了 DynamicMBean - https://docs.oracle .com/javase/7/docs/api/javax/management/DynamicMBean.html
我相信这就是您想要的。
Java 7 brought us DynamicMBean - https://docs.oracle.com/javase/7/docs/api/javax/management/DynamicMBean.html
I believe that's what you want.