polishing

This commit is contained in:
Juergen Hoeller 2010-03-31 15:36:35 +00:00
parent 6b93f41f3a
commit 461b488eee
2 changed files with 20 additions and 25 deletions

View File

@ -114,23 +114,26 @@ import org.springframework.web.util.UrlPathHelper;
import org.springframework.web.util.WebUtils;
/**
* Implementation of the {@link org.springframework.web.servlet.HandlerAdapter} interface that maps handler methods
* based on HTTP paths, HTTP methods and request parameters expressed through the {@link RequestMapping} annotation.
* Implementation of the {@link org.springframework.web.servlet.HandlerAdapter} interface
* that maps handler methods based on HTTP paths, HTTP methods and request parameters
* expressed through the {@link RequestMapping} annotation.
*
* <p>Supports request parameter binding through the {@link RequestParam} annotation. Also supports the {@link
* ModelAttribute} annotation for exposing model attribute values to the view, as well as {@link InitBinder} for binder
* initialization methods and {@link SessionAttributes} for automatic session management of specific attributes.
* <p>Supports request parameter binding through the {@link RequestParam} annotation.
* Also supports the {@link ModelAttribute} annotation for exposing model attribute
* values to the view, as well as {@link InitBinder} for binder initialization methods
* and {@link SessionAttributes} for automatic session management of specific attributes.
*
* <p>This adapter can be customized through various bean properties. A common use case is to apply shared binder
* initialization logic through a custom {@link #setWebBindingInitializer WebBindingInitializer}.
* <p>This adapter can be customized through various bean properties.
* A common use case is to apply shared binder initialization logic through
* a custom {@link #setWebBindingInitializer WebBindingInitializer}.
*
* @author Juergen Hoeller
* @author Arjen Poutsma
* @since 2.5
* @see #setPathMatcher
* @see #setMethodNameResolver
* @see #setWebBindingInitializer
* @see #setSessionAttributeStore
* @since 2.5
*/
public class AnnotationMethodHandlerAdapter extends WebContentGenerator
implements HandlerAdapter, Ordered, BeanFactoryAware {
@ -451,9 +454,8 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
* @see ServletRequestDataBinder#bind(javax.servlet.ServletRequest)
* @see ServletRequestDataBinder#convertIfNecessary(Object, Class, org.springframework.core.MethodParameter)
*/
protected ServletRequestDataBinder createBinder(
HttpServletRequest request, Object target, String objectName) throws Exception {
protected ServletRequestDataBinder createBinder(HttpServletRequest request, Object target, String objectName)
throws Exception {
return new ServletRequestDataBinder(target, objectName);
}
@ -466,7 +468,6 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
* @throws Exception in case of errors
*/
protected HttpInputMessage createHttpInputMessage(HttpServletRequest servletRequest) throws Exception {
return new ServletServerHttpRequest(servletRequest);
}
@ -479,7 +480,6 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
* @throws Exception in case of errors
*/
protected HttpOutputMessage createHttpOutputMessage(HttpServletResponse servletResponse) throws Exception {
return new ServletServerHttpResponse(servletResponse);
}
@ -833,12 +833,11 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
handleResponseBody(returnValue, webRequest);
return null;
}
if (returnValue instanceof HttpEntity) {
else if (returnValue instanceof HttpEntity) {
handleHttpEntityResponse((HttpEntity<?>) returnValue, webRequest);
return null;
}
if (returnValue instanceof ModelAndView) {
else if (returnValue instanceof ModelAndView) {
ModelAndView mav = (ModelAndView) returnValue;
mav.getModelMap().mergeAttributes(implicitModel);
return mav;
@ -884,10 +883,8 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
if (returnValue == null) {
return;
}
HttpInputMessage inputMessage = createHttpInputMessage(webRequest);
HttpOutputMessage outputMessage = createHttpOutputMessage(webRequest);
writeWithMessageConverters(returnValue, inputMessage, outputMessage);
}
@ -898,7 +895,6 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
}
HttpInputMessage inputMessage = createHttpInputMessage(webRequest);
HttpOutputMessage outputMessage = createHttpOutputMessage(webRequest);
HttpHeaders entityHeaders = responseEntity.getHeaders();
if (!entityHeaders.isEmpty()) {
outputMessage.getHeaders().putAll(entityHeaders);
@ -1086,7 +1082,6 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
}
return Collections.emptyList();
}
}
}

View File

@ -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.
@ -23,13 +23,13 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation which indicates that a method return value should be bound to the web response body. Supported for annotated
* handler methods in Servlet environments.
* Annotation which indicates that a method return value should be bound to the web response body.
* Supported for annotated handler methods in Servlet environments.
*
* @author Arjen Poutsma
* @since 3.0
* @see RequestBody
* @see org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter
* @since 3.0
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)