Package javax.ejb

Examples of javax.ejb.Timer


    public boolean stopSnapshot() {
        Collection<Timer> timers = timer.getTimers();
        // stop all timers
        boolean cancelled = false;
        for(Iterator<Timer> it = timers.iterator(); it.hasNext(); ) {
            Timer t = it.next();
            t.cancel();
            cancelled = true;
            log.info("Stopped snapshot timer...");
        }
        return cancelled;
    }
View Full Code Here


        }
    }

    @Test
    public void testNotAllowed() throws Exception {
        final Timer timer = mock(Timer.class);
        try {
            ((StatelessContainer) container("jboss.j2ee:service=EJB3,name=FakedTimerBean2")).callTimeout(timer);
            fail("Should not have been allowed");
        } catch (EJBAccessException e) {
            // good
View Full Code Here

        }
    }

    @Test
    public void testTimeout() throws Exception {
        final Timer timer = mock(Timer.class);
        ((StatelessContainer) container("jboss.j2ee:service=EJB3,name=FakedTimerBean")).callTimeout(timer);
    }
View Full Code Here

        timerConfig.setInfo(INFO_MSG_FOR_CHECK);
       
        AnnotationTimerServiceBean bean1 = (AnnotationTimerServiceBean) ctx.lookup("java:module/" + AnnotationTimerServiceBean.class.getSimpleName());
        bean1.resetTimerServiceCalled();
        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());
        bean2.resetTimerServiceCalled();
        Assert.assertTrue(TimedObjectTimerServiceBean.awaitTimerCall());
        timer2.cancel();
    }
View Full Code Here

  }

  @Override
  public void cancelScheduling() {
    for (Object currentTimer : timerService.getTimers()) {
      Timer timer = (Timer) currentTimer;
      log.info("Cancel Timer ...." + timer.getInfo());
      timer.cancel();
    }
  }
View Full Code Here

    public boolean stopSnapshot() {
        Collection<Timer> timers = timer.getTimers();
        // stop all timers
        boolean cancelled = false;
        for(Iterator<Timer> it = timers.iterator(); it.hasNext(); ) {
            Timer t = it.next();
            t.cancel();
            cancelled = true;
            log.info("Stopped snapshot timer...");
        }
        return cancelled;
    }
View Full Code Here

   }

   @Override
   public Object invoke(Invocation invocation) throws Throwable
   {
      final Timer timer = getTimer(invocation);
      if (timer == null)
         throw new IllegalStateException("EJBTHREE-2035: timer not set on invocation");
      if (timer instanceof Synchronization)
      {
         final Transaction tx = getTransaction();
View Full Code Here

        }
        EjbTimerService timerService = beanContext.getEjbTimerService();
        if (timerService == null) {
            throw new NoSuchObjectLocalException("Deployment no longer supports ejbTimout " + deploymentId + ". Has this ejb been redeployed?");
        }
        Timer timer = timerService.getTimer(id);
        if (timer == null) {
            throw new NoSuchObjectLocalException("Timer not found for ejb " + deploymentId);
        }
        return timer;
    }
View Full Code Here

     *
     * @param timerData the timer to call.
     */
    public void ejbTimeout(TimerData timerData) {
        try {
            Timer timer = getTimer(timerData.getId());
            if (timer == null) {
                return;
            }
            for (int tries = 0; tries < (1 + retryAttempts); tries++) {
                boolean retry = false;
View Full Code Here

                    addTimer(30 * 1000, timerInfo);
              }
              // Reschedule timer
                IWorker worker = null;
              if (serviceInterval != IInterval.DONT_EXECUTE) {
                  Timer nextTrigger = addTimer(serviceInterval * 1000, timerInfo);
                  try {
                      // Try to acquire lock / see if this node should run
                      worker = serviceSession.getWorkerIfItShouldRun(timerInfo, nextTrigger.getNextTimeout().getTime());
                  } catch (Throwable t) {
                        if (log.isDebugEnabled()) {
                            log.debug("Exception: ", t)// Don't spam log with stacktraces in normal production cases
                        }
                  }
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.