use of org.apache.camel.runtimecatalog.RuntimeCamelCatalog in project syndesis by syndesisio.
the class SimpleEndpointStepHandler method handle.
@SuppressWarnings({ "unchecked", "PMD" })
@Override
public Optional<ProcessorDefinition> handle(Step step, ProcessorDefinition route, IntegrationRouteBuilder builder, final String index) {
// Model
final ConnectorAction action = step.getActionAs(ConnectorAction.class).get();
final ConnectorDescriptor descriptor = action.getDescriptor();
// Camel
final String componentScheme = action.getDescriptor().getComponentScheme().get();
final Map<String, String> configuredProperties = step.getConfiguredProperties();
final Map<String, String> properties = action.filterEndpointProperties(configuredProperties);
properties.entrySet().stream().filter(action::isEndpointProperty).filter(action::isSecret).forEach(e -> e.setValue(String.format("{{%s-%s.%s}}", componentScheme, index, e.getKey())));
// raw values.
properties.entrySet().stream().filter(action::isRaw).forEach(e -> e.setValue(String.format("RAW(%s)", e.getValue())));
// any configuredProperties on action descriptor are considered
properties.putAll(descriptor.getConfiguredProperties());
try {
final RuntimeCamelCatalog catalog = builder.getContext().getRuntimeCamelCatalog();
final String uri = catalog.asEndpointUri(componentScheme, Map.class.cast(properties), false);
if (route == null) {
route = builder.from(uri);
} else {
route = route.to(uri);
}
} catch (URISyntaxException e) {
throw ObjectHelper.wrapRuntimeCamelException(e);
}
return Optional.ofNullable(route);
}
use of org.apache.camel.runtimecatalog.RuntimeCamelCatalog in project syndesis by syndesisio.
the class IntegrationRouteBuilder method configureRouteScheduler.
/**
* If the integration has a scheduler, start the route with a timer or quartz2
* endpoint.
*/
private ProcessorDefinition configureRouteScheduler(Integration integration) throws URISyntaxException {
if (integration.getScheduler().isPresent()) {
Scheduler scheduler = integration.getScheduler().get();
// 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");
integration.getId().ifPresent(route::setId);
return route;
} else {
throw new IllegalArgumentException("Unsupported scheduler type: " + scheduler.getType());
}
}
return null;
}
Aggregations