60.8. Camel Bean 集成
60.8.1. Camel 注解 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
作为 Camel Bean 集成 的一部分,Camel 附带了一组可无缝支持 的注解 。因此,您可以在 CDI Bean 中使用其中任意注解,例如:
Camel 注解 | CDI 等效功能 | |
---|---|---|
配置属性 |
@PropertyInject("key") String value;
| 如果使用 DeltaSpike 配置机制 : @Inject @ConfigProperty(name = "key") String value;
如需了解更多详细信息,请参阅 配置属性。 |
制作者模板注入(默认 Camel 上下文) |
@Produce(uri = "mock:outbound") ProducerTemplate producer; @Produce(uri = "mock:outbound") FluentProducerTemplate producer;
|
|
端点注入(默认 Camel 上下文) |
@EndpointInject(uri = "direct:inbound") Endpoint endpoint;
|
@Inject @Uri("direct:inbound") Endpoint endpoint;
|
端点注入(按名称的Camel 上下文) |
@EndpointInject(uri = "direct:inbound", context = "foo") Endpoint contextEndpoint;
|
@Inject @ContextName("foo") @Uri("direct:inbound") Endpoint contextEndpoint;
|
Bean 注入(按类型) |
@BeanInject MyBean bean;
|
@Inject MyBean bean;
|
Bean (按名称) |
@BeanInject("foo") MyBean bean;
|
@Inject @Named("foo") MyBean bean;
|
使用 POJO |
@Consume(uri = "seda:inbound") void consume(@Body String body) { //... }
|
|