Search in sources :

Example 1 with RouteBuilderDefinition

use of org.apache.camel.model.RouteBuilderDefinition in project camel by apache.

the class AbstractCamelContextFactoryBean method installRoutes.

/**
     * Strategy to install all available routes into the context
     */
protected void installRoutes() throws Exception {
    List<RouteBuilder> builders = new ArrayList<RouteBuilder>();
    // lets add RoutesBuilder's added from references
    if (getBuilderRefs() != null) {
        for (RouteBuilderDefinition builderRef : getBuilderRefs()) {
            RoutesBuilder routes = builderRef.createRoutes(getContext());
            if (routes != null) {
                this.builders.add(routes);
            } else {
                throw new CamelException("Cannot find any routes with this RouteBuilder reference: " + builderRef);
            }
        }
    }
    // install already configured routes
    for (RoutesBuilder routeBuilder : this.builders) {
        getContext().addRoutes(routeBuilder);
    }
    // install builders
    for (RouteBuilder builder : builders) {
        // Inject the annotated resource
        postProcessBeforeInit(builder);
        getContext().addRoutes(builder);
    }
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) CamelException(org.apache.camel.CamelException) ArrayList(java.util.ArrayList) RouteBuilderDefinition(org.apache.camel.model.RouteBuilderDefinition) RoutesBuilder(org.apache.camel.RoutesBuilder)

Aggregations

ArrayList (java.util.ArrayList)1 CamelException (org.apache.camel.CamelException)1 RoutesBuilder (org.apache.camel.RoutesBuilder)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1 RouteBuilderDefinition (org.apache.camel.model.RouteBuilderDefinition)1