ppalaga opened a new pull request #2103:
URL: https://github.com/apache/camel-quarkus/pull/2103


   This is a PoC how we could better support the build time analysis of Camel 
route definitions. The main idea is to have a new kind of model builder (called 
`CamelDefinitionsBuilder` in this proposal) that would make the build time 
inspection explicit for the end users. 
   Instead of plain `configure()` in the existing Camel `RouteBuilder`, there 
is `configure(DefinitionsBuilderContext)` in the new `CamelDefinitionsBuilder`. 
`DefinitionsBuilderContext.getPhase()` can be used by end users to figure out 
whether the builder is called at build time or at runtime. They can thus add 
some logic (if necessary) to avoid accessing runtime resources at build time, 
including CamelContext available via 
`CamelDefinitionsBuilder.DefinitionsBuilderContext.getContext()`.
   
   Pros:
   
   * The way of writing routes stays very close to the existing `RouteBuilder` 
's Java DSL.
   * The new `CamelDefinitionsBuilder` are opt-in. Who decides for them, 
explicitly accepts both the perf. benefits and any eventual development 
overhead.
   
   Cons:
   
   * This solution makes the end users responsible for making their routes 
inspectable at build time. This may result in unclean code full of ifs.
   * The API does not prevent end users from writing non-working code. That 
would require a redesign of the Java DSL with properly modeled runtime 
resources. Hard to say without trying whether something like that is even 
possible.
   
   Open questions/issues:
   
   * Figure out how would this or any other alternative solution play with CDI 
injection of fields in `CamelDefinitionsBuilder`s.
   


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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to