Hi all, I have an xls file which has few records in it. There is a link which requests all the records in the file. I am planning to write a repository class which reads and loads the xls file. A service layer which sorts the list. In the controller I want to annotate a method with @PostConstruct which will make the service call and the service will call the repository to load and read the entire file. Whenever a request comes to the controller the list is returned. I will cache the method in the controller also. Is this a good approach?
Or should I load and read the file on the first request to the controller and then cache the result?
Your not going to get an exception until you try and access the resource in some way. Wherever you do this you can choose to catch and handle the exceptions.
After looking at this again you can probably just do something like below. It still uses the resource abstraction to read the file in but there is probably not anything to be gained by @Autowiring in the Resource, since you are most likely going to want to access it in some special format (you are probably using some library for reading an XLS)
In this example I am just using a String but gives you the idea.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com