public static void clearContent(EmbeddedCacheManager cacheContainer) { if (cacheContainer != null && cacheContainer.getStatus().allowInvocations()) { Set<Cache> runningCaches = getRunningCaches(cacheContainer); for (Cache cache : runningCaches) { clearRunningTx(cache); } if (!cacheContainer.getStatus().allowInvocations()) return; for (Cache cache : runningCaches) { clearReplicationQueues(cache); clearCacheLoader(cache); removeInMemoryData(cache); } } }
protected static Set<Cache> getRunningCaches(EmbeddedCacheManager cacheContainer) { Set<Cache> running = new HashSet<Cache>(); if (cacheContainer == null || !cacheContainer.getStatus().allowInvocations()) return running; for (String cacheName : cacheContainer.getCacheNames()) { if (cacheContainer.isRunning(cacheName)) { Cache c = cacheContainer.getCache(cacheName); if (c.getStatus().allowInvocations()) running.add(c); } } if (cacheContainer.isDefaultRunning()) { Cache defaultCache = cacheContainer.getCache(); if (defaultCache.getStatus().allowInvocations()) running.add(defaultCache); } return running; }