Index: src/test/org/jboss/ejb3/test/jbpapp2290/unit/ImplementsSessionSynchronizationUnitTestCase.java
===================================================================
--- src/test/org/jboss/ejb3/test/jbpapp2290/unit/ImplementsSessionSynchronizationUnitTestCase.java (リビジョン 0)
+++ src/test/org/jboss/ejb3/test/jbpapp2290/unit/ImplementsSessionSynchronizationUnitTestCase.java (リビジョン 0)
@@ -0,0 +1,205 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.jbpapp2290.unit;
+
+import javax.ejb.SessionSynchronization;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+
+import org.jboss.ejb3.test.common.EJB3TestCase;
+
+import org.jboss.ejb3.test.jbpapp2290.ImplementsSessionSynchronizationBean;
+import org.jboss.ejb3.test.jbpapp2290.ImplementsSessionSynchronizationRemoteBusiness;
+import org.jboss.ejb3.test.jbpapp2290.ImplementsSessionSynchronizationBMTBean;
+import org.jboss.ejb3.test.jbpapp2290.ImplementsSessionSynchronizationBMTRemoteBusiness;
+import org.jboss.logging.Logger;
+
+/**
+ * ImplementsSessionSynchronizationUnitTestCase
+ *
+ * Test Cases to validate JBPAPP-2290 (incorporates EJBTHREE-995)
+ * is resolved
+ *
+ * @author ALR
+ * @author Toshiya Kobayashi
+ * @version $Revision: $
+ */
+public class ImplementsSessionSynchronizationUnitTestCase extends EJB3TestCase
+{
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(ImplementsSessionSynchronizationUnitTestCase.class);
+
+ private ImplementsSessionSynchronizationRemoteBusiness sfsb;
+
+ // --------------------------------------------------------------------------------||
+ // Tests --------------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ public ImplementsSessionSynchronizationUnitTestCase(String name) {
+ super(name);
+ }
+
+ /**
+ * Tests that an invocation to a SFSB implementing SessionSynchronization for CMT
+ * does not result in 2 calls to any of the SessionSynchronization callbacks
+ */
+ public void testSfsbImplementingSessionSynchronizationForDoubleCallbacks() throws Throwable
+ {
+ // Define JNDI Target for Lookup
+ String jndiName = ImplementsSessionSynchronizationBean.class.getSimpleName() + "/" + "remote";
+
+ // Get JNDI Context
+ Context context = new InitialContext();
+
+ // Obtain
+ sfsb = (ImplementsSessionSynchronizationRemoteBusiness) context
+ .lookup(jndiName);
+
+ // Check callbacks are reset
+ this.assertCallbacksReset();
+
+ // Invoke
+ sfsb.call();
+
+ // Check callbacks have been made exactly once
+ this.assertCallsExpected(1);
+
+ // Invoke again
+ sfsb.call();
+
+ // Check callbacks have been made exactly twice
+ this.assertCallsExpected(2);
+
+ // Invoke again
+ sfsb.call();
+
+ // Check callbacks have been made exactly three times
+ this.assertCallsExpected(3);
+
+ // Reset
+ sfsb.resetCounters();
+
+ // Check callbacks are reset
+ this.assertCallbacksReset();
+ }
+
+ /**
+ * Tests that an invocation to a SFSB implementing SessionSynchronization for BMT
+ * does not result in duplicate calls to the SessionSynchronization callbacks after multiple method invocations within Tx.
+ */
+ public void testSfsbImplementingSessionSynchronizationBMTForDoubleCallbacks() throws Throwable
+ {
+ // Define JNDI Target for Lookup
+ String jndiName = ImplementsSessionSynchronizationBMTBean.class.getSimpleName() + "/" + "remote";
+
+ // Get JNDI Context
+ Context context = new InitialContext();
+
+ // Obtain
+ sfsb = (ImplementsSessionSynchronizationBMTRemoteBusiness) context
+ .lookup(jndiName);
+
+ // Check callbacks are reset
+ this.assertCallbacksReset();
+
+ // begin Tx
+ ((ImplementsSessionSynchronizationBMTRemoteBusiness)sfsb).beginTx();
+
+ // Invoke 3times
+ sfsb.call();
+ sfsb.call();
+ sfsb.call();
+
+ // commit Tx
+ ((ImplementsSessionSynchronizationBMTRemoteBusiness)sfsb).commitTx();
+
+ // Check callbacks have been made exactly once
+ this.assertCallsExpected(1);
+
+ // Reset
+ sfsb.resetCounters();
+
+ // Check callbacks are reset
+ this.assertCallbacksReset();
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Helper Methods -----------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Ensures that all SessionSynchronization callbacks are reset to 0
+ */
+ protected void assertCallbacksReset()
+ {
+ int expectedCalls = 0;
+ this.assertCallsExpected(expectedCalls);
+ }
+
+ /**
+ * Ensures that all SessionSynchronization callbacks have been
+ * made the specified number of times
+ *
+ * @param numCalls
+ */
+ protected void assertCallsExpected(int numCalls)
+ {
+ TestCase.assertEquals(numCalls, sfsb.getCounterAfterBegin());
+ TestCase.assertEquals(numCalls, sfsb.getCounterAfterCompletion());
+ TestCase.assertEquals(numCalls, sfsb.getCounterBeforeCompletion());
+ log.info("All " + SessionSynchronization.class.getSimpleName() + " callbacks were obtained expected " + numCalls
+ + " times.");
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(ImplementsSessionSynchronizationUnitTestCase.class, "jbpapp2290.jar");
+ }
+
+}
Index: src/test/org/jboss/ejb3/test/jbpapp2290/ImplementsSessionSynchronizationBean.java
===================================================================
--- src/test/org/jboss/ejb3/test/jbpapp2290/ImplementsSessionSynchronizationBean.java (リビジョン 0)
+++ src/test/org/jboss/ejb3/test/jbpapp2290/ImplementsSessionSynchronizationBean.java (リビジョン 0)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.jbpapp2290;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.EJBException;
+import javax.ejb.Remote;
+import javax.ejb.SessionSynchronization;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+
+import org.jboss.logging.Logger;
+
+/**
+ * ImplementsSessionSynchronizationBean
+ *
+ * A test SFSB that directly implements SessionSynchronization
+ *
+ * JBPAPP-2290 (incorporates EJBTHREE-995)
+ *
+ * @author ALR
+ * @author Toshiya Kobayashi
+ * @version $Revision: $
+ */
+@Stateful
+@Remote(ImplementsSessionSynchronizationRemoteBusiness.class)
+public class ImplementsSessionSynchronizationBean
+ implements
+ ImplementsSessionSynchronizationRemoteBusiness,
+ SessionSynchronization
+{
+
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(ImplementsSessionSynchronizationBean.class);
+
+ /*
+ * Define some counters to be used by the test.
+ */
+ public int CALLS_AFTER_BEGIN = 0;
+
+ public int CALLS_AFTER_COMPLETION = 0;
+
+ public int CALLS_BEFORE_COMPLETION = 0;
+
+ // --------------------------------------------------------------------------------||
+ // Required Implementations -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * A simple invocation that implements no business logic
+ */
+ @TransactionAttribute(value=TransactionAttributeType.REQUIRED)
+ public void call()
+ {
+ }
+
+ public void afterBegin() throws EJBException, RemoteException
+ {
+ log.info("afterBegin");
+ CALLS_AFTER_BEGIN++;
+ }
+
+ public void afterCompletion(boolean committed) throws EJBException, RemoteException
+ {
+ log.info("afterCompletion");
+ CALLS_AFTER_COMPLETION++;
+ }
+
+ public void beforeCompletion() throws EJBException, RemoteException
+ {
+ log.info("beforeCompletion");
+ CALLS_BEFORE_COMPLETION++;
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Helper Methods -----------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Resets the SessionSynchronization counters
+ */
+ @TransactionAttribute(value=TransactionAttributeType.NOT_SUPPORTED)
+ public void resetCounters()
+ {
+ CALLS_AFTER_BEGIN = 0;
+ CALLS_AFTER_COMPLETION = 0;
+ CALLS_BEFORE_COMPLETION = 0;
+ }
+
+ @TransactionAttribute(value=TransactionAttributeType.NOT_SUPPORTED)
+ public int getCounterAfterBegin() {
+ return CALLS_AFTER_BEGIN;
+ }
+
+ @TransactionAttribute(value=TransactionAttributeType.NOT_SUPPORTED)
+ public int getCounterAfterCompletion() {
+ return CALLS_AFTER_COMPLETION;
+ }
+
+ @TransactionAttribute(value=TransactionAttributeType.NOT_SUPPORTED)
+ public int getCounterBeforeCompletion() {
+ return CALLS_BEFORE_COMPLETION;
+ }
+
+}
Index: src/test/org/jboss/ejb3/test/jbpapp2290/ImplementsSessionSynchronizationRemoteBusiness.java
===================================================================
--- src/test/org/jboss/ejb3/test/jbpapp2290/ImplementsSessionSynchronizationRemoteBusiness.java (リビジョン 0)
+++ src/test/org/jboss/ejb3/test/jbpapp2290/ImplementsSessionSynchronizationRemoteBusiness.java (リビジョン 0)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.jbpapp2290;
+
+/**
+ * ImplementsSessionSynchronizationRemoteBusiness
+ *
+ * Remote Business interface for an EJB directly implementing
+ * SessionSynchronization
+ *
+ * @author ALR
+ * @author Toshiya Kobayashi
+ * @version $Revision: $
+ */
+public interface ImplementsSessionSynchronizationRemoteBusiness
+{
+ // --------------------------------------------------------------------------------||
+ // Contracts ----------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * A simple invocation that implements no business logic
+ */
+ void call();
+
+ /**
+ * Helper method for test
+ */
+ void resetCounters();
+ int getCounterAfterBegin();
+ int getCounterAfterCompletion();
+ int getCounterBeforeCompletion();
+
+}
Index: src/test/org/jboss/ejb3/test/jbpapp2290/ImplementsSessionSynchronizationBMTBean.java
===================================================================
--- src/test/org/jboss/ejb3/test/jbpapp2290/ImplementsSessionSynchronizationBMTBean.java (リビジョン 0)
+++ src/test/org/jboss/ejb3/test/jbpapp2290/ImplementsSessionSynchronizationBMTBean.java (リビジョン 0)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.jbpapp2290;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.EJBException;
+import javax.ejb.Remote;
+import javax.ejb.SessionSynchronization;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import javax.transaction.UserTransaction;
+
+import org.jboss.logging.Logger;
+
+/**
+ * ImplementsSessionSynchronizationBMTBean
+ *
+ * A test SFSB that directly implements SessionSynchronization
+ *
+ * JBPAPP-2290 (incorporates EJBTHREE-995)
+ *
+ * @author ALR
+ * @author Toshiya Kobayashi
+ * @version $Revision: $
+ */
+@TransactionManagement(value=TransactionManagementType.BEAN)
+@Stateful
+@Remote(ImplementsSessionSynchronizationBMTRemoteBusiness.class)
+public class ImplementsSessionSynchronizationBMTBean
+ implements
+ ImplementsSessionSynchronizationBMTRemoteBusiness,
+ SessionSynchronization
+{
+
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(ImplementsSessionSynchronizationBMTBean.class);
+
+ /*
+ * Define some counters to be used by the test.
+ */
+ public int CALLS_AFTER_BEGIN = 0;
+
+ public int CALLS_AFTER_COMPLETION = 0;
+
+ public int CALLS_BEFORE_COMPLETION = 0;
+
+ // --------------------------------------------------------------------------------||
+ // Required Implementations -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * A simple invocation that implements no business logic
+ */
+ public void call()
+ {
+ }
+
+ /**
+ * begin transaction
+ */
+ public void beginTx() throws Exception
+ {
+ Context context = new InitialContext();
+ UserTransaction ut = (UserTransaction)context.lookup("UserTransaction");
+ log.info("ut.begin()");
+ ut.begin();
+ }
+
+ /**
+ * commit transaction
+ */
+ public void commitTx() throws Exception
+ {
+ Context context = new InitialContext();
+ UserTransaction ut = (UserTransaction)context.lookup("UserTransaction");
+ log.info("ut.commit()");
+ ut.commit();
+ }
+
+
+
+ public void afterBegin() throws EJBException, RemoteException
+ {
+ log.info("afterBegin");
+ CALLS_AFTER_BEGIN++;
+ }
+
+ public void afterCompletion(boolean committed) throws EJBException, RemoteException
+ {
+ log.info("afterCompletion");
+ CALLS_AFTER_COMPLETION++;
+ }
+
+ public void beforeCompletion() throws EJBException, RemoteException
+ {
+ log.info("beforeCompletion");
+ CALLS_BEFORE_COMPLETION++;
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Helper Methods -----------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Resets the SessionSynchronization counters
+ */
+ public void resetCounters()
+ {
+ CALLS_AFTER_BEGIN = 0;
+ CALLS_AFTER_COMPLETION = 0;
+ CALLS_BEFORE_COMPLETION = 0;
+ }
+
+ public int getCounterAfterBegin() {
+ return CALLS_AFTER_BEGIN;
+ }
+
+ public int getCounterAfterCompletion() {
+ return CALLS_AFTER_COMPLETION;
+ }
+
+ public int getCounterBeforeCompletion() {
+ return CALLS_BEFORE_COMPLETION;
+ }
+
+}
Index: src/test/org/jboss/ejb3/test/jbpapp2290/ImplementsSessionSynchronizationBMTRemoteBusiness.java
===================================================================
--- src/test/org/jboss/ejb3/test/jbpapp2290/ImplementsSessionSynchronizationBMTRemoteBusiness.java (リビジョン 0)
+++ src/test/org/jboss/ejb3/test/jbpapp2290/ImplementsSessionSynchronizationBMTRemoteBusiness.java (リビジョン 0)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.jbpapp2290;
+
+/**
+ * ImplementsSessionSynchronizationBMTRemoteBusiness
+ *
+ * Remote Business interface for an EJB directly implementing
+ * SessionSynchronization
+ *
+ * @author ALR
+ * @author Toshiya Kobayashi
+ * @version $Revision: $
+ */
+public interface ImplementsSessionSynchronizationBMTRemoteBusiness extends ImplementsSessionSynchronizationRemoteBusiness
+{
+ // --------------------------------------------------------------------------------||
+ // Contracts ----------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ void beginTx() throws Exception;
+ void commitTx() throws Exception;
+
+}
Index: build-test.xml
===================================================================
--- build-test.xml (リビジョン 92407)
+++ build-test.xml (作業コピー)
@@ -2219,6 +2219,18 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -3921,6 +3933,7 @@
jbpapp1668,
jbpapp1951,
jbpapp2260,
+ jbpapp2290,
jbas4489, epcpropagation, jaccpropagation,
aspectdomain, ejbcontext, schema, mail, scopedclassloader, dependency, jaxws,
pkg, securitydomain, enventry, externalpersistenceunit,
@@ -4577,6 +4590,9 @@
+
+
+