Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,11 @@
*/
@Configuration
@ConditionalOnClass(ObjectMapper.class)
@EnableConfigurationProperties(HttpMapperProperties.class)
public class JacksonAutoConfiguration {

@Autowired
private HttpMapperProperties properties = new HttpMapperProperties();

@Autowired
private ListableBeanFactory beanFactory;

@Bean
@Primary
@ConditionalOnMissingBean
public ObjectMapper jacksonObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
if (this.properties.isJsonSortKeys()) {
objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
}
return objectMapper;
}

@PostConstruct
private void registerModulesWithObjectMappers() {
Collection<Module> modules = getBeans(Module.class);
Expand All @@ -88,6 +73,27 @@ private <T> Collection<T> getBeans(Class<T> type) {
.values();
}

@Configuration
@ConditionalOnClass(ObjectMapper.class)
@EnableConfigurationProperties(HttpMapperProperties.class)
static class JacksonObjectMapperAutoConfiguration {

@Autowired
private HttpMapperProperties properties = new HttpMapperProperties();

@Bean
@Primary
@ConditionalOnMissingBean
public ObjectMapper jacksonObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
if (this.properties.isJsonSortKeys()) {
objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
}
return objectMapper;
}

}

@Configuration
@ConditionalOnClass(JodaModule.class)
static class JodaModuleAutoConfiguration {
Expand Down