提交 54eaba09 编写于 作者: N Nikita Koksharov

refactoring

上级 144391ff
......@@ -182,7 +182,7 @@ public class RedissonRegionFactory implements RegionFactory {
throws CacheException {
log.debug("Building entity cache region: " + regionName);
RMapCache<Object, Object> mapCache = getCache(regionName, properties);
RMapCache<Object, Object> mapCache = getCache(regionName, properties, ENTITY_DEF);
return new RedissonEntityRegion(mapCache, this, metadata, settings, properties, ENTITY_DEF);
}
......@@ -191,7 +191,7 @@ public class RedissonRegionFactory implements RegionFactory {
throws CacheException {
log.debug("Building naturalId cache region: " + regionName);
RMapCache<Object, Object> mapCache = getCache(regionName, properties);
RMapCache<Object, Object> mapCache = getCache(regionName, properties, NATURAL_ID_DEF);
return new RedissonNaturalIdRegion(mapCache, this, metadata, settings, properties, NATURAL_ID_DEF);
}
......@@ -200,7 +200,7 @@ public class RedissonRegionFactory implements RegionFactory {
CacheDataDescription metadata) throws CacheException {
log.debug("Building collection cache region: " + regionName);
RMapCache<Object, Object> mapCache = getCache(regionName, properties);
RMapCache<Object, Object> mapCache = getCache(regionName, properties, COLLECTION_DEF);
return new RedissonCollectionRegion(mapCache, this, metadata, settings, properties, COLLECTION_DEF);
}
......@@ -208,7 +208,7 @@ public class RedissonRegionFactory implements RegionFactory {
public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties) throws CacheException {
log.debug("Building query cache region: " + regionName);
RMapCache<Object, Object> mapCache = getCache(regionName, properties);
RMapCache<Object, Object> mapCache = getCache(regionName, properties, QUERY_DEF);
return new RedissonQueryRegion(mapCache, this, properties, QUERY_DEF);
}
......@@ -216,11 +216,11 @@ public class RedissonRegionFactory implements RegionFactory {
public TimestampsRegion buildTimestampsRegion(String regionName, Properties properties) throws CacheException {
log.debug("Building timestamps cache region: " + regionName);
RMapCache<Object, Object> mapCache = getCache(regionName, properties);
RMapCache<Object, Object> mapCache = getCache(regionName, properties, TIMESTAMPS_DEF);
return new RedissonTimestampsRegion(mapCache, this, properties, TIMESTAMPS_DEF);
}
protected RMapCache<Object, Object> getCache(String regionName, Properties properties) {
protected RMapCache<Object, Object> getCache(String regionName, Properties properties, String defaultKey) {
return redisson.getMapCache(regionName);
}
......
......@@ -183,7 +183,7 @@ public class RedissonRegionFactory implements RegionFactory {
throws CacheException {
log.debug("Building entity cache region: " + regionName);
RMapCache<Object, Object> mapCache = getCache(regionName, properties);
RMapCache<Object, Object> mapCache = getCache(regionName, properties, ENTITY_DEF);
return new RedissonEntityRegion(mapCache, this, metadata, settings, properties, ENTITY_DEF);
}
......@@ -192,7 +192,7 @@ public class RedissonRegionFactory implements RegionFactory {
throws CacheException {
log.debug("Building naturalId cache region: " + regionName);
RMapCache<Object, Object> mapCache = getCache(regionName, properties);
RMapCache<Object, Object> mapCache = getCache(regionName, properties, NATURAL_ID_DEF);
return new RedissonNaturalIdRegion(mapCache, this, metadata, settings, properties, NATURAL_ID_DEF);
}
......@@ -201,7 +201,7 @@ public class RedissonRegionFactory implements RegionFactory {
CacheDataDescription metadata) throws CacheException {
log.debug("Building collection cache region: " + regionName);
RMapCache<Object, Object> mapCache = getCache(regionName, properties);
RMapCache<Object, Object> mapCache = getCache(regionName, properties, COLLECTION_DEF);
return new RedissonCollectionRegion(mapCache, this, metadata, settings, properties, COLLECTION_DEF);
}
......@@ -209,7 +209,7 @@ public class RedissonRegionFactory implements RegionFactory {
public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties) throws CacheException {
log.debug("Building query cache region: " + regionName);
RMapCache<Object, Object> mapCache = getCache(regionName, properties);
RMapCache<Object, Object> mapCache = getCache(regionName, properties, QUERY_DEF);
return new RedissonQueryRegion(mapCache, this, properties, QUERY_DEF);
}
......@@ -217,11 +217,11 @@ public class RedissonRegionFactory implements RegionFactory {
public TimestampsRegion buildTimestampsRegion(String regionName, Properties properties) throws CacheException {
log.debug("Building timestamps cache region: " + regionName);
RMapCache<Object, Object> mapCache = getCache(regionName, properties);
RMapCache<Object, Object> mapCache = getCache(regionName, properties, TIMESTAMPS_DEF);
return new RedissonTimestampsRegion(mapCache, this, properties, TIMESTAMPS_DEF);
}
protected RMapCache<Object, Object> getCache(String regionName, Properties properties) {
protected RMapCache<Object, Object> getCache(String regionName, Properties properties, String defaultKey) {
return redisson.getMapCache(regionName);
}
......
......@@ -183,7 +183,7 @@ public class RedissonRegionFactory implements RegionFactory {
throws CacheException {
log.debug("Building entity cache region: " + regionName);
RMapCache<Object, Object> mapCache = getCache(regionName, properties);
RMapCache<Object, Object> mapCache = getCache(regionName, properties, ENTITY_DEF);
return new RedissonEntityRegion(mapCache, this, metadata, settings, properties, ENTITY_DEF);
}
......@@ -192,7 +192,7 @@ public class RedissonRegionFactory implements RegionFactory {
throws CacheException {
log.debug("Building naturalId cache region: " + regionName);
RMapCache<Object, Object> mapCache = getCache(regionName, properties);
RMapCache<Object, Object> mapCache = getCache(regionName, properties, NATURAL_ID_DEF);
return new RedissonNaturalIdRegion(mapCache, this, metadata, settings, properties, NATURAL_ID_DEF);
}
......@@ -201,7 +201,7 @@ public class RedissonRegionFactory implements RegionFactory {
CacheDataDescription metadata) throws CacheException {
log.debug("Building collection cache region: " + regionName);
RMapCache<Object, Object> mapCache = getCache(regionName, properties);
RMapCache<Object, Object> mapCache = getCache(regionName, properties, COLLECTION_DEF);
return new RedissonCollectionRegion(mapCache, this, metadata, settings, properties, COLLECTION_DEF);
}
......@@ -209,7 +209,7 @@ public class RedissonRegionFactory implements RegionFactory {
public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties) throws CacheException {
log.debug("Building query cache region: " + regionName);
RMapCache<Object, Object> mapCache = getCache(regionName, properties);
RMapCache<Object, Object> mapCache = getCache(regionName, properties, QUERY_DEF);
return new RedissonQueryRegion(mapCache, this, properties, QUERY_DEF);
}
......@@ -217,11 +217,11 @@ public class RedissonRegionFactory implements RegionFactory {
public TimestampsRegion buildTimestampsRegion(String regionName, Properties properties) throws CacheException {
log.debug("Building timestamps cache region: " + regionName);
RMapCache<Object, Object> mapCache = getCache(regionName, properties);
RMapCache<Object, Object> mapCache = getCache(regionName, properties, TIMESTAMPS_DEF);
return new RedissonTimestampsRegion(mapCache, this, properties, TIMESTAMPS_DEF);
}
protected RMapCache<Object, Object> getCache(String regionName, Properties properties) {
protected RMapCache<Object, Object> getCache(String regionName, Properties properties, String defaultKey) {
return redisson.getMapCache(regionName);
}
......
......@@ -33,7 +33,6 @@ import org.hibernate.cache.spi.support.RegionFactoryTemplate;
import org.hibernate.cache.spi.support.StorageAccess;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.jboss.logging.Logger;
import org.redisson.Redisson;
import org.redisson.api.RMapCache;
import org.redisson.api.RScript;
......@@ -48,8 +47,6 @@ import org.redisson.config.Config;
*/
public class RedissonRegionFactory extends RegionFactoryTemplate {
private static final Logger log = Logger.getLogger( RedissonRegionFactory.class );
private static final long serialVersionUID = 3785315696581773811L;
public static final String QUERY_DEF = "query";
......@@ -199,25 +196,25 @@ public class RedissonRegionFactory extends RegionFactoryTemplate {
throw new IllegalArgumentException("Unable to determine entity cache type!");
}
RMapCache<Object, Object> mapCache = getCache(regionConfig.getRegionName(), buildingContext.getSessionFactory().getProperties());
RMapCache<Object, Object> mapCache = getCache(regionConfig.getRegionName(), buildingContext.getSessionFactory().getProperties(), defaultKey);
return new RedissonStorage(mapCache, buildingContext.getSessionFactory().getProperties(), defaultKey);
}
@Override
protected StorageAccess createQueryResultsRegionStorageAccess(String regionName,
SessionFactoryImplementor sessionFactory) {
RMapCache<Object, Object> mapCache = getCache(regionName, sessionFactory.getProperties());
RMapCache<Object, Object> mapCache = getCache(regionName, sessionFactory.getProperties(), QUERY_DEF);
return new RedissonStorage(mapCache, sessionFactory.getProperties(), QUERY_DEF);
}
@Override
protected StorageAccess createTimestampsRegionStorageAccess(String regionName,
SessionFactoryImplementor sessionFactory) {
RMapCache<Object, Object> mapCache = getCache(regionName, sessionFactory.getProperties());
RMapCache<Object, Object> mapCache = getCache(regionName, sessionFactory.getProperties(), TIMESTAMPS_DEF);
return new RedissonStorage(mapCache, sessionFactory.getProperties(), TIMESTAMPS_DEF);
}
protected RMapCache<Object, Object> getCache(String regionName, Map properties) {
protected RMapCache<Object, Object> getCache(String regionName, Map properties, String defaultKey) {
return redisson.getMapCache(regionName);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册