Skip to content

Commit

Permalink
HHH-5765 : Wire in dialect factory and resolvers from service registry
Browse files Browse the repository at this point in the history
  • Loading branch information
gbadner authored and galderz committed Jul 5, 2017
1 parent db6ba49 commit 37ace09
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 22 deletions.
Expand Up @@ -65,7 +65,7 @@ private void supportedAccessTypeTest() throws Exception {
String entityCfg = "entity"; String entityCfg = "entity";
cfg.setProperty(InfinispanRegionFactory.ENTITY_CACHE_RESOURCE_PROP, entityCfg); cfg.setProperty(InfinispanRegionFactory.ENTITY_CACHE_RESOURCE_PROP, entityCfg);
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory( InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
getConnectionProvider(), cfg, getCacheTestSupport() getJdbcServices(), cfg, getCacheTestSupport()
); );
supportedAccessTypeTest(regionFactory, cfg.getProperties()); supportedAccessTypeTest(regionFactory, cfg.getProperties());
} }
Expand All @@ -85,7 +85,7 @@ private void supportedAccessTypeTest() throws Exception {
public void testIsTransactionAware() throws Exception { public void testIsTransactionAware() throws Exception {
Configuration cfg = CacheTestUtil.buildConfiguration("test", InfinispanRegionFactory.class, true, false); Configuration cfg = CacheTestUtil.buildConfiguration("test", InfinispanRegionFactory.class, true, false);
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory( InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
getConnectionProvider(), cfg, getCacheTestSupport() getJdbcServices(), cfg, getCacheTestSupport()
); );
TransactionalDataRegion region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription()); TransactionalDataRegion region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription());
assertTrue("Region is transaction-aware", region.isTransactionAware()); assertTrue("Region is transaction-aware", region.isTransactionAware());
Expand All @@ -94,7 +94,7 @@ public void testIsTransactionAware() throws Exception {
// Make it non-transactional // Make it non-transactional
cfg.getProperties().remove(Environment.TRANSACTION_MANAGER_STRATEGY); cfg.getProperties().remove(Environment.TRANSACTION_MANAGER_STRATEGY);
regionFactory = CacheTestUtil.startRegionFactory( regionFactory = CacheTestUtil.startRegionFactory(
getConnectionProvider(), cfg, getCacheTestSupport() getJdbcServices(), cfg, getCacheTestSupport()
); );
region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription()); region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription());
assertFalse("Region is not transaction-aware", region.isTransactionAware()); assertFalse("Region is not transaction-aware", region.isTransactionAware());
Expand All @@ -104,7 +104,7 @@ public void testIsTransactionAware() throws Exception {
public void testGetCacheDataDescription() throws Exception { public void testGetCacheDataDescription() throws Exception {
Configuration cfg = CacheTestUtil.buildConfiguration("test", InfinispanRegionFactory.class, true, false); Configuration cfg = CacheTestUtil.buildConfiguration("test", InfinispanRegionFactory.class, true, false);
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory( InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
getConnectionProvider(), cfg, getCacheTestSupport() getJdbcServices(), cfg, getCacheTestSupport()
); );
TransactionalDataRegion region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription()); TransactionalDataRegion region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription());
CacheDataDescription cdd = region.getCacheDataDescription(); CacheDataDescription cdd = region.getCacheDataDescription();
Expand Down
Expand Up @@ -73,7 +73,7 @@ public void testEvict() throws Exception {
private void evictOrRemoveTest() throws Exception { private void evictOrRemoveTest() throws Exception {
Configuration cfg = createConfiguration(); Configuration cfg = createConfiguration();
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory( InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
getConnectionProvider(), cfg, getCacheTestSupport() getJdbcServices(), cfg, getCacheTestSupport()
); );
CacheAdapter localCache = getInfinispanCache(regionFactory); CacheAdapter localCache = getInfinispanCache(regionFactory);
boolean invalidation = localCache.isClusteredInvalidation(); boolean invalidation = localCache.isClusteredInvalidation();
Expand All @@ -86,7 +86,7 @@ private void evictOrRemoveTest() throws Exception {


cfg = createConfiguration(); cfg = createConfiguration();
regionFactory = CacheTestUtil.startRegionFactory( regionFactory = CacheTestUtil.startRegionFactory(
getConnectionProvider(), cfg, getCacheTestSupport() getJdbcServices(), cfg, getCacheTestSupport()
); );


GeneralDataRegion remoteRegion = (GeneralDataRegion) createRegion(regionFactory, GeneralDataRegion remoteRegion = (GeneralDataRegion) createRegion(regionFactory,
Expand Down Expand Up @@ -126,7 +126,7 @@ public void testEvictAll() throws Exception {
private void evictOrRemoveAllTest(String configName) throws Exception { private void evictOrRemoveAllTest(String configName) throws Exception {
Configuration cfg = createConfiguration(); Configuration cfg = createConfiguration();
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory( InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
getConnectionProvider(), cfg, getCacheTestSupport() getJdbcServices(), cfg, getCacheTestSupport()
); );
CacheAdapter localCache = getInfinispanCache(regionFactory); CacheAdapter localCache = getInfinispanCache(regionFactory);


Expand All @@ -138,7 +138,7 @@ private void evictOrRemoveAllTest(String configName) throws Exception {


cfg = createConfiguration(); cfg = createConfiguration();
regionFactory = CacheTestUtil.startRegionFactory( regionFactory = CacheTestUtil.startRegionFactory(
getConnectionProvider(), cfg, getCacheTestSupport() getJdbcServices(), cfg, getCacheTestSupport()
); );
CacheAdapter remoteCache = getInfinispanCache(regionFactory); CacheAdapter remoteCache = getInfinispanCache(regionFactory);


Expand Down
Expand Up @@ -548,13 +548,13 @@ protected void setUp() throws Exception {


localCfg = createConfiguration(configName, configResource); localCfg = createConfiguration(configName, configResource);
localRegionFactory = CacheTestUtil.startRegionFactory( localRegionFactory = CacheTestUtil.startRegionFactory(
serviceRegistryHolder.getJdbcServicesImpl().getConnectionProvider(), serviceRegistryHolder.getJdbcServicesImpl(),
localCfg localCfg
); );


remoteCfg = createConfiguration(configName, configResource); remoteCfg = createConfiguration(configName, configResource);
remoteRegionFactory = CacheTestUtil.startRegionFactory( remoteRegionFactory = CacheTestUtil.startRegionFactory(
serviceRegistryHolder.getJdbcServicesImpl().getConnectionProvider(), serviceRegistryHolder.getJdbcServicesImpl(),
remoteCfg remoteCfg
); );
} }
Expand Down
Expand Up @@ -55,7 +55,7 @@ protected void setUp() throws Exception {
if (getCollectionAccessStrategy() == null) { if (getCollectionAccessStrategy() == null) {
Configuration cfg = createConfiguration(); Configuration cfg = createConfiguration();
InfinispanRegionFactory rf = CacheTestUtil.startRegionFactory( InfinispanRegionFactory rf = CacheTestUtil.startRegionFactory(
getConnectionProvider(), cfg, getCacheTestSupport() getJdbcServices(), cfg, getCacheTestSupport()
); );


// Sleep a bit to avoid concurrent FLUSH problem // Sleep a bit to avoid concurrent FLUSH problem
Expand Down
Expand Up @@ -665,13 +665,13 @@ protected void setUp() throws Exception {


localCfg = createConfiguration(configName); localCfg = createConfiguration(configName);
localRegionFactory = CacheTestUtil.startRegionFactory( localRegionFactory = CacheTestUtil.startRegionFactory(
serviceRegistryHolder.getJdbcServicesImpl().getConnectionProvider(), serviceRegistryHolder.getJdbcServicesImpl(),
localCfg localCfg
); );


remoteCfg = createConfiguration(configName); remoteCfg = createConfiguration(configName);
remoteRegionFactory = CacheTestUtil.startRegionFactory( remoteRegionFactory = CacheTestUtil.startRegionFactory(
serviceRegistryHolder.getJdbcServicesImpl().getConnectionProvider(), serviceRegistryHolder.getJdbcServicesImpl(),
remoteCfg remoteCfg
); );
} }
Expand Down
Expand Up @@ -61,7 +61,7 @@ protected void setUp() throws Exception {
if (getEntityAccessStrategy() == null) { if (getEntityAccessStrategy() == null) {
Configuration cfg = createConfiguration(); Configuration cfg = createConfiguration();
InfinispanRegionFactory rf = CacheTestUtil.startRegionFactory( InfinispanRegionFactory rf = CacheTestUtil.startRegionFactory(
getConnectionProvider(), cfg, getCacheTestSupport() getJdbcServices(), cfg, getCacheTestSupport()
); );


// Sleep a bit to avoid concurrent FLUSH problem // Sleep a bit to avoid concurrent FLUSH problem
Expand Down
Expand Up @@ -91,7 +91,7 @@ public void testPutDoesNotBlockGet() throws Exception {
private void putDoesNotBlockGetTest() throws Exception { private void putDoesNotBlockGetTest() throws Exception {
Configuration cfg = createConfiguration(); Configuration cfg = createConfiguration();
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory( InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
getConnectionProvider(), cfg, getCacheTestSupport()); getJdbcServices(), cfg, getCacheTestSupport());


// Sleep a bit to avoid concurrent FLUSH problem // Sleep a bit to avoid concurrent FLUSH problem
avoidConcurrentFlush(); avoidConcurrentFlush();
Expand Down Expand Up @@ -177,7 +177,7 @@ public void testGetDoesNotBlockPut() throws Exception {
private void getDoesNotBlockPutTest() throws Exception { private void getDoesNotBlockPutTest() throws Exception {
Configuration cfg = createConfiguration(); Configuration cfg = createConfiguration();
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory( InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
getConnectionProvider(), cfg, getCacheTestSupport() getJdbcServices(), cfg, getCacheTestSupport()
); );


// Sleep a bit to avoid concurrent FLUSH problem // Sleep a bit to avoid concurrent FLUSH problem
Expand Down
Expand Up @@ -87,14 +87,14 @@ protected CacheAdapter getInfinispanCache(InfinispanRegionFactory regionFactory)
public void testClearTimestampsRegionInIsolated() throws Exception { public void testClearTimestampsRegionInIsolated() throws Exception {
Configuration cfg = createConfiguration(); Configuration cfg = createConfiguration();
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory( InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
getConnectionProvider(), cfg, getCacheTestSupport() getJdbcServices(), cfg, getCacheTestSupport()
); );
// Sleep a bit to avoid concurrent FLUSH problem // Sleep a bit to avoid concurrent FLUSH problem
avoidConcurrentFlush(); avoidConcurrentFlush();


Configuration cfg2 = createConfiguration(); Configuration cfg2 = createConfiguration();
InfinispanRegionFactory regionFactory2 = CacheTestUtil.startRegionFactory( InfinispanRegionFactory regionFactory2 = CacheTestUtil.startRegionFactory(
getConnectionProvider(), cfg2, getCacheTestSupport() getJdbcServices(), cfg2, getCacheTestSupport()
); );
// Sleep a bit to avoid concurrent FLUSH problem // Sleep a bit to avoid concurrent FLUSH problem
avoidConcurrentFlush(); avoidConcurrentFlush();
Expand Down
Expand Up @@ -36,6 +36,7 @@
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.cfg.Settings; import org.hibernate.cfg.Settings;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.spi.ServicesRegistry; import org.hibernate.service.spi.ServicesRegistry;


Expand Down Expand Up @@ -73,11 +74,11 @@ public static Configuration buildCustomQueryCacheConfiguration(String regionPref
return cfg; return cfg;
} }


public static InfinispanRegionFactory startRegionFactory(ConnectionProvider connectionProvider, public static InfinispanRegionFactory startRegionFactory(JdbcServices jdbcServices,
Configuration cfg) Configuration cfg)
throws ClassNotFoundException, InstantiationException, IllegalAccessException { throws ClassNotFoundException, InstantiationException, IllegalAccessException {


Settings settings = cfg.buildSettings( connectionProvider ); Settings settings = cfg.buildSettings( jdbcServices );
Properties properties = cfg.getProperties(); Properties properties = cfg.getProperties();


String factoryType = cfg.getProperty(Environment.CACHE_REGION_FACTORY); String factoryType = cfg.getProperty(Environment.CACHE_REGION_FACTORY);
Expand All @@ -89,11 +90,11 @@ public static InfinispanRegionFactory startRegionFactory(ConnectionProvider conn
return regionFactory; return regionFactory;
} }


public static InfinispanRegionFactory startRegionFactory(ConnectionProvider connectionProvider, public static InfinispanRegionFactory startRegionFactory(JdbcServices jdbcServices,
Configuration cfg, Configuration cfg,
CacheTestSupport testSupport) CacheTestSupport testSupport)
throws ClassNotFoundException, InstantiationException, IllegalAccessException { throws ClassNotFoundException, InstantiationException, IllegalAccessException {
InfinispanRegionFactory factory = startRegionFactory(connectionProvider, cfg); InfinispanRegionFactory factory = startRegionFactory(jdbcServices, cfg);
testSupport.registerFactory(factory); testSupport.registerFactory(factory);
return factory; return factory;
} }
Expand Down

0 comments on commit 37ace09

Please sign in to comment.