當前位置: 首頁>>代碼示例>>Java>>正文


Java MBeanServerConnection.getDefaultDomain方法代碼示例

本文整理匯總了Java中javax.management.MBeanServerConnection.getDefaultDomain方法的典型用法代碼示例。如果您正苦於以下問題:Java MBeanServerConnection.getDefaultDomain方法的具體用法?Java MBeanServerConnection.getDefaultDomain怎麽用?Java MBeanServerConnection.getDefaultDomain使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.management.MBeanServerConnection的用法示例。


在下文中一共展示了MBeanServerConnection.getDefaultDomain方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: test_simple

import javax.management.MBeanServerConnection; //導入方法依賴的package包/類
@Test
public void test_simple() {
    MBeanServer mBeanServer = exporter.getServer();

    try {
        ObjectName objectName = new ObjectName("bean:name=otterControllor");
        MBeanInfo nodeInfo = mBeanServer.getMBeanInfo(objectName);
        System.out.println(nodeInfo);
        Object result = mBeanServer.getAttribute(objectName, "HeapMemoryUsage");
        System.out.println(result);

        JMXServiceURL address = new JMXServiceURL("service:jmx:rmi://127.0.0.1/jndi/rmi://127.0.0.1:1099/mbean");
        Map environment = null;

        JMXConnector cntor = JMXConnectorFactory.connect(address, environment);
        MBeanServerConnection mbsc = cntor.getMBeanServerConnection();
        String domain = mbsc.getDefaultDomain();
        System.out.println(domain);

        result = mbsc.getAttribute(objectName, "HeapMemoryUsage");
        System.out.println(result);
    } catch (Exception e) {
        want.fail(e.getMessage());
    }
}
 
開發者ID:luoyaogui,項目名稱:otter-G,代碼行數:26,代碼來源:JmxLoaderIntegration.java

示例2: testStart

import javax.management.MBeanServerConnection; //導入方法依賴的package包/類
@Test
public void testStart() throws Exception {
  JMXConnector connector = JMXConnectorFactory.connect(
    JMXListener.buildJMXServiceURL(connectorPort,connectorPort));

  MBeanServerConnection mb = connector.getMBeanServerConnection();
  String domain = mb.getDefaultDomain();
  Assert.assertTrue("default domain is not correct",
    !domain.isEmpty());
  connector.close();

}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:13,代碼來源:TestJMXListener.java

示例3: main

import javax.management.MBeanServerConnection; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {

        String host = args[0];
        String port = args[1];
        String user = args[2];
        String pass = args[3];
        int pollSleep = 300;

        HashMap<String, Object> env = new HashMap<String, Object>();
        String[] creds = new String[2];
        creds[0] = user;
        creds[1] = pass;
        env.put(JMXConnector.CREDENTIALS, creds);

        String urlString = System.getProperty("jmx.service.url","service:jmx:remoting-jmx://" + host + ":" + port);
        System.err.println("URL : " + urlString);
        JMXServiceURL serviceURL = new JMXServiceURL(urlString);
        JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, env);
        try {
            MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();

            JMXGarbageCollectorNotification gcLogging = new JMXGarbageCollectorNotification(connection);

            do {
                while (gcLogging.hasNext(pollSleep, TimeUnit.SECONDS)) {
                    Notification notification = gcLogging.next();
                    processNotification(connection, notification);
                }
                System.out.printf("<timestamp>%s</timestamp>\n", DATE_FORMAT.format(Calendar.getInstance().getTime()));

                // make a call using the connection to check it is still active, otherwise we never notice.
                connection.getDefaultDomain();
            } while (true);

        }
        catch (Exception e) {
            e.printStackTrace();
        }
        finally {
            jmxConnector.close();
        }

    }
 
開發者ID:breakEval13,項目名稱:rocketmq-flink-plugin,代碼行數:44,代碼來源:JMXGarbageCollectorNotificationClient.java


注:本文中的javax.management.MBeanServerConnection.getDefaultDomain方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。