0

I need to do a lot of initialisation for few pages when they are called for only first time. Here is a decent post that addresses this: Initialize database on Jersey webapp startup

But the problem with the above approach is that the initialisation is done at application level which I don't want. I am not sure if and when a particular page will be called and so I want to go with initialisation only when the page is called for the first time.

Any thoughts on how to achieve this when using jersey. (Spring has @PostConstruct and @PreDestroy for this purpose at controller/page level... so some thing similar is what I need). A small example or code will help greatly.

samshers
  • 1
  • 6
  • 37
  • 84
  • 1
    Jersey 1.x and 2.x have different capabilities. Please choose the correct tag for the version you actually intend to use. And why the spring-jersey tag? Are you actually integrating Spring with Jersey? – Paul Samsotha Nov 26 '17 at 22:08
  • Right, I am using both 1.x and 2.x on separate projects plus I will integrate with spring – samshers Nov 27 '17 at 03:55
  • If you are integrating Spring and it is handling the lifecycle of your resources, then the Spring annotations you mentioned should work as desired. – Paul Samsotha Nov 27 '17 at 04:05

0 Answers0