Ok, so here's what I intend to prototype. Please let me know if this will work or not.
1) Define a message resource properties file like this: cust1.welcome.user = I want to live. cust2.welcome.user = I will not let you live. welcome.user = Welcome user cust1.bye = Go live bye = Good bye hello = Hello How are you? 2) As you can see above, some of the standard message keys are prefixed for 2 diff customers while other keys are not prefixed by both of them. There are still others which are same for all end users so they are not prefixed at all. 3) The instance is shared between multiple customers. Each customer has several end users. When an end user logs in then there is an attribute stored in the session identifying the customer on behalf of which the end user is logging in. E.g. user1 is logging on behalf of cust1 while user2 is logging on behalf of cust2. 4) Extend ActionSupport in MyBaseActionSupport such that all the getText methods are overridden. I will also make this class as SessionAware. Each of these methods lookup the session for the customer identifier and if it is found, try to lookup the messageresouces properties file with the <custid>+key instead of just key. If the value is not found then it will lookup using just the key for the default value, which is going to be there all the time as a fallback mechanism. In future, if a new customer is added then operations can simply override one or more values in the messageresouce files (for all locales) and the code logic would not have to change. After I successfully prototype this solution, I would move on to the more complex solution where you suggested to override TextProvider implmentation and provide a separate messageresouces files for each individual customer. What do you think? Any comments or warnings would be highly appreciated. Also, if you can also guide me as to how to enable hot-deploy of messageresouces properties file on JBoss it would be great. Thanks Pranav ----- Original Message ---- From: Jeromy Evans <[EMAIL PROTECTED]> To: Struts Users Mailing List <user@struts.apache.org> Sent: Sunday, April 20, 2008 11:36:21 PM Subject: Re: Intenationalization questions 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] ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]