🔖 V1.3.1. support zuul dynamic groovy filters

This commit is contained in:
冷冷 2018-11-15 15:33:22 +08:00
parent bdef2679d0
commit cf5328c30b
16 changed files with 94 additions and 37 deletions

View File

@ -22,7 +22,7 @@
<groupId>com.github.pig</groupId>
<artifactId>pig-auth</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<packaging>jar</packaging>
<name>pig-auth</name>
@ -31,14 +31,14 @@
<parent>
<groupId>com.github</groupId>
<artifactId>pig</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>
<dependencies>
<dependency>
<groupId>com.github.pig</groupId>
<artifactId>pig-common</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
<!--oauth2.0-->
<dependency>

View File

@ -22,7 +22,7 @@
<groupId>com.github.pig</groupId>
<artifactId>pig-common</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<packaging>jar</packaging>
<name>pig-common</name>
@ -31,7 +31,7 @@
<parent>
<groupId>com.github</groupId>
<artifactId>pig</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>
<dependencies>

View File

@ -22,7 +22,7 @@
<groupId>com.github.pig</groupId>
<artifactId>pig-config</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<packaging>jar</packaging>
<name>pig-config</name>
@ -31,7 +31,7 @@
<parent>
<groupId>com.github</groupId>
<artifactId>pig</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>
<dependencies>

View File

@ -22,7 +22,7 @@
<groupId>com.github.pig</groupId>
<artifactId>pig-eureka</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<packaging>jar</packaging>
<name>pig-eureka</name>
@ -31,7 +31,7 @@
<parent>
<groupId>com.github</groupId>
<artifactId>pig</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>
<dependencies>

View File

@ -22,7 +22,7 @@
<groupId>com.github.pig</groupId>
<artifactId>pig-gateway</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<packaging>jar</packaging>
<name>pig-gateway</name>
@ -31,14 +31,14 @@
<parent>
<groupId>com.github</groupId>
<artifactId>pig</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>
<dependencies>
<dependency>
<groupId>com.github.pig</groupId>
<artifactId>pig-common</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
<!--zuul网关-->
<dependency>

View File

@ -0,0 +1,57 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.github.pig.gateway.component.linster;
import com.netflix.zuul.FilterFileManager;
import com.netflix.zuul.FilterLoader;
import com.netflix.zuul.groovy.GroovyCompiler;
import com.netflix.zuul.groovy.GroovyFileFilter;
import com.netflix.zuul.monitoring.MonitoringHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
/**
* @author lengleng
* @date 2018/11/15
* <p>
* 动态filter 初始化配置
*/
@Slf4j
@Component
@ConditionalOnProperty("zuul.groovy.path")
public class GroovyLoadInitListener {
@Value("${zuul.groovy.path}")
private String groovyPath;
@EventListener(value = {EmbeddedServletContainerInitializedEvent.class})
public void init() {
MonitoringHelper.initMocks();
FilterLoader.getInstance().setCompiler(new GroovyCompiler());
FilterFileManager.setFilenameFilter(new GroovyFileFilter());
try {
FilterFileManager.init(10, groovyPath);
} catch (Exception e) {
log.error("初始化网关Groovy 文件失败 {}", e);
}
log.warn("初始化网关Groovy 文件成功");
}
}

View File

@ -22,7 +22,7 @@
<groupId>com.github.pig</groupId>
<artifactId>pig-daemon-service</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<packaging>jar</packaging>
<name>pig-daemon-service</name>
@ -31,7 +31,7 @@
<parent>
<groupId>com.github.pig</groupId>
<artifactId>pig-modules</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>
<properties>
@ -43,7 +43,7 @@
<dependency>
<groupId>com.github.pig</groupId>
<artifactId>pig-common</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>com.github.xjzrc.spring.boot</groupId>

View File

@ -22,7 +22,7 @@
<groupId>com.github.pig</groupId>
<artifactId>pig-mc-service</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<packaging>jar</packaging>
<name>pig-mc-service</name>
@ -31,14 +31,14 @@
<parent>
<groupId>com.github.pig</groupId>
<artifactId>pig-modules</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>
<dependencies>
<dependency>
<groupId>com.github.pig</groupId>
<artifactId>pig-common</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
<!--阿里大于-->
<dependency>

View File

@ -22,7 +22,7 @@
<groupId>com.github.pig</groupId>
<artifactId>pig-sso-client-demo</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<packaging>jar</packaging>
<name>pig-sso-client-demo</name>
@ -31,7 +31,7 @@
<parent>
<groupId>com.github.pig</groupId>
<artifactId>pig-modules</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>
<dependencies>

View File

@ -22,7 +22,7 @@
<groupId>com.github.pig</groupId>
<artifactId>pig-upms-service</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<packaging>jar</packaging>
<name>pig-upms-service</name>
@ -31,14 +31,14 @@
<parent>
<groupId>com.github.pig</groupId>
<artifactId>pig-modules</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>
<dependencies>
<dependency>
<groupId>com.github.pig</groupId>
<artifactId>pig-common</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
<!--MySQL-->
<dependency>

View File

@ -20,13 +20,13 @@
<parent>
<artifactId>pig</artifactId>
<groupId>com.github</groupId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.pig</groupId>
<artifactId>pig-modules</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<packaging>pom</packaging>
<name>pig-modules</name>

View File

@ -22,7 +22,7 @@
<groupId>com.github.pig</groupId>
<artifactId>pig-monitor</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<packaging>jar</packaging>
<name>pig-monitor</name>
@ -31,14 +31,14 @@
<parent>
<groupId>com.github.pig</groupId>
<artifactId>pig-visual</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>
<dependencies>
<dependency>
<groupId>com.github.pig</groupId>
<artifactId>pig-common</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
<!--admin-->
<dependency>

View File

@ -23,7 +23,7 @@
<groupId>com.github.pig</groupId>
<artifactId>pig-zipkin-db</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<packaging>jar</packaging>
<name>pig-zipkin-db</name>
@ -32,13 +32,13 @@
<parent>
<groupId>com.github.pig</groupId>
<artifactId>pig-visual</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>
<dependencies>
<dependency>
<groupId>com.github.pig</groupId>
<artifactId>pig-common</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>

View File

@ -22,7 +22,7 @@
<groupId>com.github.pig</groupId>
<artifactId>pig-zipkin-elk</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<packaging>jar</packaging>
<name>pig-zipkin-elk</name>
@ -31,14 +31,14 @@
<parent>
<groupId>com.github.pig</groupId>
<artifactId>pig-visual</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>
<dependencies>
<dependency>
<groupId>com.github.pig</groupId>
<artifactId>pig-common</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<exclusions>
<exclusion>
<groupId>io.github.openfeign</groupId>

View File

@ -21,7 +21,7 @@
<groupId>com.github.pig</groupId>
<artifactId>pig-visual</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<packaging>pom</packaging>
<name>pig-visual</name>
@ -30,7 +30,7 @@
<parent>
<artifactId>pig</artifactId>
<groupId>com.github</groupId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>
<modules>

View File

@ -23,7 +23,7 @@
<groupId>com.github</groupId>
<artifactId>pig</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<packaging>pom</packaging>