Pranav wrote:
Thanks for the reply.
So, for a scalability, you suggest that I should change TextProvider 
implementation to load a resource bundle for each customer. I don't exactly 
know how to tell it to load a customer specific resource bundle. I mean which 
methods to override for doing this. And also how to associate this custom 
TextProvider to my BaseActionSupport class.

Second question first: Take a look at the code for ActionSupport. You'll see it creates a TextProvider instance and all the getText(...) methods delegate to it. Your base action should create your own alternative TextSupport instance.

First question:
The Default TextProvider in Struts2 uses XWork's LocalizedTextUtils to search for resource bundles based on the classname and locale. It's designed for flexibility and tries every imaginable combination of class name, interfaces and package name as the baseName for the bundle (eg. actionName.properties, interfaceName.properties, packageName.properties etc etc etc). For each attempt, it eventually calls java.util.ResourceBundle.getBundle(baseName, Locale, ClassLoader).

Your customized TextProvider would use it's own baseName algorithm like:
 customerKey-packageName
 packageName

and call ResourceBundle.getBundle(baseName, Locale, ClassLoader). Have a look at the source of the DefaultTextProvider as a guide.

Instead of duplicating every key for each new customer, I would attempt to load two resource bundles - the default, and then the custom-specific resource bundle to overrides just the necessary properties (or delegate to the DefaultTextProvider if not custom bundle was found)

If you're using Spring, you'll find it has some good tools for managing/finding resource bundles.

regards,
Jeromy Evans


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to