use of org.apache.camel.RouteConfigurationsBuilder in project camel-quarkus by apache.
the class CamelContextRecorder method addRoutes.
public void addRoutes(RuntimeValue<CamelContext> context, List<String> nonCdiRoutesBuilderClassNames) {
List<RoutesBuilder> allRoutesBuilders = new ArrayList<>();
try {
for (String nonCdiRoutesBuilderClassName : nonCdiRoutesBuilderClassNames) {
Class<RoutesBuilder> nonCdiRoutesBuilderClass = context.getValue().getClassResolver().resolveClass(nonCdiRoutesBuilderClassName, RoutesBuilder.class);
allRoutesBuilders.add(context.getValue().getInjector().newInstance(nonCdiRoutesBuilderClass));
}
for (LambdaRouteBuilder builder : context.getValue().getRegistry().findByType(LambdaRouteBuilder.class)) {
allRoutesBuilders.add(new RouteBuilder() {
@Override
public void configure() throws Exception {
builder.accept(this);
}
});
}
for (RoutesBuilder cdiRoutesBuilder : context.getValue().getRegistry().findByType(RoutesBuilder.class)) {
allRoutesBuilders.add(cdiRoutesBuilder);
}
// Add RouteConfigurationsBuilders before RoutesBuilders
for (RoutesBuilder routesBuilder : allRoutesBuilders) {
if (routesBuilder instanceof RouteConfigurationsBuilder) {
context.getValue().addRoutesConfigurations((RouteConfigurationsBuilder) routesBuilder);
}
}
for (RoutesBuilder routesBuilder : allRoutesBuilders) {
if (!(routesBuilder instanceof RouteConfigurationsBuilder)) {
context.getValue().addRoutes(routesBuilder);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations