Skip to content

Commit be64096

Browse files
committed
Support resolution of HAL link titles from a resource bundle
Spring HATEOAS 0.19.0.RELEASE provide support for resolving a link’s title by looking up the key _links.$rel.title. For us to take advantage of this in Spring Boot, HalHandlerInstantiator must be created using the link relation message source that’s automatically created by HateoasConfiguration. Closes spring-projectsgh-3860
1 parent 378ce12 commit be64096

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hateoas/HypermediaAutoConfiguration.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.springframework.boot.context.properties.EnableConfigurationProperties;
3737
import org.springframework.context.annotation.Bean;
3838
import org.springframework.context.annotation.Configuration;
39+
import org.springframework.context.support.MessageSourceAccessor;
3940
import org.springframework.hateoas.EntityLinks;
4041
import org.springframework.hateoas.LinkDiscoverers;
4142
import org.springframework.hateoas.RelProvider;
@@ -89,6 +90,10 @@ protected static class HalObjectMapperConfiguration {
8990
@Autowired(required = false)
9091
private ObjectMapper primaryObjectMapper;
9192

93+
@Autowired
94+
@Qualifier("linkRelationMessageSource")
95+
private MessageSourceAccessor linkRelationMessageSource;
96+
9297
@PostConstruct
9398
public void configurePrimaryObjectMapper() {
9499
if (this.primaryObjectMapper != null
@@ -101,7 +106,8 @@ private void registerHalModule(ObjectMapper objectMapper) {
101106
objectMapper.registerModule(new Jackson2HalModule());
102107
Jackson2HalModule.HalHandlerInstantiator instantiator = new Jackson2HalModule.HalHandlerInstantiator(
103108
HalObjectMapperConfiguration.this.relProvider,
104-
HalObjectMapperConfiguration.this.curieProvider, null);
109+
HalObjectMapperConfiguration.this.curieProvider,
110+
this.linkRelationMessageSource);
105111
objectMapper.setHandlerInstantiator(instantiator);
106112
}
107113

0 commit comments

Comments
 (0)