| java.lang.Object org.springframework.context.i18n.LocaleContextHolder
LocaleContextHolder | abstract public class LocaleContextHolder (Code) | | Simple holder class that associates a LocaleContext instance
with the current thread. The LocaleContext will be inherited
by any child threads spawned by the current thread.
Used as a central holder for the current Locale in Spring,
wherever necessary: for example, in MessageSourceAccessor.
DispatcherServlet automatically exposes its current Locale here.
Other applications can expose theirs too, to make classes like
MessageSourceAccessor automatically use that Locale.
author: Juergen Hoeller since: 1.2 See Also: LocaleContext See Also: org.springframework.context.support.MessageSourceAccessor See Also: org.springframework.web.servlet.DispatcherServlet |
Method Summary | |
public static Locale | getLocale() Return the Locale associated with the current thread, if any,
or the system default Locale else. | public static LocaleContext | getLocaleContext() Return the LocaleContext associated with the current thread, if any. | public static void | resetLocaleContext() Reset the LocaleContext for the current thread. | public static void | setLocale(Locale locale) Associate the given Locale with the current thread. | public static void | setLocale(Locale locale, boolean inheritable) Associate the given Locale with the current thread. | public static void | setLocaleContext(LocaleContext localeContext) Associate the given LocaleContext with the current thread,
not exposing it as inheritable for child threads. | public static void | setLocaleContext(LocaleContext localeContext, boolean inheritable) Associate the given LocaleContext with the current thread. |
getLocale | public static Locale getLocale()(Code) | | Return the Locale associated with the current thread, if any,
or the system default Locale else.
the current Locale, or the system default Locale if nospecific Locale has been associated with the current thread See Also: LocaleContext.getLocale See Also: java.util.Locale.getDefault |
getLocaleContext | public static LocaleContext getLocaleContext()(Code) | | Return the LocaleContext associated with the current thread, if any.
the current LocaleContext, or null if none |
resetLocaleContext | public static void resetLocaleContext()(Code) | | Reset the LocaleContext for the current thread.
|
setLocale | public static void setLocale(Locale locale)(Code) | | Associate the given Locale with the current thread.
Will implicitly create a LocaleContext for the given Locale,
not exposing it as inheritable for child threads.
Parameters: locale - the current Locale, or null to resetthe thread-bound context See Also: SimpleLocaleContext.SimpleLocaleContext(java.util.Locale) |
setLocaleContext | public static void setLocaleContext(LocaleContext localeContext)(Code) | | Associate the given LocaleContext with the current thread,
not exposing it as inheritable for child threads.
Parameters: localeContext - the current LocaleContext, or null to resetthe thread-bound context |
setLocaleContext | public static void setLocaleContext(LocaleContext localeContext, boolean inheritable)(Code) | | Associate the given LocaleContext with the current thread.
Parameters: localeContext - the current LocaleContext, or null to resetthe thread-bound context Parameters: inheritable - whether to expose the LocaleContext as inheritablefor child threads (using an java.lang.InheritableThreadLocal) |
|
|