/** * Create a new route from the given RouteBuilder instance and service name. * @param routeBuilder RouteBuilder instance containing an @Route definition * @param camelContext CamelContext * @param namespace the namespace to append to switchyard:// service URIs * @return the route definition */ public static List<RouteDefinition> createRoute(RouteBuilder routeBuilder, SwitchYardCamelContext camelContext, String namespace) { // Create the route and tell it to create a route try { if (camelContext != null) { routeBuilder.setContext(camelContext); } routeBuilder.configure(); List<RouteDefinition> routes = routeBuilder.getRouteCollection().getRoutes(); if (routes.isEmpty()) { throw CamelComponentMessages.MESSAGES.noRoutesFoundinJavaDSLClass(routeBuilder.getClass().getName()); } return routes; } catch (Exception ex) { throw CamelComponentMessages.MESSAGES.failedToInitializeDSLClass(routeBuilder.getClass().getName(), ex); } }
/** * Creates new Camel routes in route builder. * @param routeBuilder * @return */ public CamelRouteActionBuilder create(RouteBuilder routeBuilder) { CreateCamelRouteAction camelRouteAction = new CreateCamelRouteAction(); try { if (!routeBuilder.getContext().equals(getCamelContext())) { routeBuilder.configureRoutes(getCamelContext()); } else { routeBuilder.configure(); } camelRouteAction.setRoutes(routeBuilder.getRouteCollection().getRoutes()); } catch (Exception e) { throw new CitrusRuntimeException("Failed to configure route definitions with camel context", e); } camelRouteAction.setCamelContext(getCamelContext()); action.setDelegate(camelRouteAction); return this; }
private RoutesDefinition mandatoryConvertToRoutesDefinition(String resource, Object instance) { final RoutesDefinition definitions; if (instance instanceof RoutesDefinition) { definitions = (RoutesDefinition)instance; } else if (instance instanceof RouteDefinition) { definitions = new RoutesDefinition(); definitions.route((RouteDefinition)instance); } else if (instance instanceof RouteBuilder) { RouteBuilder builder = (RouteBuilder)instance; try { builder.configure(); definitions = builder.getRouteCollection(); } catch (Exception e) { LOGGER.warn("Unable to configure resource: " + resource, e); throw ObjectHelper.wrapRuntimeCamelException(e); } } else { throw new IllegalArgumentException("Unable to convert instance: " + instance); } return definitions; } }
routeBuilder.configure();
routeBuilder.configure();
routeBuilder.configure();