You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gz...@apache.org on 2017/05/26 08:44:02 UTC
[1/4] camel git commit: CAMEL-11335: Add Actuator endpoint for
exposing Camel routes
Repository: camel
Updated Branches:
refs/heads/master 7f91e92b3 -> 83ee9a5e5
CAMEL-11335: Add Actuator endpoint for exposing Camel routes
Signed-off-by: Gregor Zurowski <gr...@zurowski.org>
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2a05c3b7
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2a05c3b7
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2a05c3b7
Branch: refs/heads/master
Commit: 2a05c3b74937ca734eedbad592cf61fe828180d1
Parents: d900401
Author: Gregor Zurowski <gr...@zurowski.org>
Authored: Fri May 26 09:18:28 2017 +0200
Committer: Gregor Zurowski <gr...@zurowski.org>
Committed: Fri May 26 09:18:28 2017 +0200
----------------------------------------------------------------------
.../actuate/endpoint/CamelRoutesEndpoint.java | 107 +++++++++++++++++++
.../CamelRoutesEndpointAutoConfiguration.java | 47 ++++++++
.../main/resources/META-INF/spring.factories | 1 +
.../actuate/endpoint/ActuatorTestRoute.java | 30 ++++++
.../endpoint/CamelRoutesEndpointTest.java | 57 ++++++++++
5 files changed, 242 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/2a05c3b7/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
new file mode 100644
index 0000000..a110149
--- /dev/null
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpoint.java
@@ -0,0 +1,107 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.boot.actuate.endpoint;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Route;
+import org.apache.camel.spring.boot.actuate.endpoint.CamelRoutesEndpoint.RouteEndpointInfo;
+import org.springframework.boot.actuate.endpoint.Endpoint;
+
+/**
+ * {@link Endpoint} to expose {@link org.apache.camel.Route} information.
+ */
+public class CamelRoutesEndpoint implements Endpoint<List<RouteEndpointInfo>> {
+
+ private static final String ENDPONT_ID = "camelroutes";
+
+ private CamelContext camelContext;
+
+ public CamelRoutesEndpoint(CamelContext camelContext) {
+ this.camelContext = camelContext;
+ }
+
+ @Override
+ public String getId() {
+ return ENDPONT_ID;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isSensitive() {
+ return true;
+ }
+
+ @Override
+ public List<RouteEndpointInfo> invoke() {
+ // @formatter:off
+ return camelContext.getRoutes().stream()
+ .map(r -> new RouteEndpointInfo(r))
+ .collect(Collectors.toList());
+ // @formatter:on
+ }
+
+ /**
+ * Container for exposing {@link org.apache.camel.Route} information as JSON.
+ */
+ @JsonPropertyOrder({"id", "description", "uptime", "uptimeMillis"})
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
+ public static class RouteEndpointInfo {
+
+ private final String id;
+
+ private final String description;
+
+ private final String uptime;
+
+ private final long uptimeMillis;
+
+ public RouteEndpointInfo(Route route) {
+ this.id = route.getId();
+ this.description = route.getDescription();
+ this.uptime = route.getUptime();
+ this.uptimeMillis = route.getUptimeMillis();
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getUptime() {
+ return uptime;
+ }
+
+ public long getUptimeMillis() {
+ return uptimeMillis;
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2a05c3b7/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointAutoConfiguration.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointAutoConfiguration.java
new file mode 100644
index 0000000..628a705
--- /dev/null
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointAutoConfiguration.java
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.boot.actuate.endpoint;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Auto configuration for the {@link CamelRoutesEndpoint}.
+ */
+@Configuration
+@ConditionalOnClass({CamelRoutesEndpoint.class})
+@ConditionalOnBean(CamelAutoConfiguration.class)
+@AutoConfigureAfter(CamelAutoConfiguration.class)
+public class CamelRoutesEndpointAutoConfiguration {
+
+ @ConditionalOnClass({CamelContext.class})
+ @ConditionalOnMissingBean(CamelRoutesEndpoint.class)
+ protected static class CamelEndpointInitializer {
+
+ @Bean
+ public CamelRoutesEndpoint camelEndpoint(CamelContext camelContext) {
+ return new CamelRoutesEndpoint(camelContext);
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2a05c3b7/components/camel-spring-boot/src/main/resources/META-INF/spring.factories
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/main/resources/META-INF/spring.factories b/components/camel-spring-boot/src/main/resources/META-INF/spring.factories
index da3defc..48be2f1 100644
--- a/components/camel-spring-boot/src/main/resources/META-INF/spring.factories
+++ b/components/camel-spring-boot/src/main/resources/META-INF/spring.factories
@@ -17,6 +17,7 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.apache.camel.spring.boot.CamelAutoConfiguration,\
+org.apache.camel.spring.boot.actuate.endpoint.CamelRoutesEndpointAutoConfiguration,\
org.apache.camel.spring.boot.cloud.CamelCloudAutoConfiguration,\
org.apache.camel.spring.boot.cloud.CamelCloudServiceCallConfigurationAutoConfiguration,\
org.apache.camel.spring.boot.cloud.CamelCloudServiceDiscoveryAutoConfiguration,\
http://git-wip-us.apache.org/repos/asf/camel/blob/2a05c3b7/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/ActuatorTestRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/ActuatorTestRoute.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/ActuatorTestRoute.java
new file mode 100644
index 0000000..599f940
--- /dev/null
+++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/ActuatorTestRoute.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.boot.actuate.endpoint;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ActuatorTestRoute extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("timer:foo").routeId("foo-route").to("log:foo");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2a05c3b7/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointTest.java
new file mode 100644
index 0000000..45e2ffb
--- /dev/null
+++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointTest.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.boot.actuate.endpoint;
+
+import java.util.List;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.actuate.endpoint.CamelRoutesEndpoint.RouteEndpointInfo;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * Test for the {@link CamelRoutesEndpoint} actuator endpoint.
+ */
+@RunWith(SpringRunner.class)
+@EnableAutoConfiguration
+@SpringBootApplication
+@SpringBootTest(classes = {CamelAutoConfiguration.class, CamelRoutesEndpointAutoConfiguration.class, ActuatorTestRoute.class})
+public class CamelRoutesEndpointTest extends Assert {
+
+ @Autowired
+ CamelRoutesEndpoint endpoint;
+
+ @Autowired
+ CamelContext camelContext;
+
+ @Test
+ public void testRoutesEndpoint() throws Exception {
+ List<RouteEndpointInfo> routes = endpoint.invoke();
+
+ assertFalse(routes.isEmpty());
+ assertEquals(routes.size(), camelContext.getRoutes().size());
+ assertTrue(routes.stream().anyMatch(r -> "foo-route".equals(r.getId())));
+ }
+
+}
[3/4] camel git commit: CAMEL-11335: [Minor] Polish code
Posted by gz...@apache.org.
CAMEL-11335: [Minor] Polish code
Signed-off-by: Gregor Zurowski <gr...@zurowski.org>
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/75de7806
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/75de7806
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/75de7806
Branch: refs/heads/master
Commit: 75de78061a637dd778633171c2d1fba594a3fda3
Parents: 41a3b4b
Author: Gregor Zurowski <gr...@zurowski.org>
Authored: Fri May 26 10:14:17 2017 +0200
Committer: Gregor Zurowski <gr...@zurowski.org>
Committed: Fri May 26 10:14:17 2017 +0200
----------------------------------------------------------------------
.../camel/spring/boot/actuate/endpoint/CamelRoutesEndpoint.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/75de7806/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 9fa81c2..3f44320 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
@@ -46,7 +46,7 @@ public class CamelRoutesEndpoint extends AbstractEndpoint<List<RouteEndpointInfo
public List<RouteEndpointInfo> invoke() {
// @formatter:off
return camelContext.getRoutes().stream()
- .map(r -> new RouteEndpointInfo(r))
+ .map(RouteEndpointInfo::new)
.collect(Collectors.toList());
// @formatter:on
}
[4/4] camel git commit: Merge branch
'feature/CAMEL-11335-routes-endpoint'
Posted by gz...@apache.org.
Merge branch 'feature/CAMEL-11335-routes-endpoint'
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/83ee9a5e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/83ee9a5e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/83ee9a5e
Branch: refs/heads/master
Commit: 83ee9a5e58375e7bec8795e76f57db2fd6b5558c
Parents: 7f91e92 75de780
Author: Gregor Zurowski <gr...@zurowski.org>
Authored: Fri May 26 09:42:27 2017 +0100
Committer: Gregor Zurowski <gr...@zurowski.org>
Committed: Fri May 26 09:42:27 2017 +0100
----------------------------------------------------------------------
.../actuate/endpoint/CamelRoutesEndpoint.java | 94 ++++++++++++++++++++
.../CamelRoutesEndpointAutoConfiguration.java | 47 ++++++++++
.../main/resources/META-INF/spring.factories | 1 +
.../actuate/endpoint/ActuatorTestRoute.java | 30 +++++++
.../endpoint/CamelRoutesEndpointTest.java | 57 ++++++++++++
5 files changed, 229 insertions(+)
----------------------------------------------------------------------
[2/4] camel git commit: CAMEL-11335: Extend from AbstractEndpoint
instead of implementing Endpoint
Posted by gz...@apache.org.
CAMEL-11335: Extend from AbstractEndpoint instead of implementing Endpoint
Signed-off-by: Gregor Zurowski <gr...@zurowski.org>
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/41a3b4be
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/41a3b4be
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/41a3b4be
Branch: refs/heads/master
Commit: 41a3b4beddd971d716cf65cf72b4d7129ea2292a
Parents: 2a05c3b
Author: Gregor Zurowski <gr...@zurowski.org>
Authored: Fri May 26 10:12:30 2017 +0200
Committer: Gregor Zurowski <gr...@zurowski.org>
Committed: Fri May 26 10:12:30 2017 +0200
----------------------------------------------------------------------
.../actuate/endpoint/CamelRoutesEndpoint.java | 21 ++++----------------
1 file changed, 4 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/41a3b4be/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 a110149..9fa81c2 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
@@ -25,37 +25,24 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.apache.camel.CamelContext;
import org.apache.camel.Route;
import org.apache.camel.spring.boot.actuate.endpoint.CamelRoutesEndpoint.RouteEndpointInfo;
+import org.springframework.boot.actuate.endpoint.AbstractEndpoint;
import org.springframework.boot.actuate.endpoint.Endpoint;
/**
* {@link Endpoint} to expose {@link org.apache.camel.Route} information.
*/
-public class CamelRoutesEndpoint implements Endpoint<List<RouteEndpointInfo>> {
+public class CamelRoutesEndpoint extends AbstractEndpoint<List<RouteEndpointInfo>> {
- private static final String ENDPONT_ID = "camelroutes";
+ private static final String ENDPOINT_ID = "camelroutes";
private CamelContext camelContext;
public CamelRoutesEndpoint(CamelContext camelContext) {
+ super(ENDPOINT_ID);
this.camelContext = camelContext;
}
@Override
- public String getId() {
- return ENDPONT_ID;
- }
-
- @Override
- public boolean isEnabled() {
- return true;
- }
-
- @Override
- public boolean isSensitive() {
- return true;
- }
-
- @Override
public List<RouteEndpointInfo> invoke() {
// @formatter:off
return camelContext.getRoutes().stream()