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


Java RMIConnectorServer.start方法代碼示例

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


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

示例1: main

import javax.management.remote.rmi.RMIConnectorServer; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    RMIJRMPServerImplSub impl = new RMIJRMPServerImplSub();

    System.out.println("Creating connectorServer");
    connectorServer = new RMIConnectorServer(url, null, impl, mbs);
    System.out.println("Starting connectorServer");
    connectorServer.start();
    System.out.println("Making client");
    RMIConnection cc = impl.newClient(null);
    System.out.println("Closing client");
    cc.close();
    if (connectorServer.isActive()) {
        System.out.println("Stopping connectorServer");
        connectorServer.stop();
    }
    if (failure == null)
        System.out.println("TEST PASSED, no deadlock");
    else
        System.out.println("TEST FAILED");
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:23,代碼來源:ConnectorStopDeadlockTest.java

示例2: init

import javax.management.remote.rmi.RMIConnectorServer; //導入方法依賴的package包/類
static JmxConnector init(Properties props) throws IOException {
	Integer port = Integer.decode(props.getProperty(JMXEndpoint.JMX_RMI_PORT_PROPERTY));

	if (!JmxConnectors.isPortAvailable(port))
		return null;

	String name = "com.devexperts.qd.monitoring:type=RmiServer,port=" + port;
	RMIJRMPServerImpl srvImpl = new RMIJRMPServerImpl(port, null, null, null);
	RMIConnectorServer rmiServer = new RMIConnectorServer(
		new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + port +  "/jmxrmi"),
		null, srvImpl, ManagementFactory.getPlatformMBeanServer());
	ConnectorImpl connector = new ConnectorImpl(name, rmiServer);
	if (!JmxConnectors.addConnector(port, connector))
		return null; // port is already taken

	LocateRegistry.createRegistry(port);
	connector.setRegistration(Management.registerMBean(rmiServer, null, name));
	rmiServer.start();
	QDLog.log.info("RMI management port is " + port);
	return connector;
}
 
開發者ID:Devexperts,項目名稱:QD,代碼行數:22,代碼來源:JmxRmi.java

示例3: maybeInitJmx

import javax.management.remote.rmi.RMIConnectorServer; //導入方法依賴的package包/類
private void maybeInitJmx()
{
    if (System.getProperty("com.sun.management.jmxremote.port") != null)
        return;

    String jmxPort = System.getProperty("cassandra.jmx.local.port");
    if (jmxPort == null)
        return;

    System.setProperty("java.rmi.server.hostname", InetAddress.getLoopbackAddress().getHostAddress());
    RMIServerSocketFactory serverFactory = new RMIServerSocketFactoryImpl();
    Map<String, ?> env = Collections.singletonMap(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, serverFactory);
    try
    {
        LocateRegistry.createRegistry(Integer.valueOf(jmxPort), null, serverFactory);
        JMXServiceURL url = new JMXServiceURL(String.format("service:jmx:rmi://localhost/jndi/rmi://localhost:%s/jmxrmi", jmxPort));
        jmxServer = new RMIConnectorServer(url, env, ManagementFactory.getPlatformMBeanServer());
        jmxServer.start();
    }
    catch (IOException e)
    {
        exitOrFail(1, e.getMessage(), e.getCause());
    }
}
 
開發者ID:scylladb,項目名稱:scylla-tools-java,代碼行數:25,代碼來源:CassandraDaemon.java

示例4: testRMIConnectorServer01

import javax.management.remote.rmi.RMIConnectorServer; //導入方法依賴的package包/類
public Result testRMIConnectorServer01() throws Exception {
    try {
        server = MBeanServerFactory.newMBeanServer();
        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
        RMIConnectorServer test = new RMIConnectorServer(url, null);
        ObjectName name = new ObjectName("test:type=rmi");
        server.registerMBean(test, name);
        test.start();
        test.stop();
    } catch (Exception e) {
        return failed("Unexpected exception" + e);
    }

    return result();
}
 
開發者ID:freeVM,項目名稱:freeVM,代碼行數:16,代碼來源:RMIConnectorTest.java

示例5: testRMIConnectorServer02

import javax.management.remote.rmi.RMIConnectorServer; //導入方法依賴的package包/類
public Result testRMIConnectorServer02() throws Exception {
    try {
        MBeanServer server = MBeanServerFactory.newMBeanServer();
        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
        RMIConnectorServer test = new RMIConnectorServer(url, null, null);
        ObjectName name = new ObjectName("test:type=rmi");
        server.registerMBean(test, name);
        test.start();
        test.stop();

    } catch (Exception e) {
        return failed("Unexpected exception" + e);
    }
    return result();
}
 
開發者ID:freeVM,項目名稱:freeVM,代碼行數:16,代碼來源:RMIConnectorTest.java

示例6: creatJMXConnectorAndRMIRegistry

import javax.management.remote.rmi.RMIConnectorServer; //導入方法依賴的package包/類
private static RMIConnectorServer creatJMXConnectorAndRMIRegistry(int rmiRegistryPort) throws Exception {
    MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
    LocateRegistry.createRegistry(rmiRegistryPort);
    Map<String, Object> env = new HashMap<String, Object>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory");
    env.put(Context.PROVIDER_URL, "rmi://localhost:" + rmiRegistryPort);
    JMXServiceURL serviceURL = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + rmiRegistryPort
            + "/jmxrmi");
    RMIConnectorServer rmiServer = new RMIConnectorServer(serviceURL, env, mbeanServer);
    rmiServer.start();
    return rmiServer;
}
 
開發者ID:nlalevee,項目名稱:jmx-daemon,代碼行數:13,代碼來源:JmxDaemonTest.java

示例7: maybeInitJmx

import javax.management.remote.rmi.RMIConnectorServer; //導入方法依賴的package包/類
private static void maybeInitJmx()
{
    String jmxPort = System.getProperty("com.sun.management.jmxremote.port");

    if (jmxPort == null)
    {
        logger.warn("JMX is not enabled to receive remote connections. Please see cassandra-env.sh for more info.");

        jmxPort = System.getProperty("cassandra.jmx.local.port");

        if (jmxPort == null)
        {
            logger.error("cassandra.jmx.local.port missing from cassandra-env.sh, unable to start local JMX service." + jmxPort);
        }
        else
        {
            System.setProperty("java.rmi.server.hostname", InetAddress.getLoopbackAddress().getHostAddress());

            try
            {
                RMIServerSocketFactory serverFactory = new RMIServerSocketFactoryImpl();
                LocateRegistry.createRegistry(Integer.valueOf(jmxPort), null, serverFactory);

                StringBuffer url = new StringBuffer();
                url.append("service:jmx:");
                url.append("rmi://localhost/jndi/");
                url.append("rmi://localhost:").append(jmxPort).append("/jmxrmi");
                
                Map env = new HashMap();
                env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, serverFactory);

                jmxServer = new RMIConnectorServer(
                        new JMXServiceURL(url.toString()),
                        env,
                        ManagementFactory.getPlatformMBeanServer()
                );

                jmxServer.start();
            }
            catch (IOException e)
            {
                logger.error("Error starting local jmx server: ", e);
            }
        }
    }
    else
    {
        logger.info("JMX is enabled to receive remote connections on port: " + jmxPort);
    }
}
 
開發者ID:vcostet,項目名稱:cassandra-kmean,代碼行數:51,代碼來源:CassandraDaemon.java

示例8: testSslStub

import javax.management.remote.rmi.RMIConnectorServer; //導入方法依賴的package包/類
public void testSslStub() throws Exception {
    File keyStoreFile = File.createTempFile("keystore", "ks");
    keyStoreFile.deleteOnExit();
    decodeHexToFile(keyStoreFile, keyStoreHex);
    System.setProperty("javax.net.ssl.keyStore", keyStoreFile.getAbsolutePath());
    System.setProperty("javax.net.ssl.keyStorePassword", "password");
    File trustStoreFile = File.createTempFile("truststore", "ks");
    trustStoreFile.deleteOnExit();
    decodeHexToFile(trustStoreFile, trustStoreHex);
    System.setProperty("javax.net.ssl.trustStore", trustStoreFile.getAbsolutePath());
    System.setProperty("javax.net.ssl.trustStorePassword", "trustword");
    // System.setProperty("javax.net.debug", "all");

    RMIClientSocketFactory csf = new SslRMIClientSocketFactory();
    RMIServerSocketFactory ssf = new SslRMIServerSocketFactory();
    
    Registry reg = LocateRegistry.createRegistry(0, csf, ssf);
    int port = getRegistryPort(reg);
    System.out.println("Port is " + port);
    
    // Server
    Map<String, Object> env = new HashMap<String, Object>();
    env.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, csf);
    env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, ssf);
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///");
    RMIServerImpl rmiServerImpl = new RMIJRMPServerImpl(port, csf, ssf, null);
    RMIConnectorServer cs =
            new RMIConnectorServer(url, null, rmiServerImpl, mbs);
    cs.start();
    reg.bind("jmxrmi", rmiServerImpl);

    // Client
    Registry creg = LocateRegistry.getRegistry(
            InetAddress.getLocalHost().getHostAddress(), port, csf);
    RMIServer rmiServerStub = (RMIServer) creg.lookup("jmxrmi");
    assertEquals(RMIServerImpl_Stub.class, rmiServerStub.getClass());
    SObject sstub = (SObject) SerialScan.examine(rmiServerStub);
    List<SEntity> annots = sstub.getAnnotations();
    /* The annotations consist of the data written for a UnicastRef2
     * before the client socket factory; the client socket factory;
     * and the data written after the factory.
     */
    assertEquals(3, annots.size());
    SObject factory = (SObject) annots.get(1);
    assertEquals(SslRMIClientSocketFactory.class.getName(), factory.getType());
}
 
開發者ID:frohoff,項目名稱:serialysis,代碼行數:48,代碼來源:JmxSslTest.java


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