gnodet-bot commented on code in PR #31016:
URL: https://github.com/apache/camel/pull/31016#discussion_r4720467535


##########
components/camel-cron/src/main/java/org/apache/camel/component/cron/CronComponent.java:
##########
@@ -35,9 +35,11 @@
 public class CronComponent extends DefaultComponent {
 
     @Metadata(label = "advanced",
-              description = "The name of the CamelCronService bean in the 
registry to use, when more than one is bound. If"
-                            + " not set, the only CamelCronService in the 
registry is used. If the registry has none, the one"
-                            + " that a module on the classpath provides is 
used, such as camel-quartz or camel-spring.")
+              description = "The CamelCronService to use: the name of a 
CamelCronService bean in the registry, or else the"
+                            + " id of the cron service of a module on the 
classpath, quartz (camel-quartz) or spring"
+                            + " (camel-spring). The component fails to start 
when neither matches. If not set, the only"
+                            + " CamelCronService in the registry is used. If 
the registry has none, the one that a module on"
+                            + " the classpath provides is used, such as 
camel-quartz or camel-spring.")

Review Comment:
   💬 **Doc clarity (medium):** The description conflates the with-name and 
without-name cases in a single run-on block. "quartz (camel-quartz) or spring 
(camel-spring)" reads as if the parenthetical clarifies something previously 
stated, but the name is actually the value and the module is the parenthetical 
— the reverse of natural English. Consider restructuring for readability:
   
   ```suggestion
                 description = "The CamelCronService to use. When set, it is 
the name of a CamelCronService bean in the"
                               + " registry, or the id of a classpath cron 
service (quartz for camel-quartz, spring for"
                               + " camel-spring). Fails to start when neither 
matches. When not set, the only"
                               + " CamelCronService in the registry is used, or 
else the one from a classpath module.")
   ```



##########
components/camel-cron/src/main/java/org/apache/camel/component/cron/CronHelper.java:
##########
@@ -44,8 +48,30 @@ public static CamelCronService 
resolveCamelCronService(CamelContext context, Str
             return service;
         }
 
-        // Fallback to factory finder
-        return ResolverHelper.resolveBootstrapService(context, FACTORY_KEY, 
CamelCronService.class).orElse(null);
+        if (ObjectHelper.isEmpty(name)) {
+            // Fallback to factory finder
+            return ResolverHelper.resolveBootstrapService(context, 
FACTORY_KEY, CamelCronService.class).orElse(null);
+        }
+
+        // the cron service of a module on the classpath, by its id, such as 
cron/cron-service-quartz
+        service = ResolverHelper.resolveBootstrapService(context, FACTORY_KEY 
+ "-" + name, CamelCronService.class)
+                .orElse(null);
+        if (service != null) {
+            return service;
+        }
+        // a module that has no cron service file of its id: its cron service 
when the id matches
+        service = ResolverHelper.resolveBootstrapService(context, FACTORY_KEY, 
CamelCronService.class).orElse(null);

Review Comment:
   💬 **Minor (low):** The generic `FACTORY_KEY` lookup runs twice — once at 
line 53 (the registry-only path) and again here, and the second-call result is 
immediately discarded when the id doesn't match. Not a correctness issue (this 
path only runs for misconfigured `cronService` values), but a local variable 
assignment from the first lookup or an early exit would avoid creating and 
discarding the extra service instance.



##########
components/camel-cron/src/main/java/org/apache/camel/component/cron/CronHelper.java:
##########
@@ -30,7 +30,11 @@ private CronHelper() {
     }
 
     /**
-     * Helper to lookup/create an instance of {@link CamelCronService}
+     * Helper to lookup/create an instance of {@link CamelCronService}.
+     * <p>
+     * Without a name, the only {@link CamelCronService} of the registry is 
used, or else the one that a module on the
+     * classpath provides. With a name, the bean of the registry with this 
name is used, or else the cron service of a
+     * module on the classpath whose id is the name, such as quartz or spring. 
A name that matches neither fails.

Review Comment:
   💬 **Doc (low):** The new Javadoc block describes the resolution logic well, 
but doesn't declare `@throws IllegalArgumentException` for the new failure 
path. Adding it makes the contract explicit for callers:
   
   ```
        * @throws IllegalArgumentException if {@code name} is set but matches 
neither a registry bean nor a classpath cron service id
   ```



-- 
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