很早就开始去了解这个了,不过一直都是皮毛,基本概念明白,具体api几乎一无不知。。。
认真看了几篇文章,做了测试,终于有所了解
参考 入门级别: http://www.cnblogs.com/agou/articles/286871.html http://www.cnblogs.com/allenny/articles/179208.html
写得最好的:http://www.cnblogs.com/yaohonv/archive/2012/02/08/jmx.html, 图也很清楚,不过初入门的时候看起来比较吃力, 其中对jmx-rmi有所涉及,不错,可惜实验不通。没地方下载jmxremoting.jar
这个相当不错:http://www.cnblogs.com/zjstar12/archive/2012/06/10/2544387.html
http://www.cnblogs.com/xzh31390080/articles/2231213.html 很精辟简练,不过只能是最后才可以看,初学者看了也白看。。 像我之前那样怎么看都没用。
个人理解:
关于mbean:
standard MBean,这种类型的MBean最简单: 一个接口,一个实现类即可,不需要任何其他类依赖,但是命名必须遵循一定的规范,例如我们的MBean为Hello,则接口必须为HelloMBean。
假如某个属性只有get方法,则说明这个属性是只读的,get/set都有的话,说明这个属性是可读可写的
DynamicMBean 可以动态拓展需要管控的资源,即允许bean里面的属性、方法可变,因此需要实现额外的方法:
(http://www.cnblogs.com/zjstar12/archive/2012/06/10/2544387.html)
package javax.management; public interface DynamicMBean{ public Object getAttribute( String attribute )throws AttributeNotFoundException, MBeanException,ReflectionException;
public void setAttribute( Attribute attribute )throws AttributeNotFoundException,InvalidAttributeValueException,MBeanException,ReflectionException;
public AttributeList getAttributes( String[] attributes );
public AttributeList setAttributes( AttributeList attributes );
public Object invoke( String actionName, Object[] params,String[] signature ) throws MBeanException,ReflectionExceptionn
public MBeanInfo getMBeanInfo(); }
openMBean及其他一些未规范的就不说了
关于jmx客户端都jmx服务端的访问:
1 通过浏览器,jmx client程序启用http协议,这个时候需要一个HTMLAdapter
2 jconsole。 不能访问? 看看: http://www.cnblogs.com/orientsun/archive/2012/07/25/2608525.html
3 程序访问?
a 通过JMXConnector
http://www.cnblogs.com/yaohonv/archive/2012/02/08/jmx.html
b 通过http协议,HTMLAdapter?
一些重要的接口:
ManagementFactory 专门生产MBeanServer
MBeanServer 一般就是MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
这个很重要,主要就是通过它来管理mbean的,主要方法有:registerMBean,unRegisterMBean,addNotificationListenerremoveNotificationListener
createMBean/queryMBean
get/setAttributes
instantiate 不知道干什么的。。。
JMXServiceURL 创建ConnectorServer需要用到,
RMIConnectorServer -> ConnectorServer
JMXConnector
待续。。
原文:http://www.cnblogs.com/FlyAway2013/p/jmx.html