From: Trevor C. <tc...@in...> - 2003-02-22 16:30:01
|
Naming - I agree that LocaleHandler is confusing. I like LocaleResolver, since it is consistent with the the ViewResolver classes. Interface - really good, but I don't think it's necessary to have locale as a parameter of setLocale, since that method will be determining the actual locale. What value be passed by the ControllerServlet for this parameter? Maybe it would be less confusing to make the signature: Locale resolveLocale(HttpServletRequest request, HttpServletResponse response); The signature now makes it clear that we are not "setting it" so much as asking the method to determine how it should be set. It also matches the viewResolver usage. An additional "setLocale" method with the signature you provided: void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale); could be used to explicitly override the Locale determined by the resolveLocale method. This would benefit Controller specific overrides (addressed below). As you noted, the response is necessary for cookie-based implementations (good catch). Configuration - I think that loading it as a bean reference (like "viewResolver") makes the most sense. If we provide an access method, this would allow individual Controllers to get a reference to the resolver and override the locale using the setLocale method mentioned above. I think the ControllerServlet should handle the locale resolution rather than a "LocaleHandler-per-Controller". If someone needs "normal" locale handling, I think the per-Controller method would require too much cut-n-paste type code. However, the exposed setLocale method would allow those who need to set it on a per-Controller basis the ability to do so. DefaultImplementation - I think "ClientLocaleHandler" is too general, since all LocaleHandlers (or LocaleResolvers as I prefer :) ) are making decisions based on the client. The default will be using the servlets default mechanism, so maybe "ServletLocaleResolver" or "RequestLocaleResolver" (although again, too me they're too general - I can't think of a really good name). We should also create additional implementations for distribution such as the cookie and session based versions, rather than requiring each client to code one themselves (although they will have the oppurtunity to do so). Great analysis Juergen! Trevor D. Cook --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.456 / Virus Database: 256 - Release Date: 2/18/03 |