public interface IMessageFilter<M>
@Listener
@Filters(Urlfilter.class)
public void someHandler(String message){...}
class Urlfilter implements IMessageFilter{
public boolean accepts(String message, SubscriptionContext context){
return message.startsWith("http");
}
}
bus.post("http://www.infoq.com"); // will be delivered
bus.post("www.stackoverflow.com"); // will not be delivered
NOTE: A message filter must provide a no-arg constructor!!!Modifier and Type | Method and Description |
---|---|
boolean |
accepts(M message,
SubscriptionContext context)
Check whether the message matches some criteria
|
boolean accepts(M message, SubscriptionContext context)
message
- The message to be handled by the handlercontext
- The context object containing a description of the message handler and the bus environmentCopyright © 2018. All rights reserved.