Description
So that user can use their existing Camel XML files with CDI or use Camel XML for configuring their Camel contexts.
For example, given the following Camel XML:
<camelContext id="test" errorHandlerRef="error-handler" xmlns="http://camel.apache.org/schema/spring"> <errorHandler id="error-handler" type="LoggingErrorHandler" logName="error" level="WARN"/> <route> <from uri="direct:inbound"/> <choice> <when> <simple>${body} contains 'exception'</simple> <throwException ref="failure"/> </when> <otherwise> <transform> <simple>Response to ${body}</simple> </transform> <to uri="mock:outbound"/> </otherwise> </choice> </route> </camelContext>
And following bean:
@Named @Produces Exception failure = new CamelException("failure message!");
The Camel XML elements with an id attributes (errorHandler in the example) get deployed as CDI beans and vice-versa the ref attributes can refer to CDI beans (@Named("failure") in the example).
The current proposition is to expose an annotation that the developer can use on any CDI bean to declare the Camel XML files to import in her/his Camel CDI application, e.g.:
@ImportResource("imported-context.xml") class MyCamelCdiBean { }