Search in sources :

Example 1 with MarshalledObject

use of java.rmi.MarshalledObject 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 MarshalledObject

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

the class MOFilterTest method delegatesToMO.

/**
     * Test that MarshalledObject inherits the ObjectInputFilter from
     * the stream it was deserialized from.
     */
@Test(dataProvider = "FilterCases")
static void delegatesToMO(boolean withFilter) {
    try {
        Serializable testobj = Integer.valueOf(5);
        MarshalledObject<Serializable> mo = new MarshalledObject<>(testobj);
        Assert.assertEquals(mo.get(), testobj, "MarshalledObject.get returned a non-equals test object");
        byte[] bytes = writeObjects(mo);
        try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
            ObjectInputStream ois = new ObjectInputStream(bais)) {
            CountingFilter filter1 = new CountingFilter();
            ObjectInputFilter.Config.setObjectInputFilter(ois, withFilter ? filter1 : null);
            MarshalledObject<?> actualMO = (MarshalledObject<?>) ois.readObject();
            int count = filter1.getCount();
            actualMO.get();
            int expectedCount = withFilter ? count + 2 : count;
            int actualCount = filter1.getCount();
            Assert.assertEquals(actualCount, expectedCount, "filter called wrong number of times during get()");
        }
    } catch (IOException ioe) {
        Assert.fail("Unexpected IOException", ioe);
    } catch (ClassNotFoundException cnf) {
        Assert.fail("Deserializing", cnf);
    }
}
Also used : Serializable(java.io.Serializable) ByteArrayInputStream(java.io.ByteArrayInputStream) MarshalledObject(java.rmi.MarshalledObject) IOException(java.io.IOException) ObjectInputStream(java.io.ObjectInputStream) Test(org.testng.annotations.Test)

Example 3 with MarshalledObject

use of java.rmi.MarshalledObject in project felix by apache.

the class ClientInvoker method setAttribute.

public void setAttribute(ObjectName objectName, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException, IOException {
    MarshalledObject attrib = RMIMarshaller.marshal(attribute);
    connection.setAttribute(objectName, attrib, delegate);
}
Also used : MarshalledObject(java.rmi.MarshalledObject)

Example 4 with MarshalledObject

use of java.rmi.MarshalledObject in project felix by apache.

the class RMIConnectionInvoker method removeNotificationListener.

public void removeNotificationListener(ObjectName name, ObjectName listener, MarshalledObject filter, MarshalledObject handback, Subject delegate) throws InstanceNotFoundException, ListenerNotFoundException, IOException {
    NotificationFilter f = (NotificationFilter) RMIMarshaller.unmarshal(filter, server.getClassLoaderFor(name), defaultLoader);
    Object h = RMIMarshaller.unmarshal(handback, server.getClassLoaderFor(name), defaultLoader);
    server.removeNotificationListener(name, listener, f, h);
}
Also used : MarshalledObject(java.rmi.MarshalledObject) NotificationFilter(javax.management.NotificationFilter)

Example 5 with MarshalledObject

use of java.rmi.MarshalledObject in project felix by apache.

the class RMIConnectionInvoker method addNotificationListeners.

public Integer[] addNotificationListeners(ObjectName[] names, MarshalledObject[] filters, Subject[] delegates) throws InstanceNotFoundException, IOException {
    ArrayList ids = new ArrayList();
    for (int i = 0; i < names.length; ++i) {
        ObjectName name = names[i];
        MarshalledObject filter = filters[i];
        NotificationFilter f = (NotificationFilter) RMIMarshaller.unmarshal(filter, server.getClassLoaderFor(name), defaultLoader);
        Integer id = notificationHandler.generateListenerID(name, f);
        NotificationListener listener = notificationHandler.getServerNotificationListener();
        server.addNotificationListener(name, listener, f, id);
        notificationHandler.addNotificationListener(id, new NotificationTuple(name, listener, f, id));
        ids.add(id);
    }
    return (Integer[]) ids.toArray(new Integer[ids.size()]);
}
Also used : NotificationTuple(org.apache.felix.mosgi.jmx.rmiconnector.mx4j.remote.NotificationTuple) MarshalledObject(java.rmi.MarshalledObject) ArrayList(java.util.ArrayList) NotificationFilter(javax.management.NotificationFilter) ObjectName(javax.management.ObjectName) NotificationListener(javax.management.NotificationListener)

Aggregations

MarshalledObject (java.rmi.MarshalledObject)32 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)5 List (java.util.List)4 Graph (edu.cmu.tetrad.graph.Graph)3 Node (edu.cmu.tetrad.graph.Node)3 Remote (java.rmi.Remote)3 EJBHome (javax.ejb.EJBHome)3 EJBObject (javax.ejb.EJBObject)3 Handle (javax.ejb.Handle)3 HomeHandle (javax.ejb.HomeHandle)3 NotificationFilter (javax.management.NotificationFilter)3 TestType (edu.cmu.tetrad.search.TestType)2 UnmarshalException (java.rmi.UnmarshalException)2 PrivilegedActionException (java.security.PrivilegedActionException)2 ObjectName (javax.management.ObjectName)2 JMXServerErrorException (javax.management.remote.JMXServerErrorException)2 NotificationTuple (org.apache.felix.mosgi.jmx.rmiconnector.mx4j.remote.NotificationTuple)2 FindOneFactorClusters (edu.cmu.tetrad.search.FindOneFactorClusters)1 FindTwoFactorClusters (edu.cmu.tetrad.search.FindTwoFactorClusters)1