Interface LocaleHandler

All Known Subinterfaces:
I18nInterceptor.LocaleHandler
All Known Implementing Classes:
AbstractLocaleHandler, AbstractStoredLocaleHandler, AcceptLanguageLocaleHandler, CookieLocaleHandler, I18nInterceptor.AcceptLanguageLocaleHandler, I18nInterceptor.CookieLocaleHandler, I18nInterceptor.LocaleHandlerAdapter, I18nInterceptor.RequestLocaleHandler, I18nInterceptor.SessionLocaleHandler, RequestLocaleHandler, SessionLocaleHandler

public interface LocaleHandler
Strategy used by I18nInterceptor to resolve and optionally persist the current request locale.

Implementations encapsulate locale source-specific behavior (request parameters, session, cookies, or Accept-Language header), while the interceptor orchestrates the overall lifecycle.

  • Method Summary

    Modifier and Type
    Method
    Description
    Looks for an explicit locale override in request-scoped sources.
    read(ActionInvocation invocation)
    Reads locale from persistent/context sources when find() did not resolve one.
    boolean
    Indicates if the locale should be persisted for the current request.
    store(ActionInvocation invocation, Locale locale)
    Persists the resolved locale when storage is enabled for the current handler.
  • Method Details

    • find

      Locale find()
      Looks for an explicit locale override in request-scoped sources.
      Returns:
      a locale override or null when no explicit override is present
    • read

      Locale read(ActionInvocation invocation)
      Reads locale from persistent/context sources when find() did not resolve one.
      Parameters:
      invocation - current action invocation
      Returns:
      resolved locale or null when no locale could be resolved
    • store

      Locale store(ActionInvocation invocation, Locale locale)
      Persists the resolved locale when storage is enabled for the current handler.
      Parameters:
      invocation - current action invocation
      locale - locale to store
      Returns:
      the effective locale to apply to the invocation context
    • shouldStore

      boolean shouldStore()
      Indicates if the locale should be persisted for the current request.
      Returns:
      true when store(ActionInvocation, Locale) should be invoked