public void start() {
      this.stateCache = cacheManager
            .<ScopedState, CounterConfiguration>getCache(GlobalConfigurationManager.CONFIG_STATE_CACHE_NAME)
            .getAdvancedCache();
      listener = new CounterConfigurationListener();
      Map<String, CounterConfiguration> persisted = storage.loadAll();
      persisted.forEach((name, cfg) -> stateCache.putIfAbsent(stateKey(name), cfg));
      counterCacheStarted.set(false);
      stateCache.addListener(listener, new ScopeFilter(COUNTER_SCOPE));
      if (!persisted.isEmpty() || stateCache.keySet().stream()
            .anyMatch(scopedState -> COUNTER_SCOPE.equals(scopedState.getScope()))) {
         //we have counter defined
         startCounterCache();
      }
   }
public void start ( ) { this . stateCache = cacheManager . < ScopedState , CounterConfiguration > getCache ( GlobalConfigurationManager . CONFIG_STATE_CACHE_NAME ) . getAdvancedCache ( ) ; listener = new CounterConfigurationListener ( ) ; Map < String , CounterConfiguration > persisted = storage . loadAll ( ) ; persisted . forEach ( ( name , cfg ) -> stateCache . putIfAbsent ( stateKey ( name ) , cfg ) ) ; counterCacheStarted . set ( false ) ; stateCache . addListener ( listener , new ScopeFilter ( COUNTER_SCOPE ) ) ; if ( ! persisted . isEmpty ( ) || stateCache . keySet ( ) . stream ( ) . anyMatch ( scopedState -> COUNTER_SCOPE . equals ( scopedState . getScope ( ) ) ) ) { startCounterCache ( ) ; } }
It checks for existing defined configurations in {@link CounterConfigurationStorage} and in the {@link Cache}.
<p>
If any is found, it starts the counter's {@link Cache}.