Паттерн: Шаблонный метод (Template Method)
Фрагмент: RequestProcessor.process() [java]
  1. public void process(HttpServletRequest request, HttpServletResponse response)
  2. throws IOException, ServletException {
  3. // Wrap multipart requests with a special wrapper
  4. request = processMultipart(request);
  5.  
  6. // Identify the path component we will use to select a mapping
  7. String path = processPath(request, response);
  8.  
  9. if (path == null) {
  10. return;
  11. }
  12.  
  13. if (log.isDebugEnabled()) {
  14. log.debug("Processing a '" + request.getMethod() + "' for path '"
  15. + path + "'");
  16. }
  17.  
  18. // Select a Locale for the current user if requested
  19. processLocale(request, response);
  20.  
  21. // Set the content type and no-caching headers if requested
  22. processContent(request, response);
  23. processNoCache(request, response);
  24.  
  25. // General purpose preprocessing hook
  26. if (!processPreprocess(request, response)) {
  27. return;
  28. }
  29.  
  30. this.processCachedMessages(request, response);
  31.  
  32. // Identify the mapping for this request
  33. ActionMapping mapping = processMapping(request, response, path);
  34.  
  35. if (mapping == null) {
  36. return;
  37. }
  38.  
  39. // Check for any role required to perform this action
  40. if (!processRoles(request, response, mapping)) {
  41. return;
  42. }
  43.  
  44. // Process any ActionForm bean related to this request
  45. ActionForm form = processActionForm(request, response, mapping);
  46.  
  47. processPopulate(request, response, form, mapping);
  48.  
  49. // Validate any fields of the ActionForm bean, if applicable
  50. try {
  51. if (!processValidate(request, response, form, mapping)) {
  52. return;
  53. }
  54. } catch (InvalidCancelException e) {
  55. ActionForward forward = processException(request, response, e, form, mapping);
  56. processForwardConfig(request, response, forward);
  57. return;
  58. } catch (IOException e) {
  59. throw e;
  60. } catch (ServletException e) {
  61. throw e;
  62. }
  63.  
  64. // Process a forward or include specified by this mapping
  65. if (!processForward(request, response, mapping)) {
  66. return;
  67. }
  68.  
  69. if (!processInclude(request, response, mapping)) {
  70. return;
  71. }
  72.  
  73. // Create or acquire the Action instance to process this request
  74. Action action = processActionCreate(request, response, mapping);
  75.  
  76. if (action == null) {
  77. return;
  78. }
  79.  
  80. // Call the Action instance itself
  81. ActionForward forward =
  82. processActionPerform(request, response, action, form, mapping);
  83.  
  84. // Process the returned ActionForward instance
  85. processForwardConfig(request, response, forward);
  86. }