當前位置: 首頁>>代碼示例>>Java>>正文


Java CacheManager.removeCache方法代碼示例

本文整理匯總了Java中javax.cache.CacheManager.removeCache方法的典型用法代碼示例。如果您正苦於以下問題:Java CacheManager.removeCache方法的具體用法?Java CacheManager.removeCache怎麽用?Java CacheManager.removeCache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.cache.CacheManager的用法示例。


在下文中一共展示了CacheManager.removeCache方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getEntitlementCache

import javax.cache.CacheManager; //導入方法依賴的package包/類
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;
}
 
開發者ID:wso2,項目名稱:carbon-identity-framework,代碼行數:40,代碼來源:EntitlementEngineCache.java

示例2: getEntitlementCache

import javax.cache.CacheManager; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:wso2,項目名稱:carbon-identity-framework,代碼行數:43,代碼來源:EntitlementBaseCache.java

示例3: getBaseCache

import javax.cache.CacheManager; //導入方法依賴的package包/類
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;
    }
 
開發者ID:wso2,項目名稱:carbon-identity-framework,代碼行數:37,代碼來源:BaseCache.java

示例4: getBaseCache

import javax.cache.CacheManager; //導入方法依賴的package包/類
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;
    }
 
開發者ID:wso2,項目名稱:carbon-identity-framework,代碼行數:52,代碼來源:BaseCache.java


注:本文中的javax.cache.CacheManager.removeCache方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。