/** * Returns a list of catalogs for the current session. * * <p>The cache is stored in the platform's caches in the region {@link #CATALOG_CACHE_REGION}. It * is also segmented by locale, but we only return the correct sub-region according to the session * passed as a parameter. */ @SuppressWarnings("unchecked") protected synchronized List<IOlapService.Catalog> getCache(IPentahoSession session) { // Create the cache region if necessary. final ICacheManager cacheMgr = PentahoSystem.getCacheManager(session); final Object cacheKey = makeCacheSubRegionKey(getLocale()); final Lock writeLock = cacheLock.writeLock(); try { writeLock.lock(); if (!cacheMgr.cacheEnabled(CATALOG_CACHE_REGION)) { // Create the region. This requires write access. cacheMgr.addCacheRegion(CATALOG_CACHE_REGION); } if (cacheMgr.getFromRegionCache(CATALOG_CACHE_REGION, cacheKey) == null) { // Create the sub-region. This requires write access. cacheMgr.putInRegionCache( CATALOG_CACHE_REGION, cacheKey, new ArrayList<IOlapService.Catalog>()); } return (List<IOlapService.Catalog>) cacheMgr.getFromRegionCache(CATALOG_CACHE_REGION, cacheKey); } finally { writeLock.unlock(); } }
public AbstractJcrBackedRoleBindingDao() { cacheManager = PentahoSystem.getCacheManager(null); if (!cacheManager.cacheEnabled(LOGICAL_ROLE_BINDINGS_REGION)) { cacheManager.addCacheRegion(LOGICAL_ROLE_BINDINGS_REGION); } }
/** Clears all caches for all locales. */ protected void resetCache(IPentahoSession session) { final Lock writeLock = cacheLock.writeLock(); try { writeLock.lock(); final ICacheManager cacheMgr = PentahoSystem.getCacheManager(session); cacheMgr.clearRegionCache(CATALOG_CACHE_REGION); } finally { writeLock.unlock(); } }
public void shutdown() { ICacheManager cacheManager = PentahoSystem.getCacheManager(null); Logger.debug(this, "DatasourceSystemListener: Called for shutdown ..."); // $NON-NLS-1$ cacheManager.removeRegionCache(IDBDatasourceService.JDBC_DATASOURCE); Logger.debug(this, "DatasourceSystemListener: Completed shutdown."); // $NON-NLS-1$ }
protected ICacheManager addCacheRegions() { ICacheManager cacheManager = PentahoSystem.getCacheManager(null); Logger.debug(this, "Adding caching regions ..."); // $NON-NLS-1$ if (!cacheManager.cacheEnabled(IDBDatasourceService.JDBC_DATASOURCE)) { cacheManager.addCacheRegion(IDBDatasourceService.JDBC_DATASOURCE); } return cacheManager; }
/** Wraps the provided domain repository to provide session-based caching of domains. */ public SessionCachingMetadataDomainRepository(final IMetadataDomainRepository delegate) { if (delegate == null) { throw new NullPointerException(); } this.delegate = delegate; cacheManager = PentahoSystem.getCacheManager(null); // cache manager gets loaded just once... if (cacheManager != null) { if (!cacheManager.cacheEnabled(CACHE_REGION)) { if (!cacheManager.addCacheRegion(CACHE_REGION)) { cacheManager = null; } } } if (cacheManager == null) { throw new IllegalStateException( getClass().getSimpleName() + " (" + CACHE_REGION + ") cannot be initialized"); //$NON-NLS-1$ //$NON-NLS-2$ } PentahoSystem.addLogoutListener( this); // So you can remove a users' region when their session disappears }