Search in sources :

Example 1 with UnicastServerRef2

use of sun.rmi.server.UnicastServerRef2 in project jdk8u_jdk by JetBrains.

the class RMIJRMPServerImpl method export.

private void export(Remote obj) throws RemoteException {
    final RMIExporter exporter = (RMIExporter) env.get(RMIExporter.EXPORTER_ATTRIBUTE);
    final boolean daemon = EnvHelp.isServerDaemon(env);
    if (daemon && exporter != null) {
        throw new IllegalArgumentException("If " + EnvHelp.JMX_SERVER_DAEMON + " is specified as true, " + RMIExporter.EXPORTER_ATTRIBUTE + " cannot be used to specify an exporter!");
    }
    if (daemon) {
        if (csf == null && ssf == null) {
            new UnicastServerRef(port).exportObject(obj, null, true);
        } else {
            new UnicastServerRef2(port, csf, ssf).exportObject(obj, null, true);
        }
    } else if (exporter != null) {
        exporter.exportObject(obj, port, csf, ssf);
    } else {
        UnicastRemoteObject.exportObject(obj, port, csf, ssf);
    }
}
Also used : RMIExporter(com.sun.jmx.remote.internal.RMIExporter) UnicastServerRef2(sun.rmi.server.UnicastServerRef2) UnicastServerRef(sun.rmi.server.UnicastServerRef)

Example 2 with UnicastServerRef2

use of sun.rmi.server.UnicastServerRef2 in project jdk8u_jdk by JetBrains.

the class FilterUSRTest method UnicastServerRef2.

/*
     * Test exporting an object with a serialFilter using UnicastServerRef2.exportObject()
     * with explicit (but null) SocketFactories.
     * Send some objects and check the number of calls to the serialFilter.
     */
@Test(dataProvider = "bindData")
public void UnicastServerRef2(String name, Object obj, int expectedFilterCount) throws RemoteException {
    try {
        RemoteImpl impl = RemoteImpl.create();
        UnicastServerRef2 ref = new UnicastServerRef2(0, null, null, impl.checker);
        Echo client = (Echo) ref.exportObject(impl, null, false);
        int count = client.filterCount(obj);
        System.out.printf("count: %d, obj: %s%n", count, obj);
        Assert.assertEquals(count, expectedFilterCount, "wrong number of filter calls");
    } catch (RemoteException rex) {
        if (expectedFilterCount == -1 && UnmarshalException.class.equals(rex.getCause().getClass()) && InvalidClassException.class.equals(rex.getCause().getCause().getClass())) {
            // normal expected exception
            return;
        }
        rex.printStackTrace();
        Assert.fail("unexpected remote exception", rex);
    } catch (Exception rex) {
        Assert.fail("unexpected exception", rex);
    }
}
Also used : UnmarshalException(java.rmi.UnmarshalException) UnicastServerRef2(sun.rmi.server.UnicastServerRef2) RemoteException(java.rmi.RemoteException) UnmarshalException(java.rmi.UnmarshalException) RemoteException(java.rmi.RemoteException) InvalidClassException(java.io.InvalidClassException) Test(org.testng.annotations.Test)

Aggregations

UnicastServerRef2 (sun.rmi.server.UnicastServerRef2)2 RMIExporter (com.sun.jmx.remote.internal.RMIExporter)1 InvalidClassException (java.io.InvalidClassException)1 RemoteException (java.rmi.RemoteException)1 UnmarshalException (java.rmi.UnmarshalException)1 Test (org.testng.annotations.Test)1 UnicastServerRef (sun.rmi.server.UnicastServerRef)1