Here are the examples of the java api org.apache.camel.model.RouteDefinition taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
51 Examples
19
Source : ExtensionStepHandlerTest.java
with Apache License 2.0
from syndesisio
with Apache License 2.0
from syndesisio
@Test
public void testEndpointExtensionStepHandler() throws Exception {
final CamelContext context = new DefaultCamelContext();
try {
final RouteBuilder routeBuilder = newIntegrationRouteBuilder(new io.syndesis.common.model.integration.Step.Builder().id("step-1").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "start").build()).build()).build(), new io.syndesis.common.model.integration.Step.Builder().id("step-2").stepKind(StepKind.extension).action(new StepAction.Builder().descriptor(new StepDescriptor.Builder().kind(StepAction.Kind.ENDPOINT).entrypoint("log:myLog").build()).build()).putConfiguredProperty("Property-1", "Val-1").putConfiguredProperty("Property-2", "Val-2").build(), new io.syndesis.common.model.integration.Step.Builder().id("step-3").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "result").build()).build()).build());
// Set up the camel context
context.addRoutes(routeBuilder);
context.setAutoStartup(false);
context.start();
// Dump routes as XML for troubleshooting
dumpRoutes(context);
List<RouteDefinition> routes = context.getRouteDefinitions();
replacedertThat(routes).hreplacedize(1);
RouteDefinition route = context.getRouteDefinitions().get(0);
replacedertThat(route).isNotNull();
replacedertThat(route.getInputs()).hreplacedize(1);
replacedertThat(route.getInputs().get(0)).hasFieldOrPropertyWithValue("uri", "direct:start");
replacedertThat(route.getOutputs()).hreplacedize(5);
replacedertThat(route.getOutputs().get(0)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(route.getOutputs().get(0).getOutputs()).hreplacedize(2);
replacedertThat(route.getOutputs().get(0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(2)).isInstanceOf(ProcessDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3).getOutputs()).hreplacedize(5);
replacedertThat(route.getOutputs().get(3).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3).getOutputs().get(1)).hasFieldOrPropertyWithValue("headerName", "Property-1");
replacedertThat(SetHeaderDefinition.clreplaced.cast(route.getOutputs().get(3).getOutputs().get(1)).getExpression()).hasFieldOrPropertyWithValue("expression", "Val-1");
replacedertThat(route.getOutputs().get(3).getOutputs().get(2)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3).getOutputs().get(2)).hasFieldOrPropertyWithValue("headerName", "Property-2");
replacedertThat(SetHeaderDefinition.clreplaced.cast(route.getOutputs().get(3).getOutputs().get(2)).getExpression()).hasFieldOrPropertyWithValue("expression", "Val-2");
replacedertThat(route.getOutputs().get(3).getOutputs().get(3)).isInstanceOf(ToDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3).getOutputs().get(3)).hasFieldOrPropertyWithValue("uri", "log:myLog");
replacedertThat(route.getOutputs().get(3).getOutputs().get(4)).isInstanceOf(ProcessDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4).getOutputs()).hreplacedize(3);
replacedertThat(route.getOutputs().get(4).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4).getOutputs().get(1)).isInstanceOf(ToDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4).getOutputs().get(1)).hasFieldOrPropertyWithValue("uri", "mock:result");
replacedertThat(route.getOutputs().get(4).getOutputs().get(2)).isInstanceOf(ProcessDefinition.clreplaced);
} finally {
context.stop();
}
}
19
Source : ExtensionStepHandlerTest.java
with Apache License 2.0
from syndesisio
with Apache License 2.0
from syndesisio
@Test
public void testStepExtensionStepHandler() throws Exception {
final CamelContext context = new DefaultCamelContext();
try {
final RouteBuilder routeBuilder = newIntegrationRouteBuilder(new io.syndesis.common.model.integration.Step.Builder().id("step-1").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "start").build()).build()).build(), new io.syndesis.common.model.integration.Step.Builder().id("step-2").stepKind(StepKind.extension).action(new StepAction.Builder().descriptor(new StepDescriptor.Builder().kind(StepAction.Kind.STEP).entrypoint("io.syndesis.integration.runtime.handlers.ExtensionStepHandlerTest$MyStepExtension").build()).build()).putConfiguredProperty("param1", "Val-1").putConfiguredProperty("param2", "Val-2").build(), new io.syndesis.common.model.integration.Step.Builder().id("step-3").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "result").build()).build()).build());
// Set up the camel context
context.addRoutes(routeBuilder);
context.setAutoStartup(false);
context.start();
// Dump routes as XML for troubleshooting
dumpRoutes(context);
RouteDefinition route = context.getRouteDefinitions().get(0);
replacedertThat(route).isNotNull();
replacedertThat(route.getInputs()).hreplacedize(1);
replacedertThat(route.getInputs().get(0)).hasFieldOrPropertyWithValue("uri", "direct:start");
replacedertThat(route.getOutputs()).hreplacedize(5);
replacedertThat(route.getOutputs().get(0)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(route.getOutputs().get(0).getOutputs()).hreplacedize(2);
replacedertThat(route.getOutputs().get(0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(2)).isInstanceOf(ProcessDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3).getOutputs()).hreplacedize(4);
replacedertThat(route.getOutputs().get(3).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3).getOutputs().get(1)).hasFieldOrPropertyWithValue("headerName", "param1");
replacedertThat(SetHeaderDefinition.clreplaced.cast(route.getOutputs().get(3).getOutputs().get(1)).getExpression()).hasFieldOrPropertyWithValue("expression", "Val-1");
replacedertThat(route.getOutputs().get(3).getOutputs().get(2)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3).getOutputs().get(2)).hasFieldOrPropertyWithValue("headerName", "param2");
replacedertThat(SetHeaderDefinition.clreplaced.cast(route.getOutputs().get(3).getOutputs().get(2)).getExpression()).hasFieldOrPropertyWithValue("expression", "Val-2");
replacedertThat(route.getOutputs().get(3).getOutputs().get(3)).isInstanceOf(ProcessDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4).getOutputs()).hreplacedize(3);
replacedertThat(route.getOutputs().get(4).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4).getOutputs().get(1)).isInstanceOf(ToDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4).getOutputs().get(1)).hasFieldOrPropertyWithValue("uri", "mock:result");
replacedertThat(route.getOutputs().get(4).getOutputs().get(2)).isInstanceOf(ProcessDefinition.clreplaced);
} finally {
context.stop();
}
}
19
Source : ExtensionStepHandlerTest.java
with Apache License 2.0
from syndesisio
with Apache License 2.0
from syndesisio
@Test
public void testBeanExtensionStepHandler() throws Exception {
final CamelContext context = new DefaultCamelContext();
try {
final RouteBuilder routeBuilder = newIntegrationRouteBuilder(new io.syndesis.common.model.integration.Step.Builder().id("step-1").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "start").build()).build()).build(), new io.syndesis.common.model.integration.Step.Builder().id("step-2").stepKind(StepKind.extension).action(new StepAction.Builder().descriptor(new StepDescriptor.Builder().kind(StepAction.Kind.BEAN).entrypoint("io.syndesis.integration.runtime.handlers.ExtensionStepHandlerTest$MyExtension::action").build()).build()).putConfiguredProperty("param1", "Val-1").putConfiguredProperty("param2", "Val-2").build(), new io.syndesis.common.model.integration.Step.Builder().id("step-3").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "result").build()).build()).build());
// Set up the camel context
context.addRoutes(routeBuilder);
context.setAutoStartup(false);
context.start();
// Dump routes as XML for troubleshooting
dumpRoutes(context);
List<RouteDefinition> routes = context.getRouteDefinitions();
replacedertThat(routes).hreplacedize(1);
RouteDefinition route = context.getRouteDefinitions().get(0);
replacedertThat(route).isNotNull();
replacedertThat(route.getInputs()).hreplacedize(1);
replacedertThat(route.getInputs().get(0)).hasFieldOrPropertyWithValue("uri", "direct:start");
replacedertThat(route.getOutputs()).hreplacedize(5);
replacedertThat(route.getOutputs().get(0)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(route.getOutputs().get(0).getOutputs()).hreplacedize(2);
replacedertThat(route.getOutputs().get(0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(2)).isInstanceOf(ProcessDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3).getOutputs()).hreplacedize(3);
replacedertThat(route.getOutputs().get(3).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3).getOutputs().get(1)).isInstanceOf(ToDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3).getOutputs().get(1)).hasFieldOrPropertyWithValue("uri", "clreplaced:io.syndesis.integration.runtime.handlers.ExtensionStepHandlerTest$MyExtension?method=action&bean.param1=Val-1&bean.param2=Val-2");
replacedertThat(route.getOutputs().get(3).getOutputs().get(2)).isInstanceOf(ProcessDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4).getOutputs()).hreplacedize(3);
replacedertThat(route.getOutputs().get(4).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4).getOutputs().get(1)).isInstanceOf(ToDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4).getOutputs().get(1)).hasFieldOrPropertyWithValue("uri", "mock:result");
replacedertThat(route.getOutputs().get(4).getOutputs().get(2)).isInstanceOf(ProcessDefinition.clreplaced);
} finally {
context.stop();
}
}
19
Source : DataMapperStepHandlerTest.java
with Apache License 2.0
from syndesisio
with Apache License 2.0
from syndesisio
@Test
public void testJsonTypeProcessors() throws Exception {
final CamelContext context = new DefaultCamelContext();
try {
final RouteBuilder routeBuilder = newIntegrationRouteBuilder(getTestSteps("{" + "\"AtlasMapping\":{" + "\"dataSource\":[" + "{\"jsonType\":\"" + DataMapperStepHandler.ATLASMAP_JSON_DATA_SOURCE + "\",\"id\":\"source\",\"uri\":\"atlas:json:source\",\"dataSourceType\":\"SOURCE\"}," + "{\"jsonType\":\"" + DataMapperStepHandler.ATLASMAP_JSON_DATA_SOURCE + "\",\"id\":\"target\",\"uri\":\"atlas:json:target\",\"dataSourceType\":\"TARGET\",\"template\":null}" + "]," + "\"mappings\":{}" + "}" + "}"));
// Set up the camel context
context.addRoutes(routeBuilder);
context.start();
// Dump routes as XML for troubleshooting
dumpRoutes(context);
List<RouteDefinition> routes = context.getRouteDefinitions();
replacedertThat(routes).hreplacedize(1);
RouteDefinition route = context.getRouteDefinitions().get(0);
replacedertThat(route).isNotNull();
replacedertThat(route.getInputs()).hreplacedize(1);
replacedertThat(route.getInputs().get(0)).hasFieldOrPropertyWithValue("uri", "direct:start");
replacedertThat(route.getOutputs()).hreplacedize(5);
replacedertThat(route.getOutputs().get(0)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(route.getOutputs().get(0).getOutputs()).hreplacedize(2);
replacedertThat(route.getOutputs().get(0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(2)).isInstanceOf(ProcessDefinition.clreplaced);
// Atlas
replacedertThat(route.getOutputs().get(3)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3).getOutputs()).hreplacedize(5);
replacedertThat(route.getOutputs().get(3).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3).getOutputs().get(1)).isInstanceOf(ProcessDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3).getOutputs().get(2)).isInstanceOf(ToDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3).getOutputs().get(2)).hasFieldOrPropertyWithValue("uri", "atlas:mapping-flow-0-step-1.json?encoding=UTF-8&sourceMapName=" + OutMessageCaptureProcessor.CAPTURED_OUT_MESSAGES_MAP);
replacedertThat(route.getOutputs().get(3).getOutputs().get(3)).isInstanceOf(ProcessDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3).getOutputs().get(4)).isInstanceOf(ProcessDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4).getOutputs()).hreplacedize(3);
replacedertThat(route.getOutputs().get(4).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4).getOutputs().get(1)).isInstanceOf(ToDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4).getOutputs().get(1)).hasFieldOrPropertyWithValue("uri", "mock:result");
replacedertThat(route.getOutputs().get(4).getOutputs().get(2)).isInstanceOf(ProcessDefinition.clreplaced);
} finally {
context.stop();
}
}
19
Source : DataMapperStepHandlerTest.java
with Apache License 2.0
from syndesisio
with Apache License 2.0
from syndesisio
@Test
public void testJsonTypeProcessorsSkip() throws Exception {
final CamelContext context = new DefaultCamelContext();
try {
final RouteBuilder routeBuilder = newIntegrationRouteBuilder(getTestSteps("{" + "\"AtlasMapping\":{" + "\"dataSource\":[" + "{\"jsonType\":\"io.atlasmap.v2.DataSource\",\"id\":\"source\",\"uri\":\"atlas:java?clreplacedName=twitter4j.Status\",\"dataSourceType\":\"SOURCE\"}," + "{\"jsonType\":\"io.atlasmap.v2.DataSource\",\"id\":\"target\",\"uri\":\"atlas:java?clreplacedName=io.syndesis.connector.gmail.GmailMessageModel\",\"dataSourceType\":\"TARGET\",\"template\":null}" + "]," + "\"mappings\":{}" + "}" + "}"));
// Set up the camel context
context.addRoutes(routeBuilder);
context.start();
// Dump routes as XML for troubleshooting
dumpRoutes(context);
List<RouteDefinition> routes = context.getRouteDefinitions();
replacedertThat(routes).hreplacedize(1);
RouteDefinition route = context.getRouteDefinitions().get(0);
replacedertThat(route).isNotNull();
replacedertThat(route.getInputs()).hreplacedize(1);
replacedertThat(route.getInputs().get(0)).hasFieldOrPropertyWithValue("uri", "direct:start");
replacedertThat(route.getOutputs()).hreplacedize(5);
replacedertThat(route.getOutputs().get(0)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(route.getOutputs().get(0).getOutputs()).hreplacedize(2);
replacedertThat(route.getOutputs().get(0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(2)).isInstanceOf(ProcessDefinition.clreplaced);
// Atlas
replacedertThat(route.getOutputs().get(3)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3).getOutputs()).hreplacedize(3);
replacedertThat(route.getOutputs().get(3).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3).getOutputs().get(1)).isInstanceOf(ToDefinition.clreplaced);
replacedertThat(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);
replacedertThat(route.getOutputs().get(3).getOutputs().get(2)).isInstanceOf(ProcessDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4).getOutputs()).hreplacedize(3);
replacedertThat(route.getOutputs().get(4).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4).getOutputs().get(1)).isInstanceOf(ToDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4).getOutputs().get(1)).hasFieldOrPropertyWithValue("uri", "mock:result");
replacedertThat(route.getOutputs().get(4).getOutputs().get(2)).isInstanceOf(ProcessDefinition.clreplaced);
} finally {
context.stop();
}
}
19
Source : DataMapperStepHandlerTest.java
with Apache License 2.0
from syndesisio
with Apache License 2.0
from syndesisio
@Test
public void testDataMapperStep() throws Exception {
final CamelContext context = new DefaultCamelContext();
try {
final RouteBuilder routeBuilder = newIntegrationRouteBuilder(getTestSteps());
// Set up the camel context
context.addRoutes(routeBuilder);
context.start();
// Dump routes as XML for troubleshooting
dumpRoutes(context);
List<RouteDefinition> routes = context.getRouteDefinitions();
replacedertThat(routes).hreplacedize(1);
RouteDefinition route = context.getRouteDefinitions().get(0);
replacedertThat(route).isNotNull();
replacedertThat(route.getInputs()).hreplacedize(1);
replacedertThat(route.getInputs().get(0)).hasFieldOrPropertyWithValue("uri", "direct:start");
replacedertThat(route.getOutputs()).hreplacedize(5);
replacedertThat(route.getOutputs().get(0)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(route.getOutputs().get(0).getOutputs()).hreplacedize(2);
replacedertThat(route.getOutputs().get(0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(2)).isInstanceOf(ProcessDefinition.clreplaced);
// Atlas
replacedertThat(route.getOutputs().get(3)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3).getOutputs()).hreplacedize(3);
replacedertThat(route.getOutputs().get(3).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(3).getOutputs().get(1)).isInstanceOf(ToDefinition.clreplaced);
replacedertThat(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);
replacedertThat(route.getOutputs().get(3).getOutputs().get(2)).isInstanceOf(ProcessDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4).getOutputs()).hreplacedize(3);
replacedertThat(route.getOutputs().get(4).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4).getOutputs().get(1)).isInstanceOf(ToDefinition.clreplaced);
replacedertThat(route.getOutputs().get(4).getOutputs().get(1)).hasFieldOrPropertyWithValue("uri", "mock:result");
replacedertThat(route.getOutputs().get(4).getOutputs().get(2)).isInstanceOf(ProcessDefinition.clreplaced);
} finally {
context.stop();
}
}
19
Source : SuspendedRouteBuilder.java
with Apache License 2.0
from rodrigoserracoelho
with Apache License 2.0
from rodrigoserracoelho
private void addRoute(RunningApi runningApi) throws Exception {
RestOperationParamDefinition restParamDefinition = new RestOperationParamDefinition();
RouteDefinition routeDefinition;
switch(runningApi.getVerb()) {
case GET:
routeDefinition = rest().get("/" + runningApi.getContext() + runningApi.getPath()).route();
break;
case POST:
routeDefinition = rest().post("/" + runningApi.getContext() + runningApi.getPath()).route();
break;
case PUT:
routeDefinition = rest().put("/" + runningApi.getContext() + runningApi.getPath()).route();
break;
case DELETE:
routeDefinition = rest().delete("/" + runningApi.getContext() + runningApi.getPath()).route();
break;
default:
throw new Exception("No verb available");
}
List<String> paramList = camelUtils.evaluatePath(runningApi.getPath());
if (!paramList.isEmpty()) {
for (String param : paramList) {
restParamDefinition.name(param).type(RestParamType.path).dataType("String");
}
camelUtils.buildSuspendedRoute(routeDefinition, runningApi, true);
}
camelUtils.buildSuspendedRoute(routeDefinition, runningApi, false);
}
19
Source : SimpleRestRouteRepublisher.java
with Apache License 2.0
from rodrigoserracoelho
with Apache License 2.0
from rodrigoserracoelho
void addRoutes(Api api) throws Exception {
List<Panel> grafanaPanels;
if (grafanaDashboardBuilder != null) {
grafanaPanels = new ArrayList<>();
}
for (Path path : api.getPaths()) {
if (!path.getPath().equals("/error")) {
RestOperationParamDefinition restParamDefinition = new RestOperationParamDefinition();
List<String> paramList = camelUtils.evaluatePath(path.getPath());
String routeID = camelUtils.normalizeRouteId(api, path);
path.setRouteID(routeID);
RouteDefinition routeDefinition;
switch(path.getVerb()) {
case GET:
routeDefinition = rest().get("/" + api.getContext() + path.getPath()).route();
break;
case POST:
routeDefinition = rest().post("/" + api.getContext() + path.getPath()).route();
break;
case PUT:
routeDefinition = rest().put("/" + api.getContext() + path.getPath()).route();
break;
case DELETE:
routeDefinition = rest().delete("/" + api.getContext() + path.getPath()).route();
break;
default:
throw new Exception("No verb available");
}
camelUtils.buildOnExceptionDefinition(routeDefinition, api.isZipkinTraceIdVisible(), api.isInternalExceptionMessageVisible(), api.isInternalExceptionVisible(), routeID);
if (paramList.isEmpty()) {
camelUtils.buildRoute(routeDefinition, routeID, api, path, false);
} else {
for (String param : paramList) {
restParamDefinition.name(param).type(RestParamType.path).dataType("String");
}
camelUtils.buildRoute(routeDefinition, routeID, api, path, true);
}
}
}
throttlingManager.applyThrottling(api);
if (grafanaDashboardBuilder != null) {
// grafanaUtils.addToGrafana(api);
}
}
19
Source : SimpleRestRoutePublisher.java
with Apache License 2.0
from rodrigoserracoelho
with Apache License 2.0
from rodrigoserracoelho
void addRoutes(Api api) throws Exception {
for (Path path : api.getPaths()) {
if (!path.getPath().equals("/error")) {
RestOperationParamDefinition restParamDefinition = new RestOperationParamDefinition();
List<String> paramList = camelUtils.evaluatePath(path.getPath());
String routeID = camelUtils.normalizeRouteId(api, path);
path.setRouteID(routeID);
RouteDefinition routeDefinition;
switch(path.getVerb()) {
case GET:
routeDefinition = rest().get("/" + api.getContext() + path.getPath()).route();
break;
case POST:
routeDefinition = rest().post("/" + api.getContext() + path.getPath()).route();
break;
case PUT:
routeDefinition = rest().put("/" + api.getContext() + path.getPath()).route();
break;
case DELETE:
routeDefinition = rest().delete("/" + api.getContext() + path.getPath()).route();
break;
default:
throw new Exception("No verb available");
}
camelUtils.buildOnExceptionDefinition(routeDefinition, api.isZipkinTraceIdVisible(), api.isInternalExceptionMessageVisible(), api.isInternalExceptionVisible(), routeID);
if (paramList.isEmpty()) {
camelUtils.buildRoute(routeDefinition, routeID, api, path, false);
} else {
for (String param : paramList) {
restParamDefinition.name(param).type(RestParamType.path).dataType("String");
}
camelUtils.buildRoute(routeDefinition, routeID, api, path, true);
}
}
}
throttlingManager.applyThrottling(api);
}
19
Source : PathRouteRepublisher.java
with Apache License 2.0
from rodrigoserracoelho
with Apache License 2.0
from rodrigoserracoelho
private void addRoute(RunningApi runningApi) throws Exception {
RestOperationParamDefinition restParamDefinition = new RestOperationParamDefinition();
List<String> paramList = camelUtils.evaluatePath(runningApi.getPath());
RouteDefinition routeDefinition;
switch(runningApi.getVerb()) {
case GET:
routeDefinition = rest().get("/" + runningApi.getContext() + runningApi.getPath()).route();
break;
case POST:
routeDefinition = rest().post("/" + runningApi.getContext() + runningApi.getPath()).route().setProperty(Constants.REST_CALL_BODY, body());
break;
case PUT:
routeDefinition = rest().put("/" + runningApi.getContext() + runningApi.getPath()).route().setProperty(Constants.REST_CALL_BODY, body());
break;
case DELETE:
routeDefinition = rest().delete("/" + runningApi.getContext() + runningApi.getPath()).route();
break;
default:
throw new Exception("No verb available");
}
camelUtils.buildOnExceptionDefinition(routeDefinition, runningApi.isZipkinTraceIdVisible(), runningApi.isInternalExceptionMessageVisible(), runningApi.isInternalExceptionVisible(), runningApi.getRouteId());
if (paramList.isEmpty()) {
camelUtils.buildRoute(routeDefinition, runningApi.getRouteId(), runningApi, false);
} else {
for (String param : paramList) {
restParamDefinition.name(param).type(RestParamType.path).dataType("String");
}
camelUtils.buildRoute(routeDefinition, runningApi.getRouteId(), runningApi, true);
}
}
19
Source : RouteTypeInfo.java
with Apache License 2.0
from OpenWiseSolutions
with Apache License 2.0
from OpenWiseSolutions
/**
* Contains information about route for getting {@link RouteType} in {@link RouteTypeResolver}.
*
* @author Romah Havlicek
* @see RouteType
* @see RouteTypeResolver
* @since 2.0
*/
public clreplaced RouteTypeInfo {
/**
* Route.
*/
private final Route route;
/**
* Exchange.
*/
private final Exchange exchange;
/**
* Route id.
*/
private final String routeId;
/**
* Route definition.
*/
private final RouteDefinition routeDefinition;
/**
* New instance.
*
* @param route route, {@code NULl} no route object
* @param exchange exchange, {@code NULL} no exchange object
* @param routeId route id, {@code NULL} no route id
* @param routeDefinition route definition, {@code NULL} no route definition
*/
public RouteTypeInfo(@Nullable Route route, @Nullable Exchange exchange, @Nullable String routeId, @Nullable RouteDefinition routeDefinition) {
this.route = route;
this.exchange = exchange;
this.routeId = routeId;
this.routeDefinition = routeDefinition;
}
// --------------------------------------------------- SET / GET ----------------------------------------------------
/**
* Gets route.
*
* @return route, {@code NULL} - no route
*/
@Nullable
public Route getRoute() {
return route;
}
/**
* Gets exchange.
*
* @return exchange, {@code NULL} - no exchange
*/
@Nullable
public Exchange getExchange() {
return exchange;
}
/**
* Gets route id.
*
* @return route id, {@code NULL} - no route id
*/
@Nullable
public String getRouteId() {
return routeId;
}
/**
* Gets route definition.
*
* @return route definition, {@code NULL} route definition
*/
@Nullable
public RouteDefinition getRouteDefinition() {
return routeDefinition;
}
// --------------------------------------------- TOSTRING / HASH / EQUALS -------------------------------------------
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof RouteTypeInfo)) {
return false;
}
RouteTypeInfo that = (RouteTypeInfo) o;
return new EqualsBuilder().append(getRoute(), that.getRoute()).append(getExchange(), that.getExchange()).append(getRouteId(), that.getRouteId()).append(getRouteDefinition(), that.getRouteDefinition()).isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37).append(getRoute()).append(getExchange()).append(getRouteId()).append(getRouteDefinition()).toHashCode();
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("route", route).append("exchange", exchange).append("routeId", routeId).append("routeDefinition", routeDefinition).toString();
}
}
19
Source : AsynchRouteBuilder.java
with Apache License 2.0
from OpenWiseSolutions
with Apache License 2.0
from OpenWiseSolutions
/**
* Builds new route definition for processing incoming asynchronous messages.
*
* @param route current route builder
* @return route definition
*/
public final RouteDefinition build(RouteBuilder route) {
replacedert.notNull(route, "the route must not be null");
// check guaranteed order - funnel value must be filled
if (guaranteedOrder && funnelValue == null) {
throw new IllegalStateException("There is no funnel value for guaranteed order.");
}
String finalRouteId = routeId;
if (finalRouteId == null) {
finalRouteId = AbstractBasicRoute.getInRouteId(serviceType, operation);
}
RouteDefinition routeDefinition = route.from(inUri).routeId(finalRouteId);
if (validators != null) {
for (Processor validator : validators) {
routeDefinition.process(validator);
}
}
if (policyRef != null) {
routeDefinition.policy(policyRef);
}
if (objectIdExpr != null) {
routeDefinition.setHeader(AsynchConstants.OBJECT_ID_HEADER, objectIdExpr);
}
if (funnelValue != null) {
routeDefinition.setHeader(AsynchConstants.FUNNEL_VALUE_HEADER, funnelValue);
}
if (guaranteedOrder) {
routeDefinition.setHeader(AsynchConstants.GUARANTEED_ORDER_HEADER, constant(true));
}
if (excludeFailedState) {
routeDefinition.setHeader(AsynchConstants.EXCLUDE_FAILED_HEADER, constant(true));
}
// header values
routeDefinition.setHeader(AsynchConstants.SERVICE_HEADER, route.constant(serviceType));
routeDefinition.setHeader(AsynchConstants.OPERATION_HEADER, route.constant(operation));
// route the request to asynchronous processing
routeDefinition.to(AsynchConstants.URI_ASYNCH_IN_MSG);
// create response
if (responseProcessor != null) {
routeDefinition.process(responseProcessor);
} else {
// use default response, general for all asynch. requests
routeDefinition.process(new AsynchResponseProcessor() {
@Override
protected Object setCallbackResponse(CallbackResponse callbackResponse) {
AsynchResponse asynchResponse = new AsynchResponse();
asynchResponse.setConfirmAsynchRequest(callbackResponse);
return asynchResponse;
}
});
}
// response -> XML
if (responseMarshalling != null) {
routeDefinition.marshal(responseMarshalling);
} else {
routeDefinition.marshal(jaxb(AsynchResponse.clreplaced));
}
return routeDefinition;
}
19
Source : StartProcessingMessagePolicyFactory.java
with Apache License 2.0
from OpenWiseSolutions
with Apache License 2.0
from OpenWiseSolutions
@Override
public RoutePolicy createRoutePolicy(CamelContext camelContext, String routeId, RouteDefinition route) {
replacedert.notNull(camelContext, "camelContext must not be null");
replacedert.hasText(routeId, "routeId must not be empty");
replacedert.notNull(route, "route must not be null");
if (routeDefinitionService.isInputRoute(new RouteTypeInfo(null, null, routeId, route))) {
return getStartProcessingMessagePolicy();
} else {
return null;
}
}
19
Source : CamelTracingService.java
with Apache License 2.0
from open-telemetry
with Apache License 2.0
from open-telemetry
@Override
public RoutePolicy createRoutePolicy(CamelContext camelContext, String routeId, RouteDefinition route) {
return routePolicy;
}
19
Source : CamelRoutesSetup.java
with Apache License 2.0
from brunobat
with Apache License 2.0
from brunobat
public void start() throws Exception {
final AbstractCamelContext context = getCamelContex();
log.info("Starting camel routes");
for (RouteDefinition routeDefinition : context.getExtension(Model.clreplaced).getRouteDefinitions()) {
context.startRoute(routeDefinition.getId());
}
}
19
Source : HystrixHierarchicalConfigurationTest.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Test
public void testConfiguration() throws Exception {
RouteDefinition routeDefinition = camelContext.getExtension(Model.clreplaced).getRouteDefinition("hystrix-route");
CircuitBreakerDefinition hystrixDefinition = findCircuitBreaker(routeDefinition);
replacedert.replacedertNotNull(hystrixDefinition);
Route rc = new DefaultRoute(camelContext, null, null, null, null);
HystrixReifier reifier = new HystrixReifier(rc, hystrixDefinition);
HystrixConfigurationDefinition config = reifier.buildHystrixConfiguration();
replacedert.replacedertEquals("local-conf-group-key", config.getGroupKey());
replacedert.replacedertEquals("global-thread-key", config.getThreadPoolKey());
replacedert.replacedertEquals("5", config.getCorePoolSize());
}
19
Source : HystrixHierarchicalConfigurationTest.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
// **********************************************
// Helper
// **********************************************
private CircuitBreakerDefinition findCircuitBreaker(RouteDefinition routeDefinition) throws Exception {
return routeDefinition.getOutputs().stream().filter(CircuitBreakerDefinition.clreplaced::isInstance).map(CircuitBreakerDefinition.clreplaced::cast).findFirst().orElseThrow(() -> new IllegalStateException("Unable to find a CircuitBreakerDefinition"));
}
19
Source : OnExceptionRouteIdTest.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Test
public void testOnExceptionRouteId() throws Exception {
getMockEndpoint("mock:error").expectedMessageCount(0);
getMockEndpoint("mock:foo").expectedMessageCount(1);
template.sendBody("direct:foo", "Hello World");
replacedertMockEndpointsSatisfied();
RouteDefinition route = context.getRouteDefinition("foo");
replacedertNotNull(route);
replacedertEquals("foo", route.getId());
}
19
Source : CustomIdIssuesTest.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Test
public void testCustomId() {
RouteDefinition route = context.getRouteDefinition("myRoute");
replacedertNotNull(route);
replacedertTrue(route.hasCustomIdreplacedigned());
FromDefinition from = route.getInput();
replacedertEquals("fromFile", from.getId());
replacedertTrue(from.hasCustomIdreplacedigned());
ChoiceDefinition choice = (ChoiceDefinition) route.getOutputs().get(0);
replacedertEquals("myChoice", choice.getId());
replacedertTrue(choice.hasCustomIdreplacedigned());
WhenDefinition when = choice.getWhenClauses().get(0);
replacedertTrue(when.hasCustomIdreplacedigned());
replacedertEquals("UK", when.getId());
LogDefinition log = (LogDefinition) choice.getOtherwise().getOutputs().get(0);
replacedertFalse(log.hasCustomIdreplacedigned());
}
19
Source : RuntimeInspector.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@GET
@Path("/route-outputs/{name}")
@Produces(MediaType.APPLICATION_JSON)
public JsonArray routeOutputs(@PathParam("name") String name) {
RouteDefinition def = camelContext.adapt(ModelCamelContext.clreplaced).getRouteDefinition(name);
if (def == null) {
throw new IllegalArgumentException("RouteDefinition with name: " + name + " not found");
}
List<String> endpoints = new ArrayList<>();
Iterator<ToDefinition> it = filterTypeInOutputs(def.getOutputs(), ToDefinition.clreplaced);
while (it.hasNext()) {
endpoints.add(it.next().getEndpointUri());
}
return Json.createArrayBuilder(endpoints).build();
}
19
Source : RouteStepParser.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public Object process(Context context) {
final Definition definition = context.node(Definition.clreplaced);
if (definition.from.uri == null && definition.from.scheme == null) {
throw new IllegalArgumentException("Either uri or scheme must be set");
}
String uri = StepParserSupport.createEndpointUri(context.getCamelContext(), definition.from.uri != null ? definition.from.uri : definition.from.scheme, definition.from.parameters);
RouteDefinition route = context.builder().from(uri);
ObjectHelper.ifNotEmpty(definition.id, route::routeId);
ObjectHelper.ifNotEmpty(definition.group, route::routeGroup);
ObjectHelper.ifNotEmpty(definition.autoStartup, route::autoStartup);
// as this is a start converter, steps are mandatory
StepParserSupport.notNull(definition.steps, "steps");
return StepParserSupport.convertSteps(context, route, definition.steps);
}
19
Source : KnativeSourceLoaderInterceptor.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
private static void afterConfigure(RouteBuilder builder) {
final CamelContext camelContext = builder.getContext();
final List<RouteDefinition> definitions = builder.getRouteCollection().getRoutes();
if (definitions.size() == 1) {
final String sinkName = camelContext.resolvePropertyPlaceholders("{{knative.sink:sink}}");
final String sinkUri = String.format("knative://endpoint/%s", sinkName);
final RouteDefinition definition = definitions.get(0);
LOGGER.info("Add sink:{} to route:{}", sinkUri, definition.getId());
// replaceduming that route is linear like there's no content based routing
// or ant other EIP that would branch the flow
definition.getOutputs().add(new ToDefinition(sinkUri));
} else {
LOGGER.warn("Cannot determine route to enrich. the knative enpoint need to explicitly be defined");
}
}
19
Source : CronSourceLoaderInterceptor.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
private void afterConfigure(RouteBuilder builder) {
if (ObjectHelper.isEmpty(overridableComponents)) {
return;
}
final CamelContext context = runtime.getCamelContext();
final String[] components = overridableComponents.split(",", -1);
for (RouteDefinition def : builder.getRouteCollection().getRoutes()) {
String uri = def.getInput() != null ? def.getInput().getUri() : null;
if (shouldBeOverridden(uri, components)) {
def.getInput().setUri(timerUri);
//
// Don't install the shutdown strategy more than once.
//
if (context.getManagementStrategy().getEventNotifiers().stream().noneMatch(CronShutdownStrategy.clreplaced::isInstance)) {
CronShutdownStrategy strategy = new CronShutdownStrategy(runtime);
ServiceHelper.startService(strategy);
context.getManagementStrategy().addEventNotifier(strategy);
}
}
}
}
18
Source : IntegrationTestSupport.java
with Apache License 2.0
from syndesisio
with Apache License 2.0
from syndesisio
protected ProcessorDefinition<?> getOutput(RouteDefinition definition, int... indices) {
ProcessorDefinition<?> output = definition;
for (int index : indices) {
output = output.getOutputs().get(index);
}
return output;
}
18
Source : IntegrationTestSupport.java
with Apache License 2.0
from syndesisio
with Apache License 2.0
from syndesisio
public static ProcessorDefinition<?> getOutput(RouteDefinition definition, int... indices) {
ProcessorDefinition<?> output = definition;
for (int index : indices) {
output = output.getOutputs().get(index);
}
return output;
}
18
Source : CamelUtils.java
with Apache License 2.0
from rodrigoserracoelho
with Apache License 2.0
from rodrigoserracoelho
public void buildSuspendedRoute(RouteDefinition routeDefinition, RunningApi runningApi, boolean hasParams) {
if (hasParams) {
routeDefinition.setHeader(Constants.CAPI_CONTEXT_HEADER, constant(runningApi.getContext()));
}
routeDefinition.setHeader(Constants.ROUTE_ID_HEADER, constant(runningApi.getRouteId())).process(routeErrorProcessor).toF(Constants.FAIL_REST_ENDPOINT_OBJECT, apiGatewayErrorEndpoint).end().setId(runningApi.getRouteId());
}
18
Source : AbstractOperationRouteTest.java
with Apache License 2.0
from OpenWiseSolutions
with Apache License 2.0
from OpenWiseSolutions
private boolean replaceFrom(String routeId, final String uri) throws Exception {
RouteDefinition routeDefinition = getCamelContext().getRouteDefinition(routeId);
if (routeDefinition != null) {
routeDefinition.adviceWith(getCamelContext(), new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
replaceFromWith(uri);
}
});
}
return routeDefinition != null;
}
18
Source : FastCamelContext.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public void removeRouteDefinition(RouteDefinition routeDefinition) throws Exception {
model.removeRouteDefinition(routeDefinition);
}
18
Source : BaseModel.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public synchronized void removeRouteDefinitions(Collection<RouteDefinition> routeDefinitions) throws Exception {
for (RouteDefinition routeDefinition : routeDefinitions) {
removeRouteDefinition(routeDefinition);
}
}
17
Source : IntegrationRouteTest.java
with Apache License 2.0
from syndesisio
with Apache License 2.0
from syndesisio
@Test
public void integrationWithSplitTest() throws Exception {
final RouteBuilder routeBuilder = new IntegrationRouteBuilder("", Resources.loadServices(IntegrationStepHandler.clreplaced)) {
@Override
protected Integration loadIntegration() {
return newIntegration(new Step.Builder().id("step-1").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "start").build()).build()).build(), new Step.Builder().stepKind(StepKind.split).build(), new Step.Builder().id("step-2").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("bean").putConfiguredProperty("beanName", "io.syndesis.integration.runtime.IntegrationRouteTest.TestConfiguration").build()).build()).build(), new Step.Builder().id("step-3").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "result").build()).build()).build(), new Step.Builder().stepKind(StepKind.aggregate).build());
}
};
// initialize routes
routeBuilder.configure();
dumpRoutes(new DefaultCamelContext(), routeBuilder.getRouteCollection());
RoutesDefinition routes = routeBuilder.getRouteCollection();
replacedertThat(routes.getRoutes()).hreplacedize(1);
RouteDefinition route = routes.getRoutes().get(0);
replacedertThat(route.getInputs()).hreplacedize(1);
replacedertThat(route.getInputs().get(0)).hasFieldOrPropertyWithValue("uri", "direct:start");
replacedertThat(route.getOutputs()).hreplacedize(4);
replacedertThat(getOutput(route, 0)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(getOutput(route, 0).getOutputs()).hreplacedize(2);
replacedertThat(getOutput(route, 0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(route, 0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(route, 1)).isInstanceOf(SplitDefinition.clreplaced);
replacedertThat(getOutput(route, 1).getOutputs()).hreplacedize(4);
replacedertThat(getOutput(route, 1, 0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(route, 1, 1)).isInstanceOf(ProcessDefinition.clreplaced);
replacedertThat(getOutput(route, 1, 2)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(getOutput(route, 1, 3)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(getOutput(route, 2)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(route, 3)).isInstanceOf(ProcessDefinition.clreplaced);
}
17
Source : IntegrationRouteTest.java
with Apache License 2.0
from syndesisio
with Apache License 2.0
from syndesisio
@Test
public void integrationWithSchedulerTest() throws Exception {
final RouteBuilder routeBuilder = new IntegrationRouteBuilder("", Resources.loadServices(IntegrationStepHandler.clreplaced)) {
@Override
protected Integration loadIntegration() {
Integration integration = newIntegration(new Step.Builder().id("step-1").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("log").putConfiguredProperty("loggerName", "timer").build()).build()).build(), new Step.Builder().id("step-2").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "timer").build()).build()).build());
final Flow flow = integration.getFlows().get(0);
final Flow flowWithScheduler = flow.builder().scheduler(new Scheduler.Builder().type(Scheduler.Type.timer).expression("1s").build()).build();
return new Integration.Builder().createFrom(integration).flows(singleton(flowWithScheduler)).build();
}
};
// initialize routes
routeBuilder.configure();
dumpRoutes(new DefaultCamelContext(), routeBuilder.getRouteCollection());
RoutesDefinition routes = routeBuilder.getRouteCollection();
replacedertThat(routes.getRoutes()).hreplacedize(1);
RouteDefinition route = routes.getRoutes().get(0);
// Timer
replacedertThat(route.getInputs()).hreplacedize(1);
replacedertThat(route.getInputs().get(0)).hasFieldOrPropertyWithValue("uri", "timer:integration?period=1s");
replacedertThat(route.getOutputs()).hreplacedize(5);
replacedertThat(getOutput(route, 0)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(getOutput(route, 0).getOutputs()).hreplacedize(2);
replacedertThat(getOutput(route, 0, 0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(route, 0, 1)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(route, 1)).isInstanceOf(ToDefinition.clreplaced);
replacedertThat(getOutput(route, 1)).hasFieldOrPropertyWithValue("uri", "log:timer");
replacedertThat(getOutput(route, 2)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(route, 3)).isInstanceOf(ProcessDefinition.clreplaced);
replacedertThat(getOutput(route, 4)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(getOutput(route, 4).getOutputs()).hreplacedize(3);
replacedertThat(getOutput(route, 4, 0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(route, 4, 1)).isInstanceOf(ToDefinition.clreplaced);
replacedertThat(getOutput(route, 4, 1)).hasFieldOrPropertyWithValue("uri", "mock:timer");
replacedertThat(getOutput(route, 4, 2)).isInstanceOf(ProcessDefinition.clreplaced);
}
17
Source : IntegrationRouteTest.java
with Apache License 2.0
from syndesisio
with Apache License 2.0
from syndesisio
@Test
public void integrationWithSchedulerAndSplitTest() throws Exception {
final RouteBuilder routeBuilder = new IntegrationRouteBuilder("", Resources.loadServices(IntegrationStepHandler.clreplaced)) {
@Override
protected Integration loadIntegration() {
Integration integration = newIntegration(new Step.Builder().id("step-1").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("log").putConfiguredProperty("loggerName", "timer").build()).build()).build(), new Step.Builder().stepKind(StepKind.split).build(), new Step.Builder().id("step-2").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "timer").build()).build()).build(), new Step.Builder().stepKind(StepKind.aggregate).build());
final Flow flow = integration.getFlows().get(0);
final Flow flowWithScheduler = flow.builder().scheduler(new Scheduler.Builder().type(Scheduler.Type.timer).expression("1s").build()).build();
return new Integration.Builder().createFrom(integration).flows(singleton(flowWithScheduler)).build();
}
};
// initialize routes
routeBuilder.configure();
dumpRoutes(new DefaultCamelContext(), routeBuilder.getRouteCollection());
RoutesDefinition routes = routeBuilder.getRouteCollection();
replacedertThat(routes.getRoutes()).hreplacedize(1);
RouteDefinition route = routes.getRoutes().get(0);
replacedertThat(route.getInputs()).hreplacedize(1);
replacedertThat(route.getInputs().get(0)).hasFieldOrPropertyWithValue("uri", "timer:integration?period=1s");
replacedertThat(route.getOutputs()).hreplacedize(5);
replacedertThat(getOutput(route, 0)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(getOutput(route, 0).getOutputs()).hreplacedize(2);
replacedertThat(getOutput(route, 0, 0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(route, 0, 1)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(route, 1)).isInstanceOf(ToDefinition.clreplaced);
replacedertThat(getOutput(route, 1)).hasFieldOrPropertyWithValue("uri", "log:timer");
replacedertThat(getOutput(route, 2)).isInstanceOf(SplitDefinition.clreplaced);
replacedertThat(getOutput(route, 2).getOutputs()).hreplacedize(3);
replacedertThat(getOutput(route, 2, 0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(route, 2, 1)).isInstanceOf(ProcessDefinition.clreplaced);
replacedertThat(getOutput(route, 2, 2)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(getOutput(route, 2, 2).getOutputs()).hreplacedize(3);
replacedertThat(getOutput(route, 2, 2, 0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(route, 2, 2, 1)).isInstanceOf(ToDefinition.clreplaced);
replacedertThat(getOutput(route, 2, 2, 1)).hasFieldOrPropertyWithValue("uri", "mock:timer");
replacedertThat(getOutput(route, 2, 2, 2)).isInstanceOf(ProcessDefinition.clreplaced);
replacedertThat(getOutput(route, 3)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(route, 4)).isInstanceOf(ProcessDefinition.clreplaced);
}
17
Source : IntegrationRouteBuilderTest.java
with Apache License 2.0
from syndesisio
with Apache License 2.0
from syndesisio
@Test
public void testMultiFlowIntegrationRouteBuilder() throws Exception {
String configurationLocation = "clreplacedpath:syndesis/integration/multi-flow-integration.json";
IntegrationRouteBuilder routeBuilder = new IntegrationRouteBuilder(configurationLocation, Resources.loadServices(IntegrationStepHandler.clreplaced), policyFactories);
// initialize routes
routeBuilder.configure();
// Dump routes as XML for troubleshooting
dumpRoutes(new DefaultCamelContext(), routeBuilder.getRouteCollection());
RoutesDefinition routes = routeBuilder.getRouteCollection();
replacedertThat(routes.getRoutes()).hreplacedize(3);
RouteDefinition primaryRoute = routes.getRoutes().get(0);
replacedertThat(primaryRoute.getRoutePolicies()).hreplacedize(1);
replacedertThat(primaryRoute.getRoutePolicies().get(0)).isInstanceOf(IntegrationActivityTrackingPolicy.clreplaced);
replacedertThat(primaryRoute.getInputs()).hreplacedize(1);
replacedertThat(primaryRoute.getInputs().get(0)).hasFieldOrPropertyWithValue("uri", "direct:expression");
replacedertThat(primaryRoute.getOutputs()).hreplacedize(2);
replacedertThat(getOutput(primaryRoute, 0)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(getOutput(primaryRoute, 0).getOutputs()).hreplacedize(2);
replacedertThat(getOutput(primaryRoute, 0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(primaryRoute, 0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(primaryRoute, 1)).isInstanceOf(SplitDefinition.clreplaced);
replacedertThat(getOutput(primaryRoute, 1).getOutputs()).hreplacedize(5);
replacedertThat(getOutput(primaryRoute, 1, 0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(primaryRoute, 1, 1)).isInstanceOf(ProcessDefinition.clreplaced);
replacedertThat(getOutput(primaryRoute, 1, 2)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(getOutput(primaryRoute, 1, 2).getOutputs()).hreplacedize(2);
replacedertThat(getOutput(primaryRoute, 1, 2, 0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(primaryRoute, 1, 2, 1)).isInstanceOf(LogDefinition.clreplaced);
replacedertThat(getOutput(primaryRoute, 1, 2, 1)).hasFieldOrPropertyWithValue("message", "Body: [${bean:bodyLogger}] Before");
replacedertThat(getOutput(primaryRoute, 1, 3)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(getOutput(primaryRoute, 1, 3).getOutputs()).hreplacedize(3);
replacedertThat(getOutput(primaryRoute, 1, 3, 0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(primaryRoute, 1, 3, 1)).isInstanceOf(ChoiceDefinition.clreplaced);
replacedertThat(getOutput(primaryRoute, 1, 3, 2)).isInstanceOf(ProcessDefinition.clreplaced);
replacedertThat(getOutput(primaryRoute, 1, 4)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(getOutput(primaryRoute, 1, 4).getOutputs()).hreplacedize(2);
replacedertThat(getOutput(primaryRoute, 1, 4, 0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(primaryRoute, 1, 4, 1)).isInstanceOf(LogDefinition.clreplaced);
replacedertThat(getOutput(primaryRoute, 1, 4, 1)).hasFieldOrPropertyWithValue("message", "Body: [${bean:bodyLogger}] Finished");
RouteDefinition conditionalRoute = routes.getRoutes().get(1);
replacedertThat(conditionalRoute.getRoutePolicies()).hreplacedize(1);
replacedertThat(conditionalRoute.getRoutePolicies().get(0)).isInstanceOf(FlowActivityTrackingPolicy.clreplaced);
replacedertThat(conditionalRoute.getInputs()).hreplacedize(1);
replacedertThat(conditionalRoute.getInputs().get(0)).hasFieldOrPropertyWithValue("uri", "direct");
replacedertThat(conditionalRoute.getOutputs()).hreplacedize(5);
replacedertThat(getOutput(conditionalRoute, 0)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(getOutput(conditionalRoute, 0).getOutputs()).hreplacedize(2);
replacedertThat(getOutput(conditionalRoute, 0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(conditionalRoute, 0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(conditionalRoute, 1)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(conditionalRoute, 2)).isInstanceOf(ProcessDefinition.clreplaced);
replacedertThat(getOutput(conditionalRoute, 3)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(getOutput(conditionalRoute, 3).getOutputs()).hreplacedize(2);
replacedertThat(getOutput(conditionalRoute, 3, 0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(conditionalRoute, 3, 1)).isInstanceOf(LogDefinition.clreplaced);
replacedertThat(getOutput(conditionalRoute, 3, 1)).hasFieldOrPropertyWithValue("message", "Body: [${bean:bodyLogger}] Found <Play>");
replacedertThat(getOutput(conditionalRoute, 4)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(getOutput(conditionalRoute, 4).getOutputs()).hreplacedize(3);
replacedertThat(getOutput(conditionalRoute, 4, 0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(conditionalRoute, 4, 1)).isInstanceOf(ToDefinition.clreplaced);
replacedertThat(getOutput(conditionalRoute, 4, 1)).hasFieldOrPropertyWithValue("uri", "bean:io.syndesis.connector.flow.NoOpBean?method=process");
replacedertThat(getOutput(conditionalRoute, 4, 2)).isInstanceOf(ProcessDefinition.clreplaced);
}
17
Source : IntegrationRouteBuilderTest.java
with Apache License 2.0
from syndesisio
with Apache License 2.0
from syndesisio
@Test
public void testIntegrationRouteBuilder() throws Exception {
String configurationLocation = "clreplacedpath:syndesis/integration/integration.json";
IntegrationRouteBuilder routeBuilder = new IntegrationRouteBuilder(configurationLocation, Resources.loadServices(IntegrationStepHandler.clreplaced), policyFactories);
// initialize routes
routeBuilder.configure();
// Dump routes as XML for troubleshooting
dumpRoutes(new DefaultCamelContext(), routeBuilder.getRouteCollection());
RoutesDefinition routes = routeBuilder.getRouteCollection();
replacedertThat(routes.getRoutes()).hreplacedize(1);
RouteDefinition route = routes.getRoutes().get(0);
replacedertThat(route.getRoutePolicies()).hreplacedize(1);
replacedertThat(route.getInputs()).hreplacedize(1);
replacedertThat(route.getInputs().get(0)).hasFieldOrPropertyWithValue("uri", "direct:expression");
replacedertThat(route.getOutputs()).hreplacedize(2);
replacedertThat(getOutput(route, 0)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(getOutput(route, 0).getOutputs()).hreplacedize(2);
replacedertThat(getOutput(route, 0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(route, 0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(route, 1)).isInstanceOf(SplitDefinition.clreplaced);
replacedertThat(getOutput(route, 1).getOutputs()).hreplacedize(3);
replacedertThat(getOutput(route, 1, 0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(route, 1, 1)).isInstanceOf(ProcessDefinition.clreplaced);
replacedertThat(getOutput(route, 1, 2)).isInstanceOf(PipelineDefinition.clreplaced);
replacedertThat(getOutput(route, 1, 2).getOutputs()).hreplacedize(3);
replacedertThat(getOutput(route, 1, 2, 0)).isInstanceOf(SetHeaderDefinition.clreplaced);
replacedertThat(getOutput(route, 1, 2, 1)).isInstanceOf(ToDefinition.clreplaced);
replacedertThat(getOutput(route, 1, 2, 1)).hasFieldOrPropertyWithValue("uri", "mock:expression");
replacedertThat(getOutput(route, 1, 2, 2)).isInstanceOf(ProcessDefinition.clreplaced);
}
17
Source : IntegrationRouteBuilder.java
with Apache License 2.0
from syndesisio
with Apache License 2.0
from syndesisio
/**
* Checks if given route definition has already been configured with activity tracking policies.
* @param routeDefinition the route definition to evaluate.
* @return true if activity tracking policies have already been configured on given route definition.
*/
private boolean containsConfiguredActivityTrackingPolicies(RouteDefinition routeDefinition) {
List<RoutePolicy> routePolicies = routeDefinition.getRoutePolicies();
if (ObjectHelper.isEmpty(routePolicies)) {
return false;
}
return activityTrackingPolicyFactories.stream().anyMatch(policyFactory -> routePolicies.stream().anyMatch(policyFactory::isInstance));
}
17
Source : FastCamelContext.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public void addRouteDefinition(RouteDefinition routeDefinition) throws Exception {
model.addRouteDefinition(routeDefinition);
}
17
Source : BaseModel.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public void addRouteDefinition(RouteDefinition routeDefinition) throws Exception {
addRouteDefinitions(Collections.singletonList(routeDefinition));
}
16
Source : CamelUtils.java
with Apache License 2.0
from rodrigoserracoelho
with Apache License 2.0
from rodrigoserracoelho
public void buildOnExceptionDefinition(RouteDefinition routeDefinition, boolean isZipkinTraceIdVisible, boolean isInternalExceptionMessageVisible, boolean isInternalExceptionVisible, String routeID) {
routeDefinition.onException(Exception.clreplaced).handled(true).setHeader(Constants.ERROR_API_SHOW_TRACE_ID, constant(isZipkinTraceIdVisible)).setHeader(Constants.ERROR_API_SHOW_INTERNAL_ERROR_MESSAGE, constant(isInternalExceptionMessageVisible)).setHeader(Constants.ERROR_API_SHOW_INTERNAL_ERROR_CLreplaced, constant(isInternalExceptionVisible)).process(routeErrorProcessor).setHeader(Constants.ROUTE_ID_HEADER, constant(routeID)).toF(Constants.FAIL_REST_ENDPOINT_OBJECT, apiGatewayErrorEndpoint).removeHeader(Constants.ERROR_API_SHOW_TRACE_ID).removeHeader(Constants.ERROR_API_SHOW_INTERNAL_ERROR_MESSAGE).removeHeader(Constants.ERROR_API_SHOW_INTERNAL_ERROR_CLreplaced).removeHeader(Constants.ROUTE_ID_HEADER).end();
}
16
Source : FastCamelContext.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public RouteDefinition adviceWith(RouteDefinition definition, AdviceWithRouteBuilder builder) throws Exception {
return AdviceWith.adviceWith(definition, this, builder);
}
16
Source : BaseModel.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public synchronized void removeRouteDefinition(RouteDefinition routeDefinition) throws Exception {
RouteDefinition toBeRemoved = routeDefinition;
String id = routeDefinition.getId();
if (id != null) {
// remove existing route
camelContext.getRouteController().stopRoute(id);
camelContext.removeRoute(id);
toBeRemoved = getRouteDefinition(id);
}
this.routeDefinitions.remove(toBeRemoved);
}
16
Source : BaseModel.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public synchronized RouteDefinition getRouteDefinition(String id) {
for (RouteDefinition route : routeDefinitions) {
if (route.idOrCreate(camelContext.adapt(ExtendedCamelContext.clreplaced).getNodeIdFactory()).equals(id)) {
return route;
}
}
return null;
}
14
Source : CamelUtils.java
with Apache License 2.0
from rodrigoserracoelho
with Apache License 2.0
from rodrigoserracoelho
public void buildRoute(RouteDefinition routeDefinition, String routeID, RunningApi runningApi, boolean pathHasParams) {
String protocol = runningApi.getEndpointType().equals(EndpointType.HTTP) ? Constants.HTTP4_PREFIX : Constants.HTTPS4_PREFIX;
String[] endpointArray = buildEndpoints(pathHasParams, protocol, runningApi.getPath(), runningApi.getEndpoints(), runningApi.getConnectTimeout(), runningApi.getSocketTimeout());
if (pathHasParams) {
routeDefinition.setHeader(Constants.CAPI_CONTEXT_HEADER, constant(runningApi.getContext()));
}
/*if(trafficInspectorEnabled) {
routeDefinition
.setBody(constant(routeID))
.to("kafka:" + trafficInspectorKafkaTopic + "?brokers=" + trafficInspectorKafkaBroker);
}*/
if (runningApi.isSecured()) {
if (runningApi.isTrafficInspectorEnabled()) {
if (trafficInspectorEnabled) {
routeDefinition.setBody(constant(routeID)).to("kafka:" + trafficInspectorKafkaTopic + "?brokers=" + trafficInspectorKafkaBroker);
}
}
routeDefinition.setHeader(Constants.BLOCK_IF_IN_ERROR_HEADER, constant(runningApi.isBlockIfInError())).setHeader(Constants.API_CLIENT_ID_HEADER, constant(runningApi.getClientID())).process(authProcessor).process(pathProcessor).process(metricsProcessor).loadBalance().roundRobin().to(endpointArray).end().setId(routeID);
} else {
routeDefinition.streamCaching().process(pathProcessor).process(metricsProcessor).loadBalance().roundRobin().to(endpointArray).end().setId(routeID);
}
registerMetric(runningApi.getRouteId());
zipkinTracer.addServerServiceMapping(runningApi.getContext() + runningApi.getPath(), routeID);
}
14
Source : CamelSteps.java
with Apache License 2.0
from citrusframework
with Apache License 2.0
from citrusframework
@Given("^Camel route ([^\\s]+)\\.xml")
public void camelRouteXml(String id, String routeSpec) throws Exception {
String routeXml;
if (routeSpec.startsWith("<route>")) {
routeXml = String.format("<route id=\"%s\" xmlns=\"http://camel.apache.org/schema/spring\">", id) + routeSpec.substring("<route>".length());
} else if (routeSpec.startsWith("<route")) {
routeXml = routeSpec;
} else {
routeXml = String.format("<route id=\"%s\" xmlns=\"http://camel.apache.org/schema/spring\">", id) + routeSpec + "</route>";
}
final XMLRoutesDefinitionLoader loader = camelContext().adapt(ExtendedCamelContext.clreplaced).getXMLRoutesDefinitionLoader();
Object result = loader.loadRoutesDefinition(camelContext(), new ByteArrayInputStream(context.replaceDynamicContentInString(routeXml).getBytes(StandardCharsets.UTF_8)));
if (result instanceof RoutesDefinition) {
RoutesDefinition routeDefinition = (RoutesDefinition) result;
camelContext().addRoutes(new RouteBuilder(camelContext()) {
@Override
public void configure() throws Exception {
for (RouteDefinition route : routeDefinition.getRoutes()) {
try {
getRouteCollection().getRoutes().add(route);
log.info(String.format("Created new Camel route '%s' in context '%s'", route.getRouteId(), camelContext().getName()));
} catch (Exception e) {
throw new CitrusRuntimeException(String.format("Failed to create route definition '%s' in context '%s'", route.getRouteId(), camelContext.getName()), e);
}
}
}
});
for (RouteDefinition route : routeDefinition.getRoutes()) {
camelContext().adapt(AbstractCamelContext.clreplaced).startRoute(route.getRouteId());
}
}
}
14
Source : AbstractLocalCamelController.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public String getRouteModelAsXml(String routeId, String camelContextName) throws Exception {
CamelContext context = this.getLocalCamelContext(camelContextName);
if (context == null) {
return null;
}
RouteDefinition route = context.getExtension(Model.clreplaced).getRouteDefinition(routeId);
if (route == null) {
return null;
}
ExtendedCamelContext ecc = context.adapt(ExtendedCamelContext.clreplaced);
return ecc.getModelToXMLDumper().dumpModelAsXml(context, route);
}
13
Source : IntegrationRouteBuilder.java
with Apache License 2.0
from syndesisio
with Apache License 2.0
from syndesisio
/**
* If the integration has a scheduler, start the route with a timer or quartz2
* endpoint.
*/
private ProcessorDefinition<?> configureRouteScheduler(final Flow flow) throws URISyntaxException {
if (flow.getScheduler().isPresent()) {
Scheduler scheduler = flow.getScheduler().get();
// We now support simple timer only, cron support will be supported
// later on.
if (scheduler.isTimer()) {
Map<String, String> properties = new HashMap<>();
properties.put("timerName", "integration");
properties.put("period", scheduler.getExpression());
final RuntimeCamelCatalog catalog = getContext().getRuntimeCamelCatalog();
final String uri = catalog.asEndpointUri("timer", properties, false);
RouteDefinition route = this.from(uri);
route.getInputs().get(0).setId("integration-scheduler");
flow.getId().ifPresent(route::setId);
return route;
}
throw new IllegalArgumentException("Unsupported scheduler type: " + scheduler.getType());
}
return null;
}
13
Source : BaseModel.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public ProcessorDefinition getProcessorDefinition(String id) {
for (RouteDefinition route : getRouteDefinitions()) {
Iterator<ProcessorDefinition> it = ProcessorDefinitionHelper.filterTypeInOutputs(route.getOutputs(), ProcessorDefinition.clreplaced);
while (it.hasNext()) {
ProcessorDefinition proc = it.next();
if (id.equals(proc.getId())) {
return proc;
}
}
}
return null;
}
11
Source : CamelUtils.java
with Apache License 2.0
from rodrigoserracoelho
with Apache License 2.0
from rodrigoserracoelho
public void buildRoute(RouteDefinition routeDefinition, String routeID, Api api, Path path, boolean pathHasParams) {
String protocol = api.getEndpointType().equals(EndpointType.HTTP) ? Constants.HTTP4_PREFIX : Constants.HTTPS4_PREFIX;
String[] endpointArray = buildEndpoints(pathHasParams, protocol, path.getPath(), api.getEndpoints(), api.getConnectTimeout(), api.getSocketTimeout());
if (pathHasParams) {
routeDefinition.setHeader(Constants.CAPI_CONTEXT_HEADER, constant(api.getContext()));
}
/*if(trafficInspectorEnabled) {
routeDefinition
.setBody(constant(routeID))
.to("kafka:" + trafficInspectorKafkaTopic + "?brokers=" + trafficInspectorKafkaBroker);
}*/
if (api.isSecured()) {
if (api.getThrottlingPolicy() != null) {
if (trafficInspectorEnabled) {
routeDefinition.setBody(constant(routeID)).to("kafka:" + trafficInspectorKafkaTopic + "?brokers=" + trafficInspectorKafkaBroker);
}
}
routeDefinition.setHeader(Constants.BLOCK_IF_IN_ERROR_HEADER, constant(api.isBlockIfInError())).setHeader(Constants.API_CLIENT_ID_HEADER, constant(api.getClientID())).process(pathProcessor).process(authProcessor).process(metricsProcessor).loadBalance().roundRobin().to(endpointArray).end().setId(routeID);
} else {
routeDefinition.streamCaching().process(pathProcessor).process(metricsProcessor).loadBalance().roundRobin().to(endpointArray).end().setId(routeID);
}
registerMetric(normalizeRouteId(api, path));
zipkinTracer.addServerServiceMapping(api.getContext() + path.getPath(), normalizeRouteId(api, path));
runningApiManager.runApi(routeID, api, path.getPath(), path.getVerb());
}
10
Source : FastCamelContext.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public void startRouteDefinitions(List<RouteDefinition> routeDefinitions) throws Exception {
// indicate we are staring the route using this thread so
// we are able to query this if needed
boolean alreadyStartingRoutes = isStartingRoutes();
if (!alreadyStartingRoutes) {
setStartingRoutes(true);
}
PropertiesComponent pc = getCamelContextReference().getPropertiesComponent();
try {
RouteDefinitionHelper.forcereplacedignIds(getCamelContextReference(), routeDefinitions);
for (RouteDefinition routeDefinition : routeDefinitions) {
// replacedign ids to the routes and validate that the id's is all unique
String duplicate = RouteDefinitionHelper.validateUniqueIds(routeDefinition, routeDefinitions);
if (duplicate != null) {
throw new FailedToStartRouteException(routeDefinition.getId(), "duplicate id detected: " + duplicate + ". Please correct ids to be unique among all your routes.");
}
// if the route definition was created via a route template then we need to prepare its parameters when the route is being created and started
if (routeDefinition.isTemplate() != null && routeDefinition.isTemplate() && routeDefinition.getTemplateParameters() != null) {
Properties prop = new Properties();
prop.putAll(routeDefinition.getTemplateParameters());
pc.setLocalProperties(prop);
}
// must ensure route is prepared, before we can start it
if (!routeDefinition.isPrepared()) {
RouteDefinitionHelper.prepareRoute(getCamelContextReference(), routeDefinition);
routeDefinition.markPrepared();
}
Route route = new RouteReifier(getCamelContextReference(), routeDefinition).createRoute();
RouteService routeService = new RouteService(route);
startRouteService(routeService, true);
}
} finally {
if (!alreadyStartingRoutes) {
setStartingRoutes(false);
}
}
}
9
Source : BaseModel.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public String addRouteFromTemplate(final String routeId, final String routeTemplateId, final Map<String, Object> parameters) throws Exception {
RouteTemplateDefinition target = null;
for (RouteTemplateDefinition def : routeTemplateDefinitions) {
if (routeTemplateId.equals(def.getId())) {
target = def;
break;
}
}
if (target == null) {
throw new IllegalArgumentException("Cannot find RouteTemplate with id " + routeTemplateId);
}
final Map<String, Object> prop = new HashMap<>();
// include default values first from the template (and validate that we have inputs for all required parameters)
if (target.getTemplateParameters() != null) {
StringJoiner templatesBuilder = new StringJoiner(", ");
for (RouteTemplateParameterDefinition temp : target.getTemplateParameters()) {
if (temp.getDefaultValue() != null) {
prop.put(temp.getName(), temp.getDefaultValue());
} else {
// this is a required parameter do we have that as input
if (!parameters.containsKey(temp.getName())) {
templatesBuilder.add(temp.getName());
}
}
}
if (templatesBuilder.length() > 0) {
throw new IllegalArgumentException("Route template " + routeTemplateId + " the following mandatory parameters must be provided: " + templatesBuilder.toString());
}
}
// then override with user parameters
if (parameters != null) {
prop.putAll(parameters);
}
RouteTemplateDefinition.Converter converter = RouteTemplateDefinition.Converter.DEFAULT_CONVERTER;
for (Map.Entry<String, RouteTemplateDefinition.Converter> entry : routeTemplateConverters.entrySet()) {
final String key = entry.getKey();
final String templateId = target.getId();
if ("*".equals(key) || templateId.equals(key)) {
converter = entry.getValue();
break;
} else if (AntPathMatcher.INSTANCE.match(key, templateId)) {
converter = entry.getValue();
break;
} else if (templateId.matches(key)) {
converter = entry.getValue();
break;
}
}
RouteDefinition def = converter.apply(target, prop);
if (routeId != null) {
def.setId(routeId);
}
def.setTemplateParameters(prop);
addRouteDefinition(def);
return def.getId();
}
4
Source : SwaggerRoutePublisher.java
with Apache License 2.0
from rodrigoserracoelho
with Apache License 2.0
from rodrigoserracoelho
void addRoutes(Api api) throws Exception {
List<Path> pathList = swaggerParser.parse(api.getSwaggerEndpoint());
api.setPaths(pathList);
List<Panel> grafanaPanels = null;
if (grafanaDashboardBuilder != null) {
grafanaPanels = new ArrayList<>();
}
for (Path path : api.getPaths()) {
RestOperationParamDefinition restParamDefinition = new RestOperationParamDefinition();
List<String> paramList = camelUtils.evaluatePath(path.getPath());
String routeID = camelUtils.normalizeRouteId(api, path);
path.setRouteID(routeID);
RouteDefinition routeDefinition;
switch(path.getVerb()) {
case GET:
routeDefinition = rest().get("/" + api.getContext() + path.getPath()).route();
break;
case POST:
routeDefinition = rest().post("/" + api.getContext() + path.getPath()).route().setProperty(Constants.REST_CALL_BODY, body());
break;
case PUT:
routeDefinition = rest().put("/" + api.getContext() + path.getPath()).route().setProperty(Constants.REST_CALL_BODY, body());
break;
case DELETE:
routeDefinition = rest().delete("/" + api.getContext() + path.getPath()).route();
break;
case HEAD:
routeDefinition = rest().head("/" + api.getContext() + path.getPath()).route();
break;
default:
throw new Exception("No verb available");
}
camelUtils.buildOnExceptionDefinition(routeDefinition, api.isZipkinTraceIdVisible(), api.isInternalExceptionMessageVisible(), api.isInternalExceptionVisible(), routeID);
if (paramList.isEmpty()) {
camelUtils.buildRoute(routeDefinition, routeID, api, path, false);
} else {
for (String param : paramList) {
restParamDefinition.name(param).type(RestParamType.path).dataType("String");
}
camelUtils.buildRoute(routeDefinition, routeID, api, path, true);
}
if (grafanaPanels != null) {
Panel panel = grafanaDashboardBuilder.buildPanelObject(routeID, routeID);
grafanaPanels.add(panel);
}
}
throttlingManager.applyThrottling(api);
if (grafanaDashboardBuilder != null) {
List<String> tags = new ArrayList<>();
tags.add("CAPI");
tags.add(api.getName());
grafanaDashboardBuilder.buildDashboardObject(api.getName(), tags, grafanaPanels);
}
}
See More Examples