MethodInterceptResult.java 1.3 KB
Newer Older
1
package org.skywalking.apm.agent.core.plugin.interceptor.enhance;
2

3
/**
4
 * This is a method return value manipulator. When a interceptor's method, such as {@link
5
 * InstanceMethodsAroundInterceptor#beforeMethod(org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext, InstanceMethodInvokeContext,
6 7 8
 * MethodInterceptResult)}, has this as a method argument, the interceptor can manipulate the method's return value. <p>
 * The new value set to this object, by {@link MethodInterceptResult#defineReturnValue(Object)}, will override the
 * origin return value.
9 10
 *
 * @author wusheng
11
 */
12
public class MethodInterceptResult {
13 14
    private boolean isContinue = true;

15
    private Object ret = null;
16 17 18 19 20 21 22 23

    /**
     * define the new return value.
     *
     * @param ret new return value.
     */
    public void defineReturnValue(Object ret) {
        this.isContinue = false;
24
        this.ret = ret;
25 26 27
    }

    /**
28 29
     * @return true, will trigger method interceptor({@link ClassInstanceMethodsInterceptor} and {@link
     * ClassStaticMethodsInterceptor}) to invoke the origin method. Otherwise, not.
30 31 32 33
     */
    public boolean isContinue() {
        return isContinue;
    }
34

35 36 37 38
    /**
     * @return the new return value.
     */
    Object _ret() {
39
        return ret;
40
    }
41
}