Apache Mina study notes (4) - Filters

黄舟
Release: 2023-03-04 22:22:02
Original
1024 people have browsed it

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...  
    }  
}
Copy after login


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)!


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!