[jboss-cvs] JBossAS SVN: r95392 - in projects/ejb3/trunk: core/src/main/java/org/jboss/ejb3 and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Oct 22 07:53:53 EDT 2009
Author: jaikiran
Date: 2009-10-22 07:53:52 -0400 (Thu, 22 Oct 2009)
New Revision: 95392
Added:
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/ResultTracker.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/SimpleTimer.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/TimerBeanBase.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/TimerSLSBean.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/TimerServiceBean.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/unit/
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/unit/TimerTestCase.java
Modified:
projects/ejb3/trunk/as-int/pom.xml
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
projects/ejb3/trunk/ejb3/pom.xml
projects/ejb3/trunk/plugin/pom.xml
projects/ejb3/trunk/testsuite/build-test.xml
Log:
EJBTHREE-1926 Any suspended timers will be restored after the container is ready to accept invocations
Modified: projects/ejb3/trunk/as-int/pom.xml
===================================================================
--- projects/ejb3/trunk/as-int/pom.xml 2009-10-22 11:39:22 UTC (rev 95391)
+++ projects/ejb3/trunk/as-int/pom.xml 2009-10-22 11:53:52 UTC (rev 95392)
@@ -29,7 +29,7 @@
into the AS
-->
- <version.org.jboss.ejb3_jboss.ejb3>1.1.19</version.org.jboss.ejb3_jboss.ejb3>
+ <version.org.jboss.ejb3_jboss.ejb3>1.1.20-SNAPSHOT</version.org.jboss.ejb3_jboss.ejb3>
<version.org.jboss.ejb3_jboss.ejb3.metrics.deployer>1.0.1</version.org.jboss.ejb3_jboss.ejb3.metrics.deployer>
<version.org.jboss.ejb3_mc.int>1.0.1</version.org.jboss.ejb3_mc.int>
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java 2009-10-22 11:39:22 UTC (rev 95391)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java 2009-10-22 11:53:52 UTC (rev 95392)
@@ -896,6 +896,11 @@
// Allow invocations until stop()
this.allowInvocations();
+
+ // Now that invocations are allowed on the containers,
+ // let us invoke this callback so that individual
+ // containers can do an startup invocations if required
+ this.afterStart();
}
// Everything must be done in start to make sure all dependencies have been satisfied
@@ -925,6 +930,22 @@
log.info("STARTED EJB: " + beanClass.getName() + " ejbName: " + ejbName);
}
+
+ /**
+ * Invoked after all the dependencies on the containers have satisfied and the
+ * container is completely started and open for invocations.
+ *
+ * Containers can use this method as a callback point where they want to do
+ * some startup invocations on the container, which requires the container
+ * to be open for invocations (ex: restoring timers - see StatelessContainer)
+ *
+ * @see #start()
+ */
+ protected void afterStart()
+ {
+ // do nothing, let the specific containers (ex: StatelessContainer) do anything
+ // specific they want to.
+ }
/**
* This should have been final, but ServiceContainer wants to butt in.
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java 2009-10-22 11:39:22 UTC (rev 95391)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java 2009-10-22 11:53:52 UTC (rev 95392)
@@ -256,13 +256,14 @@
initBeanContext();
// make sure the timer service is there before injection takes place
+ // Any suspended timers will be restored, through afterStart(),
+ // once the containers are fully started and open for invocations
timerService = timerServiceFactory.createTimerService(this);
injectDependencies(beanContext);
invokePostConstruct(beanContext);
- timerServiceFactory.restoreTimerService(timerService);
}
catch (Exception e)
{
@@ -279,7 +280,21 @@
}
}
+ /**
+ * Restores the timers after this container has fully started, thus
+ * ensuring that any invocations on this container through the restored
+ * timers are handled successfully
+ *
+ * @see org.jboss.ejb3.EJBContainer#afterStart()
+ */
@Override
+ protected void afterStart()
+ {
+ super.afterStart();
+ this.timerServiceFactory.restoreTimerService(timerService);
+ }
+
+ @Override
protected void lockedStop() throws Exception
{
invokePreDestroy(beanContext);
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java 2009-10-22 11:39:22 UTC (rev 95391)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java 2009-10-22 11:53:52 UTC (rev 95392)
@@ -190,10 +190,11 @@
try
{
super.lockedStart();
-
+ // just create the timerservice, restoring of
+ // any timers which were suspended during undeployment
+ // will be done, through afterStart(), once the container has fully started.
timerService = timerServiceFactory.createTimerService(this);
- timerServiceFactory.restoreTimerService(timerService);
}
catch (Exception e)
{
@@ -208,6 +209,20 @@
throw e;
}
}
+
+ /**
+ * Restores the timers after this container has fully started, thus
+ * ensuring that any invocations on this container through the restored
+ * timers are handled successfully
+ *
+ * @see org.jboss.ejb3.EJBContainer#afterStart()
+ */
+ @Override
+ protected void afterStart()
+ {
+ super.afterStart();
+ this.timerServiceFactory.restoreTimerService(timerService);
+ }
@Override
protected void lockedStop() throws Exception
Modified: projects/ejb3/trunk/ejb3/pom.xml
===================================================================
--- projects/ejb3/trunk/ejb3/pom.xml 2009-10-22 11:39:22 UTC (rev 95391)
+++ projects/ejb3/trunk/ejb3/pom.xml 2009-10-22 11:53:52 UTC (rev 95392)
@@ -35,7 +35,7 @@
into the AS
-->
- <version.org.jboss.ejb3_core>1.1.19</version.org.jboss.ejb3_core>
+ <version.org.jboss.ejb3_core>1.1.20-SNAPSHOT</version.org.jboss.ejb3_core>
<version.org.jboss.ejb3_deployers>1.0.0</version.org.jboss.ejb3_deployers>
</properties>
Modified: projects/ejb3/trunk/plugin/pom.xml
===================================================================
--- projects/ejb3/trunk/plugin/pom.xml 2009-10-22 11:39:22 UTC (rev 95391)
+++ projects/ejb3/trunk/plugin/pom.xml 2009-10-22 11:53:52 UTC (rev 95392)
@@ -63,7 +63,7 @@
<dependency>
<groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-as-int</artifactId>
- <version>1.1.19</version>
+ <version>1.1.20-SNAPSHOT</version>
<optional>true</optional>
</dependency>
@@ -79,7 +79,7 @@
<groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-core</artifactId>
<classifier>client</classifier>
- <version>1.1.19</version>
+ <version>1.1.20-SNAPSHOT</version>
<optional>true</optional>
</dependency>
Modified: projects/ejb3/trunk/testsuite/build-test.xml
===================================================================
--- projects/ejb3/trunk/testsuite/build-test.xml 2009-10-22 11:39:22 UTC (rev 95391)
+++ projects/ejb3/trunk/testsuite/build-test.xml 2009-10-22 11:53:52 UTC (rev 95392)
@@ -4373,6 +4373,10 @@
</fileset>
</jar>
</target>
+
+ <target name="ejbthree1926">
+ <build-simple-jar name="ejbthree1926"/>
+ </target>
<target name="jars" depends="statefulproxyfactoryoverride, removedislocal, statelesscreation, defaultremotebindings, localfromremote, clusteredjms, entityoptimisticlocking, concurrentnaming, propertyreplacement, persistenceunits, appclient, tck5sec, invalidtxmdb, descriptortypo, libdeployment, homeinterface, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader,
concurrent,
@@ -4404,7 +4408,7 @@
composite, composite2, entitycallback, relationships, ssl, ssladvanced, clusteredsession, strictpool, jacc,
localcall, interceptors, interceptors2, interceptors3, iiop, clientinterceptor,
statelesscreation, changexml, externalrefscoped, singleton, ejbthree1671, ejbthree1677, ejbthree1629,
- ejbthree1807, ejbthree1346, ejbthree1823, ejbthree1858, ejbthree1876"/>
+ ejbthree1807, ejbthree1346, ejbthree1823, ejbthree1858, ejbthree1876, ejbthree1926"/>
<target name="test" depends="init" if="test"
description="Execute all tests in the given test directory.">
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/ResultTracker.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/ResultTracker.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/ResultTracker.java 2009-10-22 11:53:52 UTC (rev 95392)
@@ -0,0 +1,73 @@
+/*
+* 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.ejbthree1926;
+
+import org.jboss.ejb3.test.ejbthree1926.unit.TimerTestCase;
+
+/**
+ * ResultTracker
+ *
+ * Utility class for tracking result of {@link TimerTestCase}
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class ResultTracker
+{
+
+ private static ResultTracker resultTracker;
+
+ public enum Result {
+ SUCCESS, FAILURE
+ }
+
+ private Result result = Result.FAILURE;
+
+ private ResultTracker()
+ {
+
+ }
+
+ public static synchronized ResultTracker getInstance()
+ {
+ if (resultTracker == null)
+ {
+ resultTracker = new ResultTracker();
+ }
+ return resultTracker;
+ }
+
+ public void setSuccess()
+ {
+ this.result = Result.SUCCESS;
+ }
+
+ public void setFailure()
+ {
+ this.result = Result.FAILURE;
+ }
+
+ public Result getResult()
+ {
+ return this.result;
+ }
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/SimpleTimer.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/SimpleTimer.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/SimpleTimer.java 2009-10-22 11:53:52 UTC (rev 95392)
@@ -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.ejbthree1926;
+
+import org.jboss.ejb3.test.ejbthree1926.ResultTracker.Result;
+
+/**
+ * SimpleTimer
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface SimpleTimer
+{
+ void scheduleAfter(long delay);
+
+ Result getResult();
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/TimerBeanBase.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/TimerBeanBase.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/TimerBeanBase.java 2009-10-22 11:53:52 UTC (rev 95392)
@@ -0,0 +1,80 @@
+/*
+* 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.ejbthree1926;
+
+import java.util.Date;
+
+import javax.annotation.Resource;
+import javax.ejb.Timeout;
+import javax.ejb.Timer;
+import javax.ejb.TimerService;
+
+import org.jboss.ejb3.test.ejbthree1926.ResultTracker.Result;
+import org.jboss.logging.Logger;
+
+/**
+ * TimerBeanBase
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class TimerBeanBase implements SimpleTimer
+{
+
+ /**
+ * Logger
+ */
+ private static Logger logger = Logger.getLogger(TimerBeanBase.class);
+
+ @Resource
+ private TimerService timerService;
+
+ /**
+ * @see org.jboss.ejb3.test.ejbthree1926.SimpleTimer#scheduleAfter(long)
+ */
+ public void scheduleAfter(long delay)
+ {
+ Date scheduledTime = new Date(new Date().getTime() + delay);
+ Timer timer = this.timerService.createTimer(scheduledTime, "This is a timer which was scheduled to fire at "
+ + scheduledTime);
+ logger.info("Timer " + timer + " scheduled to fire once at " + timer.getNextTimeout());
+
+ }
+
+ @Timeout
+ public void timeout(Timer timer)
+ {
+ logger.info("Received timeout at " + new Date(System.currentTimeMillis()) + " from timer " + timer
+ + " with info: " + timer.getInfo());
+ // track this successful invocation
+ ResultTracker.getInstance().setSuccess();
+ }
+
+ /**
+ * @see org.jboss.ejb3.test.ejbthree1926.SimpleTimer#getResult()
+ */
+ public Result getResult()
+ {
+ return ResultTracker.getInstance().getResult();
+ }
+
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/TimerSLSBean.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/TimerSLSBean.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/TimerSLSBean.java 2009-10-22 11:53:52 UTC (rev 95392)
@@ -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.ejb3.test.ejbthree1926;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+/**
+ * TimerSLSBean
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Stateless
+ at Remote(SimpleTimer.class)
+public class TimerSLSBean extends TimerBeanBase
+{
+
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/TimerServiceBean.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/TimerServiceBean.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/TimerServiceBean.java 2009-10-22 11:53:52 UTC (rev 95392)
@@ -0,0 +1,40 @@
+/*
+* 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.ejbthree1926;
+
+import javax.ejb.Remote;
+
+import org.jboss.ejb3.annotation.Service;
+
+/**
+ * TimerServiceBean
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Service
+ at Remote (SimpleTimer.class)
+public class TimerServiceBean extends TimerBeanBase
+{
+
+
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/unit/TimerTestCase.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/unit/TimerTestCase.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1926/unit/TimerTestCase.java 2009-10-22 11:53:52 UTC (rev 95392)
@@ -0,0 +1,129 @@
+/*
+* 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.ejbthree1926.unit;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.ejbthree1926.SimpleTimer;
+import org.jboss.ejb3.test.ejbthree1926.ResultTracker.Result;
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * TimerTestCase
+ *
+ * Testcase for EJBTHREE-1926 https://jira.jboss.org/jira/browse/EJBTHREE-1926
+ * The bug was caused by restoring the timers too early during the EJB3 container
+ * startup (in the stateless/service container lockedStart()).
+ *
+ * The fix involved restoring the timers after the containers have started
+ * and are ready to accept invocations.
+ *
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class TimerTestCase extends JBossTestCase
+{
+
+ /**
+ * Logger
+ */
+ private static Logger logger = Logger.getLogger(TimerTestCase.class);
+
+ private static final String JAR_NAME = "ejbthree1926.jar";
+
+ /**
+ * @param name
+ */
+ public TimerTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ *
+ * @return
+ * @throws Exception
+ */
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(TimerTestCase.class, JAR_NAME);
+ }
+
+ /**
+ * Tests that the timer, for a SLSB, scheduled for future, is invoked after
+ * the StatelessContainer is started completely.
+ *
+ * @throws Exception
+ */
+ public void testTimerRestoreForSLSB() throws Exception
+ {
+ logger.debug("Testing timer restore on SLSB");
+ doTest("TimerSLSBean/remote");
+ }
+
+ /**
+ * Tests that the timer scheduled, for Service Bean, for future, is invoked after
+ * the ServiceContainer is started completely.
+ *
+ * @throws Exception
+ */
+ public void testTimerRestoreForServiceBean() throws Exception
+ {
+ logger.debug("Testing timer restore on @Service Bean");
+ doTest("TimerServiceBean/remote");
+ }
+
+ /**
+ * Utility method for testing the timers
+ *
+ * @param jndiName The jndi name of the bean to lookup
+ * @throws Exception
+ */
+ private void doTest(String jndiName) throws Exception
+ {
+ // first get hold of the bean and create a timer
+ Context ctx = new InitialContext();
+ SimpleTimer timerBean = (SimpleTimer) ctx.lookup(jndiName);
+ // schedule a (future) timer to fire after 1 sec
+ // and then immidiately undeploy the EJB application, so that
+ // the timer is triggered next time the EJB application is deployed
+ timerBean.scheduleAfter(1000);
+ logger.info("Undeploying " + JAR_NAME);
+ this.undeploy(JAR_NAME);
+ // wait for a few seconds so that the timer is triggered
+ // during container start
+ Thread.sleep(3000);
+ // now deploy back the same EJB application
+ logger.info("deploying again " + JAR_NAME);
+ this.deploy("ejbthree1926.jar");
+
+ // lookup the bean and check the result
+ timerBean = (SimpleTimer) ctx.lookup(jndiName);
+ assertEquals("Timer failed to invoke the TimeOut method on bean with jndi-name: " + jndiName, Result.SUCCESS,
+ timerBean.getResult());
+ }
+}
More information about the jboss-cvs-commits
mailing list