Search in sources :

Example 1 with GenericTransformer

use of org.springframework.integration.transformer.GenericTransformer in project spring-integration by spring-projects.

the class IntegrationFlowDefinition method transform.

/**
 * Populate the {@link MessageTransformingHandler} instance for the provided {@link GenericTransformer}
 * for the specific {@code payloadType} to convert at runtime.
 * In addition accept options for the integration endpoint using {@link GenericEndpointSpec}.
 * @param payloadType the {@link Class} for expected payload type.
 * @param genericTransformer the {@link GenericTransformer} to populate.
 * @param endpointConfigurer the {@link Consumer} to provide integration endpoint options.
 * @param <P> the payload type - 'transform from'.
 * @param <T> the target type - 'transform to'.
 * @return the current {@link IntegrationFlowDefinition}.
 * @see MethodInvokingTransformer
 * @see LambdaMessageProcessor
 * @see GenericEndpointSpec
 */
public <P, T> B transform(Class<P> payloadType, GenericTransformer<P, T> genericTransformer, Consumer<GenericEndpointSpec<MessageTransformingHandler>> endpointConfigurer) {
    Assert.notNull(genericTransformer, "'genericTransformer' must not be null");
    Transformer transformer = genericTransformer instanceof Transformer ? (Transformer) genericTransformer : (isLambda(genericTransformer) ? new MethodInvokingTransformer(new LambdaMessageProcessor(genericTransformer, payloadType)) : new MethodInvokingTransformer(genericTransformer));
    return addComponent(transformer).handle(new MessageTransformingHandler(transformer), endpointConfigurer);
}
Also used : LambdaMessageProcessor(org.springframework.integration.handler.LambdaMessageProcessor) MessageTransformingHandler(org.springframework.integration.transformer.MessageTransformingHandler) Transformer(org.springframework.integration.transformer.Transformer) MethodInvokingTransformer(org.springframework.integration.transformer.MethodInvokingTransformer) ClaimCheckOutTransformer(org.springframework.integration.transformer.ClaimCheckOutTransformer) GenericTransformer(org.springframework.integration.transformer.GenericTransformer) ExpressionEvaluatingTransformer(org.springframework.integration.transformer.ExpressionEvaluatingTransformer) ClaimCheckInTransformer(org.springframework.integration.transformer.ClaimCheckInTransformer) MethodInvokingTransformer(org.springframework.integration.transformer.MethodInvokingTransformer)

Aggregations

LambdaMessageProcessor (org.springframework.integration.handler.LambdaMessageProcessor)1 ClaimCheckInTransformer (org.springframework.integration.transformer.ClaimCheckInTransformer)1 ClaimCheckOutTransformer (org.springframework.integration.transformer.ClaimCheckOutTransformer)1 ExpressionEvaluatingTransformer (org.springframework.integration.transformer.ExpressionEvaluatingTransformer)1 GenericTransformer (org.springframework.integration.transformer.GenericTransformer)1 MessageTransformingHandler (org.springframework.integration.transformer.MessageTransformingHandler)1 MethodInvokingTransformer (org.springframework.integration.transformer.MethodInvokingTransformer)1 Transformer (org.springframework.integration.transformer.Transformer)1