Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.hubspot.ringleader.watcher;
 
 
 
 public class WatcherFactory {
   private final Supplier<CuratorFrameworkcuratorSupplier;
  public WatcherFactory(Supplier<CuratorFrameworkcuratorSupplier) {
    this. = curatorSupplier;
  }
  public PersistentWatcher dataWatcher(String path) {
    return new PersistentWatcher(path);
  }
    final CountDownLatch started = new CountDownLatch(1);
    PersistentWatcher watcher = new PersistentWatcher(path) {
      @Override
      public void start() {
        super.start();
        try {
          started.await();
        } catch (InterruptedException e) {
          Thread.currentThread().interrupt();
        }
      }
    };
    watcher.getEventListenable().addListener(new EventListener() {
      //@Override Java 5 compatibility
      public void newEvent(Event event) {
        started.countDown();
      }
    });
    return watcher;
  }
New to GrepCode? Check out our FAQ X