Thanks for quick response! I do need reflection for my class. Please see my
dummy Integration below. When I removed annotation, it was not able to find my
‘getRandomNumber’ method. When I added annotation, it worked just fine, but my
VS Code was complaining about missing Quarkus dependency.
Thanks,
Vlad
// camel-k: language=java
// camel-k: trait=quarkus.enabled=true
// camel-k: trait=quarkus.build-mode=native
// camel-k: trait=builder.verbose=true
// camel-k: trait=builder.node-selector.'camelk-builds'='true'
import org.apache.camel.builder.RouteBuilder;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
public class Demo05 extends RouteBuilder {
@Override
public void configure() throws Exception {
// Write your routes here, for example:
from("timer:java?period={{time:1000}}")
.id("demo05")
.bean(this, "getRandomNumber")
.log("Random number: ${body}")
.choice()
.when(simple("${body} > 50"))
.to("direct:greater")
.otherwise()
.to("direct:lower");
from("direct:greater")
.log("Greater than 50: ${body}");
from("direct:lower")
.log("Lower than 50: ${body}");
}
public int getRandomNumber() {
return (int) (Math.random() * 100) + 1;
}
}
> On 15. 4. 2024, at 15:47, Claudio Miranda <[email protected]> wrote:
>
> Em seg., 15 de abr. de 2024 às 14:21, Vladislav Krejcirik
> <[email protected]> escreveu:
>>
>> I’m building Kamel K integration where I’m using Native build due to sparing
>> some Kubernetes resources. I’m using VS Code and RH extension pack for
>> Camel. It seems like I need to tag all my classes with
>> @RegisterForReflection. When I do that, I’m having unresolved dependency -
>> io.quarkus.runtime.annotations.RegisterForReflection. Since the project is
>> not managed by either Maven or Gradle, what is the good practice for
>> including Quarkus .jar files for design time?
>
> Your code only needs RegisterForReflection annotation if your custom
> classes do reflection, see
> https://camel.apache.org/camel-quarkus/3.8.x/user-guide/native-mode.html#reflection
>
> Otherwise there is no need for the annotation.
>
> For in depth doc about the extension development in camel, see
> https://camel.apache.org/camel-quarkus/3.8.x/contributor-guide/create-new-extension.html
>
> --
> Claudio Miranda
>
> [email protected]
> http://www.claudius.com.br