Claus Ibsen created CAMEL-24709:
-----------------------------------
Summary: camel-yaml-dsl - class not found hint for beans should
use the bean metadata on the classpath, not a hardcoded aggregation strategy
package
Key: CAMEL-24709
URL: https://issues.apache.org/jira/browse/CAMEL-24709
Project: Camel
Issue Type: Improvement
Components: camel-yaml-dsl
Reporter: Claus Ibsen
The class-not-found hint in the YAML beans deserializer (CAMEL-24702, PR 26361)
suggests a built-in class only for names ending in AggregationStrategy, by
trying the hardcoded package org.apache.camel.processor.aggregate. Camel ships
many more out-of-the-box beans (aggregation repositories, idempotent
repositories, header filter strategies, key-value repositories, ...) in
camel-core and in some 30 components, and the catalog lists them (camel-catalog
beans/*.json with javaType and interfaceType).
The same information is on the classpath at runtime, generated by the build
tools into every jar that has such beans:
META-INF/services/org/apache/camel/bean.properties (the bean names) and
META-INF/services/org/apache/camel/bean/<Name>.json (javaType, interfaceType,
description). The runtime cannot depend on camel-catalog, but it can read these
resources, so the hint can be data driven:
* {{type: "#class:com.foo.UseLatestAggregationStrategy"}} (not found) -> did
you mean org.apache.camel.processor.aggregate.UseLatestAggregationStrategy
(org.apache.camel.AggregationStrategy)?
* {{type: "#class:MemoryAggregationRepository"}} -> the same, from the
repository bean metadata
* a name that is not a built-in bean keeps the generic hint (check the package
name; a class from another library needs its dependency added)
Possibly also: when the missing class name does not match a bean by simple
name, but the option that references it needs an interface
(aggregationStrategy, idempotentRepository), list the built-in beans of that
interface from the same metadata. The write-time check in camel-jbang
(camel_validate_source) already does this from the catalog
(CatalogDocs.beansOfInterface); the runtime hint should give the same answer
from the classpath resources.
Found while reviewing PR 26361.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)