javax.cache.CacheManager Java Examples
The following examples show how to use
javax.cache.CacheManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EhcacheCachingProvider.java From ehcache3 with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public CacheManager getCacheManager(URI uri, ClassLoader classLoader, Properties properties) { uri = uri == null ? getDefaultURI() : uri; classLoader = classLoader == null ? getDefaultClassLoader() : classLoader; properties = properties == null ? new Properties() : cloneProperties(properties); if (URI_DEFAULT.equals(uri)) { URI override = DefaultConfigurationResolver.resolveConfigURI(properties); if (override != null) { uri = override; } } return getCacheManager(new ConfigSupplier(uri, classLoader), properties); }
Example #2
Source File: ReadWriteICacheTest.java From hazelcast-simulator with Apache License 2.0 | 6 votes |
@Setup public void setup() { counters = targetInstance.getList(name + "counters"); RecordingCacheLoader<Integer> loader = new RecordingCacheLoader<>(); loader.loadDelayMs = getDelayMs; RecordingCacheWriter<Integer, Integer> writer = new RecordingCacheWriter<>(); writer.writeDelayMs = putDelayMs; writer.deleteDelayMs = removeDelayMs; config = new CacheConfig<>(); config.setReadThrough(true); config.setWriteThrough(true); config.setCacheLoaderFactory(FactoryBuilder.factoryOf(loader)); config.setCacheWriterFactory(FactoryBuilder.factoryOf(writer)); CacheManager cacheManager = createCacheManager(targetInstance); cacheManager.createCache(name, config); cache = cacheManager.getCache(name); }
Example #3
Source File: OAuth2Test.java From openwebbeans-meecrowave with Apache License 2.0 | 6 votes |
private void createRedirectedClient(final int httpPort) throws URISyntaxException { final CachingProvider provider = Caching.getCachingProvider(); final CacheManager cacheManager = provider.getCacheManager( ClassLoaderUtils.getResource("default-oauth2.jcs", OAuth2Test.class).toURI(), Thread.currentThread().getContextClassLoader()); Cache<String, org.apache.cxf.rs.security.oauth2.common.Client> cache; try { cache = cacheManager .createCache(JCacheCodeDataProvider.CLIENT_CACHE_KEY, new MutableConfiguration<String, org.apache.cxf.rs.security.oauth2.common.Client>() .setTypes(String.class, org.apache.cxf.rs.security.oauth2.common.Client.class) .setStoreByValue(true)); } catch (final RuntimeException re) { cache = cacheManager.getCache(JCacheCodeDataProvider.CLIENT_CACHE_KEY, String.class, org.apache.cxf.rs.security.oauth2.common.Client.class); } final org.apache.cxf.rs.security.oauth2.common.Client value = new org.apache.cxf.rs.security.oauth2.common.Client("c1", "cpwd", true); value.setRedirectUris(singletonList("http://localhost:" + httpPort + "/redirected")); cache.put("c1", value); }
Example #4
Source File: CacheConfiguration.java From ehcache3-samples with Apache License 2.0 | 6 votes |
private CacheManager createInMemoryCacheManager() { long cacheSize = jHipsterProperties.getCache().getEhcache().getMaxEntries(); long ttl = jHipsterProperties.getCache().getEhcache().getTimeToLiveSeconds(); org.ehcache.config.CacheConfiguration<Object, Object> cacheConfiguration = CacheConfigurationBuilder .newCacheConfigurationBuilder(Object.class, Object.class, ResourcePoolsBuilder .heap(cacheSize)) .withExpiry(ExpiryPolicyBuilder.timeToLiveExpiration(Duration.ofSeconds(ttl))) .build(); Map<String, org.ehcache.config.CacheConfiguration<?, ?>> caches = createCacheConfigurations(cacheConfiguration); EhcacheCachingProvider provider = getCachingProvider(); DefaultConfiguration configuration = new DefaultConfiguration(caches, getClassLoader()); return getCacheManager(provider, configuration); }
Example #5
Source File: BlazingCacheProvider.java From blazingcache with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public synchronized void close(URI uri, ClassLoader classLoader) { URI managerURI = uri == null ? getDefaultURI() : uri; ClassLoader managerClassLoader = classLoader == null ? getDefaultClassLoader() : classLoader; HashMap<URI, BlazingCacheManager> cacheManagersByURI = cacheManagersByClassLoader.get(managerClassLoader); if (cacheManagersByURI != null) { CacheManager cacheManager = cacheManagersByURI.remove(managerURI); if (cacheManager != null) { cacheManager.close(); } if (cacheManagersByURI.size() == 0) { cacheManagersByClassLoader.remove(managerClassLoader); } } }
Example #6
Source File: TCKCacheManagerTest.java From blazingcache with Apache License 2.0 | 6 votes |
@Test public void shouldNotLoadWithNullKeyUsingLoadAll() throws Exception { HashSet<String> keys = new HashSet<>(); keys.add(null); try { CacheManager cacheManager = getCacheManager(); Cache<String, String> cache = cacheManager.createCache("test", new MutableConfiguration<String, String>()); CompletionListenerFuture future = new CompletionListenerFuture(); cache.loadAll(keys, false, future); fail("Expected a NullPointerException"); } catch (NullPointerException e) { //SKIP: expected } finally { // assertThat(cacheLoader.getLoadCount(), is(0)); } }
Example #7
Source File: CaffeineCachingProvider.java From caffeine with Apache License 2.0 | 6 votes |
@Override @SuppressWarnings("PMD.CloseResource") public void close(URI uri, ClassLoader classLoader) { synchronized (cacheManagers) { ClassLoader managerClassLoader = getManagerClassLoader(classLoader); Map<URI, CacheManager> cacheManagersByURI = cacheManagers.get(managerClassLoader); if (cacheManagersByURI != null) { CacheManager cacheManager = cacheManagersByURI.remove(getManagerUri(uri)); if (cacheManager != null) { cacheManager.close(); } if (cacheManagersByURI.isEmpty()) { cacheManagers.remove(managerClassLoader); } } } }
Example #8
Source File: TCKCacheManagerTest.java From blazingcache with Apache License 2.0 | 6 votes |
@Test public void jmxExampleTest() throws Exception { CachingProvider cachingProvider = Caching.getCachingProvider(); CacheManager cacheManager = cachingProvider.getCacheManager(); MutableConfiguration<String, Integer> config = new MutableConfiguration<String, Integer>(); config.setTypes(String.class, Integer.class) .setStatisticsEnabled(true); cacheManager.createCache("simpleCache", config); Cache<String, Integer> cache = cacheManager.getCache("simpleCache", String.class, Integer.class); cache.get("test"); MBeanServer mBeanServer = JMXUtils.getMBeanServer(); System.out.println("mBeanServer:" + mBeanServer); ObjectName objectName = new ObjectName("javax.cache:type=CacheStatistics" + ",CacheManager=" + (cache.getCacheManager().getURI().toString()) + ",Cache=" + cache.getName()); System.out.println("obhectNAme:" + objectName); // Thread.sleep(Integer.MAX_VALUE); Long CacheMisses = (Long) mBeanServer.getAttribute(objectName, "CacheMisses"); System.out.println("CacheMisses:" + CacheMisses); assertEquals(1L, CacheMisses.longValue()); }
Example #9
Source File: TCKCacheManagerTest.java From blazingcache with Apache License 2.0 | 6 votes |
@Test public void testReuseCacheManagerGetCache() throws Exception { CachingProvider provider = Caching.getCachingProvider(); URI uri = provider.getDefaultURI(); CacheManager cacheManager = provider.getCacheManager(uri, provider.getDefaultClassLoader()); assertFalse(cacheManager.isClosed()); cacheManager.close(); assertTrue(cacheManager.isClosed()); try { cacheManager.getCache("nonExistent", null, null); fail(); } catch (IllegalStateException e) { //expected } CacheManager otherCacheManager = provider.getCacheManager(uri, provider.getDefaultClassLoader()); assertFalse(otherCacheManager.isClosed()); assertNotSame(cacheManager, otherCacheManager); }
Example #10
Source File: CachingProviderClassLoaderTest.java From cache2k with Apache License 2.0 | 6 votes |
/** * Closing a single CacheManager from a CachingProvider when there are * multiple available across different ClassLoaders. */ @Test public void closeCacheManager() throws Exception { ClassLoader contextLoader = Thread.currentThread().getContextClassLoader(); CachingProvider provider = Caching.getCachingProvider(contextLoader); URI uri = provider.getDefaultURI(); ClassLoader loader1 = new MyClassLoader(contextLoader); CacheManager manager1 = provider.getCacheManager(uri, loader1); ClassLoader loader2 = new MyClassLoader(contextLoader); CacheManager manager2 = provider.getCacheManager(uri, loader2); ClassLoader loader3 = new MyClassLoader(contextLoader); CacheManager manager3 = provider.getCacheManager(uri, loader3); provider.close(manager2.getURI(), loader2); assertSame(manager1, provider.getCacheManager(uri, loader1)); assertNotSame(manager2, provider.getCacheManager(uri, loader2)); assertSame(manager3, provider.getCacheManager(uri, loader3)); }
Example #11
Source File: CacheTest.java From cache2k with Apache License 2.0 | 6 votes |
@Test public void testGetCacheManager() throws Exception { String cacheName = "SampleCache"; URI uri = Caching.getCachingProvider().getDefaultURI(); ClassLoader cl1 = Thread.currentThread().getContextClassLoader(); ClassLoader cl2 = URLClassLoader.newInstance(new URL[]{}, cl1); CacheManager cacheManager1 = Caching.getCachingProvider().getCacheManager(uri, cl1); CacheManager cacheManager2 = Caching.getCachingProvider().getCacheManager(uri, cl2); assertNotSame(cacheManager1, cacheManager2); cacheManager1.createCache(cacheName, new MutableConfiguration()); Cache cache1 = cacheManager1.getCache(cacheName); cacheManager2.createCache(cacheName, new MutableConfiguration()); Cache cache2 = cacheManager2.getCache(cacheName); assertSame(cacheManager1, cache1.getCacheManager()); assertSame(cacheManager2, cache2.getCacheManager()); }
Example #12
Source File: CacheConfiguration.java From ehcache3-samples with Apache License 2.0 | 5 votes |
private CacheManager createClusteredCacheManager() { ApplicationProperties.Cluster clusterProperties = applicationProperties.getCluster(); URI clusterUri = clusterProperties.getUri(); boolean autoCreate = clusterProperties.isAutoCreate(); long clusteredCacheSize = clusterProperties.getSizeInMb(); String offheapResourceName = clusterProperties.getOffheapResourceName(); Consistency consistency = clusterProperties.getConsistency(); long heapCacheSize = jHipsterProperties.getCache().getEhcache().getMaxEntries(); long ttl = jHipsterProperties.getCache().getEhcache().getTimeToLiveSeconds(); ClusteringServiceConfigurationBuilder clusteringServiceConfigurationBuilder = ClusteringServiceConfigurationBuilder.cluster(clusterUri); ServerSideConfigurationBuilder serverSideConfigurationBuilder = (autoCreate ? clusteringServiceConfigurationBuilder.autoCreate() : clusteringServiceConfigurationBuilder.expecting()) .defaultServerResource(offheapResourceName); org.ehcache.config.CacheConfiguration<Object, Object> cacheConfiguration = CacheConfigurationBuilder .newCacheConfigurationBuilder(Object.class, Object.class, ResourcePoolsBuilder .heap(heapCacheSize) .with(ClusteredResourcePoolBuilder.clusteredDedicated(clusteredCacheSize, MemoryUnit.MB))) .withExpiry(ExpiryPolicyBuilder.timeToLiveExpiration(Duration.ofSeconds(ttl))) .add(new ClusteredStoreConfiguration(consistency)).build(); Map<String, org.ehcache.config.CacheConfiguration<?, ?>> caches = createCacheConfigurations(cacheConfiguration); EhcacheCachingProvider provider = getCachingProvider(); DefaultConfiguration configuration = new DefaultConfiguration(caches, getClassLoader(), serverSideConfigurationBuilder.build()); return getCacheManager(provider, configuration); }
Example #13
Source File: CacheManagerTest.java From cache2k with Apache License 2.0 | 5 votes |
@Test public void create_empty_config() { CachingProvider p = Caching.getCachingProvider(); CacheManager cm = p.getCacheManager(); MutableConfiguration<String, BigDecimal> mc = new ExtendedMutableConfiguration<String, BigDecimal>(); mc.setTypes(String.class, BigDecimal.class); Cache<String, BigDecimal> c = cm.createCache("aCache", mc); assertEquals("aCache", c.getName()); assertEquals(String.class, c.getConfiguration(Configuration.class).getKeyType()); assertEquals(BigDecimal.class, c.getConfiguration(Configuration.class).getValueType()); c.close(); }
Example #14
Source File: JCacheEhCacheAnnotationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override protected ConfigurableApplicationContext getApplicationContext() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.getBeanFactory().registerSingleton("cachingProvider", getCachingProvider()); context.register(EnableCachingConfig.class); context.refresh(); jCacheManager = context.getBean("jCacheManager", CacheManager.class); return context; }
Example #15
Source File: CacheManagerTest.java From cache2k with Apache License 2.0 | 5 votes |
@Test public void getOrCreateCache_NullCacheName() { CacheManager cacheManager = getCacheManager(); try { cacheManager.createCache(null, new MutableConfiguration()); fail("should have thrown an exception - null cache name not allowed"); } catch (NullPointerException e) { //good } }
Example #16
Source File: CasICacheTest.java From hazelcast-simulator with Apache License 2.0 | 5 votes |
@Setup public void setup() { resultsPerWorker = targetInstance.getList(name); CacheManager cacheManager = createCacheManager(targetInstance); cache = cacheManager.getCache(name); }
Example #17
Source File: JCacheEhCacheAnnotationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Bean public CacheManager jCacheManager() { CacheManager cacheManager = this.cachingProvider.getCacheManager(); MutableConfiguration<Object, Object> mutableConfiguration = new MutableConfiguration<Object, Object>(); mutableConfiguration.setStoreByValue(false); // otherwise value has to be Serializable cacheManager.createCache("testCache", mutableConfiguration); cacheManager.createCache("primary", mutableConfiguration); cacheManager.createCache("secondary", mutableConfiguration); return cacheManager; }
Example #18
Source File: RepositoryCachingProvider.java From mobi with GNU Affero General Public License v3.0 | 5 votes |
@Override public void close(ClassLoader classLoader) { synchronized (cacheManagers) { ClassLoader managerClassLoader = getManagerClassLoader(classLoader); Map<URI, CacheManager> cacheManagersByURI = cacheManagers.remove(managerClassLoader); if (cacheManagersByURI != null) { for (CacheManager cacheManager : cacheManagersByURI.values()) { cacheManager.close(); } } } }
Example #19
Source File: EvictionICacheTest.java From hazelcast-simulator with Apache License 2.0 | 5 votes |
@Setup public void setup() { value = new byte[valueSize]; Random random = new Random(); random.nextBytes(value); CacheManager cacheManager = createCacheManager(targetInstance); cache = (ICache<Object, Object>) cacheManager.getCache(name); CacheConfig<Object, Object> config = cache.getConfiguration(CacheConfig.class); logger.info(name + ": " + cache.getName() + " config: " + config); configuredMaxSize = config.getEvictionConfig().getSize(); // we are explicitly using a random key so that all participants of the test do not put keys 0...max // the size of putAllMap is not guarantied to be configuredMaxSize / 2 as keys are random for (int i = 0; i < configuredMaxSize / 2; i++) { putAllMap.put(random.nextInt(), value); } if (configuredMaxSize < 1000) { toleranceFactor = TOLERANCE_FACTOR_SMALL; } else if (configuredMaxSize < 10000) { toleranceFactor = TOLERANCE_FACTOR_MEDIUM; } else { toleranceFactor = TOLERANCE_FACTOR_LARGE; } estimatedMaxSize = (int) (configuredMaxSize * toleranceFactor); }
Example #20
Source File: EntitlementBaseCache.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
/** * Getting existing cache if the cache available, else returns a newly created cache. * This logic handles by javax.cache implementation * * @return */ private Cache<K, V> getEntitlementCache() { Cache<K, V> cache = null; CacheManager cacheManager = Caching.getCacheManagerFactory().getCacheManager(ENTITLEMENT_CACHE_MANAGER); if (this.cacheTimeout > 0) { if (cacheBuilder == null) { synchronized (Entitlement_CACHE_NAME.intern()) { if (cacheBuilder == null) { cacheManager.removeCache(Entitlement_CACHE_NAME); this.cacheBuilder = cacheManager.<K, V>createCacheBuilder(Entitlement_CACHE_NAME). setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration.Duration(TimeUnit.SECONDS, cacheTimeout)). setStoreByValue(false); cache = cacheBuilder.build(); if (cacheEntryUpdatedListener != null) { this.cacheBuilder.registerCacheEntryListener(cacheEntryUpdatedListener); } if (cacheEntryCreatedListener != null) { this.cacheBuilder.registerCacheEntryListener(cacheEntryCreatedListener); } if (log.isDebugEnabled()) { String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); log.debug("Cache : " + Entitlement_CACHE_NAME + " is built with time out value " + ": " + cacheTimeout + " for tenant domain : " + tenantDomain); } } } } else { cache = cacheManager.getCache(Entitlement_CACHE_NAME); } } else { cache = cacheManager.getCache(Entitlement_CACHE_NAME); } return cache; }
Example #21
Source File: DeviceManagerUtil.java From carbon-device-mgt with Apache License 2.0 | 5 votes |
public static void initializeDeviceCache() { DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); int deviceCacheExpiry = config.getDeviceCacheConfiguration().getExpiryTime(); long deviceCacheCapacity = config.getDeviceCacheConfiguration().getCapacity(); CacheManager manager = getCacheManager(); if (config.getDeviceCacheConfiguration().isEnabled()) { if(!isDeviceCacheInitialized) { isDeviceCacheInitialized = true; if (manager != null) { if (deviceCacheExpiry > 0) { manager.<DeviceCacheKey, Device>createCacheBuilder(DeviceManagementConstants.DEVICE_CACHE). setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration.Duration(TimeUnit.SECONDS, deviceCacheExpiry)).setExpiry(CacheConfiguration.ExpiryType.ACCESSED, new CacheConfiguration. Duration(TimeUnit.SECONDS, deviceCacheExpiry)).setStoreByValue(true).build(); if(deviceCacheCapacity > 0 ) { ((CacheImpl)(manager.<DeviceCacheKey, Device>getCache(DeviceManagementConstants.DEVICE_CACHE))). setCapacity(deviceCacheCapacity); } } else { manager.<DeviceCacheKey, Device>getCache(DeviceManagementConstants.DEVICE_CACHE); } } else { if (deviceCacheExpiry > 0) { Caching.getCacheManager(). <DeviceCacheKey, Device>createCacheBuilder(DeviceManagementConstants.DEVICE_CACHE). setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration.Duration(TimeUnit.SECONDS, deviceCacheExpiry)).setExpiry(CacheConfiguration.ExpiryType.ACCESSED, new CacheConfiguration. Duration(TimeUnit.SECONDS, deviceCacheExpiry)).setStoreByValue(true).build(); ((CacheImpl)(manager.<DeviceCacheKey, Device>getCache(DeviceManagementConstants.DEVICE_CACHE))). setCapacity(deviceCacheCapacity); } else { Caching.getCacheManager().<DeviceCacheKey, Device>getCache(DeviceManagementConstants.DEVICE_CACHE); } } } } }
Example #22
Source File: CacheListenerTestBase.java From triava with Apache License 2.0 | 5 votes |
/** * Returns a CacheManager * @return */ public synchronized CacheManager cacheManager() { if (cacheManager == null) { CachingProvider cachingProvider = Caching.getCachingProvider(); cacheManager = cachingProvider.getCacheManager(); } return cacheManager; }
Example #23
Source File: CsCaching107Provider.java From demo_cache with Apache License 2.0 | 5 votes |
public void releaseCacheManager(URI uri, ClassLoader classLoader) { if (uri == null || classLoader == null) { throw new NullPointerException("uri or classLoader should not be null"); } ConcurrentMap<URI, CacheManager> cacheManagersByURI = cacheManagers.get(classLoader); if (cacheManagersByURI != null) { cacheManagersByURI.remove(uri); if (cacheManagersByURI.size() == 0) { cacheManagers.remove(classLoader); } } }
Example #24
Source File: CacheManagerTest.java From cache2k with Apache License 2.0 | 5 votes |
@Test public void createCache_NullCacheConfiguration() { CacheManager cacheManager = getCacheManager(); try { cacheManager.createCache("cache", null); fail("should have thrown an exception - null cache configuration not allowed"); } catch (NullPointerException e) { //good } }
Example #25
Source File: CachingTest.java From cache2k with Apache License 2.0 | 5 votes |
/** * Multiple invocations of {@link CachingProvider#getCacheManager()} return the same CacheManager */ @Test public void getCacheManager_singleton() { CachingProvider provider = Caching.getCachingProvider(); CacheManager manager = provider.getCacheManager(); manager.getProperties(); assertNotNull(manager); assertSame(manager, provider.getCacheManager()); }
Example #26
Source File: CacheManagerTest.java From cache2k with Apache License 2.0 | 5 votes |
@Test public void removeCache_CacheStopped() { CacheManager cacheManager = getCacheManager(); String name1 = "c1"; cacheManager.createCache(name1, new MutableConfiguration()); Cache cache1 = cacheManager.getCache(name1); cacheManager.destroyCache(name1); ensureClosed(cache1); }
Example #27
Source File: OpenJPAJCacheDataCache.java From commons-jcs with Apache License 2.0 | 5 votes |
@Override protected void clearInternal() { final CacheManager cacheManager = manager.getCacheManager(); for (final String cacheName : cacheManager.getCacheNames()) { if (!cacheName.startsWith(OPENJPA_PREFIX)) { continue; } cacheManager.getCache(cacheName).clear(); } }
Example #28
Source File: JCSCachingProvider.java From commons-jcs with Apache License 2.0 | 5 votes |
@Override public CacheManager getCacheManager(final URI inUri, final ClassLoader inClassLoader, final Properties properties) { final URI uri = inUri != null ? inUri : getDefaultURI(); final ClassLoader classLoader = inClassLoader != null ? inClassLoader : getDefaultClassLoader(); ConcurrentMap<URI, CacheManager> managers = cacheManagersByLoader.get(classLoader); if (managers == null) { managers = new ConcurrentHashMap<>(); final ConcurrentMap<URI, CacheManager> existingManagers = cacheManagersByLoader.putIfAbsent(classLoader, managers); if (existingManagers != null) { managers = existingManagers; } } CacheManager mgr = managers.get(uri); if (mgr == null) { mgr = new JCSCachingManager(this, uri, classLoader, properties); final CacheManager existing = managers.putIfAbsent(uri, mgr); if (existing != null) { mgr = existing; } } return mgr; }
Example #29
Source File: CacheLoaderIntegrationTest.java From tutorials with MIT License | 5 votes |
@Before public void setup() { // Adding fully qualified class name because of multiple Cache Provider (Ignite and Hazelcast) CachingProvider cachingProvider = Caching.getCachingProvider("com.hazelcast.cache.HazelcastCachingProvider"); CacheManager cacheManager = cachingProvider.getCacheManager(); MutableConfiguration<Integer, String> config = new MutableConfiguration<Integer, String>().setReadThrough(true).setCacheLoaderFactory(new FactoryBuilder.SingletonFactory<>(new SimpleCacheLoader())); this.cache = cacheManager.createCache("SimpleCache", config); }
Example #30
Source File: EhCacheManagerProviderTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test @Ignore("Disabled due to https://github.com/ehcache/ehcache-jcache/issues/40") public void preconfiguredCacheWithEternal() { CacheManager cacheManager = underTest.get(); log(cacheManager); assertThat(cacheManager, notNullValue()); Cache<Object,Object> cache = cacheManager.getCache("testEternalCache", Object.class, Object.class); log(cache); assertThat(cache, notNullValue()); //log(JCacheConfiguration.class.getProtectionDomain().getCodeSource().getLocation()); //JCacheConfiguration config = (JCacheConfiguration) cache.getConfiguration(JCacheConfiguration.class); //log(config.getExpiryPolicy().getExpiryForAccess()); //log(config.getExpiryPolicy().getExpiryForAccess().isEternal()); //log(config.getExpiryPolicy().getExpiryForAccess().isZero()); Object key = "foo"; Object value = "bar"; Object result = cache.getAndPut(key, value); log(result); assertThat(result, nullValue()); result = cache.get(key); log(result); assertThat(result, is(value)); result = cache.get(key); log(result); assertThat(result, is(value)); result = cache.get(key); log(result); assertThat(result, is(value)); }