|
From: Colin S. <col...@ex...> - 2004-12-05 20:56:52
|
I'm thinking of the best strategy for making the locale available to the MessageSourceAccessor, as per SPR-485: http://opensource.atlassian.com/projects/spring/browse/SPR-485 This would probably be a TheadLocal that the locale is bound to. The question is what the best strategy to do this is. I suppose DispatcherServlet could just bind the locale to a threadlocal, using the configured LocaleResolver, before dispatching. The problem here is that it won't pick up a changed locale as a result of a setLocale call on the localeresolver by the web code. Alternately, a ControllerInterceptor would have the same limitation, and would also have to be configured in front of every controller. What I am thinking would perhaps work though is something like a new Interface called LocaleAccessor. The implementation would be a JavaBean, and would be bound to the thread by the dispatcher. What it would hold would be both the Servlet Request, and also the LocaleResolver. When asked to get the Locale, it would be able to use the normal localeresolver, since it would also have the request. The whole point of this is so that non-view layer code can have access to locale resolution, in a similar fashion to view layer code. Can anybody think of a better mechanism? Colin |