[jboss-cvs] JBossAS SVN: r75784 - projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jul 14 11:53:39 EDT 2008


Author: pferraro
Date: 2008-07-14 11:53:39 -0400 (Mon, 14 Jul 2008)
New Revision: 75784

Removed:
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/JBCCacheBase.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/JBCCacheFactory.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/OptimisticJBCCache.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/OptimisticTreeCacheProviderHook.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/PessimisticJBCCache.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/TransactionalCacheFactory.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/TreeCacheProviderHook.java
Log:
[EJBTHREE-1411] Removed TreeCacheProviderHook.  This is obsoleted by JBC RegionFactory impls in Hibernate 3.3

Deleted: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/JBCCacheBase.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/JBCCacheBase.java	2008-07-14 15:53:11 UTC (rev 75783)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/JBCCacheBase.java	2008-07-14 15:53:39 UTC (rev 75784)
@@ -1,304 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.entity;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
-import org.hibernate.cache.Cache;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.StandardQueryCache;
-import org.hibernate.cache.UpdateTimestampsCache;
-import org.hibernate.util.PropertiesHelper;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
-import org.jboss.cache.Region;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.Configuration.CacheMode;
-
-/**
- * Base superclass for a {@link Cache} implementation that uses a 2.x or later 
- * release of JBoss Cache.
- * 
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1.1 $
- */
-public abstract class JBCCacheBase
-{
-   public static final String QUERY_CACHE_LOCAL_ONLY_PROP = "hibernate.cache.region.jbc2.query.localonly";
-   
-   protected static final String ITEM = "item";
- 
-   protected org.jboss.cache.Cache<Object, Object> cache;
-   protected final String regionName;
-   protected final Fqn<String> regionFqn;
-   protected final TransactionManager transactionManager;
-   protected boolean localOnlyQueries;
-   protected boolean forTimestamps;
-   protected boolean forceAsync;
-   protected Node<Object, Object> regionRoot;
-   protected final Object regionRootMutex = new Object();
-
-
-   public JBCCacheBase(org.jboss.cache.Cache<Object, Object> cache, String regionName, 
-                       String regionPrefix, TransactionManager transactionManager,
-                       Properties properties) 
-   throws CacheException 
-   {
-       this.cache = cache;
-       this.regionName = regionName;
-       this.regionFqn = Fqn.fromString(SecondLevelCacheUtil.createRegionFqn(regionName, regionPrefix));
-       this.transactionManager = transactionManager;
-       this.forTimestamps = regionName.contains(UpdateTimestampsCache.class.getName());
-       CacheMode mode = cache.getConfiguration().getCacheMode();
-       if (forTimestamps)
-       {          
-          if (mode == CacheMode.INVALIDATION_ASYNC || mode == CacheMode.INVALIDATION_SYNC)
-          {
-             throw new IllegalStateException("Cache is configured for " + mode + 
-                                             "; not supported for a timestamps cache");
-          }
-          
-          forceAsync = (mode == CacheMode.REPL_SYNC);
-       }
-       
-       // 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 a config option to disable query replication
-       if (mode != CacheMode.LOCAL)
-       {
-          localOnlyQueries = PropertiesHelper.getBoolean(QUERY_CACHE_LOCAL_ONLY_PROP, properties, false);
-          // If its the standard query region with no prefix, its possibly shared
-          // between classloaders, so we make it local only
-          localOnlyQueries = localOnlyQueries || 
-                             StandardQueryCache.class.getName().equals(regionName);
-       }
-       
-       activateLocalClusterNode();
-   }
-   
-   private void activateLocalClusterNode()
-   {       
-      // Regions can get instantiated in the course of normal work (e.g.
-      // a named query region will be created the first time the query is
-      // executed), so suspend any ongoing tx
-      Transaction tx = suspend();
-      try {
-         Configuration cfg = cache.getConfiguration();
-         if (cfg.isUseRegionBasedMarshalling()) {                
-
-            Region jbcRegion = cache.getRegion(regionFqn, true);
-
-            // Only register the classloader if it's not a shared region.  
-            // If it's shared, no single classloader is valid
-            boolean shared = SecondLevelCacheUtil.isSharedClassLoaderRegion(regionName);
-            if (!shared)
-            {
-               ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-               if (classLoader == null) {
-                  classLoader = getClass().getClassLoader();
-               }
-               jbcRegion.registerContextClassLoader(classLoader);
-            }
-
-            if ( !jbcRegion.isActive() ) 
-            {
-               boolean fetchState = cfg.isFetchInMemoryState();
-               try
-               {
-                  // We don't want a state transfer for a shared region,
-                  // as it can include classes from multiple scoped classloaders
-                  if (shared)
-                     cfg.setFetchInMemoryState(false);
-
-                  jbcRegion.activate();
-               }
-               finally
-               {
-                  // Restore the normal state transfer setting
-                  if (shared)
-                     cfg.setFetchInMemoryState(fetchState);              
-               }
-
-            }
-         }
-
-         regionRoot = createRegionRootNode();
-      }
-      catch (Exception e)
-      {
-         throw SecondLevelCacheUtil.convertToHibernateException(e);
-      }
-      finally {
-         resume(tx);
-      }        
-    }
-
-   protected abstract void establishRegionRootNode();
-
-   protected abstract Node<Object, Object> createRegionRootNode();
-
-   /**
-     * Checks for the validity of the root cache node for this region,
-     * creating a new one if it does not exist or is invalid, and also
-     * ensuring that the root node is marked as resident.  Suspends any 
-     * transaction while doing this to ensure no transactional locks are held 
-     * on the region root.
-     * 
-     * TODO remove this once JBCACHE-1250 is resolved.
-     */
-   protected void ensureRegionRootExists()
-   {       
-       if (regionRoot == null || !regionRoot.isValid())
-       {
-          synchronized (regionRootMutex)
-          {
-             // If we've been blocking for the mutex, perhaps another
-             // thread has already reestablished the root.
-             // In case the node was reestablised via replication, confirm it's 
-             // marked "resident" (a status which doesn't replicate)
-             if (regionRoot != null && regionRoot.isValid()) {
-                return;
-             }
-             
-             establishRegionRootNode();
-          }
-       }
-       
-       // Fix up the resident flag
-       if (regionRoot != null && regionRoot.isValid() && !regionRoot.isResident())
-          regionRoot.setResident(true);
-    }
-
-   protected void resume(Transaction tx)
-   {
-      if (tx != null)
-      {
-         try {
-            transactionManager.resume(tx);
-         }
-         catch (Exception e) {
-            throw new CacheException("Could not resume transaction", e);
-         }
-      }
-   }
-
-   protected Transaction suspend()
-   {
-      Transaction tx = null;
-      if (transactionManager != null)
-      {
-         try {
-            tx = transactionManager.suspend();
-         }
-         catch (SystemException se) {
-            throw new CacheException("Could not suspend transaction", se);
-         }
-      }
-      return tx;
-   }
-   
-   protected void inactivateCacheRegion() throws CacheException
-   {
-      Region region = cache.getRegion(regionFqn, false);
-      if (region != null && region.isActive())
-      {
-         try
-         {
-            region.deactivate();
-            region.unregisterContextClassLoader();
-         }
-         catch (Exception e)
-         {
-            throw SecondLevelCacheUtil.convertToHibernateException(e);
-         }
-      }        
-   }
-
-   public void lock(Object key) throws CacheException {
-       throw new UnsupportedOperationException( "TreeCache is a fully transactional cache" + regionName );
-   }
-
-   public void unlock(Object key) throws CacheException {
-       throw new UnsupportedOperationException( "TreeCache is a fully transactional cache: " + regionName );
-   }
-
-   public long nextTimestamp() {
-       return System.currentTimeMillis() / 100;
-   }
-
-   public int getTimeout() {
-       return 600; //60 seconds
-   }
-
-   public String getRegionName() {
-       return regionName;
-   }
-
-   public long getSizeInMemory() {
-       return -1;
-   }
-
-   public long getElementCountInMemory() {
-       try {
-           return getChildrenNames().size();
-       }
-       catch (Exception e) {
-           throw SecondLevelCacheUtil.convertToHibernateException(e);
-       }
-   }
-
-   public long getElementCountOnDisk() {
-       return 0;
-   }
-
-   public Map<Object, Object> toMap() {
-       try {
-           Map<Object, Object> result = new HashMap<Object, Object>();
-           for (Object key : getChildrenNames() ) {
-               result.put(key, cache.get( new Fqn( regionFqn, key ), ITEM ));
-           }
-           return result;
-       }
-       catch (Exception e) {
-           throw SecondLevelCacheUtil.convertToHibernateException(e);
-       }
-   }
-   
-   private Set<Object> getChildrenNames()
-   {
-      try {
-         return regionRoot == null ? new HashSet<Object>() : regionRoot.getChildrenNames();
-      }
-      catch (Exception e) {
-         throw SecondLevelCacheUtil.convertToHibernateException(e);
-      }   
-   }
-
-}
\ No newline at end of file

Deleted: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/JBCCacheFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/JBCCacheFactory.java	2008-07-14 15:53:11 UTC (rev 75783)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/JBCCacheFactory.java	2008-07-14 15:53:39 UTC (rev 75784)
@@ -1,135 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.entity;
-
-import java.util.Properties;
-
-import org.hibernate.cache.Cache;
-import org.hibernate.cache.CacheException;
-import org.jboss.cache.CacheManager;
-import org.jboss.cache.CacheStatus;
-import org.jboss.ejb3.tx.TxUtil;
-import org.jboss.ha.framework.server.CacheManagerLocator;
-import org.jboss.logging.Logger;
-
-/**
- * Concrete implementation of TransactionalCacheFactory meant for use with
- * JBoss Cache 2.x
- * 
- * @author Brian Stansberry
- */
-class JBCCacheFactory extends TransactionalCacheFactory
-{
-   private static final Logger log = Logger.getLogger(JBCCacheFactory.class);
-   
-   private CacheManager cacheManager;
-   private String cacheName;
-   private org.jboss.cache.Cache<Object, Object> cache;
-   private boolean optimistic;
-   
-   JBCCacheFactory()
-   {
-       
-   }
-   
-   protected void configure(Properties hibernateConfig)
-   {
-       try
-       {
-          cacheManager = CacheManagerLocator.getCacheManagerLocator().getCacheManager(null);
-          
-          cacheName = (String) hibernateConfig.get(TreeCacheProviderHook.HIBERNATE_CACHE_CONFIG_NAME_PROPERTY);
-          if (cacheName == null)
-          {
-             cacheName = (String) hibernateConfig.get(TreeCacheProviderHook.HIBERNATE_CACHE_OBJECT_NAME_PROPERTY);
-          }
-          if (cacheName == null)
-          {
-             cacheName = TreeCacheProviderHook.DEFAULT_MBEAN_OBJECT_NAME;
-          }          
-       }
-       catch (Exception e)
-       {
-          throw new CacheException(e);
-       }      
-   }
-   
-   public void start()
-   {
-      try
-      {
-         cache = cacheManager.getCache(cacheName, true);
-         optimistic = cache.getConfiguration().isNodeLockingOptimistic();
-         if (cache.getCacheStatus() != CacheStatus.STARTED)
-         {
-            if (cache.getCacheStatus() != CacheStatus.CREATED)
-            {
-               cache.create();
-            }
-            
-            if (cache.getConfiguration().getRuntimeConfig().getTransactionManager() == null
-                  && cache.getConfiguration().getTransactionManagerLookupClass() == null)
-            {
-               cache.getConfiguration().getRuntimeConfig().setTransactionManager(TxUtil.getTransactionManager());
-            }
-            cache.start();
-         }
-      }
-      catch (Exception e)
-      {
-         throw new CacheException("Problem accessing cache " + cacheName, e);
-      }
-   }
-   
-   public Cache buildCache(String regionName, Properties properties) throws CacheException
-   {
-      String regionPrefix = properties.getProperty(SecondLevelCacheUtil.HIBERNATE_CACHE_REGION_PREFIX);
-      
-      if (optimistic)
-      {
-         return new OptimisticJBCCache(cache, regionName, regionPrefix,
-                                       TxUtil.getTransactionManager(),
-                                       properties);
-      }
-      else
-      {
-         return new PessimisticJBCCache(cache, regionName, regionPrefix,
-                                        TxUtil.getTransactionManager(),
-                                        properties);
-      }
-   }
-   
-   public void stop()
-   {
-      if (cache != null)
-      {
-         cacheManager.releaseCache(cacheName);
-         log.debug("Cache " + cacheName + " released");
-      }
-   }
-   
-   public boolean isOptimistic()
-   {
-      return optimistic;
-   }
-
-}

Deleted: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/OptimisticJBCCache.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/OptimisticJBCCache.java	2008-07-14 15:53:11 UTC (rev 75783)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/OptimisticJBCCache.java	2008-07-14 15:53:39 UTC (rev 75784)
@@ -1,426 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.entity;
-
-import java.util.Comparator;
-import java.util.Properties;
-
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
-
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.OptimisticCache;
-import org.hibernate.cache.OptimisticCacheSource;
-import org.hibernate.cache.QueryKey;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.optimistic.DataVersion;
-import org.jboss.cache.config.Option;
-import org.jboss.cache.lock.TimeoutException;
-import org.jboss.logging.Logger;
-
-/**
- * Represents a particular region within the given JBossCache TreeCache
- * utilizing TreeCache's optimistic locking capabilities.
- *
- * @see org.hibernate.cache.OptimisticTreeCacheProvider for more details
- *
- * @author Steve Ebersole
- * @author Brian Stansberry
- */
-public class OptimisticJBCCache extends JBCCacheBase implements OptimisticCache 
-{
-
-   private static final Logger log = Logger.getLogger(OptimisticJBCCache.class);
-   
-   private OptimisticCacheSource source;
-
-   public OptimisticJBCCache(org.jboss.cache.Cache<Object, Object> cache, 
-         String regionName, String regionPrefix, 
-         TransactionManager transactionManager,
-         Properties properties) 
-   throws CacheException {
-      super(cache, regionName, regionPrefix, transactionManager, properties);
-   }
-
-   @Override
-   protected void establishRegionRootNode()
-   {
-      // Don't hold a transactional lock for this 
-      Transaction tx = suspend();
-      Node<Object, Object> newRoot = null;
-      try {
-         // Make sure the root node for the region exists and 
-         // has a DataVersion that never complains
-         newRoot = createRegionRootNode();
-      }
-      finally {
-         resume(tx);
-         regionRoot = newRoot;
-      }
-   }
-
-   @Override
-   protected Node<Object, Object> createRegionRootNode()
-   {
-      Node<Object, Object> root = cache.getRoot();
-      Node<Object, Object> targetNode = root.getChild( regionFqn );
-      if (targetNode == null || !targetNode.isValid()) {
-         cache.getInvocationContext().getOptionOverrides().setDataVersion(NonLockingDataVersion.INSTANCE);          
-         targetNode = root.addChild( regionFqn );    
-      }
-      else if (targetNode instanceof NodeSPI) {
-         // FIXME Hacky workaround to JBCACHE-1202
-         if ( !( ( ( NodeSPI ) targetNode ).getVersion() instanceof NonLockingDataVersion ) ) {
-              ((NodeSPI) targetNode).setVersion(NonLockingDataVersion.INSTANCE);
-         }
-      }
-
-      // Never evict this node
-      targetNode.setResident(true);
-
-      return targetNode;
-   }
-
-
-	// OptimisticCache impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-	public void setSource(OptimisticCacheSource source) {
-		this.source = source;
-	}
-
-	public void writeInsert(Object key, Object value, Object currentVersion) {
-		writeUpdate( key, value, currentVersion, null );
-	}
-
-	@SuppressWarnings("unchecked")
-	public void writeUpdate(Object key, Object value, Object currentVersion, Object previousVersion) {
-		try {
-            ensureRegionRootExists();
-            
-			Option option = new Option();
-			DataVersion dv = ( source != null && source.isVersioned() )
-			                 ? new DataVersionAdapter( currentVersion, previousVersion, source.getVersionComparator(), source.toString() )
-			                 : NonLockingDataVersion.INSTANCE;
-			option.setDataVersion( dv );
-			if (localOnlyQueries && key instanceof QueryKey)
-               option.setCacheModeLocal(true);
-            cache.getInvocationContext().setOptionOverrides(option);
-			cache.put( new Fqn( regionFqn, key ), ITEM, value );
-		}
-		catch ( Exception e ) {
-			throw SecondLevelCacheUtil.convertToHibernateException( e );
-		}
-	}
-
-	@SuppressWarnings("unchecked")
-    public void writeLoad(Object key, Object value, Object currentVersion) {
-	   Transaction tx = null;
-	   try {
-	      Option option = new Option();
-	      DataVersion dv = ( source != null && source.isVersioned() )
-	                           ? new DataVersionAdapter( currentVersion, currentVersion, source.getVersionComparator(), source.toString() )
-	                           : NonLockingDataVersion.INSTANCE;
-	      option.setDataVersion( dv );
-
-	      if (forTimestamps) 
-	      {
-	         tx = suspend();
-
-	         ensureRegionRootExists();
-
-	         // Timestamps don't use putForExternalRead, but are async
-	         if (forceAsync)
-	            option.setForceAsynchronous(true);
-	         cache.getInvocationContext().setOptionOverrides(option);
-	         cache.put(new Fqn( regionFqn, key ), ITEM, value);               
-	      }
-	      else if (key instanceof QueryKey) 
-	      {
-	         ensureRegionRootExists();
-
-	         option.setCacheModeLocal(localOnlyQueries);
-             option.setLockAcquisitionTimeout(2);
-	         cache.getInvocationContext().setOptionOverrides(option);
-	         cache.put( new Fqn( regionFqn, key ), ITEM, value );
-	      }
-	      else
-	      {
-	         ensureRegionRootExists();
-	         cache.getInvocationContext().setOptionOverrides(option);
-	         cache.putForExternalRead( new Fqn( regionFqn, key ), ITEM, value );
-	      }
-	   }
-	   catch (TimeoutException te) {
-	      if (!(key instanceof QueryKey))
-	         throw SecondLevelCacheUtil.convertToHibernateException(te);
-	   } 
-	   catch (Exception e) {
-	      throw SecondLevelCacheUtil.convertToHibernateException(e);
-	   }
-	   finally {
-	      resume(tx);
-	   }
-	}
-
-
-	// Cache impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-	public Object get(Object key) throws CacheException {
-	    Transaction tx = suspend();
-	    try {
-	        ensureRegionRootExists();
-		    if (key instanceof QueryKey)
-		    {		       
-		       cache.getInvocationContext().getOptionOverrides().setLockAcquisitionTimeout(0);		       
-		    }
-		    
-			return cache.get( new Fqn( regionFqn, key ), ITEM );
-		}
-		catch (TimeoutException e) {
-		   if (key instanceof QueryKey)
-		      return null;
-		   throw SecondLevelCacheUtil.convertToHibernateException(e);
-		}
-		catch (Exception e) {
-			throw SecondLevelCacheUtil.convertToHibernateException(e);
-		}
-		finally {
-		   resume(tx);
-		}
-	}
-
-	public Object read(Object key) throws CacheException {
-		try {
-            ensureRegionRootExists();
-			return cache.get( new Fqn( regionFqn, key ), ITEM );
-		}
-		catch (Exception e) {
-			throw SecondLevelCacheUtil.convertToHibernateException(e);
-		}
-	}
-
-	public void update(Object key, Object value) throws CacheException {
-		try {
-            ensureRegionRootExists();
-			Option option = new Option();
-			option.setDataVersion( NonLockingDataVersion.INSTANCE );
-            if (localOnlyQueries && key instanceof QueryKey)
-               option.setCacheModeLocal(true);
-            cache.getInvocationContext().setOptionOverrides(option);
-			cache.put( new Fqn( regionFqn, key ), ITEM, value );
-		}
-		catch (Exception e) {
-			throw SecondLevelCacheUtil.convertToHibernateException(e);
-		}
-	}
-
-	public void put(Object key, Object value) throws CacheException {
-	    Transaction tx = null;
-		try {
-            Option option = new Option();
-            option.setDataVersion( NonLockingDataVersion.INSTANCE );
-            if (forTimestamps) {
-               tx = suspend();
-
-               ensureRegionRootExists();
-               
-               // Timestamps don't use putForExternalRead, but are async
-               if (forceAsync)
-                  option.setForceAsynchronous(true);
-               cache.getInvocationContext().setOptionOverrides(option);
-               cache.put(new Fqn( regionFqn, key ), ITEM, value);               
-            }
-            else if (key instanceof QueryKey) { 
-               
-               ensureRegionRootExists();
-               
-               option.setCacheModeLocal(localOnlyQueries);
-               option.setLockAcquisitionTimeout(2);
-               cache.getInvocationContext().setOptionOverrides(option);
-               cache.put(new Fqn( regionFqn, key ), ITEM, value); 
-            }
-            else {
-               ensureRegionRootExists();
-               cache.getInvocationContext().setOptionOverrides(option);
-   			   cache.putForExternalRead( new Fqn( regionFqn, key ), ITEM, value );
-            }
-		}
-		catch (TimeoutException te) {
-			if (!(key instanceof QueryKey))
-	            throw SecondLevelCacheUtil.convertToHibernateException(te);
-		}
-		catch (Exception e) {
-			throw SecondLevelCacheUtil.convertToHibernateException(e);
-		}
-		finally {
-		   resume(tx);
-		}
-	}
-
-	public void remove(Object key) throws CacheException {
-	   try {
-	      ensureRegionRootExists();
-
-	      Option option = new Option();
-	      option.setDataVersion( NonLockingDataVersion.INSTANCE );
-	      if (localOnlyQueries && key instanceof QueryKey)
-	         option.setCacheModeLocal(true);
-	      cache.getInvocationContext().setOptionOverrides(option);
-	      cache.removeNode( new Fqn( regionFqn, key ) );
-	   }
-	   catch (Exception e) {
-	      throw SecondLevelCacheUtil.convertToHibernateException(e);
-	   }
-	}
-
-	public void clear() throws CacheException {
-		try {
-			cache.getInvocationContext().getOptionOverrides().setDataVersion( NonLockingDataVersion.INSTANCE );
-			cache.removeNode( regionFqn );
-		}
-		catch (Exception e) {
-			throw SecondLevelCacheUtil.convertToHibernateException(e);
-		}
-	}
-
-	public void destroy() throws CacheException {
-		try {
-			Option option = new Option();
-			option.setCacheModeLocal( true );
-			option.setDataVersion( NonLockingDataVersion.INSTANCE );
-            cache.getInvocationContext().setOptionOverrides(option);
-			cache.removeNode( regionFqn );
-            
-            if (cache.getConfiguration().isUseRegionBasedMarshalling() 
-                  && !SecondLevelCacheUtil.isSharedClassLoaderRegion(regionName))
-            {
-               inactivateCacheRegion();
-            }
-		}
-		catch( Exception e ) {
-			throw SecondLevelCacheUtil.convertToHibernateException( e );
-		}
-	}
-
-	public String toString() {
-		return "OptimisticJBCCache(" + regionName + ')';
-	}
-
-	public static class DataVersionAdapter implements DataVersion 
-    {
-        private static final long serialVersionUID = 5564692336076405571L;
-		private final Object currentVersion;
-		private final Object previousVersion;
-		private final Comparator<Object> versionComparator;
-		private final String sourceIdentifer;
-
-		public DataVersionAdapter(Object currentVersion, Object previousVersion, Comparator<Object> versionComparator, String sourceIdentifer) {
-			this.currentVersion = currentVersion;
-			this.previousVersion = previousVersion;
-			this.versionComparator = versionComparator;
-			this.sourceIdentifer = sourceIdentifer;
-			log.trace( "created " + this );
-		}
-
-		/**
-		 * newerThan() call is dispatched against the DataVersion currently
-		 * associated with the node; the passed dataVersion param is the
-		 * DataVersion associated with the data we are trying to put into
-		 * the node.
-		 * <p/>
-		 * we are expected to return true in the case where we (the current
-		 * node DataVersion) are newer that then incoming value.  Returning
-		 * true here essentially means that a optimistic lock failure has
-		 * occured (because conversely, the value we are trying to put into
-		 * the node is "older than" the value already there...)
-		 */
-		public boolean newerThan(DataVersion dataVersion) {
-			log.trace( "checking [" + this + "] against [" + dataVersion + "]" );
-			if ( dataVersion instanceof CircumventChecksDataVersion ) {
-				log.trace( "skipping lock checks..." );
-				return false;
-			}
-			else if ( dataVersion instanceof NonLockingDataVersion ) {
-				// can happen because of the multiple ways Cache.remove()
-				// can be invoked :(
-				log.trace( "skipping lock checks..." );
-				return false;
-			}
-			DataVersionAdapter other = ( DataVersionAdapter ) dataVersion;
-			if ( other.previousVersion == null ) {
-				log.warn( "Unexpected optimistic lock check on inserting data" );
-				// work around the "feature" where tree cache is validating the
-				// inserted node during the next transaction.  no idea...
-				if ( this == dataVersion ) {
-					log.trace( "skipping lock checks due to same DV instance" );
-					return false;
-				}
-			}
-            
-            if (currentVersion == null)
-            {
-               // If the workspace node has null as well, OK; if not we've
-               // been modified in a non-comparable manner, which we have to
-               // treat as us being newer 
-               return (other.previousVersion != null);
-            }
-            
-			return versionComparator.compare( currentVersion, other.previousVersion ) >= 1;
-		}
-
-		public String toString() {
-			return super.toString() + " [current=" + currentVersion + ", previous=" + previousVersion + ", src=" + sourceIdentifer + "]";
-		}
-	}
-
-	/**
-	 * Used in regions where no locking should ever occur.  This includes query-caches,
-	 * update-timestamps caches, collection caches, and entity caches where the entity
-	 * is not versioned.
-	 */
-	public static class NonLockingDataVersion implements DataVersion 
-    {
-        private static final long serialVersionUID = 7050722490368630553L;
-		public static final DataVersion INSTANCE = new NonLockingDataVersion();
-		public boolean newerThan(DataVersion dataVersion) {
-			log.trace( "non locking lock check...");
-			return false;
-		}
-	}
-
-	/**
-	 * Used to signal to a DataVersionAdapter to simply not perform any checks.  This
-	 * is currently needed for proper handling of remove() calls for entity cache regions
-	 * (we do not know the version info...).
-	 */
-	public static class CircumventChecksDataVersion implements DataVersion  
-    {
-        private static final long serialVersionUID = 7996980646166032369L;
-		public static final DataVersion INSTANCE = new CircumventChecksDataVersion();
-		public boolean newerThan(DataVersion dataVersion) {
-			throw new CacheException( "optimistic locking checks should never happen on CircumventChecksDataVersion" );
-		}
-	}
-}

Deleted: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/OptimisticTreeCacheProviderHook.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/OptimisticTreeCacheProviderHook.java	2008-07-14 15:53:11 UTC (rev 75783)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/OptimisticTreeCacheProviderHook.java	2008-07-14 15:53:39 UTC (rev 75784)
@@ -1,39 +0,0 @@
-/*
- * 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 org.hibernate.cache.CacheException;
-
-/**
- * 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 
-   extends TreeCacheProviderHook 
-{
-   public void start(Properties properties) throws CacheException
-   {
-      super.start(properties);
-      
-      if (getCacheFactory().isOptimistic() == false)
-      {
-         log.warn("JBoss Cache is not configured for optimistic locking; " +
-         "provided Cache implementations therefore will not implement OptimisticCache");
-      }
-   }
-
-}

Deleted: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/PessimisticJBCCache.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/PessimisticJBCCache.java	2008-07-14 15:53:11 UTC (rev 75783)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/PessimisticJBCCache.java	2008-07-14 15:53:39 UTC (rev 75784)
@@ -1,208 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.entity;
-
-import java.util.Properties;
-
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
-import org.hibernate.cache.Cache;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.QueryKey;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
-import org.jboss.cache.config.Option;
-import org.jboss.cache.lock.TimeoutException;
-import org.jboss.ejb3.entity.OptimisticJBCCache.NonLockingDataVersion;
-
-/**
- * {@link Cache} implementation that uses a 2.x or later release of 
- * JBoss Cache configured for pessimistic locking.
- * 
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1.1 $
- */
-public class PessimisticJBCCache extends JBCCacheBase implements Cache
-{
-   public PessimisticJBCCache(org.jboss.cache.Cache<Object, Object> cache, String regionName, 
-                              String regionPrefix, TransactionManager transactionManager,
-                              Properties properties) 
-   throws CacheException {
-       super(cache, regionName, regionPrefix, transactionManager, properties);
-   }
-
-   @Override
-   protected void establishRegionRootNode()
-   {            
-      // For pessimistic locking, we just want to toss out our ref
-      // to any old invalid root node and get the latest (may be null)            
-      regionRoot = cache.getRoot().getChild( regionFqn );               
-   }
-
-   @Override
-   protected Node<Object, Object> createRegionRootNode()
-   {
-      Node<Object, Object> root = cache.getRoot();
-      Node<Object, Object> targetNode = root.getChild( regionFqn );
-      if (targetNode == null || !targetNode.isValid()) {
-         cache.getInvocationContext().getOptionOverrides().setDataVersion(NonLockingDataVersion.INSTANCE);          
-         targetNode = root.addChild( regionFqn );    
-      }
-
-      // Never evict this node
-      targetNode.setResident(true);
-
-      return targetNode;
-   }
-
-    public Object get(Object key) throws CacheException {
-        Transaction tx = suspend();
-        try {
-            ensureRegionRootExists();
-            if (key instanceof QueryKey) {
-               cache.getInvocationContext().getOptionOverrides().setLockAcquisitionTimeout(0);  
-            }
-            return cache.get( new Fqn( regionFqn, key ), ITEM );
-        }
-        catch (TimeoutException e) {
-           if (key instanceof QueryKey)
-              return null;
-           throw SecondLevelCacheUtil.convertToHibernateException(e);
-        }
-        finally {
-            resume( tx );
-        }
-    }
-    
-    public Object read(Object key) throws CacheException {
-        try {
-            ensureRegionRootExists();
-            return cache.get( new Fqn( regionFqn, key ), ITEM );
-        }
-        catch (Exception e) {
-            throw SecondLevelCacheUtil.convertToHibernateException(e);
-        }
-    }
-
-    public void update(Object key, Object value) throws CacheException {
-        try {
-            ensureRegionRootExists();
-        	if (localOnlyQueries && key instanceof QueryKey) {
-               cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
-            }
-            cache.put( new Fqn( regionFqn, key ), ITEM, value );
-        }
-        catch (Exception e) {
-            throw SecondLevelCacheUtil.convertToHibernateException(e);
-        }
-    }
-
-    public void put(Object key, Object value) throws CacheException {
-        Transaction tx = null;
-        try {
-            if (forTimestamps) {
-               // For timestamps, we suspend and send async
-               tx = suspend();
-               ensureRegionRootExists();
-               // Timestamps don't use putForExternalRead, but are async
-               if (forceAsync) // else the cache already is async or local
-               {
-                  cache.getInvocationContext().getOptionOverrides().setForceAsynchronous(true);
-               }
-               cache.put(new Fqn( regionFqn, key ), ITEM, value);               
-            }
-            else if (key instanceof QueryKey) {
-               // For queries we use a short timeout and ignore failures
-               ensureRegionRootExists();
-               Option option = new Option();
-               option.setCacheModeLocal(localOnlyQueries);
-               option.setLockAcquisitionTimeout(2);
-               cache.getInvocationContext().setOptionOverrides(option);
-               cache.put(new Fqn( regionFqn, key ), ITEM, value);
-            }
-            else {
-               ensureRegionRootExists();
-               cache.putForExternalRead(new Fqn( regionFqn, key ), ITEM, value);
-            }
-        }
-        catch (TimeoutException te) {
-           if (!(key instanceof QueryKey))
-              throw SecondLevelCacheUtil.convertToHibernateException(te);
-        }
-        catch (Exception e) {
-            throw SecondLevelCacheUtil.convertToHibernateException(e);
-        }
-        finally {
-            resume( tx );
-        }
-    }
-
-    public void remove(Object key) throws CacheException {
-        try {
-           ensureRegionRootExists();
-           if (localOnlyQueries && key instanceof QueryKey) {
-              cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
-           }
-           cache.removeNode( new Fqn( regionFqn, key ) );
-        }
-        catch (Exception e) {
-            throw SecondLevelCacheUtil.convertToHibernateException(e);
-        }
-    }
-
-    public void clear() throws CacheException {
-        try {
-            cache.removeNode( regionFqn );
-        }
-        catch (Exception e) {
-            throw SecondLevelCacheUtil.convertToHibernateException(e);
-        }
-    }
-
-    public void destroy() throws CacheException {
-        try {
-            // NOTE : evict() operates locally only (i.e., does not propogate
-            // to any other nodes in the potential cluster).  This is
-            // exactly what is needed when we destroy() here; destroy() is used
-            // as part of the process of shutting down a SessionFactory; thus
-            // these removals should not be propogated
-           // FIXME NPE bug in 2.0.0.ALPHA1, so we don't use evict 'til fixed
-//            cache.evict( regionFqn, true );
-           cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
-           cache.removeNode( regionFqn );
-           
-           if (cache.getConfiguration().isUseRegionBasedMarshalling() 
-                 && !SecondLevelCacheUtil.isSharedClassLoaderRegion(regionName))
-           {
-              inactivateCacheRegion();
-           }
-        }
-        catch( Exception e ) {
-            throw SecondLevelCacheUtil.convertToHibernateException( e );
-        }
-    }
-    
-    public String toString() {
-        return "PessimisticJBCCache(" + regionName + ')';
-    }
-}

Deleted: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/TransactionalCacheFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/TransactionalCacheFactory.java	2008-07-14 15:53:11 UTC (rev 75783)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/TransactionalCacheFactory.java	2008-07-14 15:53:39 UTC (rev 75784)
@@ -1,115 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.entity;
-
-import java.util.Properties;
-
-import org.hibernate.cache.Cache;
-import org.hibernate.cache.CacheException;
-import org.jboss.cache.Version;
-
-/**
- * Factory for <cdoe>org.hibernate.cache.Cache</code> implementations that
- * work with JBoss Cache.
- * 
- * @author Brian Stansberry
- */
-public abstract class TransactionalCacheFactory
-{
-
-   /**
-    * Gets and configures a concrete TransactionalCacheFactory suitable for 
-    * interoperation with the version of JBoss Cache visible on the classpath.
-    * 
-    * @param hibernateConfig properties to use to {@link #configure(Properties) configure}
-    *                        the factory.
-    * @return the factory
-    * 
-    * @throws CacheException
-    */
-   public static TransactionalCacheFactory getFactory(Properties hibernateConfig) throws CacheException
-   {
-      String factoryClass = null;
-      short version = Version.getVersionShort();
-      if (version >= Version.getVersionShort("2.0.0.GA") || version <= 0)
-      {
-         factoryClass = "org.jboss.ejb3.entity.JBCCacheFactory";
-      }
-      else
-      {
-         // TODO write a factory for the old hibernate stuff
-         // needs to be in a separate code tree from JBCCacheFactory as 
-         // TreeCacheMBean is no longer available in 2.0
-         throw new IllegalStateException("Cannot create factory for JBC 1.x");
-      }
-      
-      try
-      {
-         Class clazz = Thread.currentThread().getContextClassLoader().loadClass(factoryClass);
-         TransactionalCacheFactory factory = (TransactionalCacheFactory) clazz.newInstance();
-         factory.configure(hibernateConfig);
-         
-         return factory;
-      }
-      catch (CacheException e)
-      {
-         throw e;
-      }
-      catch (Exception e)
-      {
-         throw new CacheException(e);
-      }
-      
-   }
-   
-   public abstract void start();
-   
-   public abstract void stop();
-   
-   /**
-    * Construct and configure the Cache representation of a named cache region.
-    *
-    * @param regionName the name of the cache region
-    * @param properties configuration settings
-    * @return The Cache representation of the named cache region.
-    * @throws org.hibernate.cache.CacheException
-    *          Indicates an error building the cache region.
-    */
-   public abstract Cache buildCache(String regionName, Properties properties) throws CacheException;
-   
-   /**
-    * Configures the factory using the Hibernate configuration properties.  
-    * Called by {@link #getFactory(Properties)}.
-    *  
-    * @param hibernateConfig the Hibernate configuration properties
-    */
-   protected abstract void configure(Properties hibernateConfig);
-   
-   /**
-    * Gets whether the underlying JBoss Cache instance is configured
-    * for optimistic locking.
-    * 
-    * @return <code>true</code> if the JBoss Cache uses optimistic locking;
-    *         <code>false</code> if it uses pessimistic locking
-    */
-   public abstract boolean isOptimistic();
-}

Deleted: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/TreeCacheProviderHook.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/TreeCacheProviderHook.java	2008-07-14 15:53:11 UTC (rev 75783)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/TreeCacheProviderHook.java	2008-07-14 15:53:39 UTC (rev 75784)
@@ -1,123 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.entity;
-
-import java.util.Properties;
-
-import org.hibernate.cache.Cache;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.CacheProvider;
-import org.jboss.logging.Logger;
-
-/**
- * Support for integration as a 2nd level cache with an already existing 
- * JBoss Cache (TreeCache) instance.  The ObjectName of the cache is 
- * provided via the <code>hibernate.treecache.mbean.object_name</code>
- * configuration property.
- * <p/>
- * This class supports both optimistic and pessimistic locking, providing
- * instances of <code>org.hibernate.cache.OptimisticCache</code> if the 
- * underlying JBoss Cache is configured for optimistic locking.
- * 
- * @author Gavin King
- * @author Brian Stansberry
- */
-public class TreeCacheProviderHook implements CacheProvider
-{
-   /**
-    * Name of the Hibernate configuration property used to provide
-    * the name of the JBoss Cache instance.
-    */
-   public static final String HIBERNATE_CACHE_CONFIG_NAME_PROPERTY = 
-      "hibernate.cache.jbc2.config.name";
-   
-   /**
-    * Name of the Hibernate configuration property used to provide
-    * the ObjectName of the JBoss Cache instance.
-    * 
-    * @deprecated use {@link #HIBERNATE_CACHE_CONFIG_NAME_PROPERTY}
-    */
-   public static final String HIBERNATE_CACHE_OBJECT_NAME_PROPERTY = 
-      "hibernate.treecache.mbean.object_name";
-   
-   /**
-    * Default ObjectName for the JBoss Cache instance that will be used
-    * if {@link HIBERNATE_CACHE_OBJECT_NAME_PROPERTY} is not provided.
-    */
-   public static final String DEFAULT_MBEAN_OBJECT_NAME = "jboss.cache:service=EJB3EntityTreeCache";
-   
-   protected Logger log = Logger.getLogger(getClass());
-   
-   private TransactionalCacheFactory cacheFactory;
-
-   /**
-    * Construct and configure the Cache representation of a named cache region.
-    *
-    * @param regionName the name of the cache region
-    * @param properties configuration settings
-    * @return The Cache representation of the named cache region.
-    * @throws org.hibernate.cache.CacheException
-    *          Indicates an error building the cache region.
-    */
-   public Cache buildCache(String regionName, Properties properties) throws CacheException
-   {
-      return cacheFactory.buildCache(regionName, properties);
-   }
-
-   public boolean isMinimalPutsEnabledByDefault()
-   {
-      return true;
-   }
-
-   public long nextTimestamp()
-   {
-      return System.currentTimeMillis() / 100;
-   }
-
-   /**
-    * Find the underlying JBoss Cache instance.
-    *
-    * @param properties  All current config settings. 
-    *                    If {@link #HIBERNATE_CACHE_OBJECT_NAME_PROPERTY} is provided,
-    *                    the value will be the expected name of the cache; otherwise
-    *                    {@link #DEFAULT_MBEAN_OBJECT_NAME} will be used.
-    * @throws org.hibernate.cache.CacheException
-    *          Indicates a problem preparing cache for use.
-    */
-   public void start(Properties properties) throws CacheException
-   {
-      cacheFactory = TransactionalCacheFactory.getFactory(properties);
-      cacheFactory.start();
-   }
-
-   public void stop()
-   {
-      if (cacheFactory != null)
-         cacheFactory.stop();
-   }
-   
-   protected TransactionalCacheFactory getCacheFactory()
-   {
-      return cacheFactory;
-   }
-
-}




More information about the jboss-cvs-commits mailing list