camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lburgazz...@apache.org
Subject camel git commit: "CAMEL-11596: camel-spring-boot - actuator endpoint routes - Get single route only"
Date Wed, 02 Aug 2017 12:35:13 GMT
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 <kkakarla@redhat.com>
Authored: Wed Aug 2 16:12:22 2017 +0530
Committer: Ramu <kkakarla@redhat.com>
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<List<RouteEndpointInfo
     public List<RouteEndpointInfo> invoke() {
         return getRoutesInfo();
     }
+    
+    public RouteEndpointInfo getRouteInfo(String id) {
+        Route route = camelContext.getRoute(id);
+        if (route != null) {
+            return new RouteEndpointInfo(route);
+        }
+
+        return null;
+    }
 
     public List<RouteEndpointInfo> 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
 +


Mime
View raw message