jamesnetherton commented on code in PR #30338:
URL: https://github.com/apache/camel/pull/30338#discussion_r4613035850


##########
core/camel-support/src/main/java/org/apache/camel/support/PropertyConfigurerHelper.java:
##########
@@ -103,6 +108,75 @@ public static PropertyConfigurer 
resolvePropertyConfigurer(CamelContext context,
         return null;
     }
 
+    /**
+     * Resolves the configurer of a component, data format or language by its 
name (such as jackson-dataformat), and
+     * makes sure it is the configurer of the given target.
+     * <p>
+     * Two JARs can register a configurer with the same name, and then the one 
first on the classpath is found. For
+     * example both camel-jackson (Jackson 2.x) and camel-jackson3 (Jackson 
3.x) register jackson-dataformat, while the
+     * jackson data format is created from camel-jackson3 when both are on the 
classpath. When the configurer found by
+     * name is generated for another type than the target, the configurer 
generated for the type of the target is used
+     * instead.
+     *
+     * @param  context the camel context
+     * @param  name    the name of the configurer, such as jackson-dataformat
+     * @param  target  the component, data format or language to configure, or 
<code>null</code> to only resolve the
+     *                 configurer by its name
+     * @return         the resolved configurer, or <code>null</code> if no 
configurer could be found
+     */
+    public static PropertyConfigurer 
resolvePropertyConfigurerByName(CamelContext context, String name, Object 
target) {

Review Comment:
   Nit: the new fallback is only tested indirectly, through camel-kamelet with 
both real Jackson JARs. Could you add a small unit test in camel-core with two 
`GeneratedPropertyConfigurer`s registered under one name? It could cover:
   - the fallback to the target's own configurer
   - a target with no generated configurer, where the configurer found by name 
is kept
   - a subclass target, where the parent's configurer is kept
   
   _Claude Code on behalf of jamesnetherton_



##########
core/camel-support/src/main/java/org/apache/camel/support/PropertyConfigurerHelper.java:
##########
@@ -103,6 +108,75 @@ public static PropertyConfigurer 
resolvePropertyConfigurer(CamelContext context,
         return null;
     }
 
+    /**
+     * Resolves the configurer of a component, data format or language by its 
name (such as jackson-dataformat), and
+     * makes sure it is the configurer of the given target.
+     * <p>
+     * Two JARs can register a configurer with the same name, and then the one 
first on the classpath is found. For
+     * example both camel-jackson (Jackson 2.x) and camel-jackson3 (Jackson 
3.x) register jackson-dataformat, while the
+     * jackson data format is created from camel-jackson3 when both are on the 
classpath. When the configurer found by
+     * name is generated for another type than the target, the configurer 
generated for the type of the target is used
+     * instead.
+     *
+     * @param  context the camel context
+     * @param  name    the name of the configurer, such as jackson-dataformat
+     * @param  target  the component, data format or language to configure, or 
<code>null</code> to only resolve the
+     *                 configurer by its name
+     * @return         the resolved configurer, or <code>null</code> if no 
configurer could be found
+     */
+    public static PropertyConfigurer 
resolvePropertyConfigurerByName(CamelContext context, String name, Object 
target) {
+        return resolvePropertyConfigurerByName(context, name, target != null ? 
target.getClass() : null);
+    }
+
+    private static PropertyConfigurer resolvePropertyConfigurerByName(

Review Comment:
   Nit: the private overload has the same name as the public 
`resolvePropertyConfigurerByName(CamelContext, String, Object)` and differs 
only in taking a `Class<?>`. Code outside this class that passes a `Class` 
object gets the public overload, which treats the `Class` instance as the 
target. That's harmless today, but it's easy to misuse. Could the private one 
get a different name, e.g. `resolvePropertyConfigurerByNameForType`?
   
   _Claude Code on behalf of jamesnetherton_



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to