Commit 390e99e1fac9c34a935d0c1cffa669d586028bc3
1 parent
d1acd639e4
Exists in
master
and in
1 other branch
增加基本数据类型的过滤
Showing 1 changed file with 14 additions and 0 deletions
platform-common/src/main/java/com/lyms/platform/common/perf/DalMethodInterceptor.java
View file @
390e99e
... | ... | @@ -6,6 +6,9 @@ |
6 | 6 | import org.slf4j.Logger; |
7 | 7 | import org.slf4j.LoggerFactory; |
8 | 8 | |
9 | +import java.util.HashMap; | |
10 | +import java.util.Map; | |
11 | + | |
9 | 12 | /** |
10 | 13 | * |
11 | 14 | * dao层的性能拦截类,用于统计dal层操作的耗时 |
... | ... | @@ -16,6 +19,13 @@ |
16 | 19 | public class DalMethodInterceptor implements MethodInterceptor { |
17 | 20 | |
18 | 21 | private Logger logger = LoggerFactory.getLogger("DAL-MONITOR"); |
22 | + | |
23 | + private static Map<String,Object> typeMap = new HashMap<>(); | |
24 | + { | |
25 | + typeMap.put("int",0); | |
26 | + typeMap.put("double",0.00); | |
27 | + typeMap.put("long",0); | |
28 | + } | |
19 | 29 | |
20 | 30 | /** |
21 | 31 | * 阀值超过该阀值就是warn 级别的日志 |
22 | 32 | |
... | ... | @@ -30,7 +40,11 @@ |
30 | 40 | public Object invoke(MethodInvocation arg0) throws Throwable { |
31 | 41 | long start = System.currentTimeMillis(); |
32 | 42 | try { |
43 | + | |
33 | 44 | Object object = arg0.proceed(); |
45 | + if(null==object && arg0.getMethod().getReturnType().isPrimitive()){ | |
46 | + return typeMap.get(arg0.getMethod().getReturnType()); | |
47 | + } | |
34 | 48 | return object; |
35 | 49 | } catch (Exception e) { |
36 | 50 | ExceptionUtils.catchException(e,e.getMessage()); |