Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

5. Transformers > Using Annotations

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:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial