Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

切面如果想知道Advice的方法签名,开销有点大 #426

Open
XHao opened this issue May 17, 2023 · 3 comments
Open

切面如果想知道Advice的方法签名,开销有点大 #426

XHao opened this issue May 17, 2023 · 3 comments
Assignees

Comments

@XHao
Copy link

XHao commented May 17, 2023

构造Advice时,虽然用到了lazyGet,避免了一些开销;但如果用户在切面需要用到方法名做判断,则还是会进行初始化。
仅仅为了获得方法签名,还需要进行一次loadClass,这个开销有点大,高并发时会有锁竞争问题。

@oldmanpushcart
Copy link
Collaborator

收到,确实会有额外的开销。我考虑下如何修改。
不过高并发场景下,不推荐用AdviceListener,可否用EventListener来满足你的诉求?

@oldmanpushcart
Copy link
Collaborator

@XHao 我在Advice上新增了3个方法,你看是否能满足你当前需求

    /**
     * 获取触发调用事件的类名称
     *
     * @return 触发调用事件的类名称
     * @since {@code sandbox-api:1.4.1}
     */
    public String getJavaClassName() {
        return javaClassName;
    }

    /**
     * 获取触发调用事件的方法名称
     *
     * @return 触发调用事件的方法名称
     * @since {@code sandbox-api:1.4.1}
     */
    public String getJavaMethodName() {
        return javaMethodName;
    }

    /**
     * 获取触发调用事件的方法签名
     *
     * @return 触发调用事件的方法签名
     * @since {@code sandbox-api:1.4.1}
     */
    public String getJavaMethodDesc() {
        return javaMethodDesc;
    }

oldmanpushcart pushed a commit that referenced this issue Jun 16, 2023
@XHao
Copy link
Author

XHao commented Jun 17, 2023

@XHao 我在Advice上新增了3个方法,你看是否能满足你当前需求

    /**
     * 获取触发调用事件的类名称
     *
     * @return 触发调用事件的类名称
     * @since {@code sandbox-api:1.4.1}
     */
    public String getJavaClassName() {
        return javaClassName;
    }

    /**
     * 获取触发调用事件的方法名称
     *
     * @return 触发调用事件的方法名称
     * @since {@code sandbox-api:1.4.1}
     */
    public String getJavaMethodName() {
        return javaMethodName;
    }

    /**
     * 获取触发调用事件的方法签名
     *
     * @return 触发调用事件的方法签名
     * @since {@code sandbox-api:1.4.1}
     */
    public String getJavaMethodDesc() {
        return javaMethodDesc;
    }

可以的,我本地也是加了类似的API。感谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants