Answer the question
In order to leave comments, you need to log in
Is there a cleaner alternative to Spring AOP?
Hello.
In Spring, you can say newbie.
You need to do a simple thing: there are a number of methods in different components.
I want to write an annotation that would transparently change the behavior of the method to this:
- would call the contents of the method
- if the exception - would try to call again, and so on several attempts
- if the specified number of attempts failed - call the last exception
- if the call was successful - return the result
I have a lot of similar methods in the code.
As I understand it, conceptually it seems to be suitable for Spring AOP (I have not dealt with it yet).
The configuration at first glance is complicated, but you can figure it out.
The most confusing thing is that in the aspect you need to specify attachment points of the type
@Pointcut("execution(public * com.example.demoAspects.MyService.*(..))")
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question