1 29 30 package com.caucho.jmx.remote; 31 32 import com.caucho.hessian.client.HessianProxyFactory; 33 import com.caucho.hessian.jmx.JMXSerializerFactory; 34 35 import javax.management.MBeanInfo ; 36 import javax.management.ObjectName ; 37 38 41 public class MBeanClient { 42 private String _url; 43 private RemoteJMX _jmxProxy; 44 45 48 public MBeanClient() 49 { 50 } 51 52 55 public MBeanClient(String url) 56 { 57 _url = url; 58 } 59 60 63 public void setProxy(RemoteJMX proxy) 64 { 65 _jmxProxy = proxy; 66 } 67 68 71 public MBeanInfo getMBeanInfo(ObjectName objectName) 72 throws Exception 73 { 74 return getProxy().getMBeanInfo(objectName.getCanonicalName()); 75 } 76 77 80 public Object getAttribute(ObjectName objectName, String attrName) 81 throws Exception 82 { 83 return getProxy().getAttribute(objectName.getCanonicalName(), attrName); 84 } 85 86 private RemoteJMX getProxy() 87 { 88 if (_jmxProxy == null) { 89 try { 90 HessianProxyFactory proxy = new HessianProxyFactory(); 91 proxy.getSerializerFactory().addFactory(new JMXSerializerFactory()); 92 _jmxProxy = (RemoteJMX) proxy.create(_url); 93 } catch (Exception e) { 94 throw new RuntimeException (e); 95 } 96 } 97 98 return _jmxProxy; 99 } 100 } 101 | Popular Tags |