bennidi/mbassador — pull request #70 by Rossi1337 (2014-05-20 16:04:05+00:00)
Title: Support Message filtering per Expression Language

Hi,
I just experimented with mbassador and it looks really great. We might use it for a web framework to send UI related messages. In this context I found the existing filters and the routing by Event class hirarchy a little bit limited. For example if we integrate into a button component that it will send an message to the event bus "on click" it is hard to write a handler that will not get all button clicks but only the one of a specific button.

So I came to the idea of routing events based on event attributes like a action command, a message ID or something else. So I added support to define filters via Expression Language.

Example:
@Handler(condition = "msg.action == 'TEST' ")
public void handleTypeMessage(TestEvent msg) {
message.result = "handleTypeMessage";
}

This works great so I wanted to feed this back to your project. Of course this would be also implemented with a filter and a separate annotation but with this directly in the framework it is very compact and easy to use.
This will introduce a dependency on the Expression Language API at compile time but I took care to make this an optional feature with only optional runtime dependencies.
I added some unit tests that as examples.

Thanks for your greate project,
- Bernd Rosstauscher

P.S. I'm new to github and git and maven so please excuse if something is not as it should be.