Java 类org.springframework.web.servlet.config.annotation.InterceptorRegistration 实例源码

项目:xm-commons    文件:XmWebMvcConfigurerAdapter.java   
/**
 * Registered interceptor to all request except passed urls.
 * @param registry helps with configuring a list of mapped interceptors.
 * @param interceptor the interceptor
 */
protected void registerTenantInterceptorWithIgnorePathPattern(
                InterceptorRegistry registry, HandlerInterceptor interceptor) {
    InterceptorRegistration tenantInterceptorRegistration = registry.addInterceptor(interceptor);
    tenantInterceptorRegistration.addPathPatterns("/**");

    List<String> tenantIgnorePathPatterns = getTenantIgnorePathPatterns();
    Objects.requireNonNull(tenantIgnorePathPatterns, "tenantIgnorePathPatterns can't be null");

    for (String pattern : tenantIgnorePathPatterns) {
        tenantInterceptorRegistration.excludePathPatterns(pattern);
    }

    LOGGER.info("Added handler interceptor '{}' to all urls, exclude {}", interceptor.getClass()
                    .getSimpleName(), tenantIgnorePathPatterns);
}
项目:service-hive    文件:DevCloudWebMvcConfigurer.java   
/**
 * 添加令牌处理拦截器,检查请求头是否带有效的令牌。
 */
@Override
public void addInterceptors(InterceptorRegistry registry) {
    InterceptorRegistration interceptor = registry.addInterceptor(tokenInterceptor);

    String pathPatterns = devcloudProperties.getPathPatterns();
    log.info("Interceptor path patterns: " + pathPatterns);

    if (pathPatterns == null || pathPatterns.isEmpty()) {
        return;
    }

    String[] paths = pathPatterns.split(",");
    if (paths == null || paths.length == 0) {
        return;
    }

    for (String path : paths) {
        interceptor.addPathPatterns(path);
    }
}
项目:onetwo    文件:BootMvcConfigurerAdapter.java   
@Override
    public void addInterceptors(InterceptorRegistry registry) {
        /*Optional.ofNullable(interceptorList).ifPresent(list->{
            list.stream().forEach(inter->registry.addInterceptor(inter));
        });*/
        if(LangUtils.isEmpty(interceptorList)){
            return ;
        }
        for(HandlerInterceptor inter : interceptorList){
            InterceptorRegistration reg = registry.addInterceptor(inter);
            if(inter instanceof WebInterceptorAdapter){
                WebInterceptorAdapter webinter = (WebInterceptorAdapter) inter;
                if(LangUtils.isEmpty(webinter.getPathPatterns())){
                    continue;
                }
                reg.addPathPatterns(webinter.getPathPatterns());
            }
        }
//      registry.addInterceptor(new BootFirstInterceptor());
    }
项目:spring4-understanding    文件:StandaloneMockMvcBuilder.java   
@Override
protected void addInterceptors(InterceptorRegistry registry) {
    for (MappedInterceptor interceptor : mappedInterceptors) {
        InterceptorRegistration registration = registry.addInterceptor(interceptor.getInterceptor());
        if (interceptor.getPathPatterns() != null) {
            registration.addPathPatterns(interceptor.getPathPatterns());
        }
    }
}
项目:onetwo    文件:AccessLogInterceptorConfigurerAdapter.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    InterceptorRegistration reg = registry.addInterceptor(loggerInterceptor);
    if(LangUtils.isEmpty(loggerInterceptor.getPathPatterns())){
        return ;
    }
    reg.addPathPatterns(loggerInterceptor.getPathPatterns());
}
项目:class-guard    文件:StandaloneMockMvcBuilder.java   
@Override
protected void addInterceptors(InterceptorRegistry registry) {
    for (MappedInterceptor interceptor : mappedInterceptors) {
        InterceptorRegistration registration = registry.addInterceptor(interceptor.getInterceptor());
        if (interceptor.getPathPatterns() != null) {
            registration.addPathPatterns(interceptor.getPathPatterns());
        }
    }
}
项目:Daily-Email-WebApp    文件:WebMvcContextConfiguration.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    @SuppressWarnings("unused")
    InterceptorRegistration registration = registry.addInterceptor(
            new SecurityHandlerInterceptor()).addPathPatterns("/account",
            "/account/*", "/reader", "/reader/*");

}
项目:filter    文件:FilterPreInterceptorConfigurer.java   
public void addInterceptors(InterceptorRegistry registry) {




        InterceptorRegistration filterResponseInterceptor = registry.addInterceptor(new FilterResponseInterceptor(filterPreResponseHandler));
        // 拦截配置
        filterResponseInterceptor.addPathPatterns("/**");

        try {
            filterInterceptor =  applicationContext.getBean(FilterInterceptor.class);
        }catch (Exception e){
        }

        logger.info("filterInterceptor->"+filterInterceptor);

        if(filterInterceptor!=null){
            filterInterceptor.addInterceptors(registry);
        }

    }
项目:SpringBootMagicEightBallProject    文件:ApplicationConfigurationTest.java   
@Before
public void setUp() throws Exception {
    applicationConfiguration = new ApplicationConfiguration(tenantInterceptorAdapter);
    when(registry.addInterceptor(tenantInterceptorAdapter)).thenReturn(new InterceptorRegistration(tenantInterceptorAdapter));
}