[HHH-4485] Replace the JBoss Cache integration configuration properties with "jbc2"-less versions
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@17660 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
c32a7a00a5
commit
ac6a4f652a
|
@ -62,7 +62,13 @@ public class MultiplexingCacheInstanceManager implements CacheInstanceManager {
|
||||||
*
|
*
|
||||||
* @see #DEF_CACHE_FACTORY_RESOURCE
|
* @see #DEF_CACHE_FACTORY_RESOURCE
|
||||||
*/
|
*/
|
||||||
public static final String CACHE_FACTORY_RESOURCE_PROP = "hibernate.cache.region.jbc2.configs";
|
public static final String CACHE_FACTORY_RESOURCE_PROP = "hibernate.cache.jbc.configs";
|
||||||
|
/**
|
||||||
|
* Legacy name for configuration property {@link #CACHE_FACTORY_RESOURCE_PROP}.
|
||||||
|
*
|
||||||
|
* @see #DEF_CACHE_FACTORY_RESOURCE
|
||||||
|
*/
|
||||||
|
public static final String LEGACY_CACHE_FACTORY_RESOURCE_PROP = "hibernate.cache.region.jbc2.configs";
|
||||||
/**
|
/**
|
||||||
* Classpath or filesystem resource containing JGroups protocol
|
* Classpath or filesystem resource containing JGroups protocol
|
||||||
* stack configurations the <code>org.jgroups.ChannelFactory</code>
|
* stack configurations the <code>org.jgroups.ChannelFactory</code>
|
||||||
|
@ -70,14 +76,26 @@ public class MultiplexingCacheInstanceManager implements CacheInstanceManager {
|
||||||
*
|
*
|
||||||
* @see #DEF_JGROUPS_RESOURCE
|
* @see #DEF_JGROUPS_RESOURCE
|
||||||
*/
|
*/
|
||||||
public static final String CHANNEL_FACTORY_RESOURCE_PROP = "hibernate.cache.region.jbc2.jgroups.stacks";
|
public static final String CHANNEL_FACTORY_RESOURCE_PROP = "hibernate.cache.jbc.jgroups.stacks";
|
||||||
|
/**
|
||||||
|
* Legacy name for configuration property {@link #CHANNEL_FACTORY_RESOURCE_PROP}.
|
||||||
|
*
|
||||||
|
* @see #DEF_JGROUPS_RESOURCE
|
||||||
|
*/
|
||||||
|
public static final String LEGACY_CHANNEL_FACTORY_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.jgroups.stacks";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the configuration that should be used for entity caches.
|
* Name of the configuration that should be used for entity caches.
|
||||||
*
|
*
|
||||||
* @see #DEF_ENTITY_RESOURCE
|
* @see #DEF_ENTITY_RESOURCE
|
||||||
*/
|
*/
|
||||||
public static final String ENTITY_CACHE_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.entity";
|
public static final String ENTITY_CACHE_RESOURCE_PROP = "hibernate.cache.jbc.cfg.entity";
|
||||||
|
/**
|
||||||
|
* Legacy name for configuration property {@link #ENTITY_CACHE_RESOURCE_PROP}.
|
||||||
|
*
|
||||||
|
* @see #DEF_ENTITY_RESOURCE
|
||||||
|
*/
|
||||||
|
public static final String LEGACY_ENTITY_CACHE_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.entity";
|
||||||
/**
|
/**
|
||||||
* Name of the configuration that should be used for collection caches.
|
* Name of the configuration that should be used for collection caches.
|
||||||
* No default value, as by default we try to use the same JBoss Cache
|
* No default value, as by default we try to use the same JBoss Cache
|
||||||
|
@ -86,19 +104,39 @@ public class MultiplexingCacheInstanceManager implements CacheInstanceManager {
|
||||||
* @see #ENTITY_CACHE_RESOURCE_PROP
|
* @see #ENTITY_CACHE_RESOURCE_PROP
|
||||||
* @see #DEF_ENTITY_RESOURCE
|
* @see #DEF_ENTITY_RESOURCE
|
||||||
*/
|
*/
|
||||||
public static final String COLLECTION_CACHE_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.collection";
|
public static final String COLLECTION_CACHE_RESOURCE_PROP = "hibernate.cache.jbc.cfg.collection";
|
||||||
|
/**
|
||||||
|
* Legacy name for configuration property {@link #COLLECTION_CACHE_RESOURCE_PROP}.
|
||||||
|
*
|
||||||
|
* @see #ENTITY_CACHE_RESOURCE_PROP
|
||||||
|
* @see #DEF_ENTITY_RESOURCE
|
||||||
|
*/
|
||||||
|
public static final String LEGACY_COLLECTION_CACHE_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.collection";
|
||||||
/**
|
/**
|
||||||
* Name of the configuration that should be used for timestamp caches.
|
* Name of the configuration that should be used for timestamp caches.
|
||||||
*
|
*
|
||||||
* @see #DEF_TS_RESOURCE
|
* @see #DEF_TS_RESOURCE
|
||||||
*/
|
*/
|
||||||
public static final String TIMESTAMP_CACHE_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.ts";
|
public static final String TIMESTAMP_CACHE_RESOURCE_PROP = "hibernate.cache.jbc.cfg.timestamps";
|
||||||
|
/**
|
||||||
|
* Legacy name for configuration property {@link #TIMESTAMP_CACHE_RESOURCE_PROP}.
|
||||||
|
*
|
||||||
|
* @see #DEF_TS_RESOURCE
|
||||||
|
*/
|
||||||
|
public static final String LEGACY_TIMESTAMP_CACHE_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.ts";
|
||||||
/**
|
/**
|
||||||
* Name of the configuration that should be used for query caches.
|
* Name of the configuration that should be used for query caches.
|
||||||
*
|
*
|
||||||
* @see #DEF_QUERY_RESOURCE
|
* @see #DEF_QUERY_RESOURCE
|
||||||
*/
|
*/
|
||||||
public static final String QUERY_CACHE_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.query";
|
public static final String QUERY_CACHE_RESOURCE_PROP = "hibernate.cache.jbc.cfg.query";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legacy name for configuration property {@link #QUERY_CACHE_RESOURCE_PROP}.
|
||||||
|
*
|
||||||
|
* @see #DEF_QUERY_RESOURCE
|
||||||
|
*/
|
||||||
|
public static final String LEGACY_QUERY_CACHE_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.query";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default value for {@link #CACHE_FACTORY_RESOURCE_PROP}. Specifies
|
* Default value for {@link #CACHE_FACTORY_RESOURCE_PROP}. Specifies
|
||||||
|
@ -279,14 +317,20 @@ public class MultiplexingCacheInstanceManager implements CacheInstanceManager {
|
||||||
if (buildCaches && jbcFactory == null) {
|
if (buildCaches && jbcFactory == null) {
|
||||||
// See if the user configured a multiplexer stack
|
// See if the user configured a multiplexer stack
|
||||||
if (channelFactory == null) {
|
if (channelFactory == null) {
|
||||||
String muxStacks = PropertiesHelper.getString(CHANNEL_FACTORY_RESOURCE_PROP, properties, DEF_JGROUPS_RESOURCE);
|
String muxStacks = PropertiesHelper.getString(CHANNEL_FACTORY_RESOURCE_PROP, properties, null);
|
||||||
|
if (muxStacks == null) {
|
||||||
|
muxStacks = PropertiesHelper.getString(LEGACY_CHANNEL_FACTORY_RESOURCE_PROP, properties, DEF_JGROUPS_RESOURCE);
|
||||||
|
}
|
||||||
if (muxStacks != null) {
|
if (muxStacks != null) {
|
||||||
channelFactory = new JChannelFactory();
|
channelFactory = new JChannelFactory();
|
||||||
channelFactory.setMultiplexerConfig(muxStacks);
|
channelFactory.setMultiplexerConfig(muxStacks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String factoryRes = PropertiesHelper.getString(CACHE_FACTORY_RESOURCE_PROP, properties, DEF_CACHE_FACTORY_RESOURCE);
|
String factoryRes = PropertiesHelper.getString(CACHE_FACTORY_RESOURCE_PROP, properties, null);
|
||||||
|
if (factoryRes == null) {
|
||||||
|
factoryRes = PropertiesHelper.getString(LEGACY_CACHE_FACTORY_RESOURCE_PROP, properties, DEF_CACHE_FACTORY_RESOURCE);
|
||||||
|
}
|
||||||
jbcFactory = new CacheManagerImpl(factoryRes, channelFactory);
|
jbcFactory = new CacheManagerImpl(factoryRes, channelFactory);
|
||||||
((CacheManagerImpl) jbcFactory).start();
|
((CacheManagerImpl) jbcFactory).start();
|
||||||
selfCreatedFactory = true;
|
selfCreatedFactory = true;
|
||||||
|
@ -296,11 +340,18 @@ public class MultiplexingCacheInstanceManager implements CacheInstanceManager {
|
||||||
|
|
||||||
if (buildCaches) {
|
if (buildCaches) {
|
||||||
entityConfig = PropertiesHelper
|
entityConfig = PropertiesHelper
|
||||||
.getString(ENTITY_CACHE_RESOURCE_PROP, properties, DEF_ENTITY_RESOURCE);
|
.getString(ENTITY_CACHE_RESOURCE_PROP, properties, null);
|
||||||
|
if (entityConfig == null) {
|
||||||
|
entityConfig = PropertiesHelper.getString(LEGACY_ENTITY_CACHE_RESOURCE_PROP,
|
||||||
|
properties, DEF_ENTITY_RESOURCE);
|
||||||
|
}
|
||||||
jbcEntityCache = jbcFactory.getCache(entityConfig, true);
|
jbcEntityCache = jbcFactory.getCache(entityConfig, true);
|
||||||
|
|
||||||
// Default to collections sharing entity cache if there is one
|
// Default to collections sharing entity cache if there is one
|
||||||
collectionConfig = PropertiesHelper.getString(COLLECTION_CACHE_RESOURCE_PROP, properties, entityConfig);
|
collectionConfig = PropertiesHelper.getString(COLLECTION_CACHE_RESOURCE_PROP, properties, null);
|
||||||
|
if (collectionConfig == null) {
|
||||||
|
collectionConfig = PropertiesHelper.getString(LEGACY_COLLECTION_CACHE_RESOURCE_PROP, properties, entityConfig);
|
||||||
|
}
|
||||||
if (entityConfig.equals(collectionConfig)) {
|
if (entityConfig.equals(collectionConfig)) {
|
||||||
jbcCollectionCache = jbcEntityCache;
|
jbcCollectionCache = jbcEntityCache;
|
||||||
}
|
}
|
||||||
|
@ -329,7 +380,10 @@ public class MultiplexingCacheInstanceManager implements CacheInstanceManager {
|
||||||
if (buildCaches) {
|
if (buildCaches) {
|
||||||
// Default to sharing the entity cache if there is one
|
// Default to sharing the entity cache if there is one
|
||||||
String dfltQueryResource = (entityConfig == null ? DEF_QUERY_RESOURCE : entityConfig);
|
String dfltQueryResource = (entityConfig == null ? DEF_QUERY_RESOURCE : entityConfig);
|
||||||
queryConfig = PropertiesHelper.getString(QUERY_CACHE_RESOURCE_PROP, properties, dfltQueryResource);
|
queryConfig = PropertiesHelper.getString(QUERY_CACHE_RESOURCE_PROP, properties, null);
|
||||||
|
if (queryConfig == null) {
|
||||||
|
queryConfig = PropertiesHelper.getString(LEGACY_QUERY_CACHE_RESOURCE_PROP, properties, dfltQueryResource);
|
||||||
|
}
|
||||||
if (queryConfig.equals(entityConfig)) {
|
if (queryConfig.equals(entityConfig)) {
|
||||||
jbcQueryCache = jbcEntityCache;
|
jbcQueryCache = jbcEntityCache;
|
||||||
} else if (queryConfig.equals(collectionConfig)) {
|
} else if (queryConfig.equals(collectionConfig)) {
|
||||||
|
@ -339,7 +393,10 @@ public class MultiplexingCacheInstanceManager implements CacheInstanceManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// For Timestamps, we default to a separate config
|
// For Timestamps, we default to a separate config
|
||||||
tsConfig = PropertiesHelper.getString(TIMESTAMP_CACHE_RESOURCE_PROP, properties, DEF_TS_RESOURCE);
|
tsConfig = PropertiesHelper.getString(TIMESTAMP_CACHE_RESOURCE_PROP, properties, null);
|
||||||
|
if (tsConfig == null) {
|
||||||
|
tsConfig = PropertiesHelper.getString(LEGACY_TIMESTAMP_CACHE_RESOURCE_PROP, properties, DEF_TS_RESOURCE);
|
||||||
|
}
|
||||||
if (tsConfig.equals(queryConfig)) {
|
if (tsConfig.equals(queryConfig)) {
|
||||||
jbcTsCache = jbcQueryCache;
|
jbcTsCache = jbcQueryCache;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,14 @@ public class SharedCacheInstanceManager implements CacheInstanceManager {
|
||||||
*
|
*
|
||||||
* @see #DEFAULT_CACHE_RESOURCE
|
* @see #DEFAULT_CACHE_RESOURCE
|
||||||
*/
|
*/
|
||||||
public static final String CACHE_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.shared";
|
public static final String CACHE_RESOURCE_PROP = "hibernate.cache.jbc.cfg.shared";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legacy name for configuration property {@link #CACHE_RESOURCE_PROP}.
|
||||||
|
*
|
||||||
|
* @see #DEFAULT_CACHE_RESOURCE
|
||||||
|
*/
|
||||||
|
public static final String LEGACY_CACHE_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.shared";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default name for the JBoss Cache configuration file.
|
* Default name for the JBoss Cache configuration file.
|
||||||
|
@ -74,7 +81,13 @@ public class SharedCacheInstanceManager implements CacheInstanceManager {
|
||||||
*
|
*
|
||||||
* @see #DEF_JGROUPS_RESOURCE
|
* @see #DEF_JGROUPS_RESOURCE
|
||||||
*/
|
*/
|
||||||
public static final String CHANNEL_FACTORY_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.jgroups.stacks";
|
public static final String CHANNEL_FACTORY_RESOURCE_PROP = "hibernate.cache.jbc.cfg.jgroups.stacks";
|
||||||
|
/**
|
||||||
|
* Legacy name for configuration property {@link #CHANNEL_FACTORY_RESOURCE_PROP}.
|
||||||
|
*
|
||||||
|
* @see #DEF_JGROUPS_RESOURCE
|
||||||
|
*/
|
||||||
|
public static final String LEGACY_CHANNEL_FACTORY_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.jgroups.stacks";
|
||||||
/**
|
/**
|
||||||
* Default value for {@link #CHANNEL_FACTORY_RESOURCE_PROP}. Specifies
|
* Default value for {@link #CHANNEL_FACTORY_RESOURCE_PROP}. Specifies
|
||||||
* the "jgroups-stacks.xml" file in this package.
|
* the "jgroups-stacks.xml" file in this package.
|
||||||
|
@ -136,7 +149,10 @@ public class SharedCacheInstanceManager implements CacheInstanceManager {
|
||||||
if (cache == null) {
|
if (cache == null) {
|
||||||
|
|
||||||
if (channelFactory == null) {
|
if (channelFactory == null) {
|
||||||
String muxStacks = PropertiesHelper.getString(CHANNEL_FACTORY_RESOURCE_PROP, properties, DEF_JGROUPS_RESOURCE);
|
String muxStacks = PropertiesHelper.getString(CHANNEL_FACTORY_RESOURCE_PROP, properties, null);
|
||||||
|
if (muxStacks == null) {
|
||||||
|
PropertiesHelper.getString(LEGACY_CHANNEL_FACTORY_RESOURCE_PROP, properties, DEF_JGROUPS_RESOURCE);
|
||||||
|
}
|
||||||
if (muxStacks != null) {
|
if (muxStacks != null) {
|
||||||
channelFactory = new JChannelFactory();
|
channelFactory = new JChannelFactory();
|
||||||
try {
|
try {
|
||||||
|
@ -189,7 +205,10 @@ public class SharedCacheInstanceManager implements CacheInstanceManager {
|
||||||
*/
|
*/
|
||||||
protected Cache createSharedCache(Settings settings, Properties properties)
|
protected Cache createSharedCache(Settings settings, Properties properties)
|
||||||
{
|
{
|
||||||
String configResource = PropertiesHelper.getString(CACHE_RESOURCE_PROP, properties, DEFAULT_CACHE_RESOURCE);
|
String configResource = PropertiesHelper.getString(CACHE_RESOURCE_PROP, properties, null);
|
||||||
|
if (configResource == null) {
|
||||||
|
configResource = PropertiesHelper.getString(LEGACY_CACHE_RESOURCE_PROP, properties, DEFAULT_CACHE_RESOURCE);
|
||||||
|
}
|
||||||
return new DefaultCacheFactory().createCache(configResource, false);
|
return new DefaultCacheFactory().createCache(configResource, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,8 @@ import org.jboss.cache.notifications.annotation.CacheListener;
|
||||||
@CacheListener
|
@CacheListener
|
||||||
public class QueryResultsRegionImpl extends TransactionalDataRegionAdapter implements QueryResultsRegion {
|
public class QueryResultsRegionImpl extends TransactionalDataRegionAdapter implements QueryResultsRegion {
|
||||||
|
|
||||||
public static final String QUERY_CACHE_LOCAL_ONLY_PROP = "hibernate.cache.region.jbc2.query.localonly";
|
public static final String QUERY_CACHE_LOCAL_ONLY_PROP = "hibernate.cache.jbc.query.localonly";
|
||||||
|
public static final String LEGACY_QUERY_CACHE_LOCAL_ONLY_PROP = "hibernate.cache.region.jbc2.query.localonly";
|
||||||
public static final String TYPE = "QUERY";
|
public static final String TYPE = "QUERY";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,9 +73,15 @@ public class QueryResultsRegionImpl extends TransactionalDataRegionAdapter imple
|
||||||
if (!localOnly) {
|
if (!localOnly) {
|
||||||
// We don't want to waste effort setting an option if JBC is
|
// We don't want to waste effort setting an option if JBC is
|
||||||
// already in LOCAL mode. If JBC is REPL_(A)SYNC then check
|
// already in LOCAL mode. If JBC is REPL_(A)SYNC then check
|
||||||
// if they passed an config option to disable query replication
|
// if they passed an config option to disable query replication
|
||||||
localOnly = CacheHelper.isClusteredReplication(jbcCache)
|
if (CacheHelper.isClusteredReplication(jbcCache)) {
|
||||||
&& PropertiesHelper.getBoolean(QUERY_CACHE_LOCAL_ONLY_PROP, properties, false);
|
if (properties.containsKey(QUERY_CACHE_LOCAL_ONLY_PROP)) {
|
||||||
|
localOnly = PropertiesHelper.getBoolean(QUERY_CACHE_LOCAL_ONLY_PROP, properties, false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
localOnly = PropertiesHelper.getBoolean(LEGACY_QUERY_CACHE_LOCAL_ONLY_PROP, properties, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue