当前位置: 首页>>代码示例>>Java>>正文


Java RMIServerImpl类代码示例

本文整理汇总了Java中javax.management.remote.rmi.RMIServerImpl的典型用法代码示例。如果您正苦于以下问题:Java RMIServerImpl类的具体用法?Java RMIServerImpl怎么用?Java RMIServerImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RMIServerImpl类属于javax.management.remote.rmi包,在下文中一共展示了RMIServerImpl类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSslStub

import javax.management.remote.rmi.RMIServerImpl; //导入依赖的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.RMIServerImpl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。