private List<Cache<?, ?>> getAllCaches(Session session) {
    List<Cache<?, ?>> caches = new ArrayList<Cache<?, ?>>();
    EmbeddedCacheManager container = session.getCacheManager();
    for (String cacheName : container.getCacheNames()) {
      if (container.isRunning(cacheName)) {
        caches.add(session.getCache(cacheName));
      }
    }
    caches.add(container.getCache());

    return caches;
  }
  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;
  }