public synchronized void listenOn(Cache<CounterKey, CounterValue> cache) throws InterruptedException {
      if (!topologyListener.registered) {
         this.cache = cache;
         topologyListener.register(cache);
      }
      if (!listenersRegistered) {
         this.cache.addListener(valueListener, CounterKeyFilter.getInstance());
         listenersRegistered = true;
      }
   }
public synchronized void listenOn ( Cache < CounterKey , CounterValue > cache ) throws InterruptedException { if ( ! topologyListener . registered ) { this . cache = cache ; topologyListener . register ( cache ) ; } if ( ! listenersRegistered ) { this . cache . addListener ( valueListener , CounterKeyFilter . getInstance ( ) ) ; listenersRegistered = true ; } }
It registers the cache listeners if they aren't already registered.

@param cache The {@link Cache} to register the listener.