I am writing business logic for a web application in which web tier is done using
JSF. My business logic is pretty much independent of UI aspects.
In few of my logic classes an error message bundle object is defined as:
/** The error message bundle object */
private static final AppResourceBundleUtil ERROR_MSG_RESOURCE_BUNDLE
= new AppResourceBundleUtil ( AppLogicConstants.APP_ERRORS );
Where AppResourceBundleUtil's construtor loads the resource bundle and this class has a method to access a message by key name.
My understanding is if I code this way then there will be many instances of AppResourceBundleUtil since they are static.
My confusion is should I define this object as
public static final AppResourceBundleUtil ERROR_MSG_RESOURCE_BUNDLE in one utility class so that single instance is used in all the classes.
OR
Should I define as non static member in every class where I intend to use it :
private final AppResourceBundleUtil ERROR_MSG_RESOURCE_BUNDLE
Which would be better approach?
TIA,
Sachin