@Override public void startPublishing(String prop) { trace(_log, "register: ", prop); if (_eventBus == null) { throw new IllegalStateException("_eventBus must not be null when publishing"); } // Zookeeper callbacks (see the listener below) will be executed by the Zookeeper // notification thread, in order. See: // http://zookeeper.apache.org/doc/current/zookeeperProgrammers.html#Java+Binding // This call occurs on a different thread, the PropertyEventBus callback thread. // // Publication to the event bus always occurs in the callback which is executed by the // ZooKeeper notification thread. Since ZK guarantees the callbacks will be executed in // the same order as the requests were made, we will never publish a stale value to the bus, // even if there was a watch set on this property before this call to startPublishing(). _zkChildWatcher.addWatch(prop); _zk.getChildren(getPath(prop), _zkChildWatcher, _zkChildWatcher, true); }