@@ -67,24 +67,27 @@ import org.springframework.core.ResolvableType;
|
|||||||
* 1. BeanNameAware's {@code setBeanName}<br>
|
* 1. BeanNameAware's {@code setBeanName}<br>
|
||||||
* 2. BeanClassLoaderAware's {@code setBeanClassLoader}<br>
|
* 2. BeanClassLoaderAware's {@code setBeanClassLoader}<br>
|
||||||
* 3. BeanFactoryAware's {@code setBeanFactory}<br>
|
* 3. BeanFactoryAware's {@code setBeanFactory}<br>
|
||||||
* 4. ResourceLoaderAware's {@code setResourceLoader}
|
* 4. EnvironmentAware's {@code setEnvironment}
|
||||||
|
* 5. EmbeddedValueResolverAware's {@code setEmbeddedValueResolver}
|
||||||
|
* 6. ResourceLoaderAware's {@code setResourceLoader}
|
||||||
* (only applicable when running in an application context)<br>
|
* (only applicable when running in an application context)<br>
|
||||||
* 5. ApplicationEventPublisherAware's {@code setApplicationEventPublisher}
|
* 7. ApplicationEventPublisherAware's {@code setApplicationEventPublisher}
|
||||||
* (only applicable when running in an application context)<br>
|
* (only applicable when running in an application context)<br>
|
||||||
* 6. MessageSourceAware's {@code setMessageSource}
|
* 8. MessageSourceAware's {@code setMessageSource}
|
||||||
* (only applicable when running in an application context)<br>
|
* (only applicable when running in an application context)<br>
|
||||||
* 7. ApplicationContextAware's {@code setApplicationContext}
|
* 9. ApplicationContextAware's {@code setApplicationContext}
|
||||||
* (only applicable when running in an application context)<br>
|
* (only applicable when running in an application context)<br>
|
||||||
* 8. ServletContextAware's {@code setServletContext}
|
* 10. ServletContextAware's {@code setServletContext}
|
||||||
* (only applicable when running in a web application context)<br>
|
* (only applicable when running in a web application context)<br>
|
||||||
* 9. {@code postProcessBeforeInitialization} methods of BeanPostProcessors<br>
|
* 11. {@code postProcessBeforeInitialization} methods of BeanPostProcessors<br>
|
||||||
* 10. InitializingBean's {@code afterPropertiesSet}<br>
|
* 12. InitializingBean's {@code afterPropertiesSet}<br>
|
||||||
* 11. a custom init-method definition<br>
|
* 13. a custom init-method definition<br>
|
||||||
* 12. {@code postProcessAfterInitialization} methods of BeanPostProcessors
|
* 14. {@code postProcessAfterInitialization} methods of BeanPostProcessors
|
||||||
*
|
*
|
||||||
* <p>On shutdown of a bean factory, the following lifecycle methods apply:<br>
|
* <p>On shutdown of a bean factory, the following lifecycle methods apply:<br>
|
||||||
* 1. DisposableBean's {@code destroy}<br>
|
* 1. {@code postProcessBeforeDestruction} methods of DestructionAwareBeanPostProcessors
|
||||||
* 2. a custom destroy-method definition
|
* 2. DisposableBean's {@code destroy}<br>
|
||||||
|
* 3. a custom destroy-method definition
|
||||||
*
|
*
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2013 the original author or authors.
|
* Copyright 2002-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -191,7 +191,7 @@ public class DateFormatter implements Formatter<Date> {
|
|||||||
if (timeStyle != -1) {
|
if (timeStyle != -1) {
|
||||||
return DateFormat.getTimeInstance(timeStyle, locale);
|
return DateFormat.getTimeInstance(timeStyle, locale);
|
||||||
}
|
}
|
||||||
throw new IllegalStateException("Unsupported style pattern '"+ this.stylePattern+ "'");
|
throw new IllegalStateException("Unsupported style pattern '" + this.stylePattern + "'");
|
||||||
|
|
||||||
}
|
}
|
||||||
return DateFormat.getDateInstance(this.style, locale);
|
return DateFormat.getDateInstance(this.style, locale);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2015 the original author or authors.
|
* Copyright 2002-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -194,7 +194,7 @@ public class ReflectionHelper {
|
|||||||
TypeDescriptor varargsDesc = expectedArgTypes.get(expectedArgTypes.size() - 1);
|
TypeDescriptor varargsDesc = expectedArgTypes.get(expectedArgTypes.size() - 1);
|
||||||
Class<?> varargsParamType = varargsDesc.getElementTypeDescriptor().getType();
|
Class<?> varargsParamType = varargsDesc.getElementTypeDescriptor().getType();
|
||||||
|
|
||||||
// All remaining parameters must be of this type or convertable to this type
|
// All remaining parameters must be of this type or convertible to this type
|
||||||
for (int i = expectedArgTypes.size() - 1; i < suppliedArgTypes.size(); i++) {
|
for (int i = expectedArgTypes.size() - 1; i < suppliedArgTypes.size(); i++) {
|
||||||
TypeDescriptor suppliedArg = suppliedArgTypes.get(i);
|
TypeDescriptor suppliedArg = suppliedArgTypes.get(i);
|
||||||
if (suppliedArg == null) {
|
if (suppliedArg == null) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2012 the original author or authors.
|
* Copyright 2002-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -122,7 +122,7 @@ public abstract class DataAccessUtils {
|
|||||||
/**
|
/**
|
||||||
* Return a unique result object from the given Collection.
|
* Return a unique result object from the given Collection.
|
||||||
* Throws an exception if 0 or more than 1 result objects found,
|
* Throws an exception if 0 or more than 1 result objects found,
|
||||||
* of if the unique result object is not convertable to the
|
* of if the unique result object is not convertible to the
|
||||||
* specified required type.
|
* specified required type.
|
||||||
* @param results the result Collection (can be {@code null})
|
* @param results the result Collection (can be {@code null})
|
||||||
* @return the unique result object
|
* @return the unique result object
|
||||||
@@ -162,7 +162,7 @@ public abstract class DataAccessUtils {
|
|||||||
/**
|
/**
|
||||||
* Return a unique int result from the given Collection.
|
* Return a unique int result from the given Collection.
|
||||||
* Throws an exception if 0 or more than 1 result objects found,
|
* Throws an exception if 0 or more than 1 result objects found,
|
||||||
* of if the unique result object is not convertable to an int.
|
* of if the unique result object is not convertible to an int.
|
||||||
* @param results the result Collection (can be {@code null})
|
* @param results the result Collection (can be {@code null})
|
||||||
* @return the unique int result
|
* @return the unique int result
|
||||||
* @throws IncorrectResultSizeDataAccessException if more than one
|
* @throws IncorrectResultSizeDataAccessException if more than one
|
||||||
@@ -170,7 +170,7 @@ public abstract class DataAccessUtils {
|
|||||||
* @throws EmptyResultDataAccessException if no result object
|
* @throws EmptyResultDataAccessException if no result object
|
||||||
* at all has been found in the given Collection
|
* at all has been found in the given Collection
|
||||||
* @throws TypeMismatchDataAccessException if the unique object
|
* @throws TypeMismatchDataAccessException if the unique object
|
||||||
* in the collection is not convertable to an int
|
* in the collection is not convertible to an int
|
||||||
*/
|
*/
|
||||||
public static int intResult(Collection<?> results)
|
public static int intResult(Collection<?> results)
|
||||||
throws IncorrectResultSizeDataAccessException, TypeMismatchDataAccessException {
|
throws IncorrectResultSizeDataAccessException, TypeMismatchDataAccessException {
|
||||||
@@ -181,7 +181,7 @@ public abstract class DataAccessUtils {
|
|||||||
/**
|
/**
|
||||||
* Return a unique long result from the given Collection.
|
* Return a unique long result from the given Collection.
|
||||||
* Throws an exception if 0 or more than 1 result objects found,
|
* Throws an exception if 0 or more than 1 result objects found,
|
||||||
* of if the unique result object is not convertable to a long.
|
* of if the unique result object is not convertible to a long.
|
||||||
* @param results the result Collection (can be {@code null})
|
* @param results the result Collection (can be {@code null})
|
||||||
* @return the unique long result
|
* @return the unique long result
|
||||||
* @throws IncorrectResultSizeDataAccessException if more than one
|
* @throws IncorrectResultSizeDataAccessException if more than one
|
||||||
@@ -189,7 +189,7 @@ public abstract class DataAccessUtils {
|
|||||||
* @throws EmptyResultDataAccessException if no result object
|
* @throws EmptyResultDataAccessException if no result object
|
||||||
* at all has been found in the given Collection
|
* at all has been found in the given Collection
|
||||||
* @throws TypeMismatchDataAccessException if the unique object
|
* @throws TypeMismatchDataAccessException if the unique object
|
||||||
* in the collection is not convertable to a long
|
* in the collection is not convertible to a long
|
||||||
*/
|
*/
|
||||||
public static long longResult(Collection<?> results)
|
public static long longResult(Collection<?> results)
|
||||||
throws IncorrectResultSizeDataAccessException, TypeMismatchDataAccessException {
|
throws IncorrectResultSizeDataAccessException, TypeMismatchDataAccessException {
|
||||||
|
|||||||
@@ -126,8 +126,9 @@ public class ModelAndViewResolverMethodReturnValueHandlerTests {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public ModelAndView resolveModelAndView(Method method, Class handlerType, Object returnValue,
|
public ModelAndView resolveModelAndView(Method method, Class<?> handlerType, Object returnValue,
|
||||||
ExtendedModelMap model, NativeWebRequest request) {
|
ExtendedModelMap model, NativeWebRequest request) {
|
||||||
|
|
||||||
if (returnValue != null && returnValue.getClass().equals(returnValueType)) {
|
if (returnValue != null && returnValue.getClass().equals(returnValueType)) {
|
||||||
return new ModelAndView("viewName", "modelAttrName", returnValue);
|
return new ModelAndView("viewName", "modelAttrName", returnValue);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2015 the original author or authors.
|
* Copyright 2002-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -106,7 +106,6 @@ import org.springframework.validation.BindingResult;
|
|||||||
import org.springframework.validation.Errors;
|
import org.springframework.validation.Errors;
|
||||||
import org.springframework.validation.FieldError;
|
import org.springframework.validation.FieldError;
|
||||||
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
|
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
|
||||||
import org.springframework.web.accept.ContentNegotiationManager;
|
|
||||||
import org.springframework.web.accept.ContentNegotiationManagerFactoryBean;
|
import org.springframework.web.accept.ContentNegotiationManagerFactoryBean;
|
||||||
import org.springframework.web.bind.WebDataBinder;
|
import org.springframework.web.bind.WebDataBinder;
|
||||||
import org.springframework.web.bind.annotation.CookieValue;
|
import org.springframework.web.bind.annotation.CookieValue;
|
||||||
@@ -141,30 +140,23 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|||||||
import org.springframework.web.servlet.support.RequestContextUtils;
|
import org.springframework.web.servlet.support.RequestContextUtils;
|
||||||
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.*;
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
import static org.junit.Assert.assertSame;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The origin of this test class is {@link ServletAnnotationControllerHandlerMethodTests}.
|
* The origin of this test class is {@link ServletAnnotationControllerHandlerMethodTests}.
|
||||||
*
|
*
|
||||||
* Tests in this class run against the {@link HandlerMethod} infrastructure:
|
* Tests in this class run against the {@link HandlerMethod} infrastructure:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>RequestMappingHandlerMapping
|
* <li>RequestMappingHandlerMapping
|
||||||
* <li>RequestMappingHandlerAdapter
|
* <li>RequestMappingHandlerAdapter
|
||||||
* <li>ExceptionHandlerExceptionResolver
|
* <li>ExceptionHandlerExceptionResolver
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* <p>Rather than against the existing infrastructure:
|
* <p>Rather than against the existing infrastructure:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>DefaultAnnotationHandlerMapping
|
* <li>DefaultAnnotationHandlerMapping
|
||||||
* <li>AnnotationMethodHandlerAdapter
|
* <li>AnnotationMethodHandlerAdapter
|
||||||
* <li>AnnotationMethodHandlerExceptionResolver
|
* <li>AnnotationMethodHandlerExceptionResolver
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
@@ -2789,18 +2781,15 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public ModelAndView resolveModelAndView(Method handlerMethod,
|
public ModelAndView resolveModelAndView(Method handlerMethod, Class<?> handlerType, Object returnValue,
|
||||||
Class handlerType,
|
ExtendedModelMap implicitModel, NativeWebRequest webRequest) {
|
||||||
Object returnValue,
|
|
||||||
ExtendedModelMap implicitModel,
|
|
||||||
NativeWebRequest webRequest) {
|
|
||||||
if (returnValue instanceof MySpecialArg) {
|
if (returnValue instanceof MySpecialArg) {
|
||||||
return new ModelAndView(new View() {
|
return new ModelAndView(new View() {
|
||||||
@Override
|
@Override
|
||||||
public String getContentType() {
|
public String getContentType() {
|
||||||
return "text/html";
|
return "text/html";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response)
|
public void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user