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


Java RMISocketFactory类代码示例

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


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

示例1: main

import java.rmi.server.RMISocketFactory; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 4924577\n");

    RMISocketFactory.setFailureHandler(new RMIFailureHandler() {
        public boolean failure(Exception e) { return false; }
    });

    tryWith(new IOException());
    tryWith(new NullPointerException());
    tryWith(new OutOfMemoryError());
    tryWith(new NoClassDefFoundError());
    tryWith(new InternalError());
    tryWith(new Throwable());

    System.err.println("TEST PASSED");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:CloseServerSocketOnTermination.java

示例2: main

import java.rmi.server.RMISocketFactory; //导入依赖的package包/类
public static void main (String[] args) throws Exception {
    if (args.length > 0) {
        success = System.getSecurityManager() == null || args[0].equals("success");
    }

    doTest(()->{
        System.out.println("Verify URLConnection.setContentHandlerFactor()");
        URLConnection.setContentHandlerFactory(null);
    });
    doTest(()->{
        System.out.println("Verify URL.setURLStreamHandlerFactory()");
        URL.setURLStreamHandlerFactory(null);
    });
    doTest(()->{
        System.out.println("Verify ServerSocket.setSocketFactory()");
        ServerSocket.setSocketFactory(null);
    });
    doTest(()->{
        System.out.println("Verify Socket.setSocketImplFactory()");
        Socket.setSocketImplFactory(null);
    });
    doTest(()->{
        System.out.println("Verify RMISocketFactory.setSocketFactory()");
        RMISocketFactory.setSocketFactory(null);
    });
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:SetFactoryPermission.java

示例3: main

import java.rmi.server.RMISocketFactory; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    System.setProperty(RMISocketFactoryImpl.RMI_HOSTNAME_KEY, "localhost");
    RMISocketFactoryImpl impl = new RMISocketFactoryImpl();
    RMISocketFactory.setSocketFactory(impl);

    if (args.length > 0) {

    } else {
        Test.requireNameServer();
        Test.rebindTest();

        IntegerRMI remoteInt = new IntegerRMI();
        Test.rebind(TEST_INT_NAME, remoteInt);
    }

    Object o = Test.lookup(TEST_DATE_NAME);
    RemoteDate rd = (RemoteDate) o;
    System.out.println("The remote-date is: " + rd.getDate());

    o = Test.lookup(TEST_INT_NAME);
    RemoteInteger ri = (RemoteInteger) o;
    System.out.println("The remote-int  is: " + ri.getInt());

}
 
开发者ID:drankye,项目名称:haox,代码行数:25,代码来源:Test.java

示例4: getClientConnection

import java.rmi.server.RMISocketFactory; //导入依赖的package包/类
static final AbstractClientConnection getClientConnection(Endpoint ep)
        throws IOException, UnknownHostException, ConnectException,
        ConnectIOException {
    Socket sock = null;
    AbstractClientConnection ret;
    
    RMIClientSocketFactory csf = (ep.getCsf() != null) ? ep.getCsf()
            : RMISocketFactory.getSocketFactory();
    if (csf == null) {
        csf = RMISocketFactory.getDefaultSocketFactory();
    }
    sock = csf.createSocket(ep.getEndpointID().getHost(), ep.getPort());
    if (SO_TIME_OUT != 0) {
        sock.setSoTimeout(SO_TIME_OUT);
    }
    sock.setTcpNoDelay(true);
    if (sock instanceof HttpSocketClientSide) {
        ret = new SingleOpClientConnection(sock, ep);
    } else {
        ret = new StreamClientConnection(sock, ep);
    }
    return ret;
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:24,代码来源:ClientConnectionFactory.java

示例5: getSunSocketFactory

import java.rmi.server.RMISocketFactory; //导入依赖的package包/类
public static RMISocketFactory getSunSocketFactory(String type) {
    if (type.equalsIgnoreCase("default")) {
        System.out.println("No forced SocketFactory, enabled DefaultSocketFactory supporting Fallback mode");
        return new RMIDirectSocketFactory();
    } else if (type.equalsIgnoreCase("cgi")) {
        System.out.println("RMIToCGISocketFactory enabled...");
        return new RMIHttpToCGISocketFactory();    
    } else if (type.equalsIgnoreCase("http")) {
        System.out.println("RMIHttpToPortSocketFactory enabled...");
        return new RMIHttpToPortSocketFactory();
    } else if (type.equalsIgnoreCase("direct")) {
        System.out.println("RMIDirectSocketFactory enabled...");
        return new RMIDirectSocketFactory();
    }
    return new RMIDirectSocketFactory(); // if null returns default socket factory
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:17,代码来源:Util.java

示例6: rememberFactory

import java.rmi.server.RMISocketFactory; //导入依赖的package包/类
/**
 * Remember a successful factory for connecting to host.
 * Currently, excess hosts are removed from the remembered list
 * using a Least Recently Created strategy.
 */
void rememberFactory(String host, RMISocketFactory factory) {
    synchronized (successTable) {
        while (hostList.size() >= MaxRememberedHosts) {
            successTable.remove(hostList.elementAt(0));
            hostList.removeElementAt(0);
        }
        hostList.addElement(host);
        successTable.put(host, factory);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:RMIMasterSocketFactory.java

示例7: AsyncConnector

import java.rmi.server.RMISocketFactory; //导入依赖的package包/类
/**
 * Create a new asynchronous connector object.
 */
AsyncConnector(RMISocketFactory factory, String host, int port,
               AccessControlContext acc)
{
    this.factory = factory;
    this.host    = host;
    this.port    = port;
    this.acc     = acc;
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkConnect(host, port);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:RMIMasterSocketFactory.java

示例8: chooseFactory

import java.rmi.server.RMISocketFactory; //导入依赖的package包/类
private static RMISocketFactory chooseFactory() {
    RMISocketFactory sf = RMISocketFactory.getSocketFactory();
    if (sf == null) {
        sf = TCPTransport.defaultSocketFactory;
    }
    return sf;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:TCPEndpoint.java

示例9: continueAfterAcceptFailure

import java.rmi.server.RMISocketFactory; //导入依赖的package包/类
/**
 * Returns true if the accept loop should continue after the
 * specified exception has been caught, or false if the accept
 * loop should terminate (closing the server socket).  If
 * there is an RMIFailureHandler, this method returns the
 * result of passing the specified exception to it; otherwise,
 * this method always returns true, after sleeping to throttle
 * the accept loop if necessary.
 **/
private boolean continueAfterAcceptFailure(Throwable t) {
    RMIFailureHandler fh = RMISocketFactory.getFailureHandler();
    if (fh != null) {
        return fh.failure(t instanceof Exception ? (Exception) t :
                          new InvocationTargetException(t));
    } else {
        throttleLoopOnException();
        return true;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:TCPTransport.java

示例10: createServerSocket

import java.rmi.server.RMISocketFactory; //导入依赖的package包/类
public ServerSocket createServerSocket(int port) throws IOException
{
    RMISocketFactory sf = RMISocketFactory.getSocketFactory();
    if (sf == null) {
        sf = RMISocketFactory.getDefaultSocketFactory();
    }
    return sf.createServerSocket(port);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:ActivationGroupImpl.java

示例11: main

import java.rmi.server.RMISocketFactory; //导入依赖的package包/类
public static void main(String args[]) {
    UnderscoreHost t = null;
    try {
        HostVerifyingSocketFactory hvf = new HostVerifyingSocketFactory();
        RMISocketFactory.setSocketFactory(hvf);
        Registry r = TestLibrary.createRegistryOnUnusedPort();
        int port = TestLibrary.getRegistryPort(r);
        t = new UnderscoreHost();
        r.rebind(NAME, t);
        Naming.lookup("rmi://" + HOSTNAME +
                      ":" + port + "/" + NAME);
        /*
         * This test is coded to pass whether java.net.URI obeys
         * RFC 2396 or RFC 3986 (see 5085902, 6394131, etc.).
         *
         * If java.net.URI obeys RFC 3986, so host names may
         * contain underscores, then the Naming.lookup invocation
         * should succeed-- but the host actually connected to
         * must equal HOSTNAME.
         */
        if (!hvf.host.equals(HOSTNAME)) {
            throw new RuntimeException(
                "java.rmi.Naming Parsing error:" +
                hvf.host + ":" + HOSTNAME);
        }
    } catch (MalformedURLException e) {
        /*
         * If java.net.URI obeys RFC 2396, so host names must not
         * contain underscores, then the Naming.lookup invocation
         * should throw MalformedURLException-- so this is OK.
         */
    } catch (IOException ioe) {
        TestLibrary.bomb(ioe);
    } catch (java.rmi.NotBoundException nbe) {
        TestLibrary.bomb(nbe);
    } finally {
        TestLibrary.unexport(t);
    }

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:41,代码来源:UnderscoreHost.java

示例12: main

import java.rmi.server.RMISocketFactory; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 6269166\n");
    RMISocketFactory.setSocketFactory(new SF());
    Remote impl = new ReuseDefaultPort();
    Remote stub = UnicastRemoteObject.exportObject(impl, 0);
    System.err.println("- exported object: " + stub);
    try {
        Registry registry = LocateRegistry.createRegistry(PORT);
        System.err.println("- exported registry: " + registry);
        System.err.println("TEST PASSED");
    } finally {
        UnicastRemoteObject.unexportObject(impl, true);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:ReuseDefaultPort.java

示例13: main

import java.rmi.server.RMISocketFactory; //导入依赖的package包/类
public static void main(String args[]) {
    UnderscoreHost t = null;
    try {
        HostVerifyingSocketFactory hvf = new HostVerifyingSocketFactory();
        RMISocketFactory.setSocketFactory(hvf);
        Registry r = TestLibrary.createRegistryOnEphemeralPort();
        int port = TestLibrary.getRegistryPort(r);
        t = new UnderscoreHost();
        r.rebind(NAME, t);
        Naming.lookup("rmi://" + HOSTNAME +
                      ":" + port + "/" + NAME);
        /*
         * This test is coded to pass whether java.net.URI obeys
         * RFC 2396 or RFC 3986 (see 5085902, 6394131, etc.).
         *
         * If java.net.URI obeys RFC 3986, so host names may
         * contain underscores, then the Naming.lookup invocation
         * should succeed-- but the host actually connected to
         * must equal HOSTNAME.
         */
        if (!hvf.host.equals(HOSTNAME)) {
            throw new RuntimeException(
                "java.rmi.Naming Parsing error:" +
                hvf.host + ":" + HOSTNAME);
        }
    } catch (MalformedURLException e) {
        /*
         * If java.net.URI obeys RFC 2396, so host names must not
         * contain underscores, then the Naming.lookup invocation
         * should throw MalformedURLException-- so this is OK.
         */
    } catch (IOException ioe) {
        TestLibrary.bomb(ioe);
    } catch (java.rmi.NotBoundException nbe) {
        TestLibrary.bomb(nbe);
    } finally {
        TestLibrary.unexport(t);
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:UnderscoreHost.java

示例14: main

import java.rmi.server.RMISocketFactory; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 6269166\n");
    RMISocketFactory.setSocketFactory(new SF());
    Remote impl = new ReuseDefaultPort();
    Remote stub = UnicastRemoteObject.exportObject(impl, 0);
    System.err.println("- exported object: " + stub);
    try {
        Registry registry = LocateRegistry.createRegistry(rmiPort);
        System.err.println("- exported registry: " + registry);
        System.err.println("TEST PASSED");
    } finally {
        UnicastRemoteObject.unexportObject(impl, true);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:ReuseDefaultPort.java

示例15: createSocket

import java.rmi.server.RMISocketFactory; //导入依赖的package包/类
@Override
public Socket createSocket(String host, int port) throws IOException {
    Socket socket = RMISocketFactory.getDefaultSocketFactory()
            .createSocket(host, port);
    InterposeSocket s = new InterposeSocket(socket,
            triggerBytes, matchBytes, replaceBytes);
    sockets.add(s);
    return s;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:TestSocketFactory.java


注:本文中的java.rmi.server.RMISocketFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。