Jersey (javax.ws.rs): how to do initialisation at page level ONLY not at application level

27 Views Asked by At

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.

0

There are 0 best solutions below