private ToDefinition getDroolsNode(RouteDefinition routeDef) { ToDefinition toDrools = null; for ( ProcessorDefinition<?> child : routeDef.getOutputs() ) { toDrools = getDroolsNode( child ); if ( toDrools != null ) { break; } } return toDrools; }
private ToDefinition getDroolsNode(RouteDefinition routeDef) { ToDefinition toDrools = null; for ( ProcessorDefinition<?> child : routeDef.getOutputs() ) { toDrools = getDroolsNode( child ); if ( toDrools != null ) { break; } } return toDrools; }
private static FromDefinition getFromDefinition(ProcessorDefinition<?> definition) { ProcessorDefinition<?> parent = definition.getParent(); if( parent instanceof RouteDefinition ) { RouteDefinition route = (RouteDefinition) parent; List<ProcessorDefinition<?>> outputs = route.getOutputs(); if( outputs!=null && outputs.get(0) == definition) { return route.getInputs().get(0); } } return null; }
protected boolean isWired(EcaDefinition ecaDefinition, RouteDefinition routeDefinition) { for (ProcessorDefinition pd : routeDefinition.getOutputs()) { if (pd instanceof ToDefinition) { ToDefinition td = (ToDefinition) pd; String uri = td.getUriOrRef(); if (uri != null && uri.indexOf(ecaDefinition.getUri()) >= 0) { return true; } } } return false; }
public Processor wrap(RouteContext routeContext, ProcessorDefinition<?> definition, Processor processor) { if (processor == null) { return null; } // is this the first output from a route, as we want to know this so we can do special logic in first boolean first = false; RouteDefinition route = ProcessorDefinitionHelper.getRoute(definition); if (route != null) { if (routeContext.getCamelContext().getNodeIdFactory() != null) { RouteDefinitionHelper.forceAssignIds(routeContext.getCamelContext(), route); } if (!route.getOutputs().isEmpty()) { first = route.getOutputs().get(0) == definition; } } routeContexts.add(routeContext); processors.add(definition); return new TraceProcessor(queue, processor, definition, route, first, this); }
route.getOutputs().add(0, intercept); route.getOutputs().add(0, intercept); route.getOutputs().add(0, sendTo); route.getOutputs().addAll(getOnCompletions()); route.getOutputs().addAll(0, getOnExceptions());
public Processor wrap(RouteContext routeContext, ProcessorDefinition<?> definition, Processor processor) { if (processor == null) { return null; } // is this the first output from a route, as we want to know this so we can do special logic in first boolean first = false; RouteDefinition route = ProcessorDefinitionHelper.getRoute(definition); if (route != null) { if (routeContext.getCamelContext().getNodeIdFactory() != null) { RouteDefinitionHelper.forceAssignIds(routeContext.getCamelContext(), route); } if (!route.getOutputs().isEmpty()) { first = route.getOutputs().get(0) == definition; } } routeContexts.add(routeContext); processors.add(definition); TraceProcessor traceProcessor = new TraceProcessor(queue, processor, definition, route, first, this); traceProcessor.setCamelContext(routeContext.getCamelContext()); if (processor instanceof CamelContextAware) { ((CamelContextAware) processor).setCamelContext(routeContext.getCamelContext()); } return traceProcessor; }
findOutputComponents(rd.getOutputs(), components, languages, dataformats); RouteDefinition route = (RouteDefinition) o; findInputComponents(route.getInputs(), components, languages, dataformats); findOutputComponents(route.getOutputs(), components, languages, dataformats); } else if (o instanceof ToDefinition) { findUriComponent(((ToDefinition) o).getUri(), components);
rd.getOutputs().add(new ToDefinition(ecaRouteDefinition.getEcaDefinition().getUri())); rd = getRouteCollection().getRouteDefinition(targetId); if (!isWired(ecaRouteDefinition.getEcaDefinition(), rd)) { rd.getOutputs().add(new ToDefinition(ecaRouteDefinition.getEcaDefinition().getUri())); routePolicies.add(routePolicy); newRoute.setRoutePolicies(routePolicies); newRoute.getOutputs().add(new ToDefinition(ecaRouteDefinition.getEcaDefinition().getUri())); getContext().addRouteDefinition(newRoute);
List<ProcessorDefinition<?>> outputs = routeDefinition.getOutputs(); for (ProcessorDefinition<?> processorDefinition : outputs) { if (processorDefinition instanceof ToDefinition) {
assertThat(route.getInputs()).hasSize(1); assertThat(route.getInputs().get(0)).hasFieldOrPropertyWithValue("uri", "direct:start"); assertThat(route.getOutputs()).hasSize(5); assertThat(route.getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class); assertThat(route.getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class); assertThat(route.getOutputs().get(2)).isInstanceOf(ProcessDefinition.class); assertThat(route.getOutputs().get(3)).isInstanceOf(PipelineDefinition.class); assertThat(route.getOutputs().get(3).getOutputs()).hasSize(3); assertThat(route.getOutputs().get(3).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class); assertThat(route.getOutputs().get(3).getOutputs().get(1)).isInstanceOf(ToDefinition.class); assertThat(route.getOutputs().get(3).getOutputs().get(1)).hasFieldOrPropertyWithValue( "uri", "atlas:mapping-flow-0-step-1.json?encoding=UTF-8&sourceMapName=" + OutMessageCaptureProcessor.CAPTURED_OUT_MESSAGES_MAP ); assertThat(route.getOutputs().get(3).getOutputs().get(2)).isInstanceOf(ProcessDefinition.class); assertThat(route.getOutputs().get(4)).isInstanceOf(PipelineDefinition.class); } finally { context.stop();
assertThat(route.getInputs()).hasSize(1); assertThat(route.getInputs().get(0)).hasFieldOrPropertyWithValue("uri", "direct:start"); assertThat(route.getOutputs()).hasSize(5); assertThat(route.getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class); assertThat(route.getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class); assertThat(route.getOutputs().get(2)).isInstanceOf(ProcessDefinition.class); assertThat(route.getOutputs().get(3)).isInstanceOf(PipelineDefinition.class); assertThat(route.getOutputs().get(3).getOutputs()).hasSize(5); assertThat(route.getOutputs().get(3).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class); assertThat(route.getOutputs().get(3).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class); assertThat(route.getOutputs().get(3).getOutputs().get(1)).hasFieldOrPropertyWithValue("headerName", "Property-1"); assertThat(SetHeaderDefinition.class.cast(route.getOutputs().get(3).getOutputs().get(1)).getExpression()).hasFieldOrPropertyWithValue("expression", "Val-1"); assertThat(route.getOutputs().get(3).getOutputs().get(2)).isInstanceOf(SetHeaderDefinition.class); assertThat(route.getOutputs().get(3).getOutputs().get(2)).hasFieldOrPropertyWithValue("headerName", "Property-2"); assertThat(SetHeaderDefinition.class.cast(route.getOutputs().get(3).getOutputs().get(2)).getExpression()).hasFieldOrPropertyWithValue("expression", "Val-2"); assertThat(route.getOutputs().get(3).getOutputs().get(3)).isInstanceOf(ToDefinition.class); assertThat(route.getOutputs().get(3).getOutputs().get(3)).hasFieldOrPropertyWithValue( "uri", "log:myLog" ); assertThat(route.getOutputs().get(3).getOutputs().get(4)).isInstanceOf(ProcessDefinition.class); assertThat(route.getOutputs().get(4)).isInstanceOf(PipelineDefinition.class); } finally { context.stop();
assertThat(route.getInputs()).hasSize(1); assertThat(route.getInputs().get(0)).hasFieldOrPropertyWithValue("uri", "direct:start"); assertThat(route.getOutputs()).hasSize(5); assertThat(route.getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class); assertThat(route.getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class); assertThat(route.getOutputs().get(2)).isInstanceOf(ProcessDefinition.class); assertThat(route.getOutputs().get(3)).isInstanceOf(PipelineDefinition.class); assertThat(route.getOutputs().get(3).getOutputs()).hasSize(4); assertThat(route.getOutputs().get(3).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class); assertThat(route.getOutputs().get(3).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class); assertThat(route.getOutputs().get(3).getOutputs().get(1)).hasFieldOrPropertyWithValue("headerName", "param1"); assertThat(SetHeaderDefinition.class.cast(route.getOutputs().get(3).getOutputs().get(1)).getExpression()).hasFieldOrPropertyWithValue("expression", "Val-1"); assertThat(route.getOutputs().get(3).getOutputs().get(2)).isInstanceOf(SetHeaderDefinition.class); assertThat(route.getOutputs().get(3).getOutputs().get(2)).hasFieldOrPropertyWithValue("headerName", "param2"); assertThat(SetHeaderDefinition.class.cast(route.getOutputs().get(3).getOutputs().get(2)).getExpression()).hasFieldOrPropertyWithValue("expression", "Val-2"); assertThat(route.getOutputs().get(3).getOutputs().get(3)).isInstanceOf(ProcessDefinition.class); assertThat(route.getOutputs().get(4)).isInstanceOf(PipelineDefinition.class); } finally { context.stop();
assertThat(route.getInputs()).hasSize(1); assertThat(route.getInputs().get(0)).hasFieldOrPropertyWithValue("uri", "direct:start"); assertThat(route.getOutputs()).hasSize(5); assertThat(route.getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class); assertThat(route.getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class); assertThat(route.getOutputs().get(2)).isInstanceOf(ProcessDefinition.class); assertThat(route.getOutputs().get(3)).isInstanceOf(PipelineDefinition.class); assertThat(route.getOutputs().get(3).getOutputs()).hasSize(3); assertThat(route.getOutputs().get(3).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class); assertThat(route.getOutputs().get(3).getOutputs().get(1)).isInstanceOf(ToDefinition.class); assertThat(route.getOutputs().get(3).getOutputs().get(1)).hasFieldOrPropertyWithValue( "uri", "class:io.syndesis.integration.runtime.handlers.ExtensionStepHandlerTest$MyExtension?method=action&bean.param1=Val-1&bean.param2=Val-2" ); assertThat(route.getOutputs().get(3).getOutputs().get(2)).isInstanceOf(ProcessDefinition.class); assertThat(route.getOutputs().get(4)).isInstanceOf(PipelineDefinition.class); } finally { context.stop();
@Test public void testBuilder() throws Exception { IntegrationRuntimeConfiguration configuration = new IntegrationRuntimeConfiguration(); IntegrationRouteBuilder routeBuilder = new IntegrationRouteBuilder(configuration.getConfigurationLocation(), Collections.emptyList()); // initialize routes routeBuilder.configure(); // Dump routes as XML for troubleshooting dumpRoutes(new DefaultCamelContext(), routeBuilder.getRouteCollection()); RoutesDefinition routes = routeBuilder.getRouteCollection(); assertThat(routes.getRoutes()).hasSize(1); RouteDefinition route = routes.getRoutes().get(0); assertThat(route.getInputs()).hasSize(1); assertThat(route.getInputs().get(0)).hasFieldOrPropertyWithValue("uri", "direct:expression"); assertThat(route.getOutputs()).hasSize(4); assertThat(getOutput(route, 0)).isInstanceOf(SetHeaderDefinition.class); assertThat(getOutput(route, 1)).isInstanceOf(SetHeaderDefinition.class); assertThat(getOutput(route, 2)).isInstanceOf(ProcessDefinition.class); assertThat(getOutput(route, 3)).isInstanceOf(PipelineDefinition.class); assertThat(getOutput(route, 3).getOutputs()).hasSize(2); assertThat(getOutput(route, 3, 0)).isInstanceOf(SetHeaderDefinition.class); assertThat(getOutput(route, 3, 1)).isInstanceOf(SplitDefinition.class); assertThat(getOutput(route, 3, 1).getOutputs()).hasSize(2); assertThat(getOutput(route, 3, 1, 0)).isInstanceOf(ProcessDefinition.class); assertThat(getOutput(route, 3, 1, 1)).isInstanceOf(PipelineDefinition.class); assertThat(getOutput(route, 3, 1, 1).getOutputs()).hasSize(3); assertThat(getOutput(route, 3, 1, 1, 0)).isInstanceOf(SetHeaderDefinition.class); assertThat(getOutput(route, 3, 1, 1, 1)).isInstanceOf(ToDefinition.class); assertThat(getOutput(route, 3, 1, 1, 1)).hasFieldOrPropertyWithValue("uri", "mock:expression"); assertThat(getOutput(route, 3, 1, 1, 2)).isInstanceOf(ProcessDefinition.class); }
assertThat(route.getOutputs()).hasSize(3); assertThat(getOutput(route, 0)).isInstanceOf(SetHeaderDefinition.class); assertThat(getOutput(route, 1)).isInstanceOf(SetHeaderDefinition.class);
assertThat(route.getOutputs()).hasSize(4); assertThat(getOutput(route, 0)).isInstanceOf(SetHeaderDefinition.class); assertThat(getOutput(route, 1)).isInstanceOf(ToDefinition.class);
assertThat(route.getOutputs()).hasSize(3); assertThat(getOutput(route, 0)).isInstanceOf(SetHeaderDefinition.class); assertThat(getOutput(route, 1)).isInstanceOf(ToDefinition.class);
public static EcaRouteDefinition transform(RouteDefinition original) { if (original instanceof EcaRouteDefinition) { return (EcaRouteDefinition) original; } EcaRouteDefinition result = new EcaRouteDefinition(); result.setInputs(original.getInputs()); result.setOutputs(original.getOutputs()); result.setGroup(original.getGroup()); result.setStreamCache(original.getStreamCache()); result.setTrace(original.getTrace()); result.setHandleFault(original.getHandleFault()); result.setDelayer(original.getDelayer()); result.setAutoStartup(original.getAutoStartup()); result.setStartupOrder(original.getStartupOrder()); result.setRoutePolicies(original.getRoutePolicies()); result.setShutdownRoute(original.getShutdownRoute()); result.setShutdownRunningTask(original.getShutdownRunningTask()); return result; }