Managing string resources in a Java application - singleton?

Posted by Joe Attardi on Stack Overflow See other posts from Stack Overflow or by Joe Attardi
Published on 2010-03-31T05:20:26Z Indexed on 2010/03/31 5:23 UTC
Read the original article Hit count: 330

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!

© Stack Overflow or respective owner

Related posts about java

Related posts about swing