support for default "conversionService" bean in an ApplicationContext; revised formatting package, now integrated with DataBinder and AnnotationMethodHandlerAdapter; revised AccessControlContext access from BeanFactory
This commit is contained in:
@@ -75,8 +75,8 @@ import org.springframework.web.multipart.MultipartRequest;
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Arjen Poutsma
|
||||
* @see #invokeHandlerMethod
|
||||
* @since 2.5.2
|
||||
* @see #invokeHandlerMethod
|
||||
*/
|
||||
public class HandlerMethodInvoker {
|
||||
|
||||
@@ -93,18 +93,17 @@ public class HandlerMethodInvoker {
|
||||
|
||||
private final WebArgumentResolver[] customArgumentResolvers;
|
||||
|
||||
private final SimpleSessionStatus sessionStatus = new SimpleSessionStatus();
|
||||
|
||||
private final HttpMessageConverter[] messageConverters;
|
||||
|
||||
private final SimpleSessionStatus sessionStatus = new SimpleSessionStatus();
|
||||
|
||||
|
||||
public HandlerMethodInvoker(HandlerMethodResolver methodResolver) {
|
||||
this(methodResolver, null);
|
||||
}
|
||||
|
||||
public HandlerMethodInvoker(HandlerMethodResolver methodResolver, WebBindingInitializer bindingInitializer) {
|
||||
this(methodResolver, bindingInitializer, new DefaultSessionAttributeStore(), null, new WebArgumentResolver[0],
|
||||
new HttpMessageConverter[0]);
|
||||
this(methodResolver, bindingInitializer, new DefaultSessionAttributeStore(), null, null, null);
|
||||
}
|
||||
|
||||
public HandlerMethodInvoker(HandlerMethodResolver methodResolver, WebBindingInitializer bindingInitializer,
|
||||
@@ -379,7 +378,7 @@ public class HandlerMethodInvoker {
|
||||
MethodParameter methodParam, NativeWebRequest webRequest, Object handlerForInitBinderCall)
|
||||
throws Exception {
|
||||
|
||||
Class paramType = methodParam.getParameterType();
|
||||
Class<?> paramType = methodParam.getParameterType();
|
||||
if (paramName.length() == 0) {
|
||||
paramName = getRequiredParameterName(methodParam);
|
||||
}
|
||||
@@ -411,7 +410,7 @@ public class HandlerMethodInvoker {
|
||||
MethodParameter methodParam, NativeWebRequest webRequest, Object handlerForInitBinderCall)
|
||||
throws Exception {
|
||||
|
||||
Class paramType = methodParam.getParameterType();
|
||||
Class<?> paramType = methodParam.getParameterType();
|
||||
if (headerName.length() == 0) {
|
||||
headerName = getRequiredParameterName(methodParam);
|
||||
}
|
||||
@@ -455,12 +454,14 @@ public class HandlerMethodInvoker {
|
||||
"Cannot extract @RequestBody parameter (" + builder.toString() + "): no Content-Type found");
|
||||
}
|
||||
List<MediaType> allSupportedMediaTypes = new ArrayList<MediaType>();
|
||||
for (HttpMessageConverter<?> messageConverter : messageConverters) {
|
||||
allSupportedMediaTypes.addAll(messageConverter.getSupportedMediaTypes());
|
||||
if (messageConverter.supports(paramType)) {
|
||||
for (MediaType supportedMediaType : messageConverter.getSupportedMediaTypes()) {
|
||||
if (supportedMediaType.includes(contentType)) {
|
||||
return messageConverter.read(paramType, inputMessage);
|
||||
if (this.messageConverters != null) {
|
||||
for (HttpMessageConverter<?> messageConverter : this.messageConverters) {
|
||||
allSupportedMediaTypes.addAll(messageConverter.getSupportedMediaTypes());
|
||||
if (messageConverter.supports(paramType)) {
|
||||
for (MediaType supportedMediaType : messageConverter.getSupportedMediaTypes()) {
|
||||
if (supportedMediaType.includes(contentType)) {
|
||||
return messageConverter.read(paramType, inputMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -480,7 +481,7 @@ public class HandlerMethodInvoker {
|
||||
MethodParameter methodParam, NativeWebRequest webRequest, Object handlerForInitBinderCall)
|
||||
throws Exception {
|
||||
|
||||
Class paramType = methodParam.getParameterType();
|
||||
Class<?> paramType = methodParam.getParameterType();
|
||||
if (cookieName.length() == 0) {
|
||||
cookieName = getRequiredParameterName(methodParam);
|
||||
}
|
||||
@@ -512,7 +513,7 @@ public class HandlerMethodInvoker {
|
||||
private Object resolvePathVariable(String pathVarName, MethodParameter methodParam,
|
||||
NativeWebRequest webRequest, Object handlerForInitBinderCall) throws Exception {
|
||||
|
||||
Class paramType = methodParam.getParameterType();
|
||||
Class<?> paramType = methodParam.getParameterType();
|
||||
if (pathVarName.length() == 0) {
|
||||
pathVarName = getRequiredParameterName(methodParam);
|
||||
}
|
||||
@@ -565,8 +566,8 @@ public class HandlerMethodInvoker {
|
||||
if ("".equals(name)) {
|
||||
name = Conventions.getVariableNameForParameter(methodParam);
|
||||
}
|
||||
Class paramType = methodParam.getParameterType();
|
||||
Object bindObject = null;
|
||||
Class<?> paramType = methodParam.getParameterType();
|
||||
Object bindObject;
|
||||
if (implicitModel.containsKey(name)) {
|
||||
bindObject = implicitModel.get(name);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
* Copyright 2002-2009 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.
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.web.bind.support;
|
||||
|
||||
import org.springframework.beans.PropertyEditorRegistrar;
|
||||
import org.springframework.ui.format.FormatterRegistry;
|
||||
import org.springframework.validation.BindingErrorProcessor;
|
||||
import org.springframework.validation.MessageCodesResolver;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
@@ -42,6 +43,8 @@ public class ConfigurableWebBindingInitializer implements WebBindingInitializer
|
||||
|
||||
private BindingErrorProcessor bindingErrorProcessor;
|
||||
|
||||
private FormatterRegistry formatterRegistry;
|
||||
|
||||
private PropertyEditorRegistrar[] propertyEditorRegistrars;
|
||||
|
||||
|
||||
@@ -91,24 +94,35 @@ public class ConfigurableWebBindingInitializer implements WebBindingInitializer
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a single PropertyEditorRegistrar to be applied
|
||||
* to every DataBinder that this controller uses.
|
||||
* Specify a FormatterRegistry which will apply to every DataBinder.
|
||||
*/
|
||||
public final void setFormatterRegistry(FormatterRegistry formatterRegistry) {
|
||||
this.formatterRegistry = formatterRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a FormatterRegistry which will apply to every DataBinder.
|
||||
*/
|
||||
public final FormatterRegistry getFormatterRegistry() {
|
||||
return this.formatterRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a single PropertyEditorRegistrar to be applied to every DataBinder.
|
||||
*/
|
||||
public final void setPropertyEditorRegistrar(PropertyEditorRegistrar propertyEditorRegistrar) {
|
||||
this.propertyEditorRegistrars = new PropertyEditorRegistrar[] {propertyEditorRegistrar};
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify multiple PropertyEditorRegistrars to be applied
|
||||
* to every DataBinder that this controller uses.
|
||||
* Specify multiple PropertyEditorRegistrars to be applied to every DataBinder.
|
||||
*/
|
||||
public final void setPropertyEditorRegistrars(PropertyEditorRegistrar[] propertyEditorRegistrars) {
|
||||
this.propertyEditorRegistrars = propertyEditorRegistrars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the PropertyEditorRegistrars to be applied
|
||||
* to every DataBinder that this controller uses.
|
||||
* Return the PropertyEditorRegistrars to be applied to every DataBinder.
|
||||
*/
|
||||
public final PropertyEditorRegistrar[] getPropertyEditorRegistrars() {
|
||||
return this.propertyEditorRegistrars;
|
||||
@@ -125,9 +139,12 @@ public class ConfigurableWebBindingInitializer implements WebBindingInitializer
|
||||
if (this.bindingErrorProcessor != null) {
|
||||
binder.setBindingErrorProcessor(this.bindingErrorProcessor);
|
||||
}
|
||||
if (this.formatterRegistry != null) {
|
||||
binder.setFormatterRegistry(this.formatterRegistry);
|
||||
}
|
||||
if (this.propertyEditorRegistrars != null) {
|
||||
for (int i = 0; i < this.propertyEditorRegistrars.length; i++) {
|
||||
this.propertyEditorRegistrars[i].registerCustomEditors(binder);
|
||||
for (PropertyEditorRegistrar propertyEditorRegistrar : this.propertyEditorRegistrars) {
|
||||
propertyEditorRegistrar.registerCustomEditors(binder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user