title: How does javax.ejb.TimerService know which bean to call?
body: <p>How does <a href="https://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html" rel="nofollow">javax.ejb.TimerService</a> (Glassfish 3.1.2.2) know which bean to execute?</p>
  
  <p>In the <a href="https://docs.oracle.com/javaee/6/tutorial/doc/bnboy.html" rel="nofollow">Java EE 6 tutorial</a> we learn that we can define timer callbacks in an enterprise bean:</p>
  
  <pre><code>@Timeout
  public void timeout(Timer timer) {
      System.out.println("TimerBean: timeout occurred");
  }
  </code></pre>
  
  <p>Then we can schedule programmatic timers like this:</p>
  
  <pre><code>@Resource
  TimerService timerService;
  ...
  // Sets a programmatic timer that will expire in 1 minute (6,000 milliseconds):
  long duration = 6000;
  Timer timer = timerService.createSingleActionTimer(duration, new TimerConfig());
  </code></pre>
  
  <p>How does the TimeService know which <em>bean</em> to call? There can only be one annotated method in the bean, but how does it know which bean to call? <code>this</code> is not a parameter of <code>createSingleActionTimer</code>.</p>