[Jboss-cvs] JBossAS SVN: r56631 - in branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful: . nested

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Sep 7 23:14:21 EDT 2006


Author: bill.burke at jboss.com
Date: 2006-09-07 23:14:19 -0400 (Thu, 07 Sep 2006)
New Revision: 56631

Added:
   branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/ConcurrentStateful.java
   branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/ConcurrentStatefulBean.java
   branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/RemoteTx.java
   branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/StatefulInvoker.java
   branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/
   branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/NestedStateful.java
   branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/NestedStatefulBean.java
   branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/ParentStatefulBean.java
   branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/ParentStatefulRemote.java
Log:
merge from head

Added: branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/ConcurrentStateful.java
===================================================================
--- branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/ConcurrentStateful.java	2006-09-08 03:03:34 UTC (rev 56630)
+++ branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/ConcurrentStateful.java	2006-09-08 03:14:19 UTC (rev 56631)
@@ -0,0 +1,37 @@
+/*
+  * 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;
+
+
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version $Revision: 56003 $
+ */
+public interface ConcurrentStateful
+{
+   String getState() throws Exception;
+
+   void setState(String state) throws Exception;
+}

Added: branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/ConcurrentStatefulBean.java
===================================================================
--- branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/ConcurrentStatefulBean.java	2006-09-08 03:03:34 UTC (rev 56630)
+++ branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/ConcurrentStatefulBean.java	2006-09-08 03:14:19 UTC (rev 56631)
@@ -0,0 +1,58 @@
+/*
+  * 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;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.annotation.ejb.RemoteBinding;
+import org.jboss.logging.Logger;
+
+import org.jboss.annotation.ejb.SerializedConcurrentAccess;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version $Revision: 56003 $
+ */
+ at Stateful
+ at Remote(ConcurrentStateful.class)
+ at RemoteBinding(jndiBinding = "ConcurrentStateful")
+ at SerializedConcurrentAccess
+public class ConcurrentStatefulBean implements ConcurrentStateful
+{
+   private static final Logger log = Logger.getLogger(ConcurrentStatefulBean.class);
+
+   private String state;
+
+   public String getState() throws Exception
+   {
+      Thread.sleep(1000);
+      return state;
+   }
+
+   public void setState(String state) throws Exception
+   {
+      this.state = state;
+      Thread.sleep(1000);
+   }
+
+}

Added: branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/RemoteTx.java
===================================================================
--- branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/RemoteTx.java	2006-09-08 03:03:34 UTC (rev 56630)
+++ branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/RemoteTx.java	2006-09-08 03:14:19 UTC (rev 56631)
@@ -0,0 +1,34 @@
+/*
+  * 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;
+
+
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface RemoteTx<T>
+{
+   T testMandatoryTx(T t);
+}

Added: branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/StatefulInvoker.java
===================================================================
--- branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/StatefulInvoker.java	2006-09-08 03:03:34 UTC (rev 56630)
+++ branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/StatefulInvoker.java	2006-09-08 03:14:19 UTC (rev 56631)
@@ -0,0 +1,61 @@
+/*
+  * 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;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version $Revision: 45088 $
+ */
+public class StatefulInvoker extends Thread
+{
+   private static final Logger log = Logger.getLogger(StatefulInvoker.class);
+   
+   Exception exception = null;
+   
+   ConcurrentStateful stateful;
+   
+   public StatefulInvoker(ConcurrentStateful stateful)
+   {
+      this.stateful = stateful;
+   }
+   
+   public Exception getException()
+   {
+      return exception;
+   }
+   
+   public void run()
+   {
+      try
+      {
+         stateful.setState("state");
+         stateful.getState();
+      }
+      catch(Exception e)
+      {
+         exception = e;
+      }
+   }
+
+}

Added: branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/NestedStateful.java
===================================================================
--- branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/NestedStateful.java	2006-09-08 03:03:34 UTC (rev 56630)
+++ branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/NestedStateful.java	2006-09-08 03:14:19 UTC (rev 56631)
@@ -0,0 +1,20 @@
+/*
+ * 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: 45372 $
+ */
+public interface NestedStateful
+{
+   int increment();   
+   void reset();
+}

Added: branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/NestedStatefulBean.java
===================================================================
--- branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/NestedStatefulBean.java	2006-09-08 03:03:34 UTC (rev 56630)
+++ branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/NestedStatefulBean.java	2006-09-08 03:14:19 UTC (rev 56631)
@@ -0,0 +1,68 @@
+/*
+ * 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.tree.CacheConfig;
+import org.jboss.logging.Logger;
+
+import javax.ejb.*;
+
+/**
+ * Nested SFSB
+ *
+ * @author Ben Wang
+ * @version $Revision: 45372 $
+ */
+ at Stateful(name="testNestedStateful")
+ 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
+{
+   private Logger log = Logger.getLogger(NestedStatefulBean.class);
+   private int counter = 0;
+
+   public int increment()
+   {
+      log.debug("INCREMENT - 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;
+   }
+
+   @PostActivate
+   public void postActivate()
+   {
+      ++NestedStatefulBean.postActivateCalled;
+      log.debug("Activate with counter: " + counter);
+   }
+
+   @PrePassivate
+   public void prePassivate()
+   {
+      ++NestedStatefulBean.prePassivateCalled;
+      log.debug("Passivate with counter: " + counter);
+   }
+
+}

Added: branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/ParentStatefulBean.java
===================================================================
--- branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/ParentStatefulBean.java	2006-09-08 03:03:34 UTC (rev 56630)
+++ branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/ParentStatefulBean.java	2006-09-08 03:14:19 UTC (rev 56631)
@@ -0,0 +1,99 @@
+/*
+ * 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: 45473 $
+ */
+ at Stateful(name="testParentStateful")
+ 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
+{
+   private Logger log = Logger.getLogger(ParentStatefulBean.class);
+   private int counter = 0;
+
+   @EJB
+   private NestedStateful nested;
+
+   public int increment()
+   {
+      counter = nested.increment();
+
+      log.debug("INCREMENT - counter: " + counter);
+      return counter;
+   }
+
+   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 void reset()
+   {
+      counter = 0;
+      ParentStatefulBean.postActivateCalled = 0;
+      ParentStatefulBean.prePassivateCalled = 0;
+   }
+
+   @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()
+   {
+   }
+
+   @PostConstruct
+   public void ejbCreate()
+   {
+   }
+
+   // Remote Interface implementation ----------------------------------------------
+
+}

Added: branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/ParentStatefulRemote.java
===================================================================
--- branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/ParentStatefulRemote.java	2006-09-08 03:03:34 UTC (rev 56630)
+++ branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/stateful/nested/ParentStatefulRemote.java	2006-09-08 03:14:19 UTC (rev 56631)
@@ -0,0 +1,29 @@
+/*
+ * 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
+ * @version $Revision: 45372 $
+ */
+public interface ParentStatefulRemote
+{
+   int increment();
+
+   int getPostActivate();
+
+   int getPrePassivate();
+
+   void reset();
+
+   void longRunning() throws Exception;
+
+   void remove();
+}




More information about the jboss-cvs-commits mailing list