Ejemplo n.º 1
0
 private void flushClass(final Class<?> actionClass) {
   Map<ActionID, ScheduledActionTask> scheduledActionsToFlush = null;
   synchronized (scheduledActions) {
     scheduledActionsToFlush = new ConcurrentHashMap<ActionID, ScheduledActionTask>();
     Iterator<Entry<ActionID, ScheduledActionTask>> it = scheduledActions.entrySet().iterator();
     while (it.hasNext()) {
       final Entry<ActionID, ScheduledActionTask> entry = it.next();
       if (entry
           .getValue()
           .getAlarmHandler()
           .getScheduledAction()
           .getClass()
           .equals(actionClass)) {
         scheduledActionsToFlush.put(entry.getKey(), entry.getValue());
         it.remove();
       }
     }
     this.count_pending -= scheduledActionsToFlush.size();
   }
   for (ScheduledActionTask task : scheduledActionsToFlush.values()) {
     task.cancel();
     AlarmHandler alarmHandler = task.getAlarmHandler();
     if (isAllowed(alarmHandler)) {
       alarmHandler.setStatus(EActionStatus.FORCED);
       execute(alarmHandler);
     }
   }
 }
Ejemplo n.º 2
0
 @Override
 public boolean cancel() {
   String reason =
       alarmHandler.getReason().isEmpty()
           ? "the timer has been canceled"
           : alarmHandler.getReason();
   Activator.getLogger()
       .log(Level.INFO, "CANCEL " + alarmHandler.getInfos() + " because " + reason);
   alarmHandler.setStatus(EActionStatus.CANCELED);
   return super.cancel();
 }
Ejemplo n.º 3
0
 @Override
 public void run() {
   if (alarmHandler.getStatus().equals(EActionStatus.PENDING)
       || alarmHandler.getStatus().equals(EActionStatus.FORCED)) {
     if (alarmHandler.getStatus().equals(EActionStatus.PENDING))
       alarmHandler.setStatus(EActionStatus.EXECUTED);
     execute(alarmHandler);
   } else {
     if (debug) AlarmNotifierHistory.getInstance().addAction(alarmHandler);
     Activator.getLogger()
         .log(
             Level.INFO,
             "CANCEL " + alarmHandler.getInfos() + " because " + alarmHandler.getReason());
   }
   remove(this.alarmHandler);
 }