[jboss-cvs] JBossAS SVN: r60706 - 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
Tue Feb 20 01:06:06 EST 2007
Author: bstansberry at jboss.com
Date: 2007-02-20 01:06:03 -0500 (Tue, 20 Feb 2007)
New Revision: 60706
Modified:
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/entity/OptimisticTreeCacheProviderHook.java
Log:
Just extend TreeCacheProviderHook and log a warn if JBC isn't using optimistic locking.
Modified: 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 2007-02-20 06:04:29 UTC (rev 60705)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/entity/OptimisticTreeCacheProviderHook.java 2007-02-20 06:06:03 UTC (rev 60706)
@@ -8,61 +8,32 @@
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.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.
+ * Trivial {@link TreeCacheProviderHook} subclass that logs a warning in
+ * {@link #start(Properties) start} if the underlying JBoss Cache
+ * is not configured for optimistic locking. Like the superclass,
+ * will provide working Cache implementations whether JBoss Cache is
+ * configured for optimistic locking or not; the only added behavior
+ * is the logging of the warning if the JBoss Cache configuration doesn't
+ * match the intent implied by the use of this class.
*
* @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ * @author Brian Stansberry
*/
-public class OptimisticTreeCacheProviderHook implements CacheProvider
+public class OptimisticTreeCacheProviderHook
+ extends TreeCacheProviderHook
{
- 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.jboss.ejb3.entity.OptimisticJBCCache instance for region " + regionName); }
- return new OptimisticJBCCache( cache, regionName );
- }
-
- public boolean isMinimalPutsEnabledByDefault()
- {
- return true;
- }
-
- public long nextTimestamp()
- {
- return System.currentTimeMillis() / 100;
- }
-
public void start(Properties properties) throws CacheException
{
- try
+ super.start(properties);
+
+ if (isOptimistic() == false)
{
- 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"); }
+ log.warn("JBoss Cache is not configured for optimistic locking; " +
+ "provided Cache implementations therefore will not implement OptimisticCache");
}
- catch (Exception e)
- {
- throw new CacheException(e);
- }
}
- public void stop()
- {
- }
-
}
More information about the jboss-cvs-commits
mailing list