From f77a3c7fa8b37beba0a5864f49529f7a0c14ae9d Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Wed, 4 Jan 2017 12:46:22 +0100 Subject: [PATCH 1/2] moved template to Bean so it can be intercepted by sleuth --- .../weave/socks/orders/config/RestProxyTemplate.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/works/weave/socks/orders/config/RestProxyTemplate.java b/src/main/java/works/weave/socks/orders/config/RestProxyTemplate.java index 6d28831..174bb9a 100644 --- a/src/main/java/works/weave/socks/orders/config/RestProxyTemplate.java +++ b/src/main/java/works/weave/socks/orders/config/RestProxyTemplate.java @@ -6,6 +6,8 @@ import org.springframework.http.client.SimpleClientHttpRequestFactory; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; +import org.springframework.context.annotation.Bean; +import org.springframework.beans.factory.annotation.Autowired; import javax.annotation.PostConstruct; import java.net.InetSocketAddress; @@ -15,7 +17,12 @@ public final class RestProxyTemplate { private final Logger logger = LoggerFactory.getLogger(getClass()); - private RestTemplate restTemplate = new RestTemplate(); + @Autowired RestTemplate restTemplate; + + @Bean + public RestTemplate restTemplate() { + return new RestTemplate(); + } @Value("${proxy.host:}") private String host; From d4159fb36a8e4c7f86b15de449ad228e48eea996 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Wed, 4 Jan 2017 17:19:21 +0100 Subject: [PATCH 2/2] moved from modifified RestService to proxy to get get requests working for tracing --- .../java/works/weave/socks/orders/services/AsyncGetService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/works/weave/socks/orders/services/AsyncGetService.java b/src/main/java/works/weave/socks/orders/services/AsyncGetService.java index dc49cc1..901c621 100644 --- a/src/main/java/works/weave/socks/orders/services/AsyncGetService.java +++ b/src/main/java/works/weave/socks/orders/services/AsyncGetService.java @@ -56,7 +56,7 @@ public Future> getResource(URI url, TypeReferences.ResourceType< InterruptedException, IOException { RequestEntity request = RequestEntity.get(url).accept(HAL_JSON).build(); LOG.debug("Requesting: " + request.toString()); - Resource body = halTemplate.exchange(request, type).getBody(); + Resource body = restProxyTemplate.getRestTemplate().exchange(request, type).getBody(); LOG.debug("Received: " + body.toString()); return new AsyncResult<>(body); }