Disabling all graphs in Glassfish 3.1

How to disable all schedulers (@Schedule annotated) in a deploing project on Glassfish 3.1
Perhaps there are some configuration entries for this?
I have about 20 EJBs with schedulers in my project, and if I want to check / fix a small thing, I do not want all / some timers to start.

+5
source share
2 answers

Unfortunately, I don't know if there are any configuration entries to solve your problem, but there is a programmatic way to do this by calling the cancel () method on Timer -Objects TimerService .

, , :

@Stateless
public class ScheduleCancellation {

  @Resource
  private TimerService timerService;

  @Schedule(second = "0", minute = "*", hour = "*")
  public void cancelTimers() {
    System.out.println("cancelTimers()");
    for (Timer timer : timerService.getTimers()) {
      System.out.println("schedule gone!");
      timer.cancel();
    }
  }

  @Schedule(second = "*", minute = "*", hour = "*")
  public void tick() {
    System.out.println("tick");
  }
}

, !:)

+2

TimerService#getTimers() EJB. ( , : http://java.net/jira/browse/EJB_SPEC-47).

, Glassfish ( ). GlassFish, .

+2

All Articles