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

com.lx.AutoConfiguration Maven / Gradle / Ivy

package com.lx;


import com.lx.boot.web.AuthUtil;
import com.lx.boot.web.SecurityFilter;
import com.lx.constant.DefaultBaseConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

@Configuration
@ComponentScan(basePackages = { "com.lx.boot"})
public class AutoConfiguration {

    @Bean
    @ConditionalOnProperty(name = DefaultBaseConstant.SECURITY_FILTER_ENABLE, havingValue = "true", matchIfMissing = true)
    public FilterRegistrationBean pubSecurityFilter(@Autowired AuthUtil authUtil) {
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(new SecurityFilter(authUtil));
        //配置过滤规则
        filterRegistrationBean.addUrlPatterns("*");
        //设置过滤器名称
        filterRegistrationBean.setName("securityFilter");
        //执行次序,值越小,则越早执行
        filterRegistrationBean.setOrder(2);

        return filterRegistrationBean;
    }

    @Bean("executor")
    public Executor executor(){
        ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
        taskExecutor.setCorePoolSize(10);
        taskExecutor.setMaxPoolSize(50);
        taskExecutor.setQueueCapacity(200);
        taskExecutor.setKeepAliveSeconds(60);
        taskExecutor.setThreadNamePrefix("taskExecutor--");
        taskExecutor.setWaitForTasksToCompleteOnShutdown(true);
        taskExecutor.setAwaitTerminationSeconds(60);
        return taskExecutor;
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy