From be640965a683135f20559f12f48d1eeb4aa696c2 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 1 Sep 2015 15:20:36 +0100 Subject: [PATCH] Support resolution of HAL link titles from a resource bundle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 gh-3860 --- .../hateoas/HypermediaAutoConfiguration.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hateoas/HypermediaAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hateoas/HypermediaAutoConfiguration.java index 8c66a5c90e..d9e3665667 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hateoas/HypermediaAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hateoas/HypermediaAutoConfiguration.java @@ -36,6 +36,7 @@ import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.support.MessageSourceAccessor; import org.springframework.hateoas.EntityLinks; import org.springframework.hateoas.LinkDiscoverers; import org.springframework.hateoas.RelProvider; @@ -89,6 +90,10 @@ public class HypermediaAutoConfiguration { @Autowired(required = false) private ObjectMapper primaryObjectMapper; + @Autowired + @Qualifier("linkRelationMessageSource") + private MessageSourceAccessor linkRelationMessageSource; + @PostConstruct public void configurePrimaryObjectMapper() { if (this.primaryObjectMapper != null @@ -101,7 +106,8 @@ public class HypermediaAutoConfiguration { objectMapper.registerModule(new Jackson2HalModule()); Jackson2HalModule.HalHandlerInstantiator instantiator = new Jackson2HalModule.HalHandlerInstantiator( HalObjectMapperConfiguration.this.relProvider, - HalObjectMapperConfiguration.this.curieProvider, null); + HalObjectMapperConfiguration.this.curieProvider, + this.linkRelationMessageSource); objectMapper.setHandlerInstantiator(instantiator); }