Search in sources :

Example 1 with NotificationTuple

use of org.apache.felix.mosgi.jmx.rmiconnector.mx4j.remote.NotificationTuple 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)

Example 2 with NotificationTuple

use of org.apache.felix.mosgi.jmx.rmiconnector.mx4j.remote.NotificationTuple in project felix by apache.

the class ClientInvoker method removeNotificationListener.

public void removeNotificationListener(ObjectName observed, NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException, IOException {
    Integer[] ids = notificationHandler.getNotificationListeners(new NotificationTuple(observed, listener));
    if (ids == null)
        throw new ListenerNotFoundException("Could not find listener " + listener);
    connection.removeNotificationListeners(observed, ids, delegate);
    notificationHandler.removeNotificationListeners(ids);
}
Also used : NotificationTuple(org.apache.felix.mosgi.jmx.rmiconnector.mx4j.remote.NotificationTuple) ListenerNotFoundException(javax.management.ListenerNotFoundException)

Example 3 with NotificationTuple

use of org.apache.felix.mosgi.jmx.rmiconnector.mx4j.remote.NotificationTuple 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 4 with NotificationTuple

use of org.apache.felix.mosgi.jmx.rmiconnector.mx4j.remote.NotificationTuple in project felix by apache.

the class ClientInvoker method removeNotificationListener.

public void removeNotificationListener(ObjectName observed, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException, IOException {
    Integer id = notificationHandler.getNotificationListener(new NotificationTuple(observed, listener, filter, handback));
    if (id == null)
        throw new ListenerNotFoundException("Could not find listener " + listener + " with filter " + filter + " and handback " + handback);
    Integer[] ids = new Integer[] { id };
    connection.removeNotificationListeners(observed, ids, delegate);
    notificationHandler.removeNotificationListeners(ids);
}
Also used : NotificationTuple(org.apache.felix.mosgi.jmx.rmiconnector.mx4j.remote.NotificationTuple) ListenerNotFoundException(javax.management.ListenerNotFoundException)

Example 5 with NotificationTuple

use of org.apache.felix.mosgi.jmx.rmiconnector.mx4j.remote.NotificationTuple in project felix by apache.

the class RMIConnectionInvoker method removeNotificationListeners.

public void removeNotificationListeners(ObjectName name, Integer[] listenerIDs, Subject delegate) throws InstanceNotFoundException, ListenerNotFoundException, IOException {
    for (int i = 0; i < listenerIDs.length; ++i) {
        Integer id = listenerIDs[i];
        NotificationTuple tuple = notificationHandler.getNotificationListener(id);
        server.removeNotificationListener(name, tuple.getNotificationListener(), tuple.getNotificationFilter(), tuple.getHandback());
        notificationHandler.removeNotificationListener(id);
    }
}
Also used : NotificationTuple(org.apache.felix.mosgi.jmx.rmiconnector.mx4j.remote.NotificationTuple)

Aggregations

NotificationTuple (org.apache.felix.mosgi.jmx.rmiconnector.mx4j.remote.NotificationTuple)5 MarshalledObject (java.rmi.MarshalledObject)2 ListenerNotFoundException (javax.management.ListenerNotFoundException)2 NotSerializableException (java.io.NotSerializableException)1 ArrayList (java.util.ArrayList)1 NotificationFilter (javax.management.NotificationFilter)1 NotificationListener (javax.management.NotificationListener)1 ObjectName (javax.management.ObjectName)1