pro.shuangxi.devTool.servlet.ServletDevToolAutoConfig Maven / Gradle / Ivy
package pro.shuangxi.devTool.servlet;
import java.util.Arrays;
import javax.servlet.Filter;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import pro.shuangxi.devTool.DevToolProperties;
/**
* @author mengshx
**/
@Configuration
@ConditionalOnClass(javax.servlet.Filter.class)
public class ServletDevToolAutoConfig {
public ServletDevToolAutoConfig() {
System.out.println("ServletDevToolAutoConfig");
}
@Bean
@ConditionalOnProperty(name = "dev-tool.servlet.open-log", havingValue = "true",matchIfMissing = true)
public FilterRegistrationBean servletParamFilter() {
FilterRegistrationBean bean = new FilterRegistrationBean<>();
bean.setFilter(new ServletParamFilter());
bean.setOrder(Ordered.HIGHEST_PRECEDENCE+1);
bean.setUrlPatterns(Arrays.asList("/*"));
return bean;
}
@Bean
@ConditionalOnProperty(name = "dev-tool.servlet.is-save", havingValue = "true",matchIfMissing = true)
public FilterRegistrationBean servletSaveFilter(ServletDevToolProperties devToolProperties) {
FilterRegistrationBean bean = new FilterRegistrationBean<>();
bean.setFilter(new ServletSaveFilter(devToolProperties));
bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
bean.setUrlPatterns(Arrays.asList("/*"));
return bean;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy