You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Robert Haycock <Ro...@artificial-solutions.com> on 2016/11/08 17:07:14 UTC

How to listen for any lock timeout

Hi,

I want to be able to listen for lock time outs. How to do this?

I had tried this, called when I initialise the app...

    EventListener listener = (EventIterator events) -> {
            while (events.hasNext()) {
                try {
                    Event event = events.nextEvent();
                    String path = event.getPath();
                    if (!path.endsWith(JcrConstants.JCR_LOCKOWNER))
                        continue;

                    LockCache.instance().removeLock(path);

                } catch (RepositoryException ex) {
                    log.warn("Unable to get property path for PROPERTY_REMOVED event", ex);
                }
            }
        };

        observationManager.addEventListener(listener, Event.PROPERTY_REMOVED,
            "/MyRoot", true, null, null, false);


But the listener never gets called. Not even when I call LockManager.Unlock().

Does the session (where I got the ObservationManager from) have to remain open?

Thanks,
Rob.