[jboss-cvs] JBossAS SVN: r112711 - in branches/JBPAPP_5_1_2_GA_JBPAPP-8231: ejb3/src/main/org/jboss/as/ejb3/timerservice and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Feb 29 00:21:39 EST 2012


Author: bmaxwell
Date: 2012-02-29 00:21:36 -0500 (Wed, 29 Feb 2012)
New Revision: 112711

Added:
   branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/
   branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/TimerSample.java
   branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/TimerSampleBean.java
   branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/unit/
   branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/unit/OverloadTimerServiceTestCase.java
Removed:
   branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/TimerSample.java
   branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/TimerSampleBean.java
   branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/unit/
   branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/unit/OverloadTimerServiceTestCase.java
Modified:
   branches/JBPAPP_5_1_2_GA_JBPAPP-8231/
   branches/JBPAPP_5_1_2_GA_JBPAPP-8231/ejb3/src/main/org/jboss/as/ejb3/timerservice/JBossTimerServiceFactory.java
   branches/JBPAPP_5_1_2_GA_JBPAPP-8231/main/src/bin/run.sh
   branches/JBPAPP_5_1_2_GA_JBPAPP-8231/server/src/main/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
   branches/JBPAPP_5_1_2_GA_JBPAPP-8231/server/src/main/org/jboss/ejb/txtimer/EJBTimerServiceImplMBean.java
   branches/JBPAPP_5_1_2_GA_JBPAPP-8231/server/src/main/org/jboss/ejb/txtimer/TimerImpl.java
   branches/JBPAPP_5_1_2_GA_JBPAPP-8231/server/src/main/org/jboss/ejb/txtimer/TimerServiceImpl.java
   branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/imports/sections/ejb3.xml
Log:
[JBPAPP-8231] introduced a ScheduledExecutorService for handling the timeout callbacks


Property changes on: branches/JBPAPP_5_1_2_GA_JBPAPP-8231
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/JBPAPP_5_1:112274,112285,112323
   + /branches/JBPAPP_5_1:112274,112285,112323,112630

Modified: branches/JBPAPP_5_1_2_GA_JBPAPP-8231/ejb3/src/main/org/jboss/as/ejb3/timerservice/JBossTimerServiceFactory.java
===================================================================
--- branches/JBPAPP_5_1_2_GA_JBPAPP-8231/ejb3/src/main/org/jboss/as/ejb3/timerservice/JBossTimerServiceFactory.java	2012-02-28 18:03:36 UTC (rev 112710)
+++ branches/JBPAPP_5_1_2_GA_JBPAPP-8231/ejb3/src/main/org/jboss/as/ejb3/timerservice/JBossTimerServiceFactory.java	2012-02-29 05:21:36 UTC (rev 112711)
@@ -21,9 +21,6 @@
  */
 package org.jboss.as.ejb3.timerservice;
 
-import javax.ejb.TimerService;
-import javax.management.ObjectName;
-
 import org.jboss.ejb.AllowedOperationsAssociation;
 import org.jboss.ejb.txtimer.EJBTimerService;
 import org.jboss.ejb3.timerservice.spi.TimedObjectInvoker;
@@ -32,6 +29,9 @@
 import org.jboss.mx.util.MBeanProxyExt;
 import org.jboss.mx.util.MBeanServerLocator;
 
+import javax.ejb.TimerService;
+import javax.management.ObjectName;
+
 /**
  * Factory to create timer services which use the JBoss EJB Timer Service.
  *
@@ -87,15 +87,7 @@
       }
       catch (Exception e)
       {
-         //throw new EJBException("Could not remove timer service", e);
-         if (log.isTraceEnabled())
-         {
-            log.trace("Unable to initialize timer service", e);
-         }
-         else
-         {
-            log.trace("Unable to initialize timer service");
-         }
+         log.warn("Unable to remove timer service", e);
       }
    }
 


Property changes on: branches/JBPAPP_5_1_2_GA_JBPAPP-8231/main/src/bin/run.sh
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/JBPAPP_4_2_0_GA_CP/system/src/bin/run.sh:108548
/branches/JBPAPP_5_1/main/src/bin/run.sh:112274,112285,112323
   + /branches/JBPAPP_4_2_0_GA_CP/system/src/bin/run.sh:108548
/branches/JBPAPP_5_1/main/src/bin/run.sh:112274,112285,112323,112630

Modified: branches/JBPAPP_5_1_2_GA_JBPAPP-8231/server/src/main/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
===================================================================
--- branches/JBPAPP_5_1_2_GA_JBPAPP-8231/server/src/main/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java	2012-02-28 18:03:36 UTC (rev 112710)
+++ branches/JBPAPP_5_1_2_GA_JBPAPP-8231/server/src/main/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java	2012-02-29 05:21:36 UTC (rev 112711)
@@ -23,6 +23,20 @@
 
 // $Id$
 
+import org.jboss.ejb.Container;
+import org.jboss.ejb.ContainerMBean;
+import org.jboss.logging.Logger;
+import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.system.ServiceMBeanSupport;
+import org.jboss.tm.TransactionManagerFactory;
+import org.jboss.tm.TransactionManagerLocator;
+
+import javax.ejb.EJBException;
+import javax.ejb.Timer;
+import javax.ejb.TimerService;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+import javax.transaction.TransactionManager;
 import java.io.Serializable;
 import java.lang.reflect.Constructor;
 import java.util.Collection;
@@ -33,21 +47,6 @@
 import java.util.List;
 import java.util.Map;
 
-import javax.ejb.EJBException;
-import javax.ejb.Timer;
-import javax.ejb.TimerService;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.transaction.TransactionManager;
-
-import org.jboss.ejb.Container;
-import org.jboss.ejb.ContainerMBean;
-import org.jboss.logging.Logger;
-import org.jboss.mx.util.MBeanProxyExt;
-import org.jboss.system.ServiceMBeanSupport;
-import org.jboss.tm.TransactionManagerFactory;
-import org.jboss.tm.TransactionManagerLocator;
-
 /**
  * A service that implements this interface provides an Tx aware EJBTimerService.
  *
@@ -127,6 +126,9 @@
    // Maps the timedObjectId to TimerServiceImpl objects
    private Map<TimedObjectId, TimerServiceImpl> timerServiceMap = Collections.synchronizedMap(new HashMap<TimedObjectId, TimerServiceImpl>());
 
+   // A pool of timer that avoid creating one thread per task.
+   private Integer threadPoolSize = new Integer(50);
+
    // Attributes ----------------------------------------------------
    
    /**
@@ -216,7 +218,27 @@
    {
       this.transactionManagerFactory = factory;
    }
-   
+
+   /**
+    * Get the ThreadPoolSize
+    *
+    * @jmx.managed-attribute
+    */
+   public Integer getThreadPoolSize()
+   {
+      return threadPoolSize;
+   }
+
+   /**
+    * Set the threadPoolSize
+    *
+    * @jmx.managed-attribute
+    */
+   public void setThreadPoolSize(Integer threadPoolSize)
+   {
+      this.threadPoolSize = threadPoolSize;
+   }
+
    // ServiceMBeanSupport Lifecycle ---------------------------------
    
    protected void startService() throws Exception
@@ -228,7 +250,7 @@
          transactionManager = transactionManagerFactory.getTransactionManager();
       else
          transactionManager = TransactionManagerLocator.getInstance().locate();
-      
+
       // Get a proxy to the retry policy
       try
       {
@@ -291,7 +313,7 @@
     * The TimedObjectInvoker is constructed from the invokerClassName.
     *
     * @param containerId The string identifier for a class of TimedObjects
-    * @param instancePk  The rimary key for an instance of a TimedObject, may be null
+    * @param instancePk  The primary key for an instance of a TimedObject, may be null
     * @param container   The Container that is associated with the TimerService
     * @return the TimerService
     */
@@ -329,7 +351,7 @@
       if (timerService == null)
       {
          timerService = new TimerServiceImpl(timedObjectId, invoker,
-               transactionManager, persistencePolicy, retryPolicy, timerIdGenerator);
+               transactionManager, persistencePolicy, retryPolicy, timerIdGenerator, getThreadPoolSize());
          log.debug("createTimerService: " + timerService);
          timerServiceMap.put(timedObjectId, timerService);
       }

Modified: branches/JBPAPP_5_1_2_GA_JBPAPP-8231/server/src/main/org/jboss/ejb/txtimer/EJBTimerServiceImplMBean.java
===================================================================
--- branches/JBPAPP_5_1_2_GA_JBPAPP-8231/server/src/main/org/jboss/ejb/txtimer/EJBTimerServiceImplMBean.java	2012-02-28 18:03:36 UTC (rev 112710)
+++ branches/JBPAPP_5_1_2_GA_JBPAPP-8231/server/src/main/org/jboss/ejb/txtimer/EJBTimerServiceImplMBean.java	2012-02-29 05:21:36 UTC (rev 112711)
@@ -21,12 +21,12 @@
  */
 package org.jboss.ejb.txtimer;
 
-import javax.management.ObjectName;
-
 import org.jboss.mx.util.ObjectNameFactory;
 import org.jboss.system.ServiceMBean;
 import org.jboss.tm.TransactionManagerFactory;
 
+import javax.management.ObjectName;
+
 /**
  * EJBTimerServiceImpl MBean interface.
  * 
@@ -61,6 +61,10 @@
    /** The TransactionManagerFactory */
    void setTransactionManagerFactory(TransactionManagerFactory factory);
 
+   Integer getThreadPoolSize();
+   /** Sets the thread pool size for running timeout callbacks, takes effect on restart of the timer service */
+   void setThreadPoolSize(Integer threadPoolSize);
+
    // Operations ----------------------------------------------------
    
    /**

Modified: branches/JBPAPP_5_1_2_GA_JBPAPP-8231/server/src/main/org/jboss/ejb/txtimer/TimerImpl.java
===================================================================
--- branches/JBPAPP_5_1_2_GA_JBPAPP-8231/server/src/main/org/jboss/ejb/txtimer/TimerImpl.java	2012-02-28 18:03:36 UTC (rev 112710)
+++ branches/JBPAPP_5_1_2_GA_JBPAPP-8231/server/src/main/org/jboss/ejb/txtimer/TimerImpl.java	2012-02-29 05:21:36 UTC (rev 112711)
@@ -23,10 +23,8 @@
 
 // $Id$
 
-import java.io.Serializable;
-import java.util.Date;
-import java.util.Timer;
-import java.util.TimerTask;
+import org.jboss.ejb.AllowedOperationsAssociation;
+import org.jboss.logging.Logger;
 
 import javax.ejb.EJBException;
 import javax.ejb.NoSuchObjectLocalException;
@@ -34,9 +32,13 @@
 import javax.transaction.Status;
 import javax.transaction.Synchronization;
 import javax.transaction.Transaction;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.TimerTask;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
 
-import org.jboss.ejb.AllowedOperationsAssociation;
-import org.jboss.logging.Logger;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
 
 /**
  * An implementation of an EJB Timer.
@@ -96,7 +98,7 @@
 
    private long nextExpire;
    private int timerState;
-   private Timer utilTimer;
+   private ScheduledFuture<Void> scheduledFuture;
    private int hashCode;
    
    /**
@@ -119,6 +121,11 @@
       setTimerState(CREATED);
    }
 
+   private ScheduledExecutorService executor()
+   {
+      return timerService.getScheduledExecutorService();
+   }
+
    void startTimer(Date firstTime, long periode)
    {
       this.startTimer(firstTime, firstTime, periode);
@@ -252,7 +259,7 @@
       if (timerState != EXPIRED)
          setTimerState(CANCELED);
       timerService.removeTimer(this);
-      utilTimer.cancel();
+      scheduledFuture.cancel(false);
    }
 
    /**
@@ -262,7 +269,8 @@
    {
       if (timerState != EXPIRED)
          setTimerState(CANCELED);
-      utilTimer.cancel();
+      if (scheduledFuture != null)
+         scheduledFuture.cancel(false);
    }
 
    /**
@@ -273,7 +281,8 @@
       log.debug("stopTimer: " + this);
       if (timerState != EXPIRED)
          setTimerState(CANCELED);
-      utilTimer.cancel();      
+      if (scheduledFuture != null)
+         scheduledFuture.cancel(false);
    }
    
    /**
@@ -411,9 +420,6 @@
 
    private void startInTx()
    {
-      // JBAS-4330, provide a meaningful name to the timer thread, needs jdk5+
-      utilTimer = new Timer("EJB-Timer-" + timerId + timedObjectId);
-      
       if (timerService.getTransaction() != null)
       {
          // don't schedule the timeout yet
@@ -443,14 +449,17 @@
 
    private void scheduleTimeout()
    {
+      long initialDelay = nextExpire - System.currentTimeMillis();
+      if (initialDelay < 0)
+         initialDelay = 0;
       if (periode > 0)
       {
          // schedule the periodic timer task
-         utilTimer.schedule(new TimerTaskImpl(this), new Date(nextExpire), periode);
+         executor().scheduleAtFixedRate(new TimerTaskImpl(this), initialDelay, periode, MILLISECONDS);
       }
       else
       {
-         utilTimer.schedule(new TimerTaskImpl(this), new Date(nextExpire));
+         executor().schedule(new TimerTaskImpl(this), initialDelay, MILLISECONDS);
       }
    }
    
@@ -460,7 +469,7 @@
     */
    private void triggerBacklogTimeoutNow()
    {
-      utilTimer.schedule(new TimerTaskImpl(this, true), new Date());
+      executor().schedule(new TimerTaskImpl(this, true), 0, MILLISECONDS);
    }
    
    /**
@@ -516,13 +525,32 @@
       }
    }
 
+   public void afterCompletion(int status)
+   {
+      // JBPAPP-8073: JBossTM won't say anything useful if afterCompletion fails
+      // TwoPhaseCoordinator.afterCompletion - returned failure for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple at 3c255a5a
+      try
+      {
+         afterCompletion2(status);
+      }
+      catch (Throwable t)
+      {
+         log.error("Aftercompletion failed", t);
+         if (t instanceof RuntimeException)
+            throw (RuntimeException) t;
+         if (t instanceof Error)
+            throw (Error) t;
+         throw new RuntimeException(t);
+      }
+   }
+
    /**
     * This method is invoked after the transaction has committed or
     * rolled back.
     *
     * @param status The status of the completed transaction.
     */
-   public void afterCompletion(int status)
+   private void afterCompletion2(int status)
    {
       if (status == Status.STATUS_COMMITTED)
       {

Modified: branches/JBPAPP_5_1_2_GA_JBPAPP-8231/server/src/main/org/jboss/ejb/txtimer/TimerServiceImpl.java
===================================================================
--- branches/JBPAPP_5_1_2_GA_JBPAPP-8231/server/src/main/org/jboss/ejb/txtimer/TimerServiceImpl.java	2012-02-28 18:03:36 UTC (rev 112710)
+++ branches/JBPAPP_5_1_2_GA_JBPAPP-8231/server/src/main/org/jboss/ejb/txtimer/TimerServiceImpl.java	2012-02-29 05:21:36 UTC (rev 112711)
@@ -23,6 +23,14 @@
 
 // $Id$
 
+import org.jboss.logging.Logger;
+
+import javax.ejb.EJBException;
+import javax.ejb.Timer;
+import javax.ejb.TimerHandle;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -30,16 +38,11 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
 
-import javax.ejb.EJBException;
-import javax.ejb.Timer;
-import javax.ejb.TimerHandle;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
-import org.jboss.logging.Logger;
-
 /**
  * The TimerService provides enterprise bean components with access to the
  * container-provided Timer Service. The EJB Timer Service allows entity beans, stateless
@@ -74,6 +77,8 @@
    // Map<TimerHandleImpl,TimerImpl>
    private Map timers = new HashMap();
 
+   private final ScheduledExecutorService scheduledExecutorService;
+
    // Constructors --------------------------------------------------
    
    /**
@@ -82,16 +87,27 @@
     * All the dependencies are supplied by the caller
     */
    public TimerServiceImpl(
-         TimedObjectId timedObjectId, TimedObjectInvoker timedObjectInvoker,
+         final TimedObjectId timedObjectId, TimedObjectInvoker timedObjectInvoker,
          TransactionManager transactionManager, PersistencePolicy persistencePolicy,
-         RetryPolicy retryPolicy, TimerIdGenerator timerIdGenerator)
+         RetryPolicy retryPolicy, TimerIdGenerator timerIdGenerator, int corePoolSize)
    {
       this.timedObjectId = timedObjectId;
       this.timedObjectInvoker = timedObjectInvoker;
       this.transactionManager = transactionManager;
       this.persistencePolicy = persistencePolicy;
       this.timerIdGenerator = timerIdGenerator;
-      this.retryPolicy = retryPolicy;      
+      this.retryPolicy = retryPolicy;
+      final AtomicInteger numThread = new AtomicInteger(0);
+      final ThreadFactory threadFactory = new ThreadFactory()
+      {
+         @Override
+         public Thread newThread(Runnable r)
+         {
+            // JBAS-4330, provide a meaningful name to the timer thread, needs jdk5+
+            return new Thread(r, "EJB-Timer-" + numThread.incrementAndGet() + " " + timedObjectId);
+         }
+      };
+      this.scheduledExecutorService = new ScheduledThreadPoolExecutor(corePoolSize, threadFactory);
    }
 
    // Public --------------------------------------------------------
@@ -107,6 +123,11 @@
       }
    }
 
+   ScheduledExecutorService getScheduledExecutorService()
+   {
+      return scheduledExecutorService;
+   }
+
    /**
     * Get the Timer for the given timedObjectId
     */
@@ -126,6 +147,8 @@
     */
    public void shutdown(boolean keepState)
    {
+      scheduledExecutorService.shutdown();
+      // TODO: should we await termination? If so, how long?
       synchronized (timers)
       {
          Iterator it = timers.values().iterator();

Modified: branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/imports/sections/ejb3.xml
===================================================================
--- branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/imports/sections/ejb3.xml	2012-02-28 18:03:36 UTC (rev 112710)
+++ branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/imports/sections/ejb3.xml	2012-02-29 05:21:36 UTC (rev 112711)
@@ -259,6 +259,16 @@
       </jar>
    </target>
 
+    <target name="jbpapp8035" depends="compile">
+        <mkdir dir="${build.lib}"/>
+
+        <jar destfile="${build.lib}/jbpapp8035.jar">
+            <fileset dir="${build.classes}">
+                <include name="org/jboss/test/ejb3/jbpapp8035/**" />
+            </fileset>
+        </jar>
+    </target>
+
 	<target name="_jars-ejb3" depends="ejb3-servlet,jbas6161,jbas6239,ejbthree1597,jbas5713,
 		    jbas7883,
 			ejb3iiop,
@@ -269,7 +279,8 @@
 			jbpapp4681,
 			jbpapp6953,
 			jboss51xsd,
-			jbpapp-6855">
+			jbpapp-6855,
+            jbpapp8035">
 		<mkdir dir="${build.lib}" />
 
 		<!-- A jar with a simple ejb3 session -->

Deleted: branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/TimerSample.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/TimerSample.java	2012-02-09 12:35:24 UTC (rev 112630)
+++ branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/TimerSample.java	2012-02-29 05:21:36 UTC (rev 112711)
@@ -1,37 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright (c) 2012, Red Hat, Inc., 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.test.ejb3.jbpapp8035;
-
-import javax.ejb.Remote;
-import java.util.Date;
-
- at Remote
-public interface TimerSample {
-    void cancelAllTimers();
-    int getCount();
-    void resetCount();
-    void scheduleTimer(Date date);
-    void scheduleTimer(long milliseconds);
-    void scheduleTimer(long milliseconds, long period);
-    void scheduleTimers(long number, long milliseconds);
-    void scheduleTimerTxTimeout(long number);
-}
\ No newline at end of file

Copied: branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/TimerSample.java (from rev 112630, branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/TimerSample.java)
===================================================================
--- branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/TimerSample.java	                        (rev 0)
+++ branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/TimerSample.java	2012-02-29 05:21:36 UTC (rev 112711)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (c) 2012, Red Hat, Inc., 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.test.ejb3.jbpapp8035;
+
+import javax.ejb.Remote;
+import java.util.Date;
+
+ at Remote
+public interface TimerSample {
+    void cancelAllTimers();
+    int getCount();
+    void resetCount();
+    void scheduleTimer(Date date);
+    void scheduleTimer(long milliseconds);
+    void scheduleTimer(long milliseconds, long period);
+    void scheduleTimers(long number, long milliseconds);
+    void scheduleTimerTxTimeout(long number);
+}
\ No newline at end of file

Deleted: branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/TimerSampleBean.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/TimerSampleBean.java	2012-02-09 12:35:24 UTC (rev 112630)
+++ branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/TimerSampleBean.java	2012-02-29 05:21:36 UTC (rev 112711)
@@ -1,118 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright (c) 2012, Red Hat, Inc., 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.test.ejb3.jbpapp8035;
-
-import org.jboss.logging.Logger;
-
-import javax.annotation.Resource;
-import javax.ejb.SessionContext;
-import javax.ejb.Stateless;
-import javax.ejb.Timeout;
-import javax.ejb.Timer;
-import java.util.Date;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * Sample Timer sample bean used by the unit test.
- * @author nicolasleroux
- */
- at Stateless
-public class TimerSampleBean implements TimerSample {
-    @Resource
-    private SessionContext ctx;
-
-    private static AtomicInteger count = new AtomicInteger(0);
-
-    public static final Logger log = Logger
-            .getLogger(TimerSampleBean.class);
-
-    public int getCount() {
-        return count.intValue();
-    }
-
-    public void resetCount() {
-        count.set(0);
-    }
-
-    public void scheduleTimer(long milliseconds) {
-        log.info("scheduleTimer with initial duration " + milliseconds);
-        ctx.getTimerService().createTimer(
-                milliseconds, "Hello World");
-    }
-
-    public void scheduleTimer(long milliseconds, long period) {
-        log.info("scheduleTimer with initial duration " + milliseconds + " and period " + period);
-
-        ctx.getTimerService().createTimer(
-                milliseconds, period, "Hello World repeat");
-    }
-
-    public void scheduleTimer(Date date) {
-        log.info("scheduleTimer with date " + date);
-
-        ctx.getTimerService().createTimer(
-                date, "Hello World ");
-    }
-
-    public void scheduleTimerTxTimeout(long milliseconds) {
-        log.info("scheduleTimer with initial duration " + milliseconds);
-        ctx.getTimerService().createTimer(
-                milliseconds, "Hello World ");
-        try {
-            Thread.sleep(300200);
-        } catch(Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    public void cancelAllTimers() {
-        // Cancel the timers
-        for (Object t : ctx.getTimerService().getTimers()) {
-            ((Timer)t).cancel();
-        }
-    }
-
-    @Timeout
-    public void timeoutHandler(Timer timer) {
-        log.info("---------------------");
-        log.info("* Received Timer event: " + timer.getInfo() + " in " + Thread.currentThread().getName());
-        log.info("---------------------");
-        sleep(100);
-        count.incrementAndGet();
-    }
-
-    public void scheduleTimers(long number, long milliseconds) {
-        for (int i = 0; i < number; i++) {
-            log.info("scheduleTimer with initial duration " + milliseconds);
-            ctx.getTimerService().createTimer(
-                    milliseconds, "Hello World");
-        }
-    }
-
-    private static void sleep(final long millis) {
-        try {
-            Thread.sleep(millis);
-        } catch (InterruptedException e) {
-            // ignore
-        }
-    }
-}

Copied: branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/TimerSampleBean.java (from rev 112630, branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/TimerSampleBean.java)
===================================================================
--- branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/TimerSampleBean.java	                        (rev 0)
+++ branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/TimerSampleBean.java	2012-02-29 05:21:36 UTC (rev 112711)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (c) 2012, Red Hat, Inc., 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.test.ejb3.jbpapp8035;
+
+import org.jboss.logging.Logger;
+
+import javax.annotation.Resource;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+import javax.ejb.Timeout;
+import javax.ejb.Timer;
+import java.util.Date;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Sample Timer sample bean used by the unit test.
+ * @author nicolasleroux
+ */
+ at Stateless
+public class TimerSampleBean implements TimerSample {
+    @Resource
+    private SessionContext ctx;
+
+    private static AtomicInteger count = new AtomicInteger(0);
+
+    public static final Logger log = Logger
+            .getLogger(TimerSampleBean.class);
+
+    public int getCount() {
+        return count.intValue();
+    }
+
+    public void resetCount() {
+        count.set(0);
+    }
+
+    public void scheduleTimer(long milliseconds) {
+        log.info("scheduleTimer with initial duration " + milliseconds);
+        ctx.getTimerService().createTimer(
+                milliseconds, "Hello World");
+    }
+
+    public void scheduleTimer(long milliseconds, long period) {
+        log.info("scheduleTimer with initial duration " + milliseconds + " and period " + period);
+
+        ctx.getTimerService().createTimer(
+                milliseconds, period, "Hello World repeat");
+    }
+
+    public void scheduleTimer(Date date) {
+        log.info("scheduleTimer with date " + date);
+
+        ctx.getTimerService().createTimer(
+                date, "Hello World ");
+    }
+
+    public void scheduleTimerTxTimeout(long milliseconds) {
+        log.info("scheduleTimer with initial duration " + milliseconds);
+        ctx.getTimerService().createTimer(
+                milliseconds, "Hello World ");
+        try {
+            Thread.sleep(300200);
+        } catch(Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void cancelAllTimers() {
+        // Cancel the timers
+        for (Object t : ctx.getTimerService().getTimers()) {
+            ((Timer)t).cancel();
+        }
+    }
+
+    @Timeout
+    public void timeoutHandler(Timer timer) {
+        log.info("---------------------");
+        log.info("* Received Timer event: " + timer.getInfo() + " in " + Thread.currentThread().getName());
+        log.info("---------------------");
+        sleep(100);
+        count.incrementAndGet();
+    }
+
+    public void scheduleTimers(long number, long milliseconds) {
+        for (int i = 0; i < number; i++) {
+            log.info("scheduleTimer with initial duration " + milliseconds);
+            ctx.getTimerService().createTimer(
+                    milliseconds, "Hello World");
+        }
+    }
+
+    private static void sleep(final long millis) {
+        try {
+            Thread.sleep(millis);
+        } catch (InterruptedException e) {
+            // ignore
+        }
+    }
+}

Deleted: branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/unit/OverloadTimerServiceTestCase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/unit/OverloadTimerServiceTestCase.java	2012-02-09 12:35:24 UTC (rev 112630)
+++ branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/unit/OverloadTimerServiceTestCase.java	2012-02-29 05:21:36 UTC (rev 112711)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright (c) 2012, Red Hat, Inc., 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.test.ejb3.jbpapp8035.unit;
-
-import junit.framework.Test;
-import org.jboss.test.ejb3.common.EJB3TestCase;
-import org.jboss.test.ejb3.jbpapp8035.TimerSample;
-
-/**
- * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
- */
-public class OverloadTimerServiceTestCase extends EJB3TestCase {
-    private TimerSample bean;
-
-    public OverloadTimerServiceTestCase(String name) {
-        super(name);
-    }
-
-    public static Test suite() throws Exception {
-        return getDeploySetup(OverloadTimerServiceTestCase.class, "jbpapp8035.jar");
-    }
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-
-        bean = lookup("TimerSampleBean/remote", TimerSample.class);
-        bean.cancelAllTimers();
-        bean.resetCount();
-    }
-
-    public void testOverload() throws InterruptedException {
-        bean.scheduleTimers(1000, 1);
-        sleep(1000 * 100 / 50 + 1000);
-        int result = bean.getCount();
-        assertEquals(1000, result);
-    }
-}

Copied: branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/unit/OverloadTimerServiceTestCase.java (from rev 112630, branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/unit/OverloadTimerServiceTestCase.java)
===================================================================
--- branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/unit/OverloadTimerServiceTestCase.java	                        (rev 0)
+++ branches/JBPAPP_5_1_2_GA_JBPAPP-8231/testsuite/src/main/org/jboss/test/ejb3/jbpapp8035/unit/OverloadTimerServiceTestCase.java	2012-02-29 05:21:36 UTC (rev 112711)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (c) 2012, Red Hat, Inc., 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.test.ejb3.jbpapp8035.unit;
+
+import junit.framework.Test;
+import org.jboss.test.ejb3.common.EJB3TestCase;
+import org.jboss.test.ejb3.jbpapp8035.TimerSample;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class OverloadTimerServiceTestCase extends EJB3TestCase {
+    private TimerSample bean;
+
+    public OverloadTimerServiceTestCase(String name) {
+        super(name);
+    }
+
+    public static Test suite() throws Exception {
+        return getDeploySetup(OverloadTimerServiceTestCase.class, "jbpapp8035.jar");
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        bean = lookup("TimerSampleBean/remote", TimerSample.class);
+        bean.cancelAllTimers();
+        bean.resetCount();
+    }
+
+    public void testOverload() throws InterruptedException {
+        bean.scheduleTimers(1000, 1);
+        sleep(1000 * 100 / 50 + 1000);
+        int result = bean.getCount();
+        assertEquals(1000, result);
+    }
+}



More information about the jboss-cvs-commits mailing list