HHH-9762 - Complete deprecation of Settings contract

This commit is contained in:
Steve Ebersole 2015-05-05 18:00:37 -05:00
parent 9bfd65e370
commit da1fcbbfb7
41 changed files with 128 additions and 113 deletions

View File

@ -25,6 +25,7 @@ package org.hibernate.cache.internal;
import java.util.Properties;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.NoCacheRegionFactoryAvailableException;
import org.hibernate.cache.spi.CacheDataDescription;
@ -35,7 +36,6 @@ import org.hibernate.cache.spi.QueryResultsRegion;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.TimestampsRegion;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cfg.Settings;
/**
* Factory used if no caching enabled in config...
@ -55,7 +55,7 @@ public class NoCachingRegionFactory implements RegionFactory {
}
@Override
public void start(Settings settings, Properties properties) throws CacheException {
public void start(SessionFactoryOptions settings, Properties properties) throws CacheException {
}
@Override

View File

@ -32,12 +32,13 @@ import javax.persistence.EntityNotFoundException;
import org.hibernate.HibernateException;
import org.hibernate.UnresolvableObjectException;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.spi.QueryCache;
import org.hibernate.cache.spi.QueryKey;
import org.hibernate.cache.spi.QueryResultsRegion;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.UpdateTimestampsCache;
import org.hibernate.cfg.Settings;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.type.Type;
@ -75,7 +76,7 @@ public class StandardQueryCache implements QueryCache {
* @param regionName The base query cache region name
*/
public StandardQueryCache(
final Settings settings,
final SessionFactoryOptions settings,
final Properties props,
final UpdateTimestampsCache updateTimestampsCache,
final String regionName) {
@ -89,7 +90,10 @@ public class StandardQueryCache implements QueryCache {
}
LOG.startingQueryCache( regionNameToUse );
this.cacheRegion = settings.getRegionFactory().buildQueryResultsRegion( regionNameToUse, props );
this.cacheRegion = settings.getServiceRegistry().getService( RegionFactory.class ).buildQueryResultsRegion(
regionNameToUse,
props
);
this.updateTimestampsCache = updateTimestampsCache;
}

View File

@ -26,10 +26,10 @@ package org.hibernate.cache.internal;
import java.util.Properties;
import org.hibernate.HibernateException;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.spi.QueryCache;
import org.hibernate.cache.spi.QueryCacheFactory;
import org.hibernate.cache.spi.UpdateTimestampsCache;
import org.hibernate.cfg.Settings;
/**
* Standard Hibernate implementation of the QueryCacheFactory interface. Returns instances of
@ -45,7 +45,7 @@ public class StandardQueryCacheFactory implements QueryCacheFactory {
public QueryCache getQueryCache(
final String regionName,
final UpdateTimestampsCache updateTimestampsCache,
final Settings settings,
final SessionFactoryOptions settings,
final Properties props) throws HibernateException {
return new StandardQueryCache(settings, props, updateTimestampsCache, regionName);
}

View File

@ -25,7 +25,7 @@ package org.hibernate.cache.spi;
import java.util.Properties;
import org.hibernate.cfg.Settings;
import org.hibernate.boot.spi.SessionFactoryOptions;
/**
* Defines a factory for query cache instances. These factories are responsible for
@ -47,6 +47,6 @@ public interface QueryCacheFactory {
public QueryCache getQueryCache(
String regionName,
UpdateTimestampsCache updateTimestampsCache,
Settings settings,
SessionFactoryOptions settings,
Properties props);
}

View File

@ -25,20 +25,20 @@ package org.hibernate.cache.spi;
import java.util.Properties;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cfg.Settings;
import org.hibernate.service.Service;
/**
* Contract for building second level cache regions.
* <p/>
* Implementors should define a constructor in one of two forms:<ul>
* <li>MyRegionFactoryImpl({@link java.util.Properties})</li>
* <li>MyRegionFactoryImpl()</li>
* <li>MyRegionFactoryImpl({@link java.util.Properties})</li>
* <li>MyRegionFactoryImpl()</li>
* </ul>
* Use the first when we need to read config properties prior to
* {@link #start(Settings, Properties)} being called.
* {@link #start(SessionFactoryOptions, Properties)} being called.
*
* @author Steve Ebersole
*/
@ -56,7 +56,7 @@ public interface RegionFactory extends Service {
* considered as a sign to stop {@link org.hibernate.SessionFactory}
* building.
*/
public void start(Settings settings, Properties properties) throws CacheException;
public void start(SessionFactoryOptions settings, Properties properties) throws CacheException;
/**
* Lifecycle callback to perform any necessary cleanup of the underlying

View File

@ -27,8 +27,8 @@ import java.io.Serializable;
import java.util.Properties;
import java.util.Set;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cfg.Settings;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.internal.CoreMessageLogger;
@ -64,13 +64,14 @@ public class UpdateTimestampsCache {
* @param props Any properties
* @param factory The SessionFactory
*/
public UpdateTimestampsCache(Settings settings, Properties props, final SessionFactoryImplementor factory) {
public UpdateTimestampsCache(SessionFactoryOptions settings, Properties props, final SessionFactoryImplementor factory) {
this.factory = factory;
final String prefix = settings.getCacheRegionPrefix();
final String regionName = prefix == null ? REGION_NAME : prefix + '.' + REGION_NAME;
LOG.startingUpdateTimestampsCache( regionName );
this.region = settings.getRegionFactory().buildTimestampsRegion( regionName, props );
this.region = settings.getServiceRegistry().getService( RegionFactory.class ).buildTimestampsRegion( regionName, props );
}
/**
@ -80,7 +81,7 @@ public class UpdateTimestampsCache {
* @param props Any properties
*/
@SuppressWarnings({"UnusedDeclaration"})
public UpdateTimestampsCache(Settings settings, Properties props) {
public UpdateTimestampsCache(SessionFactoryOptions settings, Properties props) {
this( settings, props, null );
}

View File

@ -31,7 +31,7 @@ import java.sql.Statement;
import org.hibernate.AssertionFailure;
import org.hibernate.ScrollMode;
import org.hibernate.cfg.Settings;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
import org.hibernate.engine.jdbc.spi.StatementPreparer;
@ -56,8 +56,8 @@ class StatementPreparerImpl implements StatementPreparer {
this.jdbcCoordinator = jdbcCoordinator;
}
protected final Settings settings() {
return jdbcCoordinator.sessionFactory().getSettings();
protected final SessionFactoryOptions settings() {
return jdbcCoordinator.sessionFactory().getSessionFactoryOptions();
}
protected final Connection connection() {

View File

@ -247,6 +247,10 @@ public interface SessionFactoryImplementor extends Mapping, SessionFactory {
*/
public SqlExceptionHelper getSQLExceptionHelper();
/**
* @deprecated Use {@link #getSessionFactoryOptions()} instead
*/
@Deprecated
public Settings getSettings();
/**

View File

@ -31,12 +31,12 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.hibernate.HibernateException;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.spi.CacheKey;
import org.hibernate.cache.spi.QueryCache;
import org.hibernate.cache.spi.Region;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.UpdateTimestampsCache;
import org.hibernate.cfg.Settings;
import org.hibernate.engine.spi.CacheImplementor;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.util.collections.CollectionHelper;
@ -55,7 +55,7 @@ public class CacheImpl implements CacheImplementor {
CacheImpl.class.getName()
);
private final SessionFactoryImplementor sessionFactory;
private final Settings settings;
private final SessionFactoryOptions settings;
private final transient QueryCache queryCache;
private final transient RegionFactory regionFactory;
private final transient UpdateTimestampsCache updateTimestampsCache;
@ -64,9 +64,9 @@ public class CacheImpl implements CacheImplementor {
public CacheImpl(SessionFactoryImplementor sessionFactory) {
this.sessionFactory = sessionFactory;
this.settings = sessionFactory.getSettings();
this.settings = sessionFactory.getSessionFactoryOptions();
//todo should get this from service registry
this.regionFactory = settings.getRegionFactory();
this.regionFactory = settings.getServiceRegistry().getService( RegionFactory.class );
regionFactory.start( settings, sessionFactory.getProperties() );
if ( settings.isQueryCacheEnabled() ) {
updateTimestampsCache = new UpdateTimestampsCache(

View File

@ -767,6 +767,7 @@ public final class SessionFactoryImpl
return result;
}
@Deprecated
public Settings getSettings() {
return settings;
}

View File

@ -31,6 +31,7 @@ import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Ehcache;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.ehcache.internal.nonstop.NonstopAccessStrategyFactory;
import org.hibernate.cache.ehcache.internal.regions.EhcacheCollectionRegion;
@ -50,7 +51,6 @@ import org.hibernate.cache.spi.QueryResultsRegion;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.TimestampsRegion;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cfg.Settings;
import org.hibernate.service.spi.InjectService;
import org.jboss.logging.Logger;
@ -93,7 +93,7 @@ abstract class AbstractEhcacheRegionFactory implements RegionFactory {
/**
* Settings object for the Hibernate persistence unit.
*/
protected Settings settings;
protected SessionFactoryOptions settings;
/**
* {@link EhcacheAccessStrategyFactory} for creating various access strategies

View File

@ -30,9 +30,9 @@ import net.sf.ehcache.CacheManager;
import net.sf.ehcache.config.Configuration;
import net.sf.ehcache.config.ConfigurationFactory;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.ehcache.internal.util.HibernateEhcacheUtils;
import org.hibernate.cfg.Settings;
import org.jboss.logging.Logger;
@ -69,7 +69,7 @@ public class EhCacheRegionFactory extends AbstractEhcacheRegionFactory {
}
@Override
public void start(Settings settings, Properties properties) throws CacheException {
public void start(SessionFactoryOptions settings, Properties properties) throws CacheException {
this.settings = settings;
if ( manager != null ) {
LOG.attemptToRestartAlreadyStartedEhCacheProvider();

View File

@ -31,9 +31,9 @@ import java.util.concurrent.atomic.AtomicInteger;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.config.Configuration;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.ehcache.internal.util.HibernateEhcacheUtils;
import org.hibernate.cfg.Settings;
import org.jboss.logging.Logger;
@ -71,7 +71,7 @@ public class SingletonEhCacheRegionFactory extends AbstractEhcacheRegionFactory
}
@Override
public void start(Settings settings, Properties properties) throws CacheException {
public void start(SessionFactoryOptions settings, Properties properties) throws CacheException {
this.settings = settings;
try {
String configurationResourceName = null;

View File

@ -28,13 +28,13 @@ import java.util.Properties;
import net.sf.ehcache.Ehcache;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.ehcache.internal.strategy.EhcacheAccessStrategyFactory;
import org.hibernate.cache.spi.CacheDataDescription;
import org.hibernate.cache.spi.CollectionRegion;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy;
import org.hibernate.cfg.Settings;
/**
* A collection region specific wrapper around an Ehcache instance.
@ -59,7 +59,7 @@ public class EhcacheCollectionRegion extends EhcacheTransactionalDataRegion impl
public EhcacheCollectionRegion(
EhcacheAccessStrategyFactory accessStrategyFactory,
Ehcache underlyingCache,
Settings settings,
SessionFactoryOptions settings,
CacheDataDescription metadata,
Properties properties) {
super( accessStrategyFactory, underlyingCache, settings, metadata, properties );

View File

@ -27,13 +27,13 @@ import java.util.Properties;
import net.sf.ehcache.Ehcache;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.ehcache.internal.strategy.EhcacheAccessStrategyFactory;
import org.hibernate.cache.spi.CacheDataDescription;
import org.hibernate.cache.spi.EntityRegion;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cache.spi.access.EntityRegionAccessStrategy;
import org.hibernate.cfg.Settings;
/**
* An entity region specific wrapper around an Ehcache instance.
@ -58,7 +58,7 @@ public class EhcacheEntityRegion extends EhcacheTransactionalDataRegion implemen
public EhcacheEntityRegion(
EhcacheAccessStrategyFactory accessStrategyFactory,
Ehcache underlyingCache,
Settings settings,
SessionFactoryOptions settings,
CacheDataDescription metadata,
Properties properties) {
super( accessStrategyFactory, underlyingCache, settings, metadata, properties );

View File

@ -28,13 +28,13 @@ import java.util.Properties;
import net.sf.ehcache.Ehcache;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.ehcache.internal.strategy.EhcacheAccessStrategyFactory;
import org.hibernate.cache.spi.CacheDataDescription;
import org.hibernate.cache.spi.NaturalIdRegion;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy;
import org.hibernate.cfg.Settings;
/**
* A collection region specific wrapper around an Ehcache instance.
@ -59,7 +59,7 @@ public class EhcacheNaturalIdRegion extends EhcacheTransactionalDataRegion imple
public EhcacheNaturalIdRegion(
EhcacheAccessStrategyFactory accessStrategyFactory,
Ehcache underlyingCache,
Settings settings,
SessionFactoryOptions settings,
CacheDataDescription metadata,
Properties properties) {
super( accessStrategyFactory, underlyingCache, settings, metadata, properties );

View File

@ -32,12 +32,12 @@ import net.sf.ehcache.concurrent.LockType;
import net.sf.ehcache.concurrent.StripedReadWriteLockSync;
import net.sf.ehcache.constructs.nonstop.NonStopCacheException;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.ehcache.internal.nonstop.HibernateNonstopCacheExceptionHandler;
import org.hibernate.cache.ehcache.internal.strategy.EhcacheAccessStrategyFactory;
import org.hibernate.cache.spi.CacheDataDescription;
import org.hibernate.cache.spi.TransactionalDataRegion;
import org.hibernate.cfg.Settings;
/**
* An Ehcache specific TransactionalDataRegion.
@ -53,7 +53,7 @@ import org.hibernate.cfg.Settings;
public class EhcacheTransactionalDataRegion extends EhcacheDataRegion implements TransactionalDataRegion {
private static final int LOCAL_LOCK_PROVIDER_CONCURRENCY = 128;
private final Settings settings;
private final SessionFactoryOptions settings;
/**
* Metadata associated with the objects stored in the region.
@ -66,7 +66,7 @@ public class EhcacheTransactionalDataRegion extends EhcacheDataRegion implements
* Construct an transactional Hibernate cache region around the given Ehcache instance.
*/
EhcacheTransactionalDataRegion(
EhcacheAccessStrategyFactory accessStrategyFactory, Ehcache cache, Settings settings,
EhcacheAccessStrategyFactory accessStrategyFactory, Ehcache cache, SessionFactoryOptions settings,
CacheDataDescription metadata, Properties properties) {
super( accessStrategyFactory, cache, properties );
this.settings = settings;
@ -86,7 +86,7 @@ public class EhcacheTransactionalDataRegion extends EhcacheDataRegion implements
*
* @return settings
*/
public Settings getSettings() {
public SessionFactoryOptions getSettings() {
return settings;
}

View File

@ -23,10 +23,10 @@
*/
package org.hibernate.cache.ehcache.internal.strategy;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.ehcache.internal.regions.EhcacheTransactionalDataRegion;
import org.hibernate.cache.spi.access.SoftLock;
import org.hibernate.cfg.Settings;
/**
* Ultimate superclass for all Ehcache specific Hibernate AccessStrategy implementations.
@ -38,7 +38,7 @@ import org.hibernate.cfg.Settings;
*/
abstract class AbstractEhcacheAccessStrategy<T extends EhcacheTransactionalDataRegion> {
private final T region;
private final Settings settings;
private final SessionFactoryOptions settings;
/**
* Create an access strategy wrapping the given region.
@ -46,7 +46,7 @@ abstract class AbstractEhcacheAccessStrategy<T extends EhcacheTransactionalDataR
* @param region The wrapped region. Accessible to subclasses via {@link #region()}
* @param settings The Hibernate settings. Accessible to subclasses via {@link #settings()}
*/
AbstractEhcacheAccessStrategy(T region, Settings settings) {
AbstractEhcacheAccessStrategy(T region, SessionFactoryOptions settings) {
this.region = region;
this.settings = settings;
}
@ -61,7 +61,7 @@ abstract class AbstractEhcacheAccessStrategy<T extends EhcacheTransactionalDataR
/**
* The settings for this persistence unit.
*/
protected Settings settings() {
protected SessionFactoryOptions settings() {
return settings;
}

View File

@ -28,11 +28,11 @@ import java.util.Comparator;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.ehcache.EhCacheMessageLogger;
import org.hibernate.cache.ehcache.internal.regions.EhcacheTransactionalDataRegion;
import org.hibernate.cache.spi.access.SoftLock;
import org.hibernate.cfg.Settings;
import org.jboss.logging.Logger;
@ -61,7 +61,7 @@ abstract class AbstractReadWriteEhcacheAccessStrategy<T
/**
* Creates a read/write cache access strategy around the given cache region.
*/
public AbstractReadWriteEhcacheAccessStrategy(T region, Settings settings) {
public AbstractReadWriteEhcacheAccessStrategy(T region, SessionFactoryOptions settings) {
super( region, settings );
this.versionComparator = region.getCacheDataDescription().getVersionComparator();
}

View File

@ -23,12 +23,12 @@
*/
package org.hibernate.cache.ehcache.internal.strategy;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.ehcache.internal.regions.EhcacheCollectionRegion;
import org.hibernate.cache.spi.CollectionRegion;
import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy;
import org.hibernate.cache.spi.access.SoftLock;
import org.hibernate.cfg.Settings;
/**
* Ehcache specific non-strict read/write collection region access strategy
@ -46,7 +46,7 @@ public class NonStrictReadWriteEhcacheCollectionRegionAccessStrategy
* @param region The wrapped region
* @param settings The Hibernate settings
*/
public NonStrictReadWriteEhcacheCollectionRegionAccessStrategy(EhcacheCollectionRegion region, Settings settings) {
public NonStrictReadWriteEhcacheCollectionRegionAccessStrategy(EhcacheCollectionRegion region, SessionFactoryOptions settings) {
super( region, settings );
}

View File

@ -23,12 +23,12 @@
*/
package org.hibernate.cache.ehcache.internal.strategy;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.ehcache.internal.regions.EhcacheEntityRegion;
import org.hibernate.cache.spi.EntityRegion;
import org.hibernate.cache.spi.access.EntityRegionAccessStrategy;
import org.hibernate.cache.spi.access.SoftLock;
import org.hibernate.cfg.Settings;
/**
* Ehcache specific non-strict read/write entity region access strategy
@ -46,7 +46,7 @@ public class NonStrictReadWriteEhcacheEntityRegionAccessStrategy
* @param region The wrapped region
* @param settings The Hibernate settings
*/
public NonStrictReadWriteEhcacheEntityRegionAccessStrategy(EhcacheEntityRegion region, Settings settings) {
public NonStrictReadWriteEhcacheEntityRegionAccessStrategy(EhcacheEntityRegion region, SessionFactoryOptions settings) {
super( region, settings );
}

View File

@ -23,12 +23,12 @@
*/
package org.hibernate.cache.ehcache.internal.strategy;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.ehcache.internal.regions.EhcacheNaturalIdRegion;
import org.hibernate.cache.spi.NaturalIdRegion;
import org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy;
import org.hibernate.cache.spi.access.SoftLock;
import org.hibernate.cfg.Settings;
/**
* Ehcache specific non-strict read/write NaturalId region access strategy
@ -46,7 +46,7 @@ public class NonStrictReadWriteEhcacheNaturalIdRegionAccessStrategy
* @param region The wrapped region
* @param settings The Hibernate settings
*/
public NonStrictReadWriteEhcacheNaturalIdRegionAccessStrategy(EhcacheNaturalIdRegion region, Settings settings) {
public NonStrictReadWriteEhcacheNaturalIdRegionAccessStrategy(EhcacheNaturalIdRegion region, SessionFactoryOptions settings) {
super( region, settings );
}

View File

@ -23,12 +23,12 @@
*/
package org.hibernate.cache.ehcache.internal.strategy;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.ehcache.internal.regions.EhcacheCollectionRegion;
import org.hibernate.cache.spi.CollectionRegion;
import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy;
import org.hibernate.cache.spi.access.SoftLock;
import org.hibernate.cfg.Settings;
/**
* Ehcache specific read-only collection region access strategy
@ -46,7 +46,7 @@ public class ReadOnlyEhcacheCollectionRegionAccessStrategy
* @param region The wrapped region
* @param settings The Hibernate settings
*/
public ReadOnlyEhcacheCollectionRegionAccessStrategy(EhcacheCollectionRegion region, Settings settings) {
public ReadOnlyEhcacheCollectionRegionAccessStrategy(EhcacheCollectionRegion region, SessionFactoryOptions settings) {
super( region, settings );
}

View File

@ -23,12 +23,12 @@
*/
package org.hibernate.cache.ehcache.internal.strategy;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.ehcache.internal.regions.EhcacheEntityRegion;
import org.hibernate.cache.spi.EntityRegion;
import org.hibernate.cache.spi.access.EntityRegionAccessStrategy;
import org.hibernate.cache.spi.access.SoftLock;
import org.hibernate.cfg.Settings;
/**
* Ehcache specific read-only entity region access strategy
@ -45,7 +45,7 @@ public class ReadOnlyEhcacheEntityRegionAccessStrategy extends AbstractEhcacheAc
* @param region The wrapped region
* @param settings The Hibernate settings
*/
public ReadOnlyEhcacheEntityRegionAccessStrategy(EhcacheEntityRegion region, Settings settings) {
public ReadOnlyEhcacheEntityRegionAccessStrategy(EhcacheEntityRegion region, SessionFactoryOptions settings) {
super( region, settings );
}

View File

@ -23,12 +23,12 @@
*/
package org.hibernate.cache.ehcache.internal.strategy;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.ehcache.internal.regions.EhcacheNaturalIdRegion;
import org.hibernate.cache.spi.NaturalIdRegion;
import org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy;
import org.hibernate.cache.spi.access.SoftLock;
import org.hibernate.cfg.Settings;
/**
* Ehcache specific read-only NaturalId region access strategy
@ -46,7 +46,7 @@ public class ReadOnlyEhcacheNaturalIdRegionAccessStrategy
* @param region THe wrapped region
* @param settings The Hibermate settings
*/
public ReadOnlyEhcacheNaturalIdRegionAccessStrategy(EhcacheNaturalIdRegion region, Settings settings) {
public ReadOnlyEhcacheNaturalIdRegionAccessStrategy(EhcacheNaturalIdRegion region, SessionFactoryOptions settings) {
super( region, settings );
}

View File

@ -23,10 +23,10 @@
*/
package org.hibernate.cache.ehcache.internal.strategy;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.ehcache.internal.regions.EhcacheCollectionRegion;
import org.hibernate.cache.spi.CollectionRegion;
import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy;
import org.hibernate.cfg.Settings;
/**
* Ehcache specific read/write collection region access strategy
@ -44,7 +44,7 @@ public class ReadWriteEhcacheCollectionRegionAccessStrategy
* @param region The wrapped region
* @param settings The Hibernate settings
*/
public ReadWriteEhcacheCollectionRegionAccessStrategy(EhcacheCollectionRegion region, Settings settings) {
public ReadWriteEhcacheCollectionRegionAccessStrategy(EhcacheCollectionRegion region, SessionFactoryOptions settings) {
super( region, settings );
}

View File

@ -23,12 +23,12 @@
*/
package org.hibernate.cache.ehcache.internal.strategy;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.ehcache.internal.regions.EhcacheEntityRegion;
import org.hibernate.cache.spi.EntityRegion;
import org.hibernate.cache.spi.access.EntityRegionAccessStrategy;
import org.hibernate.cache.spi.access.SoftLock;
import org.hibernate.cfg.Settings;
/**
* Ehcache specific read/write entity region access strategy
@ -46,7 +46,7 @@ public class ReadWriteEhcacheEntityRegionAccessStrategy
* @param region The wrapped region
* @param settings The Hibernate settings
*/
public ReadWriteEhcacheEntityRegionAccessStrategy(EhcacheEntityRegion region, Settings settings) {
public ReadWriteEhcacheEntityRegionAccessStrategy(EhcacheEntityRegion region, SessionFactoryOptions settings) {
super( region, settings );
}

View File

@ -23,12 +23,12 @@
*/
package org.hibernate.cache.ehcache.internal.strategy;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.ehcache.internal.regions.EhcacheNaturalIdRegion;
import org.hibernate.cache.spi.NaturalIdRegion;
import org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy;
import org.hibernate.cache.spi.access.SoftLock;
import org.hibernate.cfg.Settings;
/**
* Ehcache specific read/write NaturalId region access strategy
@ -46,7 +46,7 @@ public class ReadWriteEhcacheNaturalIdRegionAccessStrategy
* @param region The wrapped region
* @param settings The Hibernate settings
*/
public ReadWriteEhcacheNaturalIdRegionAccessStrategy(EhcacheNaturalIdRegion region, Settings settings) {
public ReadWriteEhcacheNaturalIdRegionAccessStrategy(EhcacheNaturalIdRegion region, SessionFactoryOptions settings) {
super( region, settings );
}

View File

@ -26,12 +26,12 @@ package org.hibernate.cache.ehcache.internal.strategy;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.ehcache.internal.regions.EhcacheCollectionRegion;
import org.hibernate.cache.spi.CollectionRegion;
import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy;
import org.hibernate.cache.spi.access.SoftLock;
import org.hibernate.cfg.Settings;
/**
* JTA CollectionRegionAccessStrategy.
@ -56,7 +56,7 @@ public class TransactionalEhcacheCollectionRegionAccessStrategy
public TransactionalEhcacheCollectionRegionAccessStrategy(
EhcacheCollectionRegion region,
Ehcache ehcache,
Settings settings) {
SessionFactoryOptions settings) {
super( region, settings );
this.ehcache = ehcache;
}

View File

@ -26,12 +26,12 @@ package org.hibernate.cache.ehcache.internal.strategy;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.ehcache.internal.regions.EhcacheEntityRegion;
import org.hibernate.cache.spi.EntityRegion;
import org.hibernate.cache.spi.access.EntityRegionAccessStrategy;
import org.hibernate.cache.spi.access.SoftLock;
import org.hibernate.cfg.Settings;
/**
* JTA EntityRegionAccessStrategy.
@ -55,7 +55,7 @@ public class TransactionalEhcacheEntityRegionAccessStrategy extends AbstractEhca
public TransactionalEhcacheEntityRegionAccessStrategy(
EhcacheEntityRegion region,
Ehcache ehcache,
Settings settings) {
SessionFactoryOptions settings) {
super( region, settings );
this.ehcache = ehcache;
}

View File

@ -26,12 +26,12 @@ package org.hibernate.cache.ehcache.internal.strategy;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.ehcache.internal.regions.EhcacheNaturalIdRegion;
import org.hibernate.cache.spi.NaturalIdRegion;
import org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy;
import org.hibernate.cache.spi.access.SoftLock;
import org.hibernate.cfg.Settings;
/**
* JTA NaturalIdRegionAccessStrategy.
@ -56,7 +56,7 @@ public class TransactionalEhcacheNaturalIdRegionAccessStrategy
public TransactionalEhcacheNaturalIdRegionAccessStrategy(
EhcacheNaturalIdRegion region,
Ehcache ehcache,
Settings settings) {
SessionFactoryOptions settings) {
super( region, settings );
this.ehcache = ehcache;
}

View File

@ -1,7 +1,7 @@
package org.hibernate.cache.ehcache.internal.strategy;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.ehcache.internal.regions.EhcacheTransactionalDataRegion;
import org.hibernate.cfg.Settings;
/**
@ -13,7 +13,7 @@ public class ItemValueExtractor extends AbstractReadWriteEhcacheAccessStrategy {
/**
* Creates a read/write cache access strategy around the given cache region.
*/
public ItemValueExtractor(EhcacheTransactionalDataRegion region, Settings settings) {
public ItemValueExtractor(EhcacheTransactionalDataRegion region, SessionFactoryOptions settings) {
super(region, settings);
}

View File

@ -14,6 +14,7 @@ import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.infinispan.collection.CollectionRegionImpl;
import org.hibernate.cache.infinispan.entity.EntityRegionImpl;
@ -34,7 +35,6 @@ import org.hibernate.cache.spi.QueryResultsRegion;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.TimestampsRegion;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cfg.Settings;
import org.hibernate.internal.util.ClassLoaderHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
@ -316,7 +316,7 @@ public class InfinispanRegionFactory implements RegionFactory {
}
@Override
public void start(Settings settings, Properties properties) throws CacheException {
public void start(SessionFactoryOptions settings, Properties properties) throws CacheException {
log.debug( "Starting Infinispan region factory" );
try {
transactionManagerlookup = createTransactionManagerLookup( settings, properties );
@ -358,7 +358,7 @@ public class InfinispanRegionFactory implements RegionFactory {
}
protected org.infinispan.transaction.lookup.TransactionManagerLookup createTransactionManagerLookup(
Settings settings, Properties properties) {
SessionFactoryOptions settings, Properties properties) {
return new HibernateTransactionManagerLookup( settings, properties );
}

View File

@ -24,7 +24,7 @@ package org.hibernate.cache.infinispan.tm;
import java.util.Properties;
import javax.transaction.TransactionManager;
import org.hibernate.cfg.Settings;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
/**
@ -43,8 +43,8 @@ public class HibernateTransactionManagerLookup implements org.infinispan.transac
* @param settings for the Hibernate application
* @param properties for the Hibernate application
*/
public HibernateTransactionManagerLookup(Settings settings, Properties properties) {
this.jtaPlatform = settings != null ? settings.getJtaPlatform() : null;
public HibernateTransactionManagerLookup(SessionFactoryOptions settings, Properties properties) {
this.jtaPlatform = settings != null ? settings.getServiceRegistry().getService( JtaPlatform.class ) : null;
}
@Override

View File

@ -24,7 +24,21 @@ package org.hibernate.test.cache.infinispan;
import java.util.Properties;
import javax.transaction.TransactionManager;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cache.infinispan.collection.CollectionRegionImpl;
import org.hibernate.cache.infinispan.entity.EntityRegionImpl;
import org.hibernate.cache.infinispan.query.QueryResultsRegionImpl;
import org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl;
import org.hibernate.cache.infinispan.tm.HibernateTransactionManagerLookup;
import org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform;
import org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJtaPlatform;
import org.hibernate.testing.ServiceRegistryBuilder;
import org.hibernate.test.cache.infinispan.functional.SingleNodeTestCase;
import org.junit.Test;
import org.infinispan.AdvancedCache;
import org.infinispan.configuration.cache.CacheMode;
import org.infinispan.configuration.cache.Configuration;
@ -34,19 +48,6 @@ import org.infinispan.eviction.EvictionStrategy;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.test.TestingUtil;
import org.junit.Test;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cache.infinispan.collection.CollectionRegionImpl;
import org.hibernate.cache.infinispan.entity.EntityRegionImpl;
import org.hibernate.cache.infinispan.query.QueryResultsRegionImpl;
import org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl;
import org.hibernate.cache.infinispan.tm.HibernateTransactionManagerLookup;
import org.hibernate.cfg.Settings;
import org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform;
import org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJtaPlatform;
import org.hibernate.testing.ServiceRegistryBuilder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@ -554,7 +555,7 @@ public class InfinispanRegionFactoryTestCase {
final InfinispanRegionFactory factory = new SingleNodeTestCase.TestInfinispanRegionFactory() {
@Override
protected org.infinispan.transaction.lookup.TransactionManagerLookup createTransactionManagerLookup(Settings settings, Properties properties) {
protected org.infinispan.transaction.lookup.TransactionManagerLookup createTransactionManagerLookup(SessionFactoryOptions settings, Properties properties) {
return new HibernateTransactionManagerLookup(null, null) {
@Override
public TransactionManager getTransactionManager() throws Exception {

View File

@ -24,6 +24,7 @@ package org.hibernate.test.cache.infinispan.functional.cluster;
import java.util.Hashtable;
import java.util.Properties;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cache.spi.CacheDataDescription;
@ -34,8 +35,9 @@ import org.hibernate.cache.spi.QueryResultsRegion;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.TimestampsRegion;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cfg.Settings;
import org.hibernate.test.cache.infinispan.functional.SingleNodeTestCase;
import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
@ -78,7 +80,7 @@ public class ClusterAwareRegionFactory implements RegionFactory {
cacheManagers.clear();
}
public void start(Settings settings, Properties properties) throws CacheException {
public void start(SessionFactoryOptions settings, Properties properties) throws CacheException {
cacheManagerName = properties.getProperty(DualNodeTestCase.NODE_ID_PROP);
EmbeddedCacheManager existing = getCacheManager(cacheManagerName);

View File

@ -33,7 +33,6 @@ import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Settings;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.config.spi.StandardConverters;
import org.hibernate.service.ServiceRegistry;
@ -109,10 +108,9 @@ public class CacheTestUtil {
(StandardServiceRegistry) serviceRegistry
)
);
final Settings settings = new Settings( sessionFactoryOptions );
final Properties properties = toProperties( cfgService.getSettings() );
regionFactory.start( settings, properties );
regionFactory.start( sessionFactoryOptions, properties );
return regionFactory;
}

View File

@ -25,6 +25,7 @@ package org.hibernate.testing.cache;
import java.util.Properties;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.spi.CacheDataDescription;
import org.hibernate.cache.spi.CollectionRegion;
@ -34,7 +35,6 @@ import org.hibernate.cache.spi.QueryResultsRegion;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.TimestampsRegion;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cfg.Settings;
import org.hibernate.internal.CoreMessageLogger;
import org.jboss.logging.Logger;
@ -47,7 +47,7 @@ public class CachingRegionFactory implements RegionFactory {
CoreMessageLogger.class, CachingRegionFactory.class.getName()
);
public static String DEFAULT_ACCESSTYPE = "DefaultAccessType";
private Settings settings;
private SessionFactoryOptions settings;
private Properties properties;
public CachingRegionFactory() {
LOG.warn( "CachingRegionFactory should be only used for testing." );
@ -60,7 +60,7 @@ public class CachingRegionFactory implements RegionFactory {
}
@Override
public void start(Settings settings, Properties properties) throws CacheException {
public void start(SessionFactoryOptions settings, Properties properties) throws CacheException {
this.settings=settings;
this.properties=properties;
}

View File

@ -23,12 +23,12 @@
*/
package org.hibernate.testing.cache;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.spi.CacheDataDescription;
import org.hibernate.cache.spi.CollectionRegion;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy;
import org.hibernate.cfg.Settings;
import org.hibernate.internal.CoreMessageLogger;
import org.jboss.logging.Logger;
@ -40,13 +40,15 @@ class CollectionRegionImpl extends BaseTransactionalDataRegion implements Collec
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
CoreMessageLogger.class, CollectionRegionImpl.class.getName()
);
private final Settings settings;
CollectionRegionImpl(String name, CacheDataDescription metadata, Settings settings) {
private final SessionFactoryOptions settings;
CollectionRegionImpl(String name, CacheDataDescription metadata, SessionFactoryOptions settings) {
super( name, metadata );
this.settings=settings;
}
public Settings getSettings() {
public SessionFactoryOptions getSettings() {
return settings;
}

View File

@ -23,12 +23,12 @@
*/
package org.hibernate.testing.cache;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.spi.CacheDataDescription;
import org.hibernate.cache.spi.EntityRegion;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cache.spi.access.EntityRegionAccessStrategy;
import org.hibernate.cfg.Settings;
import org.hibernate.internal.CoreMessageLogger;
import org.jboss.logging.Logger;
@ -40,16 +40,16 @@ class EntityRegionImpl extends BaseTransactionalDataRegion implements EntityRegi
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
CoreMessageLogger.class, EntityRegionImpl.class.getName()
);
private final Settings settings;
private final SessionFactoryOptions settings;
EntityRegionImpl(String name, CacheDataDescription metadata, Settings settings) {
EntityRegionImpl(String name, CacheDataDescription metadata, SessionFactoryOptions settings) {
super( name, metadata );
this.settings = settings;
}
public Settings getSettings() {
public SessionFactoryOptions getSettings() {
return settings;
}

View File

@ -23,12 +23,12 @@
*/
package org.hibernate.testing.cache;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.spi.CacheDataDescription;
import org.hibernate.cache.spi.NaturalIdRegion;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy;
import org.hibernate.cfg.Settings;
import org.hibernate.internal.CoreMessageLogger;
import org.jboss.logging.Logger;
@ -40,13 +40,15 @@ class NaturalIdRegionImpl extends BaseTransactionalDataRegion implements Natural
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
CoreMessageLogger.class, NaturalIdRegionImpl.class.getName()
);
private final Settings settings;
NaturalIdRegionImpl(String name, CacheDataDescription metadata, Settings settings) {
private final SessionFactoryOptions settings;
NaturalIdRegionImpl(String name, CacheDataDescription metadata, SessionFactoryOptions settings) {
super( name, metadata );
this.settings=settings;
}
public Settings getSettings() {
public SessionFactoryOptions getSettings() {
return settings;
}