[jboss-cvs] JBossAS SVN: r60473 - branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/entity.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Feb 9 17:33:06 EST 2007
Author: bdecoste
Date: 2007-02-09 17:33:06 -0500 (Fri, 09 Feb 2007)
New Revision: 60473
Added:
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/entity/OptimisticTreeCacheProviderHook.java
Log:
hook for optimistic locking
Added: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/entity/OptimisticTreeCacheProviderHook.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/entity/OptimisticTreeCacheProviderHook.java (rev 0)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/entity/OptimisticTreeCacheProviderHook.java 2007-02-09 22:33:06 UTC (rev 60473)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.ejb3.entity;
+
+import java.util.Properties;
+
+import javax.management.ObjectName;
+
+import org.hibernate.cache.Cache;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.CacheProvider;
+import org.hibernate.cache.OptimisticTreeCache;
+import org.jboss.cache.TreeCache;
+import org.jboss.cache.TreeCacheMBean;
+import org.jboss.logging.Logger;
+import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.mx.util.MBeanServerLocator;
+
+/**
+ * OptimisticTreeCacheProviderHook.
+ *
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+public class OptimisticTreeCacheProviderHook implements CacheProvider
+{
+ private static final Logger log = Logger.getLogger(OptimisticTreeCacheProviderHook.class);
+
+ private TreeCache cache;
+
+ public Cache buildCache(String regionName, Properties properties) throws CacheException
+ {
+ if (log.isDebugEnabled()) { log.debug("Building org.hibernate.cache.OptimisticTreeCache instance for region " + regionName); }
+ return new OptimisticTreeCache( cache, regionName );
+ }
+
+ public boolean isMinimalPutsEnabledByDefault()
+ {
+ return true;
+ }
+
+ public long nextTimestamp()
+ {
+ return System.currentTimeMillis() / 100;
+ }
+
+ public void start(Properties properties) throws CacheException
+ {
+ try
+ {
+ ObjectName mbeanObjectName = new ObjectName((String) properties.get("hibernate.treecache.mbean.object_name"));
+ TreeCacheMBean mbean = (TreeCacheMBean) MBeanProxyExt.create(TreeCacheMBean.class, mbeanObjectName, MBeanServerLocator.locateJBoss());
+ cache = mbean.getInstance();
+ if (log.isDebugEnabled()) { log.debug("TreeCache instance for " + mbeanObjectName + " retrieved"); }
+ }
+ catch (Exception e)
+ {
+ throw new CacheException(e);
+ }
+ }
+
+ public void stop()
+ {
+ }
+
+}
More information about the jboss-cvs-commits
mailing list