Паттерн: Шаблонный метод (Template Method)
Фрагмент: RequestProcessor.processLocale() [java]
  1. protected void processLocale(HttpServletRequest request,
  2. HttpServletResponse response) {
  3. // Are we configured to select the Locale automatically?
  4. if (!moduleConfig.getControllerConfig().getLocale()) {
  5. return;
  6. }
  7.  
  8. // Has a Locale already been selected?
  9. HttpSession session = request.getSession();
  10.  
  11. if (session.getAttribute(Globals.LOCALE_KEY) != null) {
  12. return;
  13. }
  14.  
  15. // Use the Locale returned by the servlet container (if any)
  16. Locale locale = request.getLocale();
  17.  
  18. if (locale != null) {
  19. if (log.isDebugEnabled()) {
  20. log.debug(" Setting user locale '" + locale + "'");
  21. }
  22.  
  23. session.setAttribute(Globals.LOCALE_KEY, locale);
  24. }
  25. }