Managing string resources in a Java application - singleton?
- by Joe Attardi
I seek a solution to the age-old problem of managing string resources. My current implementation seems to work well, but it depends on using singletons, and I know how often singletons can be maligned.
The resource manager class has a singleton instance that handles lookups in the ResourceBundle, and you use it like so:
MessageResources mr = MessageResources.getMessageResources(); // returns singleton instance
...
JLabel helloLabel = new JLabel(mr.getString("label.hello"));
Is this an appropriate use of a singleton? Is there some better, more universally used approach that I'm not aware of?
I understand that this is probably a bit subjective, but any feedback I can get would be appreciated. I'd rather find out early on that I'm doing it wrong than later on in the process.
Thanks!