private ImmutableScheduler(ImmutableScheduler.Builder builder) { this.expression = builder.expression; this.type = builder.type != null ? builder.type : Objects.requireNonNull(Scheduler.super.getType(), "type"); }
/** * 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; } else { throw new IllegalArgumentException("Unsupported scheduler type: " + scheduler.getType()); } } return null; }
/** * Fill a builder with attribute values from the provided {@code Scheduler} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Scheduler.Builder createFrom(Scheduler instance) { Objects.requireNonNull(instance, "instance"); type(instance.getType()); String expressionValue = instance.getExpression(); if (expressionValue != null) { expression(expressionValue); } return (Scheduler.Builder) this; }
@JsonIgnore default boolean isCron() { return Type.cron == getType(); }
@JsonIgnore default boolean isTimer() { return Type.timer == getType(); }