예제 #1
0
 /**
  * Check if resources from a group were changed. If a change is detected, the changeListener will
  * be invoked.
  *
  * @param cacheKey the cache key which was requested. The key contains the groupName which has to
  *     be checked for changes.
  */
 public void check(final CacheKey cacheKey, final Callback callback) {
   notNull(cacheKey);
   LOG.debug("started");
   final StopWatch watch = new StopWatch();
   watch.start("detect changes");
   try {
     final Group group =
         new WroModelInspector(modelFactory.create()).getGroupByName(cacheKey.getGroupName());
     if (isGroupChanged(group.collectResourcesOfType(cacheKey.getType()), callback)) {
       callback.onGroupChanged(cacheKey);
       cacheStrategy.put(cacheKey, null);
     }
     resourceChangeDetector.reset();
   } catch (final Exception e) {
     onException(e);
   } finally {
     watch.stop();
     LOG.debug("resource watcher info: {}", watch.prettyPrint());
   }
 }
예제 #2
0
 /**
  * Invoked when a resource change detected.
  *
  * @param key {@link CacheKey} which has to be invalidated because the corresponding group
  *     contains stale resources. @VisibleForTesting
  */
 void onGroupChanged(final CacheKey key) {
   LOG.debug("detected change for cacheKey: {}", key);
   cacheStrategy.put(key, null);
 }