47
47
* Base class for {@link View} implementations.
48
48
*
49
49
* @author Rossen Stoyanchev
50
+ * @author Sam Brannen
50
51
* @since 5.0
51
52
*/
52
53
public abstract class AbstractView implements View , BeanNameAware , ApplicationContextAware {
@@ -86,7 +87,7 @@ public AbstractView(ReactiveAdapterRegistry reactiveAdapterRegistry) {
86
87
87
88
/**
88
89
* Set the supported media types for this view.
89
- * Default is "text/html;charset=UTF-8".
90
+ * <p> Default is {@code "text/html;charset=UTF-8"} .
90
91
*/
91
92
public void setSupportedMediaTypes (List <MediaType > supportedMediaTypes ) {
92
93
Assert .notEmpty (supportedMediaTypes , "MediaType List must not be empty" );
@@ -95,7 +96,7 @@ public void setSupportedMediaTypes(List<MediaType> supportedMediaTypes) {
95
96
}
96
97
97
98
/**
98
- * Return the configured media types supported by this view.
99
+ * Get the configured media types supported by this view.
99
100
*/
100
101
@ Override
101
102
public List <MediaType > getSupportedMediaTypes () {
@@ -105,31 +106,31 @@ public List<MediaType> getSupportedMediaTypes() {
105
106
/**
106
107
* Set the default charset for this view, used when the
107
108
* {@linkplain #setSupportedMediaTypes(List) content type} does not contain one.
108
- * Default is {@linkplain StandardCharsets#UTF_8 UTF 8}.
109
+ * <p> Default is {@linkplain StandardCharsets#UTF_8 UTF 8}.
109
110
*/
110
111
public void setDefaultCharset (Charset defaultCharset ) {
111
112
Assert .notNull (defaultCharset , "'defaultCharset' must not be null" );
112
113
this .defaultCharset = defaultCharset ;
113
114
}
114
115
115
116
/**
116
- * Return the default charset, used when the
117
+ * Get the default charset, used when the
117
118
* {@linkplain #setSupportedMediaTypes(List) content type} does not contain one.
118
119
*/
119
120
public Charset getDefaultCharset () {
120
121
return this .defaultCharset ;
121
122
}
122
123
123
124
/**
124
- * Set the name of the RequestContext attribute for this view.
125
- * Default is none.
125
+ * Set the name of the {@code RequestContext} attribute for this view.
126
+ * <p> Default is none ({@code null}) .
126
127
*/
127
128
public void setRequestContextAttribute (@ Nullable String requestContextAttribute ) {
128
129
this .requestContextAttribute = requestContextAttribute ;
129
130
}
130
131
131
132
/**
132
- * Return the name of the RequestContext attribute, if any.
133
+ * Get the name of the {@code RequestContext} attribute for this view , if any.
133
134
*/
134
135
@ Nullable
135
136
public String getRequestContextAttribute () {
@@ -146,8 +147,8 @@ public void setBeanName(@Nullable String beanName) {
146
147
}
147
148
148
149
/**
149
- * Return the view's name. Should never be {@code null}, if the view was
150
- * correctly configured.
150
+ * Get the view's name.
151
+ * <p>Should never be {@code null} if the view was correctly configured.
151
152
*/
152
153
@ Nullable
153
154
public String getBeanName () {
@@ -165,9 +166,10 @@ public ApplicationContext getApplicationContext() {
165
166
}
166
167
167
168
/**
168
- * Obtain the ApplicationContext for actual use.
169
- * @return the ApplicationContext (never {@code null})
170
- * @throws IllegalStateException in case of no ApplicationContext set
169
+ * Obtain the {@link ApplicationContext} for actual use.
170
+ * @return the {@code ApplicationContext} (never {@code null})
171
+ * @throws IllegalStateException if the ApplicationContext cannot be obtained
172
+ * @see #getApplicationContext()
171
173
*/
172
174
protected final ApplicationContext obtainApplicationContext () {
173
175
ApplicationContext applicationContext = getApplicationContext ();
@@ -178,12 +180,12 @@ protected final ApplicationContext obtainApplicationContext() {
178
180
179
181
/**
180
182
* Prepare the model to render.
181
- * @param model a Map with name Strings as keys and corresponding model
182
- * objects as values (Map can also be {@code null} in case of empty model)
183
- * @param contentType the content type selected to render with which should
184
- * match one of the {@link #getSupportedMediaTypes() supported media types}.
183
+ * @param model a map with attribute names as keys and corresponding model
184
+ * objects as values (the map can also be {@code null} in case of an empty model)
185
+ * @param contentType the content type selected to render with, which should
186
+ * match one of the {@link #getSupportedMediaTypes() supported media types}
185
187
* @param exchange the current exchange
186
- * @return {@code Mono} to represent when and if rendering succeeds
188
+ * @return a {@code Mono} that represents when and if rendering succeeds
187
189
*/
188
190
@ Override
189
191
public Mono <Void > render (@ Nullable Map <String , ?> model , @ Nullable MediaType contentType ,
@@ -239,9 +241,9 @@ protected Mono<Map<String, Object>> getModelAttributes(
239
241
* Use the configured {@link ReactiveAdapterRegistry} to adapt asynchronous
240
242
* attributes to {@code Mono<T>} or {@code Mono<List<T>>} and then wait to
241
243
* resolve them into actual values. When the returned {@code Mono<Void>}
242
- * completes, the asynchronous attributes in the model would have been
244
+ * completes, the asynchronous attributes in the model will have been
243
245
* replaced with their corresponding resolved values.
244
- * @return result {@code Mono} that completes when the model is ready
246
+ * @return result a {@code Mono} that completes when the model is ready
245
247
* @since 5.1.8
246
248
*/
247
249
protected Mono <Void > resolveAsyncAttributes (Map <String , Object > model , ServerWebExchange exchange ) {
@@ -299,7 +301,7 @@ private void addBindingResult(String name, Object value, Map<String, Object> mod
299
301
* replaced with their corresponding resolved values.
300
302
* @return result {@code Mono} that completes when the model is ready
301
303
* @deprecated as of 5.1.8 this method is still invoked but it is a no-op.
302
- * Please, use {@link #resolveAsyncAttributes(Map, ServerWebExchange)}
304
+ * Please use {@link #resolveAsyncAttributes(Map, ServerWebExchange)}
303
305
* instead. It is invoked after this one and does the actual work.
304
306
*/
305
307
@ Deprecated
@@ -308,27 +310,28 @@ protected Mono<Void> resolveAsyncAttributes(Map<String, Object> model) {
308
310
}
309
311
310
312
/**
311
- * Create a RequestContext to expose under the specified attribute name.
312
- * <p>The default implementation creates a standard RequestContext instance
313
- * for the given request and model. Can be overridden in subclasses for
314
- * custom instances.
315
- * @param exchange current exchange
316
- * @param model combined output Map (never {@code null}),
317
- * with dynamic values taking precedence over static attributes
318
- * @return the RequestContext instance
313
+ * Create a {@link RequestContext} to expose under the
314
+ * {@linkplain #setRequestContextAttribute specified attribute name}.
315
+ * <p>The default implementation creates a standard {@code RequestContext}
316
+ * instance for the given exchange and model.
317
+ * <p>Can be overridden in subclasses to create custom instances.
318
+ * @param exchange the current exchange
319
+ * @param model a combined output Map (never {@code null}), with dynamic values
320
+ * taking precedence over static attributes
321
+ * @return the {@code RequestContext} instance
319
322
* @see #setRequestContextAttribute
320
323
*/
321
324
protected RequestContext createRequestContext (ServerWebExchange exchange , Map <String , Object > model ) {
322
325
return new RequestContext (exchange , model , obtainApplicationContext (), getRequestDataValueProcessor ());
323
326
}
324
327
325
328
/**
326
- * Return the {@link RequestDataValueProcessor} to use.
329
+ * Get the {@link RequestDataValueProcessor} to use.
327
330
* <p>The default implementation looks in the {@link #getApplicationContext()
328
- * Spring configuration } for a {@code RequestDataValueProcessor} bean with
331
+ * ApplicationContext } for a {@code RequestDataValueProcessor} bean with
329
332
* the name {@link #REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME}.
330
- * @return the RequestDataValueProcessor, or null if there is none at the
331
- * application context.
333
+ * @return the {@code RequestDataValueProcessor} , or {@code null} if there is
334
+ * none in the application context
332
335
*/
333
336
@ Nullable
334
337
protected RequestDataValueProcessor getRequestDataValueProcessor () {
@@ -343,10 +346,10 @@ protected RequestDataValueProcessor getRequestDataValueProcessor() {
343
346
* Subclasses must implement this method to actually render the view.
344
347
* @param renderAttributes combined output Map (never {@code null}),
345
348
* with dynamic values taking precedence over static attributes
346
- * @param contentType the content type selected to render with which should
347
- * match one of the {@link #getSupportedMediaTypes() supported media types}.
348
- *@param exchange current exchange @return {@code Mono} to represent when
349
- * and if rendering succeeds
349
+ * @param contentType the content type selected to render with, which should
350
+ * match one of the {@linkplain #getSupportedMediaTypes() supported media types}
351
+ * @param exchange current exchange
352
+ * @return a {@code Mono} that represents when and if rendering succeeds
350
353
*/
351
354
protected abstract Mono <Void > renderInternal (Map <String , Object > renderAttributes ,
352
355
@ Nullable MediaType contentType , ServerWebExchange exchange );
0 commit comments