Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Principle and Application of ConfigFilterChainManager in nacos client

Shulou Source: shulou.com Published: 2022-06-02 08:57:03 10月03日 Update

This article mainly introduces "the principle and application of ConfigFilterChainManager in nacos client". In daily operation, I believe that many people have doubts about the principle and application of ConfigFilterChainManager in nacos client. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "the principle and application of ConfigFilterChainManager in nacos client". Next, please follow the editor to study!

Order

This paper mainly studies the ConfigFilterChainManager of nacos client.

IConfigFilterChain

Nacos-1.1.3/api/src/main/java/com/alibaba/nacos/api/config/filter/IConfigFilterChain.java

Public interface IConfigFilterChain {/ * * Filter aciton * * @ param request request * @ param response response * @ throws NacosException NacosException * / void doFilter (IConfigRequest request, IConfigResponse response) throws NacosException;}

The IConfigFilterChain interface defines the doFilter method

ConfigFilterChainManager

Nacos-1.1.3/client/src/main/java/com/alibaba/nacos/client/config/filter/impl/ConfigFilterChainManager.java

Public class ConfigFilterChainManager implements IConfigFilterChain {private List filters = Lists.newArrayList (); public synchronized ConfigFilterChainManager addFilter (IConfigFilter filter) {/ / insert int I = 0 in order of order size; while (I

< this.filters.size()) { IConfigFilter currentValue = this.filters.get(i); if (currentValue.getFilterName().equals(filter.getFilterName())) { break; } if (filter.getOrder() >

= currentValue.getOrder () & & I < this.filters.size () {else {this.filters.add (I, filter); break;}} if (I = = this.filters.size ()) {this.filters.add (I, filter);} return this } @ Override public void doFilter (IConfigRequest request, IConfigResponse response) throws NacosException {new VirtualFilterChain (this.filters) .doFilter (request, response);} /.}

ConfigFilterChainManager implements the IConfigFilterChain interface, and its doFilter method uses filters to create the VirtualFilterChain, and then executes its doFilter method; it provides the addFilter method, which can be added to the filters according to the order order of the filter

VirtualFilterChain

Nacos-1.1.3/client/src/main/java/com/alibaba/nacos/client/config/filter/impl/ConfigFilterChainManager.java

Public class ConfigFilterChainManager implements IConfigFilterChain {/ /. Private static class VirtualFilterChain implements IConfigFilterChain {private final List

Tags: Methods interfaces principles applications learning order parameters more processing help practical next three size summary attributes articles theory knowledge articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Shulou Tech Info NVidia MariaDB MySQL