[jboss-cvs] JBossAS SVN: r86416 - in branches/Branch_5_x: testsuite/imports/sections and 9 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Mar 27 06:43:49 EDT 2009


Author: alex.loubyansky at jboss.com
Date: 2009-03-27 06:43:48 -0400 (Fri, 27 Mar 2009)
New Revision: 86416

Added:
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/actions/
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/actions/AbstractStatefulSessionAction.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/actions/GetAfterBeginEntryAction.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/actions/GetAfterCompletionEntryAction.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/actions/GetBeforeCompletionEntryAction.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/ejb/
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/ejb/ActionExecutorBean.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/ejb/StatefulSessionBean.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/interfaces/
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/interfaces/Action.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/interfaces/ActionExecutor.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/interfaces/ActionExecutorHome.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/interfaces/StatefulSession.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/interfaces/StatefulSessionHome.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/test/
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/test/CompEnvInSessionSyncCallbacksUnitTestCase.java
   branches/Branch_5_x/testsuite/src/resources/sessionsync/
   branches/Branch_5_x/testsuite/src/resources/sessionsync/META-INF/
   branches/Branch_5_x/testsuite/src/resources/sessionsync/META-INF/ejb-jar.xml
   branches/Branch_5_x/testsuite/src/resources/sessionsync/META-INF/jboss.xml
Modified:
   branches/Branch_5_x/server/src/main/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
   branches/Branch_5_x/testsuite/imports/sections/session.xml
Log:
JBAS-6553

Modified: branches/Branch_5_x/server/src/main/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
===================================================================
--- branches/Branch_5_x/server/src/main/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java	2009-03-27 10:14:37 UTC (rev 86415)
+++ branches/Branch_5_x/server/src/main/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java	2009-03-27 10:43:48 UTC (rev 86416)
@@ -514,13 +514,16 @@
             try
             {
                AllowedOperationsAssociation.pushInMethodFlag(IN_BEFORE_COMPLETION);
+               container.pushENC();
                beforeCompletion.invoke(ctx.getInstance(), new Object[0]);
             }
             catch (Exception e)
             {
                log.error("failed to invoke beforeCompletion", e);
             }
-            finally{
+            finally
+            {
+               container.popENC();
                AllowedOperationsAssociation.popInMethodFlag();
             }
          }
@@ -546,6 +549,7 @@
                try
                {
                   AllowedOperationsAssociation.pushInMethodFlag(IN_AFTER_COMPLETION);
+                  container.pushENC();
                   if (status == Status.STATUS_COMMITTED)
                   {
                      afterCompletion.invoke(ctx.getInstance(), new Object[]{Boolean.TRUE});
@@ -559,7 +563,9 @@
                {
                   log.error("failed to invoke afterCompletion", e);
                }
-               finally{
+               finally
+               {
+                  container.popENC();
                   AllowedOperationsAssociation.popInMethodFlag();
                }
             }

Modified: branches/Branch_5_x/testsuite/imports/sections/session.xml
===================================================================
--- branches/Branch_5_x/testsuite/imports/sections/session.xml	2009-03-27 10:14:37 UTC (rev 86415)
+++ branches/Branch_5_x/testsuite/imports/sections/session.xml	2009-03-27 10:43:48 UTC (rev 86416)
@@ -13,5 +13,18 @@
             <include name="**"/>
          </fileset>
       </jar>
+
+      <!-- build compenv-sessionsync.jar -->
+      <jar destfile="${build.lib}/compenv-sessionsync.jar">
+         <fileset dir="${build.classes}">
+            <include name="org/jboss/test/sessionsync/interfaces/**"/>
+            <include name="org/jboss/test/sessionsync/ejb/**"/>
+            <include name="org/jboss/test/sessionsync/actions/**"/>
+         </fileset>
+         <fileset dir="${build.resources}/sessionsync/">
+            <include name="**"/>
+         </fileset>
+      </jar>
+
    </target>
 </project>

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/actions/AbstractStatefulSessionAction.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/actions/AbstractStatefulSessionAction.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/actions/AbstractStatefulSessionAction.java	2009-03-27 10:43:48 UTC (rev 86416)
@@ -0,0 +1,51 @@
+/*
+ * 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.test.sessionsync.actions;
+
+import javax.ejb.Handle;
+
+import org.jboss.test.sessionsync.interfaces.Action;
+import org.jboss.test.sessionsync.interfaces.StatefulSession;
+
+/**
+ * A AbstractStatefulSessionAction.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractStatefulSessionAction implements Action
+{
+   private final Handle handle;
+   
+   public AbstractStatefulSessionAction(Handle handle)
+   {
+      this.handle = handle;
+   }
+   
+   public String execute() throws Exception
+   {
+      StatefulSession session = (StatefulSession) handle.getEJBObject();
+      return execute(session);
+   }
+
+   protected abstract String execute(StatefulSession session) throws Exception;
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/actions/GetAfterBeginEntryAction.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/actions/GetAfterBeginEntryAction.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/actions/GetAfterBeginEntryAction.java	2009-03-27 10:43:48 UTC (rev 86416)
@@ -0,0 +1,49 @@
+/*
+ * 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.test.sessionsync.actions;
+
+import javax.ejb.Handle;
+
+import org.jboss.test.sessionsync.interfaces.StatefulSession;
+
+/**
+ * A GetAfterBeginEntryAction.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class GetAfterBeginEntryAction extends AbstractStatefulSessionAction
+{
+   public GetAfterBeginEntryAction(Handle handle)
+   {
+      super(handle);
+   }
+
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
+   @Override
+   protected String execute(StatefulSession session) throws Exception
+   {
+      return session.getAfterBeginEntry();
+   }
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/actions/GetAfterCompletionEntryAction.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/actions/GetAfterCompletionEntryAction.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/actions/GetAfterCompletionEntryAction.java	2009-03-27 10:43:48 UTC (rev 86416)
@@ -0,0 +1,49 @@
+/*
+ * 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.test.sessionsync.actions;
+
+import javax.ejb.Handle;
+
+import org.jboss.test.sessionsync.interfaces.StatefulSession;
+
+/**
+ * A GetAfterBeginEntryAction.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class GetAfterCompletionEntryAction extends AbstractStatefulSessionAction
+{
+   public GetAfterCompletionEntryAction(Handle handle)
+   {
+      super(handle);
+   }
+
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
+   @Override
+   protected String execute(StatefulSession session) throws Exception
+   {
+      return session.getAfterCompletionEntry();
+   }
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/actions/GetBeforeCompletionEntryAction.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/actions/GetBeforeCompletionEntryAction.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/actions/GetBeforeCompletionEntryAction.java	2009-03-27 10:43:48 UTC (rev 86416)
@@ -0,0 +1,49 @@
+/*
+ * 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.test.sessionsync.actions;
+
+import javax.ejb.Handle;
+
+import org.jboss.test.sessionsync.interfaces.StatefulSession;
+
+/**
+ * A GetAfterBeginEntryAction.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class GetBeforeCompletionEntryAction extends AbstractStatefulSessionAction
+{
+   public GetBeforeCompletionEntryAction(Handle handle)
+   {
+      super(handle);
+   }
+
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
+   @Override
+   protected String execute(StatefulSession session) throws Exception
+   {
+      return session.getBeforeCompletionEntry();
+   }
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/ejb/ActionExecutorBean.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/ejb/ActionExecutorBean.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/ejb/ActionExecutorBean.java	2009-03-27 10:43:48 UTC (rev 86416)
@@ -0,0 +1,75 @@
+/*
+ * 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.test.sessionsync.ejb;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+
+import org.jboss.test.sessionsync.interfaces.Action;
+
+/**
+ * A ActionExecutorBean.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class ActionExecutorBean implements SessionBean
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
+   public String execute(Action action) throws EJBException
+   {
+      try
+      {
+         return action.execute();
+      }
+      catch (Exception e)
+      {
+         throw new EJBException(e);
+      }
+   }
+   
+   public void ejbCreate() throws CreateException
+   {
+   }
+   
+   public void ejbActivate() throws EJBException, RemoteException
+   {
+   }
+
+   public void ejbPassivate() throws EJBException, RemoteException
+   {
+   }
+
+   public void ejbRemove() throws EJBException, RemoteException
+   {
+   }
+
+   public void setSessionContext(SessionContext ctx) throws EJBException, RemoteException
+   {
+   }
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/ejb/StatefulSessionBean.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/ejb/StatefulSessionBean.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/ejb/StatefulSessionBean.java	2009-03-27 10:43:48 UTC (rev 86416)
@@ -0,0 +1,126 @@
+/*
+ * 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.test.sessionsync.ejb;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.EJBException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.ejb.SessionSynchronization;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ * A StatefulSessionBean.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class StatefulSessionBean implements SessionBean, SessionSynchronization
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
+   private InitialContext ic;
+   private String afterBeginEntry;
+   private String beforeCompletionEntry;
+   private String afterCompletionEntry;
+   
+   public String getAfterBeginEntry() throws RemoteException
+   {
+      return afterBeginEntry;
+   }
+
+   public String getBeforeCompletionEntry() throws RemoteException
+   {
+      return beforeCompletionEntry;
+   }
+
+   public String getAfterCompletionEntry() throws RemoteException
+   {
+      return afterCompletionEntry;
+   }
+
+   public void ejbCreate() throws EJBException, RemoteException
+   {
+   }
+   
+   public void ejbActivate() throws EJBException, RemoteException
+   {
+   }
+
+   public void ejbPassivate() throws EJBException, RemoteException
+   {
+      ic = null;
+      afterBeginEntry = null;
+      beforeCompletionEntry = null;
+      afterCompletionEntry = null;
+   }
+
+   public void ejbRemove() throws EJBException, RemoteException
+   {
+   }
+
+   public void setSessionContext(SessionContext ctx) throws EJBException, RemoteException
+   {
+   }
+
+   public void afterBegin() throws EJBException, RemoteException
+   {
+      afterBeginEntry = lookupCompEnv("afterBegin");      
+   }
+
+   public void afterCompletion(boolean committed) throws EJBException, RemoteException
+   {
+      afterCompletionEntry = lookupCompEnv("afterCompletion");      
+   }
+
+   public void beforeCompletion() throws EJBException, RemoteException
+   {
+      beforeCompletionEntry = lookupCompEnv("beforeCompletion");      
+   }
+   
+   private String lookupCompEnv(String name)
+   {
+      if(ic == null)
+      {
+         try
+         {
+            ic = new InitialContext();
+         }
+         catch (NamingException e)
+         {
+            throw new EJBException("Failed to create initial context.", e);
+         }
+      }
+      
+      try
+      {
+         return (String) ic.lookup("java:/comp/env/" + name);
+      }
+      catch (NamingException e)
+      {
+         throw new EJBException("Failed to lookup java:/comp/env/" + name, e);
+      }
+   }
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/interfaces/Action.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/interfaces/Action.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/interfaces/Action.java	2009-03-27 10:43:48 UTC (rev 86416)
@@ -0,0 +1,35 @@
+/*
+ * 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.test.sessionsync.interfaces;
+
+import java.io.Serializable;
+
+/**
+ * A Action.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Action extends Serializable
+{
+   String execute() throws Exception;
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/interfaces/ActionExecutor.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/interfaces/ActionExecutor.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/interfaces/ActionExecutor.java	2009-03-27 10:43:48 UTC (rev 86416)
@@ -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.test.sessionsync.interfaces;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.EJBObject;
+
+/**
+ * A ActionExecutor.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ActionExecutor extends EJBObject
+{
+   String execute(Action action) throws RemoteException;
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/interfaces/ActionExecutorHome.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/interfaces/ActionExecutorHome.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/interfaces/ActionExecutorHome.java	2009-03-27 10:43:48 UTC (rev 86416)
@@ -0,0 +1,38 @@
+/*
+ * 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.test.sessionsync.interfaces;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+/**
+ * A ActionExecutorHome.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ActionExecutorHome extends EJBHome
+{
+   ActionExecutor create() throws CreateException, RemoteException;
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/interfaces/StatefulSession.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/interfaces/StatefulSession.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/interfaces/StatefulSession.java	2009-03-27 10:43:48 UTC (rev 86416)
@@ -0,0 +1,41 @@
+/*
+ * 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.test.sessionsync.interfaces;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.EJBObject;
+
+/**
+ * A StatefulSession.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public interface StatefulSession extends EJBObject
+{
+   String getAfterBeginEntry() throws RemoteException;
+   
+   String getBeforeCompletionEntry() throws RemoteException;
+   
+   String getAfterCompletionEntry() throws RemoteException;
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/interfaces/StatefulSessionHome.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/interfaces/StatefulSessionHome.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/interfaces/StatefulSessionHome.java	2009-03-27 10:43:48 UTC (rev 86416)
@@ -0,0 +1,38 @@
+/*
+ * 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.test.sessionsync.interfaces;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+/**
+ * A StatefulSessionHome.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public interface StatefulSessionHome extends EJBHome
+{
+   StatefulSession create() throws CreateException, RemoteException;
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/test/CompEnvInSessionSyncCallbacksUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/test/CompEnvInSessionSyncCallbacksUnitTestCase.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/sessionsync/test/CompEnvInSessionSyncCallbacksUnitTestCase.java	2009-03-27 10:43:48 UTC (rev 86416)
@@ -0,0 +1,82 @@
+/*
+ * 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.test.sessionsync.test;
+
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.sessionsync.actions.GetAfterBeginEntryAction;
+import org.jboss.test.sessionsync.actions.GetAfterCompletionEntryAction;
+import org.jboss.test.sessionsync.actions.GetBeforeCompletionEntryAction;
+import org.jboss.test.sessionsync.interfaces.ActionExecutor;
+import org.jboss.test.sessionsync.interfaces.ActionExecutorHome;
+import org.jboss.test.sessionsync.interfaces.StatefulSession;
+import org.jboss.test.sessionsync.interfaces.StatefulSessionHome;
+
+/**
+ * A CompEnvInSessionSyncCallbacksUnitTestCase.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class CompEnvInSessionSyncCallbacksUnitTestCase extends JBossTestCase
+{
+   public static Test suite() throws Exception
+   {
+      return JBossTestCase.getDeploySetup(CompEnvInSessionSyncCallbacksUnitTestCase.class, "compenv-sessionsync.jar");
+   }
+   
+   public CompEnvInSessionSyncCallbacksUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   /**
+    * This test is based on command pattern and calling methods on the target stateful session bean
+    * from a delegating stateless session bean instead of direct method invocations on the target stateful session bean.
+    * This is done on purpose to make sure the container sets up comp/env properly in the transaction synchronization implementation
+    * before invoking SessionSynchronization callbacks.
+    * 
+    * @throws Exception
+    */
+   public void testBeforeCompletion() throws Exception
+   {
+      ActionExecutorHome executorHome = (ActionExecutorHome) getInitialContext().lookup("ActionExecutorBean");
+      ActionExecutor executor = executorHome.create();
+
+      StatefulSessionHome sessionHome = (StatefulSessionHome) getInitialContext().lookup("StatefulSessionBean");
+      final StatefulSession session = sessionHome.create();
+      try
+      {
+
+         assertEquals("after-begin", executor.execute(new GetAfterBeginEntryAction(session.getHandle())));
+         assertEquals("before-completion", executor.execute(new GetBeforeCompletionEntryAction(session.getHandle())));
+         assertEquals("after-completion", executor.execute(new GetAfterCompletionEntryAction(session.getHandle())));
+      }
+      finally
+      {
+         if(session != null)
+            session.remove();
+      }
+   }
+}

Added: branches/Branch_5_x/testsuite/src/resources/sessionsync/META-INF/ejb-jar.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/sessionsync/META-INF/ejb-jar.xml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/sessionsync/META-INF/ejb-jar.xml	2009-03-27 10:43:48 UTC (rev 86416)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
+
+<ejb-jar >
+   <enterprise-beans>
+   
+     <session>
+        <ejb-name>StatefulSession</ejb-name>
+        <home>org.jboss.test.sessionsync.interfaces.StatefulSessionHome</home>
+        <remote>org.jboss.test.sessionsync.interfaces.StatefulSession</remote>
+        <ejb-class>org.jboss.test.sessionsync.ejb.StatefulSessionBean</ejb-class>
+        <session-type>Stateful</session-type>
+        <transaction-type>Container</transaction-type>
+
+         <env-entry>
+            <description></description>
+            <env-entry-name>afterBegin</env-entry-name>
+            <env-entry-type>java.lang.String</env-entry-type>
+            <env-entry-value>after-begin</env-entry-value>
+         </env-entry>
+         <env-entry>
+            <description></description>
+            <env-entry-name>beforeCompletion</env-entry-name>
+            <env-entry-type>java.lang.String</env-entry-type>
+            <env-entry-value>before-completion</env-entry-value>
+         </env-entry>
+         <env-entry>
+            <description></description>
+            <env-entry-name>afterCompletion</env-entry-name>
+            <env-entry-type>java.lang.String</env-entry-type>
+            <env-entry-value>after-completion</env-entry-value>
+         </env-entry>
+     </session>
+
+     <session>
+        <ejb-name>ActionExecutor</ejb-name>
+        <home>org.jboss.test.sessionsync.interfaces.ActionExecutorHome</home>
+        <remote>org.jboss.test.sessionsync.interfaces.ActionExecutor</remote>
+        <ejb-class>org.jboss.test.sessionsync.ejb.ActionExecutorBean</ejb-class>
+        <session-type>Stateless</session-type>
+        <transaction-type>Container</transaction-type>
+     </session>
+          
+   </enterprise-beans>
+</ejb-jar>

Added: branches/Branch_5_x/testsuite/src/resources/sessionsync/META-INF/jboss.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/sessionsync/META-INF/jboss.xml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/sessionsync/META-INF/jboss.xml	2009-03-27 10:43:48 UTC (rev 86416)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 4.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
+
+<jboss>
+   <enterprise-beans>
+      <session>
+         <ejb-name>StatefulSession</ejb-name>
+         <jndi-name>StatefulSessionBean</jndi-name>
+      </session>   
+
+      <session>
+         <ejb-name>ActionExecutor</ejb-name>
+         <jndi-name>ActionExecutorBean</jndi-name>
+      </session>   
+   </enterprise-beans>   
+</jboss>




More information about the jboss-cvs-commits mailing list