當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。