HHH-13090 Allow to use specific cache implementations in Ehcache cache provider
Typically, it allows to use a BlockingCache.
This commit is contained in:
parent
c17e4832a9
commit
736d9dd615
|
@ -11,7 +11,7 @@ import java.net.URL;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sf.ehcache.Cache;
|
||||
import net.sf.ehcache.Ehcache;
|
||||
import net.sf.ehcache.CacheManager;
|
||||
import net.sf.ehcache.config.Configuration;
|
||||
import net.sf.ehcache.config.ConfigurationFactory;
|
||||
|
@ -131,7 +131,7 @@ public class EhcacheRegionFactory extends RegionFactoryTemplate {
|
|||
return regionName;
|
||||
}
|
||||
|
||||
protected Cache getOrCreateCache(String unqualifiedRegionName, SessionFactoryImplementor sessionFactory) {
|
||||
protected Ehcache getOrCreateCache(String unqualifiedRegionName, SessionFactoryImplementor sessionFactory) {
|
||||
verifyStarted();
|
||||
assert !RegionNameQualifier.INSTANCE.isQualified( unqualifiedRegionName, sessionFactory.getSessionFactoryOptions() );
|
||||
|
||||
|
@ -140,14 +140,14 @@ public class EhcacheRegionFactory extends RegionFactoryTemplate {
|
|||
sessionFactory.getSessionFactoryOptions()
|
||||
);
|
||||
|
||||
final Cache cache = cacheManager.getCache( qualifiedRegionName );
|
||||
final Ehcache cache = cacheManager.getEhcache( qualifiedRegionName );
|
||||
if ( cache == null ) {
|
||||
return createCache( qualifiedRegionName );
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
|
||||
protected Cache createCache(String regionName) {
|
||||
protected Ehcache createCache(String regionName) {
|
||||
switch ( missingCacheStrategy ) {
|
||||
case CREATE_WARN:
|
||||
SecondLevelCacheLogger.INSTANCE.missingCacheCreated(
|
||||
|
@ -155,10 +155,10 @@ public class EhcacheRegionFactory extends RegionFactoryTemplate {
|
|||
ConfigSettings.MISSING_CACHE_STRATEGY, MissingCacheStrategy.CREATE.getExternalRepresentation()
|
||||
);
|
||||
cacheManager.addCache( regionName );
|
||||
return cacheManager.getCache( regionName );
|
||||
return cacheManager.getEhcache( regionName );
|
||||
case CREATE:
|
||||
cacheManager.addCache( regionName );
|
||||
return cacheManager.getCache( regionName );
|
||||
return cacheManager.getEhcache( regionName );
|
||||
case FAIL:
|
||||
throw new CacheException( "On-the-fly creation of Ehcache Cache objects is not supported [" + regionName + "]" );
|
||||
default:
|
||||
|
@ -171,13 +171,14 @@ public class EhcacheRegionFactory extends RegionFactoryTemplate {
|
|||
unqualifiedRegionName,
|
||||
sessionFactory.getSessionFactoryOptions()
|
||||
);
|
||||
return cacheManager.getCache( qualifiedRegionName ) != null;
|
||||
return cacheManager.getEhcache( qualifiedRegionName ) != null;
|
||||
}
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Lifecycle
|
||||
|
||||
@Override
|
||||
protected boolean isStarted() {
|
||||
return super.isStarted() && cacheManager != null;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
package org.hibernate.cache.ehcache.internal;
|
||||
|
||||
import net.sf.ehcache.Cache;
|
||||
import net.sf.ehcache.Ehcache;
|
||||
import net.sf.ehcache.Element;
|
||||
import net.sf.ehcache.constructs.nonstop.NonStopCacheException;
|
||||
import net.sf.ehcache.hibernate.nonstop.HibernateNonstopCacheExceptionHandler;
|
||||
|
@ -25,14 +25,14 @@ import org.jboss.logging.Logger;
|
|||
public class StorageAccessImpl implements DomainDataStorageAccess {
|
||||
private static final Logger LOG = Logger.getLogger( StorageAccessImpl.class );
|
||||
|
||||
private final Cache cache;
|
||||
private final Ehcache cache;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public StorageAccessImpl(Cache cache) {
|
||||
public StorageAccessImpl(Ehcache cache) {
|
||||
this.cache = cache;
|
||||
}
|
||||
|
||||
public Cache getCache() {
|
||||
public Ehcache getCache() {
|
||||
return cache;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue