Commit 8ef7b71dfa2804813a528342f42b4190f2f45725

Authored by miaoguoxin
1 parent c8837dd3

增加properties参数校验

gateway-core/src/main/java/com/diligrp/xtrade/core/config/property/ApiMetricsProperties.java
@@ -51,4 +51,13 @@ public class ApiMetricsProperties { @@ -51,4 +51,13 @@ public class ApiMetricsProperties {
51 public void setTimeUnit(TimeUnit timeUnit) { 51 public void setTimeUnit(TimeUnit timeUnit) {
52 this.timeUnit = timeUnit; 52 this.timeUnit = timeUnit;
53 } 53 }
  54 +
  55 + @Override
  56 + public String toString() {
  57 + return "ApiMetricsProperties{" +
  58 + "collectNum=" + collectNum +
  59 + ", timeout=" + timeout +
  60 + ", timeUnit=" + timeUnit +
  61 + '}';
  62 + }
54 } 63 }
gateway-core/src/main/java/com/diligrp/xtrade/core/config/property/DispatchProperties.java
@@ -2,6 +2,9 @@ package com.diligrp.xtrade.core.config.property; @@ -2,6 +2,9 @@ package com.diligrp.xtrade.core.config.property;
2 2
3 import org.springframework.boot.context.properties.ConfigurationProperties; 3 import org.springframework.boot.context.properties.ConfigurationProperties;
4 import org.springframework.stereotype.Component; 4 import org.springframework.stereotype.Component;
  5 +import org.springframework.validation.annotation.Validated;
  6 +
  7 +import javax.validation.constraints.NotNull;
5 8
6 /** 9 /**
7 * @Auther: miaoguoxin 10 * @Auther: miaoguoxin
@@ -9,8 +12,10 @@ import org.springframework.stereotype.Component; @@ -9,8 +12,10 @@ import org.springframework.stereotype.Component;
9 */ 12 */
10 @Component 13 @Component
11 @ConfigurationProperties(prefix = "xtrade") 14 @ConfigurationProperties(prefix = "xtrade")
  15 +@Validated
12 public class DispatchProperties { 16 public class DispatchProperties {
13 /** 扫描包路径 */ 17 /** 扫描包路径 */
  18 + @NotNull
14 private String[] aggregationScanPackages; 19 private String[] aggregationScanPackages;
15 20
16 21
gateway-core/src/main/java/com/diligrp/xtrade/core/filters/factory/package-info.java 0 → 100644
  1 +/**
  2 + * @Auther: miaoguoxin
  3 + * @Date: 2018/12/8 12:47
  4 + * @Description: 类名一定要为filterName + GatewayFilterFactory,如定义为JwtCheckGatewayFilterFactory的话,它的filterName就是JwtCheck
  5 + */
  6 +package com.diligrp.xtrade.core.filters.factory;
gateway-core/src/main/java/com/diligrp/xtrade/core/support/ApiMetricsCollector.java
@@ -16,6 +16,7 @@ import java.util.Timer; @@ -16,6 +16,7 @@ import java.util.Timer;
16 import java.util.TimerTask; 16 import java.util.TimerTask;
17 import java.util.concurrent.ArrayBlockingQueue; 17 import java.util.concurrent.ArrayBlockingQueue;
18 import java.util.concurrent.BlockingQueue; 18 import java.util.concurrent.BlockingQueue;
  19 +import java.util.concurrent.Executors;
19 import java.util.concurrent.TimeUnit; 20 import java.util.concurrent.TimeUnit;
20 import java.util.concurrent.atomic.AtomicBoolean; 21 import java.util.concurrent.atomic.AtomicBoolean;
21 22
gateway-core/src/main/java/com/diligrp/xtrade/core/support/dispatch/MappingRegister.java
@@ -17,6 +17,7 @@ import org.springframework.boot.SpringApplication; @@ -17,6 +17,7 @@ import org.springframework.boot.SpringApplication;
17 import org.springframework.context.ApplicationContext; 17 import org.springframework.context.ApplicationContext;
18 import org.springframework.context.ApplicationListener; 18 import org.springframework.context.ApplicationListener;
19 import org.springframework.context.event.ContextRefreshedEvent; 19 import org.springframework.context.event.ContextRefreshedEvent;
  20 +import org.springframework.lang.NonNullApi;
20 import org.springframework.stereotype.Component; 21 import org.springframework.stereotype.Component;
21 import org.springframework.validation.annotation.Validated; 22 import org.springframework.validation.annotation.Validated;
22 23