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.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 explicitid
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/>
@Inject @ContextName("foo") CamelContext context;
@Inject @Named("bar") Endpoint endpoint;
CamelContext
beans are automatically qualified with both theNamed
andContextName
qualifiers. If the importedCamelContext
element doesn't have anid
attribute, the corresponding bean is deployed with the built-inDefault
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");
<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:
- {}
-
-