All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.arextest.web.api.service.interceptor.InterceptorConfiguration Maven / Gradle / Ivy

The newest version!
package com.arextest.web.api.service.interceptor;

import com.arextest.common.interceptor.AbstractInterceptorHandler;
import java.util.Comparator;
import java.util.List;
import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

public class InterceptorConfiguration implements WebMvcConfigurer {

  @Resource
  List interceptors;


  @Override
  public void addInterceptors(InterceptorRegistry registry) {
    if (CollectionUtils.isEmpty(interceptors)) {
      return;
    }
    interceptors.sort(Comparator.comparing(AbstractInterceptorHandler::getOrder));
    interceptors.forEach(interceptor -> {
      registry.addInterceptor(interceptor)
          .addPathPatterns(interceptor.getPathPatterns())
          .excludePathPatterns(interceptor.getExcludePathPatterns());
    });
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy