Java SE 6新特性: JMX 与系统管理
http://tech.ddvip.com 2007年08月11日 社区交流
内容摘要:介绍了 Java 管理扩展(Java Management Extension,JMX) 架构及其框架,以及在 Java SE 5 中新引入的 JMX API -- java.lang.management 包, 最后作者讲述了此 API 在 Java SE 6 中的相关改进和对未来版本的展望
给整个 serverMBeanInfo 设了一个策略描述 serverDescription,其中用 "currencyTimeLimit=10" 指出属性的缓存时间是 10 秒。所以,在 Main 方法中,两次 serverMBean.getAttribute("upTime");之间的间隔小于 10 秒就会得到同样的缓存值。
如果我们不想让 "upTime" 这个属性被缓存,我们可以在它的策略描述中加入 "currencyTimeLimit=-1":
Descriptor upTime = new DescriptorSupport(
new String[] {
"name=upTime",
"descriptorType=attribute",
"displayName=Server upTime",
"getMethod=getUpTime",
"currencyTimeLimit=-1" //不需要缓存
});
Descriptor getUpTimeDesc =
new DescriptorSupport(
new String[] {
"name=getUpTime",
"descriptorType=operation",
"class=modelmbean.Server",
"role=operation"
,"currencyTimeLimit=-1" //不需要缓存
});getUpTimeDesc 也要改动的原因是 RequiredModelBean 会把获取 upTime 属性的工作 delegate 给 getUpTime invocation。只要其中一处使用 MBean 级的缓存策略,就没法获得实时 upTime 数据了。
虚拟机检测
来源:IBM 作者:吕晶 李夷磊 责编:豆豆技术应用
正在加载评论...