You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2021/11/15 16:55:33 UTC
[camel-spring-boot] branch camel-spring-boot-3.12.x updated (a45eb32 -> 3c008c7)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch camel-spring-boot-3.12.x
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git.
from a45eb32 stop generating unused README.adoc
new 8c866cd Cleanup
new 3c008c7 Fixed Main branch: There are still reference to spring-boot docs maven plugin
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
catalog/camel-catalog-provider-springboot/pom.xml | 22 ----
core/camel-spring-boot/pom.xml | 4 +-
.../src/main/docs/spring-boot.adoc | 4 +-
.../src/main/docs/spring-boot.json | 14 +--
.../endpoint/CamelRouteControllerEndpoint.java | 4 +-
...elRouteControllerEndpointAutoConfiguration.java | 6 +-
.../boot/actuate/endpoint/CamelRoutesEndpoint.java | 119 +++++++--------------
.../CamelRoutesEndpointAutoConfiguration.java | 13 +--
.../endpoint/CamelRoutesEndpointProperties.java | 15 +--
.../additional-spring-configuration-metadata.json | 18 ----
.../src/main/resources/META-INF/spring.factories | 2 +
.../CamelRouteControllerEndpointEnabledTest.java | 4 +-
...erEndpointGloballyDisabledAndReenabledTest.java | 29 ++---
.../endpoint/CamelRouteControllerEndpointTest.java | 25 ++---
.../endpoint/CamelRoutesEndpointEnabledTest.java | 3 +-
... CamelRoutesEndpointReadOnlyOperationTest.java} | 16 +--
.../CamelRoutesEndpointWriteOperationTest.java | 18 ++--
.../modules/ROOT/pages/spring-boot.adoc | 4 +-
18 files changed, 110 insertions(+), 210 deletions(-)
copy core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/{CamelRoutesEndpointWriteOperationTest.java => CamelRoutesEndpointReadOnlyOperationTest.java} (83%)
[camel-spring-boot] 02/02: Fixed Main branch: There are still reference to spring-boot docs maven plugin
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-spring-boot-3.12.x
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git
commit 3c008c7c6fa574541f4a15e52acc32605fa36a56
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Nov 8 18:12:44 2021 +0100
Fixed Main branch: There are still reference to spring-boot docs maven plugin
---
catalog/camel-catalog-provider-springboot/pom.xml | 22 ----------------------
.../modules/ROOT/pages/spring-boot.adoc | 4 +---
2 files changed, 1 insertion(+), 25 deletions(-)
diff --git a/catalog/camel-catalog-provider-springboot/pom.xml b/catalog/camel-catalog-provider-springboot/pom.xml
index 48b73fa..a236b8c 100644
--- a/catalog/camel-catalog-provider-springboot/pom.xml
+++ b/catalog/camel-catalog-provider-springboot/pom.xml
@@ -69,27 +69,5 @@
</dependencies>
- <build>
- <plugins>
-
- <!-- update docs -->
- <plugin>
- <groupId>org.apache.camel.springboot</groupId>
- <artifactId>camel-spring-boot-docs-maven-plugin</artifactId>
- <version>${project.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>update-doc-components-list</goal>
- </goals>
- <phase>process-resources</phase>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
-
- </build>
-
</project>
diff --git a/docs/spring-boot/modules/ROOT/pages/spring-boot.adoc b/docs/spring-boot/modules/ROOT/pages/spring-boot.adoc
index 43a1fd3..76470ac 100644
--- a/docs/spring-boot/modules/ROOT/pages/spring-boot.adoc
+++ b/docs/spring-boot/modules/ROOT/pages/spring-boot.adoc
@@ -264,11 +264,9 @@ The component supports 173 options, which are listed below.
| *camel.threadpool.rejected-policy* | Sets the default handler for tasks which cannot be executed by the thread pool. | | ThreadPoolRejectedPolicy
| *camel.threadpool.time-unit* | Sets the default time unit used for keep alive time | | TimeUnit
| *management.endpoint.camelroutecontroller.cache.time-to-live* | Maximum time that a response can be cached. | 0ms | Duration
-| *management.endpoint.camelroutecontroller.enabled* | To turn on or off information about Camel Route Controller via actuator endpoint. | true | Boolean
+| *management.endpoint.camelroutecontroller.enabled* | Whether to enable the camelroutecontroller endpoint. | true | Boolean
| *management.endpoint.camelroutes.cache.time-to-live* | Maximum time that a response can be cached. | 0ms | Duration
-| *management.endpoint.camelroutes.enabled* | To turn on or off information about Camel Routes via actuator endpoint. | true | Boolean
| *management.endpoint.camelroutes.enabled* | Whether to enable the camelroutes endpoint. | true | Boolean
-| *management.endpoint.camelroutes.enabled* | | false | Boolean
| *management.endpoint.camelroutes.read-only* | Whether Camel Routes actuator is in read-only mode. If not in read-only mode then operations to start/stop routes would be enabled. | true | Boolean
| *management.info.camel.enabled* | Whether to enable Camel info. | true | Boolean
| *camel.springboot.route-controller-logging-level* | *Deprecated* Sets the logging level used for logging route activity (such as starting and stopping routes). The default logging level is DEBUG. | | LoggingLevel
[camel-spring-boot] 01/02: Cleanup
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-spring-boot-3.12.x
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git
commit 8c866cd654d4b03f5a8d96109eb7a288d6af08bb
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Nov 5 11:30:23 2021 +0100
Cleanup
CAMEL-17169: camel-spring-boot management endpoints to work with latest spring boot 2.x style.
CAMEL-17169: camel-spring-boot management endpoints to work with latest spring boot 2.x style.
CAMEL-17169: camel-spring-boot management endpoints to work with latest spring boot 2.x style.
---
core/camel-spring-boot/pom.xml | 4 +-
.../src/main/docs/spring-boot.adoc | 4 +-
.../src/main/docs/spring-boot.json | 14 +--
.../endpoint/CamelRouteControllerEndpoint.java | 4 +-
...elRouteControllerEndpointAutoConfiguration.java | 6 +-
.../boot/actuate/endpoint/CamelRoutesEndpoint.java | 119 +++++++--------------
.../CamelRoutesEndpointAutoConfiguration.java | 13 +--
.../endpoint/CamelRoutesEndpointProperties.java | 15 +--
.../additional-spring-configuration-metadata.json | 18 ----
.../src/main/resources/META-INF/spring.factories | 2 +
.../CamelRouteControllerEndpointEnabledTest.java | 4 +-
...erEndpointGloballyDisabledAndReenabledTest.java | 29 ++---
.../endpoint/CamelRouteControllerEndpointTest.java | 25 ++---
.../endpoint/CamelRoutesEndpointEnabledTest.java | 3 +-
... CamelRoutesEndpointReadOnlyOperationTest.java} | 16 +--
.../CamelRoutesEndpointWriteOperationTest.java | 18 ++--
16 files changed, 109 insertions(+), 185 deletions(-)
diff --git a/core/camel-spring-boot/pom.xml b/core/camel-spring-boot/pom.xml
index c8b9ffd..a053561 100644
--- a/core/camel-spring-boot/pom.xml
+++ b/core/camel-spring-boot/pom.xml
@@ -120,11 +120,11 @@
</exclusions>
<scope>test</scope>
</dependency>
- <!-- <dependency>
+ <dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
- </dependency> -->
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-management</artifactId>
diff --git a/core/camel-spring-boot/src/main/docs/spring-boot.adoc b/core/camel-spring-boot/src/main/docs/spring-boot.adoc
index 43a1fd3..76470ac 100644
--- a/core/camel-spring-boot/src/main/docs/spring-boot.adoc
+++ b/core/camel-spring-boot/src/main/docs/spring-boot.adoc
@@ -264,11 +264,9 @@ The component supports 173 options, which are listed below.
| *camel.threadpool.rejected-policy* | Sets the default handler for tasks which cannot be executed by the thread pool. | | ThreadPoolRejectedPolicy
| *camel.threadpool.time-unit* | Sets the default time unit used for keep alive time | | TimeUnit
| *management.endpoint.camelroutecontroller.cache.time-to-live* | Maximum time that a response can be cached. | 0ms | Duration
-| *management.endpoint.camelroutecontroller.enabled* | To turn on or off information about Camel Route Controller via actuator endpoint. | true | Boolean
+| *management.endpoint.camelroutecontroller.enabled* | Whether to enable the camelroutecontroller endpoint. | true | Boolean
| *management.endpoint.camelroutes.cache.time-to-live* | Maximum time that a response can be cached. | 0ms | Duration
-| *management.endpoint.camelroutes.enabled* | To turn on or off information about Camel Routes via actuator endpoint. | true | Boolean
| *management.endpoint.camelroutes.enabled* | Whether to enable the camelroutes endpoint. | true | Boolean
-| *management.endpoint.camelroutes.enabled* | | false | Boolean
| *management.endpoint.camelroutes.read-only* | Whether Camel Routes actuator is in read-only mode. If not in read-only mode then operations to start/stop routes would be enabled. | true | Boolean
| *management.info.camel.enabled* | Whether to enable Camel info. | true | Boolean
| *camel.springboot.route-controller-logging-level* | *Deprecated* Sets the logging level used for logging route activity (such as starting and stopping routes). The default logging level is DEBUG. | | LoggingLevel
diff --git a/core/camel-spring-boot/src/main/docs/spring-boot.json b/core/camel-spring-boot/src/main/docs/spring-boot.json
index a68970b..1f97c10 100644
--- a/core/camel-spring-boot/src/main/docs/spring-boot.json
+++ b/core/camel-spring-boot/src/main/docs/spring-boot.json
@@ -1232,7 +1232,7 @@
{
"name": "management.endpoint.camelroutecontroller.enabled",
"type": "java.lang.Boolean",
- "description": "To turn on or off information about Camel Route Controller via actuator endpoint.",
+ "description": "Whether to enable the camelroutecontroller endpoint.",
"sourceType": "org.apache.camel.spring.boot.actuate.endpoint.CamelRouteControllerEndpoint",
"defaultValue": true
},
@@ -1246,23 +1246,11 @@
{
"name": "management.endpoint.camelroutes.enabled",
"type": "java.lang.Boolean",
- "description": "To turn on or off information about Camel Routes via actuator endpoint.",
- "defaultValue": true
- },
- {
- "name": "management.endpoint.camelroutes.enabled",
- "type": "java.lang.Boolean",
"description": "Whether to enable the camelroutes endpoint.",
"sourceType": "org.apache.camel.spring.boot.actuate.endpoint.CamelRoutesEndpoint",
"defaultValue": true
},
{
- "name": "management.endpoint.camelroutes.enabled",
- "type": "java.lang.Boolean",
- "sourceType": "org.apache.camel.spring.boot.actuate.endpoint.CamelRoutesEndpointProperties",
- "defaultValue": false
- },
- {
"name": "management.endpoint.camelroutes.read-only",
"type": "java.lang.Boolean",
"description": "Whether Camel Routes actuator is in read-only mode. If not in read-only mode then operations to start\/stop routes would be enabled.",
diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpoint.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpoint.java
index c6d3f00..e0c1123 100644
--- a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpoint.java
+++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpoint.java
@@ -27,9 +27,9 @@ import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
/*
- * {@link Endpoint} to expose {@link RouteController} information.
+ * Spring Boot Management Endpoint to expose Camel RouteController information.
*/
-@Endpoint(id = "camelroutecontroller", enableByDefault = true)
+@Endpoint(id = "camelroutecontroller")
public class CamelRouteControllerEndpoint {
private CamelContext camelContext;
diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointAutoConfiguration.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointAutoConfiguration.java
index 0b2cccd..644f1cd 100644
--- a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointAutoConfiguration.java
+++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointAutoConfiguration.java
@@ -18,6 +18,7 @@ package org.apache.camel.spring.boot.actuate.endpoint;
import org.apache.camel.CamelContext;
import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@@ -28,11 +29,12 @@ import org.springframework.context.annotation.Configuration;
/*
* Auto configuration for the {@link CamelRouteControllerEndpoint}.
*/
-@Configuration
-@ConditionalOnClass({CamelRouteControllerEndpoint.class})
+@Configuration(proxyBeanMethods = false)
+@ConditionalOnAvailableEndpoint(endpoint = CamelRouteControllerEndpoint.class)
@ConditionalOnBean(CamelAutoConfiguration.class)
@AutoConfigureAfter(CamelAutoConfiguration.class)
public class CamelRouteControllerEndpointAutoConfiguration {
+
@Bean
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean
diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpoint.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpoint.java
index 1b2c34c..1db4582 100644
--- a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpoint.java
+++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpoint.java
@@ -26,14 +26,11 @@ import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.apache.camel.CamelContext;
-import org.apache.camel.ExtendedCamelContext;
import org.apache.camel.Route;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.StatefulService;
import org.apache.camel.api.management.ManagedCamelContext;
import org.apache.camel.api.management.mbean.ManagedRouteMBean;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.spi.RouteError;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.annotation.Selector;
@@ -44,24 +41,19 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-
/*
- * {@link Endpoint} to expose {@link org.apache.camel.Route} information.
+ * Spring Boot Management Endpoint to expose Camel Route information.
*/
-@Endpoint(id = "camelroutes", enableByDefault = true)
+@Endpoint(id = "camelroutes")
public class CamelRoutesEndpoint {
private CamelContext camelContext;
- private static ExtendedCamelContext extendedContext;
- private static ManagedCamelContext mcontext;
- private static DefaultCamelContext dcontext;
+ private ManagedCamelContext managedCamelContext;
private CamelRoutesEndpointProperties properties;
public CamelRoutesEndpoint(CamelContext camelContext, CamelRoutesEndpointProperties properties) {
this.camelContext = camelContext;
- this.extendedContext = camelContext.getExtension(ExtendedCamelContext.class);
- this.mcontext = camelContext.getExtension(ManagedCamelContext.class);;
- this.dcontext = camelContext.getExtension(DefaultCamelContext.class);
+ this.managedCamelContext = camelContext.getExtension(ManagedCamelContext.class);
this.properties = properties;
}
@@ -73,12 +65,12 @@ public class CamelRoutesEndpoint {
@ReadOperation
public Object doReadAction(@Selector String id, @Selector ReadAction action) {
switch (action) {
- case DETAIL:
- return getRouteDetailsInfo(id);
- case INFO:
- return getRouteInfo(id);
- default:
- throw new IllegalArgumentException("Unsupported read action " + action);
+ case DETAIL:
+ return getRouteDetailsInfo(id);
+ case INFO:
+ return getRouteInfo(id);
+ default:
+ throw new IllegalArgumentException("Unsupported read action " + action);
}
}
@@ -89,29 +81,29 @@ public class CamelRoutesEndpoint {
}
switch (action) {
- case STOP:
- stopRoute(
- id,
- Optional.ofNullable(timeInfo).flatMap(ti -> Optional.ofNullable(ti.getTimeout())),
- Optional.of(TimeUnit.SECONDS),
- Optional.ofNullable(timeInfo).flatMap(ti -> Optional.ofNullable(ti.getAbortAfterTimeout())));
- break;
- case START:
- startRoute(id);
- break;
- case RESET:
- resetRoute(id);
- break;
- case SUSPEND:
- suspendRoute(id,
- Optional.ofNullable(timeInfo).flatMap(ti -> Optional.ofNullable(ti.getTimeout())),
- Optional.of(TimeUnit.SECONDS));
- break;
- case RESUME:
- resumeRoute(id);
- break;
- default:
- throw new IllegalArgumentException("Unsupported write action " + action);
+ case STOP:
+ stopRoute(
+ id,
+ Optional.ofNullable(timeInfo).flatMap(ti -> Optional.ofNullable(ti.getTimeout())),
+ Optional.of(TimeUnit.SECONDS),
+ Optional.ofNullable(timeInfo).flatMap(ti -> Optional.ofNullable(ti.getAbortAfterTimeout())));
+ break;
+ case START:
+ startRoute(id);
+ break;
+ case RESET:
+ resetRoute(id);
+ break;
+ case SUSPEND:
+ suspendRoute(id,
+ Optional.ofNullable(timeInfo).flatMap(ti -> Optional.ofNullable(ti.getTimeout())),
+ Optional.of(TimeUnit.SECONDS));
+ break;
+ case RESUME:
+ resumeRoute(id);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported write action " + action);
}
}
@@ -149,7 +141,7 @@ public class CamelRoutesEndpoint {
private void resetRoute(String id) {
try {
- ManagedRouteMBean managedRouteMBean = mcontext.getManagedRoute(id, ManagedRouteMBean.class);
+ ManagedRouteMBean managedRouteMBean = managedCamelContext.getManagedRoute(id, ManagedRouteMBean.class);
if (managedRouteMBean != null) {
managedRouteMBean.reset(true);
}
@@ -198,17 +190,11 @@ public class CamelRoutesEndpoint {
public static class RouteEndpointInfo {
private final String id;
-
private final String group;
-
private final Map<String, Object> properties;
-
private final String description;
-
private final String uptime;
-
private final long uptimeMillis;
-
private final String status;
public RouteEndpointInfo(Route route) {
@@ -234,7 +220,7 @@ public class CamelRoutesEndpoint {
public String getId() {
return id;
}
-
+
public String getGroup() {
return group;
}
@@ -271,9 +257,9 @@ public class CamelRoutesEndpoint {
public RouteDetailsEndpointInfo(final CamelContext camelContext, final Route route) {
super(route);
-
if (camelContext.getManagementStrategy().getManagementAgent() != null) {
- this.routeDetails = new RouteDetails(mcontext.getManagedRoute(route.getId(), ManagedRouteMBean.class));
+ ManagedCamelContext mcc = camelContext.getExtension(ManagedCamelContext.class);
+ this.routeDetails = new RouteDetails(mcc.getManagedRoute(route.getId(), ManagedRouteMBean.class));
}
}
@@ -281,55 +267,29 @@ public class CamelRoutesEndpoint {
static class RouteDetails {
private long deltaProcessingTime;
-
private long exchangesInflight;
-
private long exchangesTotal;
-
private long externalRedeliveries;
-
private long failuresHandled;
-
private String firstExchangeCompletedExchangeId;
-
private Date firstExchangeCompletedTimestamp;
-
private String firstExchangeFailureExchangeId;
-
private Date firstExchangeFailureTimestamp;
-
private String lastExchangeCompletedExchangeId;
-
private Date lastExchangeCompletedTimestamp;
-
private String lastExchangeFailureExchangeId;
-
private Date lastExchangeFailureTimestamp;
-
private long lastProcessingTime;
-
private String load01;
-
private String load05;
-
private String load15;
-
private long maxProcessingTime;
-
private long meanProcessingTime;
-
private long minProcessingTime;
-
private Long oldestInflightDuration;
-
private String oldestInflightExchangeId;
-
private long redeliveries;
-
private long totalProcessingTime;
-
- private RouteError lastError;
-
private boolean hasRouteController;
RouteDetails(ManagedRouteMBean managedRoute) {
@@ -358,7 +318,6 @@ public class CamelRoutesEndpoint {
this.oldestInflightExchangeId = managedRoute.getOldestInflightExchangeId();
this.redeliveries = managedRoute.getRedeliveries();
this.totalProcessingTime = managedRoute.getTotalProcessingTime();
- //this.lastError = managedRoute.getLastError();
this.hasRouteController = managedRoute.getHasRouteController();
} catch (Exception e) {
// Ignore
@@ -461,10 +420,6 @@ public class CamelRoutesEndpoint {
return totalProcessingTime;
}
- public RouteError getLastError() {
- return lastError;
- }
-
public boolean getHasRouteController() {
return hasRouteController;
}
diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointAutoConfiguration.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointAutoConfiguration.java
index 24c9131..b29c2b5 100644
--- a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointAutoConfiguration.java
+++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointAutoConfiguration.java
@@ -18,6 +18,7 @@ package org.apache.camel.spring.boot.actuate.endpoint;
import org.apache.camel.CamelContext;
import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@@ -29,23 +30,17 @@ import org.springframework.context.annotation.Configuration;
/*
* Auto configuration for the {@link CamelRoutesEndpoint}.
*/
-@Configuration
+@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties({ CamelRoutesEndpointProperties.class })
-@ConditionalOnClass({CamelRoutesEndpoint.class})
+@ConditionalOnAvailableEndpoint(endpoint = CamelRoutesEndpoint.class)
@ConditionalOnBean(CamelAutoConfiguration.class)
@AutoConfigureAfter(CamelAutoConfiguration.class)
public class CamelRoutesEndpointAutoConfiguration {
- private CamelRoutesEndpointProperties properties;
-
- public CamelRoutesEndpointAutoConfiguration(CamelRoutesEndpointProperties properties) {
- this.properties = properties;
- }
-
@Bean
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean
- public CamelRoutesEndpoint camelEndpoint(CamelContext camelContext) {
+ public CamelRoutesEndpoint camelEndpoint(CamelContext camelContext, CamelRoutesEndpointProperties properties) {
return new CamelRoutesEndpoint(camelContext, properties);
}
diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointProperties.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointProperties.java
index 21d447b..271f2b8 100644
--- a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointProperties.java
+++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointProperties.java
@@ -21,8 +21,11 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties("management.endpoint.camelroutes")
public class CamelRoutesEndpointProperties {
+ /**
+ * Whether Camel Routes actuator is in read-only mode.
+ * If not in read-only mode then operations to start/stop routes would be enabled.
+ */
private boolean readOnly = true;
- private boolean enabled = false;
public boolean isReadOnly() {
return readOnly;
@@ -32,14 +35,4 @@ public class CamelRoutesEndpointProperties {
this.readOnly = readOnly;
}
- public boolean isEnabled() {
- return enabled;
- }
-
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-
-
-
}
diff --git a/core/camel-spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/core/camel-spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json
index cf56bd1..d1fb7f9 100644
--- a/core/camel-spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json
+++ b/core/camel-spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json
@@ -1,24 +1,6 @@
{
"properties": [
{
- "name": "management.endpoint.camelroutes.read-only",
- "type": "java.lang.Boolean",
- "description": "Whether Camel Routes actuator is in read-only mode. If not in read-only mode then operations to start/stop routes would be enabled.",
- "defaultValue": true
- },
- {
- "name": "management.endpoint.camelroutes.enabled",
- "type": "java.lang.Boolean",
- "description": "To turn on or off information about Camel Routes via actuator endpoint.",
- "defaultValue": true
- },
- {
- "name": "management.endpoint.camelroutecontroller.enabled",
- "type": "java.lang.Boolean",
- "description": "To turn on or off information about Camel Route Controller via actuator endpoint.",
- "defaultValue": true
- },
- {
"name": "management.info.camel.enabled",
"type": "java.lang.Boolean",
"description": "Whether to enable Camel info.",
diff --git a/core/camel-spring-boot/src/main/resources/META-INF/spring.factories b/core/camel-spring-boot/src/main/resources/META-INF/spring.factories
index 38f8a24..ba07de0 100644
--- a/core/camel-spring-boot/src/main/resources/META-INF/spring.factories
+++ b/core/camel-spring-boot/src/main/resources/META-INF/spring.factories
@@ -33,6 +33,8 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.apache.camel.spring.boot.CamelAutoConfiguration,\
+org.apache.camel.spring.boot.actuate.endpoint.CamelRouteControllerEndpointAutoConfiguration,\
+org.apache.camel.spring.boot.actuate.endpoint.CamelRoutesEndpointAutoConfiguration,\
org.apache.camel.spring.boot.actuate.health.CamelHealthCheckAutoConfiguration,\
org.apache.camel.spring.boot.actuate.info.CamelInfoAutoConfiguration,\
org.apache.camel.spring.boot.cloud.CamelCloudAutoConfiguration,\
diff --git a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointEnabledTest.java b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointEnabledTest.java
index 8fd384c..2cba0ca 100644
--- a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointEnabledTest.java
+++ b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointEnabledTest.java
@@ -36,11 +36,11 @@ import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
@SpringBootApplication
@SpringBootTest(
classes = {CamelAutoConfiguration.class, CamelRouteControllerEndpointAutoConfiguration.class, ActuatorTestRoute.class},
- properties = {"management.endpoint.camelroutecontroller.enabled=true"}
+ properties = {"management.endpoints.web.exposure.include=camelroutecontroller"}
)
public class CamelRouteControllerEndpointEnabledTest {
- @Autowired(required = true)
+ @Autowired
CamelRouteControllerEndpoint routeControllerEndpoint;
@Autowired
diff --git a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointGloballyDisabledAndReenabledTest.java b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointGloballyDisabledAndReenabledTest.java
index 5c60ef2..06a4dd3 100644
--- a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointGloballyDisabledAndReenabledTest.java
+++ b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointGloballyDisabledAndReenabledTest.java
@@ -18,34 +18,36 @@ package org.apache.camel.spring.boot.actuate.endpoint;
import org.apache.camel.CamelContext;
import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
+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.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
/*
* Test for the {@link CamelRoutesEndpoint} actuator endpoint.
*/
@DirtiesContext
-@CamelSpringBootTest
+@RunWith(SpringRunner.class)
@EnableAutoConfiguration
@SpringBootApplication
@SpringBootTest(
- classes = {CamelAutoConfiguration.class, CamelRoutesEndpointAutoConfiguration.class,
- CamelRouteControllerEndpointAutoConfiguration.class, ActuatorTestRoute.class},
- properties = {"management.endpoints.enabled-by-default = true",
- "management.endpoint.camelroutecontroller.enabled = true"}
+ classes = {CamelAutoConfiguration.class, CamelRoutesEndpointAutoConfiguration.class,
+ CamelRouteControllerEndpointAutoConfiguration.class, ActuatorTestRoute.class},
+ properties = {"management.endpoints.web.exposure.include=*",
+ "management.endpoint.camelroute.enabled=true",
+ "management.endpoint.camelroutecontroller.enabled=true"}
)
-public class CamelRouteControllerEndpointGloballyDisabledAndReenabledTest {
+public class CamelRouteControllerEndpointGloballyDisabledAndReenabledTest extends Assert {
- @Autowired
+ @Autowired(required = false)
CamelRouteControllerEndpoint routeControllerEndpoint;
- @Autowired
+ @Autowired(required = false)
CamelRoutesEndpoint routesEndpoint;
@Autowired
@@ -53,9 +55,8 @@ public class CamelRouteControllerEndpointGloballyDisabledAndReenabledTest {
@Test
public void testRoutesEndpointPresent() throws Exception {
-
- Assertions.assertNotNull(routesEndpoint);
- Assertions.assertNotNull(routeControllerEndpoint);
+ Assert.assertNotNull(routesEndpoint);
+ Assert.assertNotNull(routeControllerEndpoint);
}
}
diff --git a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointTest.java b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointTest.java
index c9bbd05..e73e2ec 100644
--- a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointTest.java
+++ b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointTest.java
@@ -20,23 +20,29 @@ import java.util.List;
import org.apache.camel.CamelContext;
import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
+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.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
/*
* Test for the {@link CamelRouteControllerEndpoint} actuator endpoint.
*/
@DirtiesContext
-@CamelSpringBootTest
+@RunWith(SpringRunner.class)
@EnableAutoConfiguration
@SpringBootApplication
-@SpringBootTest(classes = {CamelAutoConfiguration.class, CamelRouteControllerEndpointAutoConfiguration.class, ActuatorTestRoute.class})
+@SpringBootTest(
+ classes = {CamelAutoConfiguration.class, CamelRouteControllerEndpointAutoConfiguration.class,
+ CamelRoutesEndpointAutoConfiguration.class, ActuatorTestRoute.class},
+ properties = {"management.endpoints.web.exposure.include=*",
+ "camel.springboot.routeControllerSuperviseEnabled=true"})
public class CamelRouteControllerEndpointTest {
@Autowired
@@ -48,13 +54,8 @@ public class CamelRouteControllerEndpointTest {
@Test
public void testRouteControllerEndpoint() throws Exception {
List<String> routesId = endpoint.getControlledRoutes();
-
- Assertions.assertNotNull(routesId);
- /* FIXME DefaultRouteController returns empty list while it does control any route...
- assertFalse(routesId.isEmpty());
- assertEquals(routesId.size(), camelContext.getRoutes().size());
- assertTrue(routesId.stream().anyMatch(r -> "foo-route".equals(r)));
- */
+ Assert.assertTrue(routesId.size() > 0);
+ Assert.assertTrue(routesId.contains("foo-route"));
}
}
diff --git a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointEnabledTest.java b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointEnabledTest.java
index cd4b043..c910cee 100644
--- a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointEnabledTest.java
+++ b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointEnabledTest.java
@@ -36,7 +36,8 @@ import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
@SpringBootApplication
@SpringBootTest(
classes = {CamelAutoConfiguration.class, CamelRoutesEndpointAutoConfiguration.class, ActuatorTestRoute.class},
- properties = {"management.endpoint.camelroutes.enabled = true"}
+ properties = {"management.endpoints.web.exposure.include=*",
+ "management.endpoint.camelroutes.enabled = true"}
)
public class CamelRoutesEndpointEnabledTest {
diff --git a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointWriteOperationTest.java b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointReadOnlyOperationTest.java
similarity index 83%
copy from core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointWriteOperationTest.java
copy to core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointReadOnlyOperationTest.java
index a392a18..dc83ee7 100644
--- a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointWriteOperationTest.java
+++ b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointReadOnlyOperationTest.java
@@ -22,6 +22,7 @@ import org.apache.camel.impl.engine.AbstractCamelContext;
import org.apache.camel.spring.boot.CamelAutoConfiguration;
import org.apache.camel.spring.boot.actuate.endpoint.CamelRoutesEndpoint.TimeInfo;
import org.apache.camel.spring.boot.actuate.endpoint.CamelRoutesEndpoint.WriteAction;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -29,7 +30,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
/*
* Test for the {@link CamelRoutesEndpoint} actuator endpoint.
@@ -40,8 +40,9 @@ import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
@SpringBootApplication
@SpringBootTest(
classes = {CamelAutoConfiguration.class, CamelRoutesEndpointAutoConfiguration.class, ActuatorTestRoute.class},
- properties = {"management.endpoint.camelroutes.read-only = false"})
-public class CamelRoutesEndpointWriteOperationTest {
+ properties = {"management.endpoints.web.exposure.include=*",
+ "management.endpoint.camelroutes.read-only = true"})
+public class CamelRoutesEndpointReadOnlyOperationTest {
@Autowired
CamelRoutesEndpoint endpoint;
@@ -57,8 +58,11 @@ public class CamelRoutesEndpointWriteOperationTest {
TimeInfo timeInfo = new TimeInfo();
timeInfo.setAbortAfterTimeout(true);
timeInfo.setTimeout(10L);
- endpoint.doWriteAction("foo-route", WriteAction.STOP, timeInfo);
- status = acontext.getRouteStatus("foo-route");
- Assertions.assertTrue(status.isStopped());
+ try {
+ endpoint.doWriteAction("foo-route", WriteAction.STOP, timeInfo);
+ Assertions.fail("Should not allow write");
+ } catch (IllegalArgumentException e) {
+ Assertions.assertEquals("Read only: write action STOP is not allowed", e.getMessage());
+ }
}
}
diff --git a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointWriteOperationTest.java b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointWriteOperationTest.java
index a392a18..15bb094 100644
--- a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointWriteOperationTest.java
+++ b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointWriteOperationTest.java
@@ -22,25 +22,27 @@ import org.apache.camel.impl.engine.AbstractCamelContext;
import org.apache.camel.spring.boot.CamelAutoConfiguration;
import org.apache.camel.spring.boot.actuate.endpoint.CamelRoutesEndpoint.TimeInfo;
import org.apache.camel.spring.boot.actuate.endpoint.CamelRoutesEndpoint.WriteAction;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
+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.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
/*
* Test for the {@link CamelRoutesEndpoint} actuator endpoint.
*/
@DirtiesContext
-@CamelSpringBootTest
+@RunWith(SpringRunner.class)
@EnableAutoConfiguration
@SpringBootApplication
@SpringBootTest(
- classes = {CamelAutoConfiguration.class, CamelRoutesEndpointAutoConfiguration.class, ActuatorTestRoute.class},
- properties = {"management.endpoint.camelroutes.read-only = false"})
+ classes = {CamelAutoConfiguration.class, CamelRoutesEndpointAutoConfiguration.class, ActuatorTestRoute.class},
+ properties = {"management.endpoints.web.exposure.include=*",
+ "management.endpoint.camelroutes.read-only = false"})
public class CamelRoutesEndpointWriteOperationTest {
@Autowired
@@ -53,12 +55,12 @@ public class CamelRoutesEndpointWriteOperationTest {
public void testWriteOperation() throws Exception {
AbstractCamelContext acontext = camelContext.getExtension(AbstractCamelContext.class);
ServiceStatus status = acontext.getRouteStatus("foo-route");
- Assertions.assertTrue(status.isStarted());
+ Assert.assertTrue(status.isStarted());
TimeInfo timeInfo = new TimeInfo();
timeInfo.setAbortAfterTimeout(true);
timeInfo.setTimeout(10L);
endpoint.doWriteAction("foo-route", WriteAction.STOP, timeInfo);
status = acontext.getRouteStatus("foo-route");
- Assertions.assertTrue(status.isStopped());
+ Assert.assertTrue(status.isStopped());
}
}