/** * Populate a {@link MessageFilter} with {@link MessageSelector} for the provided SpEL expression. * @param expression the SpEL expression. * @return the current {@link IntegrationFlowDefinition}. */ public B filter(String expression) { return filter(expression, (Consumer<FilterEndpointSpec>) null); }
/** * Populate a {@link MessageFilter} with {@link MethodInvokingSelector} for the * discovered method of the provided service. * @param service the service to use. * @return the current {@link IntegrationFlowDefinition}. * @see MethodInvokingSelector */ public B filter(Object service) { return filter(service, null); }
/** * Populate a {@link MessageFilter} with {@link MethodInvokingSelector} for the * method of the provided service. * @param service the service to use. * @param methodName the method to invoke * @return the current {@link IntegrationFlowDefinition}. * @see MethodInvokingSelector */ public B filter(Object service, String methodName) { return filter(service, methodName, null); }
/** * Populate a {@link MessageFilter} with {@link MethodInvokingSelector} * for the {@link org.springframework.integration.handler.MessageProcessor} from * the provided {@link MessageProcessorSpec}. * <pre class="code"> * {@code * .filter(Scripts.script(scriptResource).lang("ruby")) * } * </pre> * @param messageProcessorSpec the {@link MessageProcessorSpec} to use. * @return the current {@link IntegrationFlowDefinition}. */ public B filter(MessageProcessorSpec<?> messageProcessorSpec) { return filter(messageProcessorSpec, (Consumer<FilterEndpointSpec>) null); }
/** * Populate a {@link MessageFilter} with {@link MethodInvokingSelector} * for the provided {@link GenericSelector}. * Typically used with a Java 8 Lambda expression: * <pre class="code"> * {@code * .filter("World"::equals) * } * </pre> * Use {@link #filter(Class, GenericSelector)} if you need to access the entire * message. * @param genericSelector the {@link GenericSelector} to use. * @param <P> the source payload type. * @return the current {@link IntegrationFlowDefinition}. */ public <P> B filter(GenericSelector<P> genericSelector) { return filter(null, genericSelector); }
/** * Populate a {@link MessageFilter} with {@link MethodInvokingSelector} * for the provided {@link GenericSelector}. * Typically used with a Java 8 Lambda expression: * <pre class="code"> * {@code * .filter(Date.class, p -> p.after(new Date())) * } * </pre> * @param payloadType the {@link Class} for expected payload type. It can also be * {@code Message.class} if you wish to access the entire message in the selector. * Conversion to this type will be attempted, if necessary. * @param genericSelector the {@link GenericSelector} to use. * @param <P> the source payload type or {@code Message.class}. * @return the current {@link IntegrationFlowDefinition}. * @see LambdaMessageProcessor */ public <P> B filter(Class<P> payloadType, GenericSelector<P> genericSelector) { return filter(payloadType, genericSelector, null); }
/** * Populate a {@link MessageFilter} with {@link MethodInvokingSelector} * for the provided {@link GenericSelector}. * In addition accept options for the integration endpoint using {@link FilterEndpointSpec}. * Typically used with a Java 8 Lambda expression: * <pre class="code"> * {@code * .filter("World"::equals, e -> e.autoStartup(false)) * } * </pre> * Use {@link #filter(Class, GenericSelector, Consumer)} if you need to access the entire * message. * @param genericSelector the {@link GenericSelector} to use. * @param endpointConfigurer the {@link Consumer} to provide integration endpoint options. * @param <P> the source payload type. * @return the current {@link IntegrationFlowDefinition}. * @see FilterEndpointSpec */ public <P> B filter(GenericSelector<P> genericSelector, Consumer<FilterEndpointSpec> endpointConfigurer) { return filter(null, genericSelector, endpointConfigurer); }
/** * Populate a {@link MessageFilter} with {@link MessageSelector} for the provided SpEL expression. * In addition accept options for the integration endpoint using {@link FilterEndpointSpec}: * <pre class="code"> * {@code * .filter("payload.hot"), e -> e.autoStartup(false)) * } * </pre> * @param expression the SpEL expression. * @param endpointConfigurer the {@link Consumer} to provide integration endpoint options. * @return the current {@link IntegrationFlowDefinition}. * @see FilterEndpointSpec */ public B filter(String expression, Consumer<FilterEndpointSpec> endpointConfigurer) { Assert.hasText(expression, "'expression' must not be empty"); return filter(new ExpressionEvaluatingSelector(expression), endpointConfigurer); }
/** * Populate a {@link MessageFilter} with {@link MethodInvokingSelector} for the * method of the provided service. * @param service the service to use. * @param methodName the method to invoke * @param endpointConfigurer the {@link Consumer} to provide integration endpoint options. * @return the current {@link IntegrationFlowDefinition}. * @see MethodInvokingSelector */ public B filter(Object service, String methodName, Consumer<FilterEndpointSpec> endpointConfigurer) { MethodInvokingSelector selector; if (StringUtils.hasText(methodName)) { selector = new MethodInvokingSelector(service, methodName); } else { selector = new MethodInvokingSelector(service); } return filter(selector, endpointConfigurer); }
/** * Populate a {@link MessageFilter} with {@link MethodInvokingSelector} * for the {@link org.springframework.integration.handler.MessageProcessor} from * the provided {@link MessageProcessorSpec}. * In addition accept options for the integration endpoint using {@link FilterEndpointSpec}. * <pre class="code"> * {@code * .filter(Scripts.script(scriptResource).lang("ruby"), * e -> e.autoStartup(false)) * } * </pre> * @param messageProcessorSpec the {@link MessageProcessorSpec} to use. * @param endpointConfigurer the {@link Consumer} to provide integration endpoint options. * @return the current {@link IntegrationFlowDefinition}. */ public B filter(MessageProcessorSpec<?> messageProcessorSpec, Consumer<FilterEndpointSpec> endpointConfigurer) { Assert.notNull(messageProcessorSpec, "'messageProcessorSpec' must not be null"); MessageProcessor<?> processor = messageProcessorSpec.get(); return addComponent(processor) .filter(new MethodInvokingSelector(processor), endpointConfigurer); }
@Bean public IntegrationFlow scriptFilter() { return f -> f.filter(Scripts.processor(this.filterScript), e -> e.discardChannel("discardChannel")) .channel(results()); }
/** * Populate a {@link MessageFilter} with {@link MethodInvokingSelector} for the * discovered method of the provided service. * @param service the service to use. * @return the current {@link IntegrationFlowDefinition}. * @see MethodInvokingSelector */ public B filter(Object service) { return filter(service, null); }
/** * Populate a {@link MessageFilter} with {@link MethodInvokingSelector} for the * method of the provided service. * @param service the service to use. * @param methodName the method to invoke * @return the current {@link IntegrationFlowDefinition}. * @see MethodInvokingSelector */ public B filter(Object service, String methodName) { return filter(service, methodName, null); }
/** * Populate a {@link MessageFilter} with {@link MessageSelector} for the provided SpEL expression. * @param expression the SpEL expression. * @return the current {@link IntegrationFlowDefinition}. */ public B filter(String expression) { return filter(expression, (Consumer<FilterEndpointSpec>) null); }
/** * Populate a {@link MessageFilter} with {@link MessageSelector} for the provided SpEL expression. * @param expression the SpEL expression. * @return the current {@link IntegrationFlowDefinition}. */ public B filter(String expression) { return filter(expression, (Consumer<FilterEndpointSpec>) null); }
/** * Populate a {@link MessageFilter} with {@link MethodInvokingSelector} for the * discovered method of the provided service. * @param service the service to use. * @return the current {@link IntegrationFlowDefinition}. * @since 1.1 * @see MethodInvokingSelector */ public B filter(Object service) { return filter(service, null); }
@Bean public IntegrationFlow scriptFilter() { return f -> f .filter(Scripts.processor(scriptResource()) .lang("groovy"), e -> e.discardChannel("discardChannel")) .channel(c -> c.queue("results")); }
/** * Populate a {@link MessageFilter} with {@link MethodInvokingSelector} for the * method of the provided service. * @param service the service to use. * @param methodName the method to invoke * @return the current {@link IntegrationFlowDefinition}. * @since 1.1 * @see MethodInvokingSelector */ public B filter(Object service, String methodName) { return filter(service, methodName, null); }
/** * Populate a {@link MessageFilter} with {@link MessageSelector} for the provided SpEL expression. * @param expression the SpEL expression. * @return the current {@link IntegrationFlowDefinition}. */ public B filter(String expression) { return filter(expression, (Consumer<FilterEndpointSpec>) null); }
/** * Populate a {@link MessageFilter} with {@link MethodInvokingSelector} for the * discovered method of the provided service. * @param service the service to use. * @return the current {@link IntegrationFlowDefinition}. * @since 1.1 * @see MethodInvokingSelector */ public B filter(Object service) { return filter(service, null); }