@Override public Collection<? extends Cache> resolveCaches(CacheOperationInvocationContext<?> context) { if (!(context instanceof CacheInvocationContext<?>)) { throw new IllegalStateException("Unexpected context " + context); } CacheInvocationContext<?> cacheInvocationContext = (CacheInvocationContext<?>) context; javax.cache.Cache<Object, Object> cache = this.target.resolveCache(cacheInvocationContext); if (cache == null) { throw new IllegalStateException("Could not resolve cache for " + context + " using " + this.target); } return Collections.singleton(new JCacheCache(cache)); }
@Override protected Collection<Cache> loadCaches() { CacheManager cacheManager = getCacheManager(); Assert.state(cacheManager != null, "No CacheManager set"); Collection<Cache> caches = new LinkedHashSet<>(); for (String cacheName : cacheManager.getCacheNames()) { javax.cache.Cache<Object, Object> jcache = cacheManager.getCache(cacheName); caches.add(new JCacheCache(jcache, isAllowNullValues())); } return caches; }
@Override public Collection<? extends Cache> resolveCaches(CacheOperationInvocationContext<?> context) { if (!(context instanceof CacheInvocationContext<?>)) { throw new IllegalStateException("Unexpected context " + context); } CacheInvocationContext<?> cacheInvocationContext = (CacheInvocationContext<?>) context; javax.cache.Cache<Object, Object> cache = this.target.resolveCache(cacheInvocationContext); if (cache == null) { throw new IllegalStateException("Could not resolve cache for " + context + " using " + this.target); } return Collections.singleton(new JCacheCache(cache)); }
@Override protected Cache getMissingCache(String name) { CacheManager cacheManager = getCacheManager(); Assert.state(cacheManager != null, "No CacheManager set"); // Check the JCache cache again (in case the cache was added at runtime) javax.cache.Cache<Object, Object> jcache = cacheManager.getCache(name); if (jcache != null) { return new JCacheCache(jcache, isAllowNullValues()); } return null; }
@Override protected Collection<Cache> loadCaches() { CacheManager cacheManager = getCacheManager(); Assert.state(cacheManager != null, "No CacheManager set"); Collection<Cache> caches = new LinkedHashSet<>(); for (String cacheName : cacheManager.getCacheNames()) { javax.cache.Cache<Object, Object> jcache = cacheManager.getCache(cacheName); caches.add(new JCacheCache(jcache, isAllowNullValues())); } return caches; }
@Override protected Cache getMissingCache(String name) { CacheManager cacheManager = getCacheManager(); Assert.state(cacheManager != null, "No CacheManager set"); // Check the JCache cache again (in case the cache was added at runtime) javax.cache.Cache<Object, Object> jcache = cacheManager.getCache(name); if (jcache != null) { return new JCacheCache(jcache, isAllowNullValues()); } return null; }
@Before public void setup() { this.cacheManager = getCachingProvider().getCacheManager(); this.cacheManager.createCache(CACHE_NAME, new MutableConfiguration<>()); this.cacheManager.createCache(CACHE_NAME_NO_NULL, new MutableConfiguration<>()); this.nativeCache = this.cacheManager.getCache(CACHE_NAME); this.cache = new JCacheCache(this.nativeCache); Cache<Object, Object> nativeCacheNoNull = this.cacheManager.getCache(CACHE_NAME_NO_NULL); this.cacheNoNull = new JCacheCache(nativeCacheNoNull, false); }
@Override public Collection<? extends Cache> resolveCaches(CacheOperationInvocationContext<?> context) { if (!(context instanceof CacheInvocationContext<?>)) { throw new IllegalStateException("Unexpected context " + context); } CacheInvocationContext<?> cacheInvocationContext = (CacheInvocationContext<?>) context; javax.cache.Cache<Object, Object> cache = this.target.resolveCache(cacheInvocationContext); if (cache == null) { throw new IllegalStateException("Could not resolve cache for " + context + " using " + this.target); } return Collections.singleton(new JCacheCache(cache)); }
@Override public Cache getCache(String name) { if (!caches.containsKey(name)) { Cache cache = cacheProvider.isCacheEnabled(name) ? new JCacheCache(cacheProvider.getCache(name)) : noOpCacheManager.getCache(name); caches.putIfAbsent(name, cache); } return caches.get(name); }
@Override protected Cache getMissingCache(String name) { // Check the JCache cache again (in case the cache was added at runtime) javax.cache.Cache<Object, Object> jcache = getCacheManager().getCache(name); if (jcache != null) { return new JCacheCache(jcache, isAllowNullValues()); } return null; }