Java Code Examples for java.rmi.server.RemoteObject#toStub()
The following examples show how to use
java.rmi.server.RemoteObject#toStub() .
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: MarshalAfterUnexport2.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 4513223\n"); Remote impl2 = null; try { Remote impl = new MarshalAfterUnexport2(); System.err.println( "created impl extending URO (with a UnicastServerRef2): " + impl); Receiver stub = (Receiver) RemoteObject.toStub(impl); System.err.println("stub for impl: " + stub); UnicastRemoteObject.unexportObject(impl, true); System.err.println("unexported impl"); impl2 = new MarshalAfterUnexport2(); Receiver stub2 = (Receiver) RemoteObject.toStub(impl2); System.err.println("marshalling unexported object:"); MarshalledObject mobj = new MarshalledObject(impl); System.err.println("passing unexported object via RMI-JRMP:"); stub2.receive(stub); System.err.println("TEST PASSED"); } finally { if (impl2 != null) { try { UnicastRemoteObject.unexportObject(impl2, true); } catch (Throwable t) { } } } }
Example 2
Source File: MarshalAfterUnexport.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { Remote impl2 = null; try { Remote impl = new MarshalAfterUnexport(); System.err.println("created impl extending URO: " + impl); Receiver stub = (Receiver) RemoteObject.toStub(impl); System.err.println("stub for impl: " + stub); UnicastRemoteObject.unexportObject(impl, true); System.err.println("unexported impl"); impl2 = new MarshalAfterUnexport(); Receiver stub2 = (Receiver) RemoteObject.toStub(impl2); System.err.println("marshalling unexported object:"); MarshalledObject mobj = new MarshalledObject(impl); System.err.println("passing unexported object via RMI-JRMP:"); stub2.receive(stub); System.err.println("TEST PASSED"); } finally { if (impl2 != null) { try { UnicastRemoteObject.unexportObject(impl2, true); } catch (Throwable t) { } } } }
Example 3
Source File: MarshalAfterUnexport.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { Remote impl2 = null; try { Remote impl = new MarshalAfterUnexport(); System.err.println("created impl extending URO: " + impl); Receiver stub = (Receiver) RemoteObject.toStub(impl); System.err.println("stub for impl: " + stub); UnicastRemoteObject.unexportObject(impl, true); System.err.println("unexported impl"); impl2 = new MarshalAfterUnexport(); Receiver stub2 = (Receiver) RemoteObject.toStub(impl2); System.err.println("marshalling unexported object:"); MarshalledObject mobj = new MarshalledObject(impl); System.err.println("passing unexported object via RMI-JRMP:"); stub2.receive(stub); System.err.println("TEST PASSED"); } finally { if (impl2 != null) { try { UnicastRemoteObject.unexportObject(impl2, true); } catch (Throwable t) { } } } }
Example 4
Source File: MarshalAfterUnexport2.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { System.err.println("\nRegression test for bug 4513223\n"); Remote impl2 = null; try { Remote impl = new MarshalAfterUnexport2(); System.err.println( "created impl extending URO (with a UnicastServerRef2): " + impl); Receiver stub = (Receiver) RemoteObject.toStub(impl); System.err.println("stub for impl: " + stub); UnicastRemoteObject.unexportObject(impl, true); System.err.println("unexported impl"); impl2 = new MarshalAfterUnexport2(); Receiver stub2 = (Receiver) RemoteObject.toStub(impl2); System.err.println("marshalling unexported object:"); MarshalledObject mobj = new MarshalledObject(impl); System.err.println("passing unexported object via RMI-JRMP:"); stub2.receive(stub); System.err.println("TEST PASSED"); } finally { if (impl2 != null) { try { UnicastRemoteObject.unexportObject(impl2, true); } catch (Throwable t) { } } } }
Example 5
Source File: ChangeHostName.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { InetAddress localAddress = InetAddress.getLocalHost(); String[] hostlist = new String[] { localAddress.getHostAddress(), localAddress.getHostName() }; for (int i = 0; i < hostlist.length; i++) { System.setProperty("java.rmi.server.hostname", hostlist[i]); Remote impl = new ChangeHostName(); System.err.println("\ncreated impl extending URO: " + impl); Receiver stub = (Receiver) RemoteObject.toStub(impl); System.err.println("stub for impl: " + stub); System.err.println("invoking method on stub"); stub.receive(stub); UnicastRemoteObject.unexportObject(impl, true); System.err.println("unexported impl"); if (stub.toString().indexOf(hostlist[i]) >= 0) { System.err.println("stub's ref contains hostname: " + hostlist[i]); } else { throw new RuntimeException( "TEST FAILED: stub's ref doesn't contain hostname: " + hostlist[i]); } } System.err.println("TEST PASSED"); }
Example 6
Source File: MarshalAfterUnexport.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { Remote impl2 = null; try { Remote impl = new MarshalAfterUnexport(); System.err.println("created impl extending URO: " + impl); Receiver stub = (Receiver) RemoteObject.toStub(impl); System.err.println("stub for impl: " + stub); UnicastRemoteObject.unexportObject(impl, true); System.err.println("unexported impl"); impl2 = new MarshalAfterUnexport(); Receiver stub2 = (Receiver) RemoteObject.toStub(impl2); System.err.println("marshalling unexported object:"); MarshalledObject mobj = new MarshalledObject(impl); System.err.println("passing unexported object via RMI-JRMP:"); stub2.receive(stub); System.err.println("TEST PASSED"); } finally { if (impl2 != null) { try { UnicastRemoteObject.unexportObject(impl2, true); } catch (Throwable t) { } } } }
Example 7
Source File: MarshalAfterUnexport2.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 4513223\n"); Remote impl2 = null; try { Remote impl = new MarshalAfterUnexport2(); System.err.println( "created impl extending URO (with a UnicastServerRef2): " + impl); Receiver stub = (Receiver) RemoteObject.toStub(impl); System.err.println("stub for impl: " + stub); UnicastRemoteObject.unexportObject(impl, true); System.err.println("unexported impl"); impl2 = new MarshalAfterUnexport2(); Receiver stub2 = (Receiver) RemoteObject.toStub(impl2); System.err.println("marshalling unexported object:"); MarshalledObject mobj = new MarshalledObject(impl); System.err.println("passing unexported object via RMI-JRMP:"); stub2.receive(stub); System.err.println("TEST PASSED"); } finally { if (impl2 != null) { try { UnicastRemoteObject.unexportObject(impl2, true); } catch (Throwable t) { } } } }
Example 8
Source File: MarshalAfterUnexport2.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 4513223\n"); Remote impl2 = null; try { Remote impl = new MarshalAfterUnexport2(); System.err.println( "created impl extending URO (with a UnicastServerRef2): " + impl); Receiver stub = (Receiver) RemoteObject.toStub(impl); System.err.println("stub for impl: " + stub); UnicastRemoteObject.unexportObject(impl, true); System.err.println("unexported impl"); impl2 = new MarshalAfterUnexport2(); Receiver stub2 = (Receiver) RemoteObject.toStub(impl2); System.err.println("marshalling unexported object:"); MarshalledObject mobj = new MarshalledObject(impl); System.err.println("passing unexported object via RMI-JRMP:"); stub2.receive(stub); System.err.println("TEST PASSED"); } finally { if (impl2 != null) { try { UnicastRemoteObject.unexportObject(impl2, true); } catch (Throwable t) { } } } }
Example 9
Source File: MarshalAfterUnexport.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { Remote impl2 = null; try { Remote impl = new MarshalAfterUnexport(); System.err.println("created impl extending URO: " + impl); Receiver stub = (Receiver) RemoteObject.toStub(impl); System.err.println("stub for impl: " + stub); UnicastRemoteObject.unexportObject(impl, true); System.err.println("unexported impl"); impl2 = new MarshalAfterUnexport(); Receiver stub2 = (Receiver) RemoteObject.toStub(impl2); System.err.println("marshalling unexported object:"); MarshalledObject mobj = new MarshalledObject(impl); System.err.println("passing unexported object via RMI-JRMP:"); stub2.receive(stub); System.err.println("TEST PASSED"); } finally { if (impl2 != null) { try { UnicastRemoteObject.unexportObject(impl2, true); } catch (Throwable t) { } } } }
Example 10
Source File: ChangeHostName.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { InetAddress localAddress = InetAddress.getLocalHost(); String[] hostlist = new String[] { localAddress.getHostAddress(), localAddress.getHostName() }; for (int i = 0; i < hostlist.length; i++) { System.setProperty("java.rmi.server.hostname", hostlist[i]); Remote impl = new ChangeHostName(); System.err.println("\ncreated impl extending URO: " + impl); Receiver stub = (Receiver) RemoteObject.toStub(impl); System.err.println("stub for impl: " + stub); System.err.println("invoking method on stub"); stub.receive(stub); UnicastRemoteObject.unexportObject(impl, true); System.err.println("unexported impl"); if (stub.toString().indexOf(hostlist[i]) >= 0) { System.err.println("stub's ref contains hostname: " + hostlist[i]); } else { throw new RuntimeException( "TEST FAILED: stub's ref doesn't contain hostname: " + hostlist[i]); } } System.err.println("TEST PASSED"); }
Example 11
Source File: MarshalAfterUnexport2.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { System.err.println("\nRegression test for bug 4513223\n"); Remote impl2 = null; try { Remote impl = new MarshalAfterUnexport2(); System.err.println( "created impl extending URO (with a UnicastServerRef2): " + impl); Receiver stub = (Receiver) RemoteObject.toStub(impl); System.err.println("stub for impl: " + stub); UnicastRemoteObject.unexportObject(impl, true); System.err.println("unexported impl"); impl2 = new MarshalAfterUnexport2(); Receiver stub2 = (Receiver) RemoteObject.toStub(impl2); System.err.println("marshalling unexported object:"); MarshalledObject mobj = new MarshalledObject(impl); System.err.println("passing unexported object via RMI-JRMP:"); stub2.receive(stub); System.err.println("TEST PASSED"); } finally { if (impl2 != null) { try { UnicastRemoteObject.unexportObject(impl2, true); } catch (Throwable t) { } } } }
Example 12
Source File: ChangeHostName.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { InetAddress localAddress = InetAddress.getLocalHost(); String[] hostlist = new String[] { localAddress.getHostAddress(), localAddress.getHostName() }; for (int i = 0; i < hostlist.length; i++) { System.setProperty("java.rmi.server.hostname", hostlist[i]); Remote impl = new ChangeHostName(); System.err.println("\ncreated impl extending URO: " + impl); Receiver stub = (Receiver) RemoteObject.toStub(impl); System.err.println("stub for impl: " + stub); System.err.println("invoking method on stub"); stub.receive(stub); UnicastRemoteObject.unexportObject(impl, true); System.err.println("unexported impl"); if (stub.toString().indexOf(hostlist[i]) >= 0) { System.err.println("stub's ref contains hostname: " + hostlist[i]); } else { throw new RuntimeException( "TEST FAILED: stub's ref doesn't contain hostname: " + hostlist[i]); } } System.err.println("TEST PASSED"); }
Example 13
Source File: ToStub.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { RemoteInterface server1 = null; RemoteInterface server2 = null; RemoteInterface stub = null; RemoteInterface proxy = null; try { System.setProperty("java.rmi.server.ignoreStubClasses", "true"); if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); } System.err.println("export objects"); server1 = new ToStub(); server2 = new ToStub(); stub = (RemoteInterface) UnicastRemoteObject.exportObject(server1); proxy = (RemoteInterface) UnicastRemoteObject.exportObject(server2, 0); System.err.println("test toStub"); if (stub != RemoteObject.toStub(server1)) { throw new RuntimeException( "toStub returned incorrect value for server1"); } if (!Proxy.isProxyClass(proxy.getClass())) { throw new RuntimeException("proxy is not a dynamic proxy"); } if (proxy != RemoteObject.toStub(server2)) { throw new RuntimeException( "toStub returned incorrect value for server2"); } try { RemoteObject.toStub(new ToStub()); throw new RuntimeException( "stub returned for exported object!"); } catch (NoSuchObjectException nsoe) { } System.err.println("invoke methods"); Object obj = stub.passObject(stub); if (!stub.equals(obj)) { throw new RuntimeException("returned stub not equal"); } obj = proxy.passObject(proxy); if (!proxy.equals(obj)) { throw new RuntimeException("returned proxy not equal"); } System.err.println("TEST PASSED"); } finally { if (stub != null) { UnicastRemoteObject.unexportObject(server1, true); } if (proxy != null) { UnicastRemoteObject.unexportObject(server2, true); } } }
Example 14
Source File: Activation.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Initialize the Activation instantiation; start activation * services. */ private void init(int port, RMIServerSocketFactory ssf, ReliableLog log, String[] childArgs) throws Exception { // initialize this.log = log; numUpdates = 0; shutdownHook = new ShutdownHook(); groupSemaphore = getInt("sun.rmi.activation.groupThrottle", 3); groupCounter = 0; Runtime.getRuntime().addShutdownHook(shutdownHook); // Use array size of 0, since the value from calling size() // may be out of date by the time toArray() is called. ActivationGroupID[] gids = groupTable.keySet().toArray(new ActivationGroupID[0]); synchronized (startupLock = new Object()) { // all the remote methods briefly synchronize on startupLock // (via checkShutdown) to make sure they don't happen in the // middle of this block. This block must not cause any such // incoming remote calls to happen, or deadlock would result! activator = new ActivatorImpl(port, ssf); activatorStub = (Activator) RemoteObject.toStub(activator); system = new ActivationSystemImpl(port, ssf); systemStub = (ActivationSystem) RemoteObject.toStub(system); monitor = new ActivationMonitorImpl(port, ssf); initCommand(childArgs); registry = new SystemRegistryImpl(port, null, ssf, systemStub); if (ssf != null) { synchronized (initLock) { initDone = true; initLock.notifyAll(); } } } startupLock = null; // restart services for (int i = gids.length; --i >= 0; ) { try { getGroupEntry(gids[i]).restartServices(); } catch (UnknownGroupException e) { System.err.println( getTextResource("rmid.restart.group.warning")); e.printStackTrace(); } } }
Example 15
Source File: ToStub.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { RemoteInterface server1 = null; RemoteInterface server2 = null; RemoteInterface stub = null; RemoteInterface proxy = null; try { System.setProperty("java.rmi.server.ignoreStubClasses", "true"); if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); } System.err.println("export objects"); server1 = new ToStub(); server2 = new ToStub(); stub = (RemoteInterface) UnicastRemoteObject.exportObject(server1); proxy = (RemoteInterface) UnicastRemoteObject.exportObject(server2, 0); System.err.println("test toStub"); if (stub != RemoteObject.toStub(server1)) { throw new RuntimeException( "toStub returned incorrect value for server1"); } if (!Proxy.isProxyClass(proxy.getClass())) { throw new RuntimeException("proxy is not a dynamic proxy"); } if (proxy != RemoteObject.toStub(server2)) { throw new RuntimeException( "toStub returned incorrect value for server2"); } try { RemoteObject.toStub(new ToStub()); throw new RuntimeException( "stub returned for exported object!"); } catch (NoSuchObjectException nsoe) { } System.err.println("invoke methods"); Object obj = stub.passObject(stub); if (!stub.equals(obj)) { throw new RuntimeException("returned stub not equal"); } obj = proxy.passObject(proxy); if (!proxy.equals(obj)) { throw new RuntimeException("returned proxy not equal"); } System.err.println("TEST PASSED"); } finally { if (stub != null) { UnicastRemoteObject.unexportObject(server1, true); } if (proxy != null) { UnicastRemoteObject.unexportObject(server2, true); } } }
Example 16
Source File: ToStub.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { RemoteInterface server1 = null; RemoteInterface server2 = null; RemoteInterface stub = null; RemoteInterface proxy = null; try { System.setProperty("java.rmi.server.ignoreStubClasses", "true"); if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); } System.err.println("export objects"); server1 = new ToStub(); server2 = new ToStub(); stub = (RemoteInterface) UnicastRemoteObject.exportObject(server1); proxy = (RemoteInterface) UnicastRemoteObject.exportObject(server2, 0); System.err.println("test toStub"); if (stub != RemoteObject.toStub(server1)) { throw new RuntimeException( "toStub returned incorrect value for server1"); } if (!Proxy.isProxyClass(proxy.getClass())) { throw new RuntimeException("proxy is not a dynamic proxy"); } if (proxy != RemoteObject.toStub(server2)) { throw new RuntimeException( "toStub returned incorrect value for server2"); } try { RemoteObject.toStub(new ToStub()); throw new RuntimeException( "stub returned for exported object!"); } catch (NoSuchObjectException nsoe) { } System.err.println("invoke methods"); Object obj = stub.passObject(stub); if (!stub.equals(obj)) { throw new RuntimeException("returned stub not equal"); } obj = proxy.passObject(proxy); if (!proxy.equals(obj)) { throw new RuntimeException("returned proxy not equal"); } System.err.println("TEST PASSED"); } finally { if (stub != null) { UnicastRemoteObject.unexportObject(server1, true); } if (proxy != null) { UnicastRemoteObject.unexportObject(server2, true); } } }
Example 17
Source File: Activation.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Initialize the Activation instantiation; start activation * services. */ private void init(int port, RMIServerSocketFactory ssf, ReliableLog log, String[] childArgs) throws Exception { // initialize this.log = log; numUpdates = 0; shutdownHook = new ShutdownHook(); groupSemaphore = getInt("sun.rmi.activation.groupThrottle", 3); groupCounter = 0; Runtime.getRuntime().addShutdownHook(shutdownHook); // Use array size of 0, since the value from calling size() // may be out of date by the time toArray() is called. ActivationGroupID[] gids = groupTable.keySet().toArray(new ActivationGroupID[0]); synchronized (startupLock = new Object()) { // all the remote methods briefly synchronize on startupLock // (via checkShutdown) to make sure they don't happen in the // middle of this block. This block must not cause any such // incoming remote calls to happen, or deadlock would result! activator = new ActivatorImpl(port, ssf); activatorStub = (Activator) RemoteObject.toStub(activator); system = new ActivationSystemImpl(port, ssf); systemStub = (ActivationSystem) RemoteObject.toStub(system); monitor = new ActivationMonitorImpl(port, ssf); initCommand(childArgs); registry = new SystemRegistryImpl(port, null, ssf, systemStub); if (ssf != null) { synchronized (initLock) { initDone = true; initLock.notifyAll(); } } } startupLock = null; // restart services for (int i = gids.length; --i >= 0; ) { try { getGroupEntry(gids[i]).restartServices(); } catch (UnknownGroupException e) { System.err.println( getTextResource("rmid.restart.group.warning")); e.printStackTrace(); } } }
Example 18
Source File: RMIJRMPServerImpl.java From Java8CN with Apache License 2.0 | 2 votes |
/** * <p>Returns a serializable stub for this {@link RMIServer} object.</p> * * @return a serializable stub. * * @exception IOException if the stub cannot be obtained - e.g the * RMIJRMPServerImpl has not been exported yet. */ public Remote toStub() throws IOException { return RemoteObject.toStub(this); }
Example 19
Source File: RMIJRMPServerImpl.java From openjdk-8-source with GNU General Public License v2.0 | 2 votes |
/** * <p>Returns a serializable stub for this {@link RMIServer} object.</p> * * @return a serializable stub. * * @exception IOException if the stub cannot be obtained - e.g the * RMIJRMPServerImpl has not been exported yet. */ public Remote toStub() throws IOException { return RemoteObject.toStub(this); }
Example 20
Source File: RMIJRMPServerImpl.java From jdk8u60 with GNU General Public License v2.0 | 2 votes |
/** * <p>Returns a serializable stub for this {@link RMIServer} object.</p> * * @return a serializable stub. * * @exception IOException if the stub cannot be obtained - e.g the * RMIJRMPServerImpl has not been exported yet. */ public Remote toStub() throws IOException { return RemoteObject.toStub(this); }