Frage

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?

War es hilfreich?

Lösung

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

Andere Tipps

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top