O'Reilly logo

Just Spring Integration by Madhusudhan Konda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Annotations

You can use Framework’s @Transformer annotation to refer to the transformer bean from your config file. The component-scan allows the container to scan for annotated beans in the transformers package, In this case, the AnnotatedTradeMapTransformer class will be instantiated:

@Component
public class AnnotatedTradeMapTransformer {
  @Transformer
  public Map<String, String> transform(Trade t) {
    Map<String,String> tradeNameValuesMap = 
      new HashMap<String,String>();
    ....
    return tradeNameValuesMap;
  }
}

The annotated transform method is invoked when a message arrives in the in-channel. The configuration is similar to the one we have already seen, except the component-scan tag is added. This scans for the beans decorated with @Component and creates instances of them once found in the application context container:

<context:component-scan 
  base-package="com.madhusudhan.jsi.flow.transformer" />

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required