Package javax.ejb

Examples of javax.ejb.Timer.cancel()


      Timer timer = service.createTimer(new Date(System.currentTimeMillis() + 500), 500, null);
      assertEquals("Expected one txtimer", 1, service.getTimers().size());
      sleep(2000);
      assertTrue("TimedObject not called enough", 1 < to.getCallCount());

      timer.cancel();
      assertEquals("Expected no txtimer", 0, service.getTimers().size());
   }

}
View Full Code Here


   public void testTimerSerialization() throws Exception
   {
      TimedMockObject to = new TimedMockObject();
      TimerService service = createTimerService(to);
      Timer timer = service.createTimer(500, null);
      timer.cancel();

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(baos);
      try
      {
View Full Code Here

      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

      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

      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();
   }

   /**
    * This is not allowed on the remote interface.
    * @ejb.interface-method view-type="both"
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();
   }

   /**
    * This is not allowed on the remote interface.
    * @ejb.interface-method view-type="both"
View Full Code Here

    * @ejb:interface-method view-type="remote"
    **/
   public void stopTimer(byte[] handle)
   {
      Timer timer = getTimer(handle);
      timer.cancel();
      log.info("TimerSLSBean.stopTimer(), create a timer: "+timer);
      synchronized( TimerSLSBean.class )
      {
         Long key = getKey(handle);
         timeoutCounts.remove(key);
View Full Code Here

        long ts = (new Date()).getTime() + TIMER_INIT_TIME_MS;
        Timer timer1 = bean1.getTimerService().createIntervalTimer(new Date(ts), TIMER_TIMEOUT_TIME_MS, timerConfig);
        Assert.assertTrue(AnnotationTimerServiceBean.awaitTimerCall());
        bean1.resetTimerServiceCalled();
        Assert.assertTrue(AnnotationTimerServiceBean.awaitTimerCall());
        timer1.cancel();

        TimedObjectTimerServiceBean bean2 = (TimedObjectTimerServiceBean) ctx.lookup("java:module/" + TimedObjectTimerServiceBean.class.getSimpleName());
        bean2.resetTimerServiceCalled();
        Timer timer2 = bean2.getTimerService().createIntervalTimer(TIMER_INIT_TIME_MS, TIMER_TIMEOUT_TIME_MS, timerConfig);
        Assert.assertTrue(TimedObjectTimerServiceBean.awaitTimerCall());
View Full Code Here

        bean2.resetTimerServiceCalled();
        Timer timer2 = bean2.getTimerService().createIntervalTimer(TIMER_INIT_TIME_MS, TIMER_TIMEOUT_TIME_MS, timerConfig);
        Assert.assertTrue(TimedObjectTimerServiceBean.awaitTimerCall());
        bean2.resetTimerServiceCalled();
        Assert.assertTrue(TimedObjectTimerServiceBean.awaitTimerCall());
        timer2.cancel();
    }

}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.