I have a Java Servlet. When the Servlet is called I would like to execute a command and call a method, that uses a Scheduler.
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Scheduler s = new Scheduler();
s.doStuff();
.
package xy;
import javax.ejb.Schedule;
import javax.ejb.Singleton;
@Singleton
public class Scheduler {
private int counter = 0;
@Schedule(second = "*/5", minute = "*", hour = "*", info="Every 5 seconds")
public void doStuff(){
counter++;
System.out.println("counter: " +counter);
}
}
Following my logic, every 5 seconds I should see a counter println getting higher and higher. But nothing happens.
Aucun commentaire:
Enregistrer un commentaire