I have a non-web project and I'm going to turn it into a web project using Spring MVC.
Today in my method static main
of my main class, I create this here:
Exec.principalTimer = new Timer();
Exec.principalTimer.scheduleAtFixedRate(new PrincipalTimerTask(), Exec.delay, Exec.interval);
The class PrincipalTimerTask
is of type TimerTask
.
How do I create this Timer in Spring already in the project deployment, without having to call any url and leave it running there, as if it were a service if I do not have a public static main
in the Web container?
I can implement the WebApplicationInitializer interface and create TImer already within the onStartup method of it.
Here's where I got the idea link