This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch CAMEL-16757b in repository https://gitbox.apache.org/repos/asf/camel.git
commit 61b7a166b8de05da3e8856f84fb9ca7fc20888b6 Author: Claus Ibsen <[email protected]> AuthorDate: Tue Aug 3 07:20:55 2021 +0200 CAMEL-16757: JMX attribute for route configuration ids on route mbean --- core/camel-api/src/main/java/org/apache/camel/Route.java | 11 +++++++++++ .../java/org/apache/camel/impl/engine/DefaultRoute.java | 6 ++++++ .../main/java/org/apache/camel/reifier/RouteReifier.java | 3 ++- .../camel/api/management/mbean/ManagedRouteMBean.java | 3 +++ .../org/apache/camel/management/mbean/ManagedRoute.java | 15 +++++++++++---- 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/core/camel-api/src/main/java/org/apache/camel/Route.java b/core/camel-api/src/main/java/org/apache/camel/Route.java index 808dc35..27e5e84 100644 --- a/core/camel-api/src/main/java/org/apache/camel/Route.java +++ b/core/camel-api/src/main/java/org/apache/camel/Route.java @@ -44,6 +44,7 @@ public interface Route extends RuntimeConfiguration { String REST_PROPERTY = "rest"; String TEMPLATE_PROPERTY = "template"; String DESCRIPTION_PROPERTY = "description"; + String CONFIGURATION_ID_PROPERTY = "configurationId"; /** * Gets the route id @@ -116,6 +117,16 @@ public interface Route extends RuntimeConfiguration { String getDescription(); /** + * Gets the route configuration id(s) (if any has been configured). + * <p/> + * The configuration ids is configured using the {@link #CONFIGURATION_ID_PROPERTY} as key in the + * {@link #getProperties()}. + * + * @return the configuration, or <tt>null</tt> if no configuration has been configured. + */ + String getConfigurationId(); + + /** * Gets the camel context * * @return the camel context diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRoute.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRoute.java index fd877b0..3d39dbf 100644 --- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRoute.java +++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRoute.java @@ -157,6 +157,12 @@ public class DefaultRoute extends ServiceSupport implements Route { } @Override + public String getConfigurationId() { + Object value = properties.get(Route.CONFIGURATION_ID_PROPERTY); + return value != null ? (String) value : null; + } + + @Override public void initializeServices() throws Exception { // gather all the services for this route gatherServices(services); diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/RouteReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/RouteReifier.java index 10ede58..bb7da1b 100644 --- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/RouteReifier.java +++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/RouteReifier.java @@ -58,7 +58,7 @@ public class RouteReifier extends ProcessorReifier<RouteDefinition> { private static final String[] RESERVED_PROPERTIES = new String[] { Route.ID_PROPERTY, Route.CUSTOM_ID_PROPERTY, Route.PARENT_PROPERTY, Route.DESCRIPTION_PROPERTY, Route.GROUP_PROPERTY, - Route.REST_PROPERTY }; + Route.REST_PROPERTY, Route.CONFIGURATION_ID_PROPERTY }; public RouteReifier(CamelContext camelContext, ProcessorDefinition<?> definition) { super(camelContext, (RouteDefinition) definition); @@ -373,6 +373,7 @@ public class RouteReifier extends ProcessorReifier<RouteDefinition> { routeProperties.put(Route.REST_PROPERTY, rest); String template = Boolean.toString(definition.isTemplate() != null && definition.isTemplate()); routeProperties.put(Route.TEMPLATE_PROPERTY, template); + routeProperties.put(Route.CONFIGURATION_ID_PROPERTY, definition.getRouteConfiguration()); List<PropertyDefinition> properties = definition.getRouteProperties(); if (properties != null) { diff --git a/core/camel-management-api/src/main/java/org/apache/camel/api/management/mbean/ManagedRouteMBean.java b/core/camel-management-api/src/main/java/org/apache/camel/api/management/mbean/ManagedRouteMBean.java index 304998a..e019e88 100644 --- a/core/camel-management-api/src/main/java/org/apache/camel/api/management/mbean/ManagedRouteMBean.java +++ b/core/camel-management-api/src/main/java/org/apache/camel/api/management/mbean/ManagedRouteMBean.java @@ -35,6 +35,9 @@ public interface ManagedRouteMBean extends ManagedPerformanceCounterMBean { @ManagedAttribute(description = "Route Description") String getDescription(); + @ManagedAttribute(description = "Route Configuration ID") + String getRouteConfigurationId(); + @ManagedAttribute(description = "Route Endpoint URI", mask = true) String getEndpointUri(); diff --git a/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java b/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java index 87ab081..988dc20 100644 --- a/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java +++ b/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java @@ -71,6 +71,7 @@ public class ManagedRoute extends ManagedPerformanceCounter implements TimerList protected final Route route; protected final String description; + protected final String configurationId; protected final CamelContext context; private final LoadTriplet load = new LoadTriplet(); private final String jmxDomain; @@ -79,6 +80,7 @@ public class ManagedRoute extends ManagedPerformanceCounter implements TimerList this.route = route; this.context = context; this.description = route.getDescription(); + this.configurationId = route.getConfigurationId(); this.jmxDomain = context.getManagementStrategy().getManagementAgent().getMBeanObjectDomainName(); } @@ -143,6 +145,11 @@ public class ManagedRoute extends ManagedPerformanceCounter implements TimerList } @Override + public String getRouteConfigurationId() { + return configurationId; + } + + @Override public String getEndpointUri() { if (route.getEndpoint() != null) { return route.getEndpoint().getEndpointUri(); @@ -171,10 +178,6 @@ public class ManagedRoute extends ManagedPerformanceCounter implements TimerList return route.getUptimeMillis(); } - public Integer getInflightExchanges() { - return (int) super.getExchangesInflight(); - } - @Override public String getCamelId() { return context.getName(); @@ -646,6 +649,10 @@ public class ManagedRoute extends ManagedPerformanceCounter implements TimerList } } + private Integer getInflightExchanges() { + return (int) super.getExchangesInflight(); + } + /** * Used for sorting the processor mbeans accordingly to their index. */
