43
43
import org .springframework .web .servlet .function .support .RouterFunctionMapping ;
44
44
import org .springframework .web .servlet .handler .BeanNameUrlHandlerMapping ;
45
45
import org .springframework .web .servlet .handler .HandlerMappingIntrospector ;
46
- import org .springframework .web .servlet .handler .SimpleUrlHandlerMapping ;
47
46
import org .springframework .web .servlet .mvc .HttpRequestHandlerAdapter ;
48
47
import org .springframework .web .servlet .mvc .SimpleControllerHandlerAdapter ;
49
48
import org .springframework .web .servlet .mvc .method .annotation .RequestMappingHandlerAdapter ;
59
58
import static org .springframework .boot .autoconfigure .web .servlet .WebMvcAutoConfiguration .ResourceChainResourceHandlerRegistrationCustomizer ;
60
59
import static org .springframework .boot .autoconfigure .web .servlet .WebMvcAutoConfiguration .ResourceHandlerRegistrationCustomizer ;
61
60
import static org .springframework .boot .autoconfigure .web .servlet .WebMvcAutoConfiguration .WebMvcAutoConfigurationAdapter ;
62
- import static org .springframework .boot .autoconfigure .web .servlet .WebMvcAutoConfiguration .WebMvcAutoConfigurationAdapter .FaviconConfiguration ;
63
- import static org .springframework .boot .autoconfigure .web .servlet .WebMvcAutoConfiguration .WebMvcAutoConfigurationAdapter .FaviconRequestHandler ;
64
61
65
62
public class ServletWebServerInitializer implements ApplicationContextInitializer <GenericApplicationContext > {
66
63
@@ -111,7 +108,6 @@ public void initialize(GenericApplicationContext context) {
111
108
public WebMvcAutoConfigurationAdapter get () {
112
109
if (configuration == null ) {
113
110
configuration = new WebMvcAutoConfigurationAdapter (resourceProperties , webMvcProperties , context , context .getBeanProvider (HttpMessageConverters .class ), context .getBeanProvider (ResourceHandlerRegistrationCustomizer .class ));
114
- configuration .setResourceLoader (context );
115
111
return configuration ;
116
112
}
117
113
return configuration ;
@@ -121,12 +117,8 @@ public WebMvcAutoConfigurationAdapter get() {
121
117
context .registerBean (BeanNameViewResolver .class , () -> webMvcConfigurationAdapter .get ().beanNameViewResolver ());
122
118
context .registerBean ("viewResolver" , ContentNegotiatingViewResolver .class , () -> webMvcConfigurationAdapter .get ().viewResolver (context ));
123
119
context .registerBean (LocaleResolver .class , () -> webMvcConfigurationAdapter .get ().localeResolver ());
124
- context .registerBean (WelcomePageHandlerMapping .class , () -> webMvcConfigurationAdapter .get ().welcomePageHandlerMapping (context ));
125
120
context .registerBean (RequestContextFilter .class , WebMvcAutoConfigurationAdapter ::requestContextFilter );
126
- FaviconConfiguration faviconConfiguration = new FaviconConfiguration (resourceProperties );
127
- faviconConfiguration .setResourceLoader (context );
128
- context .registerBean (FaviconRequestHandler .class , faviconConfiguration ::faviconRequestHandler );
129
- context .registerBean (SimpleUrlHandlerMapping .class , () -> faviconConfiguration .faviconHandlerMapping (context .getBean (FaviconRequestHandler .class )));
121
+ // TODO Favicon management
130
122
131
123
Supplier <EnableWebMvcConfiguration > enableWebMvcConfiguration = new Supplier <EnableWebMvcConfiguration >() {
132
124
@@ -138,6 +130,7 @@ public EnableWebMvcConfiguration get() {
138
130
configuration = new EnableWebMvcConfigurationWrapper (context .getBeanProvider (WebMvcProperties .class ), context .getBeanProvider (WebMvcRegistrations .class ), context );
139
131
configuration .setApplicationContext (context );
140
132
configuration .setServletContext (((WebApplicationContext ) context ).getServletContext ());
133
+ configuration .setResourceLoader (context );
141
134
}
142
135
return configuration ;
143
136
}
@@ -163,12 +156,13 @@ public EnableWebMvcConfiguration get() {
163
156
context .registerBean (HandlerExceptionResolver .class , () -> enableWebMvcConfiguration .get ().handlerExceptionResolver (context .getBean (ContentNegotiationManager .class )));
164
157
context .registerBean (ViewResolver .class , () -> enableWebMvcConfiguration .get ().mvcViewResolver (context .getBean (ContentNegotiationManager .class )));
165
158
context .registerBean (HandlerMappingIntrospector .class , () -> enableWebMvcConfiguration .get ().mvcHandlerMappingIntrospector (), bd -> bd .setLazyInit (true ));
159
+ context .registerBean (WelcomePageHandlerMapping .class , () -> enableWebMvcConfiguration .get ().welcomePageHandlerMapping (context , context .getBean (FormattingConversionService .class ), context .getBean (ResourceUrlProvider .class )));
166
160
}
167
161
168
162
private class EnableWebMvcConfigurationWrapper extends EnableWebMvcConfiguration {
169
163
170
164
public EnableWebMvcConfigurationWrapper (ObjectProvider <WebMvcProperties > mvcPropertiesProvider , ObjectProvider <WebMvcRegistrations > mvcRegistrationsProvider , ListableBeanFactory beanFactory ) {
171
- super (mvcPropertiesProvider , mvcRegistrationsProvider , beanFactory );
165
+ super (resourceProperties , mvcPropertiesProvider , mvcRegistrationsProvider , beanFactory );
172
166
}
173
167
174
168
@ Override
0 commit comments