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) {
}
}
}
}
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);
}
}
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);
}
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);
}
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()]);
}
Aggregations