16
16
17
17
package org .springframework .boot .autoconfigure .hateoas ;
18
18
19
- import javax .annotation .PostConstruct ;
20
-
21
19
import org .springframework .beans .BeansException ;
22
20
import org .springframework .beans .factory .BeanFactory ;
23
21
import org .springframework .beans .factory .BeanFactoryAware ;
24
22
import org .springframework .beans .factory .NoSuchBeanDefinitionException ;
25
- import org .springframework .beans .factory .annotation .Autowired ;
26
- import org .springframework .beans .factory .annotation .Qualifier ;
27
23
import org .springframework .beans .factory .config .BeanPostProcessor ;
28
24
import org .springframework .boot .autoconfigure .AutoConfigureAfter ;
29
25
import org .springframework .boot .autoconfigure .EnableAutoConfiguration ;
33
29
import org .springframework .boot .autoconfigure .jackson .JacksonAutoConfiguration ;
34
30
import org .springframework .boot .autoconfigure .web .HttpMessageConvertersAutoConfiguration ;
35
31
import org .springframework .boot .autoconfigure .web .WebMvcAutoConfiguration ;
36
- import org .springframework .boot .context .properties .EnableConfigurationProperties ;
37
32
import org .springframework .context .annotation .Bean ;
38
33
import org .springframework .context .annotation .Configuration ;
39
34
import org .springframework .hateoas .EntityLinks ;
40
35
import org .springframework .hateoas .LinkDiscoverers ;
41
- import org .springframework .hateoas .RelProvider ;
42
36
import org .springframework .hateoas .Resource ;
43
37
import org .springframework .hateoas .config .EnableEntityLinks ;
44
38
import org .springframework .hateoas .config .EnableHypermediaSupport ;
45
39
import org .springframework .hateoas .config .EnableHypermediaSupport .HypermediaType ;
46
- import org .springframework .hateoas .hal .CurieProvider ;
47
- import org .springframework .hateoas .hal .Jackson2HalModule ;
48
40
import org .springframework .http .converter .json .Jackson2ObjectMapperBuilder ;
49
41
import org .springframework .plugin .core .Plugin ;
50
42
import org .springframework .web .bind .annotation .RequestMapping ;
65
57
@ ConditionalOnWebApplication
66
58
@ AutoConfigureAfter ({ WebMvcAutoConfiguration .class , JacksonAutoConfiguration .class ,
67
59
HttpMessageConvertersAutoConfiguration .class })
68
- @ EnableConfigurationProperties (HateoasProperties .class )
69
60
public class HypermediaAutoConfiguration {
70
61
71
62
@ Configuration
@@ -76,35 +67,6 @@ protected static class HypermediaConfiguration {
76
67
@ ConditionalOnClass ({ Jackson2ObjectMapperBuilder .class , ObjectMapper .class })
77
68
protected static class HalObjectMapperConfiguration {
78
69
79
- @ Autowired
80
- private HateoasProperties hateoasProperties ;
81
-
82
- @ Autowired (required = false )
83
- private CurieProvider curieProvider ;
84
-
85
- @ Autowired
86
- @ Qualifier ("_relProvider" )
87
- private RelProvider relProvider ;
88
-
89
- @ Autowired (required = false )
90
- private ObjectMapper primaryObjectMapper ;
91
-
92
- @ PostConstruct
93
- public void configurePrimaryObjectMapper () {
94
- if (this .primaryObjectMapper != null
95
- && this .hateoasProperties .isApplyToPrimaryObjectMapper ()) {
96
- registerHalModule (this .primaryObjectMapper );
97
- }
98
- }
99
-
100
- private void registerHalModule (ObjectMapper objectMapper ) {
101
- objectMapper .registerModule (new Jackson2HalModule ());
102
- Jackson2HalModule .HalHandlerInstantiator instantiator = new Jackson2HalModule .HalHandlerInstantiator (
103
- HalObjectMapperConfiguration .this .relProvider ,
104
- HalObjectMapperConfiguration .this .curieProvider );
105
- objectMapper .setHandlerInstantiator (instantiator );
106
- }
107
-
108
70
@ Bean
109
71
public static HalObjectMapperConfigurer halObjectMapperConfigurer () {
110
72
return new HalObjectMapperConfigurer ();
0 commit comments