1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.bremersee.xml.test.app;
18
19 import java.util.ServiceLoader;
20 import org.bremersee.xml.JaxbContextBuilder;
21 import org.bremersee.xml.JaxbContextDataProvider;
22 import org.bremersee.xml.http.codec.ReactiveJaxbDecoder;
23 import org.bremersee.xml.http.codec.ReactiveJaxbEncoder;
24 import org.springframework.boot.SpringBootConfiguration;
25 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
26
27 import org.springframework.context.annotation.ComponentScan;
28 import org.springframework.http.codec.ServerCodecConfigurer;
29 import org.springframework.web.reactive.config.EnableWebFlux;
30 import org.springframework.web.reactive.config.WebFluxConfigurer;
31
32
33
34
35
36
37 @SpringBootConfiguration
38 @EnableAutoConfiguration
39 @EnableWebFlux
40 @ComponentScan(basePackageClasses = {WebConfiguration.class})
41 public class WebConfiguration implements WebFluxConfigurer {
42
43 private final JaxbContextBuilder jaxbContextBuilder;
44
45
46
47
48 public WebConfiguration() {
49 jaxbContextBuilder = JaxbContextBuilder
50 .newInstance()
51 .processAll(ServiceLoader.load(JaxbContextDataProvider.class));
52 }
53
54 @Override
55 public void configureHttpMessageCodecs(ServerCodecConfigurer configurer) {
56 configurer
57 .customCodecs()
58 .registerWithDefaultConfig(new ReactiveJaxbDecoder(jaxbContextBuilder));
59 configurer
60 .customCodecs()
61 .registerWithDefaultConfig(new ReactiveJaxbEncoder(jaxbContextBuilder));
62 }
63
64 }