Пример #1
0
  @Override
  public synchronized void start(final StartContext context) throws StartException {

    logger.debug("Starting timerservice for timedObjectId: " + getInvoker().getTimedObjectId());
    final EJBComponent component = ejbComponentInjectedValue.getValue();
    this.transactionManager = component.getTransactionManager();
    this.tsr = component.getTransactionSynchronizationRegistry();
    final TimedObjectInvoker invoker = timedObjectInvoker.getValue();
    if (invoker == null) {
      throw MESSAGES.invokerIsNull();
    }
    final List<ScheduleTimer> timers = new ArrayList<ScheduleTimer>();

    for (Map.Entry<Method, List<AutoTimer>> entry : autoTimers.entrySet()) {
      for (AutoTimer timer : entry.getValue()) {
        timers.add(
            new ScheduleTimer(
                entry.getKey(), timer.getScheduleExpression(), timer.getTimerConfig()));
      }
    }
    // restore the timers
    started = true;
    restoreTimers(timers);
    // register ourselves to the TimerServiceRegistry (if any)
    if (timerServiceRegistry != null) {
      timerServiceRegistry.registerTimerService(this);
    }
  }
Пример #2
0
 public synchronized void activate() {
   final List<ScheduleTimer> timers = new ArrayList<ScheduleTimer>();
   for (Map.Entry<Method, List<AutoTimer>> entry : autoTimers.entrySet()) {
     for (AutoTimer timer : entry.getValue()) {
       timers.add(
           new ScheduleTimer(
               entry.getKey(), timer.getScheduleExpression(), timer.getTimerConfig()));
     }
   }
   // restore the timers
   restoreTimers(timers);
 }