overhaul of support package arrangements for handler method processing; added missing package-info files

This commit is contained in:
Juergen Hoeller
2011-12-12 23:20:03 +00:00
parent 2065b788c4
commit 1c45c51fe1
79 changed files with 194 additions and 149 deletions

View File

@@ -14,25 +14,25 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.bind;
import org.springframework.core.MethodParameter;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;
/**
* Thrown when validation on an argument annotated with {@code @Valid} fails.
*
* Exception to be thrown when validation on an argument annotated with {@code @Valid} fails.
*
* @author Rossen Stoyanchev
* @since 3.1
*/
@SuppressWarnings("serial")
public class MethodArgumentNotValidException extends Exception {
private final MethodParameter parameter;
private final BindingResult bindingResult;
/**
* Constructor for {@link MethodArgumentNotValidException}.
* @param parameter the parameter that failed validation
@@ -47,23 +47,24 @@ public class MethodArgumentNotValidException extends Exception {
* Return the method parameter that failed validation.
*/
public MethodParameter getParameter() {
return parameter;
return this.parameter;
}
/**
* Return the results of the failed validation.
*/
public BindingResult getBindingResult() {
return bindingResult;
return this.bindingResult;
}
@Override
public String getMessage() {
StringBuilder sb = new StringBuilder("Validation failed for argument at index [")
.append(parameter.getParameterIndex()).append("] in method: ")
.append(parameter.getMethod().toGenericString())
.append(", with ").append(bindingResult.getErrorCount()).append(" error(s): ");
for (ObjectError error : bindingResult.getAllErrors()) {
StringBuilder sb = new StringBuilder("Validation failed for argument at index ")
.append(this.parameter.getParameterIndex()).append(" in method: ")
.append(this.parameter.getMethod().toGenericString())
.append(", with ").append(this.bindingResult.getErrorCount()).append(" error(s): ");
for (ObjectError error : this.bindingResult.getAllErrors()) {
sb.append("[").append(error).append("] ");
}
return sb.toString();

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.core.MethodParameter;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import java.util.ArrayList;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import javax.servlet.ServletException;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import java.util.Map;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import java.lang.annotation.Annotation;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import org.springframework.core.MethodParameter;
import org.springframework.ui.Model;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import java.util.Iterator;
import java.util.LinkedHashMap;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import java.util.Map;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import java.util.LinkedHashMap;
import java.util.Map;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import java.beans.PropertyEditor;
import java.util.Collection;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import org.springframework.core.MethodParameter;
import org.springframework.web.bind.support.SessionStatus;

View File

@@ -0,0 +1,8 @@
/**
*
* Support classes for annotation-based handler method processing.
*
*/
package org.springframework.web.method.annotation;

View File

@@ -0,0 +1,9 @@
/**
*
* Common infrastructure for handler method processing, as used by
* Spring MVC's <code>org.springframework.web.servlet.mvc.method</code> package.
*
*/
package org.springframework.web.method;

View File

@@ -0,0 +1,8 @@
/**
*
* Generic support classes for handler method processing.
*
*/
package org.springframework.web.method.support;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -34,9 +34,10 @@ import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.method.annotation.AbstractCookieValueMethodArgumentResolver;
/**
* Test fixture with {@link AbstractCookieValueMethodArgumentResolver}.
* Test fixture with {@link org.springframework.web.method.annotation.AbstractCookieValueMethodArgumentResolver}.
*
* @author Arjen Poutsma
* @author Rossen Stoyanchev

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import static org.junit.Assert.assertSame;
@@ -27,6 +27,7 @@ import org.springframework.validation.Errors;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.method.annotation.ErrorsMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;
/**

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -33,7 +33,7 @@ import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.context.support.GenericWebApplicationContext;
import org.springframework.web.method.annotation.support.ExpressionValueMethodArgumentResolver;
import org.springframework.web.method.annotation.ExpressionValueMethodArgumentResolver;
/**
* Test fixture with {@link ExpressionValueMethodArgumentResolver}.

View File

@@ -38,7 +38,6 @@ import org.springframework.web.bind.support.DefaultDataBinderFactory;
import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.method.annotation.support.RequestParamMethodArgumentResolver;
import org.springframework.web.method.support.InvocableHandlerMethod;
import org.springframework.web.method.support.HandlerMethodArgumentResolverComposite;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
@@ -30,10 +30,11 @@ import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.ui.ModelMap;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.method.annotation.MapMethodProcessor;
import org.springframework.web.method.support.ModelAndViewContainer;
/**
* Test fixture with {@link MapMethodProcessor}.
* Test fixture with {@link org.springframework.web.method.annotation.MapMethodProcessor}.
*
* @author Rossen Stoyanchev
*/

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -36,6 +36,7 @@ import org.springframework.web.bind.support.WebRequestDataBinder;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.method.annotation.ModelAttributeMethodProcessor;
import org.springframework.web.method.support.ModelAndViewContainer;
import static java.lang.annotation.ElementType.*;

View File

@@ -44,7 +44,6 @@ import org.springframework.web.bind.support.SessionAttributeStore;
import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.method.annotation.support.ModelMethodProcessor;
import org.springframework.web.method.support.HandlerMethodArgumentResolverComposite;
import org.springframework.web.method.support.InvocableHandlerMethod;
import org.springframework.web.method.support.ModelAndViewContainer;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
@@ -30,10 +30,11 @@ import org.springframework.ui.ExtendedModelMap;
import org.springframework.ui.Model;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.method.annotation.ModelMethodProcessor;
import org.springframework.web.method.support.ModelAndViewContainer;
/**
* Test fixture with {@link ModelMethodProcessor}.
* Test fixture with {@link org.springframework.web.method.annotation.ModelMethodProcessor}.
*
* @author Rossen Stoyanchev
*/

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -35,6 +35,7 @@ import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.method.annotation.RequestHeaderMapMethodArgumentResolver;
/**
* Text fixture with {@link RequestHeaderMapMethodArgumentResolver}.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
@@ -37,9 +37,10 @@ import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.context.support.GenericWebApplicationContext;
import org.springframework.web.method.annotation.RequestHeaderMethodArgumentResolver;
/**
* Test fixture with {@link RequestHeaderMethodArgumentResolver}.
* Test fixture with {@link org.springframework.web.method.annotation.RequestHeaderMethodArgumentResolver}.
*
* @author Arjen Poutsma
* @author Rossen Stoyanchev

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -34,6 +34,7 @@ import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.method.annotation.RequestParamMapMethodArgumentResolver;
/**
* Test fixture with {@link RequestParamMapMethodArgumentResolver}.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
@@ -45,11 +45,12 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.method.annotation.RequestParamMethodArgumentResolver;
import org.springframework.web.multipart.MultipartException;
import org.springframework.web.multipart.MultipartFile;
/**
* Test fixture with {@link RequestParamMethodArgumentResolver}.
* Test fixture with {@link org.springframework.web.method.annotation.RequestParamMethodArgumentResolver}.
*
* @author Arjen Poutsma
* @author Rossen Stoyanchev

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.method.annotation.support;
package org.springframework.web.method.annotation;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;