davsclaus opened a new pull request, #3135:
URL: https://github.com/apache/camel-kamelets/pull/3135

   Part of #3133.
   
   `KameletsCatalog` found the Kamelets with a ClassGraph scan of the whole 
class path (`acceptPaths("/kamelets/")`), which looks at every JAR on it. With 
the 340 JARs of the Camel CLI that is about 250 ms of the 600 ms that `new 
KameletsCatalog()` takes (`camel catalog kamelet` takes 720 ms in all).
   
   ### Change
   
   - **Listing instead of scanning**: `ClassLoader.getResources("kamelets/")` 
gives the `kamelets` directory of each JAR (or directory) on the class path, 
and the catalog reads the `*.kamelet.yaml` entries of each from there (the 
JAR's own entries, so no lookup on the class path per file). The names are made 
as before (`sanitizeFileName` of the path), so the same Kamelets are found, 
also those of other JARs with a `kamelets` directory.
   - **ClassGraph stays as the fallback**: when the listing finds no Kamelets 
(such as a class loader whose JARs have no directory entries, or a URL that is 
not a JAR or a directory), the class path is scanned as before. It is in a 
nested class, so ClassGraph's classes are loaded only then.
   - **`DefaultCamelCatalog`** is created when a method needs it 
(`getKameletSupportedHeaders`), not with every catalog.
   
   The API is unchanged. Parsing the 259 Kamelets into the CRD model (about 380 
ms) is the other big part; #3133 has ideas for that (a summary index for 
lists), which need more discussion.
   
   ### Measured
   
   JDK 25, macOS (Apple M4 Pro), `new KameletsCatalog().getKamelets()` in a new 
JVM, on the class path of the Camel CLI distribution (341 JARs) plus the 
catalog and its dependencies:
   
   | | 4.23.0 | this PR |
   |---|---|---|
   | `new KameletsCatalog()` | 584-638 ms | 429-435 ms |
   | ClassGraph classes loaded | 127 | 0 |
   
   ### Tests
   
   - `KameletsCatalogDiscoveryTest` (new): the listing finds the same Kamelets 
as the ClassGraph scan, each one the same (compared as JSON); a new catalog has 
the Kamelets.
   - `KameletsCatalogTest` and `KameletsCanonicalTest` pass unchanged: 22 tests 
in the module.
   
   _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]

Reply via email to