/** * Send notification (without propagation), children may override this. * * @param notification */ protected void changedInternal(ResourceNotification notification) { List<ResourceListener> listeners = handlers.get(notification.getPath()); if (listeners != null) { // copy listeners into a new collection, // so that listeners can remove/add themselves if necessary listeners = new ArrayList<>(listeners); for (ResourceListener listener : listeners) { listener.changed(notification); } } }
@Override public void changed(ResourceNotification notify) { assertTrue(watcher.removeListener(notify.getPath(), this)); } };
if (!notification.getPath().equals(event.getPath())) { changedInternal( new ResourceNotification( if (notification.getKind() == Kind.ENTRY_CREATE) { for (Event event : notification.events()) { if (!notification.getPath().equals(event.getPath())) { createdParents.add(event.getPath()); String path = Paths.parent(notification.getPath()); while (path != null) { boolean isCreate = createdParents.contains(path);
assertEquals("DirB", dirEvent.get().getPath()); assertEquals(2, dirEvent.get().events().size()); assertEquals(Kind.ENTRY_CREATE, dirEvent.get().events().get(0).getKind());
assertEquals(Paths.BASE, n.getPath()); assertEquals(1, n.events().size()); Event e = n.events().get(0); n = listener.await(5, TimeUnit.SECONDS); assertEquals(Kind.ENTRY_MODIFY, n.getKind()); assertEquals(Paths.BASE, n.getPath()); e = n.events().get(0); assertEquals(Kind.ENTRY_DELETE, e.getKind()); n = listener.await(5, TimeUnit.SECONDS); assertEquals(Kind.ENTRY_MODIFY, n.getKind()); assertEquals(Paths.BASE, n.getPath()); e = n.events().get(0); assertEquals(Kind.ENTRY_CREATE, e.getKind());
@Override public void changed(ResourceNotification notify) { assertTrue(watcher.removeListener(notify.getPath(), this)); } };
assertEquals(Paths.BASE, n.getPath()); assertEquals(1, n.events().size()); Event e = n.events().get(0); n = listener.await(5, TimeUnit.SECONDS); assertEquals(Kind.ENTRY_MODIFY, n.getKind()); assertEquals(Paths.BASE, n.getPath()); e = n.events().get(0); assertEquals(Kind.ENTRY_DELETE, e.getKind()); n = listener.await(5, TimeUnit.SECONDS); assertEquals(Kind.ENTRY_MODIFY, n.getKind()); assertEquals(Paths.BASE, n.getPath()); e = n.events().get(0); assertEquals(Kind.ENTRY_CREATE, e.getKind());
assertEquals(Kind.ENTRY_MODIFY, listener.getNotify().getKind()); assertEquals(1, listener.getNotify().events().size()); assertEquals("DirC", listener.getNotify().getPath()); long timeStamp = listener.getNotify().getTimestamp(); assertTrue(timeStamp > before); assertEquals(Kind.ENTRY_MODIFY, listener.getNotify().getKind()); assertEquals(1, listener.getNotify().events().size()); assertEquals(Paths.BASE, listener.getNotify().getPath()); e = listener.getNotify().events().get(0); assertEquals(Kind.ENTRY_DELETE, e.getKind()); assertEquals(Paths.BASE, listener.getNotify().getPath()); e = listener.getNotify().events().get(0); assertEquals(Kind.ENTRY_CREATE, e.getKind());