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/12/14 13:25:27 UTC

[camel] 06/07: CAMEL-17331: include source location and line number to processor mbeans

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit cf1412f1761edd84152a43c79971665649483699
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Dec 14 14:19:58 2021 +0100

    CAMEL-17331: include source location and line number to processor mbeans
---
 .../camel/api/management/mbean/ManagedProcessorMBean.java     |  3 +++
 .../org/apache/camel/management/mbean/ManagedProcessor.java   | 11 +++++++++++
 2 files changed, 14 insertions(+)

diff --git a/core/camel-management-api/src/main/java/org/apache/camel/api/management/mbean/ManagedProcessorMBean.java b/core/camel-management-api/src/main/java/org/apache/camel/api/management/mbean/ManagedProcessorMBean.java
index f5016a0..c8d9155 100644
--- a/core/camel-management-api/src/main/java/org/apache/camel/api/management/mbean/ManagedProcessorMBean.java
+++ b/core/camel-management-api/src/main/java/org/apache/camel/api/management/mbean/ManagedProcessorMBean.java
@@ -42,6 +42,9 @@ public interface ManagedProcessorMBean extends ManagedPerformanceCounterMBean {
     @ManagedAttribute(description = "Processor Index")
     Integer getIndex();
 
+    @ManagedAttribute(description = "Source file Location")
+    String getSourceLocation();
+
     @ManagedAttribute(description = "Line number of this node in the source file (when loaded from a line number aware parser)")
     Integer getSourceLineNumber();
 
diff --git a/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedProcessor.java b/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedProcessor.java
index 59359b9..1acfe0d 100644
--- a/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedProcessor.java
+++ b/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedProcessor.java
@@ -27,6 +27,7 @@ import org.apache.camel.api.management.ManagedResource;
 import org.apache.camel.api.management.mbean.ManagedProcessorMBean;
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.model.ProcessorDefinitionHelper;
+import org.apache.camel.model.RouteDefinition;
 import org.apache.camel.model.StepDefinition;
 import org.apache.camel.spi.ManagementStrategy;
 import org.apache.camel.spi.RouteIdAware;
@@ -41,6 +42,7 @@ public class ManagedProcessor extends ManagedPerformanceCounter implements Manag
     private final String id;
     private String stepId;
     private Route route;
+    private String sourceLocation;
 
     public ManagedProcessor(CamelContext context, Processor processor, ProcessorDefinition<?> definition) {
         this.context = context;
@@ -54,6 +56,10 @@ public class ManagedProcessor extends ManagedPerformanceCounter implements Manag
             step = ProcessorDefinitionHelper.findFirstParentOfType(StepDefinition.class, definition, true);
         }
         this.stepId = step != null ? step.idOrCreate(context.adapt(ExtendedCamelContext.class).getNodeIdFactory()) : null;
+        RouteDefinition rd = ProcessorDefinitionHelper.getRoute(definition);
+        if (rd != null && rd.getResource() != null) {
+            this.sourceLocation = rd.getResource().getLocation();
+        }
     }
 
     @Override
@@ -95,6 +101,11 @@ public class ManagedProcessor extends ManagedPerformanceCounter implements Manag
     }
 
     @Override
+    public String getSourceLocation() {
+        return sourceLocation;
+    }
+
+    @Override
     public Integer getSourceLineNumber() {
         int line = definition.getLineNumber();
         return line >= 0 ? line : null;