2.22.2.6. ZooKeeper Watcher Interface

public class ZooKeeper {
    ...

    // Manage watches with explicit mode.
    void addWatch (String basePath, AddWatchMode mode);
    void removeWatches (String path, Watcher watcher, Watcher.WatcherType watcherType, boolean local);

    ...
}


public enum AddWatchMode {
    PERSISTENT (0),
    PERSISTENT_RECURSIVE (1);
}


public interface Watcher {

    abstract public void process (WatchedEvent event);

    public interface Event {
        public enum EventType {
            None (-1),
            NodeCreated (1),
            NodeDeleted (2),
            NodeDataChanged (3),
            NodeChildrenChanged (4);

            ...
        }
    }
}


public class WatchedEvent {
    ...

    public KeeperState getState () { ... }
    public EventType getType () { ... }
    public String getPath () { ... }
}