Skip to content

Commit f0be79e

Browse files
committed
Promoted BindingContext to web.reactive root (since HandlerResult requires it there)
Issue: SPR-14542
1 parent 99a8510 commit f0be79e

File tree

43 files changed

+130
-169
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+130
-169
lines changed
Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.springframework.web.reactive.result.method;
16+
17+
package org.springframework.web.reactive;
1718

1819
import org.springframework.ui.Model;
1920
import org.springframework.validation.support.BindingAwareConcurrentModel;
@@ -22,7 +23,6 @@
2223
import org.springframework.web.bind.support.WebBindingInitializer;
2324
import org.springframework.web.server.ServerWebExchange;
2425

25-
2626
/**
2727
* A context for binding requests to method arguments that provides access to
2828
* the default model, data binding, validation, and type conversion.
@@ -45,14 +45,6 @@ public BindingContext(WebBindingInitializer initializer) {
4545
this.initializer = initializer;
4646
}
4747

48-
private static WebExchangeDataBinder initTypeConverter(WebBindingInitializer initializer) {
49-
WebExchangeDataBinder binder = new WebExchangeDataBinder(null);
50-
if (initializer != null) {
51-
initializer.initBinder(binder);
52-
}
53-
return binder;
54-
}
55-
5648

5749
/**
5850
* Return the default model.
@@ -65,7 +57,6 @@ public Model getModel() {
6557
/**
6658
* Create a {@link WebExchangeDataBinder} for applying data binding, type
6759
* conversion, and validation on the given "target" object.
68-
*
6960
* @param exchange the current exchange
7061
* @param target the object to create a data binder for
7162
* @param name the name of the target object
@@ -82,7 +73,6 @@ public WebExchangeDataBinder createDataBinder(ServerWebExchange exchange, Object
8273
/**
8374
* Create a {@link WebExchangeDataBinder} without a "target" object, i.e.
8475
* for applying type conversion to simple types.
85-
*
8676
* @param exchange the current exchange
8777
* @param name the name of the target object
8878
* @return a Mono for the created {@link WebDataBinder} instance
@@ -101,9 +91,7 @@ protected WebExchangeDataBinder createBinderInstance(Object target, String objec
10191
/**
10292
* Initialize the data binder instance for the given exchange.
10393
*/
104-
protected WebExchangeDataBinder initDataBinder(WebExchangeDataBinder binder,
105-
ServerWebExchange exchange) {
106-
94+
protected WebExchangeDataBinder initDataBinder(WebExchangeDataBinder binder, ServerWebExchange exchange) {
10795
return binder;
10896
}
10997

spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerResult.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.springframework.core.ResolvableType;
2626
import org.springframework.ui.Model;
2727
import org.springframework.util.Assert;
28-
import org.springframework.web.reactive.result.method.BindingContext;
2928

3029
/**
3130
* Represent the result of the invocation of a handler or a handler method.

spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/HandlerMethodArgumentResolver.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,9 +19,9 @@
1919
import reactor.core.publisher.Mono;
2020

2121
import org.springframework.core.MethodParameter;
22+
import org.springframework.web.reactive.BindingContext;
2223
import org.springframework.web.server.ServerWebExchange;
2324

24-
2525
/**
2626
* Strategy interface for resolving method parameters into argument values in
2727
* the context of a given request.
@@ -31,7 +31,6 @@
3131
*/
3232
public interface HandlerMethodArgumentResolver {
3333

34-
3534
boolean supportsParameter(MethodParameter parameter);
3635

3736
/**

spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@
3636
import org.springframework.util.ObjectUtils;
3737
import org.springframework.util.ReflectionUtils;
3838
import org.springframework.web.method.HandlerMethod;
39+
import org.springframework.web.reactive.BindingContext;
3940
import org.springframework.web.reactive.HandlerResult;
4041
import org.springframework.web.server.ServerWebExchange;
4142

4243
/**
43-
* A sub-class of {@link HandlerMethod} that can resolve method arguments from
44+
* A subclass of {@link HandlerMethod} that can resolve method arguments from
4445
* a {@link ServerWebExchange} and use that to invoke the underlying method.
4546
*
4647
* @author Rossen Stoyanchev

spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/SyncHandlerMethodArgumentResolver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,9 +21,9 @@
2121
import reactor.core.publisher.Mono;
2222

2323
import org.springframework.core.MethodParameter;
24+
import org.springframework.web.reactive.BindingContext;
2425
import org.springframework.web.server.ServerWebExchange;
2526

26-
2727
/**
2828
* An extension of {@link HandlerMethodArgumentResolver} for implementations
2929
* that are synchronous in nature and do not block to resolve values.

spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/SyncInvocableHandlerMethod.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.web.reactive.result.method;
1718

1819
import java.lang.reflect.Method;
@@ -21,6 +22,7 @@
2122

2223
import org.springframework.util.Assert;
2324
import org.springframework.web.method.HandlerMethod;
25+
import org.springframework.web.reactive.BindingContext;
2426
import org.springframework.web.reactive.HandlerResult;
2527
import org.springframework.web.server.ServerWebExchange;
2628

@@ -35,7 +37,6 @@
3537
*/
3638
public class SyncInvocableHandlerMethod extends InvocableHandlerMethod {
3739

38-
3940
public SyncInvocableHandlerMethod(HandlerMethod handlerMethod) {
4041
super(handlerMethod);
4142
}

spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractMessageReaderArgumentResolver.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.web.reactive.result.method.annotation;
1718

1819
import java.lang.annotation.Annotation;
@@ -38,12 +39,12 @@
3839
import org.springframework.util.Assert;
3940
import org.springframework.validation.Validator;
4041
import org.springframework.validation.annotation.Validated;
42+
import org.springframework.web.bind.WebExchangeBindException;
4143
import org.springframework.web.bind.WebExchangeDataBinder;
42-
import org.springframework.web.reactive.result.method.BindingContext;
44+
import org.springframework.web.reactive.BindingContext;
4345
import org.springframework.web.server.ServerWebExchange;
4446
import org.springframework.web.server.ServerWebInputException;
4547
import org.springframework.web.server.UnsupportedMediaTypeStatusException;
46-
import org.springframework.web.bind.WebExchangeBindException;
4748

4849
/**
4950
* Abstract base class for argument resolvers that resolve method arguments

spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueArgumentResolver.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import org.springframework.ui.Model;
3131
import org.springframework.web.bind.WebDataBinder;
3232
import org.springframework.web.bind.annotation.ValueConstants;
33-
import org.springframework.web.reactive.result.method.BindingContext;
33+
import org.springframework.web.reactive.BindingContext;
3434
import org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver;
3535
import org.springframework.web.server.ServerErrorException;
3636
import org.springframework.web.server.ServerWebExchange;
@@ -40,13 +40,15 @@
4040
* Abstract base class for resolving method arguments from a named value.
4141
* Request parameters, request headers, and path variables are examples of named
4242
* values. Each may have a name, a required flag, and a default value.
43+
*
4344
* <p>Subclasses define how to do the following:
4445
* <ul>
4546
* <li>Obtain named value information for a method parameter
4647
* <li>Resolve names into argument values
4748
* <li>Handle missing argument values when argument values are required
4849
* <li>Optionally handle a resolved value
4950
* </ul>
51+
*
5052
* <p>A default value string can contain ${...} placeholders and Spring Expression
5153
* Language #{...} expressions. For this to work a
5254
* {@link ConfigurableBeanFactory} must be supplied to the class constructor.

spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueSyncArgumentResolver.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
2424
import org.springframework.core.MethodParameter;
25-
import org.springframework.web.reactive.result.method.BindingContext;
25+
import org.springframework.web.reactive.BindingContext;
2626
import org.springframework.web.reactive.result.method.SyncHandlerMethodArgumentResolver;
2727
import org.springframework.web.server.ServerWebExchange;
2828

@@ -38,7 +38,6 @@
3838
public abstract class AbstractNamedValueSyncArgumentResolver extends AbstractNamedValueArgumentResolver
3939
implements SyncHandlerMethodArgumentResolver {
4040

41-
4241
public AbstractNamedValueSyncArgumentResolver(ConfigurableBeanFactory beanFactory) {
4342
super(beanFactory);
4443
}

spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/annotation/BindingContextFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.web.reactive.result.method.annotation;
1718

1819
import java.lang.reflect.Method;
@@ -33,8 +34,8 @@
3334
import org.springframework.web.bind.annotation.ModelAttribute;
3435
import org.springframework.web.bind.support.WebBindingInitializer;
3536
import org.springframework.web.method.HandlerMethod;
37+
import org.springframework.web.reactive.BindingContext;
3638
import org.springframework.web.reactive.HandlerResult;
37-
import org.springframework.web.reactive.result.method.BindingContext;
3839
import org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver;
3940
import org.springframework.web.reactive.result.method.InvocableHandlerMethod;
4041
import org.springframework.web.reactive.result.method.SyncHandlerMethodArgumentResolver;

0 commit comments

Comments
 (0)