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


Java JMXConnectorServer.start方法代碼示例

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


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

示例1: dotest

import javax.management.remote.JMXConnectorServer; //導入方法依賴的package包/類
private static void dotest(JMXServiceURL url, MBeanServer mbs)
    throws Exception {
    JMXConnectorServer server = null;
    JMXConnector client = null;

    server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    server.start();
    JMXServiceURL outputAddr = server.getAddress();
    System.out.println("Server started ["+ outputAddr+ "]");

    client = JMXConnectorFactory.newJMXConnector(outputAddr, null);

    client.connect();
    System.out.println("Client connected");

    MBeanServerConnection connection
        = client.getMBeanServerConnection();

    System.out.println(connection.getDefaultDomain());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:ProviderTest.java

示例2: main

import javax.management.remote.JMXConnectorServer; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    Sender sender = new Sender();
    mbs.registerMBean(sender, testObjectName);
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    JMXConnectorServer cs =
        JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    cs.start();
    JMXServiceURL addr = cs.getAddress();
    JMXConnector cc = JMXConnectorFactory.connect(addr);
    try {
        test(mbs, cs, cc);
    } finally {
        cc.close();
        cs.stop();
    }
}
 
開發者ID:ojdkbuild,項目名稱:lookaside_java-1.8.0-openjdk,代碼行數:18,代碼來源:ListenerScaleTest.java

示例3: testTestValidConnection

import javax.management.remote.JMXConnectorServer; //導入方法依賴的package包/類
@Test
public void testTestValidConnection() throws Exception {
	Assume.group(TestGroup.JMXMP);
	JMXConnectorServer connectorServer = getConnectorServer();
	connectorServer.start();

	try {
		MBeanServerConnectionFactoryBean bean = new MBeanServerConnectionFactoryBean();
		bean.setServiceUrl(serviceUrl);
		bean.afterPropertiesSet();

		try {
			MBeanServerConnection connection = bean.getObject();
			assertNotNull("Connection should not be null", connection);

			// perform simple MBean count test
			assertEquals("MBean count should be the same", getServer().getMBeanCount(), connection.getMBeanCount());
		} finally {
			bean.destroy();
		}
	} finally {
		connectorServer.stop();
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:25,代碼來源:MBeanServerConnectionFactoryBeanTests.java

示例4: testTestWithLazyConnection

import javax.management.remote.JMXConnectorServer; //導入方法依賴的package包/類
@Test
public void testTestWithLazyConnection() throws Exception {
	Assume.group(TestGroup.JMXMP);
	MBeanServerConnectionFactoryBean bean = new MBeanServerConnectionFactoryBean();
	bean.setServiceUrl(serviceUrl);
	bean.setConnectOnStartup(false);
	bean.afterPropertiesSet();

	MBeanServerConnection connection = bean.getObject();
	assertTrue(AopUtils.isAopProxy(connection));

	JMXConnectorServer connector = null;
	try {
		connector = getConnectorServer();
		connector.start();
		assertEquals("Incorrect MBean count", getServer().getMBeanCount(), connection.getMBeanCount());
	} finally {
		bean.destroy();
		if (connector != null) {
			connector.stop();
		}
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:24,代碼來源:MBeanServerConnectionFactoryBeanTests.java

示例5: main

import javax.management.remote.JMXConnectorServer; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception
{
   // The MBeanServer
   MBeanServer server = MBeanServerFactory.createMBeanServer();

   // Pass null as the host name to tell JMXServiceURL to default to InetAddress.getLocalHost().getHostName()
   JMXServiceURL url = new JMXServiceURL("hessian+ssl", null, 8443, "/hessianssl");

   // Replace the value of the configuration with the file path of the configuration file
   Map serverEnv = new HashMap();
   serverEnv.put(HTTPConnectorServer.WEB_CONTAINER_CONFIGURATION, "<your-web-container-configuration>");
   JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, serverEnv, server);
   connectorServer.start();

   System.out.println("Server up and running " + connectorServer + " on " + url);
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:17,代碼來源:Server.java

示例6: startRMIConnector

import javax.management.remote.JMXConnectorServer; //導入方法依賴的package包/類
public void startRMIConnector(int jmxPort)
{
  try
  {
    LogUtil.getCoreLog().info("RMI port:"+jmxPort);
    ServerConfigHelper.setProperty("JMX_RMI_PORT", ""+jmxPort);
    MBeanServer mbs= ManagementFactory.getPlatformMBeanServer();
    ObjectName namingName = ObjectName.getInstance("naming:type=rmiregistry");
    mbs.registerMBean(new NamingService(jmxPort), namingName);
    mbs.invoke(namingName, "start", null, null);
    String jndiPath = "/jmxconnector";
    String bindIp = ServerConfigHelper.getProperty(ITEMS.BINDIP.name());
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://"+bindIp+":" + jmxPort + jndiPath);
    JMXConnectorServer connector = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    
    ObjectName connectorName = null;
    connectorName = new ObjectName("Gemlite:name=RMIConnector");
    mbs.registerMBean(connector, connectorName);
    connector.start();
  }
  catch (Exception e)
  {
    LogUtil.getCoreLog().error("Error start rmi connector",e);
  }
}
 
開發者ID:iisi-nj,項目名稱:GemFireLite,代碼行數:26,代碼來源:GemliteAgent.java

示例7: main

import javax.management.remote.JMXConnectorServer; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    JMXServiceURL inputAddr =
        new JMXServiceURL("service:jmx:iiop://");
    JMXConnectorServer s =
        JMXConnectorServerFactory.newJMXConnectorServer(inputAddr, null,
                                                        null);
    MBeanServer mbs = MBeanServerFactory.createMBeanServer();
    mbs.registerMBean(s, new ObjectName("a:b=c"));
    s.start();
    JMXServiceURL outputAddr = s.getAddress();
    if (!outputAddr.getURLPath().startsWith("/ior/IOR:")) {
        System.out.println("URL path should start with \"/ior/IOR:\": " +
                           outputAddr);
        System.exit(1);
    }
    System.out.println("IIOP URL path looks OK: " + outputAddr);
    JMXConnector c = JMXConnectorFactory.connect(outputAddr);
    System.out.println("Successfully got default domain: " +
                       c.getMBeanServerConnection().getDefaultDomain());
    c.close();
    s.stop();
}
 
開發者ID:vicmarcal,項目名稱:JAVA_UNIT,代碼行數:23,代碼來源:IIOPURLTest.java

示例8: call

import javax.management.remote.JMXConnectorServer; //導入方法依賴的package包/類
public MBeanServerConnection call() {
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    try {
        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
        JMXConnectorServer cs =
            JMXConnectorServerFactory.newJMXConnectorServer(
                url, null, mbs);
        cs.start();
        JMXServiceURL addr = cs.getAddress();
        connector = JMXConnectorFactory.connect(addr);
        return connector.getMBeanServerConnection();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:16,代碼來源:OldMBeanServerTest.java

示例9: start

import javax.management.remote.JMXConnectorServer; //導入方法依賴的package包/類
public static String start() throws Exception {
    int serverPort = 12345;
    ObjectName name = new ObjectName("test", "foo", "bar");
    MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
    SteMBean bean = new Ste();
    jmxServer.registerMBean(bean, name);
    boolean exported = false;
    Random rnd = new Random(System.currentTimeMillis());
    do {
        try {
            LocateRegistry.createRegistry(serverPort);
            exported = true;
        } catch (ExportException ee) {
            if (ee.getCause() instanceof BindException) {
                serverPort = rnd.nextInt(10000) + 4096;
            } else {
                throw ee;
            }
        }

    } while (!exported);
    JMXServiceURL serverUrl = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + serverPort + "/test");
    JMXConnectorServer jmxConnector = JMXConnectorServerFactory.newJMXConnectorServer(serverUrl, null, jmxServer);
    jmxConnector.start();

    return serverUrl.toString();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:28,代碼來源:Server.java

示例10: testWithException

import javax.management.remote.JMXConnectorServer; //導入方法依賴的package包/類
private static void testWithException(boolean send)
throws Exception {
    ClassLoader zoobyCL = new ZoobyClassLoader();
    Class<?> zoobyClass = Class.forName("Zooby", false, zoobyCL);
    Object zooby = zoobyClass.newInstance();

    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///");
    JMXConnectorServer cs =
            JMXConnectorServerFactory.newJMXConnectorServer(url, null, pmbs);
    cs.start();
    JMXServiceURL addr = cs.getAddress();
    JMXConnector cc = JMXConnectorFactory.connect(addr);
    MBeanServerConnection mbsc = cc.getMBeanServerConnection();

    Object rzooby;
    if (send) {
        System.out.println("Sending object...");
        mbsc.setAttribute(getSetName, new Attribute("It", zooby));
        rzooby = getSetInstance.getIt();
    } else {
        System.out.println("Receiving object...");
        getSetInstance.setIt(zooby);
        rzooby = mbsc.getAttribute(getSetName, "It");
    }

    if (!rzooby.getClass().getName().equals("Zooby")) {
        throw new Exception("FAILED: remote object is not a Zooby");
    }
    if (rzooby.getClass().getClassLoader() ==
            zooby.getClass().getClassLoader()) {
        throw new Exception("FAILED: same class loader: " +
                zooby.getClass().getClassLoader());
    }

    cc.close();
    cs.stop();
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:38,代碼來源:RMIDownloadTest.java

示例11: main

import javax.management.remote.JMXConnectorServer; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    JMXServiceURL inputAddr =
        new JMXServiceURL("service:jmx:iiop://");
    JMXConnectorServer s;
    try {
        s = JMXConnectorServerFactory.newJMXConnectorServer(inputAddr, null, null);
    } catch (java.net.MalformedURLException x) {
        try {
            Class.forName("javax.management.remote.rmi._RMIConnectionImpl_Tie");
            throw new RuntimeException("MalformedURLException thrown but iiop appears to be supported");
        } catch (ClassNotFoundException expected) { }
        System.out.println("IIOP protocol not supported, test skipped");
        return;
    }
    MBeanServer mbs = MBeanServerFactory.createMBeanServer();
    mbs.registerMBean(s, new ObjectName("a:b=c"));
    s.start();
    JMXServiceURL outputAddr = s.getAddress();
    if (!outputAddr.getURLPath().startsWith("/ior/IOR:")) {
        throw new RuntimeException("URL path should start with \"/ior/IOR:\": " +
                                   outputAddr);
    }
    System.out.println("IIOP URL path looks OK: " + outputAddr);
    JMXConnector c = JMXConnectorFactory.connect(outputAddr);
    System.out.println("Successfully got default domain: " +
                       c.getMBeanServerConnection().getDefaultDomain());
    c.close();
    s.stop();
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:30,代碼來源:IIOPURLTest.java

示例12: jmxConnectorServerFactoryTests

import javax.management.remote.JMXConnectorServer; //導入方法依賴的package包/類
private int jmxConnectorServerFactoryTests() {
    int errorCount = 0;
    echo("");
    echo(dashedMessage("Run JMXConnectorServerFactory Tests"));
    for (int i = 0; i < maps.length - 1; i++) {
        echo("\n>>> JMXConnectorServerFactory Test [" + i + "]");
        try {
            echo("\tMap = " + maps[i]);
            echo("\tCreate the MBean server");
            MBeanServer mbs = MBeanServerFactory.createMBeanServer();
            echo("\tCreate the RMI connector server");
            JMXServiceURL url =
                new JMXServiceURL("service:jmx:rmi:///jndi/rmi://:" +
                                  port + "/JMXConnectorServerFactory" + i);
            JMXConnectorServer jmxcs =
                JMXConnectorServerFactory.newJMXConnectorServer(url,
                                                                maps[i],
                                                                mbs);
            echo("\tStart the RMI connector server");
            jmxcs.start();
            echo("\tCall RMIConnectorServer.toJMXConnector(Map)");
            jmxcs.toJMXConnector(maps[i]);
            echo("\tStop the RMI connector server");
            jmxcs.stop();
            echo("\tTest [" + i + "] PASSED!");
        } catch (Exception e) {
            errorCount++;
            echo("\tTest [" + i + "] FAILED!");
            e.printStackTrace(System.out);
        }
    }
    if (errorCount == 0) {
        echo("");
        echo(dashedMessage("JMXConnectorServerFactory Tests PASSED!"));
    } else {
        echo("");
        echo(dashedMessage("JMXConnectorServerFactory Tests FAILED!"));
    }
    return errorCount;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:41,代碼來源:MapNullValuesTest.java

示例13: main

import javax.management.remote.JMXConnectorServer; //導入方法依賴的package包/類
public static void main(String[] args) throws MalformedObjectNameException,
            NotCompliantMBeanException, InstanceAlreadyExistsException,
            MBeanRegistrationException, IOException {
        // 下麵這種方式不能再JConsole中使用
//      MBeanServer server = MBeanServerFactory.createMBeanServer();
// 首先建立一個MBeanServer,MBeanServer用來管理我們的MBean,通常是通過MBeanServer來獲取我們MBean的信息,間接
// 調用MBean的方法,然後生產我們的資源的一個對象。
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

        String domainName = "MyMBean";

//為MBean(下麵的new Hello())創建ObjectName實例
        ObjectName helloName = new ObjectName(domainName+":name=HelloWorld");
// 將new Hello()這個對象注冊到MBeanServer上去
        mbs.registerMBean(new Hello(),helloName);

// Distributed Layer, 提供了一個HtmlAdaptor。支持Http訪問協議,並且有一個不錯的HTML界麵,這裏的Hello就是用這個作為遠端管理的界麵
// 事實上HtmlAdaptor是一個簡單的HttpServer,它將Http請求轉換為JMX Agent的請求
        ObjectName adapterName = new ObjectName(domainName+":name=htmladapter,port=8082");
        HtmlAdaptorServer adapter = new HtmlAdaptorServer();
        adapter.start();
        mbs.registerMBean(adapter,adapterName);

        int rmiPort = 1099;
        Registry registry = LocateRegistry.createRegistry(rmiPort);

        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:"+rmiPort+"/"+domainName);
        JMXConnectorServer jmxConnector = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
        jmxConnector.start();
    }
 
開發者ID:breakEval13,項目名稱:rocketmq-flink-plugin,代碼行數:31,代碼來源:HelloAgent.java

示例14: createJmxConnectorServer

import javax.management.remote.JMXConnectorServer; //導入方法依賴的package包/類
private JMXConnectorServer  createJmxConnectorServer(int portNr) throws IOException {
	LocateRegistry.createRegistry(portNr);
	MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
	JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://localhost/jndi/rmi://localhost:"+portNr+"/jmxrmi");
	JMXConnectorServer svr = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
	svr.start();
	
	return svr;
}
 
開發者ID:denkbar,項目名稱:djigger,代碼行數:10,代碼來源:BasicJMXJVM.java

示例15: main

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

   // The address of the connector server
   JMXServiceURL url = new JMXServiceURL("rmi", "localhost", 0, "/jndi/jmx");

   // Specify the authenticator in the environment Map, using the
   // standard property JMXConnector.AUTHENTICATOR
   Map environment = new HashMap();
   JMXAuthenticator authenticator = new PasswordAuthenticator(new File(PASSWORD_FILE));
   environment.put(JMXConnectorServer.AUTHENTICATOR, authenticator);

   // Create and register the connector server
   JMXConnectorServer cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, environment, null);
   ObjectName cntorServerName = ObjectName.getInstance(":service=" + JMXConnectorServer.class.getName() + ",protocol=" + url.getProtocol());
   MBeanServer server = MBeanServerFactory.createMBeanServer("remote.security.example");
   server.registerMBean(cntorServer, cntorServerName);

   // Setup the rmiregistry to bind in JNDI the RMIConnectorServer stub.
   NamingService naming = new NamingService();
   ObjectName namingName = ObjectName.getInstance(":service=" + NamingService.class.getName());
   server.registerMBean(naming, namingName);
   naming.start();

   // Start the connector server
   cntorServer.start();

   System.out.println("Server up and running");
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:31,代碼來源:Server.java


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