@Override public Repository connect( String repositoryName ) throws KettleException { IPentahoSession session = PentahoSessionHolder.getSession(); if ( session == null ) { logger.debug( "No active Pentaho Session, attempting to load PDI repository unauthenticated." ); throw new KettleException( "Attempting to create PDI Repository with no Active PentahoSession. " + "This is not allowed." ); } ICacheManager cacheManager = PentahoSystem.getCacheManager( session ); String sessionName = session.getName(); Repository repository = (Repository) cacheManager.getFromRegionCache( REGION, sessionName ); if ( repository == null ) { logger.debug( "Repository not cached for user: " + sessionName + ". Creating new Repository." ); repository = delegate.connect( repositoryName ); if ( !cacheManager.cacheEnabled( REGION ) ) { cacheManager.addCacheRegion( REGION ); } cacheManager.putInRegionCache( REGION, sessionName, repository ); } else { logger.debug( "Repository was cached for user: " + sessionName ); } return repository; } }
@Override protected ICacheManager addCacheRegions( ) { ICacheManager cacheManager = super.addCacheRegions(); if ( !cacheManager.cacheEnabled( IDBDatasourceService.JDBC_POOL ) ) { cacheManager.addCacheRegion( IDBDatasourceService.JDBC_POOL ); } return cacheManager; }
public AbstractJcrBackedRoleBindingDao() { cacheManager = PentahoSystem.getCacheManager( null ); if ( !cacheManager.cacheEnabled( LOGICAL_ROLE_BINDINGS_REGION ) ) { cacheManager.addCacheRegion( LOGICAL_ROLE_BINDINGS_REGION ); } }
if ( !cacheManager.cacheEnabled( USER_CACHE_REGION ) ) { cacheManager.addCacheRegion( USER_CACHE_REGION ); if ( !cacheManager.cacheEnabled( ROLE_CACHE_REGION ) ) { cacheManager.addCacheRegion( ROLE_CACHE_REGION );
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; }
public DataSource getDataSource( String dsName ) throws DBDatasourceServiceException { DataSource dataSource = null; if ( cacheManager != null ) { if ( !cacheManager.cacheEnabled( IDBDatasourceService.JDBC_DATASOURCE ) ) { cacheManager.addCacheRegion( IDBDatasourceService.JDBC_DATASOURCE ); } Object foundDs = cacheManager.getFromRegionCache( IDBDatasourceService.JDBC_DATASOURCE, dsName ); if ( foundDs != null ) { dataSource = (DataSource) foundDs; } else { dataSource = retrieve( dsName ); } } return dataSource; }
@Override public void onReload() { if ( !loaded ) { setAuthorizationActions( PentahoSystem.getAll( IAuthorizationAction.class ) ); updateImmutableRoleBindingNames(); // when immutableRoleBindingNames gets updated, we should ensure no stale logical roles remain cached if ( cacheManager.cacheEnabled( LOGICAL_ROLE_BINDINGS_REGION ) ) { cacheManager.removeRegionCache( LOGICAL_ROLE_BINDINGS_REGION ); } loaded = true; } } } );
@Test public void testDao() throws Exception { ICacheManager cm = mock( ICacheManager.class ); PentahoSystem.registerObject( cm, IPentahoRegistrableObjectFactory.Types.INTERFACES ); when( cm.cacheEnabled( "roleBindingCache" ) ).thenReturn( false ); new AbstractJcrBackedRoleBindingDaoImpl(); verify( cm, times( 1 ) ).addCacheRegion( "roleBindingCache"); }