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

Is it possible to add an 'around' interface to the Interceptor top-level interface. Similar to the @Around annotation in AOP #1489

Closed
Ruanjq98 opened this issue Apr 8, 2024 · 4 comments
Labels
kind/feature Issue for new feature

Comments

@Ruanjq98
Copy link

Ruanjq98 commented Apr 8, 2024

What would you like to be added?

Is it possible to add an around interface to the Interceptor top-level interface. Similar to the @around annotation in AOP.

Similar to the following:

   @Around("point()")
    public Object test(ProceedingJoinPoint joinPoint) throws Throwable {
         // pre-enhancement
         ............
         
         //Execute pointcut
         Object result = joinPoint.proceed(args);
         // post-enhancement
        .....................
        return result;

Why is this needed?

Because some functions may need to run before and after the entry point. Although you can use Context to pass parameters between contexts, it is cumbersome to use and writing code is not smooth enough.

@Ruanjq98 Ruanjq98 added the kind/feature Issue for new feature label Apr 8, 2024
@lilai23
Copy link
Collaborator

lilai23 commented Apr 9, 2024

In our design, we use @Advice.OnMethodEnter and @Advice.OnMethodExit to achieve the @around effect, which is done by the interface encapsulated by bytebuddy. Another point is that it is common to enhance the same method multiple times or mount multiple Sermants. We also need to manage the execution order of the before method and after method that are enhanced multiple times. So this issue is not suitable for current situation.

@kkf1 kkf1 changed the title 是否可以在 Interceptor 顶层接口中添加一个 around 接口。类似AOP中的@Around 注解 Is it possible to add an 'around' interface to the Interceptor top-level interface. Similar to the @Around annotation in AOP Apr 13, 2024
@janyao520
Copy link

Did you solve it ???

@Ruanjq98
Copy link
Author

Did you solve it ???

没有解决,看了下代码不太好改动。目前是用serment提供的上下文接口进行的参数传递。
在before里面
context.setLocalFieldValue("xxx", xxx);
在after
context.getLocalFieldValue("xxx");

@hanbingleixue
Copy link
Collaborator

Other solutions have been provided. No other questions are replied. Therefore, this issue is closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Issue for new feature
Projects
None yet
Development

No branches or pull requests

4 participants