1
1
/*
2
- * Copyright 2012-2017 the original author or authors.
2
+ * Copyright 2012-2018 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
18
18
19
19
import com .fasterxml .jackson .databind .ObjectMapper ;
20
20
21
- import org .springframework .beans .BeansException ;
22
- import org .springframework .beans .factory .BeanFactory ;
23
- import org .springframework .beans .factory .BeanFactoryAware ;
24
- import org .springframework .beans .factory .NoSuchBeanDefinitionException ;
25
- import org .springframework .beans .factory .config .BeanPostProcessor ;
26
21
import org .springframework .boot .autoconfigure .AutoConfigureAfter ;
27
22
import org .springframework .boot .autoconfigure .EnableAutoConfiguration ;
28
23
import org .springframework .boot .autoconfigure .condition .ConditionalOnClass ;
33
28
import org .springframework .boot .autoconfigure .jackson .JacksonAutoConfiguration ;
34
29
import org .springframework .boot .autoconfigure .web .servlet .WebMvcAutoConfiguration ;
35
30
import org .springframework .boot .context .properties .EnableConfigurationProperties ;
36
- import org .springframework .context .annotation .Bean ;
37
31
import org .springframework .context .annotation .Configuration ;
38
32
import org .springframework .context .annotation .Import ;
39
33
import org .springframework .hateoas .EntityLinks ;
42
36
import org .springframework .hateoas .config .EnableEntityLinks ;
43
37
import org .springframework .hateoas .config .EnableHypermediaSupport ;
44
38
import org .springframework .hateoas .config .EnableHypermediaSupport .HypermediaType ;
45
- import org .springframework .http .converter .json .Jackson2ObjectMapperBuilder ;
46
39
import org .springframework .plugin .core .Plugin ;
47
40
import org .springframework .web .bind .annotation .RequestMapping ;
48
41
@@ -71,11 +64,6 @@ public class HypermediaAutoConfiguration {
71
64
@ EnableHypermediaSupport (type = HypermediaType .HAL )
72
65
protected static class HypermediaConfiguration {
73
66
74
- @ Bean
75
- public static HalObjectMapperConfigurer halObjectMapperConfigurer () {
76
- return new HalObjectMapperConfigurer ();
77
- }
78
-
79
67
}
80
68
81
69
@ Configuration
@@ -85,46 +73,4 @@ protected static class EntityLinksConfiguration {
85
73
86
74
}
87
75
88
- /**
89
- * {@link BeanPostProcessor} to apply any {@link Jackson2ObjectMapperBuilder}
90
- * configuration to the HAL {@link ObjectMapper}.
91
- */
92
- private static class HalObjectMapperConfigurer
93
- implements BeanPostProcessor , BeanFactoryAware {
94
-
95
- private BeanFactory beanFactory ;
96
-
97
- @ Override
98
- public Object postProcessBeforeInitialization (Object bean , String beanName )
99
- throws BeansException {
100
- if (bean instanceof ObjectMapper && "_halObjectMapper" .equals (beanName )) {
101
- postProcessHalObjectMapper ((ObjectMapper ) bean );
102
- }
103
- return bean ;
104
- }
105
-
106
- private void postProcessHalObjectMapper (ObjectMapper objectMapper ) {
107
- try {
108
- Jackson2ObjectMapperBuilder builder = this .beanFactory
109
- .getBean (Jackson2ObjectMapperBuilder .class );
110
- builder .configure (objectMapper );
111
- }
112
- catch (NoSuchBeanDefinitionException ex ) {
113
- // No Jackson configuration required
114
- }
115
- }
116
-
117
- @ Override
118
- public Object postProcessAfterInitialization (Object bean , String beanName )
119
- throws BeansException {
120
- return bean ;
121
- }
122
-
123
- @ Override
124
- public void setBeanFactory (BeanFactory beanFactory ) throws BeansException {
125
- this .beanFactory = beanFactory ;
126
- }
127
-
128
- }
129
-
130
76
}
0 commit comments