java.rmi.server.RMISocketFactory Java Examples
The following examples show how to use
java.rmi.server.RMISocketFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CloseServerSocketOnTermination.java From hottub with GNU General Public License v2.0 | 6 votes |
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"); }
Example #2
Source File: SetFactoryPermission.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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); }); }
Example #3
Source File: CloseServerSocketOnTermination.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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"); }
Example #4
Source File: SetFactoryPermission.java From hottub with GNU General Public License v2.0 | 6 votes |
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); }); }
Example #5
Source File: CloseServerSocketOnTermination.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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"); }
Example #6
Source File: CloseServerSocketOnTermination.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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"); }
Example #7
Source File: CloseServerSocketOnTermination.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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"); }
Example #8
Source File: CloseServerSocketOnTermination.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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"); }
Example #9
Source File: CloseServerSocketOnTermination.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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"); }
Example #10
Source File: SetFactoryPermission.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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); }); }
Example #11
Source File: SetFactoryPermission.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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); }); }
Example #12
Source File: CloseServerSocketOnTermination.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
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"); }
Example #13
Source File: TCPTransport.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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; } }
Example #14
Source File: ReuseDefaultPort.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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); } }
Example #15
Source File: TestSocketFactory.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public ServerSocket createServerSocket(int port) throws IOException { ServerSocket serverSocket = RMISocketFactory.getDefaultSocketFactory() .createServerSocket(port); InterposeServerSocket ss = new InterposeServerSocket(serverSocket, triggerBytes, matchBytes, replaceBytes); serverSockets.add(ss); return ss; }
Example #16
Source File: RMIMasterSocketFactory.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example #17
Source File: UnderscoreHost.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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); } }
Example #18
Source File: TCPEndpoint.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static RMISocketFactory chooseFactory() { RMISocketFactory sf = RMISocketFactory.getSocketFactory(); if (sf == null) { sf = TCPTransport.defaultSocketFactory; } return sf; }
Example #19
Source File: RMIMasterSocketFactory.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example #20
Source File: RMIMasterSocketFactory.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example #21
Source File: ReuseDefaultPort.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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); } }
Example #22
Source File: ActivationGroupImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public ServerSocket createServerSocket(int port) throws IOException { RMISocketFactory sf = RMISocketFactory.getSocketFactory(); if (sf == null) { sf = RMISocketFactory.getDefaultSocketFactory(); } return sf.createServerSocket(port); }
Example #23
Source File: ReuseDefaultPort.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
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); } }
Example #24
Source File: TCPEndpointReadBug.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public Socket createSocket(String host, int port) throws IOException { final RMIClientSocketFactory defaultFactory = RMISocketFactory.getDefaultSocketFactory(); return defaultFactory.createSocket(host, port); }
Example #25
Source File: TCPEndpointReadBug.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public I echo(I intf) { try { return (I)UnicastRemoteObject .exportObject(new C(),0, new CSF(), RMISocketFactory.getDefaultSocketFactory()); } catch (RemoteException e) { e.printStackTrace(); } return null; }
Example #26
Source File: UnderscoreHost.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
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); } }
Example #27
Source File: UnderscoreHost.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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); } }
Example #28
Source File: ActivationGroupImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public ServerSocket createServerSocket(int port) throws IOException { RMISocketFactory sf = RMISocketFactory.getSocketFactory(); if (sf == null) { sf = RMISocketFactory.getDefaultSocketFactory(); } return sf.createServerSocket(port); }
Example #29
Source File: TCPTransport.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * 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; } }
Example #30
Source File: RMIMasterSocketFactory.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * 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); } }