|
@@ -0,0 +1,58 @@
|
|
|
+package com.persagy.apm.alarmservice.common.config;
|
|
|
+
|
|
|
+import com.persagy.apm.common.handler.PoemsContextFilter;
|
|
|
+import com.persagy.apm.common.handler.PoemsContextHandler;
|
|
|
+import com.persagy.apm.mybatis.handler.DynamicDataSourceHandler;
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.core.annotation.Order;
|
|
|
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
|
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
+
|
|
|
+import javax.servlet.Filter;
|
|
|
+
|
|
|
+/**
|
|
|
+ * web拦截器配置
|
|
|
+ *
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021/5/19 7:42 下午
|
|
|
+ */
|
|
|
+@Configuration
|
|
|
+@Order(1)
|
|
|
+public class PoemsWebConfigurer implements WebMvcConfigurer {
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public PoemsContextHandler poemsContextHandler() {
|
|
|
+ return new PoemsContextHandler();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public DynamicDataSourceHandler dynamicDataSourceHandler() {
|
|
|
+ return new DynamicDataSourceHandler();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public Filter poemsContextFilter() {
|
|
|
+ return new PoemsContextFilter();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addInterceptors(InterceptorRegistry registry) {
|
|
|
+ // 设置拦截的路径、不拦截的路径、优先级等等
|
|
|
+ registry.addInterceptor(poemsContextHandler()).order(10).addPathPatterns("/**");
|
|
|
+ registry.addInterceptor(dynamicDataSourceHandler()).order(1).addPathPatterns("/**");
|
|
|
+ }
|
|
|
+
|
|
|
+// @Bean
|
|
|
+// public FilterRegistrationBean contextFilterRegistrationBean() {
|
|
|
+// FilterRegistrationBean registrationBean = new FilterRegistrationBean();
|
|
|
+// registrationBean.setFilter(poemsContextFilter());
|
|
|
+// registrationBean.addUrlPatterns("/*");
|
|
|
+// registrationBean.setName("PoemsContextFilter");
|
|
|
+// registrationBean.setOrder(1);
|
|
|
+// return registrationBean;
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|