[Jboss-cvs] JBossAS SVN: r56347 - in trunk/ejb3/src: main/org/jboss/ejb3/stateful test/org/jboss/ejb3/test/regression/ejbthree670 test/org/jboss/ejb3/test/regression/ejbthree670/unit

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Aug 28 12:09:57 EDT 2006


Author: wolfc
Date: 2006-08-28 12:09:44 -0400 (Mon, 28 Aug 2006)
New Revision: 56347

Modified:
   trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/regression/ejbthree670/MyStateful21Bean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/regression/ejbthree670/unit/PreDestroyCallsTestCase.java
Log:
EJBTHREE-670: fixed

Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java	2006-08-28 15:05:48 UTC (rev 56346)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java	2006-08-28 16:09:44 UTC (rev 56347)
@@ -533,12 +533,8 @@
       Method unadvisedMethod = info.getUnadvisedMethod();
       if (unadvisedMethod.getName().equals("remove"))
       {
-         BeanContext ctx = getCache().get(id);
+         destroySession(id);
 
-         invokePreDestroy(ctx);
-
-         getCache().remove(id);
-
          return null;
       }
       else if (unadvisedMethod.getName().equals("getEJBLocalHome"))
@@ -599,12 +595,8 @@
       {
          StatefulHandleImpl handle = (StatefulHandleImpl) args[0];
 
-         BeanContext ctx = getCache().get(handle.id);
+         destroySession(handle.id);
 
-         invokePreDestroy(ctx);
-
-         getCache().remove(handle.id);
-
          return null;
       }
       else
@@ -662,12 +654,8 @@
          StatefulHandleImpl handle = (StatefulHandleImpl) statefulInvocation
                  .getArguments()[0];
 
-         BeanContext ctx = getCache().get(handle.id);
+         destroySession(handle.id);
 
-         invokePreDestroy(ctx);
-
-         getCache().remove(handle.id);
-
          InvocationResponse response = new InvocationResponse(null);
          response.setContextInfo(statefulInvocation.getResponseContextInfo());
          return response;
@@ -734,12 +722,8 @@
       }
       else if (unadvisedMethod.getName().equals("remove"))
       {
-         BeanContext ctx = getCache().get(statefulInvocation.getId());
+         destroySession(statefulInvocation.getId());
 
-         invokePreDestroy(ctx);
-
-         getCache().remove(statefulInvocation.getId());
-
          InvocationResponse response = new InvocationResponse(null);
          return response;
       }
@@ -889,11 +873,6 @@
    {
       StatefulHandleImpl handle = (StatefulHandleImpl) arg;
 
-      //BeanContext ctx = getCache().get(handle.id);
-
-      // TODO: EJBTHREE-670: the pool calls PreDestroy
-      //invokePreDestroy(ctx);
-
       destroySession(handle.id);
    }
 }

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/regression/ejbthree670/MyStateful21Bean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/regression/ejbthree670/MyStateful21Bean.java	2006-08-28 15:05:48 UTC (rev 56346)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/regression/ejbthree670/MyStateful21Bean.java	2006-08-28 16:09:44 UTC (rev 56347)
@@ -45,7 +45,7 @@
 @RemoteHome(MyStateful21Home.class)
 public class MyStateful21Bean implements SessionBean
 {
-   private static final Logger log = Logger.getLogger(MyStatefulBean.class);
+   private static final Logger log = Logger.getLogger(MyStateful21Bean.class);
    
    private String name;
    private int preDestroyCalls = 0;
@@ -70,7 +70,7 @@
    @PreDestroy
    public void preDestroy()
    {
-      new Exception().printStackTrace();
+      //new Exception().printStackTrace();
       preDestroyCalls++;
       log.info("pre destroy");
       if(preDestroyCalls > 1)

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/regression/ejbthree670/unit/PreDestroyCallsTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/regression/ejbthree670/unit/PreDestroyCallsTestCase.java	2006-08-28 15:05:48 UTC (rev 56346)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/regression/ejbthree670/unit/PreDestroyCallsTestCase.java	2006-08-28 16:09:44 UTC (rev 56347)
@@ -79,6 +79,25 @@
       }
    }
    
+   public void testRemoveByHandle() throws Exception
+   {
+      MyStateful21Home home = (MyStateful21Home) getInitialContext().lookup("MyStateful21Bean/remoteHome");
+      MyStateful21 session = home.create();
+      session.setName("Test");
+      String actual = session.sayHello();
+      assertEquals("Hi Test", actual);
+      try
+      {
+         home.remove(session.getHandle());
+      }
+      catch(RuntimeException e)
+      {
+         if(e.getCause().getMessage().equals("pre destroy called multiple times"))
+            fail("pre destroy called multiple times");
+         throw e;
+      }
+   }
+   
    public static Test suite() throws Exception
    {
       return getDeploySetup(PreDestroyCallsTestCase.class, "ejbthree670.jar");




More information about the jboss-cvs-commits mailing list