[jboss-cvs] JBossAS SVN: r84332 - in projects/ejb3/branches/cluster-dev: core and 8 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Feb 17 17:38:37 EST 2009


Author: bstansberry at jboss.com
Date: 2009-02-17 17:38:36 -0500 (Tue, 17 Feb 2009)
New Revision: 84332

Added:
   projects/ejb3/branches/cluster-dev/core/
   projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/SharedXPC.java
   projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/BlockingPersistentObjectStore.java
   projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/ForceEventsBackingCacheEntryStore.java
   projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/ForceEventsBackingCacheEntryStoreSource.java
Removed:
   projects/ejb3/branches/cluster-dev/core/
   projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/cache/NoPassivationCache.java
   projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/cache/NoPassivationCacheFactory.java
   projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/cache/tree/
   projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java
   projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/ProxiedStatefulBeanContext.java
   projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContextReference.java
   projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/BlockingPersistenceManager.java
   projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/BlockingPersistenceManagerFactory.java
   projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/ForceEventsCache.java
Modified:
   projects/ejb3/branches/cluster-dev/core/.classpath
   projects/ejb3/branches/cluster-dev/core/pom.xml
   projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/cache/CacheFactoryRegistry.java
   projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/cache/StatefulCache.java
   projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/cache/StatefulReplicationInterceptor.java
   projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/cache/simple/SimpleStatefulCache.java
   projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContext.java
   projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java
   projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/StatefulSessionContextDelegate.java
   projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/StatefulSessionContextImpl.java
   projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java
   projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/common/MockEjb3Deployment.java
   projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/common/SimpleTransactionService.java
   projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/ForceEventsCacheFactory.java
   projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/MyStatefulBean.java
   projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/unit/PassivationDoesNotPreventNewActivityUnitTestCase.java
   projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/test/cachepassivation/unit/CachePassivationUnitTestCase.java
   projects/ejb3/branches/cluster-dev/core/src/test/resources/statefulcontainer-beans.xml
Log:
Port ejb3-core 1.0.0.GA to cluster-dev branch and adapt to work w/ new cache impl

Copied: projects/ejb3/branches/cluster-dev/core (from rev 83396, projects/ejb3/trunk/core)

Modified: projects/ejb3/branches/cluster-dev/core/.classpath
===================================================================
--- projects/ejb3/trunk/core/.classpath	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/.classpath	2009-02-17 22:38:36 UTC (rev 84332)
@@ -5,5 +5,137 @@
   <classpathentry kind="src" path="src/test/resources" output="eclipse-target/tests-classes" excluding="**/*.java"/>
   <classpathentry kind="output" path="eclipse-target/classes"/>
   <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-  <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+  <classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.0.2/activation-1.0.2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant/1.7.0/ant-1.7.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-junit/1.7.0/ant-junit-1.7.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-launcher/1.7.0/ant-launcher-1.7.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.6/antlr-2.7.6.jar" sourcepath="M2_REPO/antlr/antlr/2.7.6/antlr-2.7.6-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/asm/asm/1.5.3/asm-1.5.3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/asm/asm-attrs/1.5.3/asm-attrs-1.5.3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/bcel/bcel/5.1/bcel-5.1.jar" sourcepath="M2_REPO/bcel/bcel/5.1/bcel-5.1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/bsh/bsh/1.3.0/bsh-1.3.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/cglib/cglib/2.1_3/cglib-2.1_3.jar" sourcepath="M2_REPO/cglib/cglib/2.1_3/cglib-2.1_3-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/2.1.1/commons-collections-2.1.1.jar" sourcepath="M2_REPO/commons-collections/commons-collections/2.1.1/commons-collections-2.1.1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar" sourcepath="M2_REPO/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/oswego-concurrent/concurrent/1.3.4-jboss-update1/concurrent-1.3.4-jboss-update1.jar" sourcepath="M2_REPO/oswego-concurrent/concurrent/1.3.4-jboss-update1/concurrent-1.3.4-jboss-update1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar" sourcepath="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/net/sf/ehcache/ehcache/1.2.3/ehcache-1.2.3.jar" sourcepath="M2_REPO/net/sf/ehcache/ehcache/1.2.3/ehcache-1.2.3-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/hibernate/ejb3-persistence/1.0.1.GA/ejb3-persistence-1.0.1.GA.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate/3.2.6.ga/hibernate-3.2.6.ga.jar" sourcepath="M2_REPO/org/hibernate/hibernate/3.2.6.ga/hibernate-3.2.6.ga-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-annotations/3.3.1.GA/hibernate-annotations-3.3.1.GA.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-commons-annotations/3.0.0.ga/hibernate-commons-annotations-3.0.0.ga.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-entitymanager/3.3.2.GA/hibernate-entitymanager-3.3.2.GA.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/security/jaas/1.0.01/jaas-1.0.01.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/security/jacc/1.0/jacc-1.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/urbanophile/java-getopt/1.0.9/java-getopt-1.0.9.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javassist/javassist/3.7.1.GA/javassist-3.7.1.GA.jar" sourcepath="M2_REPO/javassist/javassist/3.7.1.GA/javassist-3.7.1.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-api/2.1.4/jaxb-api-2.1.4.jar" sourcepath="M2_REPO/sun-jaxb/jaxb-api/2.1.4/jaxb-api-2.1.4-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/sun-jaxws/jaxws-api/2.1.1/jaxws-api-2.1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/aop/jboss-aop/2.0.0.GA/jboss-aop-2.0.0.GA.jar" sourcepath="M2_REPO/org/jboss/aop/jboss-aop/2.0.0.GA/jboss-aop-2.0.0.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/aop/jboss-aop-aspects/2.0.0.CR7/jboss-aop-aspects-2.0.0.CR7.jar" sourcepath="M2_REPO/org/jboss/aop/jboss-aop-aspects/2.0.0.CR7/jboss-aop-aspects-2.0.0.CR7-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/aop/jboss-aop-deployer-jdk50/2.0.0.CR10/jboss-aop-deployer-jdk50-2.0.0.CR10.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/aop/jboss-aop-jdk50/2.0.0.CR17/jboss-aop-jdk50-2.0.0.CR17.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-aop-mc-int/2.0.0.CR2/jboss-aop-mc-int-2.0.0.CR2.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-aop-mc-int/2.0.0.CR2/jboss-aop-mc-int-2.0.0.CR2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jbossas/jboss-as-bootstrap/5.0.0.CR2/jboss-as-bootstrap-5.0.0.CR2.jar" sourcepath="M2_REPO/org/jboss/jbossas/jboss-as-bootstrap/5.0.0.CR2/jboss-as-bootstrap-5.0.0.CR2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jbossas/jboss-as-deployment/5.0.0.CR2/jboss-as-deployment-5.0.0.CR2.jar" sourcepath="M2_REPO/org/jboss/jbossas/jboss-as-deployment/5.0.0.CR2/jboss-as-deployment-5.0.0.CR2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jbossas/jboss-as-j2se/5.0.0.CR2/jboss-as-j2se-5.0.0.CR2.jar" sourcepath="M2_REPO/org/jboss/jbossas/jboss-as-j2se/5.0.0.CR2/jboss-as-j2se-5.0.0.CR2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jbossas/jboss-as-j2se/5.0.0.CR2/jboss-as-j2se-5.0.0.CR2-tests.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jbossas/jboss-as-jmx/5.0.0.CR2/jboss-as-jmx-5.0.0.CR2.jar" sourcepath="M2_REPO/org/jboss/jbossas/jboss-as-jmx/5.0.0.CR2/jboss-as-jmx-5.0.0.CR2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jbossas/jboss-as-main/5.0.0.CR2/jboss-as-main-5.0.0.CR2.jar" sourcepath="M2_REPO/org/jboss/jbossas/jboss-as-main/5.0.0.CR2/jboss-as-main-5.0.0.CR2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jbossas/jboss-as-mbeans/5.0.0.CR2/jboss-as-mbeans-5.0.0.CR2.jar" sourcepath="M2_REPO/org/jboss/jbossas/jboss-as-mbeans/5.0.0.CR2/jboss-as-mbeans-5.0.0.CR2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jbossas/jboss-as-server/5.0.0.CR2/jboss-as-server-5.0.0.CR2.jar" sourcepath="M2_REPO/org/jboss/jbossas/jboss-as-server/5.0.0.CR2/jboss-as-server-5.0.0.CR2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jbossas/jboss-as-system/5.0.0.CR2/jboss-as-system-5.0.0.CR2.jar" sourcepath="M2_REPO/org/jboss/jbossas/jboss-as-system/5.0.0.CR2/jboss-as-system-5.0.0.CR2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jbossas/jboss-as-system-jmx/5.0.0.CR2/jboss-as-system-jmx-5.0.0.CR2.jar" sourcepath="M2_REPO/org/jboss/jbossas/jboss-as-system-jmx/5.0.0.CR2/jboss-as-system-jmx-5.0.0.CR2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/aspects/jboss-aspects-test/1.0.0.Beta1/jboss-aspects-test-1.0.0.Beta1.jar" sourcepath="M2_REPO/org/jboss/aspects/jboss-aspects-test/1.0.0.Beta1/jboss-aspects-test-1.0.0.Beta1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/cl/jboss-classloader/2.0.0.CR2/jboss-classloader-2.0.0.CR2.jar" sourcepath="M2_REPO/org/jboss/cl/jboss-classloader/2.0.0.CR2/jboss-classloader-2.0.0.CR2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/cl/jboss-classloading/2.0.0.CR5/jboss-classloading-2.0.0.CR5.jar" sourcepath="M2_REPO/org/jboss/cl/jboss-classloading/2.0.0.CR5/jboss-classloading-2.0.0.CR5-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-classloading-spi/5.0.0.CR2/jboss-classloading-spi-5.0.0.CR2.jar" sourcepath="M2_REPO/org/jboss/integration/jboss-classloading-spi/5.0.0.CR2/jboss-classloading-spi-5.0.0.CR2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/cl/jboss-classloading-vfs/2.0.0.CR5/jboss-classloading-vfs-2.0.0.CR5.jar" sourcepath="M2_REPO/org/jboss/cl/jboss-classloading-vfs/2.0.0.CR5/jboss-classloading-vfs-2.0.0.CR5-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.5.GA/jboss-common-core-2.2.5.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-common-core/2.2.5.GA/jboss-common-core-2.2.5.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/aspects/jboss-current-invocation-aspects/1.0.0.CR1/jboss-current-invocation-aspects-1.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/aspects/jboss-current-invocation-aspects/1.0.0.CR1/jboss-current-invocation-aspects-1.0.0.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-dependency/2.0.0.CR5/jboss-dependency-2.0.0.CR5.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-dependency/2.0.0.CR5/jboss-dependency-2.0.0.CR5-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-client/2.0.0.CR5/jboss-deployers-client-2.0.0.CR5.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-client/2.0.0.CR5/jboss-deployers-client-2.0.0.CR5-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-client-spi/2.0.0.CR1/jboss-deployers-client-spi-2.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-client-spi/2.0.0.CR1/jboss-deployers-client-spi-2.0.0.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-deployers-client-spi/2.0.0.Beta6/jboss-deployers-client-spi-2.0.0.Beta6.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-deployers-client-spi/2.0.0.Beta6/jboss-deployers-client-spi-2.0.0.Beta6-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-core/2.0.0.CR5/jboss-deployers-core-2.0.0.CR5.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-core/2.0.0.CR5/jboss-deployers-core-2.0.0.CR5-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-core-spi/2.0.0.CR5/jboss-deployers-core-spi-2.0.0.CR5.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-core-spi/2.0.0.CR5/jboss-deployers-core-spi-2.0.0.CR5-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-impl/2.0.0.CR1/jboss-deployers-impl-2.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-impl/2.0.0.CR1/jboss-deployers-impl-2.0.0.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-spi/2.0.0.CR5/jboss-deployers-spi-2.0.0.CR5.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-spi/2.0.0.CR5/jboss-deployers-spi-2.0.0.CR5-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-structure-spi/2.0.0.CR1/jboss-deployers-structure-spi-2.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-structure-spi/2.0.0.CR1/jboss-deployers-structure-spi-2.0.0.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-vfs/2.0.0.CR5/jboss-deployers-vfs-2.0.0.CR5.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-vfs/2.0.0.CR5/jboss-deployers-vfs-2.0.0.CR5-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-vfs-spi/2.0.0.CR5/jboss-deployers-vfs-spi-2.0.0.CR5.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-vfs-spi/2.0.0.CR5/jboss-deployers-vfs-spi-2.0.0.CR5-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-deployment-spi/5.0.0.CR2/jboss-deployment-spi-5.0.0.CR2.jar" sourcepath="M2_REPO/org/jboss/integration/jboss-deployment-spi/5.0.0.CR2/jboss-deployment-spi-5.0.0.CR2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-ejb-api/3.0.0.CR1/jboss-ejb-api-3.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-ejb-api/3.0.0.CR1/jboss-ejb-api-3.0.0.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-async/1.0.0/jboss-ejb3-async-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-async/1.0.0/jboss-ejb3-async-1.0.0-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-cache/1.0.1.CACHE-SNAPSHOT/jboss-ejb3-cache-1.0.1.CACHE-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-cache/1.0.1.CACHE-SNAPSHOT/jboss-ejb3-cache-1.0.1.CACHE-SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-cache/1.0.1.CACHE-SNAPSHOT/jboss-ejb3-cache-1.0.1.CACHE-SNAPSHOT-tests.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-cache-jbc2/1.0.1.CACHE-SNAPSHOT/jboss-ejb3-cache-jbc2-1.0.1.CACHE-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-cache-jbc2/1.0.1.CACHE-SNAPSHOT/jboss-ejb3-cache-jbc2-1.0.1.CACHE-SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-common/1.0.0/jboss-ejb3-common-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-common/1.0.0/jboss-ejb3-common-1.0.0-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-ext-api/1.0.0/jboss-ejb3-ext-api-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-ext-api/1.0.0/jboss-ejb3-ext-api-1.0.0-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-ext-api-impl/1.0.0/jboss-ejb3-ext-api-impl-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-ext-api-impl/1.0.0/jboss-ejb3-ext-api-impl-1.0.0-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-interceptors/1.0.0/jboss-ejb3-interceptors-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-interceptors/1.0.0/jboss-ejb3-interceptors-1.0.0-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-metadata/1.0.0/jboss-ejb3-metadata-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-metadata/1.0.0/jboss-ejb3-metadata-1.0.0-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-proxy/1.0.0/jboss-ejb3-proxy-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-proxy/1.0.0/jboss-ejb3-proxy-1.0.0-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-proxy-clustered/1.0.0/jboss-ejb3-proxy-clustered-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-proxy-clustered/1.0.0/jboss-ejb3-proxy-clustered-1.0.0-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-security/1.0.0/jboss-ejb3-security-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-security/1.0.0/jboss-ejb3-security-1.0.0-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-test/1.0.0/jboss-ejb3-test-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-test/1.0.0/jboss-ejb3-test-1.0.0-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-transactions/1.0.0/jboss-ejb3-transactions-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-transactions/1.0.0/jboss-ejb3-transactions-1.0.0-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/embedded/jboss-embedded/beta3/jboss-embedded-beta3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/cluster/jboss-ha-client/1.1.1.GA/jboss-ha-client-1.1.1.GA.jar" sourcepath="M2_REPO/org/jboss/cluster/jboss-ha-client/1.1.1.GA/jboss-ha-client-1.1.1.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/cluster/jboss-ha-server-api/1.1.0.GA/jboss-ha-server-api-1.1.0.GA.jar" sourcepath="M2_REPO/org/jboss/cluster/jboss-ha-server-api/1.1.0.GA/jboss-ha-server-api-1.1.0.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-jacc-api/1.1.0.CR1/jboss-jacc-api-1.1.0.CR1.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-jacc-api/1.1.0.CR1/jboss-jacc-api-1.1.0.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-jad-api/1.2.0.CR2/jboss-jad-api-1.2.0.CR2.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-jad-api/1.2.0.CR2/jboss-jad-api-1.2.0.CR2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-jaspi-api/1.0.0.CR1/jboss-jaspi-api-1.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-jaspi-api/1.0.0.CR1/jboss-jaspi-api-1.0.0.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jboss/jbossws/jboss-jaxrpc/1.0.4.GA/jboss-jaxrpc-1.0.4.GA.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-jca-api/1.5.0.CR1/jboss-jca-api-1.5.0.CR1.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-jca-api/1.5.0.CR1/jboss-jca-api-1.5.0.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-jca-spi/5.0.3.GA/jboss-jca-spi-5.0.3.GA.jar" sourcepath="M2_REPO/org/jboss/integration/jboss-jca-spi/5.0.3.GA/jboss-jca-spi-5.0.3.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-jms-api/1.1.0.CR1/jboss-jms-api-1.1.0.CR1.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-jms-api/1.1.0.CR1/jboss-jms-api-1.1.0.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jpa/jboss-jpa-deployers/1.0.0-Beta5/jboss-jpa-deployers-1.0.0-Beta5.jar" sourcepath="M2_REPO/org/jboss/jpa/jboss-jpa-deployers/1.0.0-Beta5/jboss-jpa-deployers-1.0.0-Beta5-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-kernel/2.0.0.CR5/jboss-kernel-2.0.0.CR5.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-kernel/2.0.0.CR5/jboss-kernel-2.0.0.CR5-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-log4j/2.0.5.GA/jboss-logging-log4j-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-log4j/2.0.5.GA/jboss-logging-log4j-2.0.5.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-managed/2.0.0.CR1/jboss-managed-2.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/man/jboss-managed/2.0.0.CR1/jboss-managed-2.0.0.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-mdr/2.0.0.CR3/jboss-mdr-2.0.0.CR3.jar" sourcepath="M2_REPO/org/jboss/jboss-mdr/2.0.0.CR3/jboss-mdr-2.0.0.CR3-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/metadata/jboss-metadata/1.0.0.CR16/jboss-metadata-1.0.0.CR16.jar" sourcepath="M2_REPO/org/jboss/metadata/jboss-metadata/1.0.0.CR16/jboss-metadata-1.0.0.CR16-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-metatype/2.0.0.CR1/jboss-metatype-2.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/man/jboss-metatype/2.0.0.CR1/jboss-metatype-2.0.0.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jboss/profiler/jvmti/jboss-profiler-jvmti/1.0.0.CR5/jboss-profiler-jvmti-1.0.0.CR5.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-reflect/2.0.0.CR1/jboss-reflect-2.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/jboss-reflect/2.0.0.CR1/jboss-reflect-2.0.0.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/remoting/jboss-remoting/2.4.0.CR2/jboss-remoting-2.4.0.CR2.jar" sourcepath="M2_REPO/org/jboss/remoting/jboss-remoting/2.4.0.CR2/jboss-remoting-2.4.0.CR2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/aspects/jboss-remoting-aspects/1.0.1.CR4/jboss-remoting-aspects-1.0.1.CR4.jar" sourcepath="M2_REPO/org/jboss/aspects/jboss-remoting-aspects/1.0.1.CR4/jboss-remoting-aspects-1.0.1.CR4-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/aspects/jboss-security-aspects/1.0.0.Beta1/jboss-security-aspects-1.0.0.Beta1.jar" sourcepath="M2_REPO/org/jboss/aspects/jboss-security-aspects/1.0.0.Beta1/jboss-security-aspects-1.0.0.Beta1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/security/jboss-security-spi/2.0.2.SP2/jboss-security-spi-2.0.2.SP2.jar" sourcepath="M2_REPO/org/jboss/security/jboss-security-spi/2.0.2.SP2/jboss-security-spi-2.0.2.SP2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jboss/jboss-serialization/1.0.3.GA/jboss-serialization-1.0.3.GA.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jbossas/jboss-server-manager/0.1.0.GA/jboss-server-manager-0.1.0.GA.jar" sourcepath="M2_REPO/org/jboss/jbossas/jboss-server-manager/0.1.0.GA/jboss-server-manager-0.1.0.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-servlet-api/2.5.0.CR1/jboss-servlet-api-2.5.0.CR1.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-servlet-api/2.5.0.CR1/jboss-servlet-api-2.5.0.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/test/jboss-test/1.1.0.GA/jboss-test-1.1.0.GA.jar" sourcepath="M2_REPO/org/jboss/test/jboss-test/1.1.0.GA/jboss-test-1.1.0.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-transaction-api/1.0.1.CR1/jboss-transaction-api-1.0.1.CR1.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-transaction-api/1.0.1.CR1/jboss-transaction-api-1.0.1.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/aspects/jboss-transaction-aspects/1.0.0.Beta1/jboss-transaction-aspects-1.0.0.Beta1.jar" sourcepath="M2_REPO/org/jboss/aspects/jboss-transaction-aspects/1.0.0.Beta1/jboss-transaction-aspects-1.0.0.Beta1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-transaction-spi/5.0.3.GA/jboss-transaction-spi-5.0.3.GA.jar" sourcepath="M2_REPO/org/jboss/integration/jboss-transaction-spi/5.0.3.GA/jboss-transaction-spi-5.0.3.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-vfs/2.0.0.CR1/jboss-vfs-2.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/jboss-vfs/2.0.0.CR1/jboss-vfs-2.0.0.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/cache/jbosscache-core/3.0.2.GA/jbosscache-core-3.0.2.GA.jar" sourcepath="M2_REPO/org/jboss/cache/jbosscache-core/3.0.2.GA/jbosscache-core-3.0.2.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jboss/jbossts/jbossjta/4.3.0.GA/jbossjta-4.3.0.GA.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/security/jbosssx/2.0.2.SP2/jbosssx-2.0.2.SP2.jar" sourcepath="M2_REPO/org/jboss/security/jbosssx/2.0.2.SP2/jbosssx-2.0.2.SP2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jboss/jbossts/jbossts-common/4.3.0.GA/jbossts-common-4.3.0.GA.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ws/native/jbossws-native-saaj/3.0.3.GA/jbossws-native-saaj-3.0.3.GA.jar" sourcepath="M2_REPO/org/jboss/ws/native/jbossws-native-saaj/3.0.3.GA/jbossws-native-saaj-3.0.3.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ws/jbossws-spi/1.0.3.GA/jbossws-spi-1.0.3.GA.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jbossxb/2.0.0.GA/jbossxb-2.0.0.GA.jar" sourcepath="M2_REPO/org/jboss/jbossxb/2.0.0.GA/jbossxb-2.0.0.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jgroups/jgroups/2.6.7.GA/jgroups-2.6.7.GA.jar" sourcepath="M2_REPO/jgroups/jgroups/2.6.7.GA/jgroups-2.6.7.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/naming/jnp-client/5.0.0.CR2/jnp-client-5.0.0.CR2.jar" sourcepath="M2_REPO/org/jboss/naming/jnp-client/5.0.0.CR2/jnp-client-5.0.0.CR2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/naming/jnpserver/5.0.0.CR1/jnpserver-5.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/naming/jnpserver/5.0.0.CR1/jnpserver-5.0.0.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jpl-pattern/jpl-pattern/1.0/jpl-pattern-1.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jpl-util/jpl-util/1.0/jpl-util-1.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/sun-jaxws/jsr181-api/2.1.1/jsr181-api-2.1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/transaction/jta/1.0.1B/jta-1.0.1B.jar"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/4.4/junit-4.4.jar" sourcepath="M2_REPO/junit/junit/4.4/junit-4.4-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/mail/mail/1.4/mail-1.4.jar" sourcepath="M2_REPO/javax/mail/mail/1.4/mail-1.4-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/qdox/qdox/1.6.1/qdox-1.6.1.jar" sourcepath="M2_REPO/qdox/qdox/1.6.1/qdox-1.6.1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/quartz/quartz/1.6.0/quartz-1.6.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/xml/soap/saaj-api/1.3/saaj-api-1.3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/stax/stax-api/1.0/stax-api-1.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/trove/trove/1.0.2/trove-1.0.2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/apache-xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.9.1/xml-apis-2.9.1.jar"/>
 </classpath>
\ No newline at end of file

Modified: projects/ejb3/branches/cluster-dev/core/pom.xml
===================================================================
--- projects/ejb3/trunk/core/pom.xml	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/pom.xml	2009-02-17 22:38:36 UTC (rev 84332)
@@ -17,7 +17,7 @@
   <!-- Artifact Information -->
   <artifactId>jboss-ejb3-core</artifactId>
   <packaging>jar</packaging>
-  <version>1.0.1-SNAPSHOT</version>
+  <version>1.0.1.CACHE-SNAPSHOT</version>
   <name>JBoss EJB 3.0 Core</name>
   <url>http://labs.jboss.com/jbossejb3</url>
   <description>JBoss EJB 3.0 Core</description>
@@ -263,7 +263,7 @@
       <groupId>org.jboss.cache</groupId>
       <artifactId>jbosscache-core</artifactId>
       <!-- not used anywhere else -->
-      <version>3.0.0.CR4</version>
+      <version>3.0.2.GA</version>
       <exclusions>
         <exclusion>
           <groupId>org.jboss.javaee</groupId>
@@ -298,7 +298,7 @@
     <dependency>
       <groupId>org.jboss.cluster</groupId>
       <artifactId>jboss-ha-client</artifactId>
-      <version>1.1.0.CR4</version>
+      <version>1.1.1.GA</version>
       <exclusions>
         <exclusion>
           <groupId>org.jboss.aspects</groupId>
@@ -318,7 +318,7 @@
     <dependency>
       <groupId>org.jboss.cluster</groupId>
       <artifactId>jboss-ha-server-api</artifactId>
-      <version>1.1.0.CR4</version>
+      <version>1.1.0.GA</version>
       <exclusions>
         <exclusion>
           <groupId>org.jboss</groupId>
@@ -352,8 +352,29 @@
     <dependency>
       <groupId>org.jboss.ejb3</groupId>
       <artifactId>jboss-ejb3-cache</artifactId>
-      <version>1.0.0</version>
+      <version>1.0.1.CACHE-SNAPSHOT</version>
     </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.ejb3</groupId>
+      <artifactId>jboss-ejb3-cache</artifactId>
+      <version>1.0.1.CACHE-SNAPSHOT</version>
+      <classifier>tests</classifier>
+      <scope>test</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.ejb3</groupId>
+      <artifactId>jboss-ejb3-cache-jbc2</artifactId>
+      <version>1.0.1.CACHE-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.ejb3</groupId>
+      <artifactId>jboss-ejb3-cache-jbc2</artifactId>
+      <version>1.0.1.CACHE-SNAPSHOT</version>
+    </dependency>
 
     <dependency>
       <groupId>org.jboss.ejb3</groupId>

Modified: projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/cache/CacheFactoryRegistry.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/CacheFactoryRegistry.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/cache/CacheFactoryRegistry.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -23,6 +23,8 @@
 
 import java.util.Map;
 
+import org.jboss.ejb3.stateful.StatefulBeanContext;
+
 /**
  * Registry for all configured Stateful Cache Factory implementations
  * 
@@ -32,19 +34,29 @@
 public class CacheFactoryRegistry
 {
    // Instance Members
-   private Map<String, Class<? extends Ejb3CacheFactory>> factories;
+   private Map<String, StatefulCacheFactory<StatefulBeanContext>> factories;
 
    // Accessors / Mutators
 
-   public Map<String, Class<? extends Ejb3CacheFactory>> getFactories()
+   public Map<String, StatefulCacheFactory<StatefulBeanContext>> getFactories()
    {
       return factories;
    }
 
-   public void setFactories(Map<String, Class<? extends Ejb3CacheFactory>> factories)
+   public void setFactories(Map<String, StatefulCacheFactory<StatefulBeanContext>> factories)
    {
       this.factories = factories;
    }
+   
+   public void addCacheFactory(String name, StatefulCacheFactory<StatefulBeanContext> factory)
+   {
+      this.factories.put(name, factory);
+   }
+   
+   public void removeCacheFactory(String name)
+   {
+      this.factories.remove(name);
+   }
 
    // Functional Methods
 
@@ -54,10 +66,10 @@
     * @param name The registered name of the cache factory to retrieve
     * @return The Cache Factory
     */
-   public Ejb3CacheFactory getCacheFactory(String name) throws CacheFactoryNotRegisteredException
+   public StatefulCacheFactory<StatefulBeanContext> getCacheFactory(String name) throws CacheFactoryNotRegisteredException
    {
       // Obtain cache factory
-      Class<? extends Ejb3CacheFactory> cacheFactory = this.factories.get(name);
+      StatefulCacheFactory<StatefulBeanContext> cacheFactory = this.factories.get(name);
 
       // Ensure registered
       if (cacheFactory == null)
@@ -65,18 +77,6 @@
          throw new CacheFactoryNotRegisteredException("Cache Factory with name " + name + " is not registered.");
       }
 
-      try
-      {
-         // Return 
-         return cacheFactory.newInstance();
-      }
-      catch (InstantiationException e)
-      {
-         throw new RuntimeException("Error in instanciating cache factory " + cacheFactory.getName(), e);
-      }
-      catch (IllegalAccessException e)
-      {
-         throw new RuntimeException(e);
-      }
+      return cacheFactory;
    }
 }

Deleted: projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/cache/NoPassivationCache.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/NoPassivationCache.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/cache/NoPassivationCache.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -1,203 +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;
-
-import java.util.HashMap;
-
-import javax.ejb.EJBException;
-import javax.ejb.NoSuchEJBException;
-
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.stateful.StatefulBeanContext;
-import org.jboss.ejb3.stateful.StatefulContainer;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class NoPassivationCache implements StatefulCache
-{   
-   private StatefulContainer container;
-   private HashMap<Object, StatefulBeanContext> cacheMap;
-   private int createCount = 0;
-   private int removeCount = 0;
-   private boolean running;
-   
-   public void initialize(EJBContainer container) throws Exception
-   {
-      this.container = (StatefulContainer) container;
-      cacheMap = new HashMap<Object, StatefulBeanContext>();
-   }
-
-   public NoPassivationCache()
-   {
-   }
-
-   public void start()
-   {
-      this.running = true;
-   }
-
-   public void stop()
-   {
-      synchronized (cacheMap)
-      {
-         cacheMap.clear();
-      }
-      this.running = false;
-   }
-
-   public StatefulBeanContext create()
-   {
-      return create(null, null);
-   }
-   
-   public StatefulBeanContext create(Class<?>[] initTypes, Object[] initValues)
-   {
-      StatefulBeanContext ctx = null;
-      try
-      {
-         ctx = container.create(initTypes, initValues);
-         ++createCount;
-         synchronized (cacheMap)
-         {
-            cacheMap.put(ctx.getId(), ctx);
-         }
-      }
-      catch (EJBException e)
-      {
-         throw e;
-      }
-      catch (Exception e)
-      {
-         throw new EJBException(e);
-      }
-      return ctx;
-   }
-
-   public StatefulBeanContext get(Object key) throws EJBException
-   {
-      return get(key, true);
-   }
-   
-   public StatefulBeanContext get(Object key, boolean markInUse) throws EJBException
-   {
-      StatefulBeanContext entry = null;
-      synchronized (cacheMap)
-      {
-         entry = (StatefulBeanContext) cacheMap.get(key);
-      }
-      
-      if (entry == null)
-      {
-         throw new NoSuchEJBException("Could not find Stateful bean: " + key);
-      }      
-      
-      if (markInUse)
-      {   
-         if (entry.isRemoved())
-         {
-            throw new NoSuchEJBException("Could not find stateful bean: " + key +
-                                         " (bean was marked as removed");
-         }      
-      
-         entry.setInUse(true);
-         entry.lastUsed = System.currentTimeMillis();
-      }
-      
-      return entry;
-   }
-
-   public StatefulBeanContext peek(Object key) throws NoSuchEJBException
-   {
-      return get(key, false);
-   }
-   
-   public void release(StatefulBeanContext ctx)
-   {
-      synchronized (ctx)
-      {
-         ctx.setInUse(false);
-         ctx.lastUsed = System.currentTimeMillis();
-      }
-   }
-
-   public void remove(Object key)
-   {
-      StatefulBeanContext ctx = null;
-      synchronized (cacheMap)
-      {
-         ctx = (StatefulBeanContext) cacheMap.remove(key);
-      }
-      if(ctx == null)
-         throw new NoSuchEJBException("Could not find Stateful bean: " + key);
-      container.destroy(ctx);
-      ++removeCount;
-   }
-
-   public int getCacheSize()
-   {
-	   return cacheMap.size();
-   }
-   
-   public int getTotalSize()
-   {
-      return cacheMap.size();
-   }
-   
-   public int getCreateCount()
-   {
-	   return createCount;
-   }
-   
-   public int getPassivatedCount()
-   {
-	   return 0;
-   }
-   
-   public int getRemoveCount()
-   {
-      return removeCount;
-   }
-   
-   public int getAvailableCount()
-   {
-      return -1;
-   }
-   
-   public int getMaxSize()
-   {
-      return -1;
-   }
-   
-   public int getCurrentSize()
-   {
-      return cacheMap.size();
-   }
-   
-   public boolean isStarted()
-   {
-      return this.running;
-   }
-}

Deleted: projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/cache/NoPassivationCacheFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/NoPassivationCacheFactory.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/cache/NoPassivationCacheFactory.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -1,37 +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;
-
-/**
- * Factory for obtaining NoPassivationCache instances
- * 
- * @author <a href="mailto:andrew.rubinger at redhat.com">ALR</a>
- * @version $Revision: $
- */
-public class NoPassivationCacheFactory implements Ejb3CacheFactory
-{
-   public StatefulCache createCache()
-   {
-      return new NoPassivationCache();
-   }
-
-}

Modified: projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/cache/StatefulCache.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/StatefulCache.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/cache/StatefulCache.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -35,7 +35,7 @@
  * @deprecated use Cache
  */
 @Deprecated
-public interface StatefulCache extends Cache<StatefulBeanContext>
+public interface StatefulCache
 {
    public StatefulBeanContext create(Class<?>[] initTypes, Object[] initValues);
 
@@ -93,4 +93,38 @@
    public void initialize(EJBContainer container) throws Exception;
    
    public boolean isStarted();
+   
+   
+   /**
+    * Peek at an object which might be in use.
+    * 
+    * @param key    the identifier of the object
+    * @return       the object
+    * @throws NoSuchEJBException    if the object does not exist
+    */
+   StatefulBeanContext peek(Object key) throws NoSuchEJBException;
+   
+   /**
+    * Release the object from use.
+    * 
+    * @param obj    the object
+    */
+   void release(StatefulBeanContext obj);
+   
+   /**
+    * Remove the specified object from cache.
+    * 
+    * @param key    the identifier of the object
+    */
+   void remove(Object key);
+   
+   /**
+    * Start the cache.
+    */
+   void start();
+   
+   /**
+    * Stop the cache.
+    */
+   void stop();
 }

Modified: projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/cache/StatefulReplicationInterceptor.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/StatefulReplicationInterceptor.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/cache/StatefulReplicationInterceptor.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -34,6 +34,8 @@
 /**
  * Replicate SFSB if it is modified.
  *
+ * FIXME remove this
+ *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @author Brian Stansberry
  * 
@@ -52,87 +54,87 @@
    public Object invoke(Invocation invocation) throws Throwable
    {
       // Find the ultimate parent context for the tree of SFSBs the target
-      // bean is part of.  This "tree" could just be the bean itself, or
-      // a multi-layer tree of nested SFSBs.
-      StatefulContainerInvocation ejbInv = (StatefulContainerInvocation) invocation;
-      StatefulBeanContext ctx = (StatefulBeanContext) ejbInv.getBeanContext();
-      StatefulBeanContext root = ctx.getUltimateContainedIn();
-      
-      // Find out if the ultimate parent is clustered
-      boolean clustered = false;
-      StatefulContainer container = (StatefulContainer) root.getContainer();
-      ClusteredStatefulCache clusteredCache = null;
-      if (container.getCache() instanceof ClusteredStatefulCache)
-      {
-         clustered = true;
-         clusteredCache = (ClusteredStatefulCache) container.getCache();
-      }
-      
-      // Track nested calls to this tree so we know when the outer call
-      // returns -- that's when we replicate
-      if (clustered)         
-         pushCallStack(root);
-      
-      boolean stackUnwound = false;
+//      // bean is part of.  This "tree" could just be the bean itself, or
+//      // a multi-layer tree of nested SFSBs.
+//      StatefulContainerInvocation ejbInv = (StatefulContainerInvocation) invocation;
+//      StatefulBeanContext ctx = (StatefulBeanContext) ejbInv.getBeanContext();
+//      StatefulBeanContext root = ctx.getUltimateContainedIn();
+//      
+//      // Find out if the ultimate parent is clustered
+//      boolean clustered = false;
+//      StatefulContainer container = (StatefulContainer) root.getContainer();
+//      ClusteredStatefulCache clusteredCache = null;
+//      if (container.getCache() instanceof ClusteredStatefulCache)
+//      {
+//         clustered = true;
+//         clusteredCache = (ClusteredStatefulCache) container.getCache();
+//      }
+//      
+//      // Track nested calls to this tree so we know when the outer call
+//      // returns -- that's when we replicate
+//      if (clustered)         
+//         pushCallStack(root);
+//      
+//      boolean stackUnwound = false;
       Object rtn = null;
-      try
-      {
+//      try
+//      {
          rtn = invocation.invokeNext();
-      }
-      finally
-      {
-         stackUnwound = (clustered && isCallStackUnwound(root));
-      }
-
-
-      // We only replicate if the ultimate parent is clustered
-      // TODO should we fail somehow during bean creation otherwise??
-      boolean mustReplicate = clustered;
+//      }
+//      finally
+//      {
+//         stackUnwound = (clustered && isCallStackUnwound(root));
+//      }
+//
+//
+//      // We only replicate if the ultimate parent is clustered
+//      // TODO should we fail somehow during bean creation otherwise??
+//      boolean mustReplicate = clustered;
+//      
+//      // If the bean implements Optimized, we call isModified() even
+//      // if we know we won't replicate, as the bean might be expecting 
+//      // us to call the method
+//      Object obj = invocation.getTargetObject();
+//      if (obj instanceof Optimized)
+//      {
+//         if (((Optimized) obj).isModified() == false)
+//         {
+//            mustReplicate = false;
+//         }
+//      }
+//      
+//      if (mustReplicate)
+//      {
+//         // Mark the bean for replication. If the call stack is not
+//         // unwound yet this will tell the outer caller the tree is 
+//         // dirty even if the outer bean's isModified() returns false
+//         root.markedForReplication = true;
+//      }
+//      
+//      if (stackUnwound && root.markedForReplication)
+//      {
+//         clusteredCache.replicate(root);
+//      }
+//      
+//      if (ctx != root && ctx.markedForReplication)
+//      {
+//         // ctx is a ProxiedStatefulBeanContext that may have failed over
+//         // and needs to invalidate any remote nodes that hold stale refs
+//         // to their delegate. So we replicate it.
+//         container = (StatefulContainer) ctx.getContainer();
+//         Cache<StatefulBeanContext> cache = container.getCache();
+//         if (cache instanceof ClusteredStatefulCache)
+//         {
+//            clusteredCache = (ClusteredStatefulCache) cache;
+//            clusteredCache.replicate(ctx);
+//         }
+//         else
+//         {
+//            // not replicable
+//            ctx.markedForReplication = false;
+//         }
+//      }
       
-      // If the bean implements Optimized, we call isModified() even
-      // if we know we won't replicate, as the bean might be expecting 
-      // us to call the method
-      Object obj = invocation.getTargetObject();
-      if (obj instanceof Optimized)
-      {
-         if (((Optimized) obj).isModified() == false)
-         {
-            mustReplicate = false;
-         }
-      }
-      
-      if (mustReplicate)
-      {
-         // Mark the bean for replication. If the call stack is not
-         // unwound yet this will tell the outer caller the tree is 
-         // dirty even if the outer bean's isModified() returns false
-         root.markedForReplication = true;
-      }
-      
-      if (stackUnwound && root.markedForReplication)
-      {
-         clusteredCache.replicate(root);
-      }
-      
-      if (ctx != root && ctx.markedForReplication)
-      {
-         // ctx is a ProxiedStatefulBeanContext that may have failed over
-         // and needs to invalidate any remote nodes that hold stale refs
-         // to their delegate. So we replicate it.
-         container = (StatefulContainer) ctx.getContainer();
-         StatefulCache cache = container.getCache();
-         if (cache instanceof ClusteredStatefulCache)
-         {
-            clusteredCache = (ClusteredStatefulCache) cache;
-            clusteredCache.replicate(ctx);
-         }
-         else
-         {
-            // not replicable
-            ctx.markedForReplication = false;
-         }
-      }
-      
       return rtn;
    }
    

Modified: projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/cache/simple/SimpleStatefulCache.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/simple/SimpleStatefulCache.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/cache/simple/SimpleStatefulCache.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -265,14 +265,14 @@
                         {                     
                            if (centry.getCanPassivate())
                            {
-                              if (!centry.getCanRemoveFromCache())
-                              {
-                                 passivationQueue.add(centry);
-                              }
-                              else if (trace)
-                              {
+//                              if (!centry.getCanRemoveFromCache())
+//                              {
+//                                 passivationQueue.add(centry);
+//                              }
+//                              else if (trace)
+//                              {
                                  log.trace("Removing " + entry.getKey() + " from cache");
-                              }
+//                              }
                            }
                            else
                            {
@@ -399,7 +399,7 @@
       StatefulBeanContext ctx = null;
       try
       {
-         ctx = container.create(initTypes, initValues);
+         ctx = container.create(initTypes, initValues, null);
          if (log.isTraceEnabled())
          {
             log.trace("Caching context " + ctx.getId() + " of type " + ctx.getClass());
@@ -547,13 +547,13 @@
       
       ++removeCount;
       
-      if (ctx.getCanRemoveFromCache())
-      {
-         synchronized (cacheMap)
-         {
+//      if (ctx.getCanRemoveFromCache())
+//      {
+//         synchronized (cacheMap)
+//         {
             cacheMap.remove(key);
-         }
-      }
+//         }
+//      }
    }
 
    public int getCacheSize()

Deleted: projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -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.stateful;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.HashMap;
-import java.util.List;
-
-import javax.persistence.EntityManager;
-
-import org.jboss.aop.metadata.SimpleMetaData;
-import org.jboss.ejb3.Ejb3Registry;
-
-/**
- * Overrides superclass to not use MarshalledValue in externalization,
- * as a nested context is meant to be serialized as part of its parent
- * context and to share with it object references to any XPC or managed 
- * entities.  Serializing with a MarshalledValue would result in separate
- * deserializations of the XPCs and managed entities. 
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class NestedStatefulBeanContext extends StatefulBeanContext implements Externalizable
-{   
-   /** The serialVersionUID */
-   private static final long serialVersionUID = 7835719320529968045L;
-   
-
-   public NestedStatefulBeanContext(StatefulContainer container, Object bean)
-   {
-      super(container, bean);
-   }
-   
-   /**
-    * Only for externalization.
-    */
-   public NestedStatefulBeanContext()
-   {      
-   }
-   
-   public void writeExternal(ObjectOutput out) throws IOException
-   {
-      out.writeUTF(containerClusterUid);
-      out.writeUTF(containerGuid);
-      out.writeObject(id);
-      out.writeBoolean(isClustered);
-      out.writeObject(metadata);
-      out.writeObject(bean);
-      out.writeObject(persistenceContexts);
-      out.writeObject(interceptorInstances);
-      out.writeObject(contains);
-      // Cannot write a ref to our parent as that seems to blow up serialization
-      //out.writeObject(containedIn);
-      out.writeBoolean(removed);
-      out.writeBoolean(replicationIsPassivation);
-   }
-
-   public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
-   {
-      containerClusterUid = in.readUTF();
-      containerGuid = in.readUTF();
-      id = in.readObject();
-      isClustered = in.readBoolean();
-      metadata = (SimpleMetaData) in.readObject();
-      bean = in.readObject();
-      persistenceContexts = (HashMap<String, EntityManager>)  in.readObject();
-      interceptorInstances = (HashMap<Class<?>, Object>)in.readObject();
-      contains = (List<StatefulBeanContext>) in.readObject();
-      removed = in.readBoolean();
-      replicationIsPassivation = in.readBoolean();
-      
-      // Since we can't write a ref to our parent, our children also
-      // don't have a ref to use.  So reestablish it.
-      if (contains != null)
-      {
-         for (StatefulBeanContext contained : contains)
-         {
-            contained.containedIn = this;
-         }
-      }
-      
-      // If we've just been deserialized, we are passivated
-      passivated = true;
-      
-      container = (StatefulContainer)Ejb3Registry.findContainer(containerGuid);      
-      if (isClustered && container == null)
-         container = (StatefulContainer)Ejb3Registry.getClusterContainer(containerClusterUid);
-   }
-
-}

Deleted: projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/ProxiedStatefulBeanContext.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/ProxiedStatefulBeanContext.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/ProxiedStatefulBeanContext.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -1,487 +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.stateful;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.locks.ReentrantLock;
-
-import javax.ejb.EJBContext;
-import javax.ejb.NoSuchEJBException;
-import javax.persistence.EntityManager;
-
-import org.jboss.aop.metadata.SimpleMetaData;
-import org.jboss.ejb3.interceptor.InterceptorInfo;
-
-/**
- * Proxy to a NestedStatefulBeanContext that can be independently passivated,
- * activated and replicated without disturbing the object it is proxying.
- * 
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author Brian Stansberry
- * 
- * @version $Revision$
- */
-public class ProxiedStatefulBeanContext extends StatefulBeanContext implements Externalizable
-{
-   /** The serialVersionUID */
-   private static final long serialVersionUID = -5156610459343035743L;
-
-   private transient StatefulBeanContext delegate;
-
-   private Object oid;
-
-   private String containerId;
-   
-   private StatefulBeanContextReference parentRef;
-
-   public ProxiedStatefulBeanContext(StatefulBeanContext delegate)
-   {      
-      this.delegate = delegate;
-      oid = delegate.getId();
-      
-      assert oid != null : "delegate.getId() is null";
-      
-      containerId = delegate.getContainer().getObjectName().getCanonicalName();
-      parentRef = new StatefulBeanContextReference(delegate.getContainedIn());
-   }
-   
-   /**
-    * Only for externalization.
-    */
-   public ProxiedStatefulBeanContext()
-   {      
-   }
-
-   protected StatefulBeanContext getDelegate()
-   {
-      if (delegate == null)
-      {
-         for (StatefulBeanContext ctx : parentRef.getBeanContext().getContains())
-         {
-            Object matchingOid = ctx.getId();
-            if (oid.equals(matchingOid)
-                  && ctx.getContainer().getObjectName().getCanonicalName()
-                        .equals(containerId))
-            {
-               delegate = ctx;
-               break;
-            }
-         }
-         if (delegate == null)
-            throw new RuntimeException("Failed to read delegate");
-         
-         // If we just read our delegate, it's possible there's been a 
-         // failover and a remote node still has a ref to a stale delegate.
-         // So, we should be replicated to invalidate the remote node.
-         this.markedForReplication = true;
-      }
-      return delegate;
-   }
-
-   public void writeExternal(ObjectOutput out) throws IOException
-   {
-      out.writeObject(oid);
-      out.writeUTF(containerId);
-      out.writeObject(parentRef);
-   }
-
-   public void readExternal(ObjectInput in) throws IOException,
-         ClassNotFoundException
-   {
-      oid = in.readObject();
-      containerId = in.readUTF();
-      parentRef = (StatefulBeanContextReference) in.readObject();
-      
-      assert parentRef != null : "parentRef is null";
-   }
-
-   @Override
-   public List<StatefulBeanContext> getContains()
-   {
-      return getDelegate().getContains();
-   }
-
-   @Override
-   public EntityManager getExtendedPersistenceContext(String id)
-   {
-      return getDelegate().getExtendedPersistenceContext(id);
-   }
-
-   @Override
-   public void addExtendedPersistenceContext(String id, EntityManager pc)
-   {
-      getDelegate().addExtendedPersistenceContext(id, pc);
-   }
-
-   @Override
-   public Map<String, EntityManager> getExtendedPersistenceContexts()
-   {
-      return getDelegate().getExtendedPersistenceContexts();
-   }
-
-   @Override
-   public void removeExtendedPersistenceContext(String id)
-   {
-      getDelegate().removeExtendedPersistenceContext(id);
-   }
-
-   @Override
-   public boolean scanForExtendedPersistenceContext(String id, StatefulBeanContext ignore)
-   {
-      return getDelegate().scanForExtendedPersistenceContext(id, ignore);
-   }
-
-   @Override
-   public StatefulBeanContext getContainedIn()
-   {
-      return getDelegate().getContainedIn();
-   }
-
-   @Override
-   public void addContains(StatefulBeanContext ctx)
-   {
-      getDelegate().addContains(ctx);
-   }
-
-   @Override
-   public void removeContains(StatefulBeanContext ctx)
-   {
-      getDelegate().removeContains(ctx);
-   }
-
-   @Override
-   public StatefulBeanContext pushContainedIn()
-   {
-      return getDelegate().pushContainedIn();
-   }
-
-   @Override
-   public void popContainedIn()
-   {
-      getDelegate().popContainedIn();
-   }
-
-   @Override
-   public StatefulBeanContext getUltimateContainedIn()
-   {
-      return getDelegate().getUltimateContainedIn();
-   }
-
-   @Override
-   public boolean isInUse()
-   {
-      // Don't call delegate
-      return super.isInUse();
-   }
-
-   @Override
-   public void setInUse(boolean inUse)
-   {
-      super.setInUse(inUse);
-      // delegate needs to know this for getCanPassivate()
-      getDelegate().setInUse(inUse);
-      
-      if (!inUse)
-      {
-         // drop ref to delegate, as the delegate can be passivated/activated
-         // without our knowledge, and if that happens we have a ref to a
-         // stale delegate.
-         delegate = null;
-      }
-   }
-
-   @Override
-   public boolean isDiscarded()
-   {
-      return getDelegate().isDiscarded();
-   }
-
-   @Override
-   public void setDiscarded(boolean discarded)
-   {
-      getDelegate().setDiscarded(discarded);
-   }
-
-   @Override
-   public boolean isRemoved()
-   {
-      return getDelegate().isRemoved();
-   }
-
-   @Override
-   public ReentrantLock getLock()
-   {
-      return getDelegate().getLock();
-   }
-
-   @Override
-   public boolean isInInvocation()
-   {
-      return getDelegate().isInInvocation();
-   }
-
-   @Override
-   public void setInInvocation(boolean inInvocation)
-   {
-      getDelegate().setInInvocation(inInvocation);
-   }
-
-   @Override
-   public Object getId()
-   {
-      return getDelegate().getId();
-   }
-
-//   @Override
-//   public void setId(Object id)
-//   {
-//      this.oid = id;
-//      getDelegate().setId(id);
-//   }
-
-   @Override
-   public boolean isTxSynchronized()
-   {
-      return getDelegate().isTxSynchronized();
-   }
-
-   @Override
-   public void setTxSynchronized(boolean txSynchronized)
-   {
-      getDelegate().setTxSynchronized(txSynchronized);
-   }
-
-   @Override
-   public void remove()
-   {
-      StatefulBeanContext del = null;
-      try
-      {
-         del = getDelegate();
-      }
-      catch (NoSuchEJBException gone)
-      {
-         // Assume this is due to EJBTHREE-1367/8 where an invalid 
-         // proxy is left sitting around in InfinitePool
-         return;
-      }
-      
-      del.remove();
-   }
-
-//   @Override
-//   public void setContainer(Container container)
-//   {
-//      getDelegate().setContainer(container);
-//   }
-//
-   @Override
-   public StatefulContainer getContainer()
-   {
-      return getDelegate().getContainer();
-   }
-
-   @Override
-   public Object getInstance()
-   {
-      return getDelegate().getInstance();
-   }
-
-   @Override
-   public SimpleMetaData getMetaData()
-   {
-      return getDelegate().getMetaData();
-   }
-
-   @Override
-   public Object[] getInterceptorInstances(InterceptorInfo[] interceptorInfos)
-   {
-      return getDelegate().getInterceptorInstances(interceptorInfos);
-   }
-
-   @Override
-   public void extractBeanAndInterceptors()
-   {
-      getDelegate().extractBeanAndInterceptors();
-   }
-
-   /*
-   @Override
-   public void initialiseInterceptorInstances()
-   {
-      getDelegate().initialiseInterceptorInstances();
-   }
-   */
-
-   @Override
-   public EJBContext getEJBContext()
-   {
-      return getDelegate().getEJBContext();
-   }
-
-   /**
-    *  Ignores the call, as passivation of this proxy context
-    *  does not affect the underlying bean (which is passivated
-    *  along with its parent context).
-    */
-   @Override
-   public void prePassivate()
-   {
-   }
-
-   /**
-    *  Ignores the call, as activation of this proxy context
-    *  does not affect the underlying bean (which is activated
-    *  along with its parent context).
-    */
-   @Override
-   public void postActivate()
-   {
-   }
-
-   /**
-    *  Ignores the call, as passivation of this proxy context
-    *  does not affect the underlying bean (which is passivated
-    *  along with its parent context).
-    */
-   @Override
-   public void passivateAfterReplication()
-   {
-      // ignore
-   }
-
-   /**
-    *  Ignores the call, as activation of this proxy context
-    *  does not affect the underlying bean (which is activated
-    *  along with its parent context).
-    */
-   @Override
-   public void activateAfterReplication()
-   {
-      // ignore
-   }
-
-   @Override
-   public boolean getCanPassivate()
-   {
-      if (delegate == null)
-      {
-         // If we haven't deserialized our delegate, we're not in use
-         // on this node
-         return true;
-      }
-      // Just check if *we* are in use; whether any children are
-      // in use doesn't matter, since passivating this proxy
-      // doesn't affect children
-      return (isInUse() == false);
-   }
-
-   @Override
-   public boolean getCanRemoveFromCache()
-   {
-      return getDelegate().getCanRemoveFromCache();
-      // Always return true if  we've had remove called -- a proxy 
-      // that's had remove called is useless
-//      return isRemoved();
-   }
-
-   @Override
-   public boolean getReplicationIsPassivation()
-   {
-      return getDelegate().getReplicationIsPassivation();
-   }
-
-   @Override
-   public void setReplicationIsPassivation(boolean replicationIsPassivation)
-   {
-      getDelegate().setReplicationIsPassivation(replicationIsPassivation);
-   }
-
-   /**
-    * Ignores the call, as replication of this proxy context
-    * does not affect the underlying bean (which is replicated
-    * along with its parent context).
-    */
-   @Override
-   public void preReplicate()
-   {
-      // ignore
-   }
-
-   /**
-    * Ignores the call, as replication of this proxy context
-    * does not affect the underlying bean (which is replicated
-    * along with its parent context).
-    */
-   @Override
-   public void postReplicate()
-   {
-      // ignore
-   }
-
-   @Override
-   public Object getInvokedMethodKey()
-   {
-      return getDelegate().getInvokedMethodKey();
-   }
-
-   @Override
-   public Object getInterceptor(Class<?> interceptorClass) throws IllegalArgumentException
-   {
-      return getDelegate().getInterceptor(interceptorClass);
-   }
-
-   @Override
-   public void initialiseInterceptorInstances()
-   {
-      getDelegate().initialiseInterceptorInstances();
-   }
-
-   @Override
-   public boolean equals(Object obj)
-   {
-      if (this == obj)
-         return true;
-      
-      if (obj instanceof ProxiedStatefulBeanContext)
-      {
-         ProxiedStatefulBeanContext other = (ProxiedStatefulBeanContext) obj;
-         return (containerId.equals(other.containerId) && oid.equals(other.oid));
-      }
-      return false;
-   }
-
-   @Override
-   public int hashCode()
-   {
-      int result = 11;
-      result = 29 * result + containerId.hashCode();
-      result = 29 * result + oid.hashCode();
-      return result;
-   }
-
-}

Added: projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/SharedXPC.java
===================================================================
--- projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/SharedXPC.java	                        (rev 0)
+++ projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/SharedXPC.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.stateful;
+
+import java.io.Serializable;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.persistence.EntityManager;
+
+/**
+ * Wrapper for an EntityManager that keeps a reference count.
+ * 
+ * @author Brian Stansberry
+ */
+class SharedXPC implements Serializable
+{  
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 4637529179827895356L;
+   
+   private final EntityManager xpc;
+   private final AtomicInteger count = new AtomicInteger();
+   
+   /**
+    * Create a new SharedXPCImpl.
+    * 
+    */
+   public SharedXPC(EntityManager xpc)
+   {
+      assert xpc != null : "xpc is null";
+      this.xpc = xpc;
+   }
+
+   public int addSharedUser()
+   {
+      return count.incrementAndGet();
+   }
+
+   public int removeSharedUser()
+   {
+      return count.decrementAndGet();
+   }
+   
+   public EntityManager getXPC()
+   {
+      return xpc;
+   }
+}


Property changes on: projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/SharedXPC.java
___________________________________________________________________
Name: svn:keywords
   + 

Modified: projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContext.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContext.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContext.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -27,9 +27,9 @@
 import java.io.ObjectOutput;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.locks.ReentrantLock;
 
 import javax.ejb.EJBContext;
@@ -40,9 +40,8 @@
 import org.jboss.aop.metadata.SimpleMetaData;
 import org.jboss.ejb3.Ejb3Registry;
 import org.jboss.ejb3.ThreadLocalStack;
-import org.jboss.ejb3.cache.Identifiable;
+import org.jboss.ejb3.cache.CacheItem;
 import org.jboss.ejb3.cache.Optimized;
-import org.jboss.ejb3.cache.StatefulCache;
 import org.jboss.ejb3.interceptor.InterceptorInfo;
 import org.jboss.ejb3.session.SessionSpecBeanContext;
 import org.jboss.ejb3.tx.TxUtil;
@@ -62,7 +61,7 @@
  */
 public class StatefulBeanContext 
    extends SessionSpecBeanContext<StatefulContainer> 
-   implements Identifiable, Externalizable, org.jboss.ejb3.tx.container.StatefulBeanContext<Object>
+   implements CacheItem, Externalizable, org.jboss.ejb3.tx.container.StatefulBeanContext<Object>
 {
    /** The serialVersionUID */
    private static final long serialVersionUID = -102470788178912606L;
@@ -81,15 +80,16 @@
 
    // these two are needed for propagated extended persistence contexts when one
    // SFSB injects another.
-   public static ThreadLocalStack<StatefulBeanContext> propagatedContainedIn = new ThreadLocalStack<StatefulBeanContext>();
+//   public static ThreadLocalStack<StatefulBeanContext> propagatedContainedIn = new ThreadLocalStack<StatefulBeanContext>();
 
    public static ThreadLocalStack<StatefulBeanContext> currentBean = new ThreadLocalStack<StatefulBeanContext>();
 
-   protected StatefulBeanContext containedIn;
+//   protected StatefulBeanContext containedIn;
 
-   protected List<StatefulBeanContext> contains;
+//   protected List<StatefulBeanContext> contains;
 
-   protected HashMap<String, EntityManager> persistenceContexts;
+//   protected HashMap<String, EntityManager> persistenceContexts;
+   protected Set<String> persistenceContextNames;
 
    protected boolean removed;
 
@@ -100,6 +100,8 @@
    protected boolean replicationIsPassivation = true;
    
    protected transient boolean passivated = false;
+   
+   protected Map<Object, Object> sharedState;
 
    /**
     * An incoming context from serialization.
@@ -144,13 +146,26 @@
    {
       
    }
-
-   public List<StatefulBeanContext> getContains()
+   
+   /**
+    * FIXME this should be an invariant set in the constructor.
+    * 
+    * @param sharedState
+    */
+   protected void setSharedState(Map<Object, Object> sharedState)
    {
-      if (bean == null)
-         extractBeanAndInterceptors();
-      return contains;
+      assert this.sharedState == null : "Cannot re-set shared state";
+      assert sharedState != null : "sharedState is null";
+      
+      this.sharedState = sharedState;
    }
+
+//   public List<StatefulBeanContext> getContains()
+//   {
+//      if (bean == null)
+//         extractBeanAndInterceptors();
+//      return contains;
+//   }
    
    /**
     * Makes a copy of the contains list so nested callback iterators
@@ -159,20 +174,20 @@
     * 
     * TODO replace contains list with a concurrent collection
     */
-   private List<StatefulBeanContext> getThreadSafeContains()
-   {
-      // Call getContains() to ensure unmarshalling
-      List<StatefulBeanContext> orig = getContains();
-      List<StatefulBeanContext> copy = null;
-      if (orig != null)
-      {
-         synchronized (orig)
-         {
-            copy = new ArrayList<StatefulBeanContext>(orig);
-         }
-      }
-      return copy;
-   }
+//   private List<StatefulBeanContext> getThreadSafeContains()
+//   {
+//      // Call getContains() to ensure unmarshalling
+//      List<StatefulBeanContext> orig = getContains();
+//      List<StatefulBeanContext> copy = null;
+//      if (orig != null)
+//      {
+//         synchronized (orig)
+//         {
+//            copy = new ArrayList<StatefulBeanContext>(orig);
+//         }
+//      }
+//      return copy;
+//   }
 
    @Override
    public EJBContext getEJBContext()
@@ -182,63 +197,94 @@
       return ejbContext;
    }
    
+//   public EntityManager getExtendedPersistenceContext(String id)
+//   {
+//      EntityManager found = null;
+//      Map<String, EntityManager> extendedPCS = getExtendedPersistenceContexts();
+//      if (extendedPCS != null)
+//      {
+//         found = extendedPCS.get(id);
+//      }
+//      if (found != null)
+//         return found;
+//      if (containedIn != null)
+//      {
+//         found = containedIn.getExtendedPersistenceContext(id);
+//      }
+//      return found;
+//   }
+//
+//   public void addExtendedPersistenceContext(String id, EntityManager pc)
+//   {
+//      Map<String, EntityManager> extendedPCS = getExtendedPersistenceContexts();
+//      if (extendedPCS == null)
+//      {
+//         extendedPCS = persistenceContexts = new HashMap<String, EntityManager>();
+//      }
+//      extendedPCS.put(id, pc);
+//   }
+   
    public EntityManager getExtendedPersistenceContext(String id)
-   {
-      EntityManager found = null;
-      Map<String, EntityManager> extendedPCS = getExtendedPersistenceContexts();
-      if (extendedPCS != null)
-      {
-         found = extendedPCS.get(id);
-      }
-      if (found != null)
-         return found;
-      if (containedIn != null)
-      {
-         found = containedIn.getExtendedPersistenceContext(id);
-      }
-      return found;
+   {      
+      SharedXPC shared = (SharedXPC) sharedState.get(id);
+      return (shared == null ? null : shared.getXPC());
    }
 
    public void addExtendedPersistenceContext(String id, EntityManager pc)
    {
-      Map<String, EntityManager> extendedPCS = getExtendedPersistenceContexts();
-      if (extendedPCS == null)
+      Set<String> ourPCs = getPersistenceContextNames();
+      if (ourPCs == null)
       {
-         extendedPCS = persistenceContexts = new HashMap<String, EntityManager>();
+         ourPCs = persistenceContextNames = new HashSet<String>();
       }
-      extendedPCS.put(id, pc);
-   }
-   
-   public boolean scanForExtendedPersistenceContext(String id, StatefulBeanContext ignore)
-   {
-      if (this.equals(ignore))
-         return false;
       
-      if (!removed)
-      {
-         Map<String, EntityManager> extendedPCS = getExtendedPersistenceContexts();
-         if (extendedPCS != null && extendedPCS.containsKey(id))
-            return true;
-      }
+      // getPersistenceContextNames() will result in deserializing sharedState
+      // so now it's safe to assert it isn't null
       
-      if (getContains() != null)
+      assert sharedState != null : "sharedState is null; must be provided by container";
+      
+      SharedXPC shared = (SharedXPC) sharedState.get(id);
+      if (shared == null)
       {
-         synchronized (contains)
-         {
-            for (StatefulBeanContext contained : contains)
-            {
-               if (!contained.equals(ignore))
-               {
-                  if (contained.scanForExtendedPersistenceContext(id, ignore))
-                     return true;
-               }
-            }
-         }
+         shared = new SharedXPC(pc);
+         sharedState.put(id, shared);
       }
       
-      return false;
+      shared.addSharedUser();
+      
+      ourPCs.add(id);
    }
    
+//   public boolean scanForExtendedPersistenceContext(String id, StatefulBeanContext ignore)
+//   {
+//      if (this.equals(ignore))
+//         return false;
+//      
+//      if (!removed)
+//      {
+//         Map<String, EntityManager> extendedPCS = getExtendedPersistenceContexts();
+//         if (extendedPCS != null && extendedPCS.containsKey(id))
+//            return true;
+//      }
+//      
+//      if (getContains() != null)
+//      {
+//         synchronized (contains)
+//         {
+//            for (StatefulBeanContext contained : contains)
+//            {
+//               if (!contained.equals(ignore))
+////               {
+//                  if (contained.scanForExtendedPersistenceContext(id, ignore))
+//                     return true;
+//               }
+//            }
+//         }
+//      }
+//      
+//      return false;
+//   }
+   
    public void removeExtendedPersistenceContext(String id)
    {
       Map<String, EntityManager> extendedPCS = getExtendedPersistenceContexts();
@@ -247,141 +293,165 @@
          extendedPCS.remove(id);
       }
       
-      if (getContains() != null)
+      // getPersistenceContextNames() will result in deserializing sharedState
+      // so now it's safe to assert it isn't null
+      
+      assert sharedState != null : "sharedState is null; must be provided by container";
+      
+      
+      synchronized (sharedState)
       {
-         synchronized (contains)
+         SharedXPC xpc = (SharedXPC) sharedState.get(id);
+         if (xpc.removeSharedUser() == 0)
          {
-            for (StatefulBeanContext contained: contains)
-            {
-               contained.removeExtendedPersistenceContext(id);
-            }
+            sharedState.remove(id);
          }
       }
    }
 
    public Map<String, EntityManager> getExtendedPersistenceContexts()
    {
-      if (persistenceContexts == null)
+      if (persistenceContextNames == null)
       {
          if (bean == null)
             extractBeanAndInterceptors(); // unmarshall
       }
-      return persistenceContexts;
-   }
-
-   public StatefulBeanContext getContainedIn()
-   {
-      return containedIn;
-   }
-
-   public StatefulBeanContext getUltimateContainedIn()
-   {
-      StatefulBeanContext child = this;
-      StatefulBeanContext parent = containedIn;
       
-      while (parent != null)
+      Map<String, EntityManager> result = null; // TODO always return empty Map?
+      if (persistenceContextNames != null)
       {
-         child = parent;
-         parent = parent.getContainedIn();
+         result = new HashMap<String, EntityManager>();
+         for (String id : persistenceContextNames)
+         {
+            result.put(id, ((SharedXPC) sharedState.get(id)).getXPC());
+         }
       }
-      
-      if (parent == null && this != child)
-      {
-         // Don't hand out a ref to our parent obtained by walking the
-         // tree. Rather, get it from its cache.  This gives the cache
-         // a chance to activate it if it hasn't been.  We don't want
-         // to mark the parent as in use though.
-         StatefulCache ultimateCache = ((StatefulContainer)child.getContainer()).getCache();
-         child = ultimateCache.get(child.getId(), false);
-      }
-      
-      return child;
+      return result;
    }
-
-   public void addContains(StatefulBeanContext ctx)
-   {
-      if (getContains() == null)
-         contains = new ArrayList<StatefulBeanContext>();
-      
-      synchronized (contains)
-      {
-         contains.add(ctx);
-         ctx.containedIn = this;
-      }      
-   }
    
-   public void removeContains(StatefulBeanContext ctx)
+   protected Set<String> getPersistenceContextNames()
    {
-      if (getContains() != null) // call getContains() to ensure unmarshalling
+      if (persistenceContextNames == null)
       {
-         // Need to be thread safe
-         synchronized (contains)
-         {
-            if (contains.remove(ctx))
-            {             
-               ctx.containedIn = null;
-            }
-         }
-         
-         if (removed)
-         {
-            // Close out any XPCs that are no longer referenced
-            cleanExtendedPCs();
-         }
-         
-         if (getCanRemoveFromCache())
-         {  
-            if (containedIn != null)
-            {
-               containedIn.removeContains(this);               
-            }
-            
-            //  Notify our cache to remove us as we no longer have children            
-            ((StatefulContainer) getContainer()).getCache().remove(getId());
-         }
+         if (bean == null)
+            extractBeanAndInterceptors(); // unmarshall
       }
+      return persistenceContextNames;      
    }
 
-   public StatefulBeanContext pushContainedIn()
-   {
-      StatefulBeanContext thisPtr = this;
-      if (propagatedContainedIn.getList() != null)
-      {
-         // This is a nested stateful bean, within another stateful bean.
-         // We need to create a nested bean context. The nested one will 
-         // be put in the parent's list and owned by it. It is a special 
-         // class because we do not want to put its state in a separate
-         // marshalled object as we want to maintain object references 
-         // between it and its parent. 
-         
-         // We also do not want to put the nested context within its container's
-         // cache. If placed in the cache, it could be independently passivated,
-         // activated and replicated, again breaking object references due to
-         // independent marshalling. Instead, we return a proxy to it that will 
-         // be stored in its container's cache         
-         containedIn = propagatedContainedIn.get();
-         NestedStatefulBeanContext nested = new NestedStatefulBeanContext(getContainer(), bean);
-         nested.id = id;
-         nested.container = getContainer();
-         nested.containerClusterUid = containerClusterUid;
-         nested.containerGuid = containerGuid;
-         nested.isClustered = isClustered;
-         nested.replicationIsPassivation = replicationIsPassivation;
-         containedIn.addContains(nested);
-         thisPtr = new ProxiedStatefulBeanContext(nested);
-         
-         if (log.isTraceEnabled())
-         {
-            log.trace("Created ProxiedStatefulBeanContext for " + 
-                      containerGuid + "/" + id + " contained in " + 
-                      containedIn.getContainer().getIdentifier() + "/" + 
-                      containedIn.getId());
-         }
-      }
-      propagatedContainedIn.push(thisPtr);
-      return thisPtr;
-   }
+//   public StatefulBeanContext getContainedIn()
+//   {
+//      return containedIn;
+//   }
+
+//   public StatefulBeanContext getUltimateContainedIn()
+//   {
+//      StatefulBeanContext child = this;
+//      StatefulBeanContext parent = containedIn;
+//      
+//      while (parent != null)
+//      {
+//         child = parent;
+//         parent = parent.getContainedIn();
+//      }
+//      
+//      if (parent == null && this != child)
+//      {
+//         // Don't hand out a ref to our parent obtained by walking the
+//         // tree. Rather, get it from its cache.  This gives the cache
+//         // a chance to activate it if it hasn't been.  We don't want
+//         // to mark the parent as in use though.
+//         Cache<StatefulBeanContext> ultimateCache = ((StatefulContainer)child.getContainer()).getCache();
+//         child = ultimateCache.get(child.getId(), false);
+//      }
+//      
+//      return child;
+//   }
+
+//   public void addContains(StatefulBeanContext ctx)
+//   {
+//      if (getContains() == null)
+//         contains = new ArrayList<StatefulBeanContext>();
+//      
+//      synchronized (contains)
+//      {
+//         contains.add(ctx);
+//         ctx.containedIn = this;
+//      }      
+//   }
    
+//   public void removeContains(StatefulBeanContext ctx)
+//   {
+//      if (getContains() != null) // call getContains() to ensure unmarshalling
+//      {
+//         // Need to be thread safe
+//         synchronized (contains)
+//         {
+//            if (contains.remove(ctx))
+//            {             
+//               ctx.containedIn = null;
+//            }
+//         }
+//         
+//         if (removed)
+//         {
+//            // Close out any XPCs that are no longer referenced
+//            cleanExtendedPCs();
+//         }
+//         
+//         if (getCanRemoveFromCache())
+//         {  
+//            if (containedIn != null)
+//            {
+//               containedIn.removeContains(this);               
+//            }
+//            
+//            //  Notify our cache to remove us as we no longer have children            
+//            ((StatefulContainer) getContainer()).getCache().remove(getId());
+//         }
+//      }
+//   }
+
+//   public StatefulBeanContext pushContainedIn()
+//   {
+//      StatefulBeanContext thisPtr = this;
+//      if (propagatedContainedIn.getList() != null)
+//      {
+//         // This is a nested stateful bean, within another stateful bean.
+//         // We need to create a nested bean context. The nested one will 
+//         // be put in the parent's list and owned by it. It is a special 
+//         // class because we do not want to put its state in a separate
+//         // marshalled object as we want to maintain object references 
+//         // between it and its parent. 
+//         
+//         // We also do not want to put the nested context within its container's
+//         // cache. If placed in the cache, it could be independently passivated,
+//         // activated and replicated, again breaking object references due to
+//         // independent marshalling. Instead, we return a proxy to it that will 
+//         // be stored in its container's cache         
+//         containedIn = propagatedContainedIn.get();
+//         NestedStatefulBeanContext nested = new NestedStatefulBeanContext(getContainer(), bean);
+//         nested.id = id;
+//         nested.container = getContainer();
+//         nested.containerClusterUid = containerClusterUid;
+//         nested.containerGuid = containerGuid;
+//         nested.isClustered = isClustered;
+//         nested.replicationIsPassivation = replicationIsPassivation;
+//         containedIn.addContains(nested);
+//         thisPtr = new ProxiedStatefulBeanContext(nested);
+//         
+//         if (log.isTraceEnabled())
+//         {
+//            log.trace("Created ProxiedStatefulBeanContext for " + 
+//                      containerGuid + "/" + id + " contained in " + 
+//                      containedIn.getContainer().getIdentifier() + "/" + 
+//                      containedIn.getId());
+//         }
+//      }
+//      propagatedContainedIn.push(thisPtr);
+//      return thisPtr;
+//   }
+   
    /**
     * Checks whether this context or any of its children are in use.
     */
@@ -392,20 +462,20 @@
       // Just check contains directly; don't call getContains() since
       // getContains() will deserialize the beanMO. If the beanMO isn't 
       // deserialized it's safe to assume the children aren't in use
-      if (canPassivate && contains != null)
-      {
-         synchronized (contains)
-         {
-            for (StatefulBeanContext contained : contains)
-            {
-               if (!contained.getCanPassivate())
-               {
-                  canPassivate = false;
-                  break;
-               }
-            }
-         }
-      }
+//      if (canPassivate && contains != null)
+//      {
+//         synchronized (contains)
+//         {
+//            for (StatefulBeanContext contained : contains)
+//            {
+//               if (!contained.getCanPassivate())
+//               {
+//                  canPassivate = false;
+//                  break;
+//               }
+//            }
+//         }
+//      }
       
       return canPassivate;
    }
@@ -425,15 +495,15 @@
          passivated = true;
       }
       
-      // Pass the call on to any nested children
-      List<StatefulBeanContext> children = getThreadSafeContains();
-      if (children != null)
-      {
-         for (StatefulBeanContext contained : children)
-         {
-            contained.prePassivate();
-         }
-      }
+//      // Pass the call on to any nested children
+//      List<StatefulBeanContext> children = getThreadSafeContains();
+//      if (children != null)
+//      {
+//         for (StatefulBeanContext contained : children)
+//         {
+//            contained.prePassivate();
+//         }
+//      }
    }
 
    /**
@@ -451,15 +521,15 @@
          passivated = false;
       }
       
-      // Pass the call on to any nested children
-      List<StatefulBeanContext> children = getThreadSafeContains();
-      if (children != null)
-      {  
-         for (StatefulBeanContext contained : children)
-         {
-            contained.postActivate();
-         }
-      }
+//      // Pass the call on to any nested children
+//      List<StatefulBeanContext> children = getThreadSafeContains();
+//      if (children != null)
+//      {  
+//         for (StatefulBeanContext contained : children)
+//         {
+//            contained.postActivate();
+//         }
+//      }
    }
    
    /**
@@ -481,21 +551,21 @@
          passivated = true;
       }
       
-      // Only bother informing children if we aren't already serialized.
-      // If we're serialized, so are they and there's no point.
-      // Notifying them would cause us to deserialize a beanMO to no purpose.
-      if (contains != null)
-      {
-         // Pass the call on to any nested children
-         List<StatefulBeanContext> children = getThreadSafeContains();
-         if (children != null)
-         {
-            for (StatefulBeanContext contained : children)
-            {
-               contained.passivateAfterReplication();
-            }
-         }
-      }
+//      // Only bother informing children if we aren't already serialized.
+//      // If we're serialized, so are they and there's no point.
+//      // Notifying them would cause us to deserialize a beanMO to no purpose.
+//      if (contains != null)
+//      {
+//         // Pass the call on to any nested children
+//         List<StatefulBeanContext> children = getThreadSafeContains();
+//         if (children != null)
+//         {
+//            for (StatefulBeanContext contained : children)
+//            {
+//               contained.passivateAfterReplication();
+//            }
+//         }
+//      }
    }
    
    public void activateAfterReplication()
@@ -509,15 +579,15 @@
          passivated = false;
       }
       
-      // Pass the call on to any nested children
-      List<StatefulBeanContext> children = getThreadSafeContains();
-      if (children != null)
-      {
-         for (StatefulBeanContext contained : children)
-         {
-            contained.activateAfterReplication();
-         }
-      }
+//      // Pass the call on to any nested children
+//      List<StatefulBeanContext> children = getThreadSafeContains();
+//      if (children != null)
+//      {
+//         for (StatefulBeanContext contained : children)
+//         {
+//            contained.activateAfterReplication();
+//         }
+//      }
    }
 
    public boolean getReplicationIsPassivation()
@@ -545,15 +615,15 @@
          passivated = true;
       }
       
-      // Pass the call on to any nested children
-      List<StatefulBeanContext> children = getThreadSafeContains();
-      if (children != null)
-      {
-         for (StatefulBeanContext contained : children)
-         {
-            contained.preReplicate();
-         }
-      }
+//      // Pass the call on to any nested children
+//      List<StatefulBeanContext> children = getThreadSafeContains();
+//      if (children != null)
+//      {
+//         for (StatefulBeanContext contained : children)
+//         {
+//            contained.preReplicate();
+//         }
+//      }
    }
 
    /**
@@ -576,21 +646,21 @@
          passivated = false;
       }
       
-      // Pass the call on to any nested children
-      List<StatefulBeanContext> children = getThreadSafeContains();
-      if (children != null)
-      {
-         for (StatefulBeanContext contained : children)
-         {
-            contained.postReplicate();
-         }
-      }
+//      // Pass the call on to any nested children
+//      List<StatefulBeanContext> children = getThreadSafeContains();
+//      if (children != null)
+//      {
+//         for (StatefulBeanContext contained : children)
+//         {
+//            contained.postReplicate();
+//         }
+//      }
    }
 
-   public void popContainedIn()
-   {
-      propagatedContainedIn.pop();
-   }
+//   public void popContainedIn()
+//   {
+//      propagatedContainedIn.pop();
+//   }
 
    public boolean isInUse()
    {
@@ -668,20 +738,20 @@
             exceptionThrown = e;
       }
       
-      if (containedIn != null && getCanRemoveFromCache())
-      {
-         try
-         {
-            containedIn.removeContains(this);
-         }
-         catch (RuntimeException e)
-         {
-            // we still need to clean internal state, so save the
-            // thrown exception and rethrow it after we have cleaned up.
-            if (exceptionThrown == null)
-               exceptionThrown = e;
-         }
-      }
+//      if (containedIn != null && getCanRemoveFromCache())
+//      {
+//         try
+//         {
+//            containedIn.removeContains(this);
+//         }
+//         catch (RuntimeException e)
+//         {
+//            // we still need to clean internal state, so save the
+//            // thrown exception and rethrow it after we have cleaned up.
+//            if (exceptionThrown == null)
+//               exceptionThrown = e;
+//         }
+//      }
             
       // Clear out refs to our bean and interceptors, to reduce our footprint
       // in case we are still cached for our refs to any XPCs
@@ -691,20 +761,20 @@
       if (exceptionThrown != null) throw new RuntimeException("exception thrown while removing SFSB", exceptionThrown);
    }
    
-   public boolean getCanRemoveFromCache()
-   {
-      boolean canRemove = removed;
-      
-      if (canRemove && getContains() != null) // call getContains() to ensure unmarshalling
-      {
-         synchronized (contains)
-         {
-            canRemove = (contains.size() == 0);
-         }
-      }
-      
-      return canRemove;
-   }
+//   public boolean getCanRemoveFromCache()
+//   {
+//      boolean canRemove = removed;
+//      
+//      if (canRemove && getContains() != null) // call getContains() to ensure unmarshalling
+//      {
+//         synchronized (contains)
+//         {
+//            canRemove = (contains.size() == 0);
+//         }
+//      }
+//      
+//      return canRemove;
+//   }
    
    private void cleanExtendedPCs()
    {    
@@ -732,59 +802,59 @@
 
    private void closeExtendedPCs()
    {
-      Map<String, EntityManager> extendedPCS = getExtendedPersistenceContexts();
+      Set<String> extendedPCS = getPersistenceContextNames();
       if (extendedPCS != null)
       {
          RuntimeException exceptionThrown = null;
          
-         List<String> closedXPCs = new ArrayList<String>();
-         StatefulBeanContext topCtx = getUltimateContainedIn();
+//         List<String> closedXPCs = new ArrayList<String>();
+//         StatefulBeanContext topCtx = getUltimateContainedIn();
+//         
+//         for (Iterator<Map.Entry<String,EntityManager>> iter = extendedPCS.entrySet().iterator(); 
+//               iter.hasNext();)
+//         {
+//            Map.Entry<String,EntityManager> entry = iter.next();
+//            String id = entry.getKey();
+//            EntityManager xpc = entry.getValue();
+//            
+//            // Only close the XPC if our live parent(s) or cousins 
+//            // don't also have a ref to it
+//            boolean canClose = topCtx.scanForExtendedPersistenceContext(id, this);
+//            
+//            if (canClose && getContains() != null)
+//            {
+//               // Only close the XPC if our live childrenScan don't have a ref
+//               synchronized (contains)
+//               {
+//                  for (StatefulBeanContext contained : contains)
+//                  {
+//                     if (contained.scanForExtendedPersistenceContext(id, null))
+//                     {
+//                        canClose = false;
+//                        break;
+//                     }
+//                  }
+//               }
+//            }
+//            
+//            if (canClose)
+//            {
+//               try
+//               {
+//                  xpc.close();
+//                  closedXPCs.add(id);
+//               }
+//               catch (RuntimeException e)
+//               {
+//                  exceptionThrown = e;
+//               }
+//            }
+//         }
          
-         for (Iterator<Map.Entry<String,EntityManager>> iter = extendedPCS.entrySet().iterator(); 
-               iter.hasNext();)
-         {
-            Map.Entry<String,EntityManager> entry = iter.next();
-            String id = entry.getKey();
-            EntityManager xpc = entry.getValue();
-            
-            // Only close the XPC if our live parent(s) or cousins 
-            // don't also have a ref to it
-            boolean canClose = topCtx.scanForExtendedPersistenceContext(id, this);
-            
-            if (canClose && getContains() != null)
-            {
-               // Only close the XPC if our live childrenScan don't have a ref
-               synchronized (contains)
-               {
-                  for (StatefulBeanContext contained : contains)
-                  {
-                     if (contained.scanForExtendedPersistenceContext(id, null))
-                     {
-                        canClose = false;
-                        break;
-                     }
-                  }
-               }
-            }
-            
-            if (canClose)
-            {
-               try
-               {
-                  xpc.close();
-                  closedXPCs.add(id);
-               }
-               catch (RuntimeException e)
-               {
-                  exceptionThrown = e;
-               }
-            }
-         }
-         
          // Clean all refs to the closed XPCs from the tree
-         for (String id : closedXPCs)
+         for (String id : extendedPCS)
          {
-            topCtx.removeExtendedPersistenceContext(id);
+            removeExtendedPersistenceContext(id);
          }            
          
          if (exceptionThrown != null) throw new RuntimeException("Error closing PersistenceContexts in SFSB removal", exceptionThrown);
@@ -866,8 +936,9 @@
          
          Object[] beanAndInterceptors = (Object[]) beanMO.get();
          bean = beanAndInterceptors[0];
-         persistenceContexts = (HashMap<String, EntityManager>) beanAndInterceptors[1];
-         ArrayList list = (ArrayList) beanAndInterceptors[2];
+         persistenceContextNames = (Set<String>) beanAndInterceptors[1];
+         sharedState = (Map<Object, Object>) beanAndInterceptors[2];
+         ArrayList list = (ArrayList) beanAndInterceptors[3];
          interceptorInstances = new HashMap<Class<?>, Object>();
          if (list != null)
          {
@@ -876,16 +947,16 @@
                interceptorInstances.put(o.getClass(), o);
             }
          }
-         contains = (List<StatefulBeanContext>) beanAndInterceptors[3];
-         // Reestablish links to our children; if they serialize a link
-         // to us for some reason serialization blows up
-         if (contains != null)
-         {
-            for (StatefulBeanContext contained : contains)
-            {
-               contained.containedIn = this;
-            }
-         }
+//         contains = (List<StatefulBeanContext>) beanAndInterceptors[4];
+//         // Reestablish links to our children; if they serialize a link
+//         // to us for some reason serialization blows up
+//         if (contains != null)
+//         {
+//            for (StatefulBeanContext contained : contains)
+//            {
+//               contained.containedIn = this;
+//            }
+//         }
          
          // Don't hold onto the beanMo, as its contents are mutable
          // and we don't want to serialize a stale version of them
@@ -916,14 +987,15 @@
       {
          Object[] beanAndInterceptors = new Object[4];
          beanAndInterceptors[0] = bean;
-         beanAndInterceptors[1] = persistenceContexts;
+         beanAndInterceptors[1] = persistenceContextNames;
+         beanAndInterceptors[2] = sharedState;
          if (interceptorInstances != null && interceptorInstances.size() > 0)
          {
             ArrayList list = new ArrayList();
             list.addAll(interceptorInstances.values());
             beanAndInterceptors[2] = list;
          }
-         beanAndInterceptors[3] = contains;
+//         beanAndInterceptors[3] = contains;
          
          // BES 2007/02/12 Previously we were trying to hold a ref to
          // beanMO after we created it, but that exposes the risk of

Deleted: projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContextReference.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContextReference.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContextReference.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -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.stateful;
-
-import java.io.Serializable;
-
-import org.jboss.ejb3.Ejb3Registry;
-
-/**
- * Serializable reference to stateful bean context that can be disconnected
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class StatefulBeanContextReference implements Serializable
-{
-   /** The serialVersionUID */
-   private static final long serialVersionUID = -7622266426902284032L;
-   
-   private transient StatefulBeanContext beanContext;
-   private Object oid;
-   private String containerGuid;
-   private String containerClusterUid;
-   private boolean isClustered = false;
-   
-   public StatefulBeanContextReference(StatefulBeanContext beanContext)
-   {
-      assert beanContext != null : "beanContext is null";
-      
-      this.beanContext = beanContext;
-      oid = beanContext.getId();
-      containerGuid = Ejb3Registry.guid(beanContext.getContainer());
-      containerClusterUid = Ejb3Registry.clusterUid(beanContext.getContainer());
-      isClustered = beanContext.getContainer().isClustered();
-   }
-
-   public StatefulBeanContext getBeanContext()
-   {
-      if (beanContext == null)
-      {
-         StatefulContainer container = (StatefulContainer)Ejb3Registry.findContainer(containerGuid);
-         if (isClustered && container == null)
-            container = (StatefulContainer)Ejb3Registry.getClusterContainer(containerClusterUid);
-         // We are willing to accept a context that has been marked as removed
-         // as it can still hold nested children
-         beanContext = container.getCache().get(oid, false);
-         
-         assert beanContext != null : "beanContext no longer in cache";
-      }
-      return beanContext;
-   }
-}

Modified: projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -54,15 +54,14 @@
 import org.jboss.ejb3.BeanContext;
 import org.jboss.ejb3.Ejb3Deployment;
 import org.jboss.ejb3.Ejb3Registry;
-import org.jboss.ejb3.annotation.Cache;
-import org.jboss.ejb3.annotation.CacheConfig;
 import org.jboss.ejb3.annotation.Clustered;
 import org.jboss.ejb3.annotation.LocalBinding;
 import org.jboss.ejb3.annotation.RemoteBinding;
 import org.jboss.ejb3.annotation.RemoteHomeBinding;
+import org.jboss.ejb3.cache.Cache;
 import org.jboss.ejb3.cache.CacheFactoryRegistry;
-import org.jboss.ejb3.cache.Ejb3CacheFactory;
-import org.jboss.ejb3.cache.StatefulCache;
+import org.jboss.ejb3.cache.PassivationManager;
+import org.jboss.ejb3.cache.StatefulCacheFactory;
 import org.jboss.ejb3.cache.StatefulObjectFactory;
 import org.jboss.ejb3.common.lang.SerializableMethod;
 import org.jboss.ejb3.common.registrar.spi.Ejb3Registrar;
@@ -103,11 +102,12 @@
 public class StatefulContainer extends SessionSpecContainer
       implements
          StatefulObjectFactory<StatefulBeanContext>,
+         PassivationManager<StatefulBeanContext>,
          StatefulSessionInvokableContext
 {
    private static final Logger log = Logger.getLogger(StatefulContainer.class);
 
-   protected StatefulCache cache;
+   protected Cache<StatefulBeanContext> cache;
    private StatefulDelegateWrapper mbean = new StatefulDelegateWrapper(this);
 
    public StatefulContainer(ClassLoader cl, String beanClassName, String ejbName, Domain domain,
@@ -116,18 +116,47 @@
       super(cl, beanClassName, ejbName, domain, ctxProperties, deployment, beanMetaData);
    }
 
-   public StatefulBeanContext create(Class<?>[] initTypes, Object[] initValues)
+//   public StatefulBeanContext create(Class<?>[] initTypes, Object[] initValues)
+//   {
+//      StatefulBeanContext sfctx = (StatefulBeanContext) createBeanContext();
+//      // Tell context how to handle replication
+//      CacheConfig config = getAnnotation(CacheConfig.class);
+//      if (config != null)
+//      {
+//         sfctx.setReplicationIsPassivation(config.replicationIsPassivation());
+//      }
+//
+//      // this is for propagated extended PC's
+//      sfctx = sfctx.pushContainedIn();
+//      
+//      pushContext(sfctx);
+//      try
+//      {
+//         injectBeanContext(sfctx);
+//
+//         sfctx.initialiseInterceptorInstances();
+//
+//      }
+//      finally
+//      {
+//         popContext();
+//         // this is for propagated extended PC's
+//         sfctx.popContainedIn();
+//      }
+//      
+//      invokePostConstruct(sfctx, initValues);
+//      
+//      //TODO This needs to be reimplemented as replacement for create() on home interface
+//      invokeInit(sfctx.getInstance(), initTypes, initValues);
+//      
+//      return sfctx;
+//   }
+   
+   public StatefulBeanContext create(Class<?>[] initTypes, Object[] initValues, Map<Object, Object> sharedState)
    {
       StatefulBeanContext sfctx = (StatefulBeanContext) createBeanContext();
-      // Tell context how to handle replication
-      CacheConfig config = getAnnotation(CacheConfig.class);
-      if (config != null)
-      {
-         sfctx.setReplicationIsPassivation(config.replicationIsPassivation());
-      }
-
-      // this is for propagated extended PC's
-      sfctx = sfctx.pushContainedIn();
+      // FIXME this needs to be passed via the constructor to establish invariant
+      sfctx.setSharedState(sharedState);
       
       pushContext(sfctx);
       try
@@ -140,8 +169,6 @@
       finally
       {
          popContext();
-         // this is for propagated extended PC's
-         sfctx.popContainedIn();
       }
       
       invokePostConstruct(sfctx, initValues);
@@ -149,6 +176,8 @@
       //TODO This needs to be reimplemented as replacement for create() on home interface
       invokeInit(sfctx.getInstance(), initTypes, initValues);
       
+      log.trace("Created context " + sfctx.getId() + " for " + getName());
+      
       return sfctx;
    }
    
@@ -293,11 +322,11 @@
          return;
       }
       
-      Cache cacheConfig = getAnnotation(Cache.class);
+      org.jboss.ejb3.annotation.Cache cacheAnnotation = getAnnotation(org.jboss.ejb3.annotation.Cache.class);
+      org.jboss.ejb3.annotation.CacheConfig cacheConfig = getAnnotation(org.jboss.ejb3.annotation.CacheConfig.class);
       CacheFactoryRegistry registry = getCacheFactoryRegistry();
-      Ejb3CacheFactory factory = registry.getCacheFactory(cacheConfig.value());
-      this.cache = factory.createCache();
-      this.cache.initialize(this);
+      StatefulCacheFactory<StatefulBeanContext> factory = registry.getCacheFactory(cacheAnnotation.value());
+      this.cache = factory.createCache(getName(), this, this, cacheConfig);
       this.cache.start();
    }
    
@@ -332,7 +361,7 @@
       super.lockedStop();
    }
 
-   public StatefulCache getCache()
+   public Cache<StatefulBeanContext> getCache()
    {
       // Ensure initialized
       try{
@@ -484,11 +513,8 @@
       try
       {
          Thread.currentThread().setContextClassLoader(classloader);
-         StatefulCache cache = this.getCache();
-         StatefulBeanContext ctx = cache.create(initTypes, initValues);
-         // Since we return the key here, the context is not in use.
-         cache.release(ctx);
-         Object id = ctx.getId();
+         Cache<StatefulBeanContext> cache = this.getCache();
+         Object id = cache.create(initTypes, initValues);
          assert id instanceof Serializable : "SFSB Session IDs must be " + Serializable.class.getSimpleName();
          return (Serializable) id;
       }
@@ -614,8 +640,7 @@
 
                if (sessionId == null)
                {
-                  StatefulBeanContext ctx = getCache().create(null, null);
-                  Object objNewId = ctx.getId();
+                  Object objNewId = getCache().create(null, null);
                   assert objNewId instanceof Serializable : "Obtained new Session ID from cache, " + objNewId
                         + ", which is not " + Serializable.class.getSimpleName();
                   sessionId = (Serializable) objNewId;
@@ -1295,6 +1320,7 @@
    {
       StatefulSessionContainerMethodInvocation newStatefulInvocation = null;
 
+      Object id = null;
       StatefulBeanContext ctx = null;
       
       // ENC is required in scope to create a session
@@ -1303,9 +1329,11 @@
       try
       {
          if (initParameterTypes.length > 0)
-            ctx = getCache().create(initParameterTypes, initParameterValues);
+            id = getCache().create(initParameterTypes, initParameterValues);
          else
-            ctx = getCache().create(null, null);
+            id = getCache().create(null, null);
+         
+         ctx = getCache().get(id);
       }
       finally
       {
@@ -1335,8 +1363,9 @@
       Object newId = null;
       if (statefulInvocation.getId() == null)
       {
-         StatefulBeanContext ctx = getCache().create(null, null);
-         newId = ctx.getId();
+         newId = getCache().create(null, null);
+         // FIXME -- previous create(...) impl would do equiv of a get() as well;
+         // do we need to add a cache.get(newId) to have the same behavior?
          newStatefulInvocation = new StatefulContainerInvocation(info, newId);
       }
       else
@@ -1464,4 +1493,28 @@
       */
       arg.getEJBObject().remove();
    }
+   
+
+   
+   // --------------------------------------------------  PassivationManager
+
+   public void postActivate(StatefulBeanContext ctx)
+   {
+      ctx.postActivate();
+   }
+
+   public void postReplicate(StatefulBeanContext ctx)
+   {
+      ctx.postReplicate(); 
+   }
+
+   public void prePassivate(StatefulBeanContext ctx)
+   {
+      ctx.prePassivate();
+   }
+
+   public void preReplicate(StatefulBeanContext ctx)
+   {
+      ctx.preReplicate();
+   }
 }

Modified: projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/StatefulSessionContextDelegate.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulSessionContextDelegate.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/StatefulSessionContextDelegate.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -23,6 +23,8 @@
 
 import javax.ejb.EJBLocalObject;
 import javax.ejb.EJBObject;
+import javax.transaction.UserTransaction;
+import javax.xml.rpc.handler.MessageContext;
 
 import org.jboss.ejb3.session.SessionBeanContext;
 import org.jboss.ejb3.session.SessionContextDelegateBase;
@@ -36,18 +38,32 @@
  */
 public class StatefulSessionContextDelegate extends SessionContextDelegateBase<StatefulContainer>
 {
-
-   public StatefulSessionContextDelegate(SessionBeanContext<StatefulContainer> beanContext)
+   private final Object id;
+   
+   public StatefulSessionContextDelegate(StatefulBeanContext ctx)
    {
-      super(beanContext);
+      super(ctx);
+      this.id = ctx.getId();
+      // Hack. Here we don't release the bean context back to the cache
+      // since we aren't the one that accessed it
+//      container.getCache().release((StatefulBeanContext) beanContext);
+      this.beanContext = null;
    }
+   
+   public StatefulSessionContextDelegate(StatefulContainer container, Object id)
+   {
+      super(container.getCache().get(id));
+      this.id = id;
+      // Hack. Need to release the bean context back to the cache
+      container.getCache().release((StatefulBeanContext) beanContext);
+      this.beanContext = null;
+   }
 
    @Override
    public EJBLocalObject getEJBLocalObject() throws IllegalStateException
    {
       try
       {
-         Object id = beanContext.getId();
          EJBLocalObject proxy = null;
          try
          {
@@ -76,7 +92,6 @@
    {
       try
       {
-         Object id = beanContext.getId();
          EJBObject proxy = null;
          try
          {
@@ -99,4 +114,60 @@
       }
    }
 
+   @Override
+   public <T> T getBusinessObject(Class<T> businessInterface) throws IllegalStateException
+   {
+      establishBeanContext();
+      try
+      {
+         return super.getBusinessObject(businessInterface);
+      }
+      finally
+      {
+         releaseBeanContext();
+      }
+   }
+
+   @Override
+   public MessageContext getMessageContext() throws IllegalStateException
+   {
+      establishBeanContext();
+      try
+      {
+         return super.getMessageContext();
+      }
+      finally
+      {
+         releaseBeanContext();
+      }
+   }
+
+   @Override
+   public UserTransaction getUserTransaction() throws IllegalStateException
+   {
+      establishBeanContext();
+      try
+      {
+         return super.getUserTransaction();
+      }
+      finally
+      {
+         releaseBeanContext();
+      }
+   }
+   
+   private void establishBeanContext()
+   {
+      this.beanContext = container.getCache().get(id);
+   }
+   
+   private void releaseBeanContext()
+   {
+      if (this.beanContext != null)
+      {
+         container.getCache().release((StatefulBeanContext) beanContext);
+         beanContext = null;
+      }
+   }
+
 }

Modified: projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/StatefulSessionContextImpl.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulSessionContextImpl.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/main/java/org/jboss/ejb3/stateful/StatefulSessionContextImpl.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -127,7 +127,7 @@
          if (container == null && isClustered)
             container = (StatefulContainer)Ejb3Registry.getClusterContainer(containerClusterUid);
          
-         delegate = new StatefulSessionContextDelegate(container.getCache().get(id, false));
+         delegate = new StatefulSessionContextDelegate(container, id);
       }
       return delegate;
    }

Modified: projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -41,7 +41,7 @@
 import org.jboss.ejb3.Ejb3Registry;
 import org.jboss.ejb3.InitialContextFactory;
 import org.jboss.ejb3.cache.CacheFactoryRegistry;
-import org.jboss.ejb3.cache.persistence.PersistenceManagerFactoryRegistry;
+//import org.jboss.ejb3.cache.persistence.PersistenceManagerFactoryRegistry;
 import org.jboss.ejb3.common.registrar.plugin.mc.Ejb3McRegistrar;
 import org.jboss.ejb3.common.registrar.spi.DuplicateBindException;
 import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
@@ -247,13 +247,13 @@
          if (sessionType.equals(ContainerType.SFSB))
          {
             // Lookup Factory Registries in MC
-            PersistenceManagerFactoryRegistry registry = Ejb3RegistrarLocator.locateRegistrar().lookup(
-                  AbstractEJB3TestCase.OBJECT_STORE_NAME_PM_FACTORY_REGISTRY, PersistenceManagerFactoryRegistry.class);
+//            PersistenceManagerFactoryRegistry registry = Ejb3RegistrarLocator.locateRegistrar().lookup(
+//                  AbstractEJB3TestCase.OBJECT_STORE_NAME_PM_FACTORY_REGISTRY, PersistenceManagerFactoryRegistry.class);
             CacheFactoryRegistry cacheFactoryRegistry = Ejb3RegistrarLocator.locateRegistrar().lookup(
                   AbstractEJB3TestCase.OBJECT_STORE_NAME_CACHE_FACTORY_REGISTRY, CacheFactoryRegistry.class);
 
             // Set on the deployment
-            deployment.setPersistenceManagerFactoryRegistry(registry);
+//            deployment.setPersistenceManagerFactoryRegistry(registry);
             deployment.setCacheFactoryRegistry(cacheFactoryRegistry);
          }
 

Modified: projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/common/MockEjb3Deployment.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/common/MockEjb3Deployment.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/common/MockEjb3Deployment.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -23,7 +23,10 @@
 
 import java.util.HashMap;
 
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
 import javax.security.jacc.PolicyConfiguration;
+import javax.transaction.TransactionManager;
 
 import org.jboss.deployers.structure.spi.helpers.AbstractDeploymentUnit;
 import org.jboss.ejb3.DependencyPolicy;
@@ -32,9 +35,20 @@
 import org.jboss.ejb3.Ejb3Deployment;
 import org.jboss.ejb3.cache.CacheFactoryRegistry;
 import org.jboss.ejb3.cache.Ejb3CacheFactory;
-import org.jboss.ejb3.cache.NoPassivationCacheFactory;
-import org.jboss.ejb3.cache.simple.SimpleStatefulCacheFactory;
-import org.jboss.ejb3.cache.tree.StatefulTreeCacheFactory;
+import org.jboss.ejb3.cache.StatefulCacheFactory;
+import org.jboss.ejb3.cache.impl.factory.GroupAwareCacheFactory;
+import org.jboss.ejb3.cache.impl.factory.NonClusteredBackingCacheEntryStoreSource;
+import org.jboss.ejb3.cache.impl.factory.NonPassivatingCacheFactory;
+import org.jboss.ejb3.cache.spi.BackingCacheEntryStoreSource;
+import org.jboss.ejb3.cache.spi.impl.AbstractStatefulCacheFactory;
+import org.jboss.ejb3.cache.spi.impl.JndiTransactionSynchronizationRegistrySource;
+import org.jboss.ejb3.cache.spi.impl.SynchronizationCoordinatorImpl;
+import org.jboss.ejb3.cache.spi.impl.TransactionSynchronizationRegistrySource;
+//import org.jboss.ejb3.cache.NoPassivationCacheFactory;
+//import org.jboss.ejb3.cache.simple.SimpleStatefulCacheFactory;
+//import org.jboss.ejb3.cache.tree.StatefulTreeCacheFactory;
+import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.common.registrar.spi.NotBoundException;
 import org.jboss.ejb3.common.resolvers.plugins.FirstMatchEjbReferenceResolver;
 import org.jboss.ejb3.common.resolvers.spi.EjbReferenceResolver;
 import org.jboss.ejb3.deployers.JBoss5DependencyPolicy;
@@ -43,6 +57,10 @@
 import org.jboss.ejb3.pool.PoolFactoryRegistry;
 import org.jboss.ejb3.pool.StrictMaxPoolFactory;
 import org.jboss.ejb3.pool.ThreadlocalPoolFactory;
+import org.jboss.ejb3.stateful.StatefulBeanContext;
+import org.jboss.ejb3.test.cache.distributed.MockBackingCacheEntryStoreSource;
+import org.jboss.ejb3.test.cache.distributed.UnmarshallingMap;
+import org.jboss.ejb3.test.cache.mock.tm.MockTransactionManager;
 
 /**
  * Comment
@@ -86,10 +104,10 @@
       poolRegistry.setFactories(poolFactories);
       setPoolFactoryRegistry(poolRegistry);
       CacheFactoryRegistry cacheRegistry = new CacheFactoryRegistry();
-      HashMap<String, Class<? extends Ejb3CacheFactory>> cacheFactories = new HashMap<String, Class<? extends Ejb3CacheFactory>>();
-      cacheFactories.put("NoPassivationCache", NoPassivationCacheFactory.class);
-      cacheFactories.put("SimpleStatefulCache", SimpleStatefulCacheFactory.class);
-      cacheFactories.put("StatefulTreeCache", StatefulTreeCacheFactory.class);
+      HashMap<String, StatefulCacheFactory<StatefulBeanContext>> cacheFactories = new HashMap<String, StatefulCacheFactory<StatefulBeanContext>>();
+      cacheFactories.put("NoPassivationCache", buildNonPassivatingCacheFactory());
+      cacheFactories.put("SimpleStatefulCache", buildSimpleCacheFactory());
+      cacheFactories.put("StatefulTreeCache", buildDistributedCacheFactory());
       cacheRegistry.setFactories(cacheFactories);
       setCacheFactoryRegistry(cacheRegistry);
    }
@@ -111,5 +129,73 @@
    {
       throw new RuntimeException("mock");
    }
+   
+   private StatefulCacheFactory<StatefulBeanContext> buildNonPassivatingCacheFactory()
+   {
+      AbstractStatefulCacheFactory<StatefulBeanContext> factory = new NonPassivatingCacheFactory<StatefulBeanContext>();
+      configureStatefulCacheFactory(factory);
+      return factory;
+   }
+   
+   private StatefulCacheFactory<StatefulBeanContext> buildSimpleCacheFactory()
+   {
+      NonClusteredBackingCacheEntryStoreSource<StatefulBeanContext> source = 
+         new NonClusteredBackingCacheEntryStoreSource<StatefulBeanContext>();
+      AbstractStatefulCacheFactory<StatefulBeanContext> factory =  new GroupAwareCacheFactory<StatefulBeanContext>(source);
+      configureStatefulCacheFactory(factory);
+      return factory;
+   }
+   
+   private StatefulCacheFactory<StatefulBeanContext> buildDistributedCacheFactory()
+   {
+     BackingCacheEntryStoreSource<StatefulBeanContext> storeSource = getDistributedStoreSource();
+     AbstractStatefulCacheFactory<StatefulBeanContext> factory =  new GroupAwareCacheFactory<StatefulBeanContext>(storeSource);
+     configureStatefulCacheFactory(factory);
+     return factory;
+   }
+   
+   private void configureStatefulCacheFactory(AbstractStatefulCacheFactory<StatefulBeanContext> factory)
+   {
+      TransactionManager tm = null;
+      try
+      {
+         tm = (TransactionManager) Ejb3RegistrarLocator.locateRegistrar().lookup("RealTransactionManager");
+      }
+      catch (NotBoundException e)
+      {
+         // fall back on JNDI
+         try
+         {
+            InitialContext ctx = new InitialContext();
+            tm = (TransactionManager) ctx.lookup("java:/TransactionManager");
+         }
+         catch (NamingException e1)
+         {
+            throw new RuntimeException("cannot resolve transaction manager", e1);
+         }         
+      }
+      
+      factory.setTransactionManager(tm);
+      
+      //factory.setPassivationExpirationCoordinator(coordinator);
+      // Process passivation/expiration as quickly as possible so tests run fast
+      factory.setDefaultPassivationExpirationInterval(10);
+      SynchronizationCoordinatorImpl sci = new SynchronizationCoordinatorImpl();
+      if (tm instanceof TransactionSynchronizationRegistrySource)
+      {
+         sci.setTransactionSynchronizationRegistrySource((TransactionSynchronizationRegistrySource) tm);
+      }
+      else
+      {
+         sci.setTransactionSynchronizationRegistrySource(new JndiTransactionSynchronizationRegistrySource());
+      }
+      factory.setSynchronizationCoordinator(sci);      
+      factory.start();
+   }
 
+   private BackingCacheEntryStoreSource<StatefulBeanContext> getDistributedStoreSource()
+   {
+      return new MockBackingCacheEntryStoreSource<StatefulBeanContext>(new UnmarshallingMap(), new UnmarshallingMap());
+   }
+
 }

Modified: projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/common/SimpleTransactionService.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/common/SimpleTransactionService.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/common/SimpleTransactionService.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -51,6 +51,7 @@
       ctx = new InitialContext();
       JNDIManager.bindJTAImplementation();
       this.tm = (TransactionManager) ctx.lookup(TM_JNDI_NAME);
+      JNDIManager.bindJTATransactionSynchronizationRegistryImplementation();
    }
    
    public void stop() throws NamingException

Deleted: projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/BlockingPersistenceManager.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/BlockingPersistenceManager.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/BlockingPersistenceManager.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -1,172 +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.core.test.ejbthree1549;
-
-import java.io.IOException;
-import java.rmi.MarshalledObject;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.BrokenBarrierException;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CyclicBarrier;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-import javax.ejb.EJBException;
-
-import org.jboss.ejb3.Container;
-import org.jboss.ejb3.cache.simple.StatefulSessionPersistenceManager;
-import org.jboss.ejb3.stateful.StatefulBeanContext;
-import org.jboss.logging.Logger;
-
-/**
- * BlockingPersistenceManager
- * 
- * An implementation of a PersistenceManager which, instead of
- * persisting directly, exposes a blocking mechanism allowing 
- * tests to control when passivation occurs 
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class BlockingPersistenceManager implements StatefulSessionPersistenceManager
-{
-   // --------------------------------------------------------------------------------||
-   // Class Members ------------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   private static final Logger log = Logger.getLogger(BlockingPersistenceManager.class);
-
-   /**
-    * Publicly-accessible lock
-    * 
-    * Used by the test to block the act of passivation
-    */
-   public static final Lock PASSIVATION_LOCK = new ReentrantLock();
-
-   /**
-    * Publicly-accessible barrier
-    * 
-    * Will block until both the test and the PM agree that passivation 
-    * should take place
-    */
-   public static final CyclicBarrier BARRIER = new CyclicBarrier(2);
-   
-   private Map<Object, MarshalledObject> passivated = new ConcurrentHashMap<Object, MarshalledObject>();
-
-   // --------------------------------------------------------------------------------||
-   // Required Implementations -------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   public StatefulBeanContext activateSession(Object id)
-   {
-      log.info("Activating " + id);
-      MarshalledObject o = passivated.remove(id);
-      if(o == null)
-         throw new EJBException("Can't find bean " + id);
-      try
-      {
-         return (StatefulBeanContext)o.get();
-      }
-      catch (IOException e)
-      {
-         throw new EJBException(e);
-      }
-      catch (ClassNotFoundException e)
-      {
-         throw new EJBException(e);
-      }
-   }
-
-   public void destroy() throws Exception
-   {
-      passivated.clear();
-   }
-
-   public List<StatefulBeanContext> getPassivatedBeans()
-   {
-      // very stupid and slow, don't do this
-      throw new RuntimeException("NYI");
-   }
-
-   public void initialize(Container container) throws Exception
-   {
-   }
-   
-   public void passivateSession(StatefulBeanContext ctx)
-   {
-
-      try
-      {
-         /*
-          * Block until the lock may be acquired,
-          * may currently be held by the test Thread until the test is ready.
-          * So here both the test and passivation will block until this barrier
-          * is agreed by both Threads to be released
-          */
-         log.info("Waiting until the test is ready for passivation to start...");
-         BARRIER.await();
-
-         // Block until the test releases this lock
-         log.info("Blocking until the test tells us that the act of passivation may continue...");
-         PASSIVATION_LOCK.lock();
-
-         try
-         {
-            // Mock Passivate
-            log.info("Mock Passivation on " + ctx.getId());
-            passivated.put(ctx.getId(), new MarshalledObject(ctx));
-         }
-         catch(IOException e)
-         {
-            throw new EJBException(e);
-         }
-         finally
-         {
-            // Release the passivation lock
-            log.info("We're done with passivation, letting the lock go.");
-            PASSIVATION_LOCK.unlock();
-         }
-      }
-      catch (InterruptedException e)
-      {
-         throw new RuntimeException("Barrier was interrupted prematurely", e);
-      }
-      catch (BrokenBarrierException e)
-      {
-         throw new RuntimeException("Barrier was broken prematurely", e);
-      }
-      finally
-      {
-         // Reset the Barrier
-         BARRIER.reset();
-      }
-   }
-   
-   public void removePassivated(Object id)
-   {
-      MarshalledObject o = passivated.remove(id);
-      if(o == null)
-         throw new EJBException("Can't find bean " + id);
-   }
-
-}

Deleted: projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/BlockingPersistenceManagerFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/BlockingPersistenceManagerFactory.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/BlockingPersistenceManagerFactory.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -1,56 +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.core.test.ejbthree1549;
-
-import org.jboss.ejb3.cache.persistence.PersistenceManagerFactory;
-import org.jboss.ejb3.cache.simple.StatefulSessionPersistenceManager;
-
-/**
- * BlockingPersistenceManagerFactory
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class BlockingPersistenceManagerFactory implements PersistenceManagerFactory
-{
-   // --------------------------------------------------------------------------------||
-   // Class Members ------------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   /**
-    * Name under which this PM will be bound into the PersistenceManagerFactoryRegistry
-    */
-   public static final String REGISTRY_BIND_NAME = "BlockingPersistenceManager";
-
-   // --------------------------------------------------------------------------------||
-   // Required Implementations -------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   /* (non-Javadoc)
-    * @see org.jboss.ejb3.cache.persistence.PersistenceManagerFactory#createPersistenceManager()
-    */
-   public StatefulSessionPersistenceManager createPersistenceManager()
-   {
-      return new BlockingPersistenceManager();
-   }
-
-}

Added: projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/BlockingPersistentObjectStore.java
===================================================================
--- projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/BlockingPersistentObjectStore.java	                        (rev 0)
+++ projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/BlockingPersistentObjectStore.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -0,0 +1,175 @@
+/*
+ * 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.core.test.ejbthree1549;
+
+import java.io.IOException;
+import java.rmi.MarshalledObject;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+import javax.ejb.EJBException;
+
+import org.jboss.ejb3.cache.CacheItem;
+import org.jboss.ejb3.cache.spi.PersistentObjectStore;
+import org.jboss.ejb3.stateful.StatefulBeanContext;
+import org.jboss.logging.Logger;
+
+/**
+ * BlockingPersistenceManager
+ * 
+ * An implementation of a PersistenceManager which, instead of
+ * persisting directly, exposes a blocking mechanism allowing 
+ * tests to control when passivation occurs 
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class BlockingPersistentObjectStore<T extends CacheItem> implements PersistentObjectStore<T>
+{
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private static final Logger log = Logger.getLogger(BlockingPersistentObjectStore.class);
+
+   /**
+    * Publicly-accessible lock
+    * 
+    * Used by the test to block the act of passivation
+    */
+   public static final Lock PASSIVATION_LOCK = new ReentrantLock();
+
+   /**
+    * Publicly-accessible barrier
+    * 
+    * Will block until both the test and the PM agree that passivation 
+    * should take place
+    */
+   public static final CyclicBarrier BARRIER = new CyclicBarrier(2);
+   
+   private Map<Object, MarshalledObject> passivated = new ConcurrentHashMap<Object, MarshalledObject>();
+
+   // --------------------------------------------------------------------------------||
+   // Required Implementations -------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   public T load(Object id)
+   {
+      log.info("Activating " + id);
+      MarshalledObject o = passivated.remove(id);
+      if(o == null)
+         throw new EJBException("Can't find bean " + id);
+      try
+      {
+         return (T) o.get();
+      }
+      catch (IOException e)
+      {
+         throw new EJBException(e);
+      }
+      catch (ClassNotFoundException e)
+      {
+         throw new EJBException(e);
+      }
+   }
+
+   public List<StatefulBeanContext> getPassivatedBeans()
+   {
+      // very stupid and slow, don't do this
+      throw new RuntimeException("NYI");
+   }
+   
+   public void store(T ctx)
+   {
+
+      try
+      {
+         /*
+          * Block until the lock may be acquired,
+          * may currently be held by the test Thread until the test is ready.
+          * So here both the test and passivation will block until this barrier
+          * is agreed by both Threads to be released
+          */
+         log.info("Waiting until the test is ready for passivation to start...");
+         try
+         {
+            BARRIER.await();
+         }
+         catch (BrokenBarrierException e1)
+         {
+            log.debug("BARRIER was broken");
+         }
+
+         // Block until the test releases this lock
+         log.info("Blocking until the test tells us that the act of passivation may continue...");
+         PASSIVATION_LOCK.lock();
+
+         try
+         {
+            // Mock Passivate
+            log.info("Mock Passivation on " + ctx.getId());
+            passivated.put(ctx.getId(), new MarshalledObject(ctx));
+         }
+         catch(IOException e)
+         {
+            throw new EJBException(e);
+         }
+         finally
+         {
+            // Release the passivation lock
+            log.info("We're done with passivation, letting the lock go.");
+            PASSIVATION_LOCK.unlock();
+         }
+      }
+      catch (InterruptedException e)
+      {
+         throw new RuntimeException("Barrier was interrupted prematurely", e);
+      }
+      finally
+      {
+         // Reset the Barrier
+         BARRIER.reset();
+      }
+   }
+
+   public void start()
+   {
+   }
+
+   public void stop()
+   {
+      passivated.clear();
+   }
+   
+   public void removePassivated(Object id)
+   {
+      MarshalledObject o = passivated.remove(id);
+      if(o == null)
+         throw new EJBException("Can't find bean " + id);
+   }
+
+}


Property changes on: projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/BlockingPersistentObjectStore.java
___________________________________________________________________
Name: svn:keywords
   + 

Added: projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/ForceEventsBackingCacheEntryStore.java
===================================================================
--- projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/ForceEventsBackingCacheEntryStore.java	                        (rev 0)
+++ projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/ForceEventsBackingCacheEntryStore.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -0,0 +1,310 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.core.test.ejbthree1549;
+
+import java.io.Serializable;
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CyclicBarrier;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.cache.impl.backing.SimpleBackingCacheEntryStore;
+import org.jboss.ejb3.cache.spi.BackingCacheEntry;
+import org.jboss.ejb3.cache.spi.PersistentObjectStore;
+import org.jboss.ejb3.cache.spi.impl.AbstractBackingCacheEntry;
+import org.jboss.ejb3.stateful.StatefulBeanContext;
+import org.jboss.logging.Logger;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class ForceEventsBackingCacheEntryStore<T extends BackingCacheEntry<StatefulBeanContext>> 
+   extends SimpleBackingCacheEntryStore<StatefulBeanContext, T>
+{
+   private static final Object START_PASSIVATION_LOCK = new Object();
+   
+   private static volatile boolean passivationForced = false;
+   
+   private static final Logger log = Logger.getLogger(ForceEventsBackingCacheEntryStore.class);
+   
+   /**
+    * Shared barrier between the Cache and the test so that 
+    * the test may block until passivation is completed
+    */
+   public static final CyclicBarrier POST_PASSIVATE_BARRIER = new CyclicBarrier(2);
+
+   public static final CyclicBarrier PRE_PASSIVATE_BARRIER = new CyclicBarrier(2);
+
+   /**
+    * Public barrier for removal to block until both test and removal tasks are ready
+    */
+   public static final CyclicBarrier PRE_REMOVE_BARRIER = new CyclicBarrier(2);
+   
+   private boolean blockOnExpiration;
+   private boolean blockOnPassivation;
+   
+   /**
+    * Create a new SimpleIntegratedObjectStore.
+    */
+   public ForceEventsBackingCacheEntryStore(PersistentObjectStore<T> store, 
+                                                 CacheConfig config,
+                                                 String name,
+                                                 boolean forGroups)
+   {
+      super(store, config, name, forGroups);  
+   }
+   
+   public static void triggerPassivationExpiration()
+   {
+      // Get a lock
+      log.info("Awaiting lock to force passivation");
+      synchronized (START_PASSIVATION_LOCK)
+      {
+         passivationForced = true;
+         // Notify that passivation should run
+         log.info("Notifying passivation via manual force...");
+         START_PASSIVATION_LOCK.notifyAll();
+      }
+      
+   }
+
+   @Override
+   public void processPassivationExpiration()
+   {
+      // Get a lock on our monitor
+      synchronized (START_PASSIVATION_LOCK)
+      {
+         if (!passivationForced)
+         {
+            // Wait until we're signaled
+            log.info("Waiting to be notified to run passivation...");
+            try
+            {
+               START_PASSIVATION_LOCK.wait();
+            }
+            catch (InterruptedException e)
+            {
+               log.error(e);
+               return;
+            }
+         }
+         passivationForced = false;
+      }
+      
+      super.processPassivationExpiration();
+   }
+
+
+
+   public boolean isBlockOnExpiration()
+   {
+      return blockOnExpiration;
+   }
+
+
+
+   public void setBlockOnExpiration(boolean blockOnExpiration)
+   {
+      this.blockOnExpiration = blockOnExpiration;
+   }
+
+
+
+   public boolean isBlockOnPassivation()
+   {
+      return blockOnPassivation;
+   }
+
+
+
+   public void setBlockOnPassivation(boolean blockOnPassivation)
+   {
+      this.blockOnPassivation = blockOnPassivation;
+   }
+
+
+
+   /**
+    * Manually sets the session with the specified sessionId
+    * past expiry for passivation
+    * 
+    * @param sessionId
+    */
+   public void makeSessionEligibleForPassivation(Serializable sessionId)
+   {
+      this.setSessionLastUsedPastTimeout(sessionId, this.getIdleTimeSeconds());
+   }
+
+   /**
+    * Manually sets the session with the specified sessionId
+    * past expiry for removal
+    * 
+    * @param sessionId
+    */
+   public void makeSessionEligibleForRemoval(Serializable sessionId)
+   {
+      this.setSessionLastUsedPastTimeout(sessionId, this.getExpirationTimeSeconds());
+   }
+
+   /**
+    * Expose as public for unit test.
+    */
+   @Override
+   public boolean containsInMemoryEntry(Object key)
+   {
+      return super.containsInMemoryEntry(key);
+   }
+
+   /**
+    * Expose as public for unit test.
+    */
+   @Override
+   public void clear()
+   {
+      super.clear();
+      
+      this.blockOnExpiration = false;
+      this.blockOnPassivation = false;
+   }
+
+   @Override
+   protected void expirationCompleted()
+   {
+      super.expirationCompleted();
+   }
+
+   @Override
+   protected void passivationCompleted()
+   {
+      // Call super
+      super.passivationCompleted();
+
+      if (blockOnPassivation)
+      {
+         // Tell the barrier we've arrived
+         try
+         {
+            log.info("Waiting on the post-passivate barrier...");
+            POST_PASSIVATE_BARRIER.await();
+         }
+         catch (InterruptedException e)
+         {
+            throw new RuntimeException("Post Passivate prematurely interrupted", e);
+         }
+         catch (BrokenBarrierException e)
+         {
+            throw new RuntimeException("Post Passivate prematurely broken", e);
+         }
+         finally
+         {
+            // Reset the barrier
+            log.info("Post-passivate of PM is done, resetting the barrier");
+            POST_PASSIVATE_BARRIER.reset();
+         }
+      }
+   }
+
+   @Override
+   protected void preExpirationCompleted()
+   {
+      if (blockOnExpiration)
+      {
+         // Block until the barrier is cleared
+         try
+         {
+            PRE_REMOVE_BARRIER.await();
+         }
+         catch (InterruptedException e)
+         {
+            throw new RuntimeException(e);
+         }
+         catch (BrokenBarrierException e)
+         {
+            throw new RuntimeException(e);
+         }
+      }
+      
+      // Invoke super implementation
+      super.preExpirationCompleted();
+   }
+
+   @Override
+   protected void prePassivationCompleted()
+   {
+      super.prePassivationCompleted();
+
+      if (blockOnPassivation)
+      {
+         try
+         {
+            PRE_PASSIVATE_BARRIER.await();
+         }
+         catch (BrokenBarrierException e)
+         {
+            throw new RuntimeException("PRE_PASSIVATE_BARRIER prematurely broken", e);
+         }
+         catch (InterruptedException e)
+         {
+            throw new RuntimeException(e);
+         }
+      }
+   }
+   /**
+    * Obtains a time in the past further away than the specified timeout value,
+    * expressed in milliseconds since the epoch (per contract of System.currentTimeMillis()
+    * 
+    * @param timeoutValue
+    * @return
+    */
+   private long getExpiredTime(long timeoutValue)
+   {
+      long now = System.currentTimeMillis();
+      return (now - (timeoutValue * 1000)) - 1;
+   }
+
+   /**
+    * Marks the session with the specified ID as last used past the 
+    * specified timeout period
+    * 
+    * @param sessionId
+    * @param timeout
+    */
+   private void setSessionLastUsedPastTimeout(Serializable sessionId, long timeout)
+   {
+      // Find the session
+      @SuppressWarnings("unchecked")
+      AbstractBackingCacheEntry entry = (AbstractBackingCacheEntry) getBackingCacheEntry(sessionId);
+
+      // Synchronize on the session
+      synchronized (entry)
+      {
+         // Manually set past expiry
+         entry.setLastUsed(this.getExpiredTime(timeout));
+      }
+   }
+   
+   
+
+   
+   
+}


Property changes on: projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/ForceEventsBackingCacheEntryStore.java
___________________________________________________________________
Name: svn:keywords
   + 

Added: projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/ForceEventsBackingCacheEntryStoreSource.java
===================================================================
--- projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/ForceEventsBackingCacheEntryStoreSource.java	                        (rev 0)
+++ projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/ForceEventsBackingCacheEntryStoreSource.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -0,0 +1,98 @@
+/*
+ * 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.core.test.ejbthree1549;
+
+import java.lang.ref.WeakReference;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.transaction.TransactionManager;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.cache.CacheItem;
+import org.jboss.ejb3.cache.spi.BackingCacheEntryStore;
+import org.jboss.ejb3.cache.spi.BackingCacheEntryStoreSource;
+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;
+import org.jboss.ejb3.stateful.StatefulBeanContext;
+
+/**
+ * {@link BackingCacheEntryStoreSource} for a non-clustered cache. Uses
+ * a {@link FilePersistentObjectStore} store for persistence.
+ * 
+ * @author Brian Stansberry
+ */
+public class ForceEventsBackingCacheEntryStoreSource 
+   implements BackingCacheEntryStoreSource<StatefulBeanContext>
+{
+   private Map<String, WeakReference<ForceEventsBackingCacheEntryStore<SerializationGroup<StatefulBeanContext>>>> groupStores =
+      new HashMap<String, WeakReference<ForceEventsBackingCacheEntryStore<SerializationGroup<StatefulBeanContext>>>>();
+   
+   private Map<String, WeakReference<ForceEventsBackingCacheEntryStore<SerializationGroupMember<StatefulBeanContext>>>> groupMemberStores =
+      new HashMap<String, WeakReference<ForceEventsBackingCacheEntryStore<SerializationGroupMember<StatefulBeanContext>>>>();
+   
+   public ForceEventsBackingCacheEntryStore<SerializationGroup<StatefulBeanContext>> getGroupStore(String containerName)
+   {
+      WeakReference<ForceEventsBackingCacheEntryStore<SerializationGroup<StatefulBeanContext>>> ref = groupStores.get(containerName);
+      return ref == null ? null : ref.get();
+   }
+   
+   public ForceEventsBackingCacheEntryStore<SerializationGroupMember<StatefulBeanContext>> getGroupMemberStore(String containerName)
+   {
+      WeakReference<ForceEventsBackingCacheEntryStore<SerializationGroupMember<StatefulBeanContext>>> ref = groupMemberStores.get(containerName);
+      return ref == null ? null : ref.get();
+   }
+   
+   public BackingCacheEntryStore<StatefulBeanContext, SerializationGroup<StatefulBeanContext>> createGroupIntegratedObjectStore(String containerName, String cacheConfigName,
+         CacheConfig cacheConfig, TransactionManager transactionManager, SynchronizationCoordinator synchronizationCoordinator)
+   {
+      BlockingPersistentObjectStore<SerializationGroup<StatefulBeanContext>> objectStore = new BlockingPersistentObjectStore<SerializationGroup<StatefulBeanContext>>();
+      
+      String storeNameSuffix = (cacheConfig.name().length() == 0) ? "" : "-" + cacheConfig;
+      String storeName = "StdGroupStore" + storeNameSuffix;
+      ForceEventsBackingCacheEntryStore<SerializationGroup<StatefulBeanContext>> store = 
+         new ForceEventsBackingCacheEntryStore<SerializationGroup<StatefulBeanContext>>(objectStore, cacheConfig, storeName, true);
+      
+      groupStores.put(containerName, new WeakReference<ForceEventsBackingCacheEntryStore<SerializationGroup<StatefulBeanContext>>>(store));
+      
+      return store;
+   }
+
+   public BackingCacheEntryStore<StatefulBeanContext, SerializationGroupMember<StatefulBeanContext>> createIntegratedObjectStore(String containerName, String cacheConfigName,
+         CacheConfig cacheConfig, TransactionManager transactionManager, SynchronizationCoordinator synchronizationCoordinator)
+   {
+      BlockingPersistentObjectStore<SerializationGroupMember<StatefulBeanContext>> objectStore = new BlockingPersistentObjectStore<SerializationGroupMember<StatefulBeanContext>>();
+      
+      ForceEventsBackingCacheEntryStore<SerializationGroupMember<StatefulBeanContext>> store = 
+         new ForceEventsBackingCacheEntryStore<SerializationGroupMember<StatefulBeanContext>>(objectStore, cacheConfig, containerName, false);
+      
+      store.setInterval(1);
+      
+      groupMemberStores.put(containerName, new WeakReference<ForceEventsBackingCacheEntryStore<SerializationGroupMember<StatefulBeanContext>>>(store));
+      
+      return store;
+   }
+   
+}


Property changes on: projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/ForceEventsBackingCacheEntryStoreSource.java
___________________________________________________________________
Name: svn:keywords
   + 

Deleted: projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/ForceEventsCache.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/ForceEventsCache.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/ForceEventsCache.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -1,375 +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.core.test.ejbthree1549;
-
-import java.io.Serializable;
-import java.util.concurrent.BrokenBarrierException;
-import java.util.concurrent.CyclicBarrier;
-
-import org.jboss.ejb3.cache.simple.SimpleStatefulCache;
-import org.jboss.ejb3.stateful.StatefulBeanContext;
-import org.jboss.logging.Logger;
-
-/**
- * ForceEventsCache
- * 
- * An extension of the SimpleStatefulCache which provides for
- * forcing the Passivation and Removal tasks to run, also supplanting
- * barriers and locks throughout the tasks' lifecycle callbacks
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class ForceEventsCache extends SimpleStatefulCache
-{
-   // --------------------------------------------------------------------------------||
-   // Class Members ------------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   private static final Logger log = Logger.getLogger(ForceEventsCache.class);
-
-   /**
-    * Shared barrier between the Cache and the test so that 
-    * the test may block until passivation is completed
-    */
-   public static final CyclicBarrier POST_PASSIVATE_BARRIER = new CyclicBarrier(2);
-
-   /**
-    * Internal lock used to manually block the passivation task from running
-    */
-   private static final Object START_PASSIVATION_LOCK = new Object();
-
-   private static volatile boolean passivationForced = false;
-
-   /**
-    * Internal lock used to manually block the removal task from running
-    */
-   private static final Object START_REMOVAL_LOCK = new Object();
-
-   /**
-    * Flag that removal has been forced
-    */
-   private static volatile boolean removalForced = false;
-
-   public static final CyclicBarrier PRE_PASSIVATE_BARRIER = new CyclicBarrier(2);
-
-   /**
-    * Public barrier for removal to block until both test and removal tasks are ready
-    */
-   public static final CyclicBarrier PRE_REMOVE_BARRIER = new CyclicBarrier(2);
-
-   // --------------------------------------------------------------------------------||
-   // Functional Methods -------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   public void clear()
-   {
-      cacheMap.clear();
-   }
-
-   /**
-    * Triggers passivation to run
-    */
-   public static void forcePassivation()
-   {
-      // Get a lock
-      log.info("Awaiting lock to force passivation");
-      synchronized (START_PASSIVATION_LOCK)
-      {
-         passivationForced = true;
-         // Notify that passivation should run
-         log.info("Notifying passivation via manual force...");
-         START_PASSIVATION_LOCK.notify();
-      }
-   }
-
-   /**
-    * Triggers removal to run
-    */
-   public static void forceRemoval()
-   {
-      // Get a lock
-      log.info("Awaiting lock to force removal");
-      synchronized (START_REMOVAL_LOCK)
-      {
-         removalForced = true;
-         // Notify that removal should run
-         log.info("Notifying removal via manual force...");
-         START_REMOVAL_LOCK.notify();
-      }
-   }
-
-   /**
-    * Manually sets the session with the specified sessionId
-    * past expiry for passivation
-    * 
-    * @param sessionId
-    */
-   public void makeSessionEligibleForPassivation(Serializable sessionId)
-   {
-      this.setSessionLastUsedPastTimeout(sessionId, this.getSessionTimeout());
-   }
-
-   /**
-    * Manually sets the session with the specified sessionId
-    * past expiry for removal
-    * 
-    * @param sessionId
-    */
-   public void makeSessionEligibleForRemoval(Serializable sessionId)
-   {
-      this.setSessionLastUsedPastTimeout(sessionId, this.getRemovalTimeout());
-   }
-
-   /**
-    * Exposed for testing only
-    * 
-    * Returns whether or not the internal cacheMap contains
-    * the specified key
-    * 
-    * @return
-    */
-   public boolean doesCacheMapContainKey(Serializable sessionId)
-   {
-      // Get the cacheMap
-      CacheMap cm = this.cacheMap;
-
-      // Synchronize on it
-      synchronized (cm)
-      {
-         // Return whether the specified key was found
-         return cm.containsKey(sessionId);
-      }
-   }
-
-   // --------------------------------------------------------------------------------||
-   // Overridden Implementations -----------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   /**
-    * Lifecycle start, overridden to switch up the Passivate and Removal tasks to
-    * test-specific implementations
-    */
-   @Override
-   public void start()
-   {
-      // Initialize
-      String threadNamePrefix = "EJBTHREE-1549 SFSB Thread: ";
-
-      // Switch up the Passivation and Removal Tasks to blocking implementations
-      this.setTimeoutTask(new BlockingPassivationTask(threadNamePrefix + "PASSIVATION"));
-      this.setRemovalTask(new BlockingRemovalTask(threadNamePrefix + "REMOVAL"));
-
-      // Call super implementation
-      super.start();
-
-   }
-
-   /**
-    * BlockingRemovalTask
-    * 
-    * An extension of the default removal task which, instead 
-    * of waiting for a timeout, will block until forced
-    *
-    * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
-    * @version $Revision: $
-    */
-   private class BlockingRemovalTask extends RemovalTimeoutTask
-   {
-      public BlockingRemovalTask(String name)
-      {
-         super(name);
-      }
-
-      @Override
-      public void block() throws InterruptedException
-      {
-         // Get a lock on our monitor
-         synchronized (START_REMOVAL_LOCK)
-         {
-            if (!removalForced)
-            {
-               // Wait until we're signaled
-               log.info("Waiting to be notified to run removal...");
-               START_REMOVAL_LOCK.wait();
-            }
-            removalForced = false;
-         }
-
-         // Log that we've been notified
-         log.info("Notified to run removal");
-      }
-
-      @Override
-      protected void preRemoval()
-      {
-
-         // Block until the barrier is cleared
-         try
-         {
-            PRE_REMOVE_BARRIER.await();
-         }
-         catch (InterruptedException e)
-         {
-            throw new RuntimeException(e);
-         }
-         catch (BrokenBarrierException e)
-         {
-            throw new RuntimeException(e);
-         }
-
-         // Invoke super implementation
-         super.preRemoval();
-      }
-
-   }
-
-   /**
-    * BlockingPassivationTask
-    * 
-    * An extension of the default timeout task which, instead of 
-    * waiting for a timeout, will await (block until) notification that passivation
-    * should run
-    *
-    * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
-    * @version $Revision: $
-    */
-   private class BlockingPassivationTask extends SessionTimeoutTask
-   {
-
-      public BlockingPassivationTask(String name)
-      {
-         super(name);
-      }
-
-      @Override
-      public void block() throws InterruptedException
-      {
-         // Get a lock on our monitor
-         synchronized (START_PASSIVATION_LOCK)
-         {
-            if (!passivationForced)
-            {
-               // Wait until we're signaled
-               log.info("Waiting to be notified to run passivation...");
-               START_PASSIVATION_LOCK.wait();
-            }
-            passivationForced = false;
-         }
-
-         // Log that we've been notified
-         log.info("Notified to run passivation");
-      }
-
-      @Override
-      protected void passivationCompleted()
-      {
-         // Call super
-         super.passivationCompleted();
-
-         // Tell the barrier we've arrived
-         try
-         {
-            log.info("Waiting on the post-passivate barrier...");
-            POST_PASSIVATE_BARRIER.await();
-         }
-         catch (InterruptedException e)
-         {
-            throw new RuntimeException("Post Passivate prematurely interrupted", e);
-         }
-         catch (BrokenBarrierException e)
-         {
-            throw new RuntimeException("Post Passivate prematurely broken", e);
-         }
-         finally
-         {
-            // Reset the barrier
-            log.info("Post-passivate of PM is done, resetting the barrier");
-            POST_PASSIVATE_BARRIER.reset();
-         }
-      }
-
-      @Override
-      protected void prePassivationCompleted()
-      {
-         super.prePassivationCompleted();
-
-         try
-         {
-            PRE_PASSIVATE_BARRIER.await();
-         }
-         catch (BrokenBarrierException e)
-         {
-            throw new RuntimeException("PRE_PASSIVATE_BARRIER prematurely broken", e);
-         }
-         catch (InterruptedException e)
-         {
-            throw new RuntimeException(e);
-         }
-      }
-   }
-
-   // --------------------------------------------------------------------------------||
-   // Internal Helper Methods --------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   /**
-    * Obtains a time in the past further away than the specified timeout value,
-    * expressed in milliseconds since the epoch (per contract of System.currentTimeMillis()
-    * 
-    * @param timeoutValue
-    * @return
-    */
-   private long getExpiredTime(long timeoutValue)
-   {
-      long now = System.currentTimeMillis();
-      return (now - (timeoutValue * 1000)) - 1;
-   }
-
-   /**
-    * Marks the session with the specified ID as last used past the 
-    * specified timeout period
-    * 
-    * @param sessionId
-    * @param timeout
-    */
-   private void setSessionLastUsedPastTimeout(Serializable sessionId, long timeout)
-   {
-      // Get the cacheMap
-      CacheMap cm = this.cacheMap;
-
-      // Synchronize on it
-      synchronized (cm)
-      {
-         // Find the session
-         StatefulBeanContext session = (StatefulBeanContext) cm.get(sessionId);
-
-         // Synchronize on the session
-         synchronized (session)
-         {
-            // Manually set past expiry
-            session.lastUsed = this.getExpiredTime(timeout);
-         }
-      }
-   }
-
-}
\ No newline at end of file

Modified: projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/ForceEventsCacheFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/ForceEventsCacheFactory.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/ForceEventsCacheFactory.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -21,8 +21,8 @@
  */
 package org.jboss.ejb3.core.test.ejbthree1549;
 
-import org.jboss.ejb3.cache.Ejb3CacheFactory;
-import org.jboss.ejb3.cache.StatefulCache;
+import org.jboss.ejb3.cache.impl.factory.GroupAwareCacheFactory;
+import org.jboss.ejb3.stateful.StatefulBeanContext;
 
 /**
  * ForceEventsCacheFactory
@@ -30,9 +30,11 @@
  * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
  * @version $Revision: $
  */
-public class ForceEventsCacheFactory implements Ejb3CacheFactory
+public class ForceEventsCacheFactory extends GroupAwareCacheFactory<StatefulBeanContext>
 {
-
+   public static final ForceEventsBackingCacheEntryStoreSource storeSource = 
+      new ForceEventsBackingCacheEntryStoreSource();
+   
    // --------------------------------------------------------------------------------||
    // Class Members ------------------------------------------------------------------||
    // --------------------------------------------------------------------------------||
@@ -42,17 +44,12 @@
     */
    public static final String REGISTRY_BIND_NAME = "ForceEventsCache";
 
-   // --------------------------------------------------------------------------------||
-   // Required Implementations -------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   /*
-    * (non-Javadoc)
-    * @see org.jboss.ejb3.cache.Ejb3CacheFactory#createCache()
-    */
-   public StatefulCache createCache()
+   public ForceEventsCacheFactory()
    {
-      return new ForceEventsCache();
+      super(storeSource);
+      setDefaultPassivationExpirationInterval(0);
    }
+   
+   
 
 }

Modified: projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/MyStatefulBean.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/MyStatefulBean.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/MyStatefulBean.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -58,12 +58,6 @@
  * Make instances eligible for timeout very soon after last invocation, and be removed (as default is NEVER)
  */
 @CacheConfig(idleTimeoutSeconds = MyStatefulLocal.PASSIVATION_TIMEOUT, removalTimeoutSeconds = MyStatefulLocal.REMOVAL_TIMEOUT)
-/*
- * Set up a persistence manager that allows us to block, and therefore
- * lets the test decide how long the processes of performing passivation
- * should take.  Used to manually interleave Threads to target the test case.
- */
- at PersistenceManager(BlockingPersistenceManagerFactory.REGISTRY_BIND_NAME)
 public class MyStatefulBean implements MyStatefulLocal
 {
    // --------------------------------------------------------------------------------||

Modified: projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/unit/PassivationDoesNotPreventNewActivityUnitTestCase.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/unit/PassivationDoesNotPreventNewActivityUnitTestCase.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/unit/PassivationDoesNotPreventNewActivityUnitTestCase.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -33,19 +33,28 @@
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.transaction.TransactionManager;
+
 import junit.framework.TestCase;
 
 import org.jboss.ejb3.cache.CacheFactoryRegistry;
-import org.jboss.ejb3.cache.persistence.PersistenceManagerFactoryRegistry;
+import org.jboss.ejb3.cache.spi.SerializationGroupMember;
+import org.jboss.ejb3.cache.spi.impl.AbstractStatefulCacheFactory;
+import org.jboss.ejb3.cache.spi.impl.JndiTransactionSynchronizationRegistrySource;
+import org.jboss.ejb3.cache.spi.impl.SynchronizationCoordinatorImpl;
+import org.jboss.ejb3.cache.spi.impl.TransactionSynchronizationRegistrySource;
 import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.common.registrar.spi.NotBoundException;
 import org.jboss.ejb3.core.test.common.AbstractEJB3TestCase;
-import org.jboss.ejb3.core.test.ejbthree1549.BlockingPersistenceManager;
-import org.jboss.ejb3.core.test.ejbthree1549.BlockingPersistenceManagerFactory;
-import org.jboss.ejb3.core.test.ejbthree1549.ForceEventsCache;
+import org.jboss.ejb3.core.test.ejbthree1549.BlockingPersistentObjectStore;
+import org.jboss.ejb3.core.test.ejbthree1549.ForceEventsBackingCacheEntryStore;
 import org.jboss.ejb3.core.test.ejbthree1549.ForceEventsCacheFactory;
 import org.jboss.ejb3.core.test.ejbthree1549.MyStatefulBean;
 import org.jboss.ejb3.core.test.ejbthree1549.MyStatefulLocal;
 import org.jboss.ejb3.proxy.handler.session.stateful.StatefulLocalProxyInvocationHandler;
+import org.jboss.ejb3.stateful.StatefulBeanContext;
 import org.jboss.ejb3.stateful.StatefulContainer;
 import org.jboss.logging.Logger;
 import org.junit.After;
@@ -59,6 +68,11 @@
  * Contains tests to ensure that performing passivation does not 
  * block either new session creation or invocation in other sessions
  *
+ * FIXME: These tests were originally written around the old SimpleStatefulCache
+ * and poked a lot into their internals. Move them into the cache module and
+ * try to get them out of the internals. Redo the commented out test method
+ * testSessionRemovalDuringPassivation.
+ * 
  * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
  * @version $Revision: $
  */
@@ -80,120 +94,118 @@
     * Tests that removal may take place during the course 
     * of passivation
     */
-   @Test
-   public void testSessionRemovalDuringPassivation() throws Throwable
-   {
-      /*
-       * First we invoke upon a new session
-       */
+   // BES 2009/02/17 Disabled as this assumes there is a separate thread
+   // for removals and passivations
+//   @Test
+//   public void testSessionRemovalDuringPassivation() throws Throwable
+//   {
+//      /*
+//       * First we invoke upon a new session
+//       */
+//
+//      // Initialize
+//      final String sfsbJndiName = MyStatefulLocal.JNDI_NAME;
+//
+//      // Create a new session, which should be allowed during passivation
+//      MyStatefulLocal sfsb = (MyStatefulLocal) container.getInitialContext().lookup(sfsbJndiName);
+//
+//      // If we've got nothing
+//      if (sfsb == null)
+//      {
+//         // Fail
+//         TestCase.fail("Lookup did not succeed");
+//      }
+//
+//      // Invoke upon the new Session
+//      final int next = sfsb.getNextCounter();
+//
+//      // Test the value is expected
+//      TestCase.assertEquals("Next counter received was not expected", 0, next);
+//
+//      /*
+//       * Mark this session as eligible for removal
+//       */
+//
+//      // Get the store
+//      final ForceEventsBackingCacheEntryStore store = ForceEventsCacheFactory.storeSource.getGroupMemberStore(container.getName());
+//      store.setBlockOnExpiration(true);
+//      store.setBlockOnPassivation(true);
+//
+//      // Get the Session ID
+//      Serializable sessionId = this.getSessionId(sfsb);
+//
+//      // Mark
+//      store.makeSessionEligibleForRemoval(sessionId);
+//
+//      /*
+//       * All's OK with traditional invocation, so define a task to force removal 
+//       * of the SFSB, but don't invoke it yet (we're going to fire this off 
+//       * *during* passivation
+//       */
+//
+//      // Define the task to invoke upon a SFSB, and trigger removal while passivation is suspended
+//      Callable<Boolean> invokeDuringPasssivationTest = new Callable<Boolean>()
+//      {
+//         /**
+//          * Force removal
+//          */
+//         public Boolean call()
+//         {
+////            ForceEventsBackingCacheEntryStore.triggerPassivationExpiration();
+//
+//            // Clear the barrier
+//            try
+//            {
+//               log.info("Test is waiting on the pre-remove barrier");
+//               ForceEventsBackingCacheEntryStore.PRE_REMOVE_BARRIER.await();
+//               log.info("Test has cleared the pre-remove barrier");
+//            }
+//            catch (InterruptedException e)
+//            {
+//               throw new RuntimeException(e);
+//            }
+//            catch (BrokenBarrierException e)
+//            {
+//               throw new RuntimeException(e);
+//            }
+//
+//            // Return OK
+//            return true;
+//
+//         }
+//      };
+//
+//      /*
+//       * Force passivation, but block it from completing (because we don't 
+//       * await on the PM)
+//       */
+//      
+//      // Force passivation
+//      ForceEventsBackingCacheEntryStore.triggerPassivationExpiration();
+//      ForceEventsBackingCacheEntryStore.PRE_PASSIVATE_BARRIER.await();
+//      
+//
+//      /*
+//       * Spawn off the test in another Thread
+//       */
+//
+//      ExecutorService executor = Executors.newFixedThreadPool(1);
+//      Future<Boolean> futureResult = executor.submit(invokeDuringPasssivationTest);
+//      Boolean result = null;
+//
+//      /*
+//       * Try to get the result of the test to remove, which 
+//       * should not be blocked by passivation already in progress
+//       */
+//
+//      // Get result
+//      log.info("Attempting to get the result of the removal task...");
+//      result = futureResult.get(5, TimeUnit.SECONDS);
+//
+//      // Make sure the result is expected
+//      TestCase.assertTrue("Removal task completed when expected, but got wrong result", result);
+//   }
 
-      // Initialize
-      final String sfsbJndiName = MyStatefulLocal.JNDI_NAME;
-
-      // Create a new session, which should be allowed during passivation
-      MyStatefulLocal sfsb = (MyStatefulLocal) container.getInitialContext().lookup(sfsbJndiName);
-
-      // If we've got nothing
-      if (sfsb == null)
-      {
-         // Fail
-         TestCase.fail("Lookup did not succeed");
-      }
-
-      // Invoke upon the new Session
-      final int next = sfsb.getNextCounter();
-
-      // Test the value is expected
-      TestCase.assertEquals("Next counter received was not expected", 0, next);
-
-      /*
-       * Mark this session as eligible for removal
-       */
-
-      // Get the cache
-      ForceEventsCache cache = (ForceEventsCache) container.getCache();
-
-      // Get the Session ID
-      Serializable sessionId = this.getSessionId(sfsb);
-
-      // Mark
-      cache.makeSessionEligibleForRemoval(sessionId);
-
-      /*
-       * All's OK with traditional invocation, so define a task to force removal 
-       * of the SFSB, but don't invoke it yet (we're going to fire this off 
-       * *during* passivation
-       */
-
-      // Define the task to invoke upon a SFSB, and trigger removal while passivation is suspended
-      Callable<Boolean> invokeDuringPasssivationTest = new Callable<Boolean>()
-      {
-         /**
-          * Force removal
-          */
-         public Boolean call()
-         {
-
-            /*
-             * Force removal
-             */
-
-            // Force
-            ForceEventsCache.forceRemoval();
-
-            // Clear the barrier
-            try
-            {
-               log.info("Test is waiting on the pre-remove barrier");
-               ForceEventsCache.PRE_REMOVE_BARRIER.await();
-               log.info("Test has cleared the pre-remove barrier");
-            }
-            catch (InterruptedException e)
-            {
-               throw new RuntimeException(e);
-            }
-            catch (BrokenBarrierException e)
-            {
-               throw new RuntimeException(e);
-            }
-
-            // Return OK
-            return true;
-
-         }
-      };
-
-      /*
-       * Force passivation, but block it from completing (because we don't 
-       * await on the PM)
-       */
-      
-      // Force passivation
-      ForceEventsCache.forcePassivation();
-      ForceEventsCache.PRE_PASSIVATE_BARRIER.await();
-      
-
-      /*
-       * Spawn off the test in another Thread
-       */
-
-      ExecutorService executor = Executors.newFixedThreadPool(1);
-      Future<Boolean> futureResult = executor.submit(invokeDuringPasssivationTest);
-      Boolean result = null;
-
-      /*
-       * Try to get the result of the test to remove, which 
-       * should not be blocked by passivation already in progress
-       */
-
-      // Get result
-      log.info("Attempting to get the result of the removal task...");
-      result = futureResult.get(5, TimeUnit.SECONDS);
-
-      // Make sure the result is expected
-      TestCase.assertTrue("Removal task completed when expected, but got wrong result", result);
-   }
-
    @Test
    public void testInvokeSameSessionDuringPassivation() throws Throwable
    {
@@ -209,11 +221,13 @@
       log.info("Got counter from " + sessionId + ": " + next);
       TestCase.assertEquals("SFSB did not return expected next counter", 0, next);
 
-      // Get the Cache
-      ForceEventsCache cache = (ForceEventsCache) container.getCache();
-
+      // Get the store
+      ForceEventsBackingCacheEntryStore<SerializationGroupMember<StatefulBeanContext>> store = 
+         ForceEventsCacheFactory.storeSource.getGroupMemberStore(container.getName());
+      store.setBlockOnPassivation(true);
+      
       // Get the lock to block the PM, now
-      boolean gotLock = BlockingPersistenceManager.PASSIVATION_LOCK.tryLock();
+      boolean gotLock = BlockingPersistentObjectStore.PASSIVATION_LOCK.tryLock();
 
       Future<Integer> result;
       // Once PM lock is acquired, everything is in "try" so we release in "finally"
@@ -221,24 +235,24 @@
       {
          // Ensure we got the PM lock, else fail the test
          TestCase.assertTrue("Test was not able to immediately get the lock to block the PersistenceManager", gotLock);
-         log.info("Locked " + BlockingPersistenceManager.class.getSimpleName());
+         log.info("Locked " + BlockingPersistentObjectStore.class.getSimpleName());
 
          // Mark
-         cache.makeSessionEligibleForPassivation(sessionId);
+         store.makeSessionEligibleForPassivation(sessionId);
 
          /*
           * Passivate
           */
 
          // Trigger Passivation
-         ForceEventsCache.forcePassivation();
+         ForceEventsBackingCacheEntryStore.triggerPassivationExpiration();
          log.info("Passivation forced, carrying out test");
 
-         ForceEventsCache.PRE_PASSIVATE_BARRIER.await(5, TimeUnit.SECONDS);
+         ForceEventsBackingCacheEntryStore.PRE_PASSIVATE_BARRIER.await(5, TimeUnit.SECONDS);
 
          // Block until the PM is ready to passivate
          log.info("Waiting on common barrier for PM to run...");
-         BlockingPersistenceManager.BARRIER.await(5, TimeUnit.SECONDS);
+         BlockingPersistentObjectStore.BARRIER.await(5, TimeUnit.SECONDS);
          log.info("PM and test have met barrier, passivation running (but will be blocked to complete by test)");
 
          Callable<Integer> task = new Callable<Integer>()
@@ -258,12 +272,12 @@
       {
          // Allow the Persistence Manager to finish up
          log.info("Letting the PM perform passivation...");
-         BlockingPersistenceManager.PASSIVATION_LOCK.unlock();
+         BlockingPersistentObjectStore.PASSIVATION_LOCK.unlock();
       }
 
       // We need to allow time to let the Cache finish passivation, so block until it's done
       log.info("Waiting on Cache to tell us passivation is completed...");
-      ForceEventsCache.POST_PASSIVATE_BARRIER.await(5, TimeUnit.SECONDS);
+      ForceEventsBackingCacheEntryStore.POST_PASSIVATE_BARRIER.await(5, TimeUnit.SECONDS);
       log.info("Test sees Cache reports passivation completed.");
 
       int duringPassivation = result.get(5, TimeUnit.SECONDS);
@@ -291,11 +305,13 @@
       log.info("Got counter from " + sessionId + ": " + next);
       TestCase.assertEquals("SFSB did not return expected next counter", 0, next);
 
-      // Get the Cache
-      ForceEventsCache cache = (ForceEventsCache) container.getCache();
+      // Get the store
+      ForceEventsBackingCacheEntryStore<SerializationGroupMember<StatefulBeanContext>> store = 
+         ForceEventsCacheFactory.storeSource.getGroupMemberStore(container.getName());
+      store.setBlockOnPassivation(true);
 
       // Get the lock to block the PM, now
-      boolean gotLock = BlockingPersistenceManager.PASSIVATION_LOCK.tryLock();
+      boolean gotLock = BlockingPersistentObjectStore.PASSIVATION_LOCK.tryLock();
 
       Future<Integer> result;
       // Once PM lock is acquired, everything is in "try" so we release in "finally"
@@ -303,17 +319,17 @@
       {
          // Ensure we got the PM lock, else fail the test
          TestCase.assertTrue("Test was not able to immediately get the lock to block the PersistenceManager", gotLock);
-         log.info("Locked " + BlockingPersistenceManager.class.getSimpleName());
+         log.info("Locked " + BlockingPersistentObjectStore.class.getSimpleName());
 
          // Mark
-         cache.makeSessionEligibleForPassivation(sessionId);
+         store.makeSessionEligibleForPassivation(sessionId);
 
          /*
           * Passivate
           */
 
          // Trigger Passivation
-         ForceEventsCache.forcePassivation();
+         ForceEventsBackingCacheEntryStore.triggerPassivationExpiration();
          log.info("Passivation forced, carrying out test");
 
          Callable<Integer> task = new Callable<Integer>()
@@ -327,27 +343,43 @@
          result = executor.submit(task);
 
          // TODO: there is no way to know where we are in StatefulInstanceInterceptor
-         Thread.sleep(5000);
+         // FIXME: this assumes the old SimpleStatefulCache architecture. Now
+         // blocking for 5 seconds means the bean will be passivated when we
+         // trip the PRE_PASSIVATE_BARRIER below and this test fails.
+//         Thread.sleep(5000);
+         Thread.sleep(100); // for now try a smaller sleep
 
-         ForceEventsCache.PRE_PASSIVATE_BARRIER.await(5, TimeUnit.SECONDS);
+         ForceEventsBackingCacheEntryStore.PRE_PASSIVATE_BARRIER.await(5, TimeUnit.SECONDS);
 
          // Block until the PM is ready to passivate
          /* we're not passivating, we yanked it out
          log.info("Waiting on common barrier for PM to run...");
-         BlockingPersistenceManager.BARRIER.await(5, TimeUnit.SECONDS);
+         BlockingPersistenctObjectStore.BARRIER.await(5, TimeUnit.SECONDS);
          log.info("PM and test have met barrier, passivation running (but will be blocked to complete by test)");
          */
+         // FIXME Hacks upon hacks
+         // BES 2009/02/16 Above is non-deterministic; maybe we passivate,
+         // maybe we don't. So await the passivation barrier but don't fail
+         try
+         {
+            log.info("Waiting on common barrier for PM to run...");
+            BlockingPersistentObjectStore.BARRIER.await(2, TimeUnit.SECONDS);
+         }
+         catch (BrokenBarrierException e)
+         {
+            log.debug("BARRIER broken; bean not passivated");
+         }
       }
       finally
       {
          // Allow the Persistence Manager to finish up
          log.info("Letting the PM perform passivation...");
-         BlockingPersistenceManager.PASSIVATION_LOCK.unlock();
+         BlockingPersistentObjectStore.PASSIVATION_LOCK.unlock();
       }
 
       // We need to allow time to let the Cache finish passivation, so block until it's done
       log.info("Waiting on Cache to tell us passivation is completed...");
-      ForceEventsCache.POST_PASSIVATE_BARRIER.await(5, TimeUnit.SECONDS);
+      ForceEventsBackingCacheEntryStore.POST_PASSIVATE_BARRIER.await(5, TimeUnit.SECONDS);
       log.info("Test sees Cache reports passivation completed.");
 
       int duringPassivation = result.get(5, TimeUnit.SECONDS);
@@ -494,39 +526,41 @@
       // Get our bean's Session ID
       Serializable sessionId = this.getSessionId(bean1);
 
-      // Get the Cache
-      ForceEventsCache cache = (ForceEventsCache) container.getCache();
+      // Get the store
+      ForceEventsBackingCacheEntryStore<SerializationGroupMember<StatefulBeanContext>> store = 
+         ForceEventsCacheFactory.storeSource.getGroupMemberStore(container.getName());
+      store.setBlockOnPassivation(true);
 
       // Get the lock to block the PM, now
-      boolean gotLock = BlockingPersistenceManager.PASSIVATION_LOCK.tryLock();
+      boolean gotLock = BlockingPersistentObjectStore.PASSIVATION_LOCK.tryLock();
 
       // Once PM lock is acquired, everything is in "try" so we release in "finally"
       try
       {
          // Ensure we got the PM lock, else fail the test
          TestCase.assertTrue("Test was not able to immediately get the lock to block the PersistenceManager", gotLock);
-         log.info("Locked " + BlockingPersistenceManager.class.getSimpleName());
+         log.info("Locked " + BlockingPersistentObjectStore.class.getSimpleName());
 
          /*
           * Mark our session as expired
           */
 
          // Mark
-         cache.makeSessionEligibleForPassivation(sessionId);
+         store.makeSessionEligibleForPassivation(sessionId);
 
          /*
           * Passivate
           */
 
          // Trigger Passivation
-         ForceEventsCache.forcePassivation();
+         ForceEventsBackingCacheEntryStore.triggerPassivationExpiration();
          log.info("Passivation forced, carrying out test");
 
-         ForceEventsCache.PRE_PASSIVATE_BARRIER.await(5, TimeUnit.SECONDS);
+         ForceEventsBackingCacheEntryStore.PRE_PASSIVATE_BARRIER.await(5, TimeUnit.SECONDS);
 
          // Block until the PM is ready to passivate
          log.info("Waiting on common barrier for PM to run...");
-         BlockingPersistenceManager.BARRIER.await(5, TimeUnit.SECONDS);
+         BlockingPersistentObjectStore.BARRIER.await(5, TimeUnit.SECONDS);
          log.info("PM and test have met barrier, passivation running (but will be blocked to complete by test)");
 
          /*
@@ -561,18 +595,18 @@
 
          // Allow the Persistence Manager to finish up
          log.info("Letting the PM perform passivation...");
-         BlockingPersistenceManager.PASSIVATION_LOCK.unlock();
+         BlockingPersistentObjectStore.PASSIVATION_LOCK.unlock();
       }
 
       // We need to allow time to let the Cache finish passivation, so block until it's done
       log.info("Waiting on Cache to tell us passivation is completed...");
-      ForceEventsCache.POST_PASSIVATE_BARRIER.await(5, TimeUnit.SECONDS);
+      ForceEventsBackingCacheEntryStore.POST_PASSIVATE_BARRIER.await(5, TimeUnit.SECONDS);
       log.info("Test sees Cache reports passivation completed.");
 
       /*
        * Here we ensure that the session was removed from the internal cacheMap
        */
-      boolean beanIsInCache = cache.doesCacheMapContainKey(sessionId);
+      boolean beanIsInCache = store.containsInMemoryEntry(sessionId);
       assertFalse("bean " + sessionId + " was not removed from cache", beanIsInCache);
 
       // Ensure we're good
@@ -589,17 +623,13 @@
       // Perform generic setup of MC, default beans, etc
       AbstractEJB3TestCase.beforeClass();
 
-      // Add the Blocking PersistenceManager
-      PersistenceManagerFactoryRegistry pmFactoryRegistry = Ejb3RegistrarLocator.locateRegistrar().lookup(
-            "EJB3PersistenceManagerFactoryRegistry", PersistenceManagerFactoryRegistry.class);
-      pmFactoryRegistry.getFactories().put(BlockingPersistenceManagerFactory.REGISTRY_BIND_NAME,
-            BlockingPersistenceManagerFactory.class);
-
       // Add the Force Passivation Cache
       CacheFactoryRegistry cacheFactoryRegistry = Ejb3RegistrarLocator.locateRegistrar().lookup(
             "EJB3CacheFactoryRegistry", CacheFactoryRegistry.class);
       String forcePassivationCacheRegistryName = ForceEventsCacheFactory.REGISTRY_BIND_NAME;
-      cacheFactoryRegistry.getFactories().put(forcePassivationCacheRegistryName, ForceEventsCacheFactory.class);
+      ForceEventsCacheFactory cacheFactory = new ForceEventsCacheFactory();
+      configureStatefulCacheFactory(cacheFactory);
+      cacheFactoryRegistry.addCacheFactory(forcePassivationCacheRegistryName, cacheFactory);
       log.info("Added " + forcePassivationCacheRegistryName);
 
       // Deploy the test SFSB
@@ -612,12 +642,13 @@
    public void after()
    {
       log.info("Resetting all barriers and clearing the cache...");
-      ForceEventsCache.POST_PASSIVATE_BARRIER.reset();
-      ForceEventsCache.PRE_PASSIVATE_BARRIER.reset();
-      ForceEventsCache.PRE_REMOVE_BARRIER.reset();
-      BlockingPersistenceManager.BARRIER.reset();
-      ForceEventsCache cache = (ForceEventsCache) container.getCache();
-      cache.clear();
+      ForceEventsBackingCacheEntryStore.POST_PASSIVATE_BARRIER.reset();
+      ForceEventsBackingCacheEntryStore.PRE_PASSIVATE_BARRIER.reset();
+      ForceEventsBackingCacheEntryStore.PRE_REMOVE_BARRIER.reset();
+      BlockingPersistentObjectStore.BARRIER.reset();
+      ForceEventsBackingCacheEntryStore<SerializationGroupMember<StatefulBeanContext>> store = 
+         ForceEventsCacheFactory.storeSource.getGroupMemberStore(container.getName());
+      store.clear();
    }
 
    @AfterClass
@@ -644,4 +675,40 @@
       Serializable sessionId = handler.getSessionId();
       return sessionId;
    }
+   
+   private static void configureStatefulCacheFactory(AbstractStatefulCacheFactory<StatefulBeanContext> factory)
+   {
+      TransactionManager tm = null;
+      try
+      {
+         tm = (TransactionManager) Ejb3RegistrarLocator.locateRegistrar().lookup("RealTransactionManager");
+      }
+      catch (NotBoundException e)
+      {
+         // fall back on JNDI
+         try
+         {
+            InitialContext ctx = new InitialContext();
+            tm = (TransactionManager) ctx.lookup("java:/TransactionManager");
+         }
+         catch (NamingException e1)
+         {
+            throw new RuntimeException("cannot resolve transaction manager", e1);
+         }         
+      }
+      
+      factory.setTransactionManager(tm);
+      
+      SynchronizationCoordinatorImpl sci = new SynchronizationCoordinatorImpl();
+      if (tm instanceof TransactionSynchronizationRegistrySource)
+      {
+         sci.setTransactionSynchronizationRegistrySource((TransactionSynchronizationRegistrySource) tm);
+      }
+      else
+      {
+         sci.setTransactionSynchronizationRegistrySource(new JndiTransactionSynchronizationRegistrySource());
+      }
+      factory.setSynchronizationCoordinator(sci);      
+      factory.start();
+   }
 }

Modified: projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/test/cachepassivation/unit/CachePassivationUnitTestCase.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/cachepassivation/unit/CachePassivationUnitTestCase.java	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/test/java/org/jboss/ejb3/test/cachepassivation/unit/CachePassivationUnitTestCase.java	2009-02-17 22:38:36 UTC (rev 84332)
@@ -26,6 +26,7 @@
 import java.util.Map;
 
 import javax.naming.InitialContext;
+import javax.transaction.TransactionManager;
 
 import junit.framework.TestCase;
 
@@ -40,6 +41,7 @@
 import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
 import org.jboss.ejb3.core.test.common.MockEjb3Deployment;
 import org.jboss.ejb3.stateful.StatefulBeanContext;
+import org.jboss.ejb3.test.cache.mock.tm.MockTransactionManager;
 import org.jboss.ejb3.test.cachepassivation.MockBean;
 import org.jboss.ejb3.test.cachepassivation.MockDeploymentUnit;
 import org.jboss.ejb3.test.cachepassivation.MockStatefulContainer;
@@ -68,7 +70,8 @@
       initializer.setInitialContextProperties(ctxProperties);
       initializer.start();
       
-      DummyTransactionManager tm = new DummyTransactionManager();
+      DummyTransactionManager dtm = new DummyTransactionManager();
+      TransactionManager tm = MockTransactionManager.getInstance();
       InitialContext ic = new InitialContext(ctxProperties);
       ic.bind("java:/TransactionManager", tm);
       
@@ -100,12 +103,14 @@
          
          Object id = container.createSession();
          
-         StatefulBeanContext ctx = container.getCache().get(id, false);
+//         StatefulBeanContext ctx = container.getCache().get(id, false);
+         StatefulBeanContext ctx = container.getCache().get(id);
          
          System.out.println("inUse = " + ctx.isInUse());
          MockBean bean = (MockBean) ctx.getInstance();
          System.out.println(bean.ctx);
-         ctx.setInUse(false);
+//         ctx.setInUse(false);
+         container.getCache().release(ctx);
          ctx = null;
          
          synchronized (MockBean.notification)
@@ -114,7 +119,8 @@
          }
          Thread.sleep(500);
          
-         ctx = container.getCache().get(id, false);
+//         ctx = container.getCache().get(id, false);
+         ctx = container.getCache().get(id);
          bean = (MockBean) ctx.getInstance();
          
          String a = ctx.getEJBContext().toString();

Modified: projects/ejb3/branches/cluster-dev/core/src/test/resources/statefulcontainer-beans.xml
===================================================================
--- projects/ejb3/trunk/core/src/test/resources/statefulcontainer-beans.xml	2009-01-24 12:01:20 UTC (rev 83396)
+++ projects/ejb3/branches/cluster-dev/core/src/test/resources/statefulcontainer-beans.xml	2009-02-17 22:38:36 UTC (rev 84332)
@@ -15,26 +15,53 @@
       </property>
    </bean>
    
+   <bean name="EJB3CacheSynchronizationCoordinator" class="org.jboss.ejb3.cache.spi.impl.SynchronizationCoordinatorImpl"/>
+   
    <!-- EJB3 Cache Factory Registry -->
    <bean name="EJB3CacheFactoryRegistry" class="org.jboss.ejb3.cache.CacheFactoryRegistry">
       <property name="factories">
          <!-- Define each of the registered factories -->
          <map class="java.util.HashMap" keyClass="java.lang.String"
-            valueClass="java.lang.Class">
+            valueClass="org.jboss.ejb3.cache.StatefulCacheFactory">
             <!-- NoPassivationCache -->
             <entry>
                <key>NoPassivationCache</key>
-               <value>org.jboss.ejb3.cache.NoPassivationCacheFactory</value>
+               <value>
+                  <bean class="org.jboss.ejb3.cache.impl.factory.NonPassivatingCacheFactory">
+                     <property name="transactionManager"><inject bean="RealTransactionManager"/></property>
+                     <property name="synchronizationCoordinator"><inject bean="EJB3CacheSynchronizationCoordinator"/></property>
+                  </bean>
+               </value>
             </entry>
             <!-- SimpleStatefulCache -->
             <entry>
                <key>SimpleStatefulCache</key>
-               <value>org.jboss.ejb3.cache.simple.SimpleStatefulCacheFactory</value>
+               <value>
+                  <bean class="org.jboss.ejb3.cache.impl.factory.GroupAwareCacheFactory">
+                     <constructor>
+                        <parameter>
+                           <bean class="org.jboss.ejb3.cache.impl.factory.NonClusteredBackingCacheEntryStoreSource"/>
+                        </parameter>
+                     </constructor>
+                     <property name="transactionManager"><inject bean="RealTransactionManager"/></property>
+                     <property name="synchronizationCoordinator"><inject bean="EJB3CacheSynchronizationCoordinator"/></property>
+                  </bean>
+               </value>
             </entry>
             <!-- StatefulTreeCache -->
             <entry>
                <key>StatefulTreeCache</key>
-               <value>org.jboss.ejb3.cache.tree.StatefulTreeCacheFactory</value>
+               <value>
+                  <bean class="org.jboss.ejb3.cache.impl.factory.GroupAwareCacheFactory">
+                     <constructor>
+                        <parameter>
+                           <bean class="org.jboss.ejb3.test.cache.distributed.MockBackingCacheEntryStoreSource"/>
+                        </parameter>
+                     </constructor>
+                     <property name="transactionManager"><inject bean="RealTransactionManager"/></property>
+                     <property name="synchronizationCoordinator"><inject bean="EJB3CacheSynchronizationCoordinator"/></property>
+                  </bean>
+               </value>
             </entry>
          </map>
       </property>




More information about the jboss-cvs-commits mailing list