test/java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java

Print this page

        

*** 27,37 **** * @author Ann Wollrath * * @library ../../testlibrary * @build RMID ActivationLibrary * @build RmidViaInheritedChannel ! * @run main/othervm/timeout=240 -Djava.rmi.activation.port=5398 RmidViaInheritedChannel */ import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; --- 27,38 ---- * @author Ann Wollrath * * @library ../../testlibrary * @build RMID ActivationLibrary * @build RmidViaInheritedChannel ! * @build TestLibrary ! * @run main/othervm/timeout=240 RmidViaInheritedChannel */ import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress;
*** 46,57 **** import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject; public class RmidViaInheritedChannel implements Callback { - - private static final int PORT = 5398; private static final Object lock = new Object(); private static boolean notified = false; private RmidViaInheritedChannel() {} --- 47,56 ----
*** 62,72 **** lock.notifyAll(); } } public static void main(String[] args) throws Exception { ! RMID rmid = null; Callback obj = null; try { /* --- 61,72 ---- lock.notifyAll(); } } public static void main(String[] args) throws Exception { ! System.setProperty("java.rmi.activation.port", ! Integer.toString(TestLibrary.RMIDVIAINHERITEDCHANNEL_ACTIVATION_PORT)); RMID rmid = null; Callback obj = null; try { /*
*** 75,93 **** System.err.println("export callback object and bind in registry"); obj = new RmidViaInheritedChannel(); Callback proxy = (Callback) UnicastRemoteObject.exportObject(obj, 0); Registry registry = ! LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); registry.bind("Callback", proxy); /* * Start rmid. */ System.err.println("start rmid with inherited channel"); RMID.removeLog(); ! rmid = RMID.createRMID(System.out, System.err, true, false, PORT); rmid.addOptions(new String[]{ "-Djava.nio.channels.spi.SelectorProvider=RmidViaInheritedChannel$RmidSelectorProvider"}); rmid.start(); /* --- 75,95 ---- System.err.println("export callback object and bind in registry"); obj = new RmidViaInheritedChannel(); Callback proxy = (Callback) UnicastRemoteObject.exportObject(obj, 0); Registry registry = ! LocateRegistry.createRegistry( ! TestLibrary.RMIDVIAINHERITEDCHANNEL_REGISTRY_PORT); registry.bind("Callback", proxy); /* * Start rmid. */ System.err.println("start rmid with inherited channel"); RMID.removeLog(); ! rmid = RMID.createRMID(System.out, System.err, true, false, ! TestLibrary.RMIDVIAINHERITEDCHANNEL_ACTIVATION_PORT); rmid.addOptions(new String[]{ "-Djava.nio.channels.spi.SelectorProvider=RmidViaInheritedChannel$RmidSelectorProvider"}); rmid.start(); /*
*** 106,116 **** } finally { if (obj != null) { UnicastRemoteObject.unexportObject(obj, true); } ! ActivationLibrary.rmidCleanup(rmid, PORT); } } public static class RmidSelectorProvider extends SelectorProvider { --- 108,118 ---- } finally { if (obj != null) { UnicastRemoteObject.unexportObject(obj, true); } ! ActivationLibrary.rmidCleanup(rmid); } } public static class RmidSelectorProvider extends SelectorProvider {
*** 164,183 **** * Create server socket channel and bind server socket. */ channel = ServerSocketChannel.open(); ServerSocket serverSocket = channel.socket(); serverSocket.bind( ! new InetSocketAddress(InetAddress.getLocalHost(), PORT)); System.err.println("serverSocket = " + serverSocket); /* * Notify test that inherited channel was created. */ try { System.err.println("notify test..."); Registry registry = ! LocateRegistry.getRegistry(TestLibrary.REGISTRY_PORT); Callback obj = (Callback) registry.lookup("Callback"); obj.notifyTest(); } catch (NotBoundException nbe) { throw (IOException) new IOException("callback object not bound"). --- 166,186 ---- * Create server socket channel and bind server socket. */ channel = ServerSocketChannel.open(); ServerSocket serverSocket = channel.socket(); serverSocket.bind( ! new InetSocketAddress(InetAddress.getLocalHost(), ! TestLibrary.RMIDVIAINHERITEDCHANNEL_ACTIVATION_PORT)); System.err.println("serverSocket = " + serverSocket); /* * Notify test that inherited channel was created. */ try { System.err.println("notify test..."); Registry registry = ! LocateRegistry.getRegistry(TestLibrary.RMIDVIAINHERITEDCHANNEL_REGISTRY_PORT); Callback obj = (Callback) registry.lookup("Callback"); obj.notifyTest(); } catch (NotBoundException nbe) { throw (IOException) new IOException("callback object not bound").