davsclaus commented on code in PR #31016:
URL: https://github.com/apache/camel/pull/31016#discussion_r4723733030
##########
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:
Reworded the description along the lines of the suggestion (with name: a
registry bean or a classpath cron service id, quartz for camel-quartz, spring
for camel-spring; fails to start when neither matches; without name: the only
registry bean, or else the one from a classpath module), and regenerated the
metadata, catalog and component DSL in 0019a5cd7b2a.
_Claude Code on behalf of Claus Ibsen_
##########
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:
Added the `@throws IllegalArgumentException` tag to the Javadoc of
`resolveCamelCronService` in 0019a5cd7b2a.
_Claude Code on behalf of Claus Ibsen_
##########
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:
No change needed: the first generic `FACTORY_KEY` lookup only runs when
`name` is empty, and that branch returns. With a name, the generic lookup runs
once, as the last fallback after the id-specific `cron-service-<id>` file, and
its result is kept for the error message (it names the id of the cron service
that is on the classpath). It only runs on a misconfigured `cronService`, at
startup.
_Claude Code on behalf of Claus Ibsen_
--
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]