From 66b4499973de089fea8bebd71b484bbdfda0b2ac Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 6 Sep 2010 21:20:03 +0000 Subject: [PATCH] polishing --- .../web/portlet/HandlerExceptionResolver.java | 8 ++++--- .../web/servlet/DispatcherServlet.java | 24 ++++++++++--------- .../web/servlet/HandlerExceptionResolver.java | 10 ++++---- ...otationMethodHandlerExceptionResolver.java | 6 ++--- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/HandlerExceptionResolver.java b/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/HandlerExceptionResolver.java index d2efc4484dd..c5d820aca00 100644 --- a/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/HandlerExceptionResolver.java +++ b/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/HandlerExceptionResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,8 @@ public interface HandlerExceptionResolver { * @param handler the executed handler, or null if none chosen at the time of * the exception (for example, if multipart resolution failed) * @param ex the exception that got thrown during handler execution - * @return a corresponding ModelAndView to forward to, or null for default processing + * @return a corresponding ModelAndView to forward to, + * or null for default processing */ ModelAndView resolveException( RenderRequest request, RenderResponse response, Object handler, Exception ex); @@ -57,7 +58,8 @@ public interface HandlerExceptionResolver { * @param handler the executed handler, or null if none chosen at the time of * the exception (for example, if multipart resolution failed) * @param ex the exception that got thrown during handler execution - * @return a corresponding ModelAndView to forward to, or null for default processing + * @return a corresponding ModelAndView to forward to, + * or null for default processing */ ModelAndView resolveException( ResourceRequest request, ResourceResponse response, Object handler, Exception ex); diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/DispatcherServlet.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/DispatcherServlet.java index 79728d51d55..dda747cb723 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/DispatcherServlet.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/DispatcherServlet.java @@ -137,39 +137,41 @@ public class DispatcherServlet extends FrameworkServlet { public static final String THEME_RESOLVER_BEAN_NAME = "themeResolver"; /** - * Well-known name for the HandlerMapping object in the bean factory for this namespace. Only used when - * "detectAllHandlerMappings" is turned off. + * Well-known name for the HandlerMapping object in the bean factory for this namespace. + * Only used when "detectAllHandlerMappings" is turned off. * @see #setDetectAllHandlerMappings */ public static final String HANDLER_MAPPING_BEAN_NAME = "handlerMapping"; /** - * Well-known name for the HandlerAdapter object in the bean factory for this namespace. Only used when - * "detectAllHandlerAdapters" is turned off. + * Well-known name for the HandlerAdapter object in the bean factory for this namespace. + * Only used when "detectAllHandlerAdapters" is turned off. * @see #setDetectAllHandlerAdapters */ public static final String HANDLER_ADAPTER_BEAN_NAME = "handlerAdapter"; /** - * Well-known name for the HandlerExceptionResolver object in the bean factory for this namespace. Only used when - * "detectAllHandlerExceptionResolvers" is turned off. + * Well-known name for the HandlerExceptionResolver object in the bean factory for this namespace. + * Only used when "detectAllHandlerExceptionResolvers" is turned off. * @see #setDetectAllHandlerExceptionResolvers */ public static final String HANDLER_EXCEPTION_RESOLVER_BEAN_NAME = "handlerExceptionResolver"; - /** Well-known name for the RequestToViewNameTranslator object in the bean factory for this namespace. */ + /** + * Well-known name for the RequestToViewNameTranslator object in the bean factory for this namespace. + */ public static final String REQUEST_TO_VIEW_NAME_TRANSLATOR_BEAN_NAME = "viewNameTranslator"; /** - * Well-known name for the ViewResolver object in the bean factory for this namespace. Only used when - * "detectAllViewResolvers" is turned off. + * Well-known name for the ViewResolver object in the bean factory for this namespace. + * Only used when "detectAllViewResolvers" is turned off. * @see #setDetectAllViewResolvers */ public static final String VIEW_RESOLVER_BEAN_NAME = "viewResolver"; /** - * Request attribute to hold the current web application context. Otherwise only the global web app context is - * obtainable by tags etc. + * Request attribute to hold the current web application context. + * Otherwise only the global web app context is obtainable by tags etc. * @see org.springframework.web.servlet.support.RequestContextUtils#getWebApplicationContext */ public static final String WEB_APPLICATION_CONTEXT_ATTRIBUTE = DispatcherServlet.class.getName() + ".CONTEXT"; diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/HandlerExceptionResolver.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/HandlerExceptionResolver.java index e21e1b5f15a..dbdefe26f7b 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/HandlerExceptionResolver.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/HandlerExceptionResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,14 +36,16 @@ public interface HandlerExceptionResolver { /** * Try to resolve the given exception that got thrown during on handler execution, * returning a ModelAndView that represents a specific error page if appropriate. - *

The returned ModelAndView may be {@linkplain ModelAndView#isEmpty() empty} to indicate that the exception has - * been resolved successfully, but that no view should be rendered, for instance by setting a status code. + *

The returned ModelAndView may be {@linkplain ModelAndView#isEmpty() empty} + * to indicate that the exception has been resolved successfully but that no view + * should be rendered, for instance by setting a status code. * @param request current HTTP request * @param response current HTTP response * @param handler the executed handler, or null if none chosen at the * time of the exception (for example, if multipart resolution failed) * @param ex the exception that got thrown during handler execution - * @return a corresponding ModelAndView to forward to, or null for default processing + * @return a corresponding ModelAndView to forward to, + * or null for default processing */ ModelAndView resolveException( HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex); diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/annotation/AnnotationMethodHandlerExceptionResolver.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/annotation/AnnotationMethodHandlerExceptionResolver.java index e59ab38f6b5..be2c68c0ed5 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/annotation/AnnotationMethodHandlerExceptionResolver.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/annotation/AnnotationMethodHandlerExceptionResolver.java @@ -44,8 +44,8 @@ import org.springframework.core.MethodParameter; import org.springframework.core.annotation.AnnotationUtils; import org.springframework.http.HttpInputMessage; import org.springframework.http.HttpOutputMessage; -import org.springframework.http.MediaType; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.converter.ByteArrayHttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.StringHttpMessageConverter; @@ -400,9 +400,9 @@ public class AnnotationMethodHandlerExceptionResolver extends AbstractHandlerExc MediaType.sortByQualityValue(acceptedMediaTypes); HttpOutputMessage outputMessage = new ServletServerHttpResponse(webRequest.getResponse()); Class returnValueType = returnValue.getClass(); - if (messageConverters != null) { + if (this.messageConverters != null) { for (MediaType acceptedMediaType : acceptedMediaTypes) { - for (HttpMessageConverter messageConverter : messageConverters) { + for (HttpMessageConverter messageConverter : this.messageConverters) { if (messageConverter.canWrite(returnValueType, acceptedMediaType)) { messageConverter.write(returnValue, acceptedMediaType, outputMessage); return new ModelAndView();