Hi,

On Tue, Mar 11, 2014 at 6:12 AM, Michael Dürig <[email protected]> wrote:
> One way we could address this in an backward compatible way is to slightly
> extend the semantics of the absPath parameter and allow for a list of path
> instead of a single one.

Couldn't the client achieve the same effect by registering multiple
copies of the listener, one for each path?

A utility class like the one shown below should do the trick.

BR,

Jukka Zitting

----

public class MultiListener implements EventListener {

    private final ObservationManager manager;

    private final EventListener listener;

    private final List<EventListener> proxies = new ArrayList<EventListener>();

    public void register(
            int eventTypes, Collection<String> paths, boolean isDeep,
            String[] uuid, String[] nodeTypeNames, boolean noLocal)
            throws RepositoryException {
        for (String path : paths) {
            EventListener proxy = new EventListener() {
                @Override
                public void onEvent(EventIterator events) {
                    listener.onEvent(events);
                }
            };
            manager.addEventListener(
                    proxy, eventTypes, path,
                    isDeep, uuid, nodeTypeNames, noLocal);
            proxies.add(proxy);
        }
    }

    public void unregister() throws RepositoryException {
        for (EventListener proxy : proxies) {
            manager.removeEventListener(proxy);
        }
    }

}

Reply via email to