Package javax.ejb

Examples of javax.ejb.TimerService


   }

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

      Timer timer = service.createTimer(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 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

   /**
    * @ejb.interface-method view-type="both"
    **/
   public void createTimer(long duration, long periode, Serializable info)
   {
      TimerService timerService = context.getTimerService();
      if (periode > 0)
         timerService.createTimer(duration, periode, info);
      else
         timerService.createTimer(duration, info);
   }
View Full Code Here

   /**
    * @ejb.interface-method view-type="both"
    **/
   public void cancelFirstTimer()
   {
      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

    * This is not allowed on the remote interface.
    * @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

   /**
    * @ejb.interface-method view-type="both"
    **/
   public List getTimers()
   {
      TimerService timerService = context.getTimerService();

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

   /**
    * @ejb.interface-method view-type="both"
    **/
   public void createTimer(long duration, long periode, Serializable info)
   {
      TimerService timerService = context.getTimerService();
      if (periode > 0)
         timerService.createTimer(duration, periode, info);
      else
         timerService.createTimer(duration, info);
   }
View Full Code Here

   /**
    * @ejb.interface-method view-type="both"
    **/
   public void cancelFirstTimer()
   {
      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

TOP

Related Classes of javax.ejb.TimerService

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.