当前位置: 首页>>代码示例>>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;未经允许,请勿转载。