16
16
package org .springframework .data .web .config ;
17
17
18
18
import java .util .List ;
19
- import java .util .Optional ;
20
19
21
20
import org .springframework .beans .factory .BeanClassLoaderAware ;
22
21
import org .springframework .beans .factory .ObjectFactory ;
23
- import org .springframework .beans .factory .annotation .Autowired ;
24
22
import org .springframework .beans .factory .annotation .Qualifier ;
25
23
import org .springframework .context .ApplicationContext ;
26
24
import org .springframework .context .annotation .Bean ;
@@ -66,9 +64,8 @@ public class SpringDataWebConfiguration implements WebMvcConfigurer, BeanClassLo
66
64
67
65
private final Lazy <SortHandlerMethodArgumentResolver > sortResolver ;
68
66
private final Lazy <PageableHandlerMethodArgumentResolver > pageableResolver ;
69
-
70
- private @ Autowired Optional <PageableHandlerMethodArgumentResolverCustomizer > pageableResolverCustomizer ;
71
- private @ Autowired Optional <SortHandlerMethodArgumentResolverCustomizer > sortResolverCustomizer ;
67
+ private final Lazy <PageableHandlerMethodArgumentResolverCustomizer > pageableResolverCustomizer ;
68
+ private final Lazy <SortHandlerMethodArgumentResolverCustomizer > sortResolverCustomizer ;
72
69
73
70
public SpringDataWebConfiguration (ApplicationContext context ,
74
71
@ Qualifier ("mvcConversionService" ) ObjectFactory <ConversionService > conversionService ) {
@@ -77,10 +74,15 @@ public SpringDataWebConfiguration(ApplicationContext context,
77
74
Assert .notNull (conversionService , "ConversionService must not be null!" );
78
75
79
76
this .context = context ;
77
+
80
78
this .conversionService = conversionService ;
81
79
this .sortResolver = Lazy .of (() -> context .getBean ("sortResolver" , SortHandlerMethodArgumentResolver .class ));
82
- this .pageableResolver = Lazy
83
- .of (() -> context .getBean ("pageableResolver" , PageableHandlerMethodArgumentResolver .class ));
80
+ this .pageableResolver = Lazy .of ( //
81
+ () -> context .getBean ("pageableResolver" , PageableHandlerMethodArgumentResolver .class ));
82
+ this .pageableResolverCustomizer = Lazy .of ( //
83
+ () -> context .getBeanProvider (PageableHandlerMethodArgumentResolverCustomizer .class ).getIfAvailable ());
84
+ this .sortResolverCustomizer = Lazy .of ( //
85
+ () -> context .getBeanProvider (SortHandlerMethodArgumentResolverCustomizer .class ).getIfAvailable ());
84
86
}
85
87
86
88
/*
@@ -181,11 +183,11 @@ public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
181
183
}
182
184
183
185
protected void customizePageableResolver (PageableHandlerMethodArgumentResolver pageableResolver ) {
184
- pageableResolverCustomizer .ifPresent (c -> c .customize (pageableResolver ));
186
+ pageableResolverCustomizer .getOptional (). ifPresent (c -> c .customize (pageableResolver ));
185
187
}
186
188
187
189
protected void customizeSortResolver (SortHandlerMethodArgumentResolver sortResolver ) {
188
- sortResolverCustomizer .ifPresent (c -> c .customize (sortResolver ));
190
+ sortResolverCustomizer .getOptional (). ifPresent (c -> c .customize (sortResolver ));
189
191
}
190
192
191
193
private void forwardBeanClassLoader (BeanClassLoaderAware target ) {
0 commit comments