Home >Backend Development >PHP Tutorial >Apache Mina study notes (4) - Filters

Apache Mina study notes (4) - Filters

黄舟
黄舟Original
2017-01-18 10:09:571045browse

IoFilter is another core part of MINA. It filters all I/O events and requests for IoService and IoHandler, similar to the servlet filter in the web.

In this tutorial, we will develop a IoFilter in practical examples, usually it is easy to implement, but you may need to know some internal details of MINA.

The following are some existing Filters:

Apache Mina study notes (4) - Filters

You can inherit IoAdapter instead of directly implementing IoFilter. Unless overridden, any received events will be passed through the following filter:

public class MyFilter extends IoFilterAdapter {  
    @Override  
    public void sessionOpened(NextFilter nextFilter, IoSession session) throws Exception {  
        // Some logic here...  
        nextFilter.sessionOpened(session);  
        // Some other logic here...  
    }  
}


Transforming a Write Request


Be Careful When Filtering sessionCreated Event


Watch out the Empty Buffers !

The above is the content of Apache Mina Study Notes (4) - Filters. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn