List of usage examples for javax.management MBeanServerInvocationHandler newProxyInstance
public static <T> T newProxyInstance(MBeanServerConnection connection, ObjectName objectName, Class<T> interfaceClass, boolean notificationBroadcaster)
Return a proxy that implements the given interface by forwarding its methods through the given MBean server to the named MBean.
From source file:org.wso2.carbon.integration.test.metrics.CarbonMetricsTestCase.java
/** * This method will force metric manager to collect metrics by invoking report() method * using remote jmx//from www .ja v a 2 s . co m * @throws IOException * @throws MalformedObjectNameException */ private void invokeJMXReportOperation() throws IOException, MalformedObjectNameException, XPathExpressionException { int JMXServicePort = Integer.parseInt(cepServer.getInstance().getPorts().get("jmxserver")); int RMIRegistryPort = Integer.parseInt(cepServer.getInstance().getPorts().get("rmiregistry")); JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://localhost:" + JMXServicePort + "/jndi/rmi://localhost:" + RMIRegistryPort + "/jmxrmi"); Map<String, String[]> env = new HashMap<>(); String[] credentials = { "admin", "admin" }; env.put(JMXConnector.CREDENTIALS, credentials); JMXConnector jmxConnector = JMXConnectorFactory.connect(url, env); MBeanServerConnection mbeanServerConnection = jmxConnector.getMBeanServerConnection(); ObjectName mbeanName = new ObjectName("org.wso2.carbon:type=MetricManager"); MetricManagerMXBean mbeanProxy = MBeanServerInvocationHandler.newProxyInstance(mbeanServerConnection, mbeanName, MetricManagerMXBean.class, true); mbeanProxy.report(); jmxConnector.close(); }