Author: sohil.shah(a)jboss.com
Date: 2007-11-05 13:18:18 -0500 (Mon, 05 Nov 2007)
New Revision: 8828
Modified:
branches/JBoss_Portal_2_6_2_SecurityPatch/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
branches/JBoss_Portal_2_6_2_SecurityPatch/jems/src/main/org/jboss/portal/jems/hibernate/JMXTreeCacheProvider.java
Log:
added support for optmistic hibernate cache
Modified:
branches/JBoss_Portal_2_6_2_SecurityPatch/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
---
branches/JBoss_Portal_2_6_2_SecurityPatch/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-11-05
11:26:07 UTC (rev 8827)
+++
branches/JBoss_Portal_2_6_2_SecurityPatch/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-11-05
18:18:18 UTC (rev 8828)
@@ -450,6 +450,10 @@
<depends>jboss:service=Naming</depends>
<depends>jboss:service=TransactionManager</depends>
<attribute
name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute>
+ <!-- Uncomment for using an Optimistic Hibernate Cache with Portal running on AS
4.2.1 -->
+ <!--
+ <attribute name="NodeLockingScheme">OPTIMISTIC</attribute>
+ -->
<attribute name="IsolationLevel">REPEATABLE_READ</attribute>
<attribute name="CacheMode">REPL_SYNC</attribute>
<attribute name="ClusterName">portal.hibernate</attribute>
Modified:
branches/JBoss_Portal_2_6_2_SecurityPatch/jems/src/main/org/jboss/portal/jems/hibernate/JMXTreeCacheProvider.java
===================================================================
---
branches/JBoss_Portal_2_6_2_SecurityPatch/jems/src/main/org/jboss/portal/jems/hibernate/JMXTreeCacheProvider.java 2007-11-05
11:26:07 UTC (rev 8827)
+++
branches/JBoss_Portal_2_6_2_SecurityPatch/jems/src/main/org/jboss/portal/jems/hibernate/JMXTreeCacheProvider.java 2007-11-05
18:18:18 UTC (rev 8828)
@@ -27,6 +27,7 @@
import org.hibernate.cache.CacheException;
import org.hibernate.cache.CacheProvider;
import org.hibernate.cache.TreeCache;
+import org.hibernate.cache.OptimisticTreeCache;
import org.jboss.mx.util.MBeanProxy;
import org.jboss.mx.util.MBeanServerLocator;
@@ -63,7 +64,21 @@
MBeanServer server = MBeanServerLocator.locateJBoss();
TreeCacheProvider provider =
(TreeCacheProvider)MBeanProxy.get(TreeCacheProvider.class, providerName, server);
org.jboss.cache.TreeCache cache = provider.getTreeCache();
- return new TreeCache(cache, regionName, cache.getTransactionManager());
+
+ //Select the proper type of hibernate cache to be used
+ Cache hibernateCache = null;
+ if(cache.getNodeLockingScheme().equalsIgnoreCase("OPTIMISTIC"))
+ {
+ log.debug("Selecting Optimistic Cache");
+ hibernateCache = new OptimisticTreeCache(cache, regionName);
+ }
+ else
+ {
+ log.debug("Selecting regular Tree Cache");
+ hibernateCache = new TreeCache(cache, regionName,
cache.getTransactionManager());
+ }
+
+ return hibernateCache;
}
catch (Exception e)
{