List of usage examples for javax.management JMX newMBeanProxy
public static <T> T newMBeanProxy(MBeanServerConnection connection, ObjectName objectName, Class<T> interfaceClass)
Make a proxy for a Standard MBean in a local or remote MBean Server.
If you have an MBean Server mbs containing an MBean with ObjectName name , and if the MBean's management interface is described by the Java interface MyMBean , you can construct a proxy for the MBean like this:
MyMBean proxy = JMX.newMBeanProxy(mbs, name, MyMBean.class);
Suppose, for example, MyMBean looks like this:
public interface MyMBean { public String getSomeAttribute(); public void setSomeAttribute(String value); public void someOperation(String param1, int param2); }
Then you can execute:
From source file:org.opendaylight.infrautils.diagstatus.MBeanUtils.java
private static <T> T getMBean(String jmxName, Class<T> klass, MBeanServerConnection mbsc) throws MalformedObjectNameException { ObjectName objectName = new ObjectName(jmxName); if (JMX.isMXBeanInterface(klass)) { return JMX.newMXBeanProxy(mbsc, objectName, klass); } else {// w w w .jav a 2s . c o m return JMX.newMBeanProxy(mbsc, objectName, klass); } }
From source file:org.wso2.carbon.cassandra.cluster.ClusterDataAccessMBeanImplementation.java
/** * A helper method to access a Cassndra MBean * * @param name name of the MBean/*ww w. j a v a 2 s .c om*/ * @param mBeanClass MBean Class * @param <T> types of the MBean * @return MBean instance with given Type * @throws ClusterMBeanDataAccessException * for error during locating the given MBean */ private <T> T locateMBean(ObjectName name, Class<T> mBeanClass) { return JMX.newMBeanProxy(mBeanServerConnection, name, mBeanClass); }
From source file:org.wso2.carbon.cassandra.mgt.CassandraMBeanLocator.java
/** * A helper method to access a MBean/*from w w w. j a v a2s.c o m*/ * * @param name name of the MBean * @param mBeanClass MBean Class * @param <T> types of the MBean * @return MBean instance with given Type * @throws CassandraServerManagementException * for error during locating the given MBean */ private <T> T locateMBean(String name, Class<T> mBeanClass) throws CassandraServerManagementException { try { return JMX.newMBeanProxy(mBeanServerConnection, new ObjectName(name), mBeanClass); } catch (MalformedObjectNameException e) { String msg = "Invalid ObjectName? Please report this as a bug"; log.error(msg); throw new CassandraServerManagementException(msg, e); } }