[hibernate-commits] Hibernate SVN: r17660 - in core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc: query and 1 other directory.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Thu Oct 8 18:40:43 EDT 2009


Author: bstansberry at jboss.com
Date: 2009-10-08 18:40:42 -0400 (Thu, 08 Oct 2009)
New Revision: 17660

Modified:
   core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/builder/MultiplexingCacheInstanceManager.java
   core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/builder/SharedCacheInstanceManager.java
   core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/query/QueryResultsRegionImpl.java
Log:
[HHH-4485] Replace the JBoss Cache integration configuration properties with "jbc2"-less versions

Modified: core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/builder/MultiplexingCacheInstanceManager.java
===================================================================
--- core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/builder/MultiplexingCacheInstanceManager.java	2009-10-08 20:59:56 UTC (rev 17659)
+++ core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/builder/MultiplexingCacheInstanceManager.java	2009-10-08 22:40:42 UTC (rev 17660)
@@ -62,7 +62,13 @@
      * 
      * @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
      * stack configurations the <code>org.jgroups.ChannelFactory</code>
@@ -70,15 +76,27 @@
      * 
      * @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.
      * 
      * @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.
      * No default value, as by default we try to use the same JBoss Cache
      * instance we use for entity caching.
@@ -86,21 +104,41 @@
      * @see #ENTITY_CACHE_RESOURCE_PROP
      * @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.
      * 
      * @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.
      * 
      * @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
      * the "jbc2-configs.xml" file in this package.
      */
@@ -279,14 +317,20 @@
             if (buildCaches && jbcFactory == null) {
                 // See if the user configured a multiplexer stack
                 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) {
                         channelFactory = new JChannelFactory();
                         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);
                 ((CacheManagerImpl) jbcFactory).start();
                 selfCreatedFactory = true;
@@ -296,11 +340,18 @@
 
                 if (buildCaches) {
                     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);
                 
                     // 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)) {
                         jbcCollectionCache = jbcEntityCache;
                     }
@@ -329,7 +380,10 @@
                 if (buildCaches) {
                     // Default to sharing the entity cache if there is one
                     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)) {
                         jbcQueryCache = jbcEntityCache;
                     } else if (queryConfig.equals(collectionConfig)) {
@@ -339,7 +393,10 @@
                     }
     
                     // 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)) {
                         jbcTsCache = jbcQueryCache;
                     }

Modified: core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/builder/SharedCacheInstanceManager.java
===================================================================
--- core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/builder/SharedCacheInstanceManager.java	2009-10-08 20:59:56 UTC (rev 17659)
+++ core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/builder/SharedCacheInstanceManager.java	2009-10-08 22:40:42 UTC (rev 17660)
@@ -61,9 +61,16 @@
      * 
      * @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.
      */
     public static final String DEFAULT_CACHE_RESOURCE = "treecache.xml";
@@ -74,8 +81,14 @@
      * 
      * @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
      * the "jgroups-stacks.xml" file in this package.
      */
@@ -136,7 +149,10 @@
         if (cache == 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) {
                     channelFactory = new JChannelFactory();
                     try {
@@ -189,7 +205,10 @@
      */
     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);
     }
     

Modified: core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/query/QueryResultsRegionImpl.java
===================================================================
--- core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/query/QueryResultsRegionImpl.java	2009-10-08 20:59:56 UTC (rev 17659)
+++ core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/query/QueryResultsRegionImpl.java	2009-10-08 22:40:42 UTC (rev 17660)
@@ -46,7 +46,8 @@
 @CacheListener
 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";
     
     /**
@@ -72,9 +73,15 @@
         if (!localOnly) {
             // 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
-            // if they passed an config option to disable query replication
-            localOnly = CacheHelper.isClusteredReplication(jbcCache)
-                    && PropertiesHelper.getBoolean(QUERY_CACHE_LOCAL_ONLY_PROP, properties, false);
+        	// if they passed an config option to disable query replication
+        	if (CacheHelper.isClusteredReplication(jbcCache)) {
+        		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);
+        		}
+        	}
         }
     }
 



More information about the hibernate-commits mailing list