Java 类javax.management.remote.rmi.RMIJRMPServerImpl 实例源码

项目:QD    文件:JmxRmi.java   
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;
}
项目:jdk8u-jdk    文件:ImplVersionCommand.java   
public static void main(String[] args) throws Exception {

        // Create RMIJRMPServerImpl
        //
        System.out.println("Create RMIJRMPServerImpl");
        RMIServer server = new RMIJRMPServerImpl(0, null, null, null);

        // Get the JMX Remote impl version from RMIServer
        //
        System.out.println("Get JMX Remote implementation version from RMIServer");
        String full_version = server.getVersion();
        System.out.println("RMIServer.getVersion() = "+ full_version);
        String impl_version = full_version.substring(
            full_version.indexOf("java_runtime_")+"java_runtime_".length());

        // Display JMX Remote impl version and Java Runtime version
        //
        System.out.println("JMX Remote implementation version   = " +
                           impl_version);
        System.out.println("Java Runtime implementation version = " +
                           args[0]);

        // Check JMX Remote impl version vs. Java Runtime  version
        //
        if (!impl_version.equals(args[0])) {
            // Test FAILED
            throw new IllegalArgumentException(
                "***FAILED: JMX Remote and Java Runtime versions do NOT match***");
        }
        // Test OK!
        System.out.println("JMX Remote and Java Runtime versions match.");
        System.out.println("Bye! Bye!");
    }
项目:openjdk-jdk10    文件:ImplVersionCommand.java   
public static void main(String[] args) throws Exception {

        // Create RMIJRMPServerImpl
        //
        System.out.println("Create RMIJRMPServerImpl");
        RMIServer server = new RMIJRMPServerImpl(0, null, null, null);

        // Get the JMX Remote impl version from RMIServer
        //
        System.out.println("Get JMX Remote implementation version from RMIServer");
        String full_version = server.getVersion();
        System.out.println("RMIServer.getVersion() = "+ full_version);
        String impl_version = full_version.substring(
            full_version.indexOf("java_runtime_")+"java_runtime_".length());

        // Display JMX Remote impl version and Java Runtime version
        //
        System.out.println("JMX Remote implementation version   = " +
                           impl_version);
        System.out.println("Java Runtime implementation version = " +
                           args[0]);

        // Check JMX Remote impl version vs. Java Runtime  version
        //
        if (!impl_version.equals(args[0])) {
            // Test FAILED
            throw new IllegalArgumentException(
                "***FAILED: JMX Remote and Java Runtime versions do NOT match***");
        }
        // Test OK!
        System.out.println("JMX Remote and Java Runtime versions match.");
        System.out.println("Bye! Bye!");
    }
项目:openjdk9    文件:ImplVersionCommand.java   
public static void main(String[] args) throws Exception {

        // Create RMIJRMPServerImpl
        //
        System.out.println("Create RMIJRMPServerImpl");
        RMIServer server = new RMIJRMPServerImpl(0, null, null, null);

        // Get the JMX Remote impl version from RMIServer
        //
        System.out.println("Get JMX Remote implementation version from RMIServer");
        String full_version = server.getVersion();
        System.out.println("RMIServer.getVersion() = "+ full_version);
        String impl_version = full_version.substring(
            full_version.indexOf("java_runtime_")+"java_runtime_".length());

        // Display JMX Remote impl version and Java Runtime version
        //
        System.out.println("JMX Remote implementation version   = " +
                           impl_version);
        System.out.println("Java Runtime implementation version = " +
                           args[0]);

        // Check JMX Remote impl version vs. Java Runtime  version
        //
        if (!impl_version.equals(args[0])) {
            // Test FAILED
            throw new IllegalArgumentException(
                "***FAILED: JMX Remote and Java Runtime versions do NOT match***");
        }
        // Test OK!
        System.out.println("JMX Remote and Java Runtime versions match.");
        System.out.println("Bye! Bye!");
    }
项目:jdk8u_jdk    文件:ImplVersionCommand.java   
public static void main(String[] args) throws Exception {

        // Create RMIJRMPServerImpl
        //
        System.out.println("Create RMIJRMPServerImpl");
        RMIServer server = new RMIJRMPServerImpl(0, null, null, null);

        // Get the JMX Remote impl version from RMIServer
        //
        System.out.println("Get JMX Remote implementation version from RMIServer");
        String full_version = server.getVersion();
        System.out.println("RMIServer.getVersion() = "+ full_version);
        String impl_version = full_version.substring(
            full_version.indexOf("java_runtime_")+"java_runtime_".length());

        // Display JMX Remote impl version and Java Runtime version
        //
        System.out.println("JMX Remote implementation version   = " +
                           impl_version);
        System.out.println("Java Runtime implementation version = " +
                           args[0]);

        // Check JMX Remote impl version vs. Java Runtime  version
        //
        if (!impl_version.equals(args[0])) {
            // Test FAILED
            throw new IllegalArgumentException(
                "***FAILED: JMX Remote and Java Runtime versions do NOT match***");
        }
        // Test OK!
        System.out.println("JMX Remote and Java Runtime versions match.");
        System.out.println("Bye! Bye!");
    }
项目:lookaside_java-1.8.0-openjdk    文件:ImplVersionCommand.java   
public static void main(String[] args) throws Exception {

        // Create RMIJRMPServerImpl
        //
        System.out.println("Create RMIJRMPServerImpl");
        RMIServer server = new RMIJRMPServerImpl(0, null, null, null);

        // Get the JMX Remote impl version from RMIServer
        //
        System.out.println("Get JMX Remote implementation version from RMIServer");
        String full_version = server.getVersion();
        System.out.println("RMIServer.getVersion() = "+ full_version);
        String impl_version = full_version.substring(
            full_version.indexOf("java_runtime_")+"java_runtime_".length());

        // Display JMX Remote impl version and Java Runtime version
        //
        System.out.println("JMX Remote implementation version   = " +
                           impl_version);
        System.out.println("Java Runtime implementation version = " +
                           args[0]);

        // Check JMX Remote impl version vs. Java Runtime  version
        //
        if (!impl_version.equals(args[0])) {
            // Test FAILED
            throw new IllegalArgumentException(
                "***FAILED: JMX Remote and Java Runtime versions do NOT match***");
        }
        // Test OK!
        System.out.println("JMX Remote and Java Runtime versions match.");
        System.out.println("Bye! Bye!");
    }
项目:infobip-open-jdk-8    文件:ImplVersionCommand.java   
public static void main(String[] args) throws Exception {

        // Create RMIJRMPServerImpl
        //
        System.out.println("Create RMIJRMPServerImpl");
        RMIServer server = new RMIJRMPServerImpl(0, null, null, null);

        // Get the JMX Remote impl version from RMIServer
        //
        System.out.println("Get JMX Remote implementation version from RMIServer");
        String full_version = server.getVersion();
        System.out.println("RMIServer.getVersion() = "+ full_version);
        String impl_version = full_version.substring(
            full_version.indexOf("java_runtime_")+"java_runtime_".length());

        // Display JMX Remote impl version and Java Runtime version
        //
        System.out.println("JMX Remote implementation version   = " +
                           impl_version);
        System.out.println("Java Runtime implementation version = " +
                           args[0]);

        // Check JMX Remote impl version vs. Java Runtime  version
        //
        if (!impl_version.equals(args[0])) {
            // Test FAILED
            throw new IllegalArgumentException(
                "***FAILED: JMX Remote and Java Runtime versions do NOT match***");
        }
        // Test OK!
        System.out.println("JMX Remote and Java Runtime versions match.");
        System.out.println("Bye! Bye!");
    }
项目:jdk8u-dev-jdk    文件:ImplVersionCommand.java   
public static void main(String[] args) throws Exception {

        // Create RMIJRMPServerImpl
        //
        System.out.println("Create RMIJRMPServerImpl");
        RMIServer server = new RMIJRMPServerImpl(0, null, null, null);

        // Get the JMX Remote impl version from RMIServer
        //
        System.out.println("Get JMX Remote implementation version from RMIServer");
        String full_version = server.getVersion();
        System.out.println("RMIServer.getVersion() = "+ full_version);
        String impl_version = full_version.substring(
            full_version.indexOf("java_runtime_")+"java_runtime_".length());

        // Display JMX Remote impl version and Java Runtime version
        //
        System.out.println("JMX Remote implementation version   = " +
                           impl_version);
        System.out.println("Java Runtime implementation version = " +
                           args[0]);

        // Check JMX Remote impl version vs. Java Runtime  version
        //
        if (!impl_version.equals(args[0])) {
            // Test FAILED
            throw new IllegalArgumentException(
                "***FAILED: JMX Remote and Java Runtime versions do NOT match***");
        }
        // Test OK!
        System.out.println("JMX Remote and Java Runtime versions match.");
        System.out.println("Bye! Bye!");
    }
项目:jdk7-jdk    文件:ImplVersionCommand.java   
public static void main(String[] args) throws Exception {

        // Create RMIJRMPServerImpl
        //
        System.out.println("Create RMIJRMPServerImpl");
        RMIServer server = new RMIJRMPServerImpl(0, null, null, null);

        // Get the JMX Remote impl version from RMIServer
        //
        System.out.println("Get JMX Remote implementation version from RMIServer");
        String full_version = server.getVersion();
        System.out.println("RMIServer.getVersion() = "+ full_version);
        String impl_version = full_version.substring(
            full_version.indexOf("java_runtime_")+"java_runtime_".length());

        // Display JMX Remote impl version and Java Runtime version
        //
        System.out.println("JMX Remote implementation version   = " +
                           impl_version);
        System.out.println("Java Runtime implementation version = " +
                           args[0]);

        // Check JMX Remote impl version vs. Java Runtime  version
        //
        if (!impl_version.equals(args[0])) {
            // Test FAILED
            throw new IllegalArgumentException(
                "***FAILED: JMX Remote and Java Runtime versions do NOT match***");
        }
        // Test OK!
        System.out.println("JMX Remote and Java Runtime versions match.");
        System.out.println("Bye! Bye!");
    }
项目:openjdk-source-code-learn    文件:ImplVersionCommand.java   
public static void main(String[] args) throws Exception {

        // Create RMIJRMPServerImpl
        //
        System.out.println("Create RMIJRMPServerImpl");
        RMIServer server = new RMIJRMPServerImpl(0, null, null, null);

        // Get the JMX Remote impl version from RMIServer
        //
        System.out.println("Get JMX Remote implementation version from RMIServer");
        String full_version = server.getVersion();
        System.out.println("RMIServer.getVersion() = "+ full_version);
        String impl_version = full_version.substring(
            full_version.indexOf("java_runtime_")+"java_runtime_".length());

        // Display JMX Remote impl version and Java Runtime version
        //
        System.out.println("JMX Remote implementation version   = " +
                           impl_version);
        System.out.println("Java Runtime implementation version = " +
                           args[0]);

        // Check JMX Remote impl version vs. Java Runtime  version
        //
        if (!impl_version.equals(args[0])) {
            // Test FAILED
            throw new IllegalArgumentException(
                "***FAILED: JMX Remote and Java Runtime versions do NOT match***");
        }
        // Test OK!
        System.out.println("JMX Remote and Java Runtime versions match.");
        System.out.println("Bye! Bye!");
    }
项目:OLD-OpenJDK8    文件:ImplVersionCommand.java   
public static void main(String[] args) throws Exception {

        // Create RMIJRMPServerImpl
        //
        System.out.println("Create RMIJRMPServerImpl");
        RMIServer server = new RMIJRMPServerImpl(0, null, null, null);

        // Get the JMX Remote impl version from RMIServer
        //
        System.out.println("Get JMX Remote implementation version from RMIServer");
        String full_version = server.getVersion();
        System.out.println("RMIServer.getVersion() = "+ full_version);
        String impl_version = full_version.substring(
            full_version.indexOf("java_runtime_")+"java_runtime_".length());

        // Display JMX Remote impl version and Java Runtime version
        //
        System.out.println("JMX Remote implementation version   = " +
                           impl_version);
        System.out.println("Java Runtime implementation version = " +
                           args[0]);

        // Check JMX Remote impl version vs. Java Runtime  version
        //
        if (!impl_version.equals(args[0])) {
            // Test FAILED
            throw new IllegalArgumentException(
                "***FAILED: JMX Remote and Java Runtime versions do NOT match***");
        }
        // Test OK!
        System.out.println("JMX Remote and Java Runtime versions match.");
        System.out.println("Bye! Bye!");
    }
项目:JAVA_UNIT    文件:ImplVersionCommand.java   
public static void main(String[] args) throws Exception {

        // Create RMIJRMPServerImpl
        //
        System.out.println("Create RMIJRMPServerImpl");
        RMIServer server = new RMIJRMPServerImpl(0, null, null, null);

        // Get the JMX Remote impl version from RMIServer
        //
        System.out.println("Get JMX Remote implementation version from RMIServer");
        String full_version = server.getVersion();
        System.out.println("RMIServer.getVersion() = "+ full_version);
        String impl_version = full_version.substring(
            full_version.indexOf("java_runtime_")+"java_runtime_".length());

        // Display JMX Remote impl version and Java Runtime version
        //
        System.out.println("JMX Remote implementation version   = " +
                           impl_version);
        System.out.println("Java Runtime implementation version = " +
                           args[0]);

        // Check JMX Remote impl version vs. Java Runtime  version
        //
        if (!impl_version.equals(args[0])) {
            // Test FAILED
            throw new IllegalArgumentException(
                "***FAILED: JMX Remote and Java Runtime versions do NOT match***");
        }
        // Test OK!
        System.out.println("JMX Remote and Java Runtime versions match.");
        System.out.println("Bye! Bye!");
    }
项目:openjdk-jdk7u-jdk    文件:ImplVersionCommand.java   
public static void main(String[] args) throws Exception {

        // Create RMIJRMPServerImpl
        //
        System.out.println("Create RMIJRMPServerImpl");
        RMIServer server = new RMIJRMPServerImpl(0, null, null, null);

        // Get the JMX Remote impl version from RMIServer
        //
        System.out.println("Get JMX Remote implementation version from RMIServer");
        String full_version = server.getVersion();
        System.out.println("RMIServer.getVersion() = "+ full_version);
        String impl_version = full_version.substring(
            full_version.indexOf("java_runtime_")+"java_runtime_".length());

        // Display JMX Remote impl version and Java Runtime version
        //
        System.out.println("JMX Remote implementation version   = " +
                           impl_version);
        System.out.println("Java Runtime implementation version = " +
                           args[0]);

        // Check JMX Remote impl version vs. Java Runtime  version
        //
        if (!impl_version.equals(args[0])) {
            // Test FAILED
            throw new IllegalArgumentException(
                "***FAILED: JMX Remote and Java Runtime versions do NOT match***");
        }
        // Test OK!
        System.out.println("JMX Remote and Java Runtime versions match.");
        System.out.println("Bye! Bye!");
    }
项目:openjdk-icedtea7    文件:ImplVersionCommand.java   
public static void main(String[] args) throws Exception {

        // Create RMIJRMPServerImpl
        //
        System.out.println("Create RMIJRMPServerImpl");
        RMIServer server = new RMIJRMPServerImpl(0, null, null, null);

        // Get the JMX Remote impl version from RMIServer
        //
        System.out.println("Get JMX Remote implementation version from RMIServer");
        String full_version = server.getVersion();
        System.out.println("RMIServer.getVersion() = "+ full_version);
        String impl_version = full_version.substring(
            full_version.indexOf("java_runtime_")+"java_runtime_".length());

        // Display JMX Remote impl version and Java Runtime version
        //
        System.out.println("JMX Remote implementation version   = " +
                           impl_version);
        System.out.println("Java Runtime implementation version = " +
                           args[0]);

        // Check JMX Remote impl version vs. Java Runtime  version
        //
        if (!impl_version.equals(args[0])) {
            // Test FAILED
            throw new IllegalArgumentException(
                "***FAILED: JMX Remote and Java Runtime versions do NOT match***");
        }
        // Test OK!
        System.out.println("JMX Remote and Java Runtime versions match.");
        System.out.println("Bye! Bye!");
    }
项目:serialysis    文件:JmxSslTest.java   
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());
}