Made IMessageFilter generic

Added javadoc to IMessageFilter
This commit is contained in:
bennidi 2014-02-01 15:34:37 +01:00
parent 5d7591ccdf
commit 6792d18f3a
3 changed files with 32 additions and 12 deletions

View File

@ -8,7 +8,8 @@ The performance win of this design is illustrated in <a href="http://codeblock.e
The benchmarking code can be found <a href="https://github.com/bennidi/eventbus-performance" target="_blank">here</a>
Read this documentation to get an overview of MBassadors features. There is also some documentation in the Wiki - although admittedly
not enough to make a developer happy (work is in progress). Additionally, you can browse the [javadoc](http://bennidi.github.io/mbassador/)
not enough to make a developer happy (work is in progress).
Additionally, you can browse the [javadoc](http://bennidi.github.io/mbassador/)
The current version is 1.1.9 and it is available from the Maven Central Repository. See the release notes for more details.

View File

@ -212,7 +212,7 @@
<footer>mbassador, ${project.version}</footer>
<doctitle>mbassador, ${project.version}</doctitle>
<links>
<link>http://static.springsource.org/spring/docs/3.0.x/javadoc-api/</link>
<link></link>
</links>
</configuration>
</plugin>
@ -226,7 +226,7 @@
<content>${project.reporting.outputDirectory}/apidocs</content>
<skipDeletedFiles>true</skipDeletedFiles>
<pubScmUrl>scm:git:git@github.com:bennidi/mbassador.git</pubScmUrl>
<scmBranch>gh-pages</scmBranch> <!-- branch with static site -->
<scmBranch>gh-pages</scmBranch> <!-- branch with static site on github-->
</configuration>
</plugin>
</plugins>

View File

@ -1,21 +1,40 @@
package net.engio.mbassy.listener;
/**
* Message filters can be used to prevent certain messages to be delivered to a specific listener.
* If a filter is used the message will only be delivered if it passes the filter(s)
* <p/>
* NOTE: A message filter must provide either a no-arg constructor.
* Message filters can be used to control what messages are delivered to a specific message handler.
* Filters are attached to message handler using the @Listener 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:
*
* @Lister
* @Filters(Urlfilter.class)
* public void someHandler(String message){...}
*
* class Urlfilter implements IMessageFilter<String>{
* public boolean accepts(String message, MessageHandler metadata){
* 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!!!
*
* @author bennidi
* Date: 2/8/12
*/
public interface IMessageFilter {
public interface IMessageFilter<M> {
/**
* Evaluate the message to ensure that it matches the handler configuration
* Check the message for whatever criteria
*
* @param message the message to be delivered
* @return
* @param message the message to be handled by the handler
* @param metadata the metadata object which describes the message handler
* @return true: if the message matches the criteria and should be delivered to the handler
* false: otherwise
*/
boolean accepts(Object message, MessageHandler metadata);
boolean accepts(M message, MessageHandler metadata);
}