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

Filters > Using Annotations

Using Annotations

Another way—simple and straightforward—of creating Filters is via Annotations. Here’s an annotated version of NewTradeFilter:

@Component
public class AnnotatedNewTradeFilter {

  @Filter
  public boolean isTradeCancelled(Message<?> message) {
    Trade t = (Trade)message.getPayload();
    return (t.getStatus().equalsIgnoreCase("cancel"));
  }

}

The framework uses the @Filter annotation to annotate the isTradeCancelled method shown above. The following snippet shows how the filter is configured:

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

<int:filter input-channel="in-channel"
  output-channel="stdout" 
  ref="annotatedNewTradeFilter" >
</int:filter>

The component-scan lets the container scan for annotated beans in the filter package, in this case, the AnnotatedNewTradeFilter class. The annotated method isTradeCancelled is invoked whenever an expected message arrives in the in-channel.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

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

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint