Package net.engio.mbassy.listener
Interface IMessageFilter<M>
-
- All Known Implementing Classes:
ElFilter
,Filters.RejectSubtypes
,Filters.SubtypesOnly
public interface IMessageFilter<M>
Message filters can be used to control what messages are delivered to a specific message handler. Filters are attached to message handler using the @Handler annotation. If a message handler specifies filters, the filters accepts(...) method will be checked before the actual handler is invoked. The handler will be invoked only if each filter accepted the message. Example:@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
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
accepts(M message, SubscriptionContext context)
Check whether the message matches some criteria
-
-
-
Method Detail
-
accepts
boolean accepts(M message, SubscriptionContext context)
Check whether the message matches some criteria- Parameters:
message
- The message to be handled by the handlercontext
- The context object containing a description of the message handler and the bus environment- Returns:
- true: if the message matches the criteria and should be delivered to the handler false: otherwise
-
-