From 3442f3d95c248fae169a8080942a78b624cb4e0e Mon Sep 17 00:00:00 2001 From: hengyunabc Date: Thu, 18 Oct 2018 15:32:19 +0800 Subject: [PATCH] rename ExpressFactory.newExpress to ExpressFactory.threadLocalExpress --- .../core/advisor/ReflectAdviceListenerAdapter.java | 4 ++-- .../arthas/core/command/express/ExpressFactory.java | 12 ++++++------ .../core/command/klass100/GetStaticCommand.java | 2 +- .../core/command/monitor200/TimeTunnelCommand.java | 4 ++-- .../core/command/monitor200/TimeTunnelTable.java | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/com/taobao/arthas/core/advisor/ReflectAdviceListenerAdapter.java b/core/src/main/java/com/taobao/arthas/core/advisor/ReflectAdviceListenerAdapter.java index cde1d75f..f49a80a7 100644 --- a/core/src/main/java/com/taobao/arthas/core/advisor/ReflectAdviceListenerAdapter.java +++ b/core/src/main/java/com/taobao/arthas/core/advisor/ReflectAdviceListenerAdapter.java @@ -202,11 +202,11 @@ public abstract class ReflectAdviceListenerAdapter implements AdviceListener { */ protected boolean isConditionMet(String conditionExpress, Advice advice, double cost) throws ExpressException { return StringUtils.isEmpty(conditionExpress) || - ExpressFactory.newExpress(advice).bind(Constants.COST_VARIABLE, cost).is(conditionExpress); + ExpressFactory.threadLocalExpress(advice).bind(Constants.COST_VARIABLE, cost).is(conditionExpress); } protected Object getExpressionResult(String express, Advice advice, double cost) throws ExpressException { - return ExpressFactory.newExpress(advice) + return ExpressFactory.threadLocalExpress(advice) .bind(Constants.COST_VARIABLE, cost).get(express); } diff --git a/core/src/main/java/com/taobao/arthas/core/command/express/ExpressFactory.java b/core/src/main/java/com/taobao/arthas/core/command/express/ExpressFactory.java index 958b5e57..34eaab0f 100644 --- a/core/src/main/java/com/taobao/arthas/core/command/express/ExpressFactory.java +++ b/core/src/main/java/com/taobao/arthas/core/command/express/ExpressFactory.java @@ -1,8 +1,9 @@ package com.taobao.arthas.core.command.express; /** - * 表达式工厂类 + * ExpressFactory * @author ralf0131 2017-01-04 14:40. + * @author hengyunabc 2018-10-08 */ public class ExpressFactory { @@ -14,12 +15,11 @@ public class ExpressFactory { }; /** - * 构造表达式执行类 - * - * @param object 执行对象 - * @return 返回表达式实现 + * get ThreadLocal Express Object + * @param object + * @return */ - public static Express newExpress(Object object) { + public static Express threadLocalExpress(Object object) { return expressRef.get().reset().bind(object); } diff --git a/core/src/main/java/com/taobao/arthas/core/command/klass100/GetStaticCommand.java b/core/src/main/java/com/taobao/arthas/core/command/klass100/GetStaticCommand.java index 5f495227..812e7907 100644 --- a/core/src/main/java/com/taobao/arthas/core/command/klass100/GetStaticCommand.java +++ b/core/src/main/java/com/taobao/arthas/core/command/klass100/GetStaticCommand.java @@ -128,7 +128,7 @@ public class GetStaticCommand extends AnnotatedCommand { Object value = field.get(null); if (!StringUtils.isEmpty(express)) { - value = ExpressFactory.newExpress(value).get(express); + value = ExpressFactory.threadLocalExpress(value).get(express); } String result = StringUtils.objectToString(expand >= 0 ? new ObjectView(value, expand).draw() : value); diff --git a/core/src/main/java/com/taobao/arthas/core/command/monitor200/TimeTunnelCommand.java b/core/src/main/java/com/taobao/arthas/core/command/monitor200/TimeTunnelCommand.java index f10fc026..9123aea8 100644 --- a/core/src/main/java/com/taobao/arthas/core/command/monitor200/TimeTunnelCommand.java +++ b/core/src/main/java/com/taobao/arthas/core/command/monitor200/TimeTunnelCommand.java @@ -332,7 +332,7 @@ public class TimeTunnelCommand extends EnhancerCommand { } Advice advice = tf.getAdvice(); - Object value = ExpressFactory.newExpress(advice).get(watchExpress); + Object value = ExpressFactory.threadLocalExpress(advice).get(watchExpress); if (isNeedExpand()) { process.write(new ObjectView(value, expand, sizeLimit).draw()).write("\n"); } else { @@ -361,7 +361,7 @@ public class TimeTunnelCommand extends EnhancerCommand { Advice advice = tf.getAdvice(); // 搜索出匹配的时间片段 - if ((ExpressFactory.newExpress(advice)).is(searchExpress)) { + if ((ExpressFactory.threadLocalExpress(advice)).is(searchExpress)) { matchingTimeSegmentMap.put(index, tf); } } diff --git a/core/src/main/java/com/taobao/arthas/core/command/monitor200/TimeTunnelTable.java b/core/src/main/java/com/taobao/arthas/core/command/monitor200/TimeTunnelTable.java index 677f6aa9..5ad73e96 100644 --- a/core/src/main/java/com/taobao/arthas/core/command/monitor200/TimeTunnelTable.java +++ b/core/src/main/java/com/taobao/arthas/core/command/monitor200/TimeTunnelTable.java @@ -162,7 +162,7 @@ public class TimeTunnelTable { String watchExpress, boolean isNeedExpand, int expandLevel, int sizeLimit) throws ExpressException { for (Map.Entry entry : matchingTimeSegmentMap.entrySet()) { - Object value = ExpressFactory.newExpress(entry.getValue().getAdvice()).get(watchExpress); + Object value = ExpressFactory.threadLocalExpress(entry.getValue().getAdvice()).get(watchExpress); table.row("" + entry.getKey(), "" + (isNeedExpand ? new ObjectView(value, expandLevel, sizeLimit).draw() : StringUtils.objectToString(value))); }