refactor: smaller ConnectorStepHandler::handle
@@ -150,30 +150,32 @@ public class ConnectorStepHandler implements IntegrationStepHandler, Integration
final String endpointUri = createProxyComponentUri(flowIndex, stepIndex, scheme, step);
- final ProcessorDefinition<?> definition;
+ final ProcessorDefinition<?> definition = createRouteElement(route, builder, action, component, endpointUri);
+
+ return Optional.ofNullable(definition);
+ }
+
+ static ProcessorDefinition<?> createRouteElement(final ProcessorDefinition<?> route, final IntegrationRouteBuilder builder, final ConnectorAction action,
+ final ComponentProxyComponent component, final String endpointUri) {
if (route == null) {
// we're at step 0
- definition = builder.from(endpointUri);
- } else {
+ return builder.from(endpointUri);
+ }
+
// route exists we passed step 0
final Pattern pattern = action.getPattern().orElse(Pattern.To);
switch (pattern) {
case To:
case Pipe:
case From: // sql-start connector uses From
- definition = route.to(endpointUri);
- break;
+ return route.to(endpointUri);
case PollEnrich:
- definition = route.process(pollEnricher(endpointUri, component));
- break;
+ return route.process(pollEnricher(endpointUri, component));
default:
throw new UnsupportedOperationException("'" + pattern + "' pattern not supported");
}
}
- return Optional.ofNullable(definition);
- }
-
static String createProxyComponentUri(final String flowIndex, final String stepIndex, final String scheme, final Step step) {
final String dynamicParamaters = step.getConfiguredProperties().entrySet().stream()
.filter(e -> isProxyEndpointProperty(step, e.getKey()))
