Initialization Order Spring Aspects / Advisors

Is there a way to customize how the various Aspects (or their respective advisers, to be more precise) are initialized in Spring? Note that I'm not talking about ordering, but initializing aspects.

The background to this issue is a precedent with a Aspect Adependent on Service Xwhich should be reported Aspect B. However, since it Aspect Afirst initializes and forces the creation Service X, it Aspect Bdoes not apply to the service.

How to change the initialization order without making it Service Xdependent on Aspect B(this would be a workaround as it provides the required order, but the service should never deal with its aspects ...)?

If you need a general picture of my problem, here is another question that made me ask about it.

+1
source share
1 answer

An aspect is usually only an annotated class @Aspect, which is also annotated with @Componentor has a corresponding definition <bean>. In other words, it is just a bean.

The only ways to determine the order that beans should be initialized is by property depends-on(or @DependsOn) or by playing with the order in which you import the contexts.

0
source

Source: https://habr.com/ru/post/1524948/


All Articles