protected final String defaultRegionName(String regionName, SessionFactoryImplementor sessionFactory, String defaultRegionName, List<String> legacyDefaultRegionNames) { if ( defaultRegionName.equals( regionName ) && !cacheExists( regionName, sessionFactory ) ) { // Maybe the user configured caches explicitly with legacy names; try them and use the first that exists for ( String legacyDefaultRegionName : legacyDefaultRegionNames ) { if ( cacheExists( legacyDefaultRegionName, sessionFactory ) ) { SecondLevelCacheLogger.INSTANCE.usingLegacyCacheName( defaultRegionName, legacyDefaultRegionName ); return legacyDefaultRegionName; } } } return regionName; }
protected Ehcache createCache(String regionName) { switch ( missingCacheStrategy ) { case CREATE_WARN: SecondLevelCacheLogger.INSTANCE.missingCacheCreated( regionName, ConfigSettings.MISSING_CACHE_STRATEGY, MissingCacheStrategy.CREATE.getExternalRepresentation() ); cacheManager.addCache( regionName ); return cacheManager.getEhcache( regionName ); case CREATE: cacheManager.addCache( regionName ); return cacheManager.getEhcache( regionName ); case FAIL: throw new CacheException( "On-the-fly creation of Ehcache Cache objects is not supported [" + regionName + "]" ); default: throw new IllegalStateException( "Unsupported missing cache strategy: " + missingCacheStrategy ); } }
@Override public final void start(SessionFactoryOptions settings, Map configValues) throws CacheException { if ( started.compareAndSet( false, true ) ) { synchronized (this) { this.options = settings; try { prepareForUse( settings, configValues ); startingException = null; } catch ( Exception e ) { options = null; started.set( false ); startingException = e; } } } else { SecondLevelCacheLogger.INSTANCE.attemptToStartAlreadyStartedCacheProvider(); } }
@Override protected EntityDataAccess generateTransactionalEntityDataAccess(EntityDataCachingConfig entityAccessConfig) { SecondLevelCacheLogger.INSTANCE.nonStandardSupportForAccessType( getName(), AccessType.TRANSACTIONAL.getExternalName(), getRegionFactory().getClass().getSimpleName() ); return super.generateTransactionalEntityDataAccess( entityAccessConfig ); }
public EntityReadOnlyAccess( DomainDataRegion region, CacheKeysFactory cacheKeysFactory, DomainDataStorageAccess storageAccess, EntityDataCachingConfig config) { super( region, cacheKeysFactory, storageAccess ); if ( config.isMutable() ) { SecondLevelCacheLogger.INSTANCE.readOnlyCachingMutableEntity( config.getNavigableRole() ); } }
@SuppressWarnings("WeakerAccess") protected void handleLockExpiry(SharedSessionContractImplementor session, Object key, Lockable lock) { SecondLevelCacheLogger.INSTANCE.softLockedCacheExpired( getRegion().getName(), key ); log.info( "Cached entry expired : " + key ); // create new lock that times out immediately long ts = getRegion().getRegionFactory().nextTimestamp() + getRegion().getRegionFactory().getTimeout(); SoftLockImpl newLock = new SoftLockImpl( ts, uuid, nextLockId.getAndIncrement(), null ); //newLock.unlock( ts ); newLock.unlock( ts - getRegion().getRegionFactory().getTimeout() ); getStorageAccess().putIntoCache( key, newLock, session ); }
public NaturalIdReadOnlyAccess( DomainDataRegion region, CacheKeysFactory keysFactory, DomainDataStorageAccess storageAccess, NaturalIdDataCachingConfig config) { super( region, keysFactory, storageAccess, config ); if ( config.isMutable() ) { SecondLevelCacheLogger.INSTANCE.readOnlyCachingMutableNaturalId( config.getNavigableRole() ); } }
@Override public final void stop() { if ( started.compareAndSet( true, false ) ) { synchronized ( this ) { try { releaseFromUse(); } finally { options = null; startingException = null; } } } else { SecondLevelCacheLogger.INSTANCE.attemptToStopAlreadyStoppedCacheProvider(); } }
@Override protected CollectionDataAccess generateTransactionalCollectionDataAccess(CollectionDataCachingConfig accessConfig) { SecondLevelCacheLogger.INSTANCE.nonStandardSupportForAccessType( getName(), AccessType.TRANSACTIONAL.getExternalName(), getRegionFactory().getClass().getSimpleName() ); return super.generateTransactionalCollectionDataAccess( accessConfig ); } }
public EntityReadOnlyAccess( DomainDataRegion region, CacheKeysFactory cacheKeysFactory, DomainDataStorageAccess storageAccess, EntityDataCachingConfig config) { super( region, cacheKeysFactory, storageAccess ); if ( config.isMutable() ) { SecondLevelCacheLogger.INSTANCE.readOnlyCachingMutableEntity( config.getNavigableRole() ); } }
@SuppressWarnings("WeakerAccess") protected void handleLockExpiry(SharedSessionContractImplementor session, Object key, Lockable lock) { SecondLevelCacheLogger.INSTANCE.softLockedCacheExpired( getRegion().getName(), key ); log.info( "Cached entry expired : " + key ); // create new lock that times out immediately long ts = getRegion().getRegionFactory().nextTimestamp() + getRegion().getRegionFactory().getTimeout(); SoftLockImpl newLock = new SoftLockImpl( ts, uuid, nextLockId.getAndIncrement(), null ); //newLock.unlock( ts ); newLock.unlock( ts - getRegion().getRegionFactory().getTimeout() ); getStorageAccess().putIntoCache( key, newLock, session ); }
public NaturalIdReadOnlyAccess( DomainDataRegion region, CacheKeysFactory keysFactory, DomainDataStorageAccess storageAccess, NaturalIdDataCachingConfig config) { super( region, keysFactory, storageAccess, config ); if ( config.isMutable() ) { SecondLevelCacheLogger.INSTANCE.readOnlyCachingMutableNaturalId( config.getNavigableRole() ); } }
@Override public final void stop() { if ( started.compareAndSet( true, false ) ) { synchronized ( this ) { try { releaseFromUse(); } finally { options = null; startingException = null; } } } else { SecondLevelCacheLogger.INSTANCE.attemptToStopAlreadyStoppedCacheProvider(); } }
protected final String defaultRegionName(String regionName, SessionFactoryImplementor sessionFactory, String defaultRegionName, List<String> legacyDefaultRegionNames) { if ( defaultRegionName.equals( regionName ) && !cacheExists( regionName, sessionFactory ) ) { // Maybe the user configured caches explicitly with legacy names; try them and use the first that exists for ( String legacyDefaultRegionName : legacyDefaultRegionNames ) { if ( cacheExists( legacyDefaultRegionName, sessionFactory ) ) { SecondLevelCacheLogger.INSTANCE.usingLegacyCacheName( defaultRegionName, legacyDefaultRegionName ); return legacyDefaultRegionName; } } } return regionName; }
@SuppressWarnings("WeakerAccess") protected Cache<Object, Object> createCache(String regionName) { switch ( missingCacheStrategy ) { case CREATE_WARN: SecondLevelCacheLogger.INSTANCE.missingCacheCreated( regionName, ConfigSettings.MISSING_CACHE_STRATEGY, MissingCacheStrategy.CREATE.getExternalRepresentation() ); return cacheManager.createCache( regionName, new MutableConfiguration<>() ); case CREATE: return cacheManager.createCache( regionName, new MutableConfiguration<>() ); case FAIL: throw new CacheException( "On-the-fly creation of JCache Cache objects is not supported [" + regionName + "]" ); default: throw new IllegalStateException( "Unsupported missing cache strategy: " + missingCacheStrategy ); } }
@Override protected NaturalIdDataAccess generateTransactionalNaturalIdDataAccess(NaturalIdDataCachingConfig accessConfig) { SecondLevelCacheLogger.INSTANCE.nonStandardSupportForAccessType( getName(), AccessType.TRANSACTIONAL.getExternalName(), getRegionFactory().getClass().getSimpleName() ); return super.generateTransactionalNaturalIdDataAccess( accessConfig ); }
@Override public final void start(SessionFactoryOptions settings, Map configValues) throws CacheException { if ( started.compareAndSet( false, true ) ) { synchronized (this) { this.options = settings; try { prepareForUse( settings, configValues ); startingException = null; } catch ( Exception e ) { options = null; started.set( false ); startingException = e; } } } else { SecondLevelCacheLogger.INSTANCE.attemptToStartAlreadyStartedCacheProvider(); } }
protected final String defaultRegionName(String regionName, SessionFactoryImplementor sessionFactory, String defaultRegionName, List<String> legacyDefaultRegionNames) { if (defaultRegionName.equals(regionName) && !cacheExists(regionName, sessionFactory)) { for (String legacyDefaultRegionName : legacyDefaultRegionNames) { if (cacheExists(legacyDefaultRegionName, sessionFactory)) { SecondLevelCacheLogger.INSTANCE.usingLegacyCacheName(defaultRegionName, legacyDefaultRegionName); return legacyDefaultRegionName; } } } return regionName; }
@SuppressWarnings("WeakerAccess") protected Cache<Object, Object> createCache(String regionName) { switch ( missingCacheStrategy ) { case CREATE_WARN: SecondLevelCacheLogger.INSTANCE.missingCacheCreated( regionName, ConfigSettings.MISSING_CACHE_STRATEGY, MissingCacheStrategy.CREATE.getExternalRepresentation() ); return cacheManager.createCache( regionName, new MutableConfiguration<>() ); case CREATE: return cacheManager.createCache( regionName, new MutableConfiguration<>() ); case FAIL: throw new CacheException( "On-the-fly creation of JCache Cache objects is not supported [" + regionName + "]" ); default: throw new IllegalStateException( "Unsupported missing cache strategy: " + missingCacheStrategy ); } }
@Override protected NaturalIdDataAccess generateTransactionalNaturalIdDataAccess(NaturalIdDataCachingConfig accessConfig) { SecondLevelCacheLogger.INSTANCE.nonStandardSupportForAccessType( getName(), AccessType.TRANSACTIONAL.getExternalName(), getRegionFactory().getClass().getSimpleName() ); return super.generateTransactionalNaturalIdDataAccess( accessConfig ); }