[jboss-cvs] JBossAS SVN: r71526 - in projects/ejb3/branches/cluster-dev/ejb3-cache/src: main/java/org/jboss/ejb3/cache/impl and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Mar 31 17:42:45 EDT 2008


Author: bstansberry at jboss.com
Date: 2008-03-31 17:42:45 -0400 (Mon, 31 Mar 2008)
New Revision: 71526

Added:
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/SimpleBackingCacheEntryStore.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/factory/NonClusteredBackingCacheEntryStoreSource.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/BackingCacheEntryStore.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/BackingCacheEntryStoreSource.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/PersistentObjectStore.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractBackingCacheEntryStore.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/FilePersistentObjectStore.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/distributed/MockBackingCacheEntryStoreSource.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/distributed/MockJBCBackingCacheEntryStore.java
Removed:
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/SimplePassivatingIntegratedObjectStore.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/factory/NonClusteredIntegratedObjectStoreSource.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/IntegratedObjectStore.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/IntegratedObjectStoreSource.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/ObjectStore.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/PassivatingBackingCacheEntry.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/PassivatingIntegratedObjectStore.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractPassivatingIntegratedObjectStore.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/FileObjectStore.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/distributed/MockIntegratedObjectStoreSource.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/distributed/MockJBCIntegratedObjectStore.java
Modified:
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/api/Cache.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/api/PassivationManager.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/api/StatefulObjectFactory.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/GroupAwareTransactionalCache.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/TransactionalCache.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/GroupAwareBackingCacheImpl.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/NonPassivatingBackingCacheEntry.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/PassivatingBackingCacheImpl.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/SerializationGroupContainer.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/SerializationGroupMemberContainer.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/factory/GroupAwareCacheFactory.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/factory/NonPassivatingCacheFactory.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/BackingCache.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/BackingCacheEntry.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/PassivatingBackingCache.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/SerializationGroup.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/SerializationGroupMember.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractBackingCache.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractBackingCacheEntry.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractStatefulCacheFactory.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractTimerTask.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/CacheableTimestamp.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/GroupCreationContext.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/ItemCachePair.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/distributed/MockClusterMember.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/mock/MockBeanContainer.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/mock/MockEjb3System.java
Log:
[EJBTHREE-1026] Strip out extraneous abstractions, rename abstractions

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/api/Cache.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/api/Cache.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/api/Cache.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -27,10 +27,10 @@
 /**
  * Cache a stateful object and make sure any life cycle callbacks are
  * called at the appropriate time.
- * 
- * A cache is linked to an object factory. How the link is established is left beyond
- * scope.
- *
+ * <p>
+ * A cache is linked to a {@link StatefulObjectFactory} and a {@link PassivationManager}. 
+ * How the link is established is left beyond scope.
+ * </p>
  * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
  * @author Brian Stansberry
  * 
@@ -39,17 +39,14 @@
 public interface Cache<T extends CacheItem>
 {
    /**
-    * Creates and caches a new instance of <code>T</code>. The new
-    * <code>T</code> *is* returned, but is not regarded as being "in use".
-    * Callers *must not* attempt to use the new <code>T</code> without
-    * first calling {@link #get(Object)}. 
+    * Creates and caches a new instance of <code>T</code>.
     * 
     * @param initTypes   the types of any <code>initValues</code>. 
     *                    May be <code>null</code>.
     * @param initValues  any paramaters to pass to <code>T</code>'s constructor.
     *                    May be null, in which case a default constructor will
     *                    be used.
-    * @return the new <code>T</code> 
+    * @return the new <code>T</code>'s {@link Identifiable#getId() id}. 
     */
    Object create(Class<?> initTypes[], Object initValues[]);
 

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/api/PassivationManager.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/api/PassivationManager.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/api/PassivationManager.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -33,15 +33,14 @@
 {
    /**
     * This method is called after an object has been retrieved
-    * from an ObjectStore.
+    * deserialized after passivation.
     * 
     * @param obj    the object
     */
    void postActivate(T obj);
    
    /**
-    * This method is called before an object is serialized into an
-    * ObjectStore.
+    * This method is called before an object is serialized for passivation.
     * 
     * @param obj    the object
     * 

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/api/StatefulObjectFactory.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/api/StatefulObjectFactory.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/api/StatefulObjectFactory.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -25,11 +25,12 @@
 
 /**
  * Creates and destroys stateful objects.
- * 
+ * <p>
  * The object returned by create has dependencies injected. The PostConstruct
  * callback, if defined, has been called and the Init callback, if defined,
  * has been called.
- *
+ * </p>
+ * 
  * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
  * @version $Revision: $
  */

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/GroupAwareTransactionalCache.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/GroupAwareTransactionalCache.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/GroupAwareTransactionalCache.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -28,7 +28,6 @@
 
 import javax.transaction.TransactionManager;
 
-import org.jboss.ejb3.cache.api.Cache;
 import org.jboss.ejb3.cache.api.CacheItem;
 import org.jboss.ejb3.cache.spi.GroupAwareBackingCache;
 import org.jboss.ejb3.cache.spi.SerializationGroup;
@@ -38,7 +37,7 @@
 import org.jboss.ejb3.cache.spi.impl.ItemCachePair;
 
 /**
- * {@link Cache#isGroupAware Group-aware} version of {@link TransactionalCache}.
+ * Group-aware version of {@link TransactionalCache}.
  * 
  * @author Brian Stansberry
  */
@@ -46,7 +45,7 @@
    extends TransactionalCache<C, T>
 {
    /** 
-    * Another ref to super.delegate. Just saves having to do casts all the time. 
+    * Another ref to super.delegate. Saves having to do casts all the time. 
     */
    private final GroupAwareBackingCache<C, T> groupedCache;
    
@@ -118,7 +117,10 @@
                SerializationGroup<C> group = groupedCache.createGroup();
                for (ItemCachePair pair : contextPairs)
                {
-                  pair.getCache().setGroup(pair.getItem(), group);
+                  C pairItem = (C) pair.getItem();
+                  GroupAwareBackingCache<C, T> pairCache = 
+                     (GroupAwareBackingCache<C, T>) pair.getCache();
+                  pairCache.setGroup(pairItem, group);
                }
             }
          }

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/TransactionalCache.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/TransactionalCache.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/TransactionalCache.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -37,7 +37,6 @@
 import org.jboss.ejb3.cache.api.CacheItem;
 import org.jboss.ejb3.cache.spi.BackingCache;
 import org.jboss.ejb3.cache.spi.BackingCacheEntry;
-import org.jboss.ejb3.cache.spi.IntegratedObjectStore;
 import org.jboss.ejb3.cache.spi.SynchronizationCoordinator;
 import org.jboss.ejb3.cache.spi.impl.GroupCreationContext;
 import org.jboss.logging.Logger;
@@ -50,7 +49,7 @@
  * <li>ensures that until the first transaction that accesses a given CacheItem 
  * has completed, any other transaction that attempts to access the item will
  * receive an IllegalStateException</li>
- * <li>Only releases the CacheItem to the underlying {@link IntegratedObjectStore}
+ * <li>Only releases the CacheItem to the underlying {@link BackingCache}
  * when the transaction commits or rolls back.</li>
  * </ol>
  * <p>

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/GroupAwareBackingCacheImpl.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/GroupAwareBackingCacheImpl.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/GroupAwareBackingCacheImpl.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -100,7 +100,10 @@
       {
          // We just *try* to lock; a preReplication is low priority.
          if (!entry.tryLock())
+         {
+            // Abort; wait until whoever has the lock is done
             throw new IllegalStateException("entry " + entry + " is in use");
+         }
          
          try
          {

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/NonPassivatingBackingCacheEntry.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/NonPassivatingBackingCacheEntry.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/NonPassivatingBackingCacheEntry.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -22,6 +22,7 @@
 package org.jboss.ejb3.cache.impl.backing;
 
 import java.io.Serializable;
+import java.util.concurrent.locks.ReentrantLock;
 
 import org.jboss.ejb3.cache.api.CacheItem;
 import org.jboss.ejb3.cache.spi.BackingCacheEntry;
@@ -42,6 +43,7 @@
    private static final long serialVersionUID = 1325918596862109742L;
    
    private T wrapped;
+   private ReentrantLock lock = new ReentrantLock();
    
    /**
     * Create a new SimpleBackingCacheEntry.
@@ -75,4 +77,29 @@
    {
       return wrapped.getId();
    }
+     
+
+   public void lock()
+   { 
+      try
+      {
+         lock.lockInterruptibly();
+      }
+      catch (InterruptedException ie)
+      {
+         throw new RuntimeException("interrupted waiting for lock");
+      }
+   }
+
+   public boolean tryLock()
+   {
+     return lock.tryLock();
+   }
+
+   public void unlock()
+   {
+      if (lock.isHeldByCurrentThread())
+         lock.unlock();
+      
+   }
 }

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/PassivatingBackingCacheImpl.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/PassivatingBackingCacheImpl.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/PassivatingBackingCacheImpl.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -28,22 +28,22 @@
 import org.jboss.ejb3.cache.api.CacheItem;
 import org.jboss.ejb3.cache.api.PassivationManager;
 import org.jboss.ejb3.cache.api.StatefulObjectFactory;
+import org.jboss.ejb3.cache.spi.BackingCacheEntry;
 import org.jboss.ejb3.cache.spi.GroupCompatibilityChecker;
 import org.jboss.ejb3.cache.spi.PassivatingBackingCache;
-import org.jboss.ejb3.cache.spi.PassivatingBackingCacheEntry;
-import org.jboss.ejb3.cache.spi.PassivatingIntegratedObjectStore;
+import org.jboss.ejb3.cache.spi.BackingCacheEntryStore;
 import org.jboss.ejb3.cache.spi.BackingCacheLifecycleListener.LifecycleState;
 import org.jboss.ejb3.cache.spi.impl.AbstractBackingCache;
 import org.jboss.logging.Logger;
 
 /**
  * Non group-aware {@link PassivatingBackingCache} that uses a 
- * {@link PassivatingIntegratedObjectStore} to manage data.
+ * {@link BackingCacheEntryStore} to manage data.
  *
  * @author Brian Stansberry
  * @version $Revision: 65339 $
  */
-public class PassivatingBackingCacheImpl<C extends CacheItem, T extends PassivatingBackingCacheEntry<C>>
+public class PassivatingBackingCacheImpl<C extends CacheItem, T extends BackingCacheEntry<C>>
    extends AbstractBackingCache<C>  
    implements PassivatingBackingCache<C, T>
 {
@@ -51,11 +51,11 @@
    
    private StatefulObjectFactory<T> factory;
    private PassivationManager<T> passivationManager;
-   private PassivatingIntegratedObjectStore<C, T> store;
+   private BackingCacheEntryStore<C, T> store;
    
    public PassivatingBackingCacheImpl(StatefulObjectFactory<T> factory, 
                                      PassivationManager<T> passivationManager, 
-                                     PassivatingIntegratedObjectStore<C, T> store)
+                                     BackingCacheEntryStore<C, T> store)
    {
       assert factory != null : "factory is null";
       assert passivationManager != null : "passivationManager is null";

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/SerializationGroupContainer.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/SerializationGroupContainer.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/SerializationGroupContainer.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -31,11 +31,8 @@
 import org.jboss.logging.Logger;
 
 /**
- * Comment
- *  
- *  FIXME determine whether SerializationGroup clustering support should
- *  be controlled by a property of this container or via a param passed
- *  to create(). 
+ * Functions as both a StatefulObjectFactory and PassivationManager for
+ * {@link SerializationGroup}s.
  *
  * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
  * @author Brian Stansberry

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/SerializationGroupMemberContainer.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/SerializationGroupMemberContainer.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/SerializationGroupMemberContainer.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -30,25 +30,27 @@
 import org.jboss.ejb3.cache.spi.GroupAwareBackingCache;
 import org.jboss.ejb3.cache.spi.GroupCompatibilityChecker;
 import org.jboss.ejb3.cache.spi.PassivatingBackingCache;
-import org.jboss.ejb3.cache.spi.PassivatingIntegratedObjectStore;
+import org.jboss.ejb3.cache.spi.BackingCacheEntryStore;
 import org.jboss.ejb3.cache.spi.SerializationGroup;
 import org.jboss.ejb3.cache.spi.SerializationGroupMember;
 import org.jboss.logging.Logger;
 
 /**
+ * Functions as both a StatefulObjectFactory and PassivationManager for
+ * {@link SerializationGroupMember}s.
+ * 
  * @author Brian Stansberry
- *
  */
 public class SerializationGroupMemberContainer<C extends CacheItem>
    implements StatefulObjectFactory<SerializationGroupMember<C>>, 
               PassivationManager<SerializationGroupMember<C>>, 
-              PassivatingIntegratedObjectStore<C, SerializationGroupMember<C>>
+              BackingCacheEntryStore<C, SerializationGroupMember<C>>
 {
    private static final Logger log = Logger.getLogger(SerializationGroupMemberContainer.class);
    
    private StatefulObjectFactory<C> factory;
    private PassivationManager<C> passivationManager;
-   private PassivatingIntegratedObjectStore<C, SerializationGroupMember<C>> store;
+   private BackingCacheEntryStore<C, SerializationGroupMember<C>> store;
    private GroupAwareBackingCache<C, SerializationGroupMember<C>> delegate;
    
    /**
@@ -59,7 +61,7 @@
    
    public SerializationGroupMemberContainer(StatefulObjectFactory<C> factory, 
                                             PassivationManager<C> passivationManager, 
-                                            PassivatingIntegratedObjectStore<C, SerializationGroupMember<C>> store,
+                                            BackingCacheEntryStore<C, SerializationGroupMember<C>> store,
                                             PassivatingBackingCache<C, SerializationGroup<C>> groupCache)
    {
       assert factory != null : "factory is null";

Added: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/SimpleBackingCacheEntryStore.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/SimpleBackingCacheEntryStore.java	                        (rev 0)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/SimpleBackingCacheEntryStore.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -0,0 +1,236 @@
+/*
+ * 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.cache.impl.backing;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.cache.api.CacheItem;
+import org.jboss.ejb3.cache.spi.BackingCacheEntry;
+import org.jboss.ejb3.cache.spi.GroupCompatibilityChecker;
+import org.jboss.ejb3.cache.spi.BackingCacheEntryStore;
+import org.jboss.ejb3.cache.spi.PersistentObjectStore;
+import org.jboss.ejb3.cache.spi.impl.AbstractBackingCacheEntryStore;
+import org.jboss.ejb3.cache.spi.impl.CacheableTimestamp;
+
+/**
+ * A {@link BackingCacheEntryStore} that stores in a simple
+ * <code>Map</code> and delegates to a provided {@link PersistentObjectStore} for 
+ * persistence.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class SimpleBackingCacheEntryStore<C extends CacheItem, T extends BackingCacheEntry<C>>
+      extends AbstractBackingCacheEntryStore<C, T, Object>
+{
+   private final PersistentObjectStore<T> store;
+   private Map<Object, T> cache;
+   private Map<Object, Long> passivatedEntries;
+   
+   /**
+    * Create a new SimpleIntegratedObjectStore.
+    */
+   public SimpleBackingCacheEntryStore(PersistentObjectStore<T> store, 
+                                                 CacheConfig config,
+                                                 String name,
+                                                 boolean forGroups)
+   {
+      super(config, name, forGroups);
+      
+      assert store != null : "store is null";
+      
+      this.store = store;
+      this.cache = new ConcurrentHashMap<Object, T>();
+      this.passivatedEntries = new ConcurrentHashMap<Object, Long>();      
+   }
+   
+   public boolean isClustered()
+   {
+      return false;
+   }
+
+   public T get(Object key)
+   {
+      T entry = cache.get(key);
+      if(entry == null)
+      {
+         entry = store.load(key);
+         if(entry != null)
+         {
+            cache.put(key, entry);
+            passivatedEntries.remove(key);
+         }
+      }
+      return entry;
+   }
+
+   public void insert(T entry)
+   {
+      Object key = entry.getId();
+      if (cache.containsKey(key) || passivatedEntries.containsKey(key))
+      {
+         throw new IllegalStateException(key + " is already in store");
+      }
+      cache.put(key, entry);
+   }
+   
+   public void update(T entry, boolean modified)
+   {
+      Object key = entry.getId();
+      if (!cache.containsKey(key) && !passivatedEntries.containsKey(key))
+      {
+         throw new IllegalStateException(key + " is not managed by this store");
+      }
+         
+      // Otherwise we do nothing; we already have a ref to the entry
+   }
+
+   public void passivate(T entry)
+   {
+      synchronized (entry)
+      {
+         Object key = entry.getId();
+         store.store(entry);  
+         passivatedEntries.put(key, new Long(entry.getLastUsed()));         
+         cache.remove(key);
+      }
+   }
+
+   public T remove(Object id)
+   {
+      T entry = get(id);
+      if (entry != null)
+      {
+         cache.remove(id);
+      }
+      return entry;
+   } 
+
+   protected void internalStart()
+   {
+      store.start();
+      
+      super.internalStart();
+   }
+
+   protected void internalStop()
+   {      
+      store.stop();
+      
+      super.internalStop();
+   }
+
+   @SuppressWarnings("unchecked")
+   public boolean isCompatibleWith(GroupCompatibilityChecker other)
+   {
+      if (other instanceof BackingCacheEntryStore)
+      {
+         return ((BackingCacheEntryStore) other).isClustered() == false;
+      }
+      return false;
+   }
+
+   // -------------------------------  AbstractBackingCacheEntryStore
+
+   @Override
+   public int getInMemoryCount()
+   {
+      return cache.size();
+   }
+   
+   @Override
+   public int getPassivatedCount()
+   {
+      return passivatedEntries.size();
+   }   
+   
+   @Override
+   protected void processPassivation(Object key, long lastUse)
+   {
+      if (!isRunning())
+         return;
+      
+      // If we are for groups we shouldn't be getting a processPassivation
+      // call at all, but just to be safe we'll ignore it
+      if (!isForGroups())
+      {
+         getPassivatingCache().passivate(key);
+      }
+   }
+   
+   @Override
+   protected void processExpiration(Object key, long lastUse)
+   {
+      if (!isRunning())
+         return;
+      
+      getPassivatingCache().remove(key);
+   }
+
+   @Override
+   @SuppressWarnings("unchecked")
+   protected CacheableTimestamp<Object>[] getInMemoryEntries()
+   {     
+      Set<CacheableTimestamp<Object>> set = new HashSet<CacheableTimestamp<Object>>();
+      for (Map.Entry<Object, T> entry : cache.entrySet())
+      {
+         set.add(new CacheableTimestamp<Object>(entry.getKey(), entry.getValue().getLastUsed()));
+      }
+      CacheableTimestamp<Object>[] array = new CacheableTimestamp[set.size()];
+      array = set.toArray(array);
+      Arrays.sort(array);
+      return array;
+   }
+
+   @Override
+   @SuppressWarnings("unchecked")
+   protected CacheableTimestamp<Object>[] getAllEntries()
+   {     
+      Set<CacheableTimestamp<Object>> set = new HashSet<CacheableTimestamp<Object>>();
+      for (Map.Entry<Object, T> entry : cache.entrySet())
+      {
+         set.add(new CacheableTimestamp<Object>(entry.getKey(), entry.getValue().getLastUsed()));
+      }
+      CacheableTimestamp<Object>[] inMemory = new CacheableTimestamp[set.size()];
+      inMemory = set.toArray(inMemory);   
+      
+      set = new HashSet<CacheableTimestamp<Object>>();
+      for (Map.Entry<Object, Long> entry : passivatedEntries.entrySet())
+      {
+         set.add(new CacheableTimestamp<Object>(entry.getKey(), entry.getValue()));
+      }
+      CacheableTimestamp<Object>[] passivated = new CacheableTimestamp[set.size()];
+      passivated = set.toArray(passivated);
+
+      CacheableTimestamp<Object>[] all = new CacheableTimestamp[passivated.length + inMemory.length];
+      System.arraycopy(passivated, 0, all, 0, passivated.length);
+      System.arraycopy(inMemory, 0, all, passivated.length, inMemory.length);
+      Arrays.sort(all);
+      return all;
+   }
+}

Deleted: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/SimplePassivatingIntegratedObjectStore.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/SimplePassivatingIntegratedObjectStore.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/backing/SimplePassivatingIntegratedObjectStore.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -1,236 +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.cache.impl.backing;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.jboss.ejb3.annotation.CacheConfig;
-import org.jboss.ejb3.cache.api.CacheItem;
-import org.jboss.ejb3.cache.spi.GroupCompatibilityChecker;
-import org.jboss.ejb3.cache.spi.ObjectStore;
-import org.jboss.ejb3.cache.spi.PassivatingBackingCacheEntry;
-import org.jboss.ejb3.cache.spi.PassivatingIntegratedObjectStore;
-import org.jboss.ejb3.cache.spi.impl.AbstractPassivatingIntegratedObjectStore;
-import org.jboss.ejb3.cache.spi.impl.CacheableTimestamp;
-
-/**
- * A {@link PassivatingIntegratedObjectStore} that stores in a simple
- * <code>Map</code> and delegates to a provided {@link ObjectStore} for 
- * persistence.
- * 
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class SimplePassivatingIntegratedObjectStore<C extends CacheItem, T extends PassivatingBackingCacheEntry<C>>
-      extends AbstractPassivatingIntegratedObjectStore<C, T, Object>
-{
-   private final ObjectStore<T> store;
-   private Map<Object, T> cache;
-   private Map<Object, Long> passivatedEntries;
-   
-   /**
-    * Create a new SimpleIntegratedObjectStore.
-    */
-   public SimplePassivatingIntegratedObjectStore(ObjectStore<T> store, 
-                                                 CacheConfig config,
-                                                 String name,
-                                                 boolean forGroups)
-   {
-      super(config, name, forGroups);
-      
-      assert store != null : "store is null";
-      
-      this.store = store;
-      this.cache = new ConcurrentHashMap<Object, T>();
-      this.passivatedEntries = new ConcurrentHashMap<Object, Long>();      
-   }
-   
-   public boolean isClustered()
-   {
-      return false;
-   }
-
-   public T get(Object key)
-   {
-      T entry = cache.get(key);
-      if(entry == null)
-      {
-         entry = store.load(key);
-         if(entry != null)
-         {
-            cache.put(key, entry);
-            passivatedEntries.remove(key);
-         }
-      }
-      return entry;
-   }
-
-   public void insert(T entry)
-   {
-      Object key = entry.getId();
-      if (cache.containsKey(key) || passivatedEntries.containsKey(key))
-      {
-         throw new IllegalStateException(key + " is already in store");
-      }
-      cache.put(key, entry);
-   }
-   
-   public void update(T entry, boolean modified)
-   {
-      Object key = entry.getId();
-      if (!cache.containsKey(key) && !passivatedEntries.containsKey(key))
-      {
-         throw new IllegalStateException(key + " is not managed by this store");
-      }
-         
-      // Otherwise we do nothing; we already have a ref to the entry
-   }
-
-   public void passivate(T entry)
-   {
-      synchronized (entry)
-      {
-         Object key = entry.getId();
-         store.store(entry);  
-         passivatedEntries.put(key, new Long(entry.getLastUsed()));         
-         cache.remove(key);
-      }
-   }
-
-   public T remove(Object id)
-   {
-      T entry = get(id);
-      if (entry != null)
-      {
-         cache.remove(id);
-      }
-      return entry;
-   } 
-
-   protected void internalStart()
-   {
-      store.start();
-      
-      super.internalStart();
-   }
-
-   protected void internalStop()
-   {      
-      store.stop();
-      
-      super.internalStop();
-   }
-
-   @SuppressWarnings("unchecked")
-   public boolean isCompatibleWith(GroupCompatibilityChecker other)
-   {
-      if (other instanceof PassivatingIntegratedObjectStore)
-      {
-         return ((PassivatingIntegratedObjectStore) other).isClustered() == false;
-      }
-      return false;
-   }
-
-   // -------------------------------  AbstractPassivatingIntegratedObjectStore
-
-   @Override
-   public int getInMemoryCount()
-   {
-      return cache.size();
-   }
-   
-   @Override
-   public int getPassivatedCount()
-   {
-      return passivatedEntries.size();
-   }   
-   
-   @Override
-   protected void processPassivation(Object key, long lastUse)
-   {
-      if (!isRunning())
-         return;
-      
-      // If we are for groups we shouldn't be getting a processPassivation
-      // call at all, but just to be safe we'll ignore it
-      if (!isForGroups())
-      {
-         getPassivatingCache().passivate(key);
-      }
-   }
-   
-   @Override
-   protected void processExpiration(Object key, long lastUse)
-   {
-      if (!isRunning())
-         return;
-      
-      getPassivatingCache().remove(key);
-   }
-
-   @Override
-   @SuppressWarnings("unchecked")
-   protected CacheableTimestamp<Object>[] getInMemoryEntries()
-   {     
-      Set<CacheableTimestamp<Object>> set = new HashSet<CacheableTimestamp<Object>>();
-      for (Map.Entry<Object, T> entry : cache.entrySet())
-      {
-         set.add(new CacheableTimestamp<Object>(entry.getKey(), entry.getValue().getLastUsed()));
-      }
-      CacheableTimestamp<Object>[] array = new CacheableTimestamp[set.size()];
-      array = set.toArray(array);
-      Arrays.sort(array);
-      return array;
-   }
-
-   @Override
-   @SuppressWarnings("unchecked")
-   protected CacheableTimestamp<Object>[] getAllEntries()
-   {     
-      Set<CacheableTimestamp<Object>> set = new HashSet<CacheableTimestamp<Object>>();
-      for (Map.Entry<Object, T> entry : cache.entrySet())
-      {
-         set.add(new CacheableTimestamp<Object>(entry.getKey(), entry.getValue().getLastUsed()));
-      }
-      CacheableTimestamp<Object>[] inMemory = new CacheableTimestamp[set.size()];
-      inMemory = set.toArray(inMemory);   
-      
-      set = new HashSet<CacheableTimestamp<Object>>();
-      for (Map.Entry<Object, Long> entry : passivatedEntries.entrySet())
-      {
-         set.add(new CacheableTimestamp<Object>(entry.getKey(), entry.getValue()));
-      }
-      CacheableTimestamp<Object>[] passivated = new CacheableTimestamp[set.size()];
-      passivated = set.toArray(passivated);
-
-      CacheableTimestamp<Object>[] all = new CacheableTimestamp[passivated.length + inMemory.length];
-      System.arraycopy(passivated, 0, all, 0, passivated.length);
-      System.arraycopy(inMemory, 0, all, passivated.length, inMemory.length);
-      Arrays.sort(all);
-      return all;
-   }
-}

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/factory/GroupAwareCacheFactory.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/factory/GroupAwareCacheFactory.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/factory/GroupAwareCacheFactory.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -38,9 +38,9 @@
 import org.jboss.ejb3.cache.impl.backing.SerializationGroupMemberContainer;
 import org.jboss.ejb3.cache.spi.BackingCacheLifecycleListener;
 import org.jboss.ejb3.cache.spi.GroupAwareBackingCache;
-import org.jboss.ejb3.cache.spi.IntegratedObjectStoreSource;
+import org.jboss.ejb3.cache.spi.BackingCacheEntryStoreSource;
 import org.jboss.ejb3.cache.spi.PassivatingBackingCache;
-import org.jboss.ejb3.cache.spi.PassivatingIntegratedObjectStore;
+import org.jboss.ejb3.cache.spi.BackingCacheEntryStore;
 import org.jboss.ejb3.cache.spi.SerializationGroup;
 import org.jboss.ejb3.cache.spi.SerializationGroupMember;
 import org.jboss.ejb3.cache.spi.impl.AbstractStatefulCacheFactory;
@@ -49,8 +49,8 @@
 /**
  * {@link StatefulCacheFactory} implementation that can return a group-aware 
  * cache.  How the cache functions depends on the behavior of the 
- * {@link PassivatingIntegratedObjectStore} implementations returned by
- * the injected {@link IntegratedObjectStoreSource}.
+ * {@link BackingCacheEntryStore} implementations returned by
+ * the injected {@link BackingCacheEntryStoreSource}.
  * 
  * @author Brian Stansberry
  * @version $Revision$
@@ -61,13 +61,13 @@
    private static final Logger log = Logger.getLogger(GroupAwareCacheFactory.class);
    
    private final Map<String, GroupCacheTracker> groupCaches;
-   private final IntegratedObjectStoreSource<T> storeSource;
+   private final BackingCacheEntryStoreSource<T> storeSource;
    
    /**
     * Creates a new GroupAwareCacheFactory that gets its object stores from
     * the provided source.
     */
-   public GroupAwareCacheFactory(IntegratedObjectStoreSource<T> storeSource)
+   public GroupAwareCacheFactory(BackingCacheEntryStoreSource<T> storeSource)
    {
       assert storeSource != null : "storeSource is null";
       
@@ -107,7 +107,7 @@
       }
       
       // Create the store for SerializationGroupMembers from the container
-      PassivatingIntegratedObjectStore<T, SerializationGroupMember<T>> store = 
+      BackingCacheEntryStore<T, SerializationGroupMember<T>> store = 
          storeSource.createIntegratedObjectStore(containerName, configName, cacheConfig, 
                                                  getTransactionManager(), getSynchronizationCoordinator());
       
@@ -146,7 +146,7 @@
 
    private PassivatingBackingCache<T, SerializationGroup<T>> createGroupCache(String configName, CacheConfig cacheConfig)
    {
-      PassivatingIntegratedObjectStore<T, SerializationGroup<T>> store = 
+      BackingCacheEntryStore<T, SerializationGroup<T>> store = 
          storeSource.createGroupIntegratedObjectStore(configName, configName, cacheConfig, 
                                                       getTransactionManager(), 
                                                       getSynchronizationCoordinator());

Added: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/factory/NonClusteredBackingCacheEntryStoreSource.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/factory/NonClusteredBackingCacheEntryStoreSource.java	                        (rev 0)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/factory/NonClusteredBackingCacheEntryStoreSource.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -0,0 +1,191 @@
+/*
+ * 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.cache.impl.factory;
+
+import java.io.File;
+
+import javax.transaction.TransactionManager;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.cache.api.CacheItem;
+import org.jboss.ejb3.cache.impl.backing.SimpleBackingCacheEntryStore;
+import org.jboss.ejb3.cache.spi.BackingCacheEntryStoreSource;
+import org.jboss.ejb3.cache.spi.BackingCacheEntryStore;
+import org.jboss.ejb3.cache.spi.SerializationGroup;
+import org.jboss.ejb3.cache.spi.SerializationGroupMember;
+import org.jboss.ejb3.cache.spi.SynchronizationCoordinator;
+import org.jboss.ejb3.cache.spi.impl.FilePersistentObjectStore;
+
+/**
+ * {@link BackingCacheEntryStoreSource} for a non-clustered cache. Uses
+ * a {@link FilePersistentObjectStore} store for persistence.
+ * 
+ * @author Brian Stansberry
+ */
+public class NonClusteredBackingCacheEntryStoreSource<T extends CacheItem> 
+   implements BackingCacheEntryStoreSource<T>
+{
+   /**
+    * The default session store directory name ("<tt>ejb3/sessions</tt>").
+    */
+   String DEFAULT_SESSION_DIRECTORY_NAME = "ejb3" + File.separatorChar + "sessions";
+   
+   /**
+    * The default session group store directory name ("<tt>ejb3/sfsbgroups</tt>").
+    */
+   String DEFAULT_GROUP_DIRECTORY_NAME = "ejb3" + File.separatorChar + "sfsbgroups";
+   
+   public static final int DEFAULT_SUBDIRECTORY_COUNT = 100;
+   
+   private String sessionDirectoryName = DEFAULT_SESSION_DIRECTORY_NAME;
+   private String groupDirectoryName = DEFAULT_GROUP_DIRECTORY_NAME;
+   private String baseDirectoryName;
+   private int subdirectoryCount = DEFAULT_SUBDIRECTORY_COUNT;
+   
+   public BackingCacheEntryStore<T, SerializationGroup<T>> createGroupIntegratedObjectStore(String containerName, String cacheConfigName,
+         CacheConfig cacheConfig, TransactionManager transactionManager, SynchronizationCoordinator synchronizationCoordinator)
+   {
+      FilePersistentObjectStore<SerializationGroup<T>> objectStore = new FilePersistentObjectStore<SerializationGroup<T>>();
+      objectStore.setStorageDirectory(getFullGroupDirectoryName(containerName));
+      objectStore.setSubdirectoryCount(subdirectoryCount);
+      
+      String storeNameSuffix = (cacheConfig.name().length() == 0) ? "" : "-" + cacheConfig;
+      String storeName = "StdGroupStore" + storeNameSuffix;
+      SimpleBackingCacheEntryStore<T, SerializationGroup<T>> store = 
+         new SimpleBackingCacheEntryStore<T, SerializationGroup<T>>(objectStore, cacheConfig, storeName, true);
+      
+      return store;
+   }
+
+   public BackingCacheEntryStore<T, SerializationGroupMember<T>> createIntegratedObjectStore(String containerName, String cacheConfigName,
+         CacheConfig cacheConfig, TransactionManager transactionManager, SynchronizationCoordinator synchronizationCoordinator)
+   {
+      FilePersistentObjectStore<SerializationGroupMember<T>> objectStore = new FilePersistentObjectStore<SerializationGroupMember<T>>();
+      objectStore.setStorageDirectory(getFullSessionDirectoryName(containerName));
+      objectStore.setSubdirectoryCount(subdirectoryCount);
+      
+      SimpleBackingCacheEntryStore<T, SerializationGroupMember<T>> store = 
+         new SimpleBackingCacheEntryStore<T, SerializationGroupMember<T>>(objectStore, cacheConfig, containerName, false);
+      
+      return store;
+   }
+   
+   protected String getFullSessionDirectoryName(String containerName)
+   {
+      File base = new File(getBaseDirectoryName());
+      File child = new File(base, getSessionDirectoryName());
+      File full = new File(child, containerName);
+      return full.getAbsolutePath();
+   }
+   
+   protected String getFullGroupDirectoryName(String containerName)
+   {
+      File base = new File(getBaseDirectoryName());
+      File child = new File(base, getGroupDirectoryName());
+      File full = new File(child, containerName);
+      return full.getAbsolutePath();      
+   }
+
+   /**
+    * Gets the name of the base directory under which sessions and 
+    * groups should be stored. Default is the java.io.tmpdir.
+    */
+   public synchronized String getBaseDirectoryName()
+   {
+      if (baseDirectoryName == null)
+      {
+         setBaseDirectoryName(System.getProperty("java.io.tmpdir"));
+      }
+      return baseDirectoryName;
+   }
+
+   /**
+    * Sets the name of the base directory under which sessions and 
+    * groups should be stored.
+    */
+   public void setBaseDirectoryName(String baseDirectoryName)
+   {
+      this.baseDirectoryName = baseDirectoryName;
+   }
+
+   /**
+    * Gets the name of the subdirectory under the 
+    * {@link #getBaseDirectoryName() base directory} under which sessions 
+    * should be stored. Default is {@link #DEFAULT_SESSION_DIRECTORY_NAME}.
+    */
+   public String getSessionDirectoryName()
+   {
+      return sessionDirectoryName;
+   }
+
+   /**
+    * Sets the name of the subdirectory under the 
+    * {@link #getBaseDirectoryName() base directory} under which sessions 
+    * should be stored.
+    */
+   public void setSessionDirectoryName(String directoryName)
+   {
+      this.sessionDirectoryName = directoryName;
+   }
+
+   /**
+    * Gets the name of the subdirectory under the 
+    * {@link #getBaseDirectoryName() base directory} under which session groups 
+    * should be stored. Default is {@link #DEFAULT_GROUP_DIRECTORY_NAME}.
+    */
+   public String getGroupDirectoryName()
+   {
+      return groupDirectoryName;
+   }
+
+   /**
+    * Sets the name of the subdirectory under the 
+    * {@link #getBaseDirectoryName() base directory} under which session groups 
+    * should be stored.
+    */
+   public void setGroupDirectoryName(String groupDirectoryName)
+   {
+      this.groupDirectoryName = groupDirectoryName;
+   }
+
+   /**
+    * Gets the number of subdirectories under the session directory or the
+    * group directory into which the sessions/groups should be divided. Using
+    * subdirectories helps overcome filesystem limits on the number of items
+    * that can be stored. Default is {@link #DEFAULT_SUBDIRECTORY_COUNT}.
+    */
+   public int getSubdirectoryCount()
+   {
+      return subdirectoryCount;
+   }
+
+   /**
+    * Sets the number of subdirectories under the session directory or the
+    * group directory into which the sessions/groups should be divided.
+    */
+   public void setSubdirectoryCount(int subdirectoryCount)
+   {
+      this.subdirectoryCount = subdirectoryCount;
+   }
+   
+}

Deleted: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/factory/NonClusteredIntegratedObjectStoreSource.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/factory/NonClusteredIntegratedObjectStoreSource.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/factory/NonClusteredIntegratedObjectStoreSource.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -1,191 +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.cache.impl.factory;
-
-import java.io.File;
-
-import javax.transaction.TransactionManager;
-
-import org.jboss.ejb3.annotation.CacheConfig;
-import org.jboss.ejb3.cache.api.CacheItem;
-import org.jboss.ejb3.cache.impl.backing.SimplePassivatingIntegratedObjectStore;
-import org.jboss.ejb3.cache.spi.IntegratedObjectStoreSource;
-import org.jboss.ejb3.cache.spi.PassivatingIntegratedObjectStore;
-import org.jboss.ejb3.cache.spi.SerializationGroup;
-import org.jboss.ejb3.cache.spi.SerializationGroupMember;
-import org.jboss.ejb3.cache.spi.SynchronizationCoordinator;
-import org.jboss.ejb3.cache.spi.impl.FileObjectStore;
-
-/**
- * {@link IntegratedObjectStoreSource} for a non-clustered cache. Uses
- * a {@link FileObjectStore} store for persistence.
- * 
- * @author Brian Stansberry
- */
-public class NonClusteredIntegratedObjectStoreSource<T extends CacheItem> 
-   implements IntegratedObjectStoreSource<T>
-{
-   /**
-    * The default session store directory name ("<tt>ejb3/sessions</tt>").
-    */
-   String DEFAULT_SESSION_DIRECTORY_NAME = "ejb3" + File.separatorChar + "sessions";
-   
-   /**
-    * The default session group store directory name ("<tt>ejb3/sfsbgroups</tt>").
-    */
-   String DEFAULT_GROUP_DIRECTORY_NAME = "ejb3" + File.separatorChar + "sfsbgroups";
-   
-   public static final int DEFAULT_SUBDIRECTORY_COUNT = 100;
-   
-   private String sessionDirectoryName = DEFAULT_SESSION_DIRECTORY_NAME;
-   private String groupDirectoryName = DEFAULT_GROUP_DIRECTORY_NAME;
-   private String baseDirectoryName;
-   private int subdirectoryCount = DEFAULT_SUBDIRECTORY_COUNT;
-   
-   public PassivatingIntegratedObjectStore<T, SerializationGroup<T>> createGroupIntegratedObjectStore(String containerName, String cacheConfigName,
-         CacheConfig cacheConfig, TransactionManager transactionManager, SynchronizationCoordinator synchronizationCoordinator)
-   {
-      FileObjectStore<SerializationGroup<T>> objectStore = new FileObjectStore<SerializationGroup<T>>();
-      objectStore.setStorageDirectory(getFullGroupDirectoryName(containerName));
-      objectStore.setSubdirectoryCount(subdirectoryCount);
-      
-      String storeNameSuffix = (cacheConfig.name().length() == 0) ? "" : "-" + cacheConfig;
-      String storeName = "StdGroupStore" + storeNameSuffix;
-      SimplePassivatingIntegratedObjectStore<T, SerializationGroup<T>> store = 
-         new SimplePassivatingIntegratedObjectStore<T, SerializationGroup<T>>(objectStore, cacheConfig, storeName, true);
-      
-      return store;
-   }
-
-   public PassivatingIntegratedObjectStore<T, SerializationGroupMember<T>> createIntegratedObjectStore(String containerName, String cacheConfigName,
-         CacheConfig cacheConfig, TransactionManager transactionManager, SynchronizationCoordinator synchronizationCoordinator)
-   {
-      FileObjectStore<SerializationGroupMember<T>> objectStore = new FileObjectStore<SerializationGroupMember<T>>();
-      objectStore.setStorageDirectory(getFullSessionDirectoryName(containerName));
-      objectStore.setSubdirectoryCount(subdirectoryCount);
-      
-      SimplePassivatingIntegratedObjectStore<T, SerializationGroupMember<T>> store = 
-         new SimplePassivatingIntegratedObjectStore<T, SerializationGroupMember<T>>(objectStore, cacheConfig, containerName, false);
-      
-      return store;
-   }
-   
-   protected String getFullSessionDirectoryName(String containerName)
-   {
-      File base = new File(getBaseDirectoryName());
-      File child = new File(base, getSessionDirectoryName());
-      File full = new File(child, containerName);
-      return full.getAbsolutePath();
-   }
-   
-   protected String getFullGroupDirectoryName(String containerName)
-   {
-      File base = new File(getBaseDirectoryName());
-      File child = new File(base, getGroupDirectoryName());
-      File full = new File(child, containerName);
-      return full.getAbsolutePath();      
-   }
-
-   /**
-    * Gets the name of the base directory under which sessions and 
-    * groups should be stored. Default is the java.io.tmpdir.
-    */
-   public synchronized String getBaseDirectoryName()
-   {
-      if (baseDirectoryName == null)
-      {
-         setBaseDirectoryName(System.getProperty("java.io.tmpdir"));
-      }
-      return baseDirectoryName;
-   }
-
-   /**
-    * Sets the name of the base directory under which sessions and 
-    * groups should be stored.
-    */
-   public void setBaseDirectoryName(String baseDirectoryName)
-   {
-      this.baseDirectoryName = baseDirectoryName;
-   }
-
-   /**
-    * Gets the name of the subdirectory under the 
-    * {@link #getBaseDirectoryName() base directory} under which sessions 
-    * should be stored. Default is {@link #DEFAULT_SESSION_DIRECTORY_NAME}.
-    */
-   public String getSessionDirectoryName()
-   {
-      return sessionDirectoryName;
-   }
-
-   /**
-    * Sets the name of the subdirectory under the 
-    * {@link #getBaseDirectoryName() base directory} under which sessions 
-    * should be stored.
-    */
-   public void setSessionDirectoryName(String directoryName)
-   {
-      this.sessionDirectoryName = directoryName;
-   }
-
-   /**
-    * Gets the name of the subdirectory under the 
-    * {@link #getBaseDirectoryName() base directory} under which session groups 
-    * should be stored. Default is {@link #DEFAULT_GROUP_DIRECTORY_NAME}.
-    */
-   public String getGroupDirectoryName()
-   {
-      return groupDirectoryName;
-   }
-
-   /**
-    * Sets the name of the subdirectory under the 
-    * {@link #getBaseDirectoryName() base directory} under which session groups 
-    * should be stored.
-    */
-   public void setGroupDirectoryName(String groupDirectoryName)
-   {
-      this.groupDirectoryName = groupDirectoryName;
-   }
-
-   /**
-    * Gets the number of subdirectories under the session directory or the
-    * group directory into which the sessions/groups should be divided. Using
-    * subdirectories helps overcome filesystem limits on the number of items
-    * that can be stored. Default is {@link #DEFAULT_SUBDIRECTORY_COUNT}.
-    */
-   public int getSubdirectoryCount()
-   {
-      return subdirectoryCount;
-   }
-
-   /**
-    * Sets the number of subdirectories under the session directory or the
-    * group directory into which the sessions/groups should be divided.
-    */
-   public void setSubdirectoryCount(int subdirectoryCount)
-   {
-      this.subdirectoryCount = subdirectoryCount;
-   }
-   
-}

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/factory/NonPassivatingCacheFactory.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/factory/NonPassivatingCacheFactory.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/factory/NonPassivatingCacheFactory.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -37,6 +37,9 @@
  * {@link StatefulCacheFactory} implementation that will return a 
  * non-group-aware cache that doesn't support passivation.
  * 
+ * @see TransactionalCache
+ * @see NonPassivatingBackingCacheImpl
+ * 
  * @author Brian Stansberry
  */
 public class NonPassivatingCacheFactory<T extends CacheItem> 

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/BackingCache.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/BackingCache.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/BackingCache.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -45,7 +45,7 @@
  * functionality.
  * </li>
  * <li>
- * A BackingCache does not attempt to control concurrent access to its
+ * A BackingCache does not attempt to control concurrent client access to its
  * cached {@link BackingCacheEntry} instances, beyond the simple act of
  * {@link BackingCacheEntry#setInUse(boolean) marking the entries as being
  * in or out of use}.  It assumes the external-facing Cache is preventing
@@ -61,10 +61,10 @@
 public interface BackingCache<C extends CacheItem, T extends BackingCacheEntry<C>> 
 {
    /**
-    * Creates and caches a new instance of <code>T</code>. The new
-    * <code>T</code> *is* returned, but is not regarded as being "in use".
-    * Callers *must not* attempt to use the underlying <code>C</code> without
-    * first calling {@link #get(Object)}. 
+    * Creates and caches a new instance of <code>C</code>, wrapped by a new
+    * <code>T</code>. The new <code>T</code> *is* returned, but is not 
+    * regarded as being "in use". Callers *must not* attempt to use the 
+    * underlying <code>C</code> without first calling {@link #get(Object)}. 
     * 
     * @param initTypes   the types of any <code>initValues</code>. 
     *                    May be <code>null</code>.
@@ -72,15 +72,14 @@
     *                    May be null, in which case a default constructor will
     *                    be used.
     * @param sharedState map into which any objects meant to be shared with
-    *                    other members of the new items group should be
+    *                    other members of the new item's group should be
     *                    stored. 
     * @return the new <code>T</code> 
     */
    T create(Class<?> initTypes[], Object initValues[], Map<Object, Object> sharedState);
 
    /**
-    * Get the specified object from cache. This will mark
-    * the object as being in use.
+    * Get the specified object from cache. This will mark the entry as being in use.
     * 
     * @param key    the identifier of the object
     * @return       the object

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/BackingCacheEntry.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/BackingCacheEntry.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/BackingCacheEntry.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -35,27 +35,26 @@
    extends CacheItem
 {  
    /**
-    * Gets the underlying object that should be serialized as part of 
-    * serialization of the group.
+    * Gets the underlying CacheItem.
     * 
     * @return
     */
    T getUnderlyingItem();
    
    /**
-    * Gets whether this object is in use by a caller.
+    * Gets whether this entry is in use by a caller.
     */
    boolean isInUse();
    
    /**
-    * Sets whether this object is in use by a caller.
+    * Sets whether this entry is in use by a caller.
     * 
     * @param inUse
     */
    void setInUse(boolean inUse);
    
    /**
-    * Gets the timestamp of the last time this object was in use.
+    * Gets the timestamp of the last time this entry was in use.
     * 
     * @return
     */
@@ -72,4 +71,28 @@
     * any callbacks on the underlying item.
     */
    void setPrePassivated(boolean prePassivated);
+   
+   /**
+    * Attempt to lock this item, failing promptly if the lock is already
+    * held by another thread. Has the same semantics as
+    * {@java.util.concurrent.ReentrantLock#tryLock()}.
+    * 
+    * @return <code>true</code> if the lock was acquired, <code>false</code>
+    *         otherwise
+    */
+   boolean tryLock();
+   
+   /**
+    * Lock this item, blocking until the lock is acquired. Has the same 
+    * semantics as {@java.util.concurrent.ReentrantLock#lockInterruptibly()},
+    * except that a <code>RuntimeException</code> will be thrown if the
+    * thread is interrupted instead of <code>InterruptedException</code>.
+    */
+   void lock();
+   
+   /**
+    * Unlock this item. Has the same semantics as 
+    * {@java.util.concurrent.ReentrantLock#unlock()}.
+    */
+   void unlock();
 }

Added: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/BackingCacheEntryStore.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/BackingCacheEntryStore.java	                        (rev 0)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/BackingCacheEntryStore.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -0,0 +1,153 @@
+/*
+ * 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.cache.spi;
+
+import org.jboss.ejb3.cache.api.Cache;
+import org.jboss.ejb3.cache.api.CacheItem;
+import org.jboss.ejb3.cache.api.Identifiable;
+
+/**
+ * An in-memory store for {@link BackingCacheEntry} instances 
+ * that integrates a persistent store and the ability to use its knowledge of
+ * when objects are accessed to coordinate the passivation and expiration of 
+ * cached objects. Note that this class does NOT call any callbacks; it 
+ * performs passivation and expiration by invoking methods on the 
+ * {@link #setPassivatingCache(PassivatingBackingCache) injected backing cache};
+ * the cache performs the actual passivation or removal.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public interface BackingCacheEntryStore<C extends CacheItem, T extends BackingCacheEntry<C>>
+   extends PassivationExpirationProcessor, GroupCompatibilityChecker
+{
+   /**
+    * Put a new entry into the store. This operation should only be
+    * performed once per entry.
+    * 
+    * @param entry the object to store. Cannot be <code>null</code>.
+    * 
+    * @throws IllegalStateException if the store is already managing an entry
+    *                               with the same {@link Identifiable#getId() id}.
+    *                               It is not a requirement that the store throw
+    *                               this exception in this case, but it is
+    *                               permissible. This basically puts the onus on
+    *                               callers to ensure this operation is only
+    *                               performed once per entry.
+    */
+   void insert(T entry);
+   
+   /**
+    * Gets the entry with the given id from the store.
+    * 
+    * @param key {@link Identifiable#getId() id} of the entry.
+    *           Cannot be <code>null</code>.
+    * @return the object store under <code>id</code>. May return <code>null</code>.
+    */
+   T get(Object key);
+   
+   /**
+    * Update an already cached item.
+    * 
+    * @param  entry the entry to update
+    * @param modified was the entry modified since {@link #get(Object)} was called?
+    * 
+    * @throws IllegalStateException if the store isn't already managing an entry
+    *                               with the same {@link Identifiable#getId() id}.
+    *                               It is not a requirement that the store throw
+    *                               this exception in this case, but it is
+    *                               permissible. This basically puts the onus on
+    *                               callers to ensure {@link #insert(T)}
+    *                               is invoked before the first replication.
+    */
+   void update(T entry, boolean modified);
+   
+   /**
+    * Remove the object with the given key from the store.
+    * 
+    * @param key {@link Identifiable#getId() id} of the entry.
+    *           Cannot be <code>null</code>.
+    *           
+    * @return the object that was cached under <code>key</code>
+    */
+   T remove(Object key);
+   
+   /**
+    * Remove the entry with the given key from any in-memory store
+    * while retaining it in the persistent store.
+    * 
+    * @param entry the entry to passivate
+    */
+   void passivate(T entry);
+   
+   /**
+    * Gets whether this store supports clustering functionality.
+    * 
+    * @return <code>true</code> if clustering is supported, <code>false</code>
+    *         otherwise
+    */
+   boolean isClustered();
+   
+   /**
+    * Perform any initialization work.
+    */
+   void start();
+   
+   /**
+    * Perform any shutdown work.
+    */
+   void stop();
+      
+   /**
+    * Gets how often, in seconds, this object should process 
+    * {@link #runPassivation() passivations} and
+    * {@link #runExpiration() expirations}.
+    * 
+    * @return  interval, in seconds, at which passivations and expirations
+    *          are processed. A value of less than 1 means this object will 
+    *          not itself initiate processing, depending instead on an external 
+    *          caller to do so.
+    */
+   int getInterval();
+   
+   /**
+    * Sets how often, in seconds, this object should process 
+    * {@link #runPassivation() passivations} and
+    * {@link #runExpiration() expirations}.
+    * 
+    * @param seconds  interval, in seconds, at which passivations and
+    *                 expirations should be processed. A value of less than 1 
+    *                 means this object will not itself initiate processing, 
+    *                 depending instead on an external caller to do so.
+    */
+   void setInterval(int seconds);
+   
+   /**
+    * Handback provided by the controlling {@link PassivatingBackingCache} to
+    * allow the actual {@link PassivatingBackingCache#passivate(Object) passivate}
+    * and {@link Cache#remove(Object) remove} calls.
+    * 
+    * @param cache
+    */
+   void setPassivatingCache(PassivatingBackingCache<C, T> cache);
+}

Copied: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/BackingCacheEntryStoreSource.java (from rev 71451, projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/IntegratedObjectStoreSource.java)
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/BackingCacheEntryStoreSource.java	                        (rev 0)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/BackingCacheEntryStoreSource.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -0,0 +1,83 @@
+/*
+ * 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.cache.spi;
+
+import javax.transaction.TransactionManager;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.cache.api.CacheItem;
+import org.jboss.ejb3.cache.api.StatefulCacheFactory;
+
+/**
+ * Provides {@link BackingCacheEntryStore} instances to a 
+ * {@link StatefulCacheFactory} that needs to create a 
+ * {@link GroupAwareBackingCache}.
+ * 
+ * @author Brian Stansberry
+ */
+public interface BackingCacheEntryStoreSource<T extends CacheItem>
+{
+   /**
+    * Provide a {@link BackingCacheEntryStore} for storage
+    * of serialization groups.
+    * 
+    * @param containerName name of the container using this store's cache
+    * @param cacheConfigName potentially aliased name of the cache configuration. 
+    *                        Implementations should use this value in place
+    *                        of {@link CacheConfig#name()}
+    * @param config configuration details of the cache
+    * @param transactionManager TransactionManager the store should use if
+    *                           it needs to monitor transactions
+    * @param synchronizationCoordinator SynchronizationCoordinator the store
+    *                                   should use if it needs to add
+    *                                   tranaction synchronizations
+    * @return the store
+    */
+   BackingCacheEntryStore<T, SerializationGroup<T>> 
+         createGroupIntegratedObjectStore(String containerName, 
+                                          String cacheConfigName, 
+                                          CacheConfig config, 
+                                          TransactionManager transactionManager, 
+                                          SynchronizationCoordinator synchronizationCoordinator);
+   
+   /**
+    * Provide a {@link BackingCacheEntryStore} for storage
+    * of serialization group members.
+    * 
+    * @param containerName name of the container using this store's cache
+    * @param cacheConfigName TODO
+    * @param transactionManager TransactionManager the store should use if
+    *                           it needs to monitor transactions
+    * @param synchronizationCoordinator SynchronizationCoordinator the store
+    *                                   should use if it needs to add
+    *                                   tranaction synchronizations
+    * @param config configuration details of the cache
+    * @return the store
+    */
+   BackingCacheEntryStore<T, SerializationGroupMember<T>> 
+         createIntegratedObjectStore(String containerName, 
+                                     String cacheConfigName, 
+                                     CacheConfig cacheConfig, 
+                                     TransactionManager transactionManager, 
+                                     SynchronizationCoordinator synchronizationCoordinator);
+}

Deleted: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/IntegratedObjectStore.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/IntegratedObjectStore.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/IntegratedObjectStore.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -1,113 +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.cache.spi;
-
-import org.jboss.ejb3.cache.api.CacheItem;
-import org.jboss.ejb3.cache.api.Identifiable;
-
-/**
- * An in-memory store for identifiable objects that integrates a persistent store. 
- * Note that this class does NOT call any callbacks.
- * 
- * @author Brian Stansberry
- * @version $Revision$
- */
-public interface IntegratedObjectStore<T extends CacheItem>
-{
-   /**
-    * Put a new entry into the store. This operation should only be
-    * performed once per entry.
-    * 
-    * @param entry the object to store. Cannot be <code>null</code>.
-    * 
-    * @throws IllegalStateException if the store is already managing an entry
-    *                               with the same {@link Identifiable#getId() id}.
-    *                               It is not a requirement that the store throw
-    *                               this exception in this case, but it is
-    *                               permissible. This basically puts the onus on
-    *                               callers to ensure this operation is only
-    *                               performed once per entry.
-    */
-   void insert(T entry);
-   
-   /**
-    * Gets the entry with the given id from the store.
-    * 
-    * @param key {@link Identifiable#getId() id} of the entry.
-    *           Cannot be <code>null</code>.
-    * @return the object store under <code>id</code>. May return <code>null</code>.
-    */
-   T get(Object key);
-   
-   /**
-    * Update an already cached item.
-    * 
-    * @param  entry the entry to update
-    * @param modified was the entry modified since {@link #get(Object)} was called?
-    * 
-    * @throws IllegalStateException if the store isn't already managing an entry
-    *                               with the same {@link Identifiable#getId() id}.
-    *                               It is not a requirement that the store throw
-    *                               this exception in this case, but it is
-    *                               permissible. This basically puts the onus on
-    *                               callers to ensure {@link #insert(T)}
-    *                               is invoked before the first replication.
-    */
-   void update(T entry, boolean modified);
-   
-   /**
-    * Remove the object with the given key from the store.
-    * 
-    * @param key {@link Identifiable#getId() id} of the entry.
-    *           Cannot be <code>null</code>.
-    *           
-    * @return the object that was cached under <code>key</code>
-    */
-   T remove(Object key);
-   
-   /**
-    * Remove the entry with the given key from any in-memory store
-    * while retaining it in the persistent store.
-    * 
-    * @param entry the entry to passivate
-    */
-   void passivate(T entry);
-   
-   /**
-    * Gets whether this store supports clustering functionality.
-    * 
-    * @return <code>true</code> if clustering is supported, <code>false</code>
-    *         otherwise
-    */
-   boolean isClustered();
-   
-   /**
-    * Perform any initialization work.
-    */
-   void start();
-   
-   /**
-    * Perform any shutdown work.
-    */
-   void stop();
-}

Deleted: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/IntegratedObjectStoreSource.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/IntegratedObjectStoreSource.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/IntegratedObjectStoreSource.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -1,83 +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.cache.spi;
-
-import javax.transaction.TransactionManager;
-
-import org.jboss.ejb3.annotation.CacheConfig;
-import org.jboss.ejb3.cache.api.CacheItem;
-import org.jboss.ejb3.cache.api.StatefulCacheFactory;
-
-/**
- * Provides {@link PassivatingIntegratedObjectStore} instances to a 
- * {@link StatefulCacheFactory} that needs to create a 
- * {@link GroupAwareBackingCache}.
- * 
- * @author Brian Stansberry
- */
-public interface IntegratedObjectStoreSource<T extends CacheItem>
-{
-   /**
-    * Provide a {@link PassivatingIntegratedObjectStore} for storage
-    * of serialization groups.
-    * 
-    * @param containerName name of the container using this store's cache
-    * @param cacheConfigName potentially aliased name of the cache configuration. 
-    *                        Implementations should use this value in place
-    *                        of {@link CacheConfig#name()}
-    * @param config configuration details of the cache
-    * @param transactionManager TransactionManager the store should use if
-    *                           it needs to monitor transactions
-    * @param synchronizationCoordinator SynchronizationCoordinator the store
-    *                                   should use if it needs to add
-    *                                   tranaction synchronizations
-    * @return the store
-    */
-   PassivatingIntegratedObjectStore<T, SerializationGroup<T>> 
-         createGroupIntegratedObjectStore(String containerName, 
-                                          String cacheConfigName, 
-                                          CacheConfig config, 
-                                          TransactionManager transactionManager, 
-                                          SynchronizationCoordinator synchronizationCoordinator);
-   
-   /**
-    * Provide a {@link PassivatingIntegratedObjectStore} for storage
-    * of serialization group members.
-    * 
-    * @param containerName name of the container using this store's cache
-    * @param cacheConfigName TODO
-    * @param transactionManager TransactionManager the store should use if
-    *                           it needs to monitor transactions
-    * @param synchronizationCoordinator SynchronizationCoordinator the store
-    *                                   should use if it needs to add
-    *                                   tranaction synchronizations
-    * @param config configuration details of the cache
-    * @return the store
-    */
-   PassivatingIntegratedObjectStore<T, SerializationGroupMember<T>> 
-         createIntegratedObjectStore(String containerName, 
-                                     String cacheConfigName, 
-                                     CacheConfig cacheConfig, 
-                                     TransactionManager transactionManager, 
-                                     SynchronizationCoordinator synchronizationCoordinator);
-}

Deleted: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/ObjectStore.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/ObjectStore.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/ObjectStore.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -1,62 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2007, 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.cache.spi;
-
-import org.jboss.ejb3.cache.api.CacheItem;
-
-
-/**
- * Stores an indentifiable object in a persistent store. Note that the object store
- * does NOT call any callbacks.
- * 
- * It is assumed the key represents something meaning full to the object store.
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public interface ObjectStore<T extends CacheItem>
-{
-   /**
-    * Load the object from storage.
-    * 
-    * @param key    the object identifier
-    * @return       the object or null if not found
-    */
-   T load(Object key);
-   
-   /**
-    * Store the object into storage.
-    * 
-    * @param obj    the object
-    */
-   void store(T obj);
-   
-   /**
-    * Perform any initialization work.
-    */
-   void start();
-   
-   /**
-    * Perform any shutdown work.
-    */
-   void stop();
-}

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/PassivatingBackingCache.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/PassivatingBackingCache.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/PassivatingBackingCache.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -27,17 +27,19 @@
 /**
  * A {@link BackingCache} which passivates unused objects.
  * <p>
- * A PassivatingBackingCache is linked to an ObjectStore to store the
- * passivated object and to a PassivationManager to manage lifecycle
+ * A PassivatingBackingCache is linked to a some sort of persistent store to 
+ * store the passivated object and to a PassivationManager to manage lifecycle
  * callbacks on the object.
  * </p>
  * 
+ * @see BackingCacheEntryStore
+ * 
  * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
  * @author Brian Stansberry
  * 
  * @version $Revision: 65977 $
  */
-public interface PassivatingBackingCache<C extends CacheItem, T extends PassivatingBackingCacheEntry<C>>
+public interface PassivatingBackingCache<C extends CacheItem, T extends BackingCacheEntry<C>>
    extends BackingCache<C, T>
 {
    /**

Deleted: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/PassivatingBackingCacheEntry.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/PassivatingBackingCacheEntry.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/PassivatingBackingCacheEntry.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -1,59 +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.cache.spi;
-
-import org.jboss.ejb3.cache.api.CacheItem;
-
-/**
- * A {@link BackingCacheEntry} that can be passivated.
- * 
- * @author Brian Stansberry
- */
-public interface PassivatingBackingCacheEntry<T extends CacheItem> 
-   extends BackingCacheEntry<T>
-{
-   /**
-    * Attempt to lock this item, failing promptly if the lock is already
-    * held by another thread. Has the same semantics as
-    * {@java.util.concurrent.ReentrantLock#tryLock()}.
-    * 
-    * @return <code>true</code> if the lock was acquired, <code>false</code>
-    *         otherwise
-    */
-   boolean tryLock();
-   
-   /**
-    * Lock this item, blocking until the lock is acquired. Has the same 
-    * semantics as {@java.util.concurrent.ReentrantLock#lockInterruptibly()},
-    * except that a <code>RuntimeException</code> will be thrown if the
-    * thread is interrupted instead of <code>InterruptedException</code>.
-    */
-   void lock();
-   
-   /**
-    * Unlock this item. Has the same semantics as 
-    * {@java.util.concurrent.ReentrantLock#unlock()}.
-    */
-   void unlock();
-
-}

Deleted: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/PassivatingIntegratedObjectStore.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/PassivatingIntegratedObjectStore.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/PassivatingIntegratedObjectStore.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -1,71 +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.cache.spi;
-
-import org.jboss.ejb3.cache.api.Cache;
-import org.jboss.ejb3.cache.api.CacheItem;
-
-/**
- * An {@link IntegratedObjectStore} that is able to use its knowledge of
- * when objects are accessed to coordinate the passivation and removal of 
- * cached objects.
- * 
- * @author Brian Stansberry
- * @version $Revision$
- */
-public interface PassivatingIntegratedObjectStore<C extends CacheItem, T extends PassivatingBackingCacheEntry<C>>
-   extends IntegratedObjectStore<T>, PassivationExpirationProcessor, GroupCompatibilityChecker
-{
-   /**
-    * Gets how often, in seconds, this object should process 
-    * {@link #runPassivation() passivations} and
-    * {@link #runExpiration() expirations}.
-    * 
-    * @return  interval, in seconds, at which passivations and expirations
-    *          are processed. A value of less than 1 means this object will 
-    *          not itself initiate processing, depending instead on an external 
-    *          caller to do so.
-    */
-   int getInterval();
-   
-   /**
-    * Sets how often, in seconds, this object should process 
-    * {@link #runPassivation() passivations} and
-    * {@link #runExpiration() expirations}.
-    * 
-    * @param seconds  interval, in seconds, at which passivations and
-    *                 expirations should be processed. A value of less than 1 
-    *                 means this object will not itself initiate processing, 
-    *                 depending instead on an external caller to do so.
-    */
-   void setInterval(int seconds);
-   
-   /**
-    * Handback provided by the controlling {@link PassivatingBackingCache} to
-    * allow the actual {@link PassivatingBackingCache#passivate(Object) passivate}
-    * and {@link Cache#remove(Object) remove} calls.
-    * 
-    * @param cache
-    */
-   void setPassivatingCache(PassivatingBackingCache<C, T> cache);
-}

Copied: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/PersistentObjectStore.java (from rev 71451, projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/ObjectStore.java)
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/PersistentObjectStore.java	                        (rev 0)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/PersistentObjectStore.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.cache.spi;
+
+import org.jboss.ejb3.cache.api.Identifiable;
+
+
+/**
+ * Stores an indentifiable object in a persistent store. Note that the object 
+ * store does NOT call any callbacks.
+ * 
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface PersistentObjectStore<T extends Identifiable>
+{
+   /**
+    * Load the object from storage.
+    * 
+    * @param key    the object identifier. It is assumed the key represents 
+    *               something meaningful to the object store.
+    * @return       the object or null if not found
+    */
+   T load(Object key);
+   
+   /**
+    * Store the object into storage.
+    * 
+    * @param obj    the object
+    */
+   void store(T obj);
+   
+   /**
+    * Perform any initialization work.
+    */
+   void start();
+   
+   /**
+    * Perform any shutdown work.
+    */
+   void stop();
+}

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/SerializationGroup.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/SerializationGroup.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/SerializationGroup.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -39,7 +39,7 @@
  * @param <T> the type of the underlying items that form the group.
  */
 public interface SerializationGroup<T extends CacheItem>
-   extends PassivatingBackingCacheEntry<T>
+   extends BackingCacheEntry<T>
 {
    /**
     * Adds a member to the group.

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/SerializationGroupMember.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/SerializationGroupMember.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/SerializationGroupMember.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -23,9 +23,11 @@
 package org.jboss.ejb3.cache.spi;
 
 import org.jboss.ejb3.cache.api.CacheItem;
+import org.jboss.ejb3.cache.api.Identifiable;
 
 /**
- * Specialized {@link BackingCacheEntry} that wraps an {@link #setUnderlyingItem(CacheItem)} 
+ * Specialized {@link BackingCacheEntry} that wraps an 
+ * {@link #setUnderlyingItem(CacheItem) underlying CacheItem} 
  * and represents it as a strong>potential</strong> member of a 
  * {@link SerializationGroup}. Note that a particular instance need not actually 
  * be a member of a group; such an instance will return <code>null</code> 
@@ -36,7 +38,7 @@
  * @param <T> the type of the underlying item
  */
 public interface SerializationGroupMember<T extends CacheItem>
-  extends PassivatingBackingCacheEntry<T>
+  extends BackingCacheEntry<T>
 {  
    /**
     * {@inheritDoc}

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractBackingCache.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractBackingCache.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractBackingCache.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -37,9 +37,9 @@
  * 
  * @author Brian Stansberry
  *
- * @param <C> the type of item being managed by the cache
+ * @param <T> the type of item being managed by the cache
  */
-public abstract class AbstractBackingCache<C extends CacheItem>
+public abstract class AbstractBackingCache<T extends CacheItem>
 {
    protected Logger log = Logger.getLogger(getClass().getName());
    

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractBackingCacheEntry.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractBackingCacheEntry.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractBackingCacheEntry.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -29,7 +29,7 @@
  * 
  * @author Brian Stansberry
  *
- * @param <T>
+ * @param <T> the type of item being managed by the entry
  */
 public abstract class AbstractBackingCacheEntry<T extends CacheItem>
    implements BackingCacheEntry<T>

Added: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractBackingCacheEntryStore.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractBackingCacheEntryStore.java	                        (rev 0)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractBackingCacheEntryStore.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -0,0 +1,361 @@
+/*
+ * 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.cache.spi.impl;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.cache.api.CacheItem;
+import org.jboss.ejb3.cache.spi.BackingCacheEntry;
+import org.jboss.ejb3.cache.spi.PassivatingBackingCache;
+import org.jboss.ejb3.cache.spi.BackingCacheEntryStore;
+import org.jboss.ejb3.cache.spi.SerializationGroup;
+import org.jboss.logging.Logger;
+
+/**
+ * Abstract superclass for {@link BackingCacheEntryStore} 
+ * implementations.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public abstract class AbstractBackingCacheEntryStore<C extends CacheItem, T extends BackingCacheEntry<C>, K>
+      implements BackingCacheEntryStore<C, T>
+{
+   protected Logger log = Logger.getLogger(getClass().getName());
+   
+   /** Our name */
+   private final String name;
+   /**
+    * Support callbacks when our SessionTimeoutThread decides to
+    * evict an entry.
+    */
+   private PassivatingBackingCache<C, T> owningCache;   
+   /** Is this store for groups or group members? */
+   private boolean forGroups;
+   /** How often (in seconds) any PassivationExpirationRunner should run */
+   private int interval;
+   /** 
+    * Max number of stored items before passivation should begin passivating
+    * LRU items regardless of idleTimeSeconds.
+    */
+   private int maxSize;
+   /** 
+    * Max number of seconds any item must be inactive after which passivation
+    * should passivate it, regardless of maxItems.
+    */
+   private long idleTimeSeconds;
+   private long expirationTimeSeconds; 
+   /** Timer task that performs passivation and expiration */
+   private PassivationExpirationRunner sessionTimeoutRunner;
+   /** Whether start() has completed and stop() has not been called. */
+   private boolean running = true;
+   
+   /**
+    * Create a new AbstractBackingCacheEntryStore.
+    * 
+    * @param config  the configuration for the cache. Cannot be <code>null</code>
+    * @param name    our name. Cannot be <code>null</code>
+    * @param forGroups <code>true</code> if this store is used for 
+    *                  {@link SerializationGroup}s, <code>false</code> if not
+    */
+   protected AbstractBackingCacheEntryStore(CacheConfig config,
+                                            String name,
+                                            boolean forGroups)
+   {
+      assert config != null : "config is null";
+      assert name != null : "name is null";
+      
+      this.idleTimeSeconds = config.idleTimeoutSeconds();
+      this.expirationTimeSeconds = config.removalTimeoutSeconds();
+      this.maxSize = config.maxSize();
+      this.name = name;
+      this.forGroups = forGroups;
+   }
+
+   // ---------------------------------------------------------------- Abstract
+   
+   /**
+    * Invoked by {@link #processPassivationExpiration()} to indicate the
+    * item associated with the given key needs to be passivated.
+    * 
+    * @param key  key for the item
+    * @param lastUse time item was last used
+    */
+   protected abstract void processPassivation(K key, long lastUse);
+   /**
+    * Invoked by {@link #processPassivationExpiration()} to indicate the
+    * item associated with the given key needs to be expired.
+    * 
+    * @param key  key for the item
+    * @param lastUse time item was last used
+    */
+   protected abstract void processExpiration(K key, long lastUse);
+
+   /**
+    * Get a set of {@link CacheableTimestamp} representing the items currently
+    * in memory.
+    * 
+    * @return array of {@link CacheableTimestamp}, sorted by 
+    *         {@link CacheableTimestamp#getLastUsed() last use}, with least
+    *         recently used items first.
+    */
+   protected abstract CacheableTimestamp<K>[] getInMemoryEntries();
+   
+   /**
+    * Get a set of {@link CacheableTimestamp} representing all items, both
+    * those in memory and those passivated.
+    * 
+    * @return array of {@link CacheableTimestamp}, sorted by 
+    *         {@link CacheableTimestamp#getLastUsed() last use}, with least
+    *         recently used items first.
+    */
+   protected abstract CacheableTimestamp<K>[] getAllEntries();
+   
+   /**
+    * Get the number of items in memory.
+    */
+   public abstract int getInMemoryCount();
+   
+   /**
+    * Get the number of passivated items.
+    */
+   public abstract int getPassivatedCount();
+
+   // --------------------------------------------------  IntegratedObjectStore
+
+   public void start()
+   {    
+      log.debug("Starting store " + name);
+      
+      internalStart();
+      
+      running = true;
+      
+      log.debug("Started store " + name);
+   }
+   
+   protected void internalStart()
+   {
+      if (!forGroups && interval > 0)
+      {
+         if (sessionTimeoutRunner == null)
+         {
+            assert name != null : "name has not been set";
+            assert owningCache != null;
+            String timerName = "PassivationExpirationTimer-" + name;
+            sessionTimeoutRunner = new PassivationExpirationRunner(this, timerName, interval);
+         }
+         sessionTimeoutRunner.start();
+      }
+   }
+
+   public void stop()
+   {     
+      log.debug("Stopping store " + name);
+      
+      running = false;
+      
+      internalStop();      
+      
+      log.debug("Stopped store " + name);
+   }
+   
+   protected void internalStop()
+   {     
+      if (sessionTimeoutRunner != null)
+      {
+         sessionTimeoutRunner.stop();
+      }
+   }
+
+   // ---------------------------------------  BackingCacheEntryStore
+
+
+   public void setPassivatingCache(PassivatingBackingCache<C, T> cache)
+   {
+      this.owningCache = cache;      
+   }
+   
+   public PassivatingBackingCache<C, T> getPassivatingCache()
+   {
+      return owningCache;
+   }
+   
+   public int getInterval()
+   {
+      return interval;
+   }
+
+   public void setInterval(int seconds)
+   {
+      this.interval = seconds;      
+   }
+   
+   public void processPassivationExpiration()
+   {
+      // Group passivation/expiration is a function of its members
+      if (forGroups)
+         return;
+      
+      if (running)
+      {
+         try
+         {
+            runPassivation();               
+         }
+         catch (Exception e)
+         {
+            log.error("Caught exception processing passivations", e);
+         }
+      }
+      
+      if (running)
+      {
+         try
+         {
+            runExpiration();               
+         }
+         catch (Exception e)
+         {
+            log.error("Caught exception processing expirations", e);
+         }               
+      }
+   }
+   
+   public boolean isPassivationExpirationSelfManaged()
+   {
+      return interval > 0;
+   }
+   
+   public int getMaxSize()
+   {
+      return maxSize;
+   }
+   
+   public long getIdleTimeSeconds()
+   {
+      return idleTimeSeconds;
+   }
+
+   public void setIdleTimeSeconds(long idleTimeSeconds)
+   {
+      this.idleTimeSeconds = idleTimeSeconds;
+   }
+
+   public long getExpirationTimeSeconds()
+   {
+      return expirationTimeSeconds;
+   }
+   
+   public void setExpirationTimeSeconds(long timeout)
+   {
+      this.expirationTimeSeconds = timeout;
+   }
+
+   public boolean isForGroups()
+   {
+      return forGroups;
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public boolean isRunning()
+   {
+      return running;
+   }
+
+   public void setMaxSize(int maxSize)
+   {
+      this.maxSize = maxSize;
+   }
+   
+   // --------------------------------------------------------------  Protected
+   
+   
+   
+   // ----------------------------------------------------------------  Private
+
+   private void runExpiration()
+   {
+      if (!isForGroups() && getExpirationTimeSeconds() > 0)
+      {
+         long now = System.currentTimeMillis();
+         long minRemovalUse = now - (getExpirationTimeSeconds() * 1000);                     
+         for (CacheableTimestamp<K> ts : getAllEntries())
+         {
+            try
+            {
+               if (running && minRemovalUse >= ts.getLastUsed())
+               {
+                  processExpiration(ts.getId(), ts.getLastUsed());
+               }
+               else
+               {
+                  break;
+               }
+            }
+            catch (IllegalStateException ise)
+            {
+               // Not so great; we're assuming it's 'cause item's in use
+               log.trace("skipping in-use entry " + ts.getId(), ise);
+            }
+         }    
+      }      
+   }
+
+   private void runPassivation()
+   {
+      if (!isForGroups() 
+            && (getMaxSize() > 0 || getIdleTimeSeconds() > 0))
+      {
+         long now = System.currentTimeMillis();
+         long minPassUse = (getIdleTimeSeconds() > 0 ? now - (getIdleTimeSeconds() * 1000) : 0);
+         
+         CacheableTimestamp<K>[] timestamps = getInMemoryEntries();
+         int overCount = (getMaxSize() > 0 ? timestamps.length - getMaxSize() : 0);
+         for (CacheableTimestamp<K> ts : timestamps)
+         {
+            try
+            {
+               if (running && (overCount > 0 || minPassUse >= ts.getLastUsed()))
+               {
+                  log.trace("attempting to passivate " + ts.getId());
+                  processPassivation(ts.getId(), ts.getLastUsed());
+                  overCount--;
+               }
+               else
+               {
+                  break;
+               }
+            }
+            catch (IllegalStateException ise)
+            {
+               // Not so great; we're assuming it's 'cause item's in use
+               log.trace("skipping in-use entry " + ts.getId(), ise);
+            }
+         }
+      }      
+   }
+}

Deleted: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractPassivatingIntegratedObjectStore.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractPassivatingIntegratedObjectStore.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractPassivatingIntegratedObjectStore.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -1,342 +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.cache.spi.impl;
-
-import org.jboss.ejb3.annotation.CacheConfig;
-import org.jboss.ejb3.cache.api.CacheItem;
-import org.jboss.ejb3.cache.spi.PassivatingBackingCache;
-import org.jboss.ejb3.cache.spi.PassivatingBackingCacheEntry;
-import org.jboss.ejb3.cache.spi.PassivatingIntegratedObjectStore;
-import org.jboss.logging.Logger;
-
-/**
- * Abstract superclass for {@link PassivatingIntegratedObjectStore} 
- * implementations.
- * 
- * @author Brian Stansberry
- * @version $Revision$
- */
-public abstract class AbstractPassivatingIntegratedObjectStore<C extends CacheItem, T extends PassivatingBackingCacheEntry<C>, K>
-      implements PassivatingIntegratedObjectStore<C, T>
-{
-   protected Logger log = Logger.getLogger(getClass().getName());
-   
-   /**
-    * Support callbacks when our SessionTimeoutThread decides to
-    * evict an entry.
-    */
-   private PassivatingBackingCache<C, T> owningCache;   
-   private boolean forGroups;
-   private int interval;
-   private int maxSize;
-   private long idleTimeSeconds;
-   private long expirationTimeSeconds;   
-   private PassivationExpirationRunner sessionTimeoutRunner;
-   private final String name;
-   private boolean running = true;
-   
-   /**
-    * Create a new AbstractPassivatingIntegratedObjectStore.
-    */
-   protected AbstractPassivatingIntegratedObjectStore(CacheConfig config,
-                                                      String name,
-                                                      boolean forGroups)
-   {
-      assert config != null : "config is null";
-      assert name != null : "name is null";
-      
-      this.idleTimeSeconds = config.idleTimeoutSeconds();
-      this.expirationTimeSeconds = config.removalTimeoutSeconds();
-      this.maxSize = config.maxSize();
-      this.name = name;
-      this.forGroups = forGroups;
-   }
-
-   // ---------------------------------------------------------------- Abstract
-   
-   /**
-    * Invoked by {@link #processPassivationExpiration()} to indicate the
-    * item associated with the given key needs to be passivated.
-    * 
-    * @param key  key for the item
-    * @param lastUse time item was last used
-    */
-   protected abstract void processPassivation(K key, long lastUse);
-   /**
-    * Invoked by {@link #processPassivationExpiration()} to indicate the
-    * item associated with the given key needs to be expired.
-    * 
-    * @param key  key for the item
-    * @param lastUse time item was last used
-    */
-   protected abstract void processExpiration(K key, long lastUse);
-
-   /**
-    * Get a set of {@link CacheableTimestamp} representing the items currently
-    * in memory.
-    * 
-    * @return array of {@link CacheableTimestamp}, sorted by 
-    *         {@link CacheableTimestamp#getLastUsed() last use}, with least
-    *         recently used items first.
-    */
-   protected abstract CacheableTimestamp<K>[] getInMemoryEntries();
-   
-   /**
-    * Get a set of {@link CacheableTimestamp} representing all items, both
-    * those in memory and those passivated.
-    * 
-    * @return array of {@link CacheableTimestamp}, sorted by 
-    *         {@link CacheableTimestamp#getLastUsed() last use}, with least
-    *         recently used items first.
-    */
-   protected abstract CacheableTimestamp<K>[] getAllEntries();
-   
-   /**
-    * Get the number of items in memory.
-    */
-   public abstract int getInMemoryCount();
-   
-   /**
-    * Get the number of passivated items.
-    */
-   public abstract int getPassivatedCount();
-
-   // --------------------------------------------------  IntegratedObjectStore
-
-   public void start()
-   {    
-      log.debug("Starting store " + name);
-      
-      internalStart();
-      
-      running = true;
-      
-      log.debug("Started store " + name);
-   }
-   
-   protected void internalStart()
-   {
-      if (!forGroups && interval > 0)
-      {
-         if (sessionTimeoutRunner == null)
-         {
-            assert name != null : "name has not been set";
-            assert owningCache != null;
-            String timerName = "PassivationExpirationTimer-" + name;
-            sessionTimeoutRunner = new PassivationExpirationRunner(this, timerName, interval);
-         }
-         sessionTimeoutRunner.start();
-      }
-   }
-
-   public void stop()
-   {     
-      log.debug("Stopping store " + name);
-      
-      running = false;
-      
-      internalStop();      
-      
-      log.debug("Stopped store " + name);
-   }
-   
-   protected void internalStop()
-   {     
-      if (sessionTimeoutRunner != null)
-      {
-         sessionTimeoutRunner.stop();
-      }
-   }
-
-   // ---------------------------------------  PassivatingIntegratedObjectStore
-
-
-   public void setPassivatingCache(PassivatingBackingCache<C, T> cache)
-   {
-      this.owningCache = cache;      
-   }
-   
-   public PassivatingBackingCache<C, T> getPassivatingCache()
-   {
-      return owningCache;
-   }
-   
-   public int getInterval()
-   {
-      return interval;
-   }
-
-   public void setInterval(int seconds)
-   {
-      this.interval = seconds;      
-   }
-   
-   public void processPassivationExpiration()
-   {
-      // Group passivation/expiration is a function of its members
-      if (forGroups)
-         return;
-      
-      if (running)
-      {
-         try
-         {
-            runPassivation();               
-         }
-         catch (Exception e)
-         {
-            log.error("Caught exception processing passivations", e);
-         }
-      }
-      
-      if (running)
-      {
-         try
-         {
-            runExpiration();               
-         }
-         catch (Exception e)
-         {
-            log.error("Caught exception processing expirations", e);
-         }               
-      }
-   }
-   
-   public boolean isPassivationExpirationSelfManaged()
-   {
-      return interval > 0;
-   }
-   
-   public int getMaxSize()
-   {
-      return maxSize;
-   }
-   
-   public long getIdleTimeSeconds()
-   {
-      return idleTimeSeconds;
-   }
-
-   public void setIdleTimeSeconds(long idleTimeSeconds)
-   {
-      this.idleTimeSeconds = idleTimeSeconds;
-   }
-
-   public long getExpirationTimeSeconds()
-   {
-      return expirationTimeSeconds;
-   }
-   
-   public void setExpirationTimeSeconds(long timeout)
-   {
-      this.expirationTimeSeconds = timeout;
-   }
-
-   public boolean isForGroups()
-   {
-      return forGroups;
-   }
-
-   public String getName()
-   {
-      return name;
-   }
-
-   public boolean isRunning()
-   {
-      return running;
-   }
-
-   public void setMaxSize(int maxSize)
-   {
-      this.maxSize = maxSize;
-   }
-   
-   // --------------------------------------------------------------  Protected
-   
-   
-   
-   // ----------------------------------------------------------------  Private
-
-   private void runExpiration()
-   {
-      if (!isForGroups() && getExpirationTimeSeconds() > 0)
-      {
-         long now = System.currentTimeMillis();
-         long minRemovalUse = now - (getExpirationTimeSeconds() * 1000);                     
-         for (CacheableTimestamp<K> ts : getAllEntries())
-         {
-            try
-            {
-               if (running && minRemovalUse >= ts.getLastUsed())
-               {
-                  processExpiration(ts.getId(), ts.getLastUsed());
-               }
-               else
-               {
-                  break;
-               }
-            }
-            catch (IllegalStateException ise)
-            {
-               // Not so great; we're assuming it's 'cause item's in use
-               log.trace("skipping in-use entry " + ts.getId(), ise);
-            }
-         }    
-      }      
-   }
-
-   private void runPassivation()
-   {
-      if (!isForGroups() 
-            && (getMaxSize() > 0 || getIdleTimeSeconds() > 0))
-      {
-         long now = System.currentTimeMillis();
-         long minPassUse = (getIdleTimeSeconds() > 0 ? now - (getIdleTimeSeconds() * 1000) : 0);
-         
-         CacheableTimestamp<K>[] timestamps = getInMemoryEntries();
-         int overCount = (getMaxSize() > 0 ? timestamps.length - getMaxSize() : 0);
-         for (CacheableTimestamp<K> ts : timestamps)
-         {
-            try
-            {
-               if (running && (overCount > 0 || minPassUse >= ts.getLastUsed()))
-               {
-                  log.trace("attempting to passivate " + ts.getId());
-                  processPassivation(ts.getId(), ts.getLastUsed());
-                  overCount--;
-               }
-               else
-               {
-                  break;
-               }
-            }
-            catch (IllegalStateException ise)
-            {
-               // Not so great; we're assuming it's 'cause item's in use
-               log.trace("skipping in-use entry " + ts.getId(), ise);
-            }
-         }
-      }      
-   }
-}

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractStatefulCacheFactory.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractStatefulCacheFactory.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractStatefulCacheFactory.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -200,6 +200,8 @@
    
    public void start()
    {
+      assert transactionManager != null : "transactionManager is null";
+      
       if (getSynchronizationCoordinator() == null)
          setSynchronizationCoordinator(new SynchronizationCoordinatorImpl());
    }

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractTimerTask.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractTimerTask.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/AbstractTimerTask.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -39,7 +39,7 @@
    private long interval;
    
    /**
-    * Create a new PassivationExpirationRunner.
+    * Create a new AbstractTimerTask.
     * 
     */
    protected AbstractTimerTask(String timerName, long interval)
@@ -48,8 +48,6 @@
       setInterval(interval);
    }
    
-   protected AbstractTimerTask() {}
-   
    public boolean isStopped()
    {
       return stopped;
@@ -72,7 +70,7 @@
    }
 
    /**
-    * Gets the interval, in milliseconds, with which this task should
+    * Gets the interval, in seconds, with which this task should
     * be {@link Timer#schedule(TimerTask, long) scheduled with the timer}.
     * 
     * @return the interval
@@ -83,7 +81,7 @@
    }
 
    /**
-    * Sets the interval, in milliseconds, with which this task should
+    * Sets the interval, in seconds, with which this task should
     * be {@link Timer#schedule(TimerTask, long) scheduled with the timer}.
     * 
     * @param interval the interval

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/CacheableTimestamp.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/CacheableTimestamp.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/CacheableTimestamp.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -24,7 +24,6 @@
 
 import org.jboss.ejb3.cache.api.Identifiable;
 import org.jboss.ejb3.cache.spi.BackingCacheEntry;
-import org.jboss.ejb3.cache.spi.IntegratedObjectStore;
 
 /**
  * Encapsulation of the {@link Identifiable#getId() id} and
@@ -35,8 +34,8 @@
  * for LRU comparisons.
  * </p>
  * 
- * @see IntegratedObjectStore#getInMemoryEntries()
- * @see IntegratedObjectStore#getPassivatedEntries()
+ * @see AbstractBackingCacheEntryStore#getInMemoryEntries()
+ * @see AbstractBackingCacheEntryStore#getAllEntries()
  * 
  * @author Brian Stansberry
  * @version $Revision$

Deleted: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/FileObjectStore.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/FileObjectStore.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/FileObjectStore.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -1,283 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.cache.spi.impl;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-import org.jboss.ejb3.cache.api.CacheItem;
-import org.jboss.ejb3.cache.spi.ObjectStore;
-import org.jboss.logging.Logger;
-import org.jboss.serial.io.JBossObjectInputStream;
-import org.jboss.serial.io.JBossObjectOutputStream;
-
-/**
- * Stores objects in a directory via serialization.
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: 65339 $
- */
-public class FileObjectStore<T extends CacheItem> 
-   implements ObjectStore<T>
-{
-   private static final Logger log = Logger.getLogger(FileObjectStore.class);
-   
-   private int subdirectoryCount;   
-   private File baseDirectory;
-   private File[] storageDirectories;
-   
-   private static class DeleteFileAction implements PrivilegedAction<Boolean>
-   {
-      File file;
-
-      DeleteFileAction(File file)
-      {
-         this.file = file;
-      }
-
-      public Boolean run()
-      {
-         return file.delete();
-      }
-
-      static boolean delete(File file)
-      {
-         DeleteFileAction action = new DeleteFileAction(file);
-         return AccessController.doPrivileged(action);
-      }
-   }
-
-   private static class FISAction implements PrivilegedExceptionAction<FileInputStream>
-   {
-      File file;
-
-      FISAction(File file)
-      {
-         this.file = file;
-      }
-
-      public FileInputStream run() throws FileNotFoundException
-      {
-         FileInputStream fis = new FileInputStream(file);
-         return fis;
-      }
-
-      static FileInputStream open(File file) throws FileNotFoundException
-      {
-         FISAction action = new FISAction(file);
-         FileInputStream fis = null;
-         try
-         {
-            fis = AccessController.doPrivileged(action);
-         }
-         catch (PrivilegedActionException e)
-         {
-            throw (FileNotFoundException) e.getException();
-         }
-         return fis;
-      }
-   }
-
-   private static class FOSAction implements PrivilegedExceptionAction<FileOutputStream>
-   {
-      File file;
-
-      FOSAction(File file)
-      {
-         this.file = file;
-      }
-
-      public FileOutputStream run() throws FileNotFoundException
-      {
-         FileOutputStream fis = new FileOutputStream(file);
-         return fis;
-      }
-
-      static FileOutputStream open(File file) throws FileNotFoundException
-      {
-         FOSAction action = new FOSAction(file);
-         FileOutputStream fos = null;
-         try
-         {
-            fos = AccessController.doPrivileged(action);
-         }
-         catch (PrivilegedActionException e)
-         {
-            throw (FileNotFoundException) e.getException();
-         }
-         return fos;
-      }
-   }
-
-   private static class MkdirsFileAction implements PrivilegedAction<Boolean>
-   {
-      File file;
-
-      MkdirsFileAction(File file)
-      {
-         this.file = file;
-      }
-
-      public Boolean run()
-      {
-         return file.mkdirs();
-      }
-
-      static boolean mkdirs(File file)
-      {
-         MkdirsFileAction action = new MkdirsFileAction(file);
-         return AccessController.doPrivileged(action);
-      }
-   }
-
-   protected File getFile(Object key)
-   {
-      File base = null;
-      if (storageDirectories != null)
-      {
-         int hash = (key.hashCode()& 0x7FFFFFFF) % storageDirectories.length;
-         base = storageDirectories[hash];
-      }
-      else
-      {
-         base = baseDirectory;
-      }
-      return new File(base, String.valueOf(key) + ".ser");
-      
-   }
-   
-   @SuppressWarnings("unchecked")
-   public T load(Object key)
-   {
-      File file = getFile(key);
-      if(!file.exists())
-         return null;
-      
-      log.debug("loading state from " + file);
-      try
-      {
-         FileInputStream fis = FISAction.open(file);
-         ObjectInputStream in = new JBossObjectInputStream(fis);
-//         ObjectInputStream in = new ObjectInputStream(fis);
-         try
-         {
-            return (T) in.readObject();
-         }
-         finally
-         {
-            in.close();
-            DeleteFileAction.delete(file);
-         }
-      }
-      catch(ClassNotFoundException e)
-      {
-         throw new RuntimeException("failed to load object " + key, e);
-      }
-      catch(IOException e)
-      {
-         throw new RuntimeException("failed to load object " + key, e);
-      }
-   }
-
-   public void setStorageDirectory(String dirName)
-   {
-      baseDirectory = new File(dirName);
-   }   
-   
-   public void setSubdirectoryCount(int subdirectoryCount)
-   {
-      this.subdirectoryCount = subdirectoryCount;
-   }
-
-   public void start()
-   {
-      assert baseDirectory != null : "baseDirectory is null";
-      assert subdirectoryCount > 0 : "subdirectoryCount is < 1";
-      
-      establishDirectory(baseDirectory);
-      
-      if (subdirectoryCount > 1)
-      {
-         storageDirectories = new File[subdirectoryCount];
-         for (int i = 0; i < storageDirectories.length; i++)
-         {
-            File f = new File(baseDirectory, String.valueOf(i));
-            establishDirectory(f);
-            storageDirectories[i] = f;
-         }
-      }
-   }
-   
-   private void establishDirectory(File dir)
-   {      
-      if(!dir.exists())
-      {
-         if(!MkdirsFileAction.mkdirs(dir))
-            throw new RuntimeException("Unable to create storage directory " + dir);
-         dir.deleteOnExit();
-      }
-      
-      if(!dir.isDirectory())
-         throw new RuntimeException("Storage directory " + dir + " is not a directory");
-      
-   }
-   
-   public void stop()
-   {
-      // TODO: implement
-   }
-   
-   public void store(T obj)
-   {
-      File file = getFile(obj.getId());
-      file.deleteOnExit();
-      log.debug("saving state to " + file);
-      try
-      {
-         FileOutputStream fos = FOSAction.open(file);
-         ObjectOutputStream out = new JBossObjectOutputStream(fos);
-//         ObjectOutputStream out = new ObjectOutputStream(fos);
-         try
-         {
-            out.writeObject(obj);
-            out.flush();
-         }
-         finally
-         {
-            out.close();
-         }
-      }
-      catch(IOException e)
-      {
-         throw new RuntimeException("failed to store object " + obj.getId(), e);
-      }
-   }
-}

Copied: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/FilePersistentObjectStore.java (from rev 71451, projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/FileObjectStore.java)
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/FilePersistentObjectStore.java	                        (rev 0)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/FilePersistentObjectStore.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -0,0 +1,283 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.cache.spi.impl;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import org.jboss.ejb3.cache.api.CacheItem;
+import org.jboss.ejb3.cache.spi.PersistentObjectStore;
+import org.jboss.logging.Logger;
+import org.jboss.serial.io.JBossObjectInputStream;
+import org.jboss.serial.io.JBossObjectOutputStream;
+
+/**
+ * Stores objects in a directory via serialization.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: 65339 $
+ */
+public class FilePersistentObjectStore<T extends CacheItem> 
+   implements PersistentObjectStore<T>
+{
+   private static final Logger log = Logger.getLogger(FilePersistentObjectStore.class);
+   
+   private int subdirectoryCount;   
+   private File baseDirectory;
+   private File[] storageDirectories;
+   
+   private static class DeleteFileAction implements PrivilegedAction<Boolean>
+   {
+      File file;
+
+      DeleteFileAction(File file)
+      {
+         this.file = file;
+      }
+
+      public Boolean run()
+      {
+         return file.delete();
+      }
+
+      static boolean delete(File file)
+      {
+         DeleteFileAction action = new DeleteFileAction(file);
+         return AccessController.doPrivileged(action);
+      }
+   }
+
+   private static class FISAction implements PrivilegedExceptionAction<FileInputStream>
+   {
+      File file;
+
+      FISAction(File file)
+      {
+         this.file = file;
+      }
+
+      public FileInputStream run() throws FileNotFoundException
+      {
+         FileInputStream fis = new FileInputStream(file);
+         return fis;
+      }
+
+      static FileInputStream open(File file) throws FileNotFoundException
+      {
+         FISAction action = new FISAction(file);
+         FileInputStream fis = null;
+         try
+         {
+            fis = AccessController.doPrivileged(action);
+         }
+         catch (PrivilegedActionException e)
+         {
+            throw (FileNotFoundException) e.getException();
+         }
+         return fis;
+      }
+   }
+
+   private static class FOSAction implements PrivilegedExceptionAction<FileOutputStream>
+   {
+      File file;
+
+      FOSAction(File file)
+      {
+         this.file = file;
+      }
+
+      public FileOutputStream run() throws FileNotFoundException
+      {
+         FileOutputStream fis = new FileOutputStream(file);
+         return fis;
+      }
+
+      static FileOutputStream open(File file) throws FileNotFoundException
+      {
+         FOSAction action = new FOSAction(file);
+         FileOutputStream fos = null;
+         try
+         {
+            fos = AccessController.doPrivileged(action);
+         }
+         catch (PrivilegedActionException e)
+         {
+            throw (FileNotFoundException) e.getException();
+         }
+         return fos;
+      }
+   }
+
+   private static class MkdirsFileAction implements PrivilegedAction<Boolean>
+   {
+      File file;
+
+      MkdirsFileAction(File file)
+      {
+         this.file = file;
+      }
+
+      public Boolean run()
+      {
+         return file.mkdirs();
+      }
+
+      static boolean mkdirs(File file)
+      {
+         MkdirsFileAction action = new MkdirsFileAction(file);
+         return AccessController.doPrivileged(action);
+      }
+   }
+
+   protected File getFile(Object key)
+   {
+      File base = null;
+      if (storageDirectories != null)
+      {
+         int hash = (key.hashCode()& 0x7FFFFFFF) % storageDirectories.length;
+         base = storageDirectories[hash];
+      }
+      else
+      {
+         base = baseDirectory;
+      }
+      return new File(base, String.valueOf(key) + ".ser");
+      
+   }
+   
+   @SuppressWarnings("unchecked")
+   public T load(Object key)
+   {
+      File file = getFile(key);
+      if(!file.exists())
+         return null;
+      
+      log.debug("loading state from " + file);
+      try
+      {
+         FileInputStream fis = FISAction.open(file);
+         ObjectInputStream in = new JBossObjectInputStream(fis);
+//         ObjectInputStream in = new ObjectInputStream(fis);
+         try
+         {
+            return (T) in.readObject();
+         }
+         finally
+         {
+            in.close();
+            DeleteFileAction.delete(file);
+         }
+      }
+      catch(ClassNotFoundException e)
+      {
+         throw new RuntimeException("failed to load object " + key, e);
+      }
+      catch(IOException e)
+      {
+         throw new RuntimeException("failed to load object " + key, e);
+      }
+   }
+
+   public void setStorageDirectory(String dirName)
+   {
+      baseDirectory = new File(dirName);
+   }   
+   
+   public void setSubdirectoryCount(int subdirectoryCount)
+   {
+      this.subdirectoryCount = subdirectoryCount;
+   }
+
+   public void start()
+   {
+      assert baseDirectory != null : "baseDirectory is null";
+      assert subdirectoryCount > 0 : "subdirectoryCount is < 1";
+      
+      establishDirectory(baseDirectory);
+      
+      if (subdirectoryCount > 1)
+      {
+         storageDirectories = new File[subdirectoryCount];
+         for (int i = 0; i < storageDirectories.length; i++)
+         {
+            File f = new File(baseDirectory, String.valueOf(i));
+            establishDirectory(f);
+            storageDirectories[i] = f;
+         }
+      }
+   }
+   
+   private void establishDirectory(File dir)
+   {      
+      if(!dir.exists())
+      {
+         if(!MkdirsFileAction.mkdirs(dir))
+            throw new RuntimeException("Unable to create storage directory " + dir);
+         dir.deleteOnExit();
+      }
+      
+      if(!dir.isDirectory())
+         throw new RuntimeException("Storage directory " + dir + " is not a directory");
+      
+   }
+   
+   public void stop()
+   {
+      // TODO: implement
+   }
+   
+   public void store(T obj)
+   {
+      File file = getFile(obj.getId());
+      file.deleteOnExit();
+      log.debug("saving state to " + file);
+      try
+      {
+         FileOutputStream fos = FOSAction.open(file);
+         ObjectOutputStream out = new JBossObjectOutputStream(fos);
+//         ObjectOutputStream out = new ObjectOutputStream(fos);
+         try
+         {
+            out.writeObject(obj);
+            out.flush();
+         }
+         finally
+         {
+            out.close();
+         }
+      }
+      catch(IOException e)
+      {
+         throw new RuntimeException("failed to store object " + obj.getId(), e);
+      }
+   }
+}

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/GroupCreationContext.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/GroupCreationContext.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/GroupCreationContext.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -26,21 +26,65 @@
 import java.util.List;
 import java.util.Map;
 
+import org.jboss.ejb3.cache.api.StatefulObjectFactory;
+import org.jboss.ejb3.cache.spi.SerializationGroup;
 
+
 /**
+ * Stores contextual information about a set of {@link CacheItem}s that are 
+ * being created as members of a {@link SerializationGroup}. Implementation is 
+ * based on a <code>ThreadLocal</code>.
+ * 
  * @author Brian Stansberry
- *
  */
 public class GroupCreationContext
 {
-   @SuppressWarnings("unchecked")
    private static final ThreadLocal<GroupCreationContext> groupCreationContext = new ThreadLocal<GroupCreationContext>();
    
    private final List<ItemCachePair> pairs;
    private Map<Object, Object> sharedState;
    private final boolean strict;
+
+   /**
+    * Gets the GroupCreationContext associated with the thread.
+    * 
+    * @return the context. May return <code>null</code>.
+    */
+   public static GroupCreationContext getGroupCreationContext()
+   {
+      return groupCreationContext.get();
+   }
    
    /**
+    * Create a new GroupCreationContext associated with the thread.
+    * 
+    * @param strict <code>true</code> if other caches associated with the context
+    *               should strictly check compatibility with a 
+    *               {@link SerializationGroup}, <code>false</code> if not.
+    *               
+    * @return the context. Will not return <code>null</code>.
+    * 
+    * @throws IllegalStateException if a context is already bound to the thread
+    */
+   public static GroupCreationContext startGroupCreationContext(boolean strict)
+   {
+      if (groupCreationContext.get() != null)
+         throw new IllegalStateException("GroupCreationContext already exists");
+      GroupCreationContext started = new GroupCreationContext(strict);
+      groupCreationContext.set(started);
+      return started;
+   }
+   
+   /**
+    * Clears the association of any GroupCreationContext with the current thread.
+    *
+    */
+   public static void clearGroupCreationContext()
+   {
+      groupCreationContext.set(null);
+   }
+   
+   /**
     * Prevent external instantiation. 
     */
    private GroupCreationContext(boolean strict) 
@@ -49,44 +93,55 @@
       this.strict = strict;
    }
 
+   /**
+    * Gets the list of cache items and associated caches that currently
+    * comprise the group.
+    * 
+    * @return a list of cache items and associated caches.  
+    *         Will not return <code>null</code>.
+    */
    public List<ItemCachePair> getPairs()
    {
       return pairs;
    }
 
+   /**
+    * Gets any shared state map that should be passed to
+    * {@link StatefulObjectFactory#create(Class[], Object[], Map)} for
+    * each member of the group.
+    * 
+    * @return the shared state map.  May be <code>null</code>
+    */
    public Map<Object, Object> getSharedState()
    {
       return sharedState;
    }  
    
+   /**
+    * Sets any shared state map that should be passed to
+    * {@link StatefulObjectFactory#create(Class[], Object[], Map)} for
+    * each member of the group.
+    * 
+    * @param sharedState the shared state map.  Cannot be <code>null</code>
+    * 
+    * @throws IllegalStateException if shared state has already been set
+    */
    public void setSharedState(Map<Object, Object> sharedState)
    {
+      assert sharedState != null : "sharedState is null";
+      
       if (this.sharedState != null)
          throw new IllegalStateException("Shared state already set");
       this.sharedState = sharedState;
    }
    
+   /**
+    * Gets whether the cache that initialized creation of the context has
+    * specified that all other caches must strictly check whether they
+    * are compatible with the group.
+    */
    public boolean isStrict()
    {
       return strict;
    }
-
-   public static GroupCreationContext getGroupCreationContext()
-   {
-      return groupCreationContext.get();
-   }
-   
-   public static GroupCreationContext startGroupCreationContext(boolean strict)
-   {
-      if (groupCreationContext.get() != null)
-         throw new IllegalStateException("GroupCreationContext already exists");
-      GroupCreationContext started = new GroupCreationContext(strict);
-      groupCreationContext.set(started);
-      return started;
-   }
-   
-   public static void clearGroupCreationContext()
-   {
-      groupCreationContext.set(null);
-   }
 }

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/ItemCachePair.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/ItemCachePair.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/spi/impl/ItemCachePair.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -25,6 +25,7 @@
 import org.jboss.ejb3.cache.api.Cache;
 import org.jboss.ejb3.cache.api.CacheItem;
 import org.jboss.ejb3.cache.spi.GroupAwareBackingCache;
+import org.jboss.ejb3.cache.spi.SerializationGroupMember;
 
 /**
  * Simple data container for a {@link CacheItem} and the
@@ -36,9 +37,9 @@
 public class ItemCachePair
 {
    private final CacheItem item;
-   private final GroupAwareBackingCache cache;
+   private final GroupAwareBackingCache<? extends CacheItem, ? extends SerializationGroupMember<?>> cache;
    
-   public ItemCachePair(CacheItem item, GroupAwareBackingCache cache)
+   public ItemCachePair(CacheItem item, GroupAwareBackingCache<? extends CacheItem, ? extends SerializationGroupMember<?>> cache)
    {
       this.item = item;
       this.cache = cache;
@@ -49,7 +50,7 @@
       return item;
    }
 
-   public GroupAwareBackingCache getCache()
+   public GroupAwareBackingCache<? extends CacheItem, ? extends SerializationGroupMember<?>> getCache()
    {
       return cache;
    }

Copied: projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/distributed/MockBackingCacheEntryStoreSource.java (from rev 71451, projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/distributed/MockIntegratedObjectStoreSource.java)
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/distributed/MockBackingCacheEntryStoreSource.java	                        (rev 0)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/distributed/MockBackingCacheEntryStoreSource.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -0,0 +1,64 @@
+/*
+ * 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.test.cache.distributed;
+
+import javax.transaction.TransactionManager;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.cache.api.CacheItem;
+import org.jboss.ejb3.cache.spi.BackingCacheEntryStoreSource;
+import org.jboss.ejb3.cache.spi.BackingCacheEntryStore;
+import org.jboss.ejb3.cache.spi.SerializationGroup;
+import org.jboss.ejb3.cache.spi.SerializationGroupMember;
+import org.jboss.ejb3.cache.spi.SynchronizationCoordinator;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class MockBackingCacheEntryStoreSource<T extends CacheItem> 
+   implements BackingCacheEntryStoreSource<T>
+{
+   private UnmarshallingMap localMap;
+   private UnmarshallingMap remoteMap;
+   
+   public MockBackingCacheEntryStoreSource(UnmarshallingMap localMap, UnmarshallingMap remoteMap)
+   {
+      this.localMap = localMap;
+      this.remoteMap = remoteMap;
+   }
+   
+   public BackingCacheEntryStore<T, SerializationGroup<T>>  createGroupIntegratedObjectStore(String containerName,
+         String cacheConfigName, CacheConfig cacheConfig, TransactionManager transactionManager, SynchronizationCoordinator synchronizationCoordinator)
+   {
+      String keyBase = "GroupCache-" + containerName;
+      return new MockJBCBackingCacheEntryStore<T, SerializationGroup<T>>(localMap, remoteMap, cacheConfig, keyBase, keyBase, true);
+   }
+
+   public BackingCacheEntryStore<T, SerializationGroupMember<T>>  createIntegratedObjectStore(String containerName, String cacheConfigName,
+         CacheConfig cacheConfig, TransactionManager transactionManager, SynchronizationCoordinator synchronizationCoordinator)
+   {
+      return new MockJBCBackingCacheEntryStore<T, SerializationGroupMember<T>>(localMap, remoteMap, cacheConfig, containerName, containerName, false);
+   }
+
+}

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/distributed/MockClusterMember.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/distributed/MockClusterMember.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/distributed/MockClusterMember.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -24,7 +24,7 @@
 
 import javax.transaction.TransactionManager;
 
-import org.jboss.ejb3.cache.spi.IntegratedObjectStoreSource;
+import org.jboss.ejb3.cache.spi.BackingCacheEntryStoreSource;
 import org.jboss.ejb3.test.cache.mock.CacheType;
 import org.jboss.ejb3.test.cache.mock.MockBeanContainer;
 import org.jboss.ejb3.test.cache.mock.MockBeanContext;
@@ -108,11 +108,11 @@
    }
 
    @Override
-   protected IntegratedObjectStoreSource<MockBeanContext> getDistributedStoreSource()
+   protected BackingCacheEntryStoreSource<MockBeanContext> getDistributedStoreSource()
    {
       if (localDistributedCacheMember != null && remoteDistributedCacheMember != null)
       {
-         return new MockIntegratedObjectStoreSource<MockBeanContext>(localDistributedCacheMember, 
+         return new MockBackingCacheEntryStoreSource<MockBeanContext>(localDistributedCacheMember, 
                                                                      remoteDistributedCacheMember);
       }
       else

Deleted: projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/distributed/MockIntegratedObjectStoreSource.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/distributed/MockIntegratedObjectStoreSource.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/distributed/MockIntegratedObjectStoreSource.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -1,64 +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.test.cache.distributed;
-
-import javax.transaction.TransactionManager;
-
-import org.jboss.ejb3.annotation.CacheConfig;
-import org.jboss.ejb3.cache.api.CacheItem;
-import org.jboss.ejb3.cache.spi.IntegratedObjectStoreSource;
-import org.jboss.ejb3.cache.spi.PassivatingIntegratedObjectStore;
-import org.jboss.ejb3.cache.spi.SerializationGroup;
-import org.jboss.ejb3.cache.spi.SerializationGroupMember;
-import org.jboss.ejb3.cache.spi.SynchronizationCoordinator;
-
-/**
- * @author Brian Stansberry
- *
- */
-public class MockIntegratedObjectStoreSource<T extends CacheItem> 
-   implements IntegratedObjectStoreSource<T>
-{
-   private UnmarshallingMap localMap;
-   private UnmarshallingMap remoteMap;
-   
-   public MockIntegratedObjectStoreSource(UnmarshallingMap localMap, UnmarshallingMap remoteMap)
-   {
-      this.localMap = localMap;
-      this.remoteMap = remoteMap;
-   }
-   
-   public PassivatingIntegratedObjectStore<T, SerializationGroup<T>>  createGroupIntegratedObjectStore(String containerName,
-         String cacheConfigName, CacheConfig cacheConfig, TransactionManager transactionManager, SynchronizationCoordinator synchronizationCoordinator)
-   {
-      String keyBase = "GroupCache-" + containerName;
-      return new MockJBCIntegratedObjectStore<T, SerializationGroup<T>>(localMap, remoteMap, cacheConfig, keyBase, keyBase, true);
-   }
-
-   public PassivatingIntegratedObjectStore<T, SerializationGroupMember<T>>  createIntegratedObjectStore(String containerName, String cacheConfigName,
-         CacheConfig cacheConfig, TransactionManager transactionManager, SynchronizationCoordinator synchronizationCoordinator)
-   {
-      return new MockJBCIntegratedObjectStore<T, SerializationGroupMember<T>>(localMap, remoteMap, cacheConfig, containerName, containerName, false);
-   }
-
-}

Copied: projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/distributed/MockJBCBackingCacheEntryStore.java (from rev 71451, projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/distributed/MockJBCIntegratedObjectStore.java)
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/distributed/MockJBCBackingCacheEntryStore.java	                        (rev 0)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/distributed/MockJBCBackingCacheEntryStore.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -0,0 +1,415 @@
+/*
+ * 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.test.cache.distributed;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.cache.api.CacheItem;
+import org.jboss.ejb3.cache.spi.BackingCacheEntry;
+import org.jboss.ejb3.cache.spi.GroupCompatibilityChecker;
+import org.jboss.ejb3.cache.spi.BackingCacheEntryStore;
+import org.jboss.ejb3.cache.spi.impl.AbstractBackingCacheEntryStore;
+import org.jboss.ejb3.cache.spi.impl.CacheableTimestamp;
+import org.jboss.logging.Logger;
+
+/**
+ * {@link BackingCacheEntryStore} implementation that mocks the functions
+ * of a JBoss Cache-based version.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class MockJBCBackingCacheEntryStore<C extends CacheItem, T extends BackingCacheEntry<C>> 
+     extends AbstractBackingCacheEntryStore<C, T, Object>
+
+{
+   private static final Logger log = Logger.getLogger(MockJBCBackingCacheEntryStore.class);
+
+   /**
+    * Qualifier used to scope our keys in the maps
+    */
+   private final Object keyBase;
+   
+   /** 
+    * Our in-VM "JBoss Cache" instance.
+    */
+   private final UnmarshallingMap localJBC;
+   /** 
+    * A remote "JBoss Cache" instance. We only store byte[] values,
+    * mocking the effect of replication.
+    */
+   private final UnmarshallingMap remoteJBC;
+   
+   /**
+    * Those keys in the mockJBC map that haven't been "passivated"
+    */
+   private final Set<Object> inMemory;
+   
+   /**
+    * Those keys that have been updated locally but not copied to remoteJBC.
+    */
+   private Set<Object> dirty;
+   
+   private final Map<Object, Long> timestamps;
+
+   /** A mock transaction manager */
+   private final ThreadLocal<Boolean> tm = new ThreadLocal<Boolean>();
+   
+   public MockJBCBackingCacheEntryStore(UnmarshallingMap localCache, 
+                                       UnmarshallingMap remoteCache,
+                                       CacheConfig cacheConfig,
+                                       Object keyBase,
+                                       String name,
+                                       boolean forGroups)
+   {      
+      super(cacheConfig, name, forGroups);
+      
+      this.localJBC = localCache;
+      this.remoteJBC = remoteCache;
+      this.keyBase = keyBase;
+      inMemory = new HashSet<Object>();
+      timestamps = new HashMap<Object, Long>();
+   }
+
+   // --------------------------------------------------  IntegratedObjectStore
+   
+   public boolean isClustered()
+   {
+      return true;
+   }
+   
+   public T get(Object key)
+   {      
+      T entry = unmarshall(key, localJBC.get(getScopedKey(key)));
+      if (entry != null)
+         timestamps.put(key, new Long(System.currentTimeMillis()));
+      return entry;
+   }
+
+   public void insert(T entry)
+   {
+      putInCache(entry.getId(), entry);
+   }
+   
+   public void update(T entry, boolean modified)
+   {
+      log.trace("updating " + entry.getId());
+      if (modified)
+      {
+         putInCache(entry.getId(), entry);
+      }
+      else
+      {
+         timestamps.put(entry.getId(), new Long(entry.getLastUsed()));
+      }
+   }
+
+   @SuppressWarnings("unchecked")
+   public void passivate(T entry)
+   {
+      Object key = entry.getId();
+      if (inMemory.contains(key))
+      {
+         log.trace("converting " + key + " to passivated state");
+         ScopedKey skey = getScopedKey(key);
+         localJBC.put(skey, marshall((T) localJBC.get(skey)));
+         inMemory.remove(key);
+      }
+   }
+
+   public T remove(Object key)
+   {
+      return unmarshall(key, putInCache(key, null));
+   }
+   
+   @SuppressWarnings("unchecked")
+   public boolean isCompatibleWith(GroupCompatibilityChecker other)
+   {
+      if (other instanceof MockJBCBackingCacheEntryStore)
+      {
+         MockJBCBackingCacheEntryStore jbc2 = (MockJBCBackingCacheEntryStore) other;
+         return this.localJBC == jbc2.localJBC
+                 && this.remoteJBC == jbc2.remoteJBC;
+      }
+      return false;
+   }
+   
+   
+   // ------------------------------------------------------------ Transaction
+
+   public void startTransaction()
+   {
+      if (tm.get() != null)
+         throw new IllegalStateException("Transaction already started");
+      tm.set(Boolean.TRUE);
+   }
+   
+   public void commitTransaction()
+   {
+      try
+      {
+         for (Iterator<Object> iter = dirty.iterator(); iter.hasNext();)
+         {
+            Object key = iter.next();
+            replicate(key, unmarshall(key, localJBC.get(getScopedKey(key))));
+            iter.remove();
+         }
+      }
+      finally
+      {
+         tm.set(null);
+      }
+   }
+   
+   @SuppressWarnings("unchecked")
+   private T unmarshall(Object key, Object obj)
+   {
+      if (!(obj instanceof byte[]))
+         return (T) obj;
+      
+      log.trace("unmarshalling " + key);
+      ScopedKey skey = getScopedKey(key);
+      T entry = (T) localJBC.unmarshall(skey);
+      localJBC.put(skey, entry);
+      inMemory.add(key);
+      return entry;
+   }
+   
+   private Object putInCache(Object key, T value)
+   {
+      ScopedKey skey = getScopedKey(key);
+      Object existing = null;
+      if (value != null)
+      {
+         existing = localJBC.put(skey, value);
+         inMemory.add(key);
+         timestamps.put(key, new Long(System.currentTimeMillis()));
+      }
+      else
+      {
+         existing = localJBC.remove(skey);
+         inMemory.remove(key);
+         timestamps.remove(key);
+      }
+      
+      if (tm.get() == null)
+      {
+         replicate(key, value);
+      }
+      else
+      {
+         dirty.add(key);
+      }
+      
+      return existing;
+   }
+   
+   private void replicate(Object key, T value)
+   {
+      ScopedKey skey = getScopedKey(key);
+      if (value != null)
+         remoteJBC.put(skey, marshall(value));
+      else
+         remoteJBC.remove(skey);
+   }
+   
+   private byte[] marshall(T value)
+   {
+      log.trace("marshalling " + value.getId());
+      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+      try
+      {
+         ObjectOutputStream oos = new ObjectOutputStream(baos);
+         oos.writeObject(value);
+         oos.close();
+      }
+      catch (IOException e)
+      {
+         throw new RuntimeException(e);
+      }
+      return baos.toByteArray();
+   }
+
+   // ---------------------------------------  BackingCacheEntryStore
+   
+     
+//   public void runExpiration()
+//   {
+//      if (expirationTimeSeconds > 0)
+//      {
+//         long now = System.currentTimeMillis();
+//         long minRemovalUse = now - (expirationTimeSeconds * 1000);                     
+//         for (CacheableTimestamp<Object> ts : getAllEntries())
+//         {
+//            try
+//            {
+//               if (minRemovalUse >= ts.getLastUsed())
+//               {
+//                  remove(ts.getId());
+//               }
+//            }
+//            catch (IllegalStateException ise)
+//            {
+//               // Not so great; we're assuming it's 'cause item's in use
+//               log.trace("skipping in-use entry " + ts.getId(), ise);
+//            }
+//         }    
+//      }      
+//   }
+
+//   public void runPassivation()
+//   {
+//      if (maxSize > 0 || idleTimeSeconds > 0)
+//      {
+//         long now = System.currentTimeMillis();
+//         long minPassUse = (idleTimeSeconds > 0 ? now - (idleTimeSeconds * 1000) : 0);
+//         
+//         SortedSet<CacheableTimestamp<Object>> timestamps = getInMemoryEntries();
+//         int overCount = (maxSize > 0 ? timestamps.size() - maxSize : 0);
+//         for (CacheableTimestamp<Object> ts : timestamps)
+//         {
+//            try
+//            {
+//               if (overCount > 0 || minPassUse >= ts.getLastUsed())
+//               {
+//                  log.trace("attempting to passivate " + ts.getId());
+//                  owningCache.passivate(ts.getId());
+//                  overCount--;
+//               }
+//               else
+//               {
+//                  break;
+//               }
+//            }
+//            catch (IllegalStateException ise)
+//            {
+//               // Not so great; we're assuming it's 'cause item's in use
+//               log.trace("skipping in-use entry " + ts.getId(), ise);
+//            }
+//         }
+//      }
+//      
+//   }
+
+   @Override
+   public int getInMemoryCount()
+   {
+      return inMemory.size();
+   }
+
+   @Override
+   public int getPassivatedCount()
+   {
+      return timestamps.size() - getInMemoryCount();
+   }
+
+   @Override
+   protected void processExpiration(Object key, long lastUse)
+   {
+      remove(key);      
+   }
+
+   @Override
+   protected void processPassivation(Object key, long lastUse)
+   {
+      getPassivatingCache().passivate(key);      
+   }
+
+   @Override
+   protected CacheableTimestamp<Object>[] getInMemoryEntries()
+   {     
+      return getTimestampArray(false);
+   }
+
+   @Override
+   protected CacheableTimestamp<Object>[] getAllEntries()
+   {     
+      return getTimestampArray(null);
+   }
+
+   @SuppressWarnings("unchecked")
+   private CacheableTimestamp<Object>[] getTimestampArray(Boolean passivated)
+   {     
+      Set<CacheableTimestamp<Object>> set = new HashSet<CacheableTimestamp<Object>>();
+      for (Map.Entry<Object, Long> entry : timestamps.entrySet())
+      {
+         if (passivated == null || passivated.booleanValue() != inMemory.contains(entry.getKey()))
+         {
+            set.add(new CacheableTimestamp<Object>(entry.getKey(), entry.getValue()));
+         }
+      }
+      CacheableTimestamp<Object>[] array = new CacheableTimestamp[set.size()];
+      array = set.toArray(array);
+      Arrays.sort(array);
+      return array;
+   }
+   
+   private ScopedKey getScopedKey(Object unscoped)
+   {
+      return new ScopedKey(unscoped, keyBase);
+   }
+   
+   private static class ScopedKey
+   {
+      private Object unscoped;
+      private Object keyBase;
+      ScopedKey(Object unscoped, Object keyBase)
+      {
+         this.unscoped = unscoped;
+         this.keyBase = keyBase;
+      }
+      
+      @Override
+      public int hashCode()
+      {
+         int result = 17;
+         result += 31 * unscoped.hashCode();
+         result += 31 * keyBase.hashCode();
+         return result;
+      }
+
+      @Override
+      public boolean equals(Object obj)
+      {
+         if (this == obj)
+            return true;
+         
+         if (obj instanceof ScopedKey)
+         {
+            ScopedKey other = (ScopedKey) obj;
+            return (this.unscoped.equals(other.unscoped) 
+                      && keyBase.equals(other.keyBase));
+         }
+         return false;
+      }
+   }
+}

Deleted: projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/distributed/MockJBCIntegratedObjectStore.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/distributed/MockJBCIntegratedObjectStore.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/distributed/MockJBCIntegratedObjectStore.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -1,415 +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.test.cache.distributed;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.ejb3.annotation.CacheConfig;
-import org.jboss.ejb3.cache.api.CacheItem;
-import org.jboss.ejb3.cache.spi.GroupCompatibilityChecker;
-import org.jboss.ejb3.cache.spi.IntegratedObjectStore;
-import org.jboss.ejb3.cache.spi.PassivatingBackingCacheEntry;
-import org.jboss.ejb3.cache.spi.impl.AbstractPassivatingIntegratedObjectStore;
-import org.jboss.ejb3.cache.spi.impl.CacheableTimestamp;
-import org.jboss.logging.Logger;
-
-/**
- * {@link IntegratedObjectStore} implementation that mocks the functions
- * of a JBoss Cache-based version.
- * 
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class MockJBCIntegratedObjectStore<C extends CacheItem, T extends PassivatingBackingCacheEntry<C>> 
-     extends AbstractPassivatingIntegratedObjectStore<C, T, Object>
-
-{
-   private static final Logger log = Logger.getLogger(MockJBCIntegratedObjectStore.class);
-
-   /**
-    * Qualifier used to scope our keys in the maps
-    */
-   private final Object keyBase;
-   
-   /** 
-    * Our in-VM "JBoss Cache" instance.
-    */
-   private final UnmarshallingMap localJBC;
-   /** 
-    * A remote "JBoss Cache" instance. We only store byte[] values,
-    * mocking the effect of replication.
-    */
-   private final UnmarshallingMap remoteJBC;
-   
-   /**
-    * Those keys in the mockJBC map that haven't been "passivated"
-    */
-   private final Set<Object> inMemory;
-   
-   /**
-    * Those keys that have been updated locally but not copied to remoteJBC.
-    */
-   private Set<Object> dirty;
-   
-   private final Map<Object, Long> timestamps;
-
-   /** A mock transaction manager */
-   private final ThreadLocal<Boolean> tm = new ThreadLocal<Boolean>();
-   
-   public MockJBCIntegratedObjectStore(UnmarshallingMap localCache, 
-                                       UnmarshallingMap remoteCache,
-                                       CacheConfig cacheConfig,
-                                       Object keyBase,
-                                       String name,
-                                       boolean forGroups)
-   {      
-      super(cacheConfig, name, forGroups);
-      
-      this.localJBC = localCache;
-      this.remoteJBC = remoteCache;
-      this.keyBase = keyBase;
-      inMemory = new HashSet<Object>();
-      timestamps = new HashMap<Object, Long>();
-   }
-
-   // --------------------------------------------------  IntegratedObjectStore
-   
-   public boolean isClustered()
-   {
-      return true;
-   }
-   
-   public T get(Object key)
-   {      
-      T entry = unmarshall(key, localJBC.get(getScopedKey(key)));
-      if (entry != null)
-         timestamps.put(key, new Long(System.currentTimeMillis()));
-      return entry;
-   }
-
-   public void insert(T entry)
-   {
-      putInCache(entry.getId(), entry);
-   }
-   
-   public void update(T entry, boolean modified)
-   {
-      log.trace("updating " + entry.getId());
-      if (modified)
-      {
-         putInCache(entry.getId(), entry);
-      }
-      else
-      {
-         timestamps.put(entry.getId(), new Long(entry.getLastUsed()));
-      }
-   }
-
-   @SuppressWarnings("unchecked")
-   public void passivate(T entry)
-   {
-      Object key = entry.getId();
-      if (inMemory.contains(key))
-      {
-         log.trace("converting " + key + " to passivated state");
-         ScopedKey skey = getScopedKey(key);
-         localJBC.put(skey, marshall((T) localJBC.get(skey)));
-         inMemory.remove(key);
-      }
-   }
-
-   public T remove(Object key)
-   {
-      return unmarshall(key, putInCache(key, null));
-   }
-   
-   @SuppressWarnings("unchecked")
-   public boolean isCompatibleWith(GroupCompatibilityChecker other)
-   {
-      if (other instanceof MockJBCIntegratedObjectStore)
-      {
-         MockJBCIntegratedObjectStore jbc2 = (MockJBCIntegratedObjectStore) other;
-         return this.localJBC == jbc2.localJBC
-                 && this.remoteJBC == jbc2.remoteJBC;
-      }
-      return false;
-   }
-   
-   
-   // ------------------------------------------------------------ Transaction
-
-   public void startTransaction()
-   {
-      if (tm.get() != null)
-         throw new IllegalStateException("Transaction already started");
-      tm.set(Boolean.TRUE);
-   }
-   
-   public void commitTransaction()
-   {
-      try
-      {
-         for (Iterator<Object> iter = dirty.iterator(); iter.hasNext();)
-         {
-            Object key = iter.next();
-            replicate(key, unmarshall(key, localJBC.get(getScopedKey(key))));
-            iter.remove();
-         }
-      }
-      finally
-      {
-         tm.set(null);
-      }
-   }
-   
-   @SuppressWarnings("unchecked")
-   private T unmarshall(Object key, Object obj)
-   {
-      if (!(obj instanceof byte[]))
-         return (T) obj;
-      
-      log.trace("unmarshalling " + key);
-      ScopedKey skey = getScopedKey(key);
-      T entry = (T) localJBC.unmarshall(skey);
-      localJBC.put(skey, entry);
-      inMemory.add(key);
-      return entry;
-   }
-   
-   private Object putInCache(Object key, T value)
-   {
-      ScopedKey skey = getScopedKey(key);
-      Object existing = null;
-      if (value != null)
-      {
-         existing = localJBC.put(skey, value);
-         inMemory.add(key);
-         timestamps.put(key, new Long(System.currentTimeMillis()));
-      }
-      else
-      {
-         existing = localJBC.remove(skey);
-         inMemory.remove(key);
-         timestamps.remove(key);
-      }
-      
-      if (tm.get() == null)
-      {
-         replicate(key, value);
-      }
-      else
-      {
-         dirty.add(key);
-      }
-      
-      return existing;
-   }
-   
-   private void replicate(Object key, T value)
-   {
-      ScopedKey skey = getScopedKey(key);
-      if (value != null)
-         remoteJBC.put(skey, marshall(value));
-      else
-         remoteJBC.remove(skey);
-   }
-   
-   private byte[] marshall(T value)
-   {
-      log.trace("marshalling " + value.getId());
-      ByteArrayOutputStream baos = new ByteArrayOutputStream();
-      try
-      {
-         ObjectOutputStream oos = new ObjectOutputStream(baos);
-         oos.writeObject(value);
-         oos.close();
-      }
-      catch (IOException e)
-      {
-         throw new RuntimeException(e);
-      }
-      return baos.toByteArray();
-   }
-
-   // ---------------------------------------  PassivatingIntegratedObjectStore
-   
-     
-//   public void runExpiration()
-//   {
-//      if (expirationTimeSeconds > 0)
-//      {
-//         long now = System.currentTimeMillis();
-//         long minRemovalUse = now - (expirationTimeSeconds * 1000);                     
-//         for (CacheableTimestamp<Object> ts : getAllEntries())
-//         {
-//            try
-//            {
-//               if (minRemovalUse >= ts.getLastUsed())
-//               {
-//                  remove(ts.getId());
-//               }
-//            }
-//            catch (IllegalStateException ise)
-//            {
-//               // Not so great; we're assuming it's 'cause item's in use
-//               log.trace("skipping in-use entry " + ts.getId(), ise);
-//            }
-//         }    
-//      }      
-//   }
-
-//   public void runPassivation()
-//   {
-//      if (maxSize > 0 || idleTimeSeconds > 0)
-//      {
-//         long now = System.currentTimeMillis();
-//         long minPassUse = (idleTimeSeconds > 0 ? now - (idleTimeSeconds * 1000) : 0);
-//         
-//         SortedSet<CacheableTimestamp<Object>> timestamps = getInMemoryEntries();
-//         int overCount = (maxSize > 0 ? timestamps.size() - maxSize : 0);
-//         for (CacheableTimestamp<Object> ts : timestamps)
-//         {
-//            try
-//            {
-//               if (overCount > 0 || minPassUse >= ts.getLastUsed())
-//               {
-//                  log.trace("attempting to passivate " + ts.getId());
-//                  owningCache.passivate(ts.getId());
-//                  overCount--;
-//               }
-//               else
-//               {
-//                  break;
-//               }
-//            }
-//            catch (IllegalStateException ise)
-//            {
-//               // Not so great; we're assuming it's 'cause item's in use
-//               log.trace("skipping in-use entry " + ts.getId(), ise);
-//            }
-//         }
-//      }
-//      
-//   }
-
-   @Override
-   public int getInMemoryCount()
-   {
-      return inMemory.size();
-   }
-
-   @Override
-   public int getPassivatedCount()
-   {
-      return timestamps.size() - getInMemoryCount();
-   }
-
-   @Override
-   protected void processExpiration(Object key, long lastUse)
-   {
-      remove(key);      
-   }
-
-   @Override
-   protected void processPassivation(Object key, long lastUse)
-   {
-      getPassivatingCache().passivate(key);      
-   }
-
-   @Override
-   protected CacheableTimestamp<Object>[] getInMemoryEntries()
-   {     
-      return getTimestampArray(false);
-   }
-
-   @Override
-   protected CacheableTimestamp<Object>[] getAllEntries()
-   {     
-      return getTimestampArray(null);
-   }
-
-   @SuppressWarnings("unchecked")
-   private CacheableTimestamp<Object>[] getTimestampArray(Boolean passivated)
-   {     
-      Set<CacheableTimestamp<Object>> set = new HashSet<CacheableTimestamp<Object>>();
-      for (Map.Entry<Object, Long> entry : timestamps.entrySet())
-      {
-         if (passivated == null || passivated.booleanValue() != inMemory.contains(entry.getKey()))
-         {
-            set.add(new CacheableTimestamp<Object>(entry.getKey(), entry.getValue()));
-         }
-      }
-      CacheableTimestamp<Object>[] array = new CacheableTimestamp[set.size()];
-      array = set.toArray(array);
-      Arrays.sort(array);
-      return array;
-   }
-   
-   private ScopedKey getScopedKey(Object unscoped)
-   {
-      return new ScopedKey(unscoped, keyBase);
-   }
-   
-   private static class ScopedKey
-   {
-      private Object unscoped;
-      private Object keyBase;
-      ScopedKey(Object unscoped, Object keyBase)
-      {
-         this.unscoped = unscoped;
-         this.keyBase = keyBase;
-      }
-      
-      @Override
-      public int hashCode()
-      {
-         int result = 17;
-         result += 31 * unscoped.hashCode();
-         result += 31 * keyBase.hashCode();
-         return result;
-      }
-
-      @Override
-      public boolean equals(Object obj)
-      {
-         if (this == obj)
-            return true;
-         
-         if (obj instanceof ScopedKey)
-         {
-            ScopedKey other = (ScopedKey) obj;
-            return (this.unscoped.equals(other.unscoped) 
-                      && keyBase.equals(other.keyBase));
-         }
-         return false;
-      }
-   }
-}

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/mock/MockBeanContainer.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/mock/MockBeanContainer.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/mock/MockBeanContainer.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -81,12 +81,12 @@
    
    public void stop()
    {      
-      log.debug("Starting container " + containerName);     
+      log.debug("Stopping container " + containerName);     
       
       cache.stop();
       MockRegistry.remove(containerName);
       
-      log.debug("Started container " + containerName);
+      log.debug("Stopped container " + containerName);
    }
    
    public String getName()

Modified: projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/mock/MockEjb3System.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/mock/MockEjb3System.java	2008-03-31 21:37:53 UTC (rev 71525)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/test/java/org/jboss/ejb3/test/cache/mock/MockEjb3System.java	2008-03-31 21:42:45 UTC (rev 71526)
@@ -30,10 +30,10 @@
 import org.jboss.ejb3.cache.api.StatefulCacheFactory;
 import org.jboss.ejb3.cache.api.StatefulCacheFactoryRegistry;
 import org.jboss.ejb3.cache.impl.factory.GroupAwareCacheFactory;
-import org.jboss.ejb3.cache.impl.factory.NonClusteredIntegratedObjectStoreSource;
+import org.jboss.ejb3.cache.impl.factory.NonClusteredBackingCacheEntryStoreSource;
 import org.jboss.ejb3.cache.impl.factory.NonPassivatingCacheFactory;
 import org.jboss.ejb3.cache.impl.factory.PassivationExpirationCoordinatorImpl;
-import org.jboss.ejb3.cache.spi.IntegratedObjectStoreSource;
+import org.jboss.ejb3.cache.spi.BackingCacheEntryStoreSource;
 import org.jboss.ejb3.cache.spi.PassivationExpirationCoordinator;
 import org.jboss.ejb3.cache.spi.impl.AbstractStatefulCacheFactory;
 import org.jboss.ejb3.test.cache.mock.tm.MockTransactionManager;
@@ -174,18 +174,18 @@
    
    private AbstractStatefulCacheFactory<MockBeanContext> buildSimpleCacheFactory()
    {
-      NonClusteredIntegratedObjectStoreSource<MockBeanContext> source = 
-         new NonClusteredIntegratedObjectStoreSource<MockBeanContext>();
+      NonClusteredBackingCacheEntryStoreSource<MockBeanContext> source = 
+         new NonClusteredBackingCacheEntryStoreSource<MockBeanContext>();
       return new GroupAwareCacheFactory<MockBeanContext>(source);
    }
    
    private AbstractStatefulCacheFactory<MockBeanContext> buildDistributedCacheFactory()
    {
-     IntegratedObjectStoreSource<MockBeanContext> storeSource = getDistributedStoreSource();
+     BackingCacheEntryStoreSource<MockBeanContext> storeSource = getDistributedStoreSource();
      return storeSource == null ? null : new GroupAwareCacheFactory<MockBeanContext>(storeSource);
    }
    
-   protected IntegratedObjectStoreSource<MockBeanContext> getDistributedStoreSource()
+   protected BackingCacheEntryStoreSource<MockBeanContext> getDistributedStoreSource()
    {
       throw new UnsupportedOperationException("Distributed caching not supported");
    }




More information about the jboss-cvs-commits mailing list