/** * Remove a single domain ID from all session domain ID caches * * @param domainId */ private void removeDomainFromIDCache(String domainId) { try { Set<?> cachedObjects = cacheManager.getAllKeysFromRegionCache(CACHE_REGION); if (cachedObjects != null) { for (Object k : cachedObjects) { if (k instanceof String) { String key = (String) k; if (key != null && key.startsWith(DOMAIN_CACHE_KEY_PREDICATE)) { Set<String> domainIds = (Set<String>) cacheManager.getFromRegionCache(CACHE_REGION, key); domainIds.remove(domainId); cacheManager.putInRegionCache(CACHE_REGION, key, domainIds); } } } } } catch (Throwable e) { // due to a known issue in hibernate cache // the getAll* methods of ICacheManager throw a NullPointerException if // cache values are null (this can happen due to cache object timeouts) // please see: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3248 if (logger.isDebugEnabled()) { logger.debug("", e); // $NON-NLS-1$ } } }
/** * Calls the callback for every key in the cache region * * @param callback {@see CacheCallback} */ protected void forAllKeys(final CacheIteratorCallback callback) { try { Set<?> cachedObjects = cacheManager.getAllKeysFromRegionCache(CACHE_REGION); if (cachedObjects != null) { for (Object k : cachedObjects) { if (k instanceof CacheKey) { CacheKey key = (CacheKey) k; if (Boolean.FALSE.equals(callback.call(cacheManager, key))) { break; } } } } } catch (Throwable e) { // due to a known issue in hibernate cache // the getAll* methods of ICacheManager throw a NullPointerException if // cache values are null (this can happen due to cache object timeouts) // please see: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3248 if (logger.isDebugEnabled()) { logger.debug("", e); // $NON-NLS-1$ } } }