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> 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 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. 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> <footer>mbassador, ${project.version}</footer>
<doctitle>mbassador, ${project.version}</doctitle> <doctitle>mbassador, ${project.version}</doctitle>
<links> <links>
<link>http://static.springsource.org/spring/docs/3.0.x/javadoc-api/</link> <link></link>
</links> </links>
</configuration> </configuration>
</plugin> </plugin>
@ -226,7 +226,7 @@
<content>${project.reporting.outputDirectory}/apidocs</content> <content>${project.reporting.outputDirectory}/apidocs</content>
<skipDeletedFiles>true</skipDeletedFiles> <skipDeletedFiles>true</skipDeletedFiles>
<pubScmUrl>scm:git:git@github.com:bennidi/mbassador.git</pubScmUrl> <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> </configuration>
</plugin> </plugin>
</plugins> </plugins>

View File

@ -1,21 +1,40 @@
package net.engio.mbassy.listener; package net.engio.mbassy.listener;
/** /**
* Message filters can be used to prevent certain messages to be delivered to a specific listener. * Message filters can be used to control what messages are delivered to a specific message handler.
* If a filter is used the message will only be delivered if it passes the filter(s) * Filters are attached to message handler using the @Listener annotation.
* <p/> * If a message handler specifies filters, the filters accepts(...) method will be checked before the actual handler is invoked.
* NOTE: A message filter must provide either a no-arg constructor. * 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 * @author bennidi
* Date: 2/8/12 * 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 * @param message the message to be handled by the handler
* @return * @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);
} }