#1591 - Polishing.
Port configuration lookup caching from HAL FORMS into HAL configuration.
This commit is contained in:
@@ -46,6 +46,8 @@ public class HalMediaTypeConfiguration implements HypermediaMappingInformation {
|
||||
private final @Qualifier("messageResolver") MessageResolver resolver;
|
||||
private final AutowireCapableBeanFactory beanFactory;
|
||||
|
||||
private HalConfiguration resolvedConfiguration;
|
||||
|
||||
public HalMediaTypeConfiguration(LinkRelationProvider relProvider, ObjectProvider<CurieProvider> curieProvider,
|
||||
ObjectProvider<HalConfiguration> halConfiguration, MessageResolver resolver,
|
||||
AutowireCapableBeanFactory beanFactory) {
|
||||
@@ -68,7 +70,7 @@ public class HalMediaTypeConfiguration implements HypermediaMappingInformation {
|
||||
*/
|
||||
@Override
|
||||
public List<MediaType> getMediaTypes() {
|
||||
return this.halConfiguration.getIfAvailable(HalConfiguration::new).getMediaTypes();
|
||||
return getResolvedConfiguration().getMediaTypes();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -78,7 +80,7 @@ public class HalMediaTypeConfiguration implements HypermediaMappingInformation {
|
||||
@Override
|
||||
public ObjectMapper configureObjectMapper(ObjectMapper mapper) {
|
||||
|
||||
HalConfiguration halConfiguration = this.halConfiguration.getIfAvailable(HalConfiguration::new);
|
||||
HalConfiguration halConfiguration = getResolvedConfiguration();
|
||||
|
||||
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||
mapper.registerModule(new Jackson2HalModule());
|
||||
@@ -89,4 +91,18 @@ public class HalMediaTypeConfiguration implements HypermediaMappingInformation {
|
||||
|
||||
return mapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup and cache the {@link HalConfiguration} instance to be used.
|
||||
*
|
||||
* @return will never be {@literal null}.
|
||||
*/
|
||||
private HalConfiguration getResolvedConfiguration() {
|
||||
|
||||
if (resolvedConfiguration == null) {
|
||||
this.resolvedConfiguration = halConfiguration.getIfAvailable(HalConfiguration::new);
|
||||
}
|
||||
|
||||
return resolvedConfiguration;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user