I’m creating a web service in java which provides facility to give information regarding a entities, for this I’m planning to build a cache which holds all the information and give the client whatever information he/she needs from the cache. So I have to build the cache only once when the webservice starts not on each client request.
My question is where should I build the cache?
Whatever I have read regarding it says for each client call the constructor is called so where should I add the cache building functionality or some other alternative.
One of the answer I found is to use @stateless to solve this problem.
TechExchange provided a good solution to my problem but as I needed a solution which can be used with the existing soap based webservice which I have created I did created a bean which builds a cache and injected it using spring injection at the start of the webservice so this bean will build the cache and this can be used by the cleints on all the request.