Tuesday, October 21, 2008

ResourceBundleMessageSource vs ReloadableResourceBundleMessageSource

With the treatise submission roughly one week away, I wanted to post a small segment that people might find useful for their own work because the issue had me confused for some time.
It relates to the difference between ReloadableResourceBundleMessageSource and ResourceBundleMessageSource.

Firstly, due to the nature of server caching, the files can no longer be stored in the default classpath and as a result must be moved and the basenames property updated as in the snippet above. The second issue is less well known and careful scouring of the internet combined with a forum post on forums.springframework.org shed no light on the matter. Using a custom read/write of the properties files and the non-reloadable configuration it was possible to read in the file and then write out to the same file with whatever changes necessary. However, with the reloadable configuration the same process would result in the file being blank. This may have resulted from the way in which the server now handled the files in terms of regular caching. This would have been an application breaking issue as the ability to be able to edit and then have the server update these files is at the core of the project. It would be no good using a non-reloadable source but being able to update the files because the server would not render a different view unless it was restarted. Fortunately it was discovered that writing the updated properties file to a temp file and then back again was a method to overcome the issue.