Search in sources :

Example 1 with Remote

use of java.rmi.Remote in project jdk8u_jdk by JetBrains.

the class Receiver method main.

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) {
            }
        }
    }
}
Also used : MarshalledObject(java.rmi.MarshalledObject) Remote(java.rmi.Remote)

Example 2 with Remote

use of java.rmi.Remote in project jdk8u_jdk by JetBrains.

the class HttpSocketTest method main.

public static void main(String[] args) throws Exception {
    Registry registry = null;
    TestLibrary.suggestSecurityManager(null);
    // Set the socket factory.
    System.err.println("installing socket factory");
    RMISocketFactory.setSocketFactory(new RMIHttpToPortSocketFactory());
    int registryPort = -1;
    try {
        System.err.println("Starting registry");
        registry = TestLibrary.createRegistryOnUnusedPort();
        registryPort = TestLibrary.getRegistryPort(registry);
    } catch (Exception e) {
        TestLibrary.bomb(e);
    }
    try {
        registry.rebind(NAME, new HttpSocketTest());
        MyRemoteInterface httpTest = (MyRemoteInterface) Naming.lookup("//:" + registryPort + "/" + NAME);
        httpTest.setRemoteObject(new HttpSocketTest());
        Remote r = httpTest.getRemoteObject();
    } catch (Exception e) {
        TestLibrary.bomb(e);
    }
}
Also used : RMIHttpToPortSocketFactory(sun.rmi.transport.proxy.RMIHttpToPortSocketFactory) Remote(java.rmi.Remote) LocateRegistry(java.rmi.registry.LocateRegistry) Registry(java.rmi.registry.Registry) RemoteException(java.rmi.RemoteException)

Example 3 with Remote

use of java.rmi.Remote in project jdk8u_jdk by JetBrains.

the class ReuseDefaultPort method main.

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);
    }
}
Also used : Remote(java.rmi.Remote) LocateRegistry(java.rmi.registry.LocateRegistry) Registry(java.rmi.registry.Registry)

Example 4 with Remote

use of java.rmi.Remote in project jdk8u_jdk by JetBrains.

the class RapidExportUnexport method main.

public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 6275081\n");
    Remote impl = new Remote() {
    };
    long start = System.currentTimeMillis();
    for (int i = 0; i < REPS; i++) {
        System.err.println(i);
        UnicastRemoteObject.exportObject(impl, PORT);
        UnicastRemoteObject.unexportObject(impl, true);
        // work around BindException (bug?)
        Thread.sleep(1);
    }
    long delta = System.currentTimeMillis() - start;
    System.err.println(REPS + " export/unexport operations took " + delta + "ms");
    if (delta > TIMEOUT) {
        throw new Error("TEST FAILED: took over " + TIMEOUT + "ms");
    }
    System.err.println("TEST PASSED");
}
Also used : Remote(java.rmi.Remote)

Example 5 with Remote

use of java.rmi.Remote in project jdk8u_jdk by JetBrains.

the class LegalRegistryNames method main.

public static void main(String[] args) throws RuntimeException {
    System.err.println("\nRegression test for bug/rfe 4254808\n");
    Registry registry = null;
    LegalRegistryNames legal = null;
    boolean oneFormFailed = false;
    String[] names = null;
    Vector legalForms = getLegalForms();
    Remote shouldFind = null;
    // create a registry and the test object
    try {
        legal = new LegalRegistryNames();
        System.err.println("Starting registry on default port");
        registry = LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
    } catch (Exception e) {
        TestLibrary.bomb("registry already running on test port");
    }
    // enumerate through all legal URLs to verify that a remote
    // object can be bound and unbound
    String s = null;
    Enumeration en = legalForms.elements();
    while (en.hasMoreElements()) {
        s = (String) en.nextElement();
        System.err.println("\ntesting form: " + s);
        try {
            Naming.rebind(s, legal);
            names = registry.list();
            // ensure that the name in the registry is what is expected
            if ((names.length > 0) && (names[0].compareTo("MyName") != 0)) {
                oneFormFailed = true;
                System.err.println("\tRegistry entry for form: " + s + " is incorrect: " + names[0]);
            }
            // ensure that the object can be unbound under the URL string
            shouldFind = Naming.lookup(s);
            Naming.unbind(s);
            System.err.println("\tform " + s + " OK");
        } catch (Exception e) {
            e.printStackTrace();
            oneFormFailed = true;
            System.err.println("\tunexpected lookup or unbind " + "exception for form: " + s + e.getMessage());
        }
    }
    if (oneFormFailed) {
        TestLibrary.bomb("Test failed");
    }
    // get the test to exit quickly
    TestLibrary.unexport(legal);
}
Also used : Enumeration(java.util.Enumeration) Remote(java.rmi.Remote) LocateRegistry(java.rmi.registry.LocateRegistry) Registry(java.rmi.registry.Registry) Vector(java.util.Vector) UnknownHostException(java.net.UnknownHostException) RemoteException(java.rmi.RemoteException)

Aggregations

Remote (java.rmi.Remote)56 LocateRegistry (java.rmi.registry.LocateRegistry)17 Registry (java.rmi.registry.Registry)17 RemoteException (java.rmi.RemoteException)15 IOException (java.io.IOException)6 AlreadyBoundException (java.rmi.AlreadyBoundException)4 NoSuchObjectException (java.rmi.NoSuchObjectException)4 InitialContext (javax.naming.InitialContext)4 WeakReference (java.lang.ref.WeakReference)3 InvocationHandler (java.lang.reflect.InvocationHandler)3 UnknownHostException (java.net.UnknownHostException)3 MarshalledObject (java.rmi.MarshalledObject)3 ExportException (java.rmi.server.ExportException)3 RemoteObject (java.rmi.server.RemoteObject)3 UnicastRemoteObject (java.rmi.server.UnicastRemoteObject)3 ServiceException (javax.xml.rpc.ServiceException)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 InetAddress (java.net.InetAddress)2 NotBoundException (java.rmi.NotBoundException)2 ObjID (java.rmi.server.ObjID)2