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


The following commit(s) were added to refs/heads/main by this push:
     new 9a425d5ad356 CAMEL-20206: Reduce cognitive complexity in core modules 
(wave 2) (#30740)
9a425d5ad356 is described below

commit 9a425d5ad35691a576dcc3919cd0efbc2f65a066
Author: Guillaume Nodet <[email protected]>
AuthorDate: Wed Nov 25 07:29:08 2026 +0100

    CAMEL-20206: Reduce cognitive complexity in core modules (wave 2) (#30740)
    
    Extract focused helper methods to reduce cognitive complexity of
    the highest-CC methods in core modules:
    
    - RouteReifier.doCreateRoute() (CC=97): extract configureRouteOptions()
      for trace/history/mask/streamCache/delayer flags, and
      configureRouteAdvices() for policy registration, advice wiring
      (REST binding, contract, inflight, JMX, lifecycle).
    
    - DefaultExchangeFormatter.format() (CC=91): extract
      appendExchangeMetadata(), appendMessageParts(), appendException()
      to separate the three logical sections of the exchange formatting.
    
    - ApiMethodParser.parse() (CC=91): extract parseSignatureArg()
      to eliminate the duplicate argument/property parsing block.
    
    - DefaultManagementObjectStrategy.getManagedObjectForProcessor()
      (CC=90): split the 50-entry if-else chain into three focused
      helpers: findManagedProcessorForConversionTypes() (type converters,
      marshal/unmarshal, transform), findManagedProcessorForRoutingTypes()
      (routing EIPs, load balancers, aggregator), and
      findManagedProcessorForMiscTypes() (all remaining processors).
    
    No behavioral changes.
    
    Co-authored-by: Claude Sonnet 4.6 <[email protected]>
---
 .../org/apache/camel/reifier/RouteReifier.java     | 258 ++++++++++---------
 .../DefaultManagementObjectStrategy.java           | 281 +++++++++++----------
 .../camel/support/component/ApiMethodParser.java   |  86 +++----
 .../processor/DefaultExchangeFormatter.java        |  75 +++---
 4 files changed, 360 insertions(+), 340 deletions(-)

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 eec2f04b69cf..d1170c27f5d6 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
@@ -128,64 +128,7 @@ public class RouteReifier extends 
ProcessorReifier<RouteDefinition> {
             route.setAllowUseOriginalMessage(true);
         }
 
-        // configure tracing
-        if (definition.getTrace() != null) {
-            Boolean isTrace = parseBoolean(definition.getTrace());
-            if (isTrace != null) {
-                route.setTracing(isTrace);
-                if (isTrace) {
-                    LOG.debug("Tracing is enabled on route: {}", 
definition.getId());
-                    // tracing is added in the DefaultChannel so we can enable
-                    // it on the fly
-                }
-            }
-        }
-
-        // configure message history
-        if (definition.getMessageHistory() != null) {
-            Boolean isMessageHistory = 
parseBoolean(definition.getMessageHistory());
-            if (isMessageHistory != null) {
-                route.setMessageHistory(isMessageHistory);
-                if (isMessageHistory) {
-                    LOG.debug("Message history is enabled on route: {}", 
definition.getId());
-                }
-            }
-        }
-
-        // configure Log EIP mask
-        if (definition.getLogMask() != null) {
-            Boolean isLogMask = parseBoolean(definition.getLogMask());
-            if (isLogMask != null) {
-                route.setLogMask(isLogMask);
-                if (isLogMask) {
-                    LOG.debug("Security mask for Logging is enabled on route: 
{}", definition.getId());
-                }
-            }
-        }
-
-        // configure stream caching
-        if (definition.getStreamCache() != null) {
-            Boolean isStreamCache = parseBoolean(definition.getStreamCache());
-            if (isStreamCache != null) {
-                route.setStreamCaching(isStreamCache);
-                if (isStreamCache) {
-                    LOG.debug("StreamCaching is enabled on route: {}", 
definition.getId());
-                }
-            }
-        }
-
-        // configure delayer
-        if (definition.getDelayer() != null) {
-            Long delayer = parseDuration(definition.getDelayer());
-            if (delayer != null) {
-                route.setDelayer(delayer);
-                if (delayer > 0) {
-                    LOG.debug("Delayer is enabled with: {} ms. on route: {}", 
delayer, definition.getId());
-                } else {
-                    LOG.debug("Delayer is disabled on route: {}", 
definition.getId());
-                }
-            }
-        }
+        configureRouteOptions(route);
 
         // configure auto startup
         Boolean isAutoStartup = parseBoolean(definition.getAutoStartup());
@@ -266,6 +209,135 @@ public class RouteReifier extends 
ProcessorReifier<RouteDefinition> {
         InternalProcessor internal = 
PluginHelper.getInternalProcessorFactory(camelContext)
                 .addUnitOfWorkProcessorAdvice(camelContext, target, route);
 
+        configureRouteAdvices(route, internal);
+
+        // wrap with variable
+        if (variable != null) {
+            internal.addAdvice(new VariableAdvice(variable));
+        }
+
+        // and create the route that wraps all of this
+        route.setProcessor(internal);
+        route.getProperties().putAll(routeProperties);
+        route.setStartupOrder(startupOrder);
+        if (isAutoStartup != null) {
+            LOG.debug("Using AutoStartup {} on route: {}", isAutoStartup, 
definition.getId());
+            route.setAutoStartup(isAutoStartup);
+        }
+
+        // after the route is created then set the route on the policy 
processor(s) so we get hold of it
+        internal.setRouteOnAdvices(route);
+
+        // invoke init on route policy
+        List<RoutePolicy> routePolicyList = route.getRoutePolicyList();
+        if (routePolicyList != null && !routePolicyList.isEmpty()) {
+            for (RoutePolicy policy : routePolicyList) {
+                policy.onInit(route);
+            }
+        }
+
+        // inject the route error handler for processors that are error 
handler aware
+        // this needs to be done here at the end because the route may be 
transactional and have a transaction error handler
+        // automatic be configured which some EIPs like 
Multicast/RecipientList needs to be using for special fine-grained error 
handling
+        ErrorHandlerFactory builder = route.getErrorHandlerFactory();
+        Processor errorHandler = ((ModelCamelContext) 
camelContext).getModelReifierFactory().createErrorHandler(route,
+                builder, null);
+        prepareErrorHandlerAware(route, errorHandler);
+
+        if (definition.getRouteTemplateContext() != null) {
+            // make route stop beans from the local repository (route 
templates / kamelets)
+            Service wrapper = new ServiceSupport() {
+                @Override
+                protected void doStop() throws Exception {
+                    close();
+                }
+
+                @Override
+                public void close() throws IOException {
+                    BeanRepository repo = 
definition.getRouteTemplateContext().getLocalBeanRepository();
+                    if (repo instanceof Closeable obj) {
+                        IOHelper.close(obj);
+                    }
+                    super.close();
+                }
+            };
+            route.addService(wrapper, true);
+        }
+
+        return route;
+    }
+
+    private void prepareErrorHandlerAware(Route route, Processor errorHandler) 
{
+        List<Processor> processors = route.filter("*");
+        for (Processor p : processors) {
+            if (p instanceof ErrorHandlerAware errorHandlerAware) {
+                errorHandlerAware.setErrorHandler(errorHandler);
+            }
+        }
+    }
+
+    private void configureRouteOptions(Route route) {
+        // configure tracing
+        if (definition.getTrace() != null) {
+            Boolean isTrace = parseBoolean(definition.getTrace());
+            if (isTrace != null) {
+                route.setTracing(isTrace);
+                if (isTrace) {
+                    LOG.debug("Tracing is enabled on route: {}", 
definition.getId());
+                    // tracing is added in the DefaultChannel so we can enable
+                    // it on the fly
+                }
+            }
+        }
+
+        // configure message history
+        if (definition.getMessageHistory() != null) {
+            Boolean isMessageHistory = 
parseBoolean(definition.getMessageHistory());
+            if (isMessageHistory != null) {
+                route.setMessageHistory(isMessageHistory);
+                if (isMessageHistory) {
+                    LOG.debug("Message history is enabled on route: {}", 
definition.getId());
+                }
+            }
+        }
+
+        // configure Log EIP mask
+        if (definition.getLogMask() != null) {
+            Boolean isLogMask = parseBoolean(definition.getLogMask());
+            if (isLogMask != null) {
+                route.setLogMask(isLogMask);
+                if (isLogMask) {
+                    LOG.debug("Security mask for Logging is enabled on route: 
{}", definition.getId());
+                }
+            }
+        }
+
+        // configure stream caching
+        if (definition.getStreamCache() != null) {
+            Boolean isStreamCache = parseBoolean(definition.getStreamCache());
+            if (isStreamCache != null) {
+                route.setStreamCaching(isStreamCache);
+                if (isStreamCache) {
+                    LOG.debug("StreamCaching is enabled on route: {}", 
definition.getId());
+                }
+            }
+        }
+
+        // configure delayer
+        if (definition.getDelayer() != null) {
+            Long delayer = parseDuration(definition.getDelayer());
+            if (delayer != null) {
+                route.setDelayer(delayer);
+                if (delayer > 0) {
+                    LOG.debug("Delayer is enabled with: {} ms. on route: {}", 
delayer, definition.getId());
+                } else {
+                    LOG.debug("Delayer is disabled on route: {}", 
definition.getId());
+                }
+            }
+        }
+    }
+
+    private void configureRouteAdvices(Route route, InternalProcessor 
internal) {
         // configure route policy
         if (definition.getRoutePolicies() != null && 
!definition.getRoutePolicies().isEmpty()) {
             for (RoutePolicy policy : definition.getRoutePolicies()) {
@@ -291,7 +363,8 @@ public class RouteReifier extends 
ProcessorReifier<RouteDefinition> {
                 }
             }
         }
-        // and then optionally add route policy processor if a custom policy 
is set
+
+        // and then optionally register route policies as services
         List<RoutePolicy> routePolicyList = route.getRoutePolicyList();
         if (routePolicyList != null && !routePolicyList.isEmpty()) {
             for (RoutePolicy policy : routePolicyList) {
@@ -309,7 +382,6 @@ public class RouteReifier extends 
ProcessorReifier<RouteDefinition> {
                     }
                 }
             }
-
             internal.addRoutePolicyAdvice(routePolicyList);
         }
 
@@ -325,7 +397,7 @@ public class RouteReifier extends 
ProcessorReifier<RouteDefinition> {
         // wrap in route lifecycle
         internal.addRouteLifecycleAdvice(camelContext, route, definition);
 
-        // add advices
+        // add advices (REST binding, contract)
         if (definition.getRestBindingDefinition() != null) {
             try {
                 // when disabling bean or processor we should also disable 
rest-dsl binding advice
@@ -340,7 +412,6 @@ public class RouteReifier extends 
ProcessorReifier<RouteDefinition> {
             }
         }
 
-        // wrap in contract
         if (definition.getInputType() != null || definition.getOutputType() != 
null) {
             Contract contract = new Contract();
             if (definition.getInputType() != null) {
@@ -356,69 +427,6 @@ public class RouteReifier extends 
ProcessorReifier<RouteDefinition> {
             // input/output types on routes
             camelContext.setUseDataType(true);
         }
-
-        // wrap with variable
-        if (variable != null) {
-            internal.addAdvice(new VariableAdvice(variable));
-        }
-
-        // and create the route that wraps all of this
-        route.setProcessor(internal);
-        route.getProperties().putAll(routeProperties);
-        route.setStartupOrder(startupOrder);
-        if (isAutoStartup != null) {
-            LOG.debug("Using AutoStartup {} on route: {}", isAutoStartup, 
definition.getId());
-            route.setAutoStartup(isAutoStartup);
-        }
-
-        // after the route is created then set the route on the policy 
processor(s) so we get hold of it
-        internal.setRouteOnAdvices(route);
-
-        // invoke init on route policy
-        if (routePolicyList != null && !routePolicyList.isEmpty()) {
-            for (RoutePolicy policy : routePolicyList) {
-                policy.onInit(route);
-            }
-        }
-
-        // inject the route error handler for processors that are error 
handler aware
-        // this needs to be done here at the end because the route may be 
transactional and have a transaction error handler
-        // automatic be configured which some EIPs like 
Multicast/RecipientList needs to be using for special fine-grained error 
handling
-        ErrorHandlerFactory builder = route.getErrorHandlerFactory();
-        Processor errorHandler = ((ModelCamelContext) 
camelContext).getModelReifierFactory().createErrorHandler(route,
-                builder, null);
-        prepareErrorHandlerAware(route, errorHandler);
-
-        if (definition.getRouteTemplateContext() != null) {
-            // make route stop beans from the local repository (route 
templates / kamelets)
-            Service wrapper = new ServiceSupport() {
-                @Override
-                protected void doStop() throws Exception {
-                    close();
-                }
-
-                @Override
-                public void close() throws IOException {
-                    BeanRepository repo = 
definition.getRouteTemplateContext().getLocalBeanRepository();
-                    if (repo instanceof Closeable obj) {
-                        IOHelper.close(obj);
-                    }
-                    super.close();
-                }
-            };
-            route.addService(wrapper, true);
-        }
-
-        return route;
-    }
-
-    private void prepareErrorHandlerAware(Route route, Processor errorHandler) 
{
-        List<Processor> processors = route.filter("*");
-        for (Processor p : processors) {
-            if (p instanceof ErrorHandlerAware errorHandlerAware) {
-                errorHandlerAware.setErrorHandler(errorHandler);
-            }
-        }
     }
 
     protected Map<String, Object> computeRouteProperties() {
diff --git 
a/core/camel-management/src/main/java/org/apache/camel/management/DefaultManagementObjectStrategy.java
 
b/core/camel-management/src/main/java/org/apache/camel/management/DefaultManagementObjectStrategy.java
index d276134daace..b054174641c5 100644
--- 
a/core/camel-management/src/main/java/org/apache/camel/management/DefaultManagementObjectStrategy.java
+++ 
b/core/camel-management/src/main/java/org/apache/camel/management/DefaultManagementObjectStrategy.java
@@ -362,135 +362,12 @@ public class DefaultManagementObjectStrategy implements 
ManagementObjectStrategy
                 return false;
             }
 
-            if (target instanceof ConvertBodyProcessor cbp) {
-                answer = new ManagedConvertBody(context, cbp, definition);
-            } else if (target instanceof ConvertHeaderProcessor chp) {
-                answer = new ManagedConvertHeader(context, chp, definition);
-            } else if (target instanceof ConvertVariableProcessor cvp) {
-                answer = new ManagedConvertVariable(context, cvp, definition);
-            } else if (target instanceof SwitchProcessor sp) {
-                answer = new ManagedSwitch(context, sp, definition);
-            } else if (target instanceof ChoiceProcessor cp) {
-                answer = new ManagedChoice(context, cp, definition);
-            } else if (target instanceof ClaimCheckProcessor ccp) {
-                answer = new ManagedClaimCheck(context, ccp, definition);
-            } else if (target instanceof Delayer d) {
-                answer = new ManagedDelayer(context, d, definition);
-            } else if (target instanceof DisabledProcessor dp) {
-                answer = new ManagedDisabled(context, dp, definition);
-            } else if (target instanceof TryProcessor tryProc) {
-                answer = new ManagedDoTry(context, tryProc, cast(definition));
-            } else if (target instanceof CatchProcessor catchProc) {
-                answer = new ManagedDoCatch(context, catchProc, 
cast(definition));
-            } else if (target instanceof FinallyProcessor fp) {
-                answer = new ManagedDoFinally(context, fp, cast(definition));
-            } else if (target instanceof Throttler t) {
-                answer = new ManagedThrottler(context, t, definition);
-            } else if (target instanceof DynamicRouter dr) {
-                answer = new ManagedDynamicRouter(context, dr, 
cast(definition));
-            } else if (target instanceof RoutingSlip rs) {
-                answer = new ManagedRoutingSlip(context, rs, cast(definition));
-            } else if (target instanceof FilterProcessor fp) {
-                answer = new ManagedFilter(context, fp, (ExpressionNode) 
definition);
-            } else if (target instanceof LogProcessor lp) {
-                answer = new ManagedLog(context, lp, definition);
-            } else if (target instanceof LoopProcessor loopProc) {
-                answer = new ManagedLoop(context, loopProc, cast(definition));
-            } else if (target instanceof MarshalProcessor mp) {
-                answer = new ManagedMarshal(context, mp, cast(definition));
-            } else if (target instanceof UnmarshalProcessor up) {
-                answer = new ManagedUnmarshal(context, up, cast(definition));
-            } else if (target instanceof FailOverLoadBalancer folb) {
-                answer = new ManagedFailoverLoadBalancer(context, folb, 
cast(definition));
-            } else if (target instanceof RandomLoadBalancer rlb) {
-                answer = new ManagedRandomLoadBalancer(context, rlb, 
cast(definition));
-            } else if (target instanceof RoundRobinLoadBalancer rrlb) {
-                answer = new ManagedRoundRobinLoadBalancer(context, rrlb, 
cast(definition));
-            } else if (target instanceof StickyLoadBalancer slb) {
-                answer = new ManagedStickyLoadBalancer(context, slb, 
cast(definition));
-            } else if (target instanceof TopicLoadBalancer tlb) {
-                answer = new ManagedTopicLoadBalancer(context, tlb, 
cast(definition));
-            } else if (target instanceof WeightedLoadBalancer wlb) {
-                answer = new ManagedWeightedLoadBalancer(context, wlb, 
cast(definition));
-            } else if (target instanceof RecipientList rl) {
-                answer = new ManagedRecipientList(context, rl, 
cast(definition));
-            } else if (target instanceof Splitter s) {
-                answer = new ManagedSplitter(context, s, cast(definition));
-            } else if (target instanceof MulticastProcessor mcp) {
-                answer = new ManagedMulticast(context, mcp, definition);
-            } else if (target instanceof SamplingThrottler st) {
-                answer = new ManagedSamplingThrottler(context, st, definition);
-            } else if (target instanceof Resequencer r) {
-                answer = new ManagedResequencer(context, r, definition);
-            } else if (target instanceof RollbackProcessor rp) {
-                answer = new ManagedRollback(context, rp, definition);
-            } else if (target instanceof StreamResequencer sr) {
-                answer = new ManagedResequencer(context, sr, definition);
-            } else if (target instanceof SetBodyProcessor sbp) {
-                answer = new ManagedSetBody(context, sbp, cast(definition));
-            } else if (target instanceof RemoveHeaderProcessor rhp) {
-                answer = new ManagedRemoveHeader(context, rhp, definition);
-            } else if (target instanceof RemoveHeadersProcessor rhsp) {
-                answer = new ManagedRemoveHeaders(context, rhsp, definition);
-            } else if (target instanceof SetHeaderProcessor shp) {
-                answer = new ManagedSetHeader(context, shp, cast(definition));
-            } else if (target instanceof SetHeadersProcessor shsp) {
-                answer = new ManagedSetHeaders(context, shsp, 
cast(definition));
-            } else if (target instanceof SetVariableProcessor svp) {
-                answer = new ManagedSetVariable(context, svp, 
cast(definition));
-            } else if (target instanceof SetVariablesProcessor svsp) {
-                answer = new ManagedSetVariables(context, svsp, 
cast(definition));
-            } else if (target instanceof RemovePropertyProcessor rpp) {
-                answer = new ManagedRemoveProperty(context, rpp, definition);
-            } else if (target instanceof RemovePropertiesProcessor rpsp) {
-                answer = new ManagedRemoveProperties(context, rpsp, 
definition);
-            } else if (target instanceof RemoveVariableProcessor rvp) {
-                answer = new ManagedRemoveVariable(context, rvp, definition);
-            } else if (target instanceof SetPropertyProcessor spp) {
-                answer = new ManagedSetProperty(context, spp, 
cast(definition));
-            } else if (target instanceof ExchangePatternProcessor epp) {
-                answer = new ManagedSetExchangePattern(context, epp, 
definition);
-            } else if (target instanceof ScriptProcessor scrp) {
-                answer = new ManagedScript(context, scrp, cast(definition));
-            } else if (target instanceof StepProcessor stepp) {
-                answer = new ManagedStep(context, stepp, definition);
-            } else if (target instanceof StopProcessor stopp) {
-                answer = new ManagedStop(context, stopp, definition);
-            } else if (target instanceof ThreadsProcessor tp) {
-                answer = new ManagedThreads(context, tp, definition);
-            } else if (target instanceof ThrowExceptionProcessor tep) {
-                answer = new ManagedThrowException(context, tep, definition);
-            } else if (target instanceof TransformProcessor) {
-                answer = new ManagedTransformer(context, target, 
cast(definition));
-            } else if (target instanceof DataTypeProcessor) {
-                answer = new ManagedDataTypeTransformer(context, target, 
cast(definition));
-            } else if (target instanceof PredicateValidatingProcessor pvp) {
-                answer = new ManagedValidate(context, pvp, cast(definition));
-            } else if (target instanceof WireTapProcessor wtp) {
-                answer = new ManagedWireTapProcessor(context, wtp, definition);
-            } else if (target instanceof SendDynamicProcessor sdp) {
-                answer = new ManagedSendDynamicProcessor(context, sdp, 
definition);
-            } else if (target instanceof SendProcessor sp) {
-                // special for sending to throughput logger
-                if (sp.getDestination() instanceof LogEndpoint le && 
le.getLogger() instanceof ThroughputLogger tl) {
-                    answer = new ManagedThroughputLogger(context, tl, 
definition, le);
-                }
-                // regular send processor
-                if (answer == null) {
-                    answer = new ManagedSendProcessor(context, sp, definition);
-                }
-            } else if (target instanceof BeanProcessor bp) {
-                answer = new ManagedBeanProcessor(context, bp, definition);
-            } else if (target instanceof IdempotentConsumer ic) {
-                answer = new ManagedIdempotentConsumer(context, ic, 
cast(definition));
-            } else if (target instanceof AggregateProcessor ap) {
-                answer = new ManagedAggregateProcessor(context, ap, 
cast(definition));
-            } else if (target instanceof Enricher e) {
-                answer = new ManagedEnricher(context, e, cast(definition));
-            } else if (target instanceof PollProcessor pp) {
-                answer = new ManagedPoll(context, pp, cast(definition));
-            } else if (target instanceof PollEnricher pe) {
-                answer = new ManagedPollEnricher(context, pe, 
cast(definition));
+            answer = findManagedProcessorForConversionTypes(context, target, 
definition);
+            if (answer == null) {
+                answer = findManagedProcessorForRoutingTypes(context, target, 
definition);
+            }
+            if (answer == null) {
+                answer = findManagedProcessorForMiscTypes(context, target, 
definition);
             }
 
             // special for custom load balancer
@@ -527,6 +404,152 @@ public class DefaultManagementObjectStrategy implements 
ManagementObjectStrategy
         return answer;
     }
 
+    private ManagedProcessor findManagedProcessorForConversionTypes(
+            CamelContext context, Processor target, ProcessorDefinition<?> 
definition) {
+        if (target instanceof ConvertBodyProcessor cbp) {
+            return new ManagedConvertBody(context, cbp, definition);
+        } else if (target instanceof ConvertHeaderProcessor chp) {
+            return new ManagedConvertHeader(context, chp, definition);
+        } else if (target instanceof ConvertVariableProcessor cvp) {
+            return new ManagedConvertVariable(context, cvp, definition);
+        } else if (target instanceof MarshalProcessor mp) {
+            return new ManagedMarshal(context, mp, cast(definition));
+        } else if (target instanceof UnmarshalProcessor up) {
+            return new ManagedUnmarshal(context, up, cast(definition));
+        } else if (target instanceof TransformProcessor) {
+            return new ManagedTransformer(context, target, cast(definition));
+        } else if (target instanceof DataTypeProcessor) {
+            return new ManagedDataTypeTransformer(context, target, 
cast(definition));
+        }
+        return null;
+    }
+
+    private ManagedProcessor findManagedProcessorForRoutingTypes(
+            CamelContext context, Processor target, ProcessorDefinition<?> 
definition) {
+        // NOTE: check subclasses before their parent type (e.g. Splitter 
before MulticastProcessor,
+        // DynamicRouter before RoutingSlip) — a subclass would otherwise 
match the parent branch first.
+        if (target instanceof SwitchProcessor sp) {
+            return new ManagedSwitch(context, sp, definition);
+        } else if (target instanceof ChoiceProcessor cp) {
+            return new ManagedChoice(context, cp, definition);
+        } else if (target instanceof DynamicRouter dr) {
+            return new ManagedDynamicRouter(context, dr, cast(definition));
+        } else if (target instanceof RoutingSlip rs) {
+            return new ManagedRoutingSlip(context, rs, cast(definition));
+        } else if (target instanceof FilterProcessor fp) {
+            return new ManagedFilter(context, fp, (ExpressionNode) definition);
+        } else if (target instanceof RecipientList rl) {
+            return new ManagedRecipientList(context, rl, cast(definition));
+        } else if (target instanceof Splitter s) {
+            return new ManagedSplitter(context, s, cast(definition));
+        } else if (target instanceof MulticastProcessor mcp) {
+            return new ManagedMulticast(context, mcp, definition);
+        } else if (target instanceof Resequencer r) {
+            return new ManagedResequencer(context, r, definition);
+        } else if (target instanceof StreamResequencer sr) {
+            return new ManagedResequencer(context, sr, definition);
+        } else if (target instanceof AggregateProcessor ap) {
+            return new ManagedAggregateProcessor(context, ap, 
cast(definition));
+        } else if (target instanceof IdempotentConsumer ic) {
+            return new ManagedIdempotentConsumer(context, ic, 
cast(definition));
+        } else if (target instanceof Enricher e) {
+            return new ManagedEnricher(context, e, cast(definition));
+        } else if (target instanceof PollProcessor pp) {
+            return new ManagedPoll(context, pp, cast(definition));
+        } else if (target instanceof PollEnricher pe) {
+            return new ManagedPollEnricher(context, pe, cast(definition));
+        } else if (target instanceof FailOverLoadBalancer folb) {
+            return new ManagedFailoverLoadBalancer(context, folb, 
cast(definition));
+        } else if (target instanceof RandomLoadBalancer rlb) {
+            return new ManagedRandomLoadBalancer(context, rlb, 
cast(definition));
+        } else if (target instanceof RoundRobinLoadBalancer rrlb) {
+            return new ManagedRoundRobinLoadBalancer(context, rrlb, 
cast(definition));
+        } else if (target instanceof StickyLoadBalancer slb) {
+            return new ManagedStickyLoadBalancer(context, slb, 
cast(definition));
+        } else if (target instanceof TopicLoadBalancer tlb) {
+            return new ManagedTopicLoadBalancer(context, tlb, 
cast(definition));
+        } else if (target instanceof WeightedLoadBalancer wlb) {
+            return new ManagedWeightedLoadBalancer(context, wlb, 
cast(definition));
+        }
+        return null;
+    }
+
+    private ManagedProcessor findManagedProcessorForMiscTypes(
+            CamelContext context, Processor target, ProcessorDefinition<?> 
definition) {
+        if (target instanceof ClaimCheckProcessor ccp) {
+            return new ManagedClaimCheck(context, ccp, definition);
+        } else if (target instanceof Delayer d) {
+            return new ManagedDelayer(context, d, definition);
+        } else if (target instanceof DisabledProcessor dp) {
+            return new ManagedDisabled(context, dp, definition);
+        } else if (target instanceof TryProcessor tryProc) {
+            return new ManagedDoTry(context, tryProc, cast(definition));
+        } else if (target instanceof CatchProcessor catchProc) {
+            return new ManagedDoCatch(context, catchProc, cast(definition));
+        } else if (target instanceof FinallyProcessor fp) {
+            return new ManagedDoFinally(context, fp, cast(definition));
+        } else if (target instanceof Throttler t) {
+            return new ManagedThrottler(context, t, definition);
+        } else if (target instanceof LogProcessor lp) {
+            return new ManagedLog(context, lp, definition);
+        } else if (target instanceof LoopProcessor loopProc) {
+            return new ManagedLoop(context, loopProc, cast(definition));
+        } else if (target instanceof SamplingThrottler st) {
+            return new ManagedSamplingThrottler(context, st, definition);
+        } else if (target instanceof RollbackProcessor rp) {
+            return new ManagedRollback(context, rp, definition);
+        } else if (target instanceof SetBodyProcessor sbp) {
+            return new ManagedSetBody(context, sbp, cast(definition));
+        } else if (target instanceof RemoveHeaderProcessor rhp) {
+            return new ManagedRemoveHeader(context, rhp, definition);
+        } else if (target instanceof RemoveHeadersProcessor rhsp) {
+            return new ManagedRemoveHeaders(context, rhsp, definition);
+        } else if (target instanceof SetHeaderProcessor shp) {
+            return new ManagedSetHeader(context, shp, cast(definition));
+        } else if (target instanceof SetHeadersProcessor shsp) {
+            return new ManagedSetHeaders(context, shsp, cast(definition));
+        } else if (target instanceof SetVariableProcessor svp) {
+            return new ManagedSetVariable(context, svp, cast(definition));
+        } else if (target instanceof SetVariablesProcessor svsp) {
+            return new ManagedSetVariables(context, svsp, cast(definition));
+        } else if (target instanceof RemovePropertyProcessor rpp) {
+            return new ManagedRemoveProperty(context, rpp, definition);
+        } else if (target instanceof RemovePropertiesProcessor rpsp) {
+            return new ManagedRemoveProperties(context, rpsp, definition);
+        } else if (target instanceof RemoveVariableProcessor rvp) {
+            return new ManagedRemoveVariable(context, rvp, definition);
+        } else if (target instanceof SetPropertyProcessor spp) {
+            return new ManagedSetProperty(context, spp, cast(definition));
+        } else if (target instanceof ExchangePatternProcessor epp) {
+            return new ManagedSetExchangePattern(context, epp, definition);
+        } else if (target instanceof ScriptProcessor scrp) {
+            return new ManagedScript(context, scrp, cast(definition));
+        } else if (target instanceof StepProcessor stepp) {
+            return new ManagedStep(context, stepp, definition);
+        } else if (target instanceof StopProcessor stopp) {
+            return new ManagedStop(context, stopp, definition);
+        } else if (target instanceof ThreadsProcessor tp) {
+            return new ManagedThreads(context, tp, definition);
+        } else if (target instanceof ThrowExceptionProcessor tep) {
+            return new ManagedThrowException(context, tep, definition);
+        } else if (target instanceof PredicateValidatingProcessor pvp) {
+            return new ManagedValidate(context, pvp, cast(definition));
+        } else if (target instanceof WireTapProcessor wtp) {
+            return new ManagedWireTapProcessor(context, wtp, definition);
+        } else if (target instanceof SendDynamicProcessor sdp) {
+            return new ManagedSendDynamicProcessor(context, sdp, definition);
+        } else if (target instanceof SendProcessor sp) {
+            // special for sending to throughput logger
+            if (sp.getDestination() instanceof LogEndpoint le && 
le.getLogger() instanceof ThroughputLogger tl) {
+                return new ManagedThroughputLogger(context, tl, definition, 
le);
+            }
+            return new ManagedSendProcessor(context, sp, definition);
+        } else if (target instanceof BeanProcessor bp) {
+            return new ManagedBeanProcessor(context, bp, definition);
+        }
+        return null;
+    }
+
     @SuppressWarnings("unchecked")
     private <T extends ProcessorDefinition<?>> T cast(ProcessorDefinition<?> 
definition) {
         return (T) definition;
diff --git 
a/core/camel-support/src/main/java/org/apache/camel/support/component/ApiMethodParser.java
 
b/core/camel-support/src/main/java/org/apache/camel/support/component/ApiMethodParser.java
index 05cf9e413ae4..562a57dfb2ea 100644
--- 
a/core/camel-support/src/main/java/org/apache/camel/support/component/ApiMethodParser.java
+++ 
b/core/camel-support/src/main/java/org/apache/camel/support/component/ApiMethodParser.java
@@ -173,65 +173,13 @@ public abstract class ApiMethodParser<T> {
             Map<String, String> args = signaturesArguments.get(signature);
             if (args != null) {
                 for (Map.Entry<String, String> entry : args.entrySet()) {
-                    String argName = entry.getKey();
-                    String rawTypeArg = entry.getValue();
-                    String shortTypeArgs = rawTypeArg;
-                    String typeArg = null;
-                    // handle generics
-                    pos = shortTypeArgs.indexOf('<');
-                    if (pos != -1) {
-                        typeArg = shortTypeArgs.substring(pos);
-                        // remove leading and trailing < > as that is what the 
old way was doing
-                        if (typeArg.startsWith("<")) {
-                            typeArg = typeArg.substring(1);
-                        }
-                        if (typeArg.endsWith(">")) {
-                            typeArg = typeArg.substring(0, typeArg.length() - 
1);
-                        }
-                        shortTypeArgs = shortTypeArgs.substring(0, pos);
-                    }
-                    final Class<?> type = forName(shortTypeArgs);
-                    argTypes.add(type);
-
-                    String typeDesc = null;
-                    if (parameters != null && argName != null) {
-                        Map<String, String> params = parameters.get(name);
-                        if (params != null) {
-                            typeDesc = params.get(argName);
-                        }
-                    }
-                    arguments.add(new ApiMethodArg(argName, type, typeArg, 
rawTypeArg, typeDesc));
+                    argTypes.add(parseSignatureArg(name, entry.getKey(), 
entry.getValue(), arguments, false));
                 }
             }
             args = signaturesProperties.get(signature);
             if (args != null) {
                 for (Map.Entry<String, String> entry : args.entrySet()) {
-                    String argName = entry.getKey();
-                    String rawTypeArg = entry.getValue();
-                    String shortTypeArgs = rawTypeArg;
-                    String typeArg = null;
-                    // handle generics
-                    pos = shortTypeArgs.indexOf('<');
-                    if (pos != -1) {
-                        typeArg = shortTypeArgs.substring(pos);
-                        // remove leading and trailing < > as that is what the 
old way was doing
-                        if (typeArg.startsWith("<")) {
-                            typeArg = typeArg.substring(1);
-                        }
-                        if (typeArg.endsWith(">")) {
-                            typeArg = typeArg.substring(0, typeArg.length() - 
1);
-                        }
-                        shortTypeArgs = shortTypeArgs.substring(0, pos);
-                    }
-                    final Class<?> type = forName(shortTypeArgs);
-                    String typeDesc = null;
-                    if (parameters != null && argName != null) {
-                        Map<String, String> params = parameters.get(name);
-                        if (params != null) {
-                            typeDesc = params.get(argName);
-                        }
-                    }
-                    properties.add(new ApiMethodArg(argName, type, typeArg, 
rawTypeArg, typeDesc, true));
+                    parseSignatureArg(name, entry.getKey(), entry.getValue(), 
properties, true);
                 }
             }
 
@@ -300,6 +248,36 @@ public abstract class ApiMethodParser<T> {
         return result;
     }
 
+    private Class<?> parseSignatureArg(
+            String methodName, String argName, String rawTypeArg,
+            List<ApiMethodArg> target, boolean isProperty) {
+        String shortTypeArgs = rawTypeArg;
+        String typeArg = null;
+        // handle generics
+        int pos = shortTypeArgs.indexOf('<');
+        if (pos != -1) {
+            typeArg = shortTypeArgs.substring(pos);
+            // remove leading and trailing < > as that is what the old way was 
doing
+            if (typeArg.startsWith("<")) {
+                typeArg = typeArg.substring(1);
+            }
+            if (typeArg.endsWith(">")) {
+                typeArg = typeArg.substring(0, typeArg.length() - 1);
+            }
+            shortTypeArgs = shortTypeArgs.substring(0, pos);
+        }
+        final Class<?> type = forName(shortTypeArgs);
+        String typeDesc = null;
+        if (parameters != null && argName != null) {
+            Map<String, String> params = parameters.get(methodName);
+            if (params != null) {
+                typeDesc = params.get(argName);
+            }
+        }
+        target.add(new ApiMethodArg(argName, type, typeArg, rawTypeArg, 
typeDesc, isProperty));
+        return type;
+    }
+
     private static Map<String, Class<?>> extractArguments(List<ApiMethodModel> 
result) {
         Map<String, Class<?>> allArguments = new HashMap<>();
         for (ApiMethodModel model : result) {
diff --git 
a/core/camel-support/src/main/java/org/apache/camel/support/processor/DefaultExchangeFormatter.java
 
b/core/camel-support/src/main/java/org/apache/camel/support/processor/DefaultExchangeFormatter.java
index 9ac3638c0d0a..a630260e1d2b 100644
--- 
a/core/camel-support/src/main/java/org/apache/camel/support/processor/DefaultExchangeFormatter.java
+++ 
b/core/camel-support/src/main/java/org/apache/camel/support/processor/DefaultExchangeFormatter.java
@@ -134,6 +134,44 @@ public class DefaultExchangeFormatter implements 
ExchangeFormatter {
         }
 
         StringBuilder sb = new StringBuilder(512);
+        appendExchangeMetadata(exchange, sb);
+        appendMessageParts(exchange, in, sb);
+        appendException(exchange, sb);
+
+        // only cut if we hit max-chars limit (or are using multiline
+        if (multiline || maxChars > 0 && sb.length() > maxChars) {
+            StringBuilder answer = new StringBuilder(sb.length());
+            for (String s : sb.toString().split(SEPARATOR)) {
+                if (s != null) {
+                    if (s.length() > maxChars) {
+                        s = s.substring(0, maxChars);
+                        answer.append(s).append("...");
+                    } else {
+                        answer.append(s);
+                    }
+                    if (multiline) {
+                        answer.append(LS);
+                    }
+                }
+            }
+
+            // switch string buffer
+            sb = answer;
+        }
+
+        if (!multiline) {
+            // get rid of the leading comma space if needed
+            if (sb.length() > 1 && sb.charAt(0) == ',' && sb.charAt(1) == ' ') 
{
+                sb.replace(0, 2, "");
+            }
+
+        }
+        sb.insert(0, "Exchange[");
+        sb.append("]");
+        return sb.toString();
+    }
+
+    private void appendExchangeMetadata(Exchange exchange, StringBuilder sb) {
         if (showAll || showExchangeId) {
             if (multiline) {
                 sb.append(SEPARATOR);
@@ -170,6 +208,9 @@ public class DefaultExchangeFormatter implements 
ExchangeFormatter {
             }
             style(sb, "ExchangePattern").append(exchange.getPattern());
         }
+    }
+
+    private void appendMessageParts(Exchange exchange, Message in, 
StringBuilder sb) {
         if (showAll || showAllProperties) {
             if (multiline) {
                 sb.append(SEPARATOR);
@@ -211,7 +252,9 @@ public class DefaultExchangeFormatter implements 
ExchangeFormatter {
             }
             style(sb, "Body").append(body);
         }
+    }
 
+    private void appendException(Exchange exchange, StringBuilder sb) {
         if (showAll || showException || showCaughtException) {
 
             // try exception on exchange first
@@ -240,38 +283,6 @@ public class DefaultExchangeFormatter implements 
ExchangeFormatter {
                 }
             }
         }
-
-        // only cut if we hit max-chars limit (or are using multiline
-        if (multiline || maxChars > 0 && sb.length() > maxChars) {
-            StringBuilder answer = new StringBuilder(sb.length());
-            for (String s : sb.toString().split(SEPARATOR)) {
-                if (s != null) {
-                    if (s.length() > maxChars) {
-                        s = s.substring(0, maxChars);
-                        answer.append(s).append("...");
-                    } else {
-                        answer.append(s);
-                    }
-                    if (multiline) {
-                        answer.append(LS);
-                    }
-                }
-            }
-
-            // switch string buffer
-            sb = answer;
-        }
-
-        if (!multiline) {
-            // get rid of the leading comma space if needed
-            if (sb.length() > 1 && sb.charAt(0) == ',' && sb.charAt(1) == ' ') 
{
-                sb.replace(0, 2, "");
-            }
-
-        }
-        sb.insert(0, "Exchange[");
-        sb.append("]");
-        return sb.toString();
     }
 
     /**

Reply via email to