1
1
/*
2
- * Copyright 2002-2017 the original author or authors.
2
+ * Copyright 2002-2018 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -79,6 +79,9 @@ public class WebHttpHandlerBuilder {
79
79
80
80
private final WebHandler webHandler ;
81
81
82
+ @ Nullable
83
+ private final ApplicationContext applicationContext ;
84
+
82
85
private final List <WebFilter > filters = new ArrayList <>();
83
86
84
87
private final List <WebExceptionHandler > exceptionHandlers = new ArrayList <>();
@@ -92,22 +95,11 @@ public class WebHttpHandlerBuilder {
92
95
@ Nullable
93
96
private LocaleContextResolver localeContextResolver ;
94
97
95
- @ Nullable
96
- private ApplicationContext applicationContext ;
97
-
98
-
99
- /**
100
- * Private constructor.
101
- */
102
- private WebHttpHandlerBuilder (WebHandler webHandler ) {
103
- Assert .notNull (webHandler , "WebHandler must not be null" );
104
- this .webHandler = webHandler ;
105
- }
106
98
107
99
/**
108
100
* Private constructor to use when initialized from an ApplicationContext.
109
101
*/
110
- private WebHttpHandlerBuilder (WebHandler webHandler , ApplicationContext applicationContext ) {
102
+ private WebHttpHandlerBuilder (WebHandler webHandler , @ Nullable ApplicationContext applicationContext ) {
111
103
Assert .notNull (webHandler , "WebHandler must not be null" );
112
104
this .webHandler = webHandler ;
113
105
this .applicationContext = applicationContext ;
@@ -118,6 +110,7 @@ private WebHttpHandlerBuilder(WebHandler webHandler, ApplicationContext applicat
118
110
*/
119
111
private WebHttpHandlerBuilder (WebHttpHandlerBuilder other ) {
120
112
this .webHandler = other .webHandler ;
113
+ this .applicationContext = other .applicationContext ;
121
114
this .filters .addAll (other .filters );
122
115
this .exceptionHandlers .addAll (other .exceptionHandlers );
123
116
this .sessionManager = other .sessionManager ;
@@ -132,7 +125,7 @@ private WebHttpHandlerBuilder(WebHttpHandlerBuilder other) {
132
125
* @return the prepared builder
133
126
*/
134
127
public static WebHttpHandlerBuilder webHandler (WebHandler webHandler ) {
135
- return new WebHttpHandlerBuilder (webHandler );
128
+ return new WebHttpHandlerBuilder (webHandler , null );
136
129
}
137
130
138
131
/**
@@ -156,7 +149,6 @@ public static WebHttpHandlerBuilder webHandler(WebHandler webHandler) {
156
149
* @return the prepared builder
157
150
*/
158
151
public static WebHttpHandlerBuilder applicationContext (ApplicationContext context ) {
159
-
160
152
WebHttpHandlerBuilder builder = new WebHttpHandlerBuilder (
161
153
context .getBean (WEB_HANDLER_BEAN_NAME , WebHandler .class ), context );
162
154
@@ -272,10 +264,7 @@ public WebHttpHandlerBuilder localeContextResolver(LocaleContextResolver localeC
272
264
* Build the {@link HttpHandler}.
273
265
*/
274
266
public HttpHandler build () {
275
-
276
- WebHandler decorated ;
277
-
278
- decorated = new FilteringWebHandler (this .webHandler , this .filters );
267
+ WebHandler decorated = new FilteringWebHandler (this .webHandler , this .filters );
279
268
decorated = new ExceptionHandlingWebHandler (decorated , this .exceptionHandlers );
280
269
281
270
HttpWebHandlerAdapter adapted = new HttpWebHandlerAdapter (decorated );
0 commit comments