0

This may be a theoretical question rather than a code question.

I started work on a spring webMVC REST API. I have a very specific requirement. I have some file system resource ( text file, markdown file). I want to read those resources and kept them in memory for faster access ( The number of resources are small so I can keep them in memory). I will planning to implement some watch event mechanism if any files changes than reload the resources.

  1. My Question is what is the best way in spring to achieve this ( By this I mean read resources during application context start ). I want to define The configuration object as a bean which would be passed to REST controllers.

I was reading the spring docs and I am thinking about implementing this as singleton configuration bean and pass that bean to all controllers. Whenever file system changes I have to reload the bean. Is this a good solution?

  1. There are so many possible options to initialize something during application context start this SO question has plenty of answers and I can adopt any solution, But I want to know what would be the best approach considering my specific requirement.

The solution should be easily scalable and modular in nature.

Community
  • 1
  • 1
Syed
  • 1,461
  • 3
  • 19
  • 37
  • Spring 4.1 has an extended resource mechanism which can do this for you. Why reinvent the wheel? – M. Deinum Jan 20 '15 at 12:55
  • @M.Deinum My intention was not to reinvent the wheel. I am trying to identify the best possible solution. Can you explain with an example ? – Syed Jan 20 '15 at 13:03

0 Answers0