Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id DBFBD200CD8 for ; Wed, 2 Aug 2017 14:35:14 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id DA4EC169540; Wed, 2 Aug 2017 12:35:14 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 04D14169532 for ; Wed, 2 Aug 2017 14:35:13 +0200 (CEST) Received: (qmail 90230 invoked by uid 500); 2 Aug 2017 12:35:13 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 90221 invoked by uid 99); 2 Aug 2017 12:35:13 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Aug 2017 12:35:13 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 19DCCDFF9F; Wed, 2 Aug 2017 12:35:13 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: lburgazzoli@apache.org To: commits@camel.apache.org Message-Id: <4ad75f50a1214269a78b5136afac91fc@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: camel git commit: "CAMEL-11596: camel-spring-boot - actuator endpoint routes - Get single route only" Date: Wed, 2 Aug 2017 12:35:13 +0000 (UTC) archived-at: Wed, 02 Aug 2017 12:35:15 -0000 Repository: camel Updated Branches: refs/heads/master bec5e1dbe -> a9dccdbd0 "CAMEL-11596: camel-spring-boot - actuator endpoint routes - Get single route only" Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a9dccdbd Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a9dccdbd Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a9dccdbd Branch: refs/heads/master Commit: a9dccdbd058b02e64352b13e198ad3846b9412a4 Parents: bec5e1d Author: Ramu Authored: Wed Aug 2 16:12:22 2017 +0530 Committer: Ramu Committed: Wed Aug 2 16:12:22 2017 +0530 ---------------------------------------------------------------------- .../actuate/endpoint/CamelRoutesEndpoint.java | 9 ++++++++ .../endpoint/CamelRoutesMvcEndpoint.java | 23 +++++++++++++++++++- .../endpoint/CamelRoutesMvcEndpointTest.java | 2 +- .../readme.adoc | 7 ++++++ 4 files changed, 39 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/a9dccdbd/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpoint.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpoint.java index 1e24907..eec11ad 100644 --- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpoint.java +++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpoint.java @@ -56,6 +56,15 @@ public class CamelRoutesEndpoint extends AbstractEndpoint invoke() { return getRoutesInfo(); } + + public RouteEndpointInfo getRouteInfo(String id) { + Route route = camelContext.getRoute(id); + if (route != null) { + return new RouteEndpointInfo(route); + } + + return null; + } public List getRoutesInfo() { return camelContext.getRoutes().stream() http://git-wip-us.apache.org/repos/asf/camel/blob/a9dccdbd/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesMvcEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesMvcEndpoint.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesMvcEndpoint.java index a0a09e2..04a0c37 100644 --- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesMvcEndpoint.java +++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesMvcEndpoint.java @@ -57,6 +57,27 @@ public class CamelRoutesMvcEndpoint extends EndpointMvcAdapter { // ******************************************** // Endpoints // ******************************************** + + @ResponseBody + @GetMapping( + value = "/{id}/detail", + produces = { + ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON_VALUE, + MediaType.APPLICATION_JSON_VALUE + } + ) + public Object detail( + @PathVariable String id) { + + return doIfEnabled(() -> { + Object result = delegate.getRouteDetailsInfo(id); + if (result == null) { + throw new NoSuchRouteException("No such route " + id); + } + + return result; + }); + } @ResponseBody @GetMapping( @@ -70,7 +91,7 @@ public class CamelRoutesMvcEndpoint extends EndpointMvcAdapter { @PathVariable String id) { return doIfEnabled(() -> { - Object result = delegate.getRouteDetailsInfo(id); + Object result = delegate.getRouteInfo(id); if (result == null) { throw new NoSuchRouteException("No such route " + id); } http://git-wip-us.apache.org/repos/asf/camel/blob/a9dccdbd/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesMvcEndpointTest.java ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesMvcEndpointTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesMvcEndpointTest.java index 9d752f2..c0b1e45 100644 --- a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesMvcEndpointTest.java +++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesMvcEndpointTest.java @@ -59,7 +59,7 @@ public class CamelRoutesMvcEndpointTest extends Assert { @Test public void testMvcRoutesEndpoint() throws Exception { - Object result = endpoint.info("foo-route"); + Object result = endpoint.detail("foo-route"); assertTrue(result instanceof RouteDetailsEndpointInfo); assertEquals("foo-route", ((RouteDetailsEndpointInfo)result).getId()); http://git-wip-us.apache.org/repos/asf/camel/blob/a9dccdbd/examples/camel-example-spring-boot-routecontroller/readme.adoc ---------------------------------------------------------------------- diff --git a/examples/camel-example-spring-boot-routecontroller/readme.adoc b/examples/camel-example-spring-boot-routecontroller/readme.adoc index 9f26542..f94221d 100644 --- a/examples/camel-example-spring-boot-routecontroller/readme.adoc +++ b/examples/camel-example-spring-boot-routecontroller/readme.adoc @@ -16,6 +16,13 @@ Beside JMX you can use Spring Boot Endpoints to interact with the routes: ---- curl -XGET -s http://localhost:8080/camel/routes ---- ++ ++* To get details about a route +++ ++[source] ++---- ++curl -XGET -s http://localhost:8080/camel/routes/{id}/detail ++---- * To get info about a route +