The responsibility chain----the Java design pattern Filter

Source: Internet
Author: User

Filter: filtration ; filter;

At present, the main application of Java is the Web project, so it will face a variety of data access and requests, so filtering is necessary, like a human lungs, need to be beneficial to the human body left in the body, unfavorable exclusion in vitro.

Mr. Ma's lecture on Javawebfilter is a classic, at least in my opinion, and it's easy for students to understand his principles.

Off topic: java, so beautiful!!!

Here are some extensibility aspects to summarize performance: from A-e step by step.

Premise: The content of filtering msg= "***********************";

The first: A, replacing the specific contents of the MSG directly in the main method.

The second type: B, filtering by uniformly implementing the filter interface to encapsulate the Xxxfilter class.

The third type: C, the Xxxfilter through the filter interface into the list of filter, the implementation of one time to add multiple reuse.

The fourth type: D, create Filterchain to combine the filter's list, filter, etc. freely.

The fifth type: E, through Javawebfilter dofilter (request,response,chain) to realize how the msg from the outside filter to inside, and then filtered from inside to outside.

OK, that's the general course, and the Code section can be found online.

Washing clothes, sleeping ....

The responsibility chain----the Java design pattern Filter

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.