Java Code Examples for javax.cache.CacheManager#removeCache()
The following examples show how to use
javax.cache.CacheManager#removeCache() .
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: EntitlementEngineCache.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
private Cache<Integer, EntitlementEngine> getEntitlementCache() { Cache<Integer, EntitlementEngine> cache; CacheManager cacheManager = Caching.getCacheManagerFactory().getCacheManager(ENTITLEMENT_ENGINE_CACHE_MANAGER); if (cacheManager != null) { if (cacheBuilder == null) { Properties properties = EntitlementServiceComponent.getEntitlementConfig().getEngineProperties(); String engineCachingInterval = properties.getProperty(PDPConstants.ENTITLEMENT_ENGINE_CACHING_INTERVAL); long entitlementEngineCachingInterval = DEFAULT_ENTITLEMENT_ENGINE_CACHING_INTERVAL; if (engineCachingInterval != null) { try { entitlementEngineCachingInterval = Long.parseLong(engineCachingInterval); } catch (NumberFormatException e) { log.warn("Invalid value for " + PDPConstants.ENTITLEMENT_ENGINE_CACHING_INTERVAL + ". Using " + "default value " + entitlementEngineCachingInterval + " seconds."); } } else { if (log.isDebugEnabled()) { log.debug(PDPConstants.ENTITLEMENT_ENGINE_CACHING_INTERVAL + " not set. Using default value " + entitlementEngineCachingInterval + " seconds."); } } cacheManager.removeCache(ENTITLEMENT_ENGINE_CACHE); cacheBuilder = cacheManager.<Integer, EntitlementEngine>createCacheBuilder(ENTITLEMENT_ENGINE_CACHE). setExpiry(CacheConfiguration.ExpiryType.ACCESSED, new CacheConfiguration.Duration(TimeUnit.SECONDS, entitlementEngineCachingInterval)). setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration.Duration(TimeUnit.SECONDS, entitlementEngineCachingInterval)); cache = cacheBuilder.build(); } else { cache = cacheManager.getCache(ENTITLEMENT_ENGINE_CACHE); } } else { cache = Caching.getCacheManager().getCache(ENTITLEMENT_ENGINE_CACHE); } if (log.isDebugEnabled()) { log.debug("created authorization cache : " + cache); } return cache; }
Example 2
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 3
Source File: BaseCache.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
private Cache<K, V> getBaseCache() { Cache<K, V> cache; CacheManager cacheManager = Caching.getCacheManagerFactory() .getCacheManager(CACHE_MANAGER_NAME); if (getCacheTimeout() > 0 && cacheBuilder == null) { synchronized (cacheName.intern()) { if (cacheBuilder == null) { cacheManager.removeCache(cacheName); cacheBuilder = cacheManager.<K, V>createCacheBuilder(cacheName). setExpiry(CacheConfiguration.ExpiryType.ACCESSED, new CacheConfiguration .Duration(TimeUnit.SECONDS, getCacheTimeout())). setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration .Duration(TimeUnit.SECONDS, getCacheTimeout())). setStoreByValue(false); cache = cacheBuilder.build(); setCapacity((CacheImpl) cache); } else { cache = cacheManager.getCache(cacheName); setCapacity((CacheImpl) cache); } } } else { cache = cacheManager.getCache(cacheName); setCapacity((CacheImpl) cache); } return cache; }
Example 4
Source File: EntitlementEngineCache.java From carbon-identity with Apache License 2.0 | 5 votes |
private Cache<Integer, EntitlementEngine> getEntitlementCache() { Cache<Integer, EntitlementEngine> cache; CacheManager cacheManager = Caching.getCacheManagerFactory().getCacheManager(ENTITLEMENT_ENGINE_CACHE_MANAGER); if (cacheManager != null) { if (cacheBuilder == null) { Properties properties = EntitlementServiceComponent.getEntitlementConfig().getEngineProperties(); String engineCachingInterval = properties.getProperty(PDPConstants.ENTITLEMENT_ENGINE_CACHING_INTERVAL); long entitlementEngineCachingInterval = DEFAULT_ENTITLEMENT_ENGINE_CACHING_INTERVAL; if (engineCachingInterval != null) { try { entitlementEngineCachingInterval = Long.parseLong(engineCachingInterval); } catch (NumberFormatException e) { log.warn("Invalid value for " + PDPConstants.ENTITLEMENT_ENGINE_CACHING_INTERVAL + ". Using " + "default value " + entitlementEngineCachingInterval + " seconds."); } } else { if (log.isDebugEnabled()) { log.debug(PDPConstants.ENTITLEMENT_ENGINE_CACHING_INTERVAL + " not set. Using default value " + entitlementEngineCachingInterval + " seconds."); } } cacheManager.removeCache(ENTITLEMENT_ENGINE_CACHE); cacheBuilder = cacheManager.<Integer, EntitlementEngine>createCacheBuilder(ENTITLEMENT_ENGINE_CACHE). setExpiry(CacheConfiguration.ExpiryType.ACCESSED, new CacheConfiguration.Duration(TimeUnit.SECONDS, entitlementEngineCachingInterval)). setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration.Duration(TimeUnit.SECONDS, entitlementEngineCachingInterval)); cache = cacheBuilder.build(); } else { cache = cacheManager.getCache(ENTITLEMENT_ENGINE_CACHE); } } else { cache = Caching.getCacheManager().getCache(ENTITLEMENT_ENGINE_CACHE); } if (log.isDebugEnabled()) { log.debug("created authorization cache : " + cache); } return cache; }
Example 5
Source File: EntitlementBaseCache.java From carbon-identity 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 6
Source File: BaseCache.java From carbon-identity-framework with Apache License 2.0 | 4 votes |
private Cache<K, V> getBaseCache() { Cache<K, V> cache = null; try { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID); carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); CacheManager cacheManager = Caching.getCacheManagerFactory() .getCacheManager(CACHE_MANAGER_NAME); if (getCacheTimeout() > 0 && cacheBuilder == null) { synchronized (cacheName.intern()) { if (cacheBuilder == null) { cacheManager.removeCache(cacheName); cacheBuilder = cacheManager.<K, V>createCacheBuilder(cacheName). setExpiry(CacheConfiguration.ExpiryType.ACCESSED, new CacheConfiguration .Duration(TimeUnit.SECONDS, getCacheTimeout())). setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration .Duration(TimeUnit.SECONDS, getCacheTimeout())). setStoreByValue(false); cache = cacheBuilder.build(); for (AbstractCacheListener cacheListener : cacheListeners) { if (cacheListener.isEnable()) { this.cacheBuilder.registerCacheEntryListener(cacheListener); } } setCapacity((CacheImpl) cache); } else { cache = cacheManager.getCache(cacheName); setCapacity((CacheImpl) cache); } } } else { cache = cacheManager.getCache(cacheName); setCapacity((CacheImpl) cache); } } finally { PrivilegedCarbonContext.endTenantFlow(); } return cache; }
Example 7
Source File: BaseCache.java From carbon-identity with Apache License 2.0 | 4 votes |
private Cache<K, V> getBaseCache() { Cache<K, V> cache = null; try { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID); carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); CacheManager cacheManager = Caching.getCacheManagerFactory() .getCacheManager(CACHE_MANAGER_NAME); if (getCacheTimeout() > 0 && cacheBuilder == null) { synchronized (cacheName.intern()) { if (cacheBuilder == null) { cacheManager.removeCache(cacheName); cacheBuilder = cacheManager.<K, V>createCacheBuilder(cacheName). setExpiry(CacheConfiguration.ExpiryType.ACCESSED, new CacheConfiguration .Duration(TimeUnit.SECONDS, getCacheTimeout())). setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration .Duration(TimeUnit.SECONDS, getCacheTimeout())). setStoreByValue(false); cache = cacheBuilder.build(); for (AbstractCacheListener cacheListener : cacheListeners) { if (cacheListener.isEnable()) { this.cacheBuilder.registerCacheEntryListener(cacheListener); } } setCapacity((CacheImpl) cache); } else { cache = cacheManager.getCache(cacheName); setCapacity((CacheImpl) cache); } } } else { cache = cacheManager.getCache(cacheName); setCapacity((CacheImpl) cache); } } finally { PrivilegedCarbonContext.endTenantFlow(); } return cache; }