### CDI

The Camel CDI component provides an auto-configuration for Apache Camel, using CDI as dependency injection framework. However, it is based on convention-over-configuration.
It implements the standard camel bean integration so that you can use the Camel annotations easily in CDI beans.

For more information about CDI, refer to the http://camel.apache.org/cdi.html[cdi,window=_blank] documentation.

The following example describes how you can consume and assosciate the Camel Context with a route.

[source,java,options="nowrap"]
----
@Startup
@ApplicationScoped
@ContextName("cdi-context")
public class MyRouteBuilder extends RouteBuilder {

    @Override
    public void configure() throws Exception {
    	from("direct:start").transform(body().prepend("Hi"));
    }
}

----

[source,java,options="nowrap"]
----
@Inject
@ContextName("cdi-context")
private CamelContext camelctx;

----

#### Importing XML DSL configuration

Camel CDI integration enables you to import existing XML DSL files via the `@ImportResource` annotation:

[source,java,options="nowrap"]
@ImportResource("camel-context.xml")
class MyBean {
}

[NOTE]
====
The location of the imported file must be present on the deployment classpath. Placing the file into locations such as `WEB-INF` will not work. However, `WEB-INF/classes` will work fine.

====


