之前开发中用到JMX的地方,如果需要根据ObjectName中某个特定值进行判断,都是把ObjectName执行toString()后,再截取字符串,今天发现原来ObjectName中有个方法
/**
* Obtains the value associated with a key in a key property.
*
* @param property The property whose value is to be obtained.
*
* @return The value of the property, or null if there is no such
* property in this ObjectName.
*
* @exception NullPointerException If <code>property</code> is null.
*/
public String getKeyProperty(String property) throws NullPointerException {
return _getKeyPropertyList().get(property);
}
该方法只要把相应的key传进来就可以获取值,而不用再在整个String中查找。
比如
ObjectName oname = new ObjectName("com.abc:name=threadpool.thread-pool-1,type=thread-pool,category=monitor,server=server");
要获取name的值,只需要oname.getKeyProperty("name");即可把后面的一串拿到。
分享到:
相关推荐
这里,`beans`属性定义了要导出的MBeans,`key`是MBean的ObjectName,`value-ref`引用了对应的bean。 现在,当应用启动时,`myManagedBean`会被注册到MBeanServer,可以通过JMX客户端进行访问。由于配置了HTTP协议...
它的格式类似于`domain:type=key,value`,其中`domain`是顶级域名,`type`是类型名,而`key`和`value`则是键值对形式的参数。 4. **连接器**:JMX提供了多种连接器(Connector),使得外部应用程序可以通过不同的...
jmxcli 简单的轻量级jmx命令行实用程序。 用法 jmxcli {commands} {options} commands: lo List available ... <attribute> [-key key] Get attribute value options: -s <server> JMX server -user <username>
<property name="configLocation" value="classpath:ehcache.xml"/> ``` 4. **使用缓存注解** - 使用`@Cacheable`注解在方法上,当方法被调用时,Spring会检查缓存中是否存在该结果,如果存在则直接返回,否则...
`source`和`object`字段分别记录事件来源和相关对象,`value`根据`source`的不同具有不同含义。 11. **actions**表:定义了触发器触发时应执行的操作,如发送通知、执行脚本等。 每个表都有其独特的功能,它们通过...