Reputation: 2148
I have a class
@OnApplicationStart
public class OnStartManager extends Job{
private DataGridServiceManager dataGridServiceManager = null;
@Override
public void doJob() {
dataGridServiceManager = DataGridServiceManagerImpl.getInstance();
}
}
This is executing when the application starts, but it also executes when i access other pages or even the same page. But i want to execute it only once during the start of the application. What should i do to achieve this.
Upvotes: 1
Views: 1117
Reputation: 1077
I do processing of some information and storing before my index.html
loads. I used the @OnApplicationStart
tag for my bootstrap.java
file. It works without a sweat.
Upvotes: 0
Reputation: 8608
If you are running in DEV mode, Play sometimes automatically restarts the application. This will cause the @OnApplicationStart
jobs to be rerun as well. Maybe this is what you are experiencing?
Quote from Jobs section of Play documentation:
When you run the application in DEV mode, the application waits for the first HTTP request to start. Moreover when you are in DEV mode, the application will sometimes automatically restart when needed.
Upvotes: 4