문제

Is it possible to call aspect on code, which is wrapped by another aspect action. For example I call service method which is in transaction. Managing of transaction is provided by own transaction aspect. And I'd like to call logging aspect in this service method

Is it possible to call it in Spring AOP?

도움이 되었습니까?

해결책

Yes, aspects as cascadable, which means you can put multiple aspects on one method.

This is when ordering of aspects come into play (eg. do you want to log before starting the transaction or after it?). This is what the spring docs say: section 6.2.4.7. Advice ordering

다른 팁

If you want to call an aspect you are showing that you don't know what an aspect is. Code must never be aware of aspects! Aspects may never be triggered manually!

Perhaps you should read this article about AOP to begin grasping the concept: Aspect-oriented programming

That said: with real AspectJ, aspects can advise each other. With Spring AOP I don't think there is a way to do that.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top