Search in sources :

Example 1 with Transformer

use of org.springframework.integration.annotation.Transformer in project spring-integration-samples by spring-projects.

the class DBoot method transform.

@Transformer(inputChannel = "foo")
@Bean
public MessageHandler transform() {
    MessageTransformingHandler transformingHandler = new MessageTransformingHandler(new MethodInvokingTransformer(helpers(), "duplicate"));
    transformingHandler.setOutputChannel(bar());
    return transformingHandler;
}
Also used : MessageTransformingHandler(org.springframework.integration.transformer.MessageTransformingHandler) MethodInvokingTransformer(org.springframework.integration.transformer.MethodInvokingTransformer) MethodInvokingTransformer(org.springframework.integration.transformer.MethodInvokingTransformer) Transformer(org.springframework.integration.annotation.Transformer) Bean(org.springframework.context.annotation.Bean)

Example 2 with Transformer

use of org.springframework.integration.annotation.Transformer in project spring-integration by spring-projects.

the class TransformerAnnotationPostProcessor method createHandler.

@Override
protected MessageHandler createHandler(Object bean, Method method, List<Annotation> annotations) {
    org.springframework.integration.transformer.Transformer transformer;
    if (AnnotatedElementUtils.isAnnotated(method, Bean.class.getName())) {
        Object target = this.resolveTargetBeanFromMethodWithBeanAnnotation(method);
        transformer = this.extractTypeIfPossible(target, org.springframework.integration.transformer.Transformer.class);
        if (transformer == null) {
            if (this.extractTypeIfPossible(target, AbstractReplyProducingMessageHandler.class) != null) {
                checkMessageHandlerAttributes(resolveTargetBeanName(method), annotations);
                return (MessageHandler) target;
            }
            transformer = new MethodInvokingTransformer(target);
        }
    } else {
        transformer = new MethodInvokingTransformer(bean, method);
    }
    MessageTransformingHandler handler = new MessageTransformingHandler(transformer);
    this.setOutputChannelIfPresent(annotations, handler);
    return handler;
}
Also used : MessageTransformingHandler(org.springframework.integration.transformer.MessageTransformingHandler) MethodInvokingTransformer(org.springframework.integration.transformer.MethodInvokingTransformer) Transformer(org.springframework.integration.annotation.Transformer) MessageHandler(org.springframework.messaging.MessageHandler) AbstractReplyProducingMessageHandler(org.springframework.integration.handler.AbstractReplyProducingMessageHandler) AbstractReplyProducingMessageHandler(org.springframework.integration.handler.AbstractReplyProducingMessageHandler) MethodInvokingTransformer(org.springframework.integration.transformer.MethodInvokingTransformer) Bean(org.springframework.context.annotation.Bean)

Example 3 with Transformer

use of org.springframework.integration.annotation.Transformer in project tutorials by eugenp.

the class TimeProcessorApplication method transform.

@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public Object transform(Long timestamp) {
    DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
    String date = dateFormat.format(timestamp);
    return date;
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) Transformer(org.springframework.integration.annotation.Transformer)

Aggregations

Transformer (org.springframework.integration.annotation.Transformer)3 Bean (org.springframework.context.annotation.Bean)2 MessageTransformingHandler (org.springframework.integration.transformer.MessageTransformingHandler)2 MethodInvokingTransformer (org.springframework.integration.transformer.MethodInvokingTransformer)2 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 AbstractReplyProducingMessageHandler (org.springframework.integration.handler.AbstractReplyProducingMessageHandler)1 MessageHandler (org.springframework.messaging.MessageHandler)1