use of java.rmi.MarshalledObject in project felix by apache.
the class ClientInvoker method addNotificationListener.
public void addNotificationListener(ObjectName observed, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, IOException {
NotificationTuple tuple = new NotificationTuple(observed, listener, filter, handback);
if (notificationHandler.contains(tuple))
return;
MarshalledObject f = null;
try {
f = RMIMarshaller.marshal(filter);
} catch (NotSerializableException x) {
// Invoke the filter on client side
tuple.setInvokeFilter(true);
}
Integer[] ids = connection.addNotificationListeners(new ObjectName[] { observed }, new MarshalledObject[] { f }, new Subject[] { delegate });
notificationHandler.addNotificationListener(ids[0], tuple);
}
use of java.rmi.MarshalledObject in project felix by apache.
the class RMIConnectionInvoker method addNotificationListener.
public void addNotificationListener(ObjectName name, ObjectName listener, MarshalledObject filter, MarshalledObject handback, Subject delegate) throws InstanceNotFoundException, IOException {
NotificationFilter f = (NotificationFilter) RMIMarshaller.unmarshal(filter, server.getClassLoaderFor(name), defaultLoader);
Object h = RMIMarshaller.unmarshal(handback, server.getClassLoaderFor(name), defaultLoader);
server.addNotificationListener(name, listener, f, h);
}
use of java.rmi.MarshalledObject in project felix by apache.
the class RMIConnectionSubjectInvoker method invoke.
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
String methodName = method.getName();
if ("fetchNotifications".equals(methodName))
return chain(proxy, method, args);
if ("addNotificationListeners".equals(methodName)) {
Subject[] delegates = (Subject[]) args[args.length - 1];
if (delegates == null || delegates.length == 0)
return chain(proxy, method, args);
if (delegates.length == 1)
return subjectInvoke(proxy, method, args, delegates[0]);
ArrayList ids = new ArrayList();
for (int i = 0; i < delegates.length; ++i) {
ObjectName name = ((ObjectName[]) args[0])[i];
MarshalledObject filter = ((MarshalledObject[]) args[1])[i];
Subject delegate = delegates[i];
Object[] newArgs = new Object[] { new ObjectName[] { name }, new MarshalledObject[] { filter }, new Subject[] { delegate } };
Integer id = ((Integer[]) subjectInvoke(proxy, method, newArgs, delegate))[0];
ids.add(id);
}
return (Integer[]) ids.toArray(new Integer[ids.size()]);
}
// For all other methods, the subject is always the last argument
Subject delegate = (Subject) args[args.length - 1];
return subjectInvoke(proxy, method, args, delegate);
}
use of java.rmi.MarshalledObject in project tomee by apache.
the class Unknown2HomeHandleTests method Xtest02_copyHandleByMarshalledObject.
public void Xtest02_copyHandleByMarshalledObject() {
try {
final MarshalledObject obj = new MarshalledObject(ejbHomeHandle);
final HomeHandle copy = (HomeHandle) obj.get();
assertNotNull("The HomeHandle copy is null", copy);
final EJBHome home = copy.getEJBHome();
assertNotNull("The EJBHome is null", home);
} catch (final Exception e) {
fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
}
use of java.rmi.MarshalledObject in project tomee by apache.
the class Complex2HandleTests method Xtest02_copyHandleByMarshalledObject.
public void Xtest02_copyHandleByMarshalledObject() {
try {
final MarshalledObject obj = new MarshalledObject(ejbHandle);
final Handle copy = (Handle) obj.get();
final EJBObject object = copy.getEJBObject();
assertNotNull("The EJBObject is null", object);
assertTrue("EJBObjects are not identical", object.isIdentical(ejbObject));
} catch (final Exception e) {
fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
}
Aggregations