Package org.apache.camel.cdi
Annotation Type ImportResource
-
@Retention(RUNTIME) @Target(TYPE) @Default public @interface ImportResource
Indicates one or more resources representing Camel XML configuration to import. Resources are currently loaded from the classpath.CamelContextelements 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 explicitidattribute set, the corresponding CDI bean is qualified with the@Namedqualifier, e.g., given the following Camel XML configuration:
Corresponding CDI beans are automatically deployed and can be injected, e.g.:<camelContext id="foo"> <endpoint id="bar" uri="seda:inbound"> <property key="queue" value="#queue"/> <property key="concurrentConsumers" value="10"/> </endpoint> <camelContext/>@Inject @ContextName("foo") CamelContext context;
Note that@Inject @Named("bar") Endpoint endpoint;CamelContextbeans are automatically qualified with both theNamedandContextNamequalifiers. If the importedCamelContextelement doesn't have anidattribute, the corresponding bean is deployed with the built-inDefaultqualifier.Conversely, CDI beans deployed in the application can be referred to from the Camel XML configuration, usually using the
refattribute, e.g., given the following bean declared:
A reference to that bean can be declared in the imported Camel XML configuration, e.g.:@Produces @Named("baz") Processor processor = exchange-> exchange.getIn().setHeader("qux", "quux");<camelContext id="foo"> <route> <from uri="..."/> <process ref="baz"/> </route> <camelContext/>- Since:
- 2.18.0
-
-
Element Detail
-
value
String[] value
Resource locations from which to import Camel XML configuration.- Returns:
- the locations of the resources to import
- Default:
- {}
-
-