code: public Watcher registerExpirationHandler(final Runnable onExpired) {
      Watcher watcher = new Watcher() {
        @Override public void process(WatchedEvent event) {
          if (event.getType() == EventType.None && event.getState() == KeeperState.Expired) {
            onExpired.run();
          }
        }
      };
      register(watcher);
      return watcher;
    }
docs: Clients that need to re-establish state after session expiration can register an
  {@code onExpired} command to execute.
  
  @param onExpired the {@code Runnable} to register
  @return the new {@link Watcher} which can later be passed to {@link #unregister} for
  removal.