|
19 | 19 | import java.time.Duration;
|
20 | 20 | import java.util.ArrayList;
|
21 | 21 | import java.util.Arrays;
|
22 |
| -import java.util.Collection; |
23 | 22 | import java.util.Collections;
|
24 | 23 | import java.util.List;
|
25 | 24 | import java.util.ListIterator;
|
|
55 | 54 | import org.springframework.boot.autoconfigure.web.ResourceProperties.Strategy;
|
56 | 55 | import org.springframework.boot.autoconfigure.web.format.WebConversionService;
|
57 | 56 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
58 |
| -import org.springframework.boot.convert.ParserConverter; |
59 |
| -import org.springframework.boot.convert.PrinterConverter; |
| 57 | +import org.springframework.boot.convert.ApplicationConversionService; |
60 | 58 | import org.springframework.boot.web.servlet.filter.OrderedFormContentFilter;
|
61 | 59 | import org.springframework.boot.web.servlet.filter.OrderedHiddenHttpMethodFilter;
|
62 | 60 | import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter;
|
|
68 | 66 | import org.springframework.context.annotation.Primary;
|
69 | 67 | import org.springframework.core.Ordered;
|
70 | 68 | import org.springframework.core.annotation.Order;
|
71 |
| -import org.springframework.core.convert.converter.Converter; |
72 |
| -import org.springframework.core.convert.converter.GenericConverter; |
73 | 69 | import org.springframework.core.io.ClassPathResource;
|
74 | 70 | import org.springframework.core.io.Resource;
|
75 | 71 | import org.springframework.core.io.ResourceLoader;
|
76 | 72 | import org.springframework.core.task.AsyncTaskExecutor;
|
77 |
| -import org.springframework.format.Formatter; |
78 | 73 | import org.springframework.format.FormatterRegistry;
|
79 |
| -import org.springframework.format.Parser; |
80 |
| -import org.springframework.format.Printer; |
81 | 74 | import org.springframework.format.support.FormattingConversionService;
|
82 | 75 | import org.springframework.http.CacheControl;
|
83 | 76 | import org.springframework.http.MediaType;
|
@@ -302,29 +295,7 @@ public MessageCodesResolver getMessageCodesResolver() {
|
302 | 295 |
|
303 | 296 | @Override
|
304 | 297 | public void addFormatters(FormatterRegistry registry) {
|
305 |
| - for (Converter<?, ?> converter : getBeansOfType(Converter.class)) { |
306 |
| - registry.addConverter(converter); |
307 |
| - } |
308 |
| - for (GenericConverter converter : getBeansOfType(GenericConverter.class)) { |
309 |
| - registry.addConverter(converter); |
310 |
| - } |
311 |
| - for (Formatter<?> formatter : getBeansOfType(Formatter.class)) { |
312 |
| - registry.addFormatter(formatter); |
313 |
| - } |
314 |
| - for (Printer<?> printer : getBeansOfType(Printer.class)) { |
315 |
| - if (!(printer instanceof Formatter<?>)) { |
316 |
| - registry.addConverter(new PrinterConverter(printer)); |
317 |
| - } |
318 |
| - } |
319 |
| - for (Parser<?> parser : getBeansOfType(Parser.class)) { |
320 |
| - if (!(parser instanceof Formatter<?>)) { |
321 |
| - registry.addConverter(new ParserConverter(parser)); |
322 |
| - } |
323 |
| - } |
324 |
| - } |
325 |
| - |
326 |
| - private <T> Collection<T> getBeansOfType(Class<T> type) { |
327 |
| - return this.beanFactory.getBeansOfType(type).values(); |
| 298 | + ApplicationConversionService.addBeans(registry, this.beanFactory); |
328 | 299 | }
|
329 | 300 |
|
330 | 301 | @Override
|
|
0 commit comments