@Retention(value=RUNTIME) @Target(value=TYPE) public @interface ImportResource
CamelContext
elements and other Camel primitives are automatically
deployed as CDI beans during the container bootstrap so that they become
available for injection at runtime. If such an element has an explicit
id
attribute set, the corresponding CDI bean is qualified with the
@Named
qualifier, e.g., given the following Camel XML configuration:
<camelContext id="foo">
<endpoint id="bar" uri="seda:inbound">
<property key="queue" value="#queue"/>
<property key="concurrentConsumers" value="10"/>
</endpoint>
<camelContext/>
Corresponding CDI beans are automatically deployed and can be injected, e.g.:
@Inject
@ContextName("foo")
CamelContext context;
@Inject
@Named("bar")
Endpoint endpoint;
Note that CamelContext
beans are automatically qualified with both
the Named
and ContextName
qualifiers. If the imported
CamelContext
element doesn't have an id
attribute, the
corresponding bean is deployed with the built-in Default
qualifier.
Conversely, CDI beans deployed in the application can be referred to from
the Camel XML configuration, usually using the ref
attribute, e.g.,
given the following bean declared:
@Produces
@Named("baz")
Processor processor = exchange -> exchange.getIn().setHeader("qux", "quux");
A reference to that bean can be declared in the imported Camel XML configuration,
e.g.:
<camelContext id="foo">
<route>
<from uri="..."/>
<process ref="baz"/>
</route>
<camelContext/>
public abstract String[] value
Apache Camel