开发者

@OnApplicationStart not working in Play framework

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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜