Package javax.ejb

Examples of javax.ejb.Timer


   public void testSingleEventExpire() throws Exception
   {
      TimedMockObject to = new TimedMockObject();
      TimerService service = createTimerService(to);

      Timer timer = service.createTimer(new Date(System.currentTimeMillis() + 500), null);
      assertEquals("Expected one txtimer", 1, service.getTimers().size());
      timer.cancel();
      sleep(1000);
      assertEquals("TimedObject called", 0, to.getCallCount());
      assertEquals("Expected no txtimer", 0, service.getTimers().size());
   }
View Full Code Here


   public void testMultipleEventDuration() throws Exception
   {
      TimedMockObject to = new CancelTimedMockObject();
      TimerService service = createTimerService(to);

      Timer timer = service.createTimer(500, 1000, null);
      assertEquals("Expected one txtimer", 1, service.getTimers().size());
      sleep(2000);
      assertEquals("TimedObject not called", 1, to.getCallCount());
      assertEquals("Expected no txtimer", 0, service.getTimers().size());
   }
View Full Code Here

   public void testMultipleEventExpire() throws Exception
   {
      TimedMockObject to = new CancelTimedMockObject();
      TimerService service = createTimerService(to);

      Timer timer = service.createTimer(new Date(System.currentTimeMillis() + 500), 500, null);
      assertEquals("Expected one txtimer", 1, service.getTimers().size());
      sleep(2000);
      assertEquals("TimedObject not called", 1, to.getCallCount());
      assertEquals("Expected no txtimer", 0, service.getTimers().size());
   }
View Full Code Here

   {
      Collection timers = context.getTimerService().getTimers();
      String s = "Timers: ";
      for (Iterator it = timers.iterator();it.hasNext();)
      {
         Timer t = (Timer)it.next();           
         s = s + t.toString() + " ";
         try
         {
            s += t.getInfo();
         }
         catch (Exception ignore)
         {
            // empty
         }
View Full Code Here

   private void cancelTimers()
   {
      Collection timers = context.getTimerService().getTimers();
      for (Iterator it = timers.iterator(); it.hasNext(); )
      {
         Timer t = (Timer)it.next();
         log.info("Cancelling timer " + t + " " + t.getInfo());
         t.cancel();
         log.info("Timer is now " + t);
      }  
   }
View Full Code Here

   {
      TimerService timerService = context.getTimerService();
      if (timerService.getTimers().isEmpty())
         throw new EJBException("There are no timers");

      Timer timer = (Timer)timerService.getTimers().iterator().next();
      timer.cancel();
   }
View Full Code Here

    * @ejb.interface-method view-type="both"
    **/
   public Object createTimerReturnHandle(long duration)
   {
      TimerService timerService = context.getTimerService();
      Timer timer = timerService.createTimer(duration, null);
      return timer.getHandle();
   }
View Full Code Here

      ArrayList handles = new ArrayList();
      Iterator it = timerService.getTimers().iterator();
      while (it.hasNext())
      {
         Timer timer = (Timer) it.next();
         handles.add(timer.getHandle().toString());
      }
      return handles;
   }
View Full Code Here

   {
      TimerService timerService = context.getTimerService();
      if (timerService.getTimers().isEmpty())
         throw new EJBException("There are no timers");

      Timer timer = (Timer)timerService.getTimers().iterator().next();
      timer.cancel();
   }
View Full Code Here

    * @ejb.interface-method view-type="both"
    **/
   public Object createTimerReturnHandle(long duration)
   {
      TimerService timerService = context.getTimerService();
      Timer timer = timerService.createTimer(duration, null);
      return timer.getHandle();
   }
View Full Code Here

TOP

Related Classes of javax.ejb.Timer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.