[jboss-cvs] JBossAS SVN: r60627 - in trunk/ejb3/src/test/org/jboss/ejb3/test: clusteredsession/nested and 6 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Feb 18 23:11:05 EST 2007
Author: bstansberry at jboss.com
Date: 2007-02-18 23:11:05 -0500 (Sun, 18 Feb 2007)
New Revision: 60627
Added:
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/IgnoreReplicationStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/OptimizedStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredDeepNestedContainedBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredDeepNestedStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredLocalContainedBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredLocalNestedStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredParentStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredRemoteContainedBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredRemoteNestedStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredShoppingCartBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleContainedBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleDeepNestedContainedBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleDeepNestedStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleLocalContainedBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleLocalNestedStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleParentStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleRemoteNestedStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleShoppingCartBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/BeanMonitor.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/BeanMonitorBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/DeepNestedStateful.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/DeepNestedStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/MidLevel.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/PassivationActivationWatcher.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/PassivationActivationWatcherBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/Removable.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/TopLevel.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/VMTracker.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/VMTrackerBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/NestedBeanMonitor.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/NestedBeanMonitorBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/NestedStateful.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/NestedStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/OptimizedNestedStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/ParentStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/ParentStatefulRemote.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/Contained.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/ContainedBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/Customer.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/DeepNestedContained.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/DeepNestedContainedBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedStatelessLocal.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedStatelessSessionBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedXPCMonitor.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedXPCMonitorBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/ShoppingCart.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/ShoppingCartBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/BaseTestRunner.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/ExtendedPersistenceUnitTestCase.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/NestedBeanTestRunner.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/XPCTestRunner.java
Removed:
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/Contained.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/ContainedBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/Customer.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/ShoppingCart.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/ShoppingCartBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/StatelessLocal.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/StatelessRemote.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/StatelessSessionBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/NestedStateful.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/NestedStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ParentStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ParentStatefulRemote.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/BaseNestedStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/LocalNestedStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/NestedStateful.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/NestedStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/ParentStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/ParentStatefulRemote.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/Removable.java
Modified:
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/ExplicitFailoverInterceptor.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/NonAnnotationStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/OverrideAnnotationStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/unit/PassivationUnitTestCase.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/NestedBeanUnitTestCase.java
Log:
Refactor and expand testing of nested SFSBs
[EJBTHREE-867] Loosen coupling of lifecycle of nested SFSBs
[EJBTHREE-849] Properly handle passivation/activation callbacks for nested SFSBs
[EJBTHREE-851] Invoke passivation/activation callbacks around replication
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/Contained.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/Contained.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/Contained.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -1,41 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.ejb3.test.clusteredsession;
-
-/**
- * Comment
- *
- * @author Ben Wang
- * @version $Revision$
- */
-public interface Contained
-{
- Customer find(long id);
-
- void setCustomer(long id);
-
- Customer getCustomer();
-
- void updateCustomer();
-
- boolean isActivated();
-}
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/ContainedBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/ContainedBean.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/ContainedBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -1,102 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.ejb3.test.clusteredsession;
-
-import javax.persistence.PersistenceContext;
-import javax.persistence.PersistenceContextType;
-import javax.persistence.EntityManager;
-import javax.annotation.PreDestroy;
-import javax.ejb.Stateful;
-import javax.ejb.PrePassivate;
-import javax.ejb.PostActivate;
-
-import org.jboss.annotation.ejb.cache.tree.CacheConfig;
-import org.jboss.annotation.ejb.Clustered;
-
-/**
- * Comment
- *
- * @author Ben Wang
- * @version $Revision$
- */
- at Stateful
- at Clustered
- at CacheConfig(maxSize = 1000, idleTimeoutSeconds = 2)
-public class ContainedBean implements Contained
-{
- @PersistenceContext(type= PersistenceContextType.EXTENDED) EntityManager em;
-
- Customer customer;
-
- public Customer find(long id)
- {
- return em.find(Customer.class, id);
- }
-
- public void setCustomer(long id)
- {
- customer = find(id);
- }
-
- public Customer getCustomer()
- {
- return customer;
- }
-
- public void updateCustomer()
- {
- customer.setName("contained modified");
- }
-
- public boolean isActivated()
- {
- return activated;
- }
-
- public static boolean destroyed = false;
- public static boolean passivated = false;
- public static boolean activate = false;
- private boolean activated = false;
-
- @PrePassivate
- public void passivate()
- {
- passivated = true;
- }
-
- @PostActivate
- public void activate()
- {
- System.out.println("*********** ACTIVATED *****************");
- if (activated) throw new RuntimeException("ACTIVATED TWICE");
- activated = true;
- if (activate) throw new RuntimeException("ACTIVATED TWICE IN TWO DIFFERENT INSTANCES");
- activate = true;
-
- }
-
- @PreDestroy
- public void destroy()
- {
- destroyed = true;
- }
-}
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/Customer.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/Customer.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/Customer.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.test.clusteredsession;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue; import javax.persistence.GenerationType;
-import javax.persistence.Id;
-
-/**
- * Company customer
- *
- * @author Ben Wang
- */
- at Entity
-public class Customer implements java.io.Serializable
-{
- long id;
- String name;
-
- public
- Customer()
- {
- }
-
- @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
- public
- long getId()
- {
- return id;
- }
-
- public
- String getName()
- {
- return name;
- }
-
- public
- void setId(long long1)
- {
- id = long1;
- }
-
- public
- void setName(String string)
- {
- name = string;
- }
-
-}
-
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/ExplicitFailoverInterceptor.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/ExplicitFailoverInterceptor.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/ExplicitFailoverInterceptor.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -58,10 +58,12 @@
if (doFail)
{
- log.debug ("WE FAILOVER IN EJB INTERCEPTOR (explicit failover)!");
+ GenericClusteringException e = new GenericClusteringException
+ (GenericClusteringException.COMPLETED_NO, "Test failover from ejb interceptor", false);
+
+ log.debug ("WE FAILOVER IN EJB INTERCEPTOR (explicit failover)!", e);
- throw new GenericClusteringException
- (GenericClusteringException.COMPLETED_NO, "Test failover from ejb interceptor", false);
+ throw e;
}
}
}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/IgnoreReplicationStatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/IgnoreReplicationStatefulBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/IgnoreReplicationStatefulBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.clusteredsession;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.annotation.ejb.Clustered;
+import org.jboss.annotation.ejb.cache.tree.CacheConfig;
+
+/**
+ * Stateful bean that configures clustering via annotations.
+ *
+ * @author Ben Wang
+ * @version $Revision: 59445 $
+ */
+ at Stateful(name="testIgnoreReplicationStateful")
+ at Clustered
+ at CacheConfig(maxSize=1000, idleTimeoutSeconds=1, replicationIsPassivation=false) // this will get evicted the second time eviction thread wakes up
+ at Remote(StatefulRemote.class)
+public class IgnoreReplicationStatefulBean extends NonAnnotationStatefulBean
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ // Only difference from superclass is the added class-level annotations
+}
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/NonAnnotationStatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/NonAnnotationStatefulBean.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/NonAnnotationStatefulBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -30,6 +30,7 @@
import javax.ejb.Remove;
import javax.interceptor.Interceptors;
+import org.jboss.ejb3.test.stateful.nested.base.VMTracker;
import org.jboss.logging.Logger;
import org.jboss.system.server.ServerConfig;
@@ -47,12 +48,18 @@
*/
public class NonAnnotationStatefulBean implements java.io.Serializable, StatefulRemote
{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
private Logger log = Logger.getLogger(getClass());
private int counter = 0;
private String state;
- public transient VMID myId = null;
+ public static final VMID myId = VMTracker.VMID;
public String name;
+ private int postActivateCalled = 0;
+ private int prePassivateCalled = 0;
+
public int increment()
{
System.out.println("INCREMENT - counter: " + (counter++));
@@ -64,9 +71,6 @@
return System.getProperty(ServerConfig.SERVER_BIND_ADDRESS);
}
- public static int postActivateCalled = 0;
- public static int prePassivateCalled = 0;
-
/**
* Sleep to test
* @throws Exception
@@ -106,7 +110,8 @@
prePassivateCalled = 0;
}
- public void resetActivationCounter() {
+ public void resetActivationCounter()
+ {
postActivateCalled = 0;
prePassivateCalled = 0;
}
@@ -114,20 +119,15 @@
@PostActivate
public void postActivate()
{
- ++postActivateCalled;
- if (this.myId == null)
- {
- //it is a failover: we need to assign ourself an id
- this.myId = new VMID();
- }
- log.debug("Activate. My ID: " + this.myId + " name: " + this.name);
+ postActivateCalled++;
+ log.debug("Activate. My ID: " + myId + " name: " + this.name);
}
@PrePassivate
public void prePassivate()
{
- ++prePassivateCalled;
- log.debug("Passivate. My ID: " + this.myId + " name: " + this.name);
+ prePassivateCalled++;
+ log.debug("Passivate. My ID: " + myId + " name: " + this.name);
}
@Remove
@@ -138,8 +138,7 @@
@PostConstruct
public void ejbCreate()
{
- this.myId = new VMID();
- log.debug("My ID: " + this.myId);
+ log.debug("My ID: " + myId);
}
// Remote Interface implementation ----------------------------------------------
@@ -148,13 +147,7 @@
@Interceptors({ExplicitFailoverInterceptor.class})
public NodeAnswer getNodeState()
{
- if (this.myId == null)
- {
- //it is a failover: we need to assign ourself an id because of transient nature
- this.myId = new VMID();
- }
-
- NodeAnswer state = new NodeAnswer(this.myId, this.name);
+ NodeAnswer state = new NodeAnswer(myId, this.name);
log.debug("getNodeState, " + state);
return state;
}
@@ -167,10 +160,10 @@
public void setNameOnlyOnNode(String name, VMID node)
{
- if (node.equals(this.myId))
+ if (node.equals(myId))
this.setName(name);
else
- throw new EJBException("Trying to assign value on node " + this.myId + " but this node expected: " + node);
+ throw new EJBException("Trying to assign value on node " + myId + " but this node expected: " + node);
}
public void setUpFailover(String failover) {
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/OptimizedStatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/OptimizedStatefulBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/OptimizedStatefulBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.clusteredsession;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.annotation.ejb.Clustered;
+import org.jboss.annotation.ejb.cache.tree.CacheConfig;
+import org.jboss.ejb3.cache.Optimized;
+
+/**
+ * Stateful bean that configures clustering via annotations.
+ *
+ * @author Ben Wang
+ * @version $Revision: 59445 $
+ */
+ at Stateful(name="testOptimizedStateful")
+ at Clustered
+ at CacheConfig(maxSize=1000, idleTimeoutSeconds=1) // this will get evicted the second time eviction thread wakes up
+ at Remote(StatefulRemote.class)
+public class OptimizedStatefulBean
+ extends NonAnnotationStatefulBean
+ implements Optimized
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ private boolean modified = true;
+
+ public boolean isModified()
+ {
+ boolean answer = modified;
+ modified = true;
+ return answer;
+ }
+
+ @Override
+ public int getPostActivate()
+ {
+ modified = false;
+ return super.getPostActivate();
+ }
+
+ @Override
+ public int getPrePassivate()
+ {
+ modified = false;
+ return super.getPrePassivate();
+ }
+
+ @Override
+ public void resetActivationCounter()
+ {
+ modified = false;
+ super.resetActivationCounter();
+ }
+
+
+}
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/OverrideAnnotationStatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/OverrideAnnotationStatefulBean.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/OverrideAnnotationStatefulBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -37,5 +37,7 @@
@Remote(StatefulRemote.class)
public class OverrideAnnotationStatefulBean extends NonAnnotationStatefulBean
{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
}
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/ShoppingCart.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/ShoppingCart.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/ShoppingCart.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.test.clusteredsession;
-
-import java.rmi.dgc.VMID;
-
-import javax.ejb.Remove;
-
-/**
- * comment
- *
- * @author Ben Wang
- */
-public interface ShoppingCart
-{
- VMID getVMID();
-
- long createCustomer();
-
- void update();
-
- Customer find(long id);
-
- @Remove void checkout();
-
- void update2();
-
- void update3();
-
- void never();
-
- void setContainedCustomer();
-
- void updateContained();
-
- void findAndUpdateStateless();
-
- void checkContainedCustomer();
-
- boolean isContainedActivated();
-}
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/ShoppingCartBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/ShoppingCartBean.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/ShoppingCartBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -1,138 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.test.clusteredsession;
-
-import java.io.Serializable;
-import java.rmi.dgc.VMID;
-
-import javax.ejb.EJB;
-import javax.ejb.Remote;
-import javax.ejb.Remove;
-import javax.ejb.Stateful;
-import javax.ejb.TransactionAttribute;
-import javax.ejb.TransactionAttributeType;
-import javax.ejb.PostActivate;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.persistence.PersistenceContextType;
-import org.jboss.annotation.ejb.cache.tree.CacheConfig;
-import org.jboss.annotation.ejb.Clustered;
-
-/**
- * comment
- *
- * @author Ben Wang
- */
- at Stateful
- at Clustered
- at Remote(ShoppingCart.class)
- at CacheConfig(maxSize = 1000, idleTimeoutSeconds = 2)
-public class ShoppingCartBean implements ShoppingCart, Serializable
-{
- @PersistenceContext(type=PersistenceContextType.EXTENDED) EntityManager em;
-
- @EJB StatelessLocal stateless;
-
- private Customer customer;
-
- @EJB private Contained contained;
-
- public VMID getVMID()
- {
- return stateless.getVMID();
- }
-
- public long createCustomer()
- {
- customer = new Customer();
- customer.setName("William");
- em.persist(customer);
- System.out.println("********* created *****");
- return customer.getId();
- }
-
- public void setContainedCustomer()
- {
- contained.setCustomer(customer.getId());
- }
-
- public void checkContainedCustomer()
- {
- if (contained.getCustomer() != customer) throw new RuntimeException("not same customer");
- }
-
- public boolean isContainedActivated()
- {
- return contained.isActivated();
- }
-
- public void updateContained()
- {
- contained.updateCustomer();
- }
-
- public void update()
- {
- System.out.println("********* update() *****");
- customer.setName("Bill");
- }
- public void update2()
- {
- customer.setName("Billy");
- }
-
- public void update3()
- {
- stateless.update(customer);
- }
-
- public void findAndUpdateStateless()
- {
- stateless.findAndUpdate(customer.getId());
- if (!customer.getName().equals("stateless modified")) throw new RuntimeException("stateless didn't get propagated pc");
- }
-
- public Customer find(long id)
- {
- return em.find(Customer.class, id);
- }
-
- @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
- public void never()
- {
- customer.setName("Bob");
- }
-
- @PostActivate
- public void activate()
- {
- System.out.println("*********** ACTIVATED *****************");
- }
-
-
- @Remove
- public void checkout()
- {
- if (customer != null)
- em.remove(customer);
- }
-}
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/StatelessLocal.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/StatelessLocal.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/StatelessLocal.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -1,47 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.test.clusteredsession;
-
-import java.rmi.dgc.VMID;
-
-
-/**
- * comment
- *
- * @author Ben Wang
- */
-public interface StatelessLocal
-{
- VMID getVMID();
-
- void update(Customer c);
-
- void findAndUpdate(long id);
-
- boolean isDestroyed();
-
- void clearDestroyed();
-
- boolean isPassivated();
-
- void clearPassivated();
-}
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/StatelessRemote.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/StatelessRemote.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/StatelessRemote.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -1,46 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.test.clusteredsession;
-
-import java.rmi.dgc.VMID;
-
-
-
-/**
- * comment
- *
- * @author Ben Wang
- */
-public interface StatelessRemote
-{
- VMID getVMID();
-
- Customer find(long id);
-
- void findAndUpdate(long id);
-
- boolean isDestroyed();
- void clearDestroyed();
- boolean isPassivated();
-
- void clearPassivated();
-}
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/StatelessSessionBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/StatelessSessionBean.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/StatelessSessionBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -1,93 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.test.clusteredsession;
-
-import javax.ejb.Local;
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import java.rmi.dgc.VMID;
-
-/**
- * comment
- *
- * @author Ben Wang
- */
- at Stateless
- at Remote(StatelessRemote.class)
- at Local(StatelessLocal.class)
-public class StatelessSessionBean implements StatelessLocal, StatelessRemote
-{
- @PersistenceContext EntityManager em;
-
- public static VMID myId = null;
-
- public VMID getVMID()
- {
- if(myId == null)
- {
- myId = new VMID();
- }
- return myId;
- }
-
- public void update(Customer c)
- {
- c.setName("Bill Jr.");
- }
-
- public void findAndUpdate(long id)
- {
- Customer cust = find(id);
- cust.setName("stateless modified");
- }
-
- public Customer find(long id)
- {
- return em.find(Customer.class, id);
- }
-
- public boolean isDestroyed()
- {
- return ContainedBean.destroyed;
- }
-
- public void clearDestroyed()
- {
- ContainedBean.destroyed = false;
- }
-
- public boolean isPassivated()
- {
- return ContainedBean.passivated;
- }
-
- public void clearPassivated()
- {
- ContainedBean.passivated = false;
- }
-
- public NodeAnswer getNodeState() {
- return new NodeAnswer(getVMID(), "test");
- }
-}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredDeepNestedContainedBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredDeepNestedContainedBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredDeepNestedContainedBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.nested;
+
+import javax.ejb.Local;
+import javax.ejb.Stateful;
+
+import org.jboss.annotation.ejb.Clustered;
+import org.jboss.annotation.ejb.cache.tree.CacheConfig;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.DeepNestedContained;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.DeepNestedContainedBean;
+
+/**
+ * A ClusteredDeepNestedStatefulBean.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateful(name="testDeepNestedContained")
+ at Clustered
+ at CacheConfig(maxSize=10000, idleTimeoutSeconds=1, replicationIsPassivation=false)
+ at Local(DeepNestedContained.class)
+public class ClusteredDeepNestedContainedBean extends DeepNestedContainedBean
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredDeepNestedStatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredDeepNestedStatefulBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredDeepNestedStatefulBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.nested;
+
+import javax.ejb.Local;
+import javax.ejb.Stateful;
+
+import org.jboss.annotation.ejb.Clustered;
+import org.jboss.annotation.ejb.cache.tree.CacheConfig;
+import org.jboss.ejb3.test.stateful.nested.base.DeepNestedStateful;
+import org.jboss.ejb3.test.stateful.nested.base.DeepNestedStatefulBean;
+
+/**
+ * A ClusteredDeepNestedStatefulBean.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateful(name="testDeepNestedStateful")
+ at Clustered
+ at CacheConfig(maxSize=10000, idleTimeoutSeconds=1, replicationIsPassivation=false)
+ at Local(DeepNestedStateful.class)
+public class ClusteredDeepNestedStatefulBean extends DeepNestedStatefulBean
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredLocalContainedBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredLocalContainedBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredLocalContainedBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.nested;
+
+import javax.ejb.Local;
+import javax.ejb.Stateful;
+
+import org.jboss.annotation.ejb.Clustered;
+import org.jboss.annotation.ejb.cache.tree.CacheConfig;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.Contained;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.ContainedBean;
+
+/**
+ * ContainedBean bean meant for testing with a clustered SFSB cache.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateful(name="testLocalShoppingCartContained")
+ at Clustered
+ at CacheConfig(maxSize = 1000, idleTimeoutSeconds = 1)
+ at Local(Contained.class)
+public class ClusteredLocalContainedBean extends ContainedBean
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredLocalNestedStatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredLocalNestedStatefulBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredLocalNestedStatefulBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.nested;
+
+import javax.ejb.Local;
+import javax.ejb.Stateful;
+
+import org.jboss.annotation.ejb.Clustered;
+import org.jboss.annotation.ejb.cache.tree.CacheConfig;
+import org.jboss.ejb3.test.stateful.nested.base.std.NestedStateful;
+import org.jboss.ejb3.test.stateful.nested.base.std.NestedStatefulBean;
+
+/**
+ * Nested SFSB with only a local interface.
+ *
+ * @author Ben Wang
+ * @author Brian Stansberry
+ *
+ * @version $Revision: 45372 $
+ */
+ at Clustered
+ at Stateful(name="testLocalNestedStateful")
+ at CacheConfig(maxSize=10000, idleTimeoutSeconds=1)
+ at Local(NestedStateful.class)
+public class ClusteredLocalNestedStatefulBean extends NestedStatefulBean
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredParentStatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredParentStatefulBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredParentStatefulBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.nested;
+
+import java.rmi.dgc.VMID;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+import javax.interceptor.Interceptors;
+
+import org.jboss.annotation.ejb.Clustered;
+import org.jboss.annotation.ejb.cache.tree.CacheConfig;
+import org.jboss.ejb3.test.clusteredsession.ExplicitFailoverInterceptor;
+import org.jboss.ejb3.test.stateful.nested.base.std.ParentStatefulBean;
+import org.jboss.ejb3.test.stateful.nested.base.std.ParentStatefulRemote;
+
+/**
+ * Parent SFSB that contains nested SFSB.
+ *
+ * @author Ben Wang
+ * @author Brian Stansberry
+ * @version $Revision: 60408 $
+ */
+ at Clustered
+ at Stateful(name="testParentStateful")
+ at CacheConfig(maxSize=1000, idleTimeoutSeconds=1) // this will get evicted the second time eviction thread wakes up
+ at Remote(ParentStatefulRemote.class)
+public class ClusteredParentStatefulBean extends ParentStatefulBean
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ // Mimic explict failover
+ @Interceptors({ExplicitFailoverInterceptor.class})
+ public VMID getVMID()
+ {
+ return super.getVMID();
+ }
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredRemoteContainedBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredRemoteContainedBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredRemoteContainedBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.nested;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.annotation.ejb.Clustered;
+import org.jboss.annotation.ejb.cache.tree.CacheConfig;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.Contained;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.ContainedBean;
+
+/**
+ * ContainedBean bean meant for testing with a clustered SFSB cache.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateful(name="testShoppingCartContained")
+ at Clustered
+ at CacheConfig(maxSize = 1000, idleTimeoutSeconds = 1)
+ at Remote(Contained.class)
+public class ClusteredRemoteContainedBean extends ContainedBean
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredRemoteNestedStatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredRemoteNestedStatefulBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredRemoteNestedStatefulBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.nested;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.annotation.ejb.Clustered;
+import org.jboss.annotation.ejb.cache.tree.CacheConfig;
+import org.jboss.ejb3.test.stateful.nested.base.std.NestedStateful;
+import org.jboss.ejb3.test.stateful.nested.base.std.OptimizedNestedStatefulBean;
+
+/**
+ * Nested SFSB with a remote interface.
+ *
+ * @author Ben Wang
+ * @author Brian Stansberry
+ *
+ * @version $Revision: 60066 $
+ */
+ at Clustered
+ at Stateful(name="testNestedStateful")
+ at CacheConfig(maxSize=1000, idleTimeoutSeconds=1)
+ at Remote(NestedStateful.class)
+public class ClusteredRemoteNestedStatefulBean extends OptimizedNestedStatefulBean
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredShoppingCartBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredShoppingCartBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ClusteredShoppingCartBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.nested;
+
+import java.rmi.dgc.VMID;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+import javax.interceptor.Interceptors;
+
+import org.jboss.annotation.ejb.Clustered;
+import org.jboss.annotation.ejb.cache.tree.CacheConfig;
+import org.jboss.ejb3.test.clusteredsession.ExplicitFailoverInterceptor;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.ShoppingCart;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.ShoppingCartBean;
+
+/**
+ * ShoppingCartBean subclass for testing with a clustered SFSB cache.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateful(name="testShoppingCart")
+ at Remote(ShoppingCart.class)
+ at Clustered
+ at CacheConfig(maxSize = 1000, idleTimeoutSeconds = 1)
+public class ClusteredShoppingCartBean extends ShoppingCartBean
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ // Mimic explict failover
+ @Interceptors({ExplicitFailoverInterceptor.class})
+ public VMID getVMID()
+ {
+ return super.getVMID();
+ }
+}
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/NestedStateful.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/NestedStateful.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/NestedStateful.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -1,25 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
-package org.jboss.ejb3.test.clusteredsession.nested;
-
-import org.jboss.ejb3.test.clusteredsession.NodeAnswer;
-
-import java.rmi.dgc.VMID;
-
-/**
- * Comment
- *
- * @author Ben Wang
- * @version $Revision$
- */
-public interface NestedStateful
-{
- int increment();
- void reset();
- void remove();
-}
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/NestedStatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/NestedStatefulBean.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/NestedStatefulBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -1,81 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
-package org.jboss.ejb3.test.clusteredsession.nested;
-
-import org.jboss.annotation.ejb.Clustered;
-import org.jboss.annotation.ejb.cache.tree.CacheConfig;
-import org.jboss.logging.Logger;
-
-import javax.ejb.*;
-
-/**
- * Nested SFSB
- *
- * @author Ben Wang
- * @version $Revision$
- */
- at Stateful(name="testNestedStateful")
- at Clustered
- at CacheConfig(maxSize=1000, idleTimeoutSeconds=3) // this will get evicted the second time eviction thread wakes up
-public class NestedStatefulBean implements java.io.Serializable, NestedStateful
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 1L;
-
- private static Logger log = Logger.getLogger(NestedStatefulBean.class);
- private int counter = 0;
-
- public int increment()
- {
- counter++;
- log.debug("INCREMENT - nested counter: " + counter);
- return counter;
- }
-
- public static int postActivateCalled = 0;
- public static int prePassivateCalled = 0;
-
- public int getPostActivate()
- {
- return postActivateCalled;
- }
-
- public int getPrePassivate()
- {
- return prePassivateCalled;
- }
-
- public void reset()
- {
- counter = 0;
- NestedStatefulBean.postActivateCalled = 0;
- NestedStatefulBean.prePassivateCalled = 0;
- }
-
- @Remove
- public void remove()
- {
- log.debug("Being removed");
- }
-
- @PostActivate
- public void postActivate()
- {
- ++NestedStatefulBean.postActivateCalled;
- log.debug("postActivate: - counter: " + counter +
- " -- activate count:" + postActivateCalled);
- }
-
- @PrePassivate
- public void prePassivate()
- {
- ++NestedStatefulBean.prePassivateCalled;
- log.debug("prePassivate: - counter: " + counter +
- " -- passivate count:" + prePassivateCalled);
- }
-}
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ParentStatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ParentStatefulBean.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ParentStatefulBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -1,206 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
-package org.jboss.ejb3.test.clusteredsession.nested;
-
-import org.jboss.annotation.ejb.Clustered;
-import org.jboss.annotation.ejb.cache.tree.CacheConfig;
-import org.jboss.logging.Logger;
-import org.jboss.system.server.ServerConfig;
-import org.jboss.ejb3.test.clusteredsession.ExplicitFailoverInterceptor;
-import org.jboss.ejb3.test.clusteredsession.NodeAnswer;
-import org.jboss.ejb3.test.clusteredsession.ClusteredStatelessRemote;
-
-import javax.interceptor.Interceptors;
-import javax.annotation.PostConstruct;
-import javax.ejb.EJB;
-import javax.ejb.Stateful;
-import javax.ejb.Remote;
-import javax.ejb.PostActivate;
-import javax.ejb.PrePassivate;
-import javax.ejb.Remove;
-import javax.ejb.EJBException;
-import java.rmi.dgc.VMID;
-
-/**
- * SFSB with nested bean
- *
- * @author Ben Wang
- * @version $Revision$
- */
- at Stateful(name="testParentStateful")
- at Clustered
-// Mimic explict failover
- at Interceptors({ExplicitFailoverInterceptor.class})
- at CacheConfig(maxSize=1000, idleTimeoutSeconds=3) // this will get evicted the second time eviction thread wakes up
- at Remote(ParentStatefulRemote.class)
-public class ParentStatefulBean implements java.io.Serializable, ParentStatefulRemote
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 1L;
-
- private static Logger log = Logger.getLogger(ParentStatefulBean.class);
- private int counter = 0;
- private String state;
- public transient VMID myId = null;
- public String name;
-
- @EJB
- private NestedStateful nested;
-
- @EJB
- private ClusteredStatelessRemote slsb;
-
- public int increment()
- {
- counter = nested.increment();
-
- log.debug("INCREMENT - parent counter: " + counter);
- return counter;
- }
-
- public String getHostAddress()
- {
- return System.getProperty(ServerConfig.SERVER_BIND_ADDRESS);
- }
-
- public static int postActivateCalled = 0;
- public static int prePassivateCalled = 0;
-
- /**
- * Sleep to test
- * @throws Exception
- */
- public void longRunning() throws Exception
- {
- log.debug("+++ longRunning() enter ");
- Thread.sleep(10000);
- log.debug("+++ longRunning() leave ");
- }
-
- public int getPostActivate()
- {
- return ParentStatefulBean.postActivateCalled;
- }
-
- public int getPrePassivate()
- {
- return ParentStatefulBean.prePassivateCalled;
- }
-
- public int getNestedPostActivate()
- {
- return NestedStatefulBean.postActivateCalled;
- }
-
- public int getNestedPrePassivate()
- {
- return NestedStatefulBean.prePassivateCalled;
- }
-
- public void setState(String state)
- {
- this.state = state;
- }
-
- public String getState()
- {
- log.debug("getState(): entering ...");
- return this.state;
- }
-
- public NodeAnswer getStatelessState() {
- return slsb.getNodeState();
- }
-
- public void reset()
- {
- state = null;
- counter = 0;
- ParentStatefulBean.postActivateCalled = 0;
- ParentStatefulBean.prePassivateCalled = 0;
- NestedStatefulBean.postActivateCalled = 0;
- NestedStatefulBean.prePassivateCalled = 0;
- }
-
- public void resetActivationCounter()
- {
- ParentStatefulBean.postActivateCalled = 0;
- ParentStatefulBean.prePassivateCalled = 0;
- NestedStatefulBean.postActivateCalled = 0;
- NestedStatefulBean.prePassivateCalled = 0;
- }
-
- @PostActivate
- public void postActivate()
- {
- ++ParentStatefulBean.postActivateCalled;
- if (this.myId == null)
- {
- //it is a failover: we need to assign ourself an id
- this.myId = new VMID();
- }
- log.debug("Activate. My ID: " + this.myId + " name: " + this.name +
- " activate count: " + postActivateCalled);
- }
-
- @PrePassivate
- public void prePassivate()
- {
- ++ParentStatefulBean.prePassivateCalled;
- log.debug("Passivate. My ID: " + this.myId + " name: " + this.name +
- " passivate count: " + prePassivateCalled);
- }
-
- @Remove
- public void remove()
- {
- log.debug("Being removed");
- }
-
- @PostConstruct
- public void ejbCreate()
- {
- this.myId = new VMID();
- log.debug("My ID: " + this.myId);
- }
-
- // Remote Interface implementation ----------------------------------------------
-
- public NodeAnswer getNodeState()
- {
- if (this.myId == null)
- {
- //it is a failover: we need to assign ourself an id
- this.myId = new VMID();
- }
-
- NodeAnswer state = new NodeAnswer(this.myId, this.name);
- log.debug("getNodeState, " + state);
- return state;
- }
-
- public void setName(String name)
- {
- this.name = name;
- log.debug("Name set to " + name);
- }
-
- public void setNameOnlyOnNode(String name, VMID node)
- {
- if (node.equals(this.myId))
- this.setName(name);
- else
- throw new EJBException("Trying to assign value on node " + this.myId + " but this node expected: " + node);
- }
-
- public void setUpFailover(String failover) {
- // To setup the failover property
- log.debug("Setting up failover property: " +failover);
- System.setProperty ("JBossCluster-DoFail", failover);
- }
-}
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ParentStatefulRemote.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ParentStatefulRemote.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/nested/ParentStatefulRemote.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
-package org.jboss.ejb3.test.clusteredsession.nested;
-
-import org.jboss.ejb3.test.clusteredsession.NodeAnswer;
-
-import java.rmi.dgc.VMID;
-
-/**
- * Comment
- *
- * @author Ben Wang
- * @version $Revision$
- */
-public interface ParentStatefulRemote
-{
- int increment();
- String getHostAddress();
-
- int getPostActivate();
-
- int getPrePassivate();
-
- int getNestedPostActivate();
-
- int getNestedPrePassivate();
-
- void setState(String state);
-
- String getState();
-
- NodeAnswer getStatelessState();
-
- void reset();
-
- void resetActivationCounter();
-
- void longRunning() throws Exception;
-
- void remove();
-
- public NodeAnswer getNodeState();
-
- public void setName(String name);
-
- public void setNameOnlyOnNode(String name, VMID node);
-
- public void setUpFailover(String failover);
-}
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/unit/PassivationUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/unit/PassivationUnitTestCase.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/unit/PassivationUnitTestCase.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -21,6 +21,9 @@
/**
* Test SFSB for load-balancing and failover behaviour
*
+ * TODO add a test with a bean configured to not treat replication as
+ * passivation
+ *
* @author Ben.Wang at jboss.org
* @version $Revision$
*/
@@ -74,21 +77,97 @@
+"Looking up testStateful...");
StatefulRemote remote = (StatefulRemote) ctx.lookup("testStateful/remote");
+ int invCount = 0;
+
remote.reset();
+ invCount++;
remote.setState("hello");
- sleep_(11000);
+ invCount++;
+
+ sleep_(11100);
+
assertEquals("hello", remote.getState());
- assertEquals(1, remote.getPrePassivate());
- assertEquals(1, remote.getPostActivate());
+ invCount++;
+
+ assertEquals(invCount, remote.getPrePassivate());
+ invCount++;
+
+ assertEquals(invCount, remote.getPostActivate());
- sleep_(11000);
remote.remove();
}
+ /**
+ * Tests that @CacheConfig.replicationIsPassivation=false works.
+ */
+ public void testIgnoreReplicationStatefulPassivation()
+ throws Exception
+ {
+ log.info("+++ testIgnoreReplicationStatefulPassivation");
+
+ // Connect to the server0 JNDI
+ InitialContext ctx = getInitialContext(0);
+
+ getLog().debug("==================================");
+ getLog().debug(++PassivationUnitTestCase.test +"- "
+ +"Looking up testIgnoreReplicationStateful...");
+ StatefulRemote remote = (StatefulRemote) ctx.lookup("testIgnoreReplicationStateful/remote");
+
+ remote.reset();
+ remote.setState("hello");
+
+ sleep_(11100);
+
+ assertEquals("hello", remote.getState());
+ assertEquals("@PrePassivate count correct", 1, remote.getPrePassivate());
+ assertEquals("@PostActivate count correct", 1, remote.getPostActivate());
+
+ remote.remove();
+ }
+
+ /**
+ * Tests that disabling replication via implementing Optimized works.
+ */
+ public void testOptimizedDisablesReplication()
+ throws Exception
+ {
+ log.info("+++ testOptimizedDisablesReplication");
+
+ // Connect to the server0 JNDI
+ InitialContext ctx = getInitialContext(0);
+
+ getLog().debug("==================================");
+ getLog().debug(++PassivationUnitTestCase.test +"- "
+ +"Looking up testOptimizedStateful...");
+ StatefulRemote remote = (StatefulRemote) ctx.lookup("testOptimizedStateful/remote");
+
+ int invCount = 0;
+ remote.reset();
+ invCount++;
+ remote.setState("hello");
+ invCount++;
+
+ sleep_(10100);
+
+ assertEquals("hello", remote.getState());
+ invCount++;
+
+ // Don't include the regular passivation in the count
+ // since there won't be an event following replication
+ assertEquals(invCount, remote.getPrePassivate());
+ // don't increment count
+ assertEquals(invCount, remote.getPostActivate());
+ // don't increment count
+ // Check that getPostActivate() didn't cause replication
+ assertEquals(invCount, remote.getPrePassivate());
+
+ remote.remove();
+ }
+
/** This is to test failover with passivation
*/
- public void XtestFailoverStatefulPassivation()
+ public void testFailoverStatefulPassivation()
throws Exception
{
log.info("+++ testFiloverStatefulPassivation");
@@ -100,20 +179,21 @@
getLog().debug(++PassivationUnitTestCase.test +"- "
+"Looking up testStateful...");
StatefulRemote stateful = (StatefulRemote) ctx.lookup("testStateful/remote");
+
stateful.reset();
-
+
stateful.setName("The Code");
- NodeAnswer node1 = stateful.getNodeState ();
+ NodeAnswer node1 = stateful.getNodeState();
getLog ().debug ("Node 1 ID: " +node1);
assertEquals("Counter: ", 1, stateful.increment());
assertEquals("Counter: ", 2, stateful.increment());
- sleep_(10000);
+
+ sleep_(10100);
// Now we switch to the other node, simulating a failure on node 1
- //
stateful.setUpFailover("once");
- NodeAnswer node2 = stateful.getNodeState ();
+ NodeAnswer node2 = stateful.getNodeState();
assertNotNull("State node: ", node2);
getLog ().debug ("Node 2 ID : " +node2);
@@ -123,12 +203,19 @@
assertEquals ("Node 2: ", "The Code", node2.answer);
stateful.resetActivationCounter(); // This will activate the bean.
- sleep_(10000); // let it get passivated again.
+ int invCount = 1;
+
+ sleep_(10100); // let it get passivated again.
+
assertEquals("Counter: ", 3, stateful.increment());
+ invCount++;
assertEquals("Counter: ", 4, stateful.increment());
- assertEquals(1, stateful.getPostActivate());
- assertEquals(1, stateful.getPrePassivate());
+ invCount++;
+ assertEquals(invCount, stateful.getPrePassivate());
+ invCount++;
+ assertEquals(invCount, stateful.getPostActivate());
+
stateful.remove();
}
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/BaseNestedStatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/BaseNestedStatefulBean.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/BaseNestedStatefulBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
-package org.jboss.ejb3.test.stateful.nested;
-
-import javax.ejb.Remove;
-
-import org.jboss.logging.Logger;
-
-/**
- * Base class for a nested SFSB. Declares no class annotations,
- * giving subclasses configuration freedom.
- *
- * @author Ben Wang
- * @author Brian Stansberry
- *
- * @version $Revision: 45372 $
- */
-public abstract class BaseNestedStatefulBean
- implements java.io.Serializable, NestedStateful
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 1L;
-
- protected Logger log = Logger.getLogger(getClass());
- private int counter = 0;
-
- public int increment()
- {
- counter++;
- log.debug("INCREMENT - counter: " + counter);
- return counter;
- }
-
- public void reset()
- {
- log.debug("Being reset");
- counter = 0;
- }
-
- @Remove
- public void remove()
- {
- log.debug("Being removed");
- }
-
- protected int getCounter()
- {
- return counter;
- }
-}
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/LocalNestedStatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/LocalNestedStatefulBean.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/LocalNestedStatefulBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
-package org.jboss.ejb3.test.stateful.nested;
-
-import javax.ejb.Local;
-import javax.ejb.PostActivate;
-import javax.ejb.PrePassivate;
-import javax.ejb.Stateful;
-
-import org.jboss.annotation.ejb.cache.simple.CacheConfig;
-
-/**
- * Nested SFSB with only a local interface.
- *
- * @author Ben Wang
- * @author Brian Stansberry
- *
- * @version $Revision: 45372 $
- */
- at Stateful(name="testLocalNestedStateful")
-// We don't want this passivated, so give it a very long timeout
- at CacheConfig(maxSize=10000, idleTimeoutSeconds=10000)
- at Local(NestedStateful.class)
-public class LocalNestedStatefulBean extends BaseNestedStatefulBean
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 1L;
-
- public static int postActivateCalled = 0;
- public static int prePassivateCalled = 0;
-
- @PostActivate
- public void postActivate()
- {
- ++postActivateCalled;
- log.debug("Activate with counter: " + getCounter() + " -- activate count: "
- + postActivateCalled );
- }
-
- @PrePassivate
- public void prePassivate()
- {
- ++prePassivateCalled;
- log.debug("Passivate with counter: " + getCounter() + " -- passivate count: "
- + prePassivateCalled );
- }
-
- public int getPostActivate()
- {
- return postActivateCalled;
- }
-
- public int getPrePassivate()
- {
- return prePassivateCalled;
- }
-
- public void reset()
- {
- super.reset();
- postActivateCalled = 0;
- prePassivateCalled = 0;
- }
-}
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/NestedStateful.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/NestedStateful.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/NestedStateful.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -1,23 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
-package org.jboss.ejb3.test.stateful.nested;
-
-/**
- * Comment
- *
- * @author Ben Wang
- * @version $Revision$
- */
-public interface NestedStateful extends Removable
-{
- int increment();
- void reset();
-
- int getPostActivate();
- int getPrePassivate();
-}
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/NestedStatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/NestedStatefulBean.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/NestedStatefulBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -1,68 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
-package org.jboss.ejb3.test.stateful.nested;
-
-import javax.ejb.PostActivate;
-import javax.ejb.PrePassivate;
-import javax.ejb.Remote;
-import javax.ejb.Stateful;
-
-import org.jboss.annotation.ejb.cache.simple.CacheConfig;
-
-/**
- * Nested SFSB with a remote interface
- *
- * @author Ben Wang
- * @author Brian Stansberry
- *
- * @version $Revision$
- */
- at Stateful(name="testNestedStateful")
- at CacheConfig(maxSize=1000, idleTimeoutSeconds=1) // this will get evicted the second time eviction thread wakes up
- at Remote(NestedStateful.class)
-public class NestedStatefulBean extends BaseNestedStatefulBean
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 1L;
-
- public static int postActivateCalled = 0;
- public static int prePassivateCalled = 0;
-
- @PostActivate
- public void postActivate()
- {
- ++postActivateCalled;
- log.debug("Activate with counter: " + getCounter() + " -- activate count: "
- + postActivateCalled );
- }
-
- @PrePassivate
- public void prePassivate()
- {
- ++prePassivateCalled;
- log.debug("Passivate with counter: " + getCounter() + " -- passivate count: "
- + prePassivateCalled );
- }
-
- public int getPostActivate()
- {
- return postActivateCalled;
- }
-
- public int getPrePassivate()
- {
- return prePassivateCalled;
- }
-
- public void reset()
- {
- super.reset();
- postActivateCalled = 0;
- prePassivateCalled = 0;
- }
-}
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/ParentStatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/ParentStatefulBean.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/ParentStatefulBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -1,133 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
-package org.jboss.ejb3.test.stateful.nested;
-
-import org.jboss.annotation.ejb.cache.simple.CacheConfig;
-import org.jboss.logging.Logger;
-
-import javax.ejb.*;
-import javax.annotation.PostConstruct;
-import javax.ejb.EJB;
-
-/**
- * Parent SFSB that contains nested SFSB
- *
- * @author Ben Wang
- * @version $Revision$
- */
- at Stateful(name="testParentStateful")
- at CacheConfig(maxSize=1000, idleTimeoutSeconds=1) // this will get evicted the second time eviction thread wakes up
- at Remote(ParentStatefulRemote.class)
-public class ParentStatefulBean implements java.io.Serializable, ParentStatefulRemote
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 1L;
-
- private Logger log = Logger.getLogger(ParentStatefulBean.class);
- private int counter = 0;
- private int localCounter = 0;
-
- @EJB(beanName="testNestedStateful")
- private NestedStateful nested;
-
- @EJB(beanName="testLocalNestedStateful")
- private NestedStateful localNested;
-
- public int increment()
- {
- counter = nested.increment();
-
- log.debug("INCREMENT - counter: " + counter);
- return counter;
- }
-
- public int incrementLocal()
- {
- localCounter = localNested.increment();
-
- log.debug("INCREMENT - localCounter: " + localCounter);
- return localCounter;
- }
-
- public static int postActivateCalled = 0;
- public static int prePassivateCalled = 0;
-
- /**
- * Sleep to test
- * @throws Exception
- */
- public void longRunning() throws Exception
- {
- log.debug("+++ longRunning() enter ");
- Thread.sleep(10000);
- log.debug("+++ longRunning() leave ");
- }
-
- public NestedStateful getNested()
- {
- return nested;
- }
-
- public int getPostActivate()
- {
- return ParentStatefulBean.postActivateCalled;
- }
-
- public int getPrePassivate()
- {
- return ParentStatefulBean.prePassivateCalled;
- }
-
- public int getLocalNestedPostActivate()
- {
- return localNested.getPostActivate();
- }
-
- public int getLocalNestedPrePassivate()
- {
- return localNested.getPrePassivate();
- }
-
- public void reset()
- {
- log.debug("Being reset");
- counter = 0;
- postActivateCalled = 0;
- prePassivateCalled = 0;
- nested.reset();
- localNested.reset();
- }
-
- @PostActivate
- public void postActivate()
- {
- ++ParentStatefulBean.postActivateCalled;
- log.debug("Activate with counter: " + counter);
- }
-
- @PrePassivate
- public void prePassivate()
- {
- ++ParentStatefulBean.prePassivateCalled;
- log.debug("Passivate with counter: " + counter);
- }
-
- @Remove
- public void remove()
- {
- log.debug("Being removed");
- }
-
- @PostConstruct
- public void ejbCreate()
- {
- }
-
- // Remote Interface implementation ----------------------------------------------
-
-}
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/ParentStatefulRemote.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/ParentStatefulRemote.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/ParentStatefulRemote.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
-package org.jboss.ejb3.test.stateful.nested;
-
-/**
- * Parent sfsb interface
- *
- * @author Ben Wang
- * @author Brian Stansberry
- * @version $Revision$
- */
-public interface ParentStatefulRemote extends Removable
-{
- int increment();
-
- int incrementLocal();
-
- int getPostActivate();
-
- int getPrePassivate();
-
- void reset();
-
- void longRunning() throws Exception;
-
- NestedStateful getNested();
-
- int getLocalNestedPostActivate();
-
- int getLocalNestedPrePassivate();
-}
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/Removable.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/Removable.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/Removable.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -1,34 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.ejb3.test.stateful.nested;
-
-/**
- * An SFSB with a remove method.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1.1 $
- */
-public interface Removable
-{
- void remove();
-}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleContainedBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleContainedBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleContainedBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.annotation.ejb.cache.simple.CacheConfig;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.Contained;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.ContainedBean;
+
+/**
+ * ContainedBean bean meant for testing with a non-clustered SFSB cache.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateful(name="testShoppingCartContained")
+ at CacheConfig(maxSize = 1000, idleTimeoutSeconds = 1)
+ at Remote(Contained.class)
+public class SimpleContainedBean extends ContainedBean
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleDeepNestedContainedBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleDeepNestedContainedBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleDeepNestedContainedBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested;
+
+import javax.ejb.Local;
+import javax.ejb.Stateful;
+
+import org.jboss.annotation.ejb.cache.simple.CacheConfig;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.DeepNestedContained;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.DeepNestedContainedBean;
+
+/**
+ * A SimpleDeepNestedStatefulBean.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateful(name="testDeepNestedContained")
+ at CacheConfig(maxSize=10000, idleTimeoutSeconds=1)
+ at Local(DeepNestedContained.class)
+public class SimpleDeepNestedContainedBean extends DeepNestedContainedBean
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleDeepNestedStatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleDeepNestedStatefulBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleDeepNestedStatefulBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested;
+
+import javax.ejb.Local;
+import javax.ejb.Stateful;
+
+import org.jboss.annotation.ejb.cache.simple.CacheConfig;
+import org.jboss.ejb3.test.stateful.nested.base.DeepNestedStateful;
+import org.jboss.ejb3.test.stateful.nested.base.DeepNestedStatefulBean;
+
+/**
+ * A SimpleDeepNestedStatefulBean.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateful(name="testDeepNestedStateful")
+ at CacheConfig(maxSize=10000, idleTimeoutSeconds=1)
+ at Local(DeepNestedStateful.class)
+public class SimpleDeepNestedStatefulBean extends DeepNestedStatefulBean
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleLocalContainedBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleLocalContainedBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleLocalContainedBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested;
+
+import javax.ejb.Local;
+import javax.ejb.Stateful;
+
+import org.jboss.annotation.ejb.cache.simple.CacheConfig;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.Contained;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.ContainedBean;
+
+/**
+ * ContainedBean bean meant for testing with a non-clustered SFSB cache.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateful(name="testLocalShoppingCartContained")
+ at CacheConfig(maxSize = 1000, idleTimeoutSeconds = 1)
+ at Local(Contained.class)
+public class SimpleLocalContainedBean extends ContainedBean
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+}
Copied: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleLocalNestedStatefulBean.java (from rev 60293, trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/LocalNestedStatefulBean.java)
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleLocalNestedStatefulBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleLocalNestedStatefulBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested;
+
+import javax.ejb.Local;
+import javax.ejb.Stateful;
+
+import org.jboss.annotation.ejb.cache.simple.CacheConfig;
+import org.jboss.ejb3.test.stateful.nested.base.std.NestedStateful;
+import org.jboss.ejb3.test.stateful.nested.base.std.NestedStatefulBean;
+
+/**
+ * Nested SFSB with only a local interface.
+ *
+ * @author Ben Wang
+ * @author Brian Stansberry
+ *
+ * @version $Revision: 45372 $
+ */
+ at Stateful(name="testLocalNestedStateful")
+ at CacheConfig(maxSize=10000, idleTimeoutSeconds=1)
+ at Local(NestedStateful.class)
+public class SimpleLocalNestedStatefulBean extends NestedStatefulBean
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+}
Copied: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleParentStatefulBean.java (from rev 60408, trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/ParentStatefulBean.java)
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleParentStatefulBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleParentStatefulBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.annotation.ejb.cache.simple.CacheConfig;
+import org.jboss.ejb3.test.stateful.nested.base.std.ParentStatefulBean;
+import org.jboss.ejb3.test.stateful.nested.base.std.ParentStatefulRemote;
+
+/**
+ * Parent SFSB that contains nested SFSB.
+ *
+ * @author Ben Wang
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+ at Stateful(name="testParentStateful")
+ at CacheConfig(maxSize=1000, idleTimeoutSeconds=1) // this will get evicted the second time eviction thread wakes up
+ at Remote(ParentStatefulRemote.class)
+public class SimpleParentStatefulBean extends ParentStatefulBean
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+}
Copied: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleRemoteNestedStatefulBean.java (from rev 60293, trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/NestedStatefulBean.java)
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleRemoteNestedStatefulBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleRemoteNestedStatefulBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.annotation.ejb.cache.simple.CacheConfig;
+import org.jboss.ejb3.test.stateful.nested.base.std.NestedStateful;
+import org.jboss.ejb3.test.stateful.nested.base.std.OptimizedNestedStatefulBean;
+
+/**
+ * Nested SFSB with a remote interface.
+ *
+ * @author Ben Wang
+ * @author Brian Stansberry
+ *
+ * @version $Revision$
+ */
+ at Stateful(name="testNestedStateful")
+ at CacheConfig(maxSize=1000, idleTimeoutSeconds=1)
+ at Remote(NestedStateful.class)
+public class SimpleRemoteNestedStatefulBean extends OptimizedNestedStatefulBean
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleShoppingCartBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleShoppingCartBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/SimpleShoppingCartBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.annotation.ejb.cache.simple.CacheConfig;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.ShoppingCart;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.ShoppingCartBean;
+
+/**
+ * ShoppingCartBean subclass for testing with a non-clustered SFSB cache.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateful(name="testShoppingCart")
+ at Remote(ShoppingCart.class)
+ at CacheConfig(maxSize = 1000, idleTimeoutSeconds = 1)
+public class SimpleShoppingCartBean extends ShoppingCartBean
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/BeanMonitor.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/BeanMonitor.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/BeanMonitor.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base;
+
+import java.rmi.dgc.VMID;
+
+public interface BeanMonitor extends Removable
+{
+ VMID getVMID();
+
+ void monitor(TopLevel topLevel);
+
+ String getDeepNestedId();
+
+ String getLocalDeepNestedId();
+
+ int getParentPassivations();
+
+ int getNestedPassivations();
+
+ int getLocalNestedPassivations();
+
+ int getDeepNestedPassivations();
+
+ int getLocalDeepNestedPassivations();
+
+ int getParentActivations();
+
+ int getNestedActivations();
+
+ int getLocalNestedActivations();
+
+ int getDeepNestedActivations();
+
+ int getLocalDeepNestedActivations();
+
+ boolean removeParent();
+
+ boolean removeNested();
+
+ boolean removeLocalNested();
+
+ boolean removeDeepNested();
+
+ boolean removeLocalDeepNested();
+
+}
\ No newline at end of file
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/BeanMonitorBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/BeanMonitorBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/BeanMonitorBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,305 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base;
+
+import java.rmi.dgc.VMID;
+
+import javax.ejb.Remote;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+
+import org.jboss.logging.Logger;
+
+/**
+ * A BeanMonitorBean.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public class BeanMonitorBean implements BeanMonitor
+{
+ protected Logger log = Logger.getLogger(getClass());
+
+ protected TopLevel parent;
+ protected MidLevel nested;
+ protected MidLevel localNested;
+ protected DeepNestedStateful deepNested;
+ protected DeepNestedStateful localDeepNested;
+
+ public VMID getVMID()
+ {
+ return VMTracker.VMID;
+ }
+
+ public void monitor(TopLevel topLevel)
+ {
+ this.parent = topLevel;
+ log.debug("parent is " + parent);
+ this.nested = parent.getNested();
+ log.debug("nested is " + nested);
+ this.localNested = parent.getLocalNested();
+ log.debug("localNested is " + localNested);
+ this.deepNested = nested.getDeepNestedStateful();
+ log.debug("deepNested is " + deepNested);
+ this.localDeepNested = localNested.getDeepNestedStateful();
+ log.debug("localDeepNested is " + localDeepNested);
+ }
+
+ public String getDeepNestedId()
+ {
+ try
+ {
+ return deepNested.getInternalId();
+ }
+ catch (Exception e)
+ {
+ log.debug("getDeepNestedId() " + e.getLocalizedMessage());
+ return "ERROR";
+ }
+ }
+
+ public String getLocalDeepNestedId()
+ {
+ try
+ {
+ return localDeepNested.getInternalId();
+ }
+ catch (Exception e)
+ {
+ log.debug("getLocalDeepNestedId() " + e.getLocalizedMessage());
+ return "ERROR";
+ }
+ }
+
+ public int getParentPassivations()
+ {
+ try
+ {
+ return parent.getPrePassivate();
+ }
+ catch (Exception e)
+ {
+ log.debug("getParentPassivations() " + e.getLocalizedMessage());
+ return -1;
+ }
+ }
+
+ public int getNestedPassivations()
+ {
+ try
+ {
+ return nested.getPrePassivate();
+ }
+ catch (Exception e)
+ {
+ log.debug("getNestedPassivations() " + e.getLocalizedMessage());
+ return -1;
+ }
+ }
+
+ public int getLocalNestedPassivations()
+ {
+ try
+ {
+ return localNested.getPrePassivate();
+ }
+ catch (Exception e)
+ {
+ log.debug("getLocalNestedPassivations() " + e.getLocalizedMessage());
+ return -1;
+ }
+ }
+
+ public int getDeepNestedPassivations()
+ {
+ try
+ {
+ return deepNested.getPrePassivate();
+ }
+ catch (Exception e)
+ {
+ log.debug("getDeepNestedPassivations() " + e.getLocalizedMessage());
+ return -1;
+ }
+ }
+
+ public int getLocalDeepNestedPassivations()
+ {
+ try
+ {
+ return localDeepNested.getPrePassivate();
+ }
+ catch (Exception e)
+ {
+ log.debug("getLocalDeepNestedPassivations() " + e.getLocalizedMessage());
+ return -1;
+ }
+ }
+
+ public int getParentActivations()
+ {
+ try
+ {
+ return parent.getPostActivate();
+ }
+ catch (Exception e)
+ {
+ log.debug("getParentActivations() " + e.getLocalizedMessage());
+ return -1;
+ }
+ }
+
+ public int getNestedActivations()
+ {
+ try
+ {
+ return nested.getPostActivate();
+ }
+ catch (Exception e)
+ {
+ log.debug("getNestedActivations() " + e.getLocalizedMessage());
+ return -1;
+ }
+ }
+
+ public int getLocalNestedActivations()
+ {
+ try
+ {
+ return localNested.getPostActivate();
+ }
+ catch (Exception e)
+ {
+ log.debug("getLocalNestedActivations() " + e.getLocalizedMessage());
+ return -1;
+ }
+ }
+
+ public int getDeepNestedActivations()
+ {
+ try
+ {
+ return deepNested.getPostActivate();
+ }
+ catch (Exception e)
+ {
+ log.debug("getDeepNestedActivations() " + e.getLocalizedMessage());
+ return -1;
+ }
+ }
+
+ public int getLocalDeepNestedActivations()
+ {
+ try
+ {
+ return localDeepNested.getPostActivate();
+ }
+ catch (Exception e)
+ {
+ log.debug("getLocalDeepNestedActivations() " + e.getLocalizedMessage());
+ return -1;
+ }
+ }
+
+ public boolean removeParent()
+ {
+ try
+ {
+ parent.remove();
+ return true;
+ }
+ catch (Exception e)
+ {
+ log.debug("removeParent() " + e.getLocalizedMessage());
+ return false;
+ }
+ }
+
+ public boolean removeNested()
+ {
+ try
+ {
+ nested.remove();
+ return true;
+ }
+ catch (Exception e)
+ {
+ log.debug("removeNested() " + e.getLocalizedMessage());
+ return false;
+ }
+ }
+
+ public boolean removeLocalNested()
+ {
+ try
+ {
+ localNested.remove();
+ return true;
+ }
+ catch (Exception e)
+ {
+ log.debug("removeLocalNested() " + e.getLocalizedMessage());
+ return false;
+ }
+ }
+
+ public boolean removeDeepNested()
+ {
+ try
+ {
+ deepNested.remove();
+ return true;
+ }
+ catch (Exception e)
+ {
+ log.debug("removeDeepNested() " + e.getLocalizedMessage());
+ return false;
+ }
+ }
+
+ public boolean removeLocalDeepNested()
+ {
+ try
+ {
+ localDeepNested.remove();
+ return true;
+ }
+ catch (Exception e)
+ {
+ log.debug("removeLocalDeepNested() " + e.getLocalizedMessage());
+ return false;
+ }
+ }
+
+ @Remove
+ public void remove()
+ {
+ log.debug("Being removed");
+ removeParent();
+ removeNested();
+ removeLocalNested();
+ removeDeepNested();
+ removeLocalDeepNested();
+ }
+
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/DeepNestedStateful.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/DeepNestedStateful.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/DeepNestedStateful.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base;
+
+/**
+ * A nested SFSB that operates at the 3rd level of a tree of beans.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public interface DeepNestedStateful extends PassivationActivationWatcher
+{
+ String getInternalId();
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/DeepNestedStatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/DeepNestedStatefulBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/DeepNestedStatefulBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base;
+
+import javax.ejb.Remove;
+
+import org.jboss.util.id.GUID;
+
+/**
+ * A DeepNestedStatefulBean.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeepNestedStatefulBean
+ extends PassivationActivationWatcherBean
+ implements DeepNestedStateful
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ private String internalId = new GUID().toString();
+
+ public String getInternalId()
+ {
+ return internalId;
+ }
+
+ @Remove
+ public void remove()
+ {
+ log.debug(internalId + " is being removed");
+ }
+
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/MidLevel.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/MidLevel.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/MidLevel.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base;
+
+/**
+ * A MidLevel.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public interface MidLevel extends PassivationActivationWatcher
+{
+ DeepNestedStateful getDeepNestedStateful();
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/PassivationActivationWatcher.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/PassivationActivationWatcher.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/PassivationActivationWatcher.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful.nested.base;
+
+/**
+ * Interface for a bean that tracks the number invocations of @PrePassivate
+ * and @PostActivate.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public interface PassivationActivationWatcher extends Removable
+{
+ int getPostActivate();
+
+ int getPrePassivate();
+
+ void reset();
+}
\ No newline at end of file
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/PassivationActivationWatcherBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/PassivationActivationWatcherBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/PassivationActivationWatcherBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful.nested.base;
+
+import java.io.Serializable;
+
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Superclass for SFSBs that monitor calls to @PrePassivate and @PostActivate.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class PassivationActivationWatcherBean
+ implements Serializable, PassivationActivationWatcher
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ protected Logger log = Logger.getLogger(getClass());
+ private int postActivateCalled = 0;
+ private int prePassivateCalled = 0;
+
+ public PassivationActivationWatcherBean()
+ {
+ super();
+ }
+
+ @PostActivate
+ public void postActivate()
+ {
+ postActivateCalled++;
+ int sysHC = System.identityHashCode(this);
+ log.debug(sysHC + ": Activated -- activate count = " + postActivateCalled );
+ }
+
+ @PrePassivate
+ public void prePassivate()
+ {
+ prePassivateCalled++;
+ int sysHC = System.identityHashCode(this);
+ log.debug(sysHC + ": Passivated -- passivate count = " + prePassivateCalled );
+ }
+
+ public int getPostActivate()
+ {
+ int sysHC = System.identityHashCode(this);
+ log.debug(sysHC + ": getPostActivate() -- activate count = " +
+ postActivateCalled );
+ return postActivateCalled;
+ }
+
+ public int getPrePassivate()
+ {
+ int sysHC = System.identityHashCode(this);
+ log.debug(sysHC + ": getPrePassivate() -- passivate count = " +
+ prePassivateCalled );
+ return prePassivateCalled;
+ }
+
+ public void reset()
+ {
+ int sysHC = System.identityHashCode(this);
+ log.debug(sysHC + "Being reset");
+ prePassivateCalled = 0;
+ postActivateCalled = 0;
+ }
+
+}
\ No newline at end of file
Copied: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/Removable.java (from rev 60293, trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/Removable.java)
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/Removable.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/Removable.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base;
+
+/**
+ * An SFSB with a remove method.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Removable
+{
+ void remove();
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/TopLevel.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/TopLevel.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/TopLevel.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base;
+
+/**
+ * A TopLevel.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public interface TopLevel extends PassivationActivationWatcher
+{
+ MidLevel getNested();
+
+ MidLevel getLocalNested();
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/VMTracker.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/VMTracker.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/VMTracker.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base;
+
+import java.rmi.dgc.VMID;
+
+/**
+ * Provides SLSB access to a static VMID field.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public interface VMTracker
+{
+ public static final VMID VMID = new VMID();
+
+ VMID getVMID();
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/VMTrackerBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/VMTrackerBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/VMTrackerBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base;
+
+import java.rmi.dgc.VMID;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+/**
+ * Provides SLSB access to a static VMID (allowing identification of a JVM.)
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateless
+ at Remote(VMTracker.class)
+public class VMTrackerBean implements VMTracker
+{
+ public VMID getVMID()
+ {
+ return VMID;
+ }
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/NestedBeanMonitor.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/NestedBeanMonitor.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/NestedBeanMonitor.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base.std;
+
+import org.jboss.ejb3.test.stateful.nested.base.BeanMonitor;
+import org.jboss.ejb3.test.stateful.nested.base.Removable;
+
+
+/**
+ * SFSB that can monitor a ParentStatefulRemote and its affiliated beans.
+ * Basically an in-VM client that has refs to all the SFSBs in the bean
+ * structure.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public interface NestedBeanMonitor extends BeanMonitor
+{
+ int incrementParent();
+ int incrementNested();
+ int incrementLocalNested();
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/NestedBeanMonitorBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/NestedBeanMonitorBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/NestedBeanMonitorBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base.std;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+
+import org.jboss.ejb3.test.stateful.nested.base.BeanMonitorBean;
+import org.jboss.ejb3.test.stateful.nested.base.TopLevel;
+
+/**
+ * A NestedBeanMonitorBean.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateful
+ at Remote(NestedBeanMonitor.class)
+ at TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
+public class NestedBeanMonitorBean
+ extends BeanMonitorBean
+ implements NestedBeanMonitor
+{
+ public void monitor(TopLevel topLevel)
+ {
+ // Just do a cast to confirm the type
+ super.monitor((ParentStatefulRemote) topLevel);
+ }
+
+ public int incrementParent()
+ {
+ try
+ {
+ return ((ParentStatefulRemote) parent).increment();
+ }
+ catch (Exception e)
+ {
+ log.debug("incrementParent() " + e.getLocalizedMessage());
+ return -1;
+ }
+ }
+
+ public int incrementNested()
+ {
+ try
+ {
+ return ((NestedStateful) nested).increment();
+ }
+ catch (Exception e)
+ {
+ log.debug("incrementNested() " + e.getLocalizedMessage());
+ return -1;
+ }
+ }
+
+ public int incrementLocalNested()
+ {
+ try
+ {
+ return ((NestedStateful) localNested).increment();
+ }
+ catch (Exception e)
+ {
+ log.debug("incrementLocalNested() " + e.getLocalizedMessage());
+ return -1;
+ }
+ }
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/NestedStateful.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/NestedStateful.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/NestedStateful.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,22 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base.std;
+
+import org.jboss.ejb3.test.stateful.nested.base.MidLevel;
+
+
+/**
+ * Comment
+ *
+ * @author Ben Wang
+ * @version $Revision: 60066 $
+ */
+public interface NestedStateful extends MidLevel
+{
+ int increment();
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/NestedStatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/NestedStatefulBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/NestedStatefulBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base.std;
+
+import javax.ejb.EJB;
+import javax.ejb.Remove;
+
+import org.jboss.ejb3.test.stateful.nested.base.DeepNestedStateful;
+import org.jboss.ejb3.test.stateful.nested.base.PassivationActivationWatcherBean;
+
+/**
+ * Base class for a nested SFSB. Declares no class annotations,
+ * giving subclasses configuration freedom.
+ *
+ * @author Ben Wang
+ * @author Brian Stansberry
+ *
+ * @version $Revision: 45372 $
+ */
+public abstract class NestedStatefulBean extends PassivationActivationWatcherBean
+ implements NestedStateful
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ private int counter = 0;
+
+ @EJB(name="testDeepNestedStateful")
+ private DeepNestedStateful deepNestedStateful;
+
+ public void reset()
+ {
+ super.reset();
+ counter = 0;
+ deepNestedStateful.reset();
+ }
+
+ public int increment()
+ {
+ counter++;
+ log.debug("INCREMENT - counter: " + counter);
+ return counter;
+ }
+
+ @Remove
+ public void remove()
+ {
+ log.debug("Being removed");
+ }
+
+
+ public DeepNestedStateful getDeepNestedStateful()
+ {
+ return deepNestedStateful;
+ }
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/OptimizedNestedStatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/OptimizedNestedStatefulBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/OptimizedNestedStatefulBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base.std;
+
+import org.jboss.ejb3.cache.Optimized;
+
+/**
+ * NestedStatefulBean subclass that implements Optimized in such a way
+ * that getPrePassivate() and getPostActivate() calls are treated as
+ * non-modifications.
+ *
+ * @author Ben Wang
+ * @author Brian Stansberry
+ *
+ * @version $Revision: 45372 $
+ */
+public abstract class OptimizedNestedStatefulBean
+ extends NestedStatefulBean
+ implements Optimized
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ private boolean modified = true;
+
+
+ public boolean isModified()
+ {
+ boolean answer = modified;
+ modified = true;
+ return answer;
+ }
+
+ @Override
+ public int getPostActivate()
+ {
+ // by default all calls except these passivate/activate checks
+ // are modifications, so set modified to false
+ modified = false;
+ return super.getPostActivate();
+ }
+
+ @Override
+ public int getPrePassivate()
+ {
+ // by default all calls except these passivate/activate checks
+ // are modifications, so set modified to false
+ modified = false;
+ return super.getPrePassivate();
+ }
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/ParentStatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/ParentStatefulBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/ParentStatefulBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base.std;
+
+import java.rmi.dgc.VMID;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.EJB;
+import javax.ejb.Remove;
+
+import org.jboss.ejb3.test.stateful.nested.base.MidLevel;
+import org.jboss.ejb3.test.stateful.nested.base.PassivationActivationWatcherBean;
+import org.jboss.ejb3.test.stateful.nested.base.VMTracker;
+
+/**
+ * Parent SFSB that contains nested SFSBs. We don't
+ * annotate it with @Stateful or @CacheConfig so the
+ * subclasses used by the clustered and non-clustered tests
+ * can do that.
+ *
+ * NOTE: EJBTHREE-778 prevents us annotating this class
+ * @Remote(ParentStatefulRemote.class), but we would if we could. Currently
+ * the subclasses need to do it.
+ *
+ * @author Ben Wang
+ * @version $Revision: 60408 $
+ */
+public class ParentStatefulBean
+ extends PassivationActivationWatcherBean
+ implements ParentStatefulRemote
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ private int counter = 0;
+ private int localCounter = 0;
+
+ @EJB(beanName="testNestedStateful")
+ private NestedStateful nested;
+
+ @EJB(beanName="testLocalNestedStateful")
+ private NestedStateful localNested;
+
+ public VMID getVMID()
+ {
+ return VMTracker.VMID;
+ }
+
+ public int increment()
+ {
+ counter = nested.increment();
+
+ log.debug("INCREMENT - counter: " + counter);
+ return counter;
+ }
+
+ public int incrementLocal()
+ {
+ localCounter = localNested.increment();
+
+ log.debug("INCREMENT - localCounter: " + localCounter);
+ return localCounter;
+ }
+
+ /**
+ * Sleep to test
+ * @throws Exception
+ */
+ public void longRunning() throws Exception
+ {
+ log.debug("+++ longRunning() enter ");
+ Thread.sleep(10000);
+ log.debug("+++ longRunning() leave ");
+ }
+
+ public MidLevel getNested()
+ {
+ return nested;
+ }
+
+ public MidLevel getLocalNested()
+ {
+ return localNested;
+ }
+
+ public int getLocalNestedPostActivate()
+ {
+ return localNested.getPostActivate();
+ }
+
+ public int getLocalNestedPrePassivate()
+ {
+ return localNested.getPrePassivate();
+ }
+
+ public void reset()
+ {
+ super.reset();
+ counter = 0;
+ nested.reset();
+ localNested.reset();
+ }
+
+ @Remove
+ public void remove()
+ {
+ log.debug("Being removed");
+ }
+
+ public void setUpFailover(String failover)
+ {
+ // To setup the failover property
+ log.debug("Setting up failover property: " +failover);
+ System.setProperty ("JBossCluster-DoFail", failover);
+ }
+
+ @PostConstruct
+ public void ejbCreate()
+ {
+ }
+
+ // Remote Interface implementation ----------------------------------------------
+
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/ParentStatefulRemote.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/ParentStatefulRemote.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/std/ParentStatefulRemote.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base.std;
+
+import java.rmi.dgc.VMID;
+
+import org.jboss.ejb3.test.stateful.nested.base.TopLevel;
+
+
+/**
+ * Parent sfsb interface
+ *
+ * @author Ben Wang
+ * @author Brian Stansberry
+ * @version $Revision: 60066 $
+ */
+public interface ParentStatefulRemote
+ extends TopLevel
+{
+ VMID getVMID();
+
+ int increment();
+
+ int incrementLocal();
+
+ void longRunning() throws Exception;
+
+ int getLocalNestedPostActivate();
+
+ int getLocalNestedPrePassivate();
+
+ public void setUpFailover(String failover);
+
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/Contained.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/Contained.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/Contained.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ejb3.test.stateful.nested.base.xpc;
+
+import org.jboss.ejb3.test.stateful.nested.base.MidLevel;
+
+
+/**
+ * Comment
+ *
+ * @author Ben Wang
+ * @version $Revision: 46483 $
+ */
+public interface Contained extends MidLevel
+{
+ Customer find(long id);
+
+ void setCustomer(long id);
+
+ Customer getCustomer();
+
+ void updateCustomer();
+
+ void setContainedCustomer();
+
+ boolean checkContainedCustomer();
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/ContainedBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/ContainedBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/ContainedBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,106 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ejb3.test.stateful.nested.base.xpc;
+
+import java.io.Serializable;
+
+import javax.ejb.EJB;
+import javax.ejb.Remove;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+
+import org.jboss.ejb3.test.stateful.nested.base.DeepNestedStateful;
+import org.jboss.ejb3.test.stateful.nested.base.PassivationActivationWatcherBean;
+
+/**
+ * Comment
+ *
+ * @author Ben Wang
+ * @version $Revision: 60062 $
+ */
+public class ContainedBean
+ extends PassivationActivationWatcherBean
+ implements Contained, Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ @PersistenceContext(unitName="tempdb",type=PersistenceContextType.EXTENDED)
+ private EntityManager em;
+
+ @EJB(beanName="testDeepNestedContained")
+ private DeepNestedContained deepNestedContained;
+
+ private Customer customer;
+
+ public Customer find(long id)
+ {
+ Customer c = em.find(Customer.class, id);
+ log.trace("customer " + id + " = " + c);
+ return c;
+ }
+
+ public void setCustomer(long id)
+ {
+ customer = find(id);
+ }
+
+ public Customer getCustomer()
+ {
+ return customer;
+ }
+
+ public void updateCustomer()
+ {
+ customer.setName("contained modified");
+ }
+
+ public void setContainedCustomer()
+ {
+ deepNestedContained.setCustomer(customer.getId());
+ }
+
+ public boolean checkContainedCustomer()
+ {
+ return (deepNestedContained.getCustomer() == customer);
+ }
+
+ @Remove
+ public void remove()
+ {
+
+ }
+
+ public DeepNestedStateful getDeepNestedStateful()
+ {
+ return deepNestedContained;
+ }
+
+ public void reset()
+ {
+ super.reset();
+ deepNestedContained.reset();
+ }
+
+
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/Customer.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/Customer.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/Customer.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful.nested.base.xpc;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue; import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ * Company customer
+ *
+ * @author Ben Wang
+ */
+ at Entity
+public class Customer implements java.io.Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ long id;
+ String name;
+
+ public
+ Customer()
+ {
+ }
+
+ @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
+ public
+ long getId()
+ {
+ return id;
+ }
+
+ public
+ String getName()
+ {
+ return name;
+ }
+
+ public
+ void setId(long long1)
+ {
+ id = long1;
+ }
+
+ public
+ void setName(String string)
+ {
+ name = string;
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+
+ if (obj instanceof Customer)
+ {
+ Customer other = (Customer) obj;
+ String oName = other.name == null ? "" : other.name;
+ return (this.id == other.id)
+ && (oName.equals(this.name));
+
+ }
+
+ return false;
+ }
+
+}
+
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/DeepNestedContained.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/DeepNestedContained.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/DeepNestedContained.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base.xpc;
+
+import org.jboss.ejb3.test.stateful.nested.base.DeepNestedStateful;
+
+/**
+ * A DeepNestedContained.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public interface DeepNestedContained extends DeepNestedStateful
+{
+ Customer find(long id);
+ void setCustomer(long id);
+ Customer getCustomer();
+ void updateCustomer();
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/DeepNestedContainedBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/DeepNestedContainedBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/DeepNestedContainedBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base.xpc;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+
+import org.jboss.ejb3.test.stateful.nested.base.DeepNestedStatefulBean;
+
+/**
+ * A DeepNestedContainedBean.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeepNestedContainedBean
+ extends DeepNestedStatefulBean
+ implements DeepNestedContained
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ @PersistenceContext(unitName="tempdb",type=PersistenceContextType.EXTENDED)
+ private EntityManager em;
+
+ private Customer customer;
+
+ public Customer find(long id)
+ {
+ return em.find(Customer.class, id);
+ }
+
+ public void setCustomer(long id)
+ {
+ customer = find(id);
+ }
+
+ public Customer getCustomer()
+ {
+ return customer;
+ }
+
+ public void updateCustomer()
+ {
+ customer.setName("modified by " + getInternalId());
+ }
+
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedStatelessLocal.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedStatelessLocal.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedStatelessLocal.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful.nested.base.xpc;
+
+import org.jboss.ejb3.test.stateful.nested.base.VMTracker;
+
+
+
+
+/**
+ * comment
+ *
+ * @author Ben Wang
+ */
+public interface NestedStatelessLocal extends VMTracker
+{
+ void update(Customer c);
+
+ void findAndUpdate(long id);
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedStatelessSessionBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedStatelessSessionBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedStatelessSessionBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful.nested.base.xpc;
+
+import javax.ejb.Local;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+
+import org.jboss.ejb3.test.stateful.nested.base.VMTrackerBean;
+
+/**
+ * SLSB that is meant to be nested in a parent SFSB and share
+ * and ExtendedPersistenceContext with it.
+ *
+ * @author Ben Wang
+ * @author Brian Stansberry
+ */
+ at Stateless
+ at Local(NestedStatelessLocal.class)
+public class NestedStatelessSessionBean
+ extends VMTrackerBean
+ implements NestedStatelessLocal
+{
+ @PersistenceContext(unitName="tempdb")
+ private EntityManager em;
+
+ public void update(Customer c)
+ {
+ c.setName("Bill Jr.");
+ }
+
+ public void findAndUpdate(long id)
+ {
+ Customer cust = find(id);
+ cust.setName("stateless modified");
+ }
+
+ public Customer find(long id)
+ {
+ return em.find(Customer.class, id);
+ }
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedXPCMonitor.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedXPCMonitor.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedXPCMonitor.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base.xpc;
+
+import org.jboss.ejb3.test.stateful.nested.base.BeanMonitor;
+
+/**
+ * A NestedXPCBeanMonitor.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public interface NestedXPCMonitor extends BeanMonitor
+{
+ Customer find(long id);
+
+ Customer findParent(long id);
+ Customer findNested(long id);
+ Customer findLocalNested(long id);
+ Customer findDeepNested(long id);
+ Customer findLocalDeepNested(long id);
+
+ boolean compareTopToNested(long id);
+ boolean compareTopToLocalNested(long id);
+ boolean compareNestedToLocalNested(long id);
+ boolean compareNestedToDeepNested(long id);
+ boolean compareLocalNestedToLocalDeepNested(long id);
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedXPCMonitorBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedXPCMonitorBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedXPCMonitorBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,234 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base.xpc;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.ejb3.test.stateful.nested.base.BeanMonitorBean;
+
+/**
+ * A NestedXPCMonitorBean.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateful
+ at Remote(NestedXPCMonitor.class)
+ at TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
+public class NestedXPCMonitorBean
+ extends BeanMonitorBean
+ implements NestedXPCMonitor
+{
+ @PersistenceContext(unitName="tempdb")
+ private EntityManager em;
+
+ private Set<Long> ids = new HashSet<Long>();
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRED)
+ public Customer find(long id)
+ {
+ ids.add(new Long(id));
+ return em.find(Customer.class, id);
+ }
+
+ public boolean compareLocalNestedToLocalDeepNested(long id)
+ {
+ try
+ {
+ Contained midLevel = (Contained) localNested;
+ midLevel.setCustomer(id);
+ midLevel.setContainedCustomer();
+ return midLevel.checkContainedCustomer();
+ }
+ catch (Exception e)
+ {
+ log.debug("compareLocalNestedToDeepNested(): " + e.getLocalizedMessage());
+ }
+ return false;
+ }
+
+ public boolean compareNestedToDeepNested(long id)
+ {
+ try
+ {
+ Contained midLevel = (Contained) nested;
+ midLevel.setCustomer(id);
+ midLevel.setContainedCustomer();
+ return midLevel.checkContainedCustomer();
+ }
+ catch (Exception e)
+ {
+ log.debug("compareNestedToDeepNested(): " + e.getLocalizedMessage());
+ }
+ return false;
+ }
+
+ public boolean compareTopToLocalNested(long id)
+ {
+ try
+ {
+ ShoppingCart cart = (ShoppingCart) parent;
+ cart.setCustomer(id);
+ cart.setContainedCustomer();
+ return cart.checkContainedCustomer();
+ }
+ catch (Exception e)
+ {
+ log.debug("compareTopToLocalNested(): " + e.getLocalizedMessage());
+ }
+ return false;
+ }
+
+ public boolean compareTopToNested(long id)
+ {
+ try
+ {
+ Customer mid = findNested(id);
+ Customer top = findParent(id);
+
+ return (mid != null && mid != top && mid.equals(top)) ;
+ }
+ catch (Exception e)
+ {
+ log.debug("compareTopToNested(): " + e.getLocalizedMessage());
+ }
+ return false;
+ }
+
+ public boolean compareNestedToLocalNested(long id)
+ {
+ try
+ {
+ Customer remote = findNested(id);
+ Customer local = findLocalNested(id);
+
+ return (remote != null && remote.equals(local));
+ }
+ catch (Exception e)
+ {
+ log.debug("compareTopToLocalNested(): " + e.getLocalizedMessage());
+ }
+ return false;
+ }
+
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public Customer findDeepNested(long id)
+ {
+ try
+ {
+ return ((DeepNestedContained) deepNested).find(id);
+ }
+ catch (Exception e)
+ {
+ log.debug("findDeepNested(): " + e.getLocalizedMessage());
+ }
+ return null;
+ }
+
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public Customer findLocalDeepNested(long id)
+ {
+ try
+ {
+ return ((DeepNestedContained) localDeepNested).find(id);
+ }
+ catch (Exception e)
+ {
+ log.debug("findLocalDeepNested(): " + e.getLocalizedMessage());
+ }
+ return null;
+ }
+
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public Customer findLocalNested(long id)
+ {
+ try
+ {
+ return ((Contained) localNested).find(id);
+ }
+ catch (Exception e)
+ {
+ log.debug("findLocalNested(): " + e.getLocalizedMessage());
+ }
+ return null;
+ }
+
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public Customer findNested(long id)
+ {
+ try
+ {
+ return ((Contained) nested).find(id);
+ }
+ catch (Exception e)
+ {
+ log.debug("findNested(): " + e.getLocalizedMessage());
+ }
+ return null;
+ }
+
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public Customer findParent(long id)
+ {
+ try
+ {
+ return ((ShoppingCart) parent).find(id);
+ }
+ catch (Exception e)
+ {
+ log.debug("findParent(): " + e.getLocalizedMessage());
+ }
+ return null;
+ }
+
+ @Override
+ @TransactionAttribute(TransactionAttributeType.REQUIRED)
+ public void remove()
+ {
+ super.remove();
+
+ for (Long id : ids)
+ {
+ try
+ {
+ Customer c = em.find(Customer.class, id.longValue());
+ if (c != null)
+ em.remove(c);
+ }
+ catch (Exception e)
+ {
+ log.debug("remove(): Problem removing " + id, e);
+ }
+ }
+ }
+
+
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/ShoppingCart.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/ShoppingCart.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/ShoppingCart.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful.nested.base.xpc;
+
+import java.rmi.dgc.VMID;
+
+import org.jboss.ejb3.test.stateful.nested.base.PassivationActivationWatcher;
+import org.jboss.ejb3.test.stateful.nested.base.TopLevel;
+
+
+/**
+ * Interface exposed by SFSB used in ExtendedPersistenceContext testing.
+ *
+ * @author Ben Wang
+ * @author Brian Stansberry
+ */
+public interface ShoppingCart
+ extends PassivationActivationWatcher, TopLevel
+{
+ VMID getVMID();
+
+ long createCustomer();
+
+ void update();
+
+ Customer find(long id);
+
+ void update2();
+
+ void update3();
+
+ void never();
+
+ void setCustomer(long id);
+
+ void setContainedCustomer();
+
+ void updateContained();
+
+ void findAndUpdateStateless();
+
+ boolean checkContainedCustomer();
+
+ void setUpFailover(String failover);
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/ShoppingCartBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/ShoppingCartBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/base/xpc/ShoppingCartBean.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,160 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful.nested.base.xpc;
+
+import java.rmi.dgc.VMID;
+
+import javax.ejb.EJB;
+import javax.ejb.Remove;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+
+import org.jboss.ejb3.test.stateful.nested.base.MidLevel;
+import org.jboss.ejb3.test.stateful.nested.base.PassivationActivationWatcherBean;
+import org.jboss.ejb3.test.stateful.nested.base.VMTracker;
+
+/**
+ * Base SFSB for use in ExtendedPersistenceContext testing.
+ *
+ * @author Ben Wang
+ */
+public class ShoppingCartBean
+ extends PassivationActivationWatcherBean
+ implements ShoppingCart
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ @PersistenceContext(unitName="tempdb",type=PersistenceContextType.EXTENDED)
+ private EntityManager em;
+
+ private Customer customer;
+
+ @EJB(beanName="testShoppingCartContained")
+ private Contained contained;
+
+ @EJB(beanName="testLocalShoppingCartContained")
+ private Contained localContained;
+
+ @EJB
+ private NestedStatelessLocal stateless;
+
+ public VMID getVMID()
+ {
+ return VMTracker.VMID;
+ }
+
+ public MidLevel getLocalNested()
+ {
+ return localContained;
+ }
+
+ public MidLevel getNested()
+ {
+ return contained;
+ }
+
+ public long createCustomer()
+ {
+ customer = new Customer();
+ customer.setName("William");
+ em.persist(customer);
+ System.out.println("********* created *****");
+ return customer.getId();
+ }
+
+ public void setCustomer(long id)
+ {
+ customer = find(id);
+ }
+
+ public void setContainedCustomer()
+ {
+ localContained.setCustomer(customer.getId());
+ }
+
+ public boolean checkContainedCustomer()
+ {
+ return (localContained.getCustomer() == customer);
+ }
+
+ public void updateContained()
+ {
+ localContained.updateCustomer();
+ }
+
+ public void update()
+ {
+ System.out.println("********* update() *****");
+ customer.setName("Bill");
+ }
+ public void update2()
+ {
+ customer.setName("Billy");
+ }
+
+ public void update3()
+ {
+ stateless.update(customer);
+ }
+
+ public void findAndUpdateStateless()
+ {
+ stateless.findAndUpdate(customer.getId());
+ if (!customer.getName().equals("stateless modified"))
+ throw new RuntimeException("stateless didn't get propagated pc");
+ }
+
+ public Customer find(long id)
+ {
+ return em.find(Customer.class, id);
+ }
+
+ @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
+ public void never()
+ {
+ customer.setName("Bob");
+ }
+
+ public void reset()
+ {
+ super.reset();
+ contained.reset();
+ localContained.reset();
+ }
+
+
+ @Remove
+ public void remove()
+ {
+ }
+
+ public void setUpFailover(String failover)
+ {
+ // To setup the failover property
+ log.debug("Setting up failover property: " +failover);
+ System.setProperty ("JBossCluster-DoFail", failover);
+ }
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/BaseTestRunner.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/BaseTestRunner.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/BaseTestRunner.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful.unit;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ejb.NoSuchEJBException;
+import javax.naming.InitialContext;
+
+import org.jboss.ejb3.test.stateful.nested.base.Removable;
+import org.jboss.logging.Logger;
+
+/**
+ * Base class for test runners that can share test functionality between
+ * JBossTestCase subclasses and JBossClusteredTestCase subclasses.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public class BaseTestRunner
+{
+ protected InitialContext initialContext;
+ protected Set<Removable> removables = new HashSet<Removable>();
+
+ private Logger log;
+ private long sleepTime = 11100L;
+ private int passivationPerInvocation = 0;
+ private int passivationPerSleep = 1;
+
+ public BaseTestRunner(InitialContext context, Logger log)
+ {
+ this.initialContext = context;
+ this.log = log;
+ }
+
+ public void setUp() throws Exception
+ {
+ }
+
+ public void tearDown() throws Exception
+ {
+ // Remove any EJBs so they don't spuriously passivate and
+ // throw off the passivation counts
+ for (Removable removable : removables)
+ {
+ try
+ {
+ removable.remove();
+ }
+ catch (Exception ignored) {}
+ }
+
+ removables.clear();
+ }
+
+ protected InitialContext getInitialContext()
+ {
+ return initialContext;
+ }
+
+ protected Logger getLog()
+ {
+ return log;
+ }
+
+ public long getSleepTime()
+ {
+ return sleepTime;
+ }
+
+ public void setSleepTime(long sleepTime)
+ {
+ this.sleepTime = sleepTime;
+ }
+
+ public void sleep(long time)
+ {
+ try {
+ Thread.sleep(time);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void sleep()
+ {
+ sleep(getSleepTime());
+ }
+
+ public int getPassivationPerInvocation()
+ {
+ return passivationPerInvocation;
+ }
+
+ public void setPassivationPerInvocation(int passivationPerInvocation)
+ {
+ this.passivationPerInvocation = passivationPerInvocation;
+ }
+
+ public int getPassivationPerSleep()
+ {
+ return passivationPerSleep;
+ }
+
+ public void setPassivationPerSleep(int passivationPerSleep)
+ {
+ this.passivationPerSleep = passivationPerSleep;
+ }
+
+ public int getExpectedPassivations(int sleepCycles, int invocations)
+ {
+ return (sleepCycles * passivationPerSleep) +
+ (invocations * passivationPerInvocation);
+ }
+
+ public void addRemovable(Removable bean)
+ {
+ removables.add(bean);
+ }
+
+ public void removeBean(Removable bean)
+ {
+ try
+ {
+ bean.remove();
+ }
+ catch (NoSuchEJBException ignored)
+ {
+ // this is OK; it was already removed
+ }
+ removables.remove(bean);
+ }
+
+}
\ No newline at end of file
Copied: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/ExtendedPersistenceUnitTestCase.java (from rev 60433, trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/unit/ExtendedPersistenceUnitTestCase.java)
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/ExtendedPersistenceUnitTestCase.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/ExtendedPersistenceUnitTestCase.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful.unit;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.ejb3.test.clusteredentity.unit.DBSetup;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Tests for ExtendedPersistenceContext management.
+ *
+ * This class uses a delegate to execute the tests so the clustered
+ * version of the tests (which derive from a different base class)
+ * can use the same delegate code.
+ *
+ * @author Ben Wang
+ * @version $Id$
+ */
+public class ExtendedPersistenceUnitTestCase extends JBossTestCase
+{
+ private XPCTestRunner runner;
+
+ public ExtendedPersistenceUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ TestSuite suite = new TestSuite();
+ Test t1 = getDeploySetup(ExtendedPersistenceUnitTestCase.class,
+ "stateful-test.jar");
+
+ suite.addTest(t1);
+
+ // Create an initializer for the test suite
+ DBSetup wrapper = new DBSetup(suite);
+ return wrapper;
+ }
+
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ runner = new XPCTestRunner(getInitialContext(), getLog());
+ runner.setUp();
+ // Use a sleep time just a bit longer than twice the bean timeout
+ runner.setSleepTime(2100L);
+ }
+
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ if (runner != null)
+ runner.tearDown();
+ }
+
+
+ public void testBasic() throws Exception
+ {
+ runner.testBasic();
+ }
+
+ public void testDependentLifecycle() throws Exception
+ {
+ runner.testDependentLifecycle();
+ }
+
+ public void testXPCSharing() throws Exception
+ {
+ runner.testXPCSharing();
+ }
+
+ public void testPassivation() throws Exception
+ {
+ runner.testPassivation();
+ }
+
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/NestedBeanTestRunner.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/NestedBeanTestRunner.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/NestedBeanTestRunner.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,355 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful.unit;
+
+import java.rmi.dgc.VMID;
+
+import javax.naming.InitialContext;
+
+import junit.framework.Assert;
+
+import org.jboss.ejb3.test.stateful.nested.base.std.NestedBeanMonitor;
+import org.jboss.ejb3.test.stateful.nested.base.std.NestedStateful;
+import org.jboss.ejb3.test.stateful.nested.base.std.ParentStatefulRemote;
+import org.jboss.logging.Logger;
+
+/**
+ * Encapsulates the functions needed for tests of nested SFSBs in
+ * a class that can be used either by a JBossTestCase subclass or
+ * a JBossClusteredTestCase subclass.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public class NestedBeanTestRunner extends BaseTestRunner
+{
+ public NestedBeanTestRunner(InitialContext context, Logger log)
+ {
+ super(context, log);
+ }
+
+
+ public void testBasic()
+ throws Exception
+ {
+ getLog().debug("Running testBasic()");
+ getLog().debug("==================================");
+
+ NestedBeanSet beanSet = getNestedBeanSet();
+ ParentStatefulRemote stateful = beanSet.parent;
+
+ Assert.assertEquals("Remote counter: ", 1, stateful.increment());
+ Assert.assertEquals("Remote counter: ", 2, stateful.increment());
+ Assert.assertEquals("Local counter: ", 1, stateful.incrementLocal());
+ Assert.assertEquals("Local counter: ", 2, stateful.incrementLocal());
+
+ removeBean(stateful);
+
+ getLog().debug("ok");
+ }
+
+ public void testDependentLifecycle()
+ throws Exception
+ {
+ getLog().debug("Running testDependentLifecycle()");
+ getLog().debug("==================================");
+
+ NestedBeanSet beanSet = getNestedBeanSet();
+ ParentStatefulRemote parent = beanSet.parent;
+ NestedStateful nested = beanSet.nested;
+ NestedBeanMonitor monitor = beanSet.monitor;
+
+ Assert.assertEquals("Remote counter (via parent): ", 1, parent.increment());
+
+ String deepId = monitor.getDeepNestedId();
+ Assert.assertNotNull("Got a deepId", deepId);
+ Assert.assertFalse("Got a non-ERROR deepId", "ERROR".equals(deepId));
+ String localDeepId = monitor.getLocalDeepNestedId();
+ Assert.assertNotNull("Got a localDeepId", localDeepId);
+ Assert.assertFalse("Got a non-ERROR localDeepId", "ERROR".equals(localDeepId));
+
+ removeBean(parent);
+
+ // Confirm parent is dead
+ Assert.assertEquals("Remote counter (via dead parent): ", -1, monitor.incrementParent());
+ Assert.assertFalse("parent.remove() fails", monitor.removeParent());
+
+ // Confirm nested beans still work following parent remove
+ Assert.assertEquals("Remote counter (direct):", 2 ,nested.increment());
+ Assert.assertEquals("Local counter (monitor):", 1 , monitor.incrementLocalNested());
+ Assert.assertEquals("Deep nested id", deepId, monitor.getDeepNestedId());
+ Assert.assertEquals("Local deep nested id", localDeepId, monitor.getLocalDeepNestedId());
+
+ // Remove the bottom tier
+ Assert.assertTrue("Local deep nested removed", monitor.removeLocalDeepNested());
+
+ // Confirm it is dead
+ Assert.assertEquals("Local deep nested removed", "ERROR", monitor.getLocalDeepNestedId());
+ Assert.assertFalse("localDeepNested.remove() fails", monitor.removeLocalDeepNested());
+
+ // Confirm other beans still work following parent remove
+ Assert.assertEquals("Remote counter (direct):", 3 ,nested.increment());
+ Assert.assertEquals("Local counter (monitor):", 2 , monitor.incrementLocalNested());
+ Assert.assertEquals("Deep nested id", deepId, monitor.getDeepNestedId());
+
+ // Remove the nested bean
+ removeBean(nested);
+
+ Assert.assertEquals("Remote counter (via monitor): ", -1, monitor.incrementNested());
+ Assert.assertFalse("nested.remove() fails", monitor.removeNested());
+
+ // Confirm other beans still work
+ Assert.assertEquals("Local counter (monitor):", 3 , monitor.incrementLocalNested());
+ Assert.assertEquals("Deep nested id", deepId, monitor.getDeepNestedId());
+
+ // Remove the local nested bean
+ Assert.assertTrue("Local nested removed", monitor.removeLocalNested());
+
+ // Confirm it is dead
+ Assert.assertEquals("Local nested removed", -1, monitor.incrementLocalNested());
+ Assert.assertFalse("localNested.remove() fails", monitor.removeLocalNested());
+
+ // Confirm other beans still work following parent remove
+ Assert.assertEquals("Deep nested id", deepId, monitor.getDeepNestedId());
+
+ // Remove the deep nested bean
+ Assert.assertTrue("Deep removed", monitor.removeDeepNested());
+
+ // Confirm it is dead
+ Assert.assertEquals("Local nested removed", "ERROR", monitor.getDeepNestedId());
+ Assert.assertFalse("deepNested.remove() fails", monitor.removeDeepNested());
+
+ removeBean(monitor);
+
+ getLog().debug("ok");
+
+ }
+
+ public void testStatefulPassivation()
+ throws Exception
+ {
+ getLog().debug("Running testStatefulPassivation()");
+ getLog().debug("==================================");
+
+ NestedBeanSet beanSet = getNestedBeanSet();
+ NestedBeanMonitor monitor = beanSet.monitor;
+ ParentStatefulRemote parent = beanSet.parent;
+ NestedStateful nested = beanSet.nested;
+
+ int parentInv = beanSet.parentInvocations;
+ int nestedInv = beanSet.nestedInvocations;
+
+ Assert.assertEquals("Remote counter: ", 1, parent.increment());
+ parentInv++;
+ nestedInv++;
+ Assert.assertEquals("Remote counter: ", 2, parent.increment());
+ parentInv++;
+ nestedInv++;
+ Assert.assertEquals("Local counter: ", 1, parent.incrementLocal());
+ parentInv++;
+ Assert.assertEquals("Local counter: ", 2, parent.incrementLocal());
+ parentInv++;
+
+ sleep(getSleepTime()); // should passivate
+
+ Assert.assertEquals("Parent passivate count: ",
+ getExpectedPassivations(1, parentInv),
+ parent.getPrePassivate());
+ parentInv++;
+ Assert.assertEquals("Parent activate count: ",
+ getExpectedPassivations(1, parentInv),
+ parent.getPostActivate());
+ parentInv++;
+ Assert.assertEquals("Remote nested passivate count: ",
+ getExpectedPassivations(1, nestedInv),
+ nested.getPrePassivate());
+ Assert.assertEquals("Remote nested activate count: ",
+ getExpectedPassivations(1, nestedInv),
+ nested.getPostActivate());
+ Assert.assertEquals("Local nested passivate count: ",
+ getExpectedPassivations(1, parentInv),
+ parent.getLocalNestedPrePassivate());
+ parentInv++;
+ Assert.assertEquals("Local nested activate count: ",
+ getExpectedPassivations(1, parentInv),
+ parent.getLocalNestedPostActivate());
+ parentInv++;
+
+ // Use the monitor to check the deep nested beans. In a cluster these
+ // are marked not to treat replication as passivation, so we ignore
+ // the number of invocations
+ Assert.assertEquals("Deep nested passivate count: ", 1, monitor.getDeepNestedPassivations());
+ nestedInv++;
+ Assert.assertEquals("Deep nested activate count: ", 1, monitor.getDeepNestedActivations());
+ nestedInv++;
+ Assert.assertEquals("Local deep nested passivate count: ", 1, monitor.getLocalDeepNestedPassivations());
+ parentInv++;
+ Assert.assertEquals("Local deep nested activate count: ", 1, monitor.getLocalDeepNestedActivations());
+ parentInv++;
+
+ Assert.assertEquals("Remote counter: ", 3, parent.increment());
+ parentInv++;
+ nestedInv++;
+ Assert.assertEquals("Remote counter: ", 4, parent.increment());
+ parentInv++;
+ nestedInv++;
+ Assert.assertEquals("Local counter: ", 3, parent.incrementLocal());
+ parentInv++;
+ Assert.assertEquals("Local counter: ", 4, parent.incrementLocal());
+ parentInv++;
+
+ sleep(getSleepTime()); // should passivate
+
+ Assert.assertEquals("Parent passivate count: ",
+ getExpectedPassivations(2, parentInv),
+ parent.getPrePassivate());
+ parentInv++;
+ Assert.assertEquals("Parent activate count: ",
+ getExpectedPassivations(2, parentInv),
+ parent.getPostActivate());
+ parentInv++;
+ Assert.assertEquals("Remote nested passivate count: ",
+ getExpectedPassivations(2, nestedInv),
+ nested.getPrePassivate());
+ Assert.assertEquals("Remote nested activate count: ",
+ getExpectedPassivations(2, nestedInv),
+ nested.getPostActivate());
+ Assert.assertEquals("Local nested passivate count: ",
+ getExpectedPassivations(2, parentInv),
+ parent.getLocalNestedPrePassivate());
+ parentInv++;
+ Assert.assertEquals("Local nested activate count: ",
+ getExpectedPassivations(2, parentInv),
+ parent.getLocalNestedPostActivate());
+ parentInv++;
+
+ // Use the monitor to check the deep nested beans.
+ Assert.assertEquals("Deep nested passivate count: ", 2, monitor.getDeepNestedPassivations());
+ nestedInv++;
+ Assert.assertEquals("Deep nested activate count: ", 2, monitor.getDeepNestedActivations());
+ nestedInv++;
+ Assert.assertEquals("Local deep nested passivate count: ", 2, monitor.getLocalDeepNestedPassivations());
+ parentInv++;
+ Assert.assertEquals("Local deep nested activate count: ", 2, monitor.getLocalDeepNestedActivations());
+ parentInv++;
+
+ Assert.assertEquals("Remote counter: ", 5, parent.increment());
+ parentInv++;
+ nestedInv++;
+ Assert.assertEquals("Remote counter: ", 6, parent.increment());
+ parentInv++;
+ nestedInv++;
+ Assert.assertEquals("Local counter: ", 5, parent.incrementLocal());
+ parentInv++;
+ Assert.assertEquals("Local counter: ", 6, parent.incrementLocal());
+ parentInv++;
+
+ removeBean(parent);
+
+ // Force the nested bean to go through another passivation
+ // to check the activation process can survive the removal
+ // of its parent
+ sleep(getSleepTime());
+
+ // Confirm nested still works following parent remove
+ Assert.assertEquals("Remote counter (direct): ", 7, nested.increment());
+ nestedInv++;
+ Assert.assertEquals("Remote nested passivate count: ",
+ getExpectedPassivations(3, nestedInv),
+ nested.getPrePassivate());
+ Assert.assertEquals("Remote nested activate count: ",
+ getExpectedPassivations(3, nestedInv),
+ nested.getPostActivate());
+
+ removeBean(nested);
+
+ getLog().debug("ok");
+ }
+
+ public NestedBeanSet getNestedBeanSet()
+ throws Exception
+ {
+ // We want a colocated monitor and SFSB to test passivation/destruction
+ // StatelessRemoteBean is not clustered, so once we have it's VMID
+ // we can keep creating SFSBs until we get one we want
+ getLog().debug("Looking up NestedBeanMonitorBean...");
+ NestedBeanMonitor monitor = (NestedBeanMonitor) getInitialContext().lookup("NestedBeanMonitorBean/remote");
+ VMID monitorVM = monitor.getVMID();
+ addRemovable(monitor);
+
+ int parentInv = 0;
+ int nestedInv = 0;
+
+ ParentStatefulRemote parent = null;
+ boolean vmMatch = false;
+ for (int i = 0; i < 20 && !vmMatch; i++)
+ {
+ getLog().debug("Looking up testParentStateful... Attempt " + (i + 1));
+ parent = (ParentStatefulRemote) initialContext.lookup("testParentStateful/remote");
+
+ vmMatch = monitorVM.equals(parent.getVMID());
+ addRemovable(parent);
+ if (!vmMatch)
+ {
+ removeBean(parent);
+ }
+ }
+
+ Assert.assertTrue("Monitor and SFSB in same VM", vmMatch);
+
+ // Reset the parent to initialize all the beans
+ parent.reset();
+
+ // Monitor the parent
+ monitor.monitor(parent);
+
+ // Reset the parent to clean things up
+ parent.reset();
+ parentInv++;
+ nestedInv++;
+
+ NestedStateful nested = (NestedStateful) parent.getNested();
+ parentInv++;
+ addRemovable(nested);
+
+ NestedBeanSet result = new NestedBeanSet();
+ result.monitor = monitor;
+ result.parent = parent;
+ result.nested = nested;
+ result.parentInvocations = parentInv;
+ result.nestedInvocations = nestedInv;
+
+ return result;
+ }
+
+
+
+ public static class NestedBeanSet
+ {
+ public NestedBeanMonitor monitor;
+ public ParentStatefulRemote parent;
+ public NestedStateful nested;
+ public int parentInvocations = 0;
+ public int nestedInvocations = 0;
+ }
+
+}
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/NestedBeanUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/NestedBeanUnitTestCase.java 2007-02-19 04:10:28 UTC (rev 60626)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/NestedBeanUnitTestCase.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -7,19 +7,10 @@
package org.jboss.ejb3.test.stateful.unit;
-import org.jboss.test.JBossTestCase;
-import org.jboss.ejb3.test.stateful.nested.NestedStateful;
-import org.jboss.ejb3.test.stateful.nested.ParentStatefulRemote;
-import org.jboss.ejb3.test.stateful.nested.Removable;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
-
import junit.framework.Test;
+import org.jboss.test.JBossTestCase;
+
/**
* Test nested SFSB for repeated passivation
*
@@ -28,17 +19,7 @@
*/
public class NestedBeanUnitTestCase extends JBossTestCase
{
- static boolean deployed = false;
- public static int test = 0;
- static Date startDate = new Date();
-
- protected final String namingFactory =
- System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
-
- protected final String providerURL =
- System.getProperty(Context.PROVIDER_URL);
-
- private Set<Removable> removables = new HashSet<Removable>();
+ private NestedBeanTestRunner runner;
public NestedBeanUnitTestCase (String name)
{
@@ -52,207 +33,40 @@
@Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ runner = new NestedBeanTestRunner(getInitialContext(), getLog());
+ runner.setUp();
+ // Use a sleep time just a bit longer than twice the bean timeout
+ runner.setSleepTime(2100L);
+ }
+
+ @Override
protected void tearDown() throws Exception
{
super.tearDown();
- // Remove any EJBs so they don't spuriously passivate and
- // throw off the passivation counts
- for (Removable removable : removables)
- {
- try
- {
- removable.remove();
- }
- catch (Exception ignored) {}
- }
-
- removables.clear();
+ if (runner != null)
+ runner.tearDown();
}
public void testBasic()
throws Exception
{
- getLog().debug("Running testBasic()");
- getLog().debug("==================================");
-
- NestedBeanSet beanSet = getNestedBeanSet();
- ParentStatefulRemote stateful = beanSet.parent;
-
- assertEquals("Counter: ", 1, stateful.increment());
- assertEquals("Counter: ", 2, stateful.increment());
- assertEquals("Counter: ", 1, stateful.incrementLocal());
- assertEquals("Counter: ", 2, stateful.incrementLocal());
-
- removeBean(stateful);
-
- getLog().debug("ok");
+ runner.testBasic();
}
public void testDependentLifecycle()
throws Exception
{
- getLog().debug("Running testDependentLifecycle()");
- getLog().debug("==================================");
-
- NestedBeanSet beanSet = getNestedBeanSet();
- ParentStatefulRemote stateful = beanSet.parent;
-
- assertEquals("Counter: ", 1, stateful.increment());
-
- NestedStateful nested = beanSet.nested;
-
- removeBean(stateful);
-
- // Confirm nested still works following parent remove
- assertEquals("Counter: :", 2 ,nested.increment());
-
- removeBean(nested);
-
- getLog().debug("ok");
-
+ runner.testDependentLifecycle();
}
public void testStatefulPassivation()
throws Exception
{
- getLog().debug("Running testStatefulPassivation()");
- getLog().debug("==================================");
-
- NestedBeanSet beanSet = getNestedBeanSet();
- ParentStatefulRemote stateful = beanSet.parent;
-
- assertEquals("Counter: ", 1, stateful.increment());
- assertEquals("Counter: ", 2, stateful.increment());
- assertEquals("Counter: ", 1, stateful.incrementLocal());
- assertEquals("Counter: ", 2, stateful.incrementLocal());
-
- NestedStateful nested = beanSet.nested;
-
- _sleep(2500); // should passivate
-
- assertEquals(1, stateful.getPrePassivate());
- assertEquals(1, stateful.getPostActivate());
- assertEquals(1, nested.getPrePassivate());
- assertEquals(1, nested.getPostActivate());
- assertEquals(1, stateful.getLocalNestedPrePassivate());
- assertEquals(1, stateful.getLocalNestedPostActivate());
- assertEquals("Counter: ", 3, stateful.increment());
- assertEquals("Counter: ", 4, stateful.increment());
- assertEquals("Counter: ", 3, stateful.incrementLocal());
- assertEquals("Counter: ", 4, stateful.incrementLocal());
-
- removeBean(stateful);
-
- // Confirm nested still works following parent remove
- assertEquals("Counter: ", 5, nested.increment());
-
- removeBean(nested);
-
- getLog().debug("ok");
+ runner.testStatefulPassivation();
}
-
- public void testStatefulRepeatedPassivation()
- throws Exception
- {
- getLog().debug("Running testStatefulRepeatedPassivation()");
- getLog().debug("=========================================");
-
- NestedBeanSet beanSet = getNestedBeanSet();
- ParentStatefulRemote stateful = beanSet.parent;
- NestedStateful nested = beanSet.nested;
-
- assertEquals("Counter: ", 1, stateful.increment());
- assertEquals("Counter: ", 2, stateful.increment());
- assertEquals("Counter: ", 1, stateful.incrementLocal());
- assertEquals("Counter: ", 2, stateful.incrementLocal());
-
- _sleep(10000); // should passivate
-
- assertEquals(1, stateful.getPrePassivate());
- assertEquals(1, stateful.getPostActivate());
- assertEquals(1, nested.getPrePassivate());
- assertEquals(1, nested.getPostActivate());
- assertEquals(1, stateful.getLocalNestedPrePassivate());
- assertEquals(1, stateful.getLocalNestedPostActivate());
- assertEquals("Counter: ", 3, stateful.increment());
- assertEquals("Counter: ", 4, stateful.increment());
- assertEquals("Counter: ", 3, stateful.incrementLocal());
- assertEquals("Counter: ", 4, stateful.incrementLocal());
-
- _sleep(10000); // should passivate
-
- assertEquals(2, stateful.getPrePassivate());
- assertEquals(2, stateful.getPostActivate());
- assertEquals(2, nested.getPrePassivate());
- assertEquals(2, nested.getPostActivate());
- assertEquals(2, stateful.getLocalNestedPrePassivate());
- assertEquals(2, stateful.getLocalNestedPostActivate());
- assertEquals("Counter: ", 5, stateful.increment());
- assertEquals("Counter: ", 6, stateful.increment());
- assertEquals("Counter: ", 5, stateful.incrementLocal());
- assertEquals("Counter: ", 6, stateful.incrementLocal());
-
- removeBean(stateful);
-
- // Force the nested bean to go through another passivation
- // to check the activation process can survive the removal
- // of its parent
- _sleep(2500);
-
- // Confirm nested still works following parent remove
- assertEquals("Counter: ", 7, nested.increment());
- assertEquals(3, nested.getPrePassivate());
- assertEquals(3, nested.getPostActivate());
-
- removeBean(nested);
-
- getLog().debug("ok");
- }
-
- protected NestedBeanSet getNestedBeanSet()
- throws Exception
- {
- getLog().debug(++NestedBeanUnitTestCase.test +"- "+"Trying the context...");
-
- InitialContext ctx = getInitialContext();
-
- getLog().debug(++NestedBeanUnitTestCase.test +"- "
- +"Looking up testParentStateful...");
- ParentStatefulRemote parent = (ParentStatefulRemote) ctx.lookup("testParentStateful/remote");
- removables.add(parent);
-
- // Reset the parent to clean things up
- parent.reset();
-
- NestedStateful nested = parent.getNested();
- removables.add(nested);
-
- NestedBeanSet result = new NestedBeanSet();
- result.parent = parent;
- result.nested = nested;
-
- return result;
- }
-
- protected void _sleep(long time)
- {
- try {
- Thread.sleep(time);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- private void removeBean(Removable bean)
- {
- bean.remove();
- removables.remove(bean);
- }
-
- protected static class NestedBeanSet
- {
- ParentStatefulRemote parent;
- NestedStateful nested;
- }
}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/XPCTestRunner.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/XPCTestRunner.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/XPCTestRunner.java 2007-02-19 04:11:05 UTC (rev 60627)
@@ -0,0 +1,385 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.unit;
+
+import java.rmi.dgc.VMID;
+
+import javax.naming.InitialContext;
+
+import junit.framework.Assert;
+
+import org.jboss.ejb3.test.stateful.nested.base.xpc.Customer;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.NestedXPCMonitor;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.ShoppingCart;
+import org.jboss.logging.Logger;
+
+/**
+ * Encapsulates the functions needed for tests of ExtendedPersistenceContext
+ * management by nested SFSBs in a class that can be used either by a
+ * JBossTestCase subclass or a JBossClusteredTestCase subclass.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public class XPCTestRunner extends BaseTestRunner
+{
+ public XPCTestRunner(InitialContext context, Logger log)
+ {
+ super(context, log);
+ }
+
+ public void testBasic() throws Exception
+ {
+ BeanSet beanSet = getBeanSet();
+ ShoppingCart cart = beanSet.cart;
+ NestedXPCMonitor monitor = beanSet.monitor;
+
+ Customer customer;
+
+ long id = cart.createCustomer();
+ customer = monitor.find(id);
+ Assert.assertEquals("Stateless has proper initial name",
+ "William", customer.getName());
+ customer = cart.find(id);
+ Assert.assertEquals("ShoppingCart has proper initial name",
+ "William", customer.getName());
+
+ cart.update();
+ customer = monitor.find(id);
+ Assert.assertEquals("Stateless has proper updated name",
+ "Bill", customer.getName());
+ customer = cart.find(id);
+ Assert.assertEquals("ShoppingCart has proper updated name",
+ "Bill", customer.getName());
+
+ cart.update2();
+ customer = monitor.find(id);
+ Assert.assertEquals("Stateless has proper update2() name",
+ "Billy", customer.getName());
+ customer = cart.find(id);
+ Assert.assertEquals("ShoppingCart has proper update2() name",
+ "Billy", customer.getName());
+
+ cart.update3();
+ customer = monitor.find(id);
+ Assert.assertEquals("Stateless has proper update3() name",
+ "Bill Jr.", customer.getName());
+ customer = cart.find(id);
+ Assert.assertEquals("ShoppingCart has proper update3() name",
+ "Bill Jr.", customer.getName());
+
+ removeBean(cart);
+ removeBean(monitor);
+ }
+
+ public void testXPCSharing() throws Exception
+ {
+ getLog().debug("Running testXPCSharing()");
+ getLog().debug("==================================");
+
+ BeanSet beanSet = getBeanSet();
+ ShoppingCart parent = beanSet.cart;
+ NestedXPCMonitor monitor = beanSet.monitor;
+
+ // Confirm the nested beans are there
+ String deepId = monitor.getDeepNestedId();
+ Assert.assertNotNull("Got a deepId", deepId);
+ Assert.assertFalse("Got a non-ERROR deepId", "ERROR".equals(deepId));
+ String localDeepId = monitor.getLocalDeepNestedId();
+ Assert.assertNotNull("Got a localDeepId", localDeepId);
+ Assert.assertFalse("Got a non-ERROR localDeepId", "ERROR".equals(localDeepId));
+
+ long id = parent.createCustomer();
+ Customer customer = parent.find(id);
+ Assert.assertNotNull("Customer created and found on parent", customer);
+
+ parent.setContainedCustomer();
+ Assert.assertTrue("Parent and local contained share customer", parent.checkContainedCustomer());
+
+ Assert.assertTrue("Parent and remote nested do not share ref",
+ monitor.compareTopToNested(id));
+ Assert.assertTrue("Parent and local nested do share ref",
+ monitor.compareTopToLocalNested(id));
+ Assert.assertTrue("Remote nested and local nested do not share a ref",
+ monitor.compareNestedToLocalNested(id));
+ Assert.assertTrue("Remote nested and deepNested share a ref",
+ monitor.compareNestedToDeepNested(id));
+ Assert.assertTrue("Local nested and localDeepNested share a ref",
+ monitor.compareLocalNestedToLocalDeepNested(id));
+
+ // Confirm this survives passivation/activation
+
+ parent.reset();
+
+ sleep(getSleepTime());
+
+ // DeepContained beans ignore replication in their
+ // activation/passivation counters, so we can test them
+ // to confirm activation/passivation
+ Assert.assertEquals("Local deep contained passivated once", 1,
+ monitor.getLocalDeepNestedPassivations());
+ Assert.assertEquals("Local deep contained activated once", 1,
+ monitor.getLocalDeepNestedActivations());
+ Assert.assertEquals("Deep contained passivated once", 1,
+ monitor.getDeepNestedPassivations());
+ Assert.assertEquals("Deep contained activated once", 1,
+ monitor.getDeepNestedActivations());
+
+ Assert.assertTrue("Parent and remote nested do not share ref",
+ monitor.compareTopToNested(id));
+ Assert.assertTrue("Parent and local nested do share ref",
+ monitor.compareTopToLocalNested(id));
+ Assert.assertTrue("Remote nested and local nested do not share a ref",
+ monitor.compareNestedToLocalNested(id));
+ Assert.assertTrue("Remote nested and deepNested share a ref",
+ monitor.compareNestedToDeepNested(id));
+ Assert.assertTrue("Local nested and localDeepNested share a ref",
+ monitor.compareLocalNestedToLocalDeepNested(id));
+
+ removeBean(parent);
+ removeBean(monitor);
+ }
+
+ public void testDependentLifecycle()
+ throws Exception
+ {
+ getLog().debug("Running testDependentLifecycle()");
+ getLog().debug("==================================");
+
+ BeanSet beanSet = getBeanSet();
+ ShoppingCart parent = beanSet.cart;
+ NestedXPCMonitor monitor = beanSet.monitor;
+
+ // Confirm the nested beans are there
+ String deepId = monitor.getDeepNestedId();
+ Assert.assertNotNull("Got a deepId", deepId);
+ Assert.assertFalse("Got a non-ERROR deepId", "ERROR".equals(deepId));
+ String localDeepId = monitor.getLocalDeepNestedId();
+ Assert.assertNotNull("Got a localDeepId", localDeepId);
+ Assert.assertFalse("Got a non-ERROR localDeepId", "ERROR".equals(localDeepId));
+
+ long id = parent.createCustomer();
+ Customer customer = parent.find(id);
+ Assert.assertNotNull("Customer created and found on parent", customer);
+
+ Assert.assertTrue("Parent and remote nested do not share ref",
+ monitor.compareTopToNested(id));
+ Assert.assertTrue("Parent and local nested do share ref",
+ monitor.compareTopToLocalNested(id));
+ Assert.assertTrue("Remote nested and local nested do not share a ref",
+ monitor.compareNestedToLocalNested(id));
+ Assert.assertTrue("Remote nested and deepNested share a ref",
+ monitor.compareNestedToDeepNested(id));
+ Assert.assertTrue("Local nested and localDeepNested share a ref",
+ monitor.compareLocalNestedToLocalDeepNested(id));
+
+ // Remove the parent and see that things still work
+ Assert.assertTrue("Parent removed", monitor.removeParent());
+
+ // Confirm parent is dead
+ Assert.assertFalse("parent.remove() fails", monitor.removeParent());
+
+ Assert.assertTrue("Remote nested and local nested do not share a ref",
+ monitor.compareNestedToLocalNested(id));
+ Assert.assertTrue("Remote nested and deepNested share a ref",
+ monitor.compareNestedToDeepNested(id));
+ Assert.assertTrue("Local nested and localDeepNested share a ref",
+ monitor.compareLocalNestedToLocalDeepNested(id));
+
+ // Remove the bottom tier
+ Assert.assertTrue("Local deep nested removed", monitor.removeLocalDeepNested());
+
+ // Confirm it is dead
+ Assert.assertFalse("localDeepNested.remove() fails", monitor.removeLocalDeepNested());
+
+ // Confirm other beans still work following remove
+ Assert.assertNotNull("Local nested still works", monitor.findLocalNested(id));
+ Assert.assertTrue("Remote nested and local nested do not share a ref",
+ monitor.compareNestedToLocalNested(id));
+ Assert.assertTrue("Remote nested and deepNested share a ref",
+ monitor.compareNestedToDeepNested(id));
+
+ // Remove the nested bean
+ Assert.assertTrue("Remote nested removed", monitor.removeNested());
+
+ // Confirm it is dead
+ Assert.assertFalse("nested.remove() fails", monitor.removeNested());
+
+ // Confirm other beans still work
+ Assert.assertNotNull("Local nested still works", monitor.findLocalNested(id));
+ Assert.assertNotNull("Remote deep nested still works", monitor.findDeepNested(id));
+
+ // Remove the local nested bean
+ Assert.assertTrue("Local nested removed", monitor.removeLocalNested());
+
+ // Confirm it is dead
+ Assert.assertFalse("localNested.remove() fails", monitor.removeLocalNested());
+
+ // Confirm other beans still work following parent remove
+ Assert.assertNotNull("Deep nested not null", monitor.findDeepNested(id));
+
+ // Remove the deep nested bean
+ Assert.assertTrue("Deep removed", monitor.removeDeepNested());
+
+ // Confirm it is dead
+ Assert.assertEquals("Local nested removed", "ERROR", monitor.getDeepNestedId());
+ Assert.assertFalse("deepNested.remove() fails", monitor.removeDeepNested());
+
+ removeBean(monitor);
+
+ getLog().debug("ok");
+
+ }
+
+ public void testPassivation() throws Exception
+ {
+ BeanSet beanSet = getBeanSet();
+ ShoppingCart cart = beanSet.cart;
+ NestedXPCMonitor monitor = beanSet.monitor;
+
+ Customer customer;
+
+ long id = cart.createCustomer();
+ customer = monitor.find(id);
+ Assert.assertEquals("Stateless has proper initial name",
+ "William", customer.getName());
+ customer = cart.find(id);
+ Assert.assertEquals("ShoppingCart has proper initial name",
+ "William", customer.getName());
+
+ cart.update();
+ customer = monitor.find(id);
+ Assert.assertEquals("Stateless has proper updated name",
+ "Bill", customer.getName());
+ customer = cart.find(id);
+ Assert.assertEquals("ShoppingCart has proper updated name",
+ "Bill", customer.getName());
+
+ cart.update2();
+ customer = monitor.find(id);
+ Assert.assertEquals("Stateless has proper update2() name",
+ "Billy", customer.getName());
+ customer = cart.find(id);
+ Assert.assertEquals("ShoppingCart has proper update2() name",
+ "Billy", customer.getName());
+
+ cart.update3();
+ customer = monitor.find(id);
+ Assert.assertEquals("Stateless has proper update3() name",
+ "Bill Jr.", customer.getName());
+ customer = cart.find(id);
+ Assert.assertEquals("ShoppingCart has proper update3() name",
+ "Bill Jr.", customer.getName());
+
+ // Tell the contained bean to get the customer
+ cart.setContainedCustomer();
+
+ // Clear the passivation counts
+ cart.reset();
+
+ sleep(getSleepTime()); // passivation
+
+ Assert.assertEquals("Contained bean was passivated", 1, monitor.getLocalNestedPassivations());
+
+ Assert.assertTrue("Parent and local contained share customer", cart.checkContainedCustomer());
+
+ Assert.assertTrue("Contained bean was activated", monitor.getLocalNestedActivations() > 0);
+
+ cart.findAndUpdateStateless();
+ cart.updateContained();
+
+ customer = monitor.find(id);
+ Assert.assertEquals("contained modified", customer.getName());
+ customer = cart.find(id);
+ Assert.assertEquals("contained modified", customer.getName());
+
+ removeBean(monitor);
+ removeBean(cart);
+ }
+
+ public BeanSet getBeanSet() throws Exception
+ {
+ // We want a colocated monitor and SFSB to test passivation/destruction
+ // NestedXPCMonitorBean is not clustered, so once we have it's VMID
+ // we can keep creating SFSBs until we get one we want
+ NestedXPCMonitor monitor = (NestedXPCMonitor) getInitialContext().lookup("NestedXPCMonitorBean/remote");
+ VMID statelessVM = monitor.getVMID();
+ addRemovable(monitor);
+
+ ShoppingCart cart = null;
+ boolean vmMatch = false;
+ for (int i = 0; i < 10 && !vmMatch; i++)
+ {
+ cart = (ShoppingCart) getInitialContext().lookup("testShoppingCart/remote");
+
+ vmMatch = statelessVM.equals(cart.getVMID());
+ addRemovable(cart);
+ if (!vmMatch)
+ removeBean(cart);
+ }
+
+ Assert.assertTrue("Monitor and SFSB in same VM", vmMatch);
+
+ // Reset the parent to initialize all the beans
+ cart.reset();
+
+ // Monitor the parent
+ monitor.monitor(cart);
+
+ // Reset the parent to clean things up
+ cart.reset();
+
+ BeanSet result = new BeanSet();
+ result.cart = cart;
+ result.monitor = monitor;
+
+ return result;
+ }
+
+ public NestedXPCMonitor getXPCMonitor(InitialContext[] ctxs, VMID vmid)
+ throws Exception
+ {
+ NestedXPCMonitor monitor = null;
+ boolean vmMatch = false;
+ for (int i = 0; i < 10 && !vmMatch; i++)
+ {
+ InitialContext ctx = ctxs[i % ctxs.length];
+ monitor = (NestedXPCMonitor) ctx.lookup("NestedXPCMonitorBean/remote");
+
+ vmMatch = vmid.equals(monitor.getVMID());
+ addRemovable(monitor);
+ if (!vmMatch)
+ removeBean(monitor);
+ }
+
+ Assert.assertTrue("SLSB and SFSB in same VM", vmMatch);
+
+ return monitor;
+ }
+
+ public static class BeanSet
+ {
+ public ShoppingCart cart;
+ public NestedXPCMonitor monitor;
+ }
+}
More information about the jboss-cvs-commits
mailing list