Search in sources :

Example 26 with MarshalledObject

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);
}
Also used : NotSerializableException(java.io.NotSerializableException) NotificationTuple(org.apache.felix.mosgi.jmx.rmiconnector.mx4j.remote.NotificationTuple) MarshalledObject(java.rmi.MarshalledObject)

Example 27 with MarshalledObject

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);
}
Also used : MarshalledObject(java.rmi.MarshalledObject) NotificationFilter(javax.management.NotificationFilter)

Example 28 with MarshalledObject

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);
}
Also used : MarshalledObject(java.rmi.MarshalledObject) ArrayList(java.util.ArrayList) MarshalledObject(java.rmi.MarshalledObject) Subject(javax.security.auth.Subject) ObjectName(javax.management.ObjectName)

Example 29 with MarshalledObject

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());
    }
}
Also used : EJBHome(javax.ejb.EJBHome) MarshalledObject(java.rmi.MarshalledObject) HomeHandle(javax.ejb.HomeHandle)

Example 30 with MarshalledObject

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());
    }
}
Also used : EJBObject(javax.ejb.EJBObject) MarshalledObject(java.rmi.MarshalledObject) Handle(javax.ejb.Handle)

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