Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note that CDI injection is supported within the type converters.

Camel bean integration

Camel annotations

As part of the Camel bean integration, Camel comes with a set of annotations that are seamlessly supported by Camel CDI. So you can use any of these annotations in your CDI beans, e.g.:

 Camel

...

annotationCDI equivalent
Configuration property
Code Block
languagejava
@PropertyInject("property")
String property;

If using DeltaSpike configuration mechanism:

Code Block
languagejava
@Inject
@ConfigProperty(name = "message")
String property;

See configuration properties for more details.

Producer template injection (default Camel context)
Code Block
languagejava
@Produce(uri = "mock:outbound")
ProducerTemplate producer;
Code Block
languagejava
@Inject
@Uri("direct:outbound")
ProducerTemplate producer;
Endpoint injection (default Camel context)
Code Block
languagejava
@EndpointInject(uri = "direct:inbound")
Endpoint endpoint;
Code Block
languagejava
@Inject
@Uri("direct:inbound")
Endpoint endpoint;
Endpoint injection (Camel context by name)
Code Block
languagejava
@EndpointInject(uri = "direct:inbound", context = "foo")
Endpoint contextEndpoint;
Code Block
languagejava
@Inject
@ContextName("foo")
@Uri("direct:inbound")
Endpoint contextEndpoint;
Bean injection
Code Block
languagejava
@BeanInject
MyBean bean;
Code Block
languagejava
@Inject
MyBean bean;
POJO consuming
Code Block
languagejava
@Consume(uri = "seda:inbound")
void consume(@Body String body) {
    //...
}
 

 

Camel events to CDI events

...