rename ExpressFactory.newExpress to ExpressFactory.threadLocalExpress

pull/539/head
hengyunabc 6 years ago
parent 734e5b547e
commit 3442f3d95c

@ -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);
}

@ -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);
}

@ -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);

@ -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);
}
}

@ -162,7 +162,7 @@ public class TimeTunnelTable {
String watchExpress, boolean isNeedExpand, int expandLevel, int sizeLimit)
throws ExpressException {
for (Map.Entry<Integer, TimeFragment> 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)));
}

Loading…
Cancel
Save