Please consider the following: we have a Spring bean B which is advised with a number of aspects: A1, A2. We have some other Spring beans: X, Y, Z — and B is injected to all of them. The question is: how can we make aspects of B to be applied or not depending on bean from which B is invoked (X, Y, Z)? In my particular task I need to make one aspect (for example, A2) to be bypassed when B is invoked from particular bean (for example, Z), while in other invocations all aspects must be applied.
Please consider the following: we have a Spring bean B which is advised with
Share
The decision was quite simple.
Zcontains the reference toB, and this reference is of typeAdvised. This interface allows accessing different properties of advised object, including its aspects. This allows creating new advised object which includes only needed aspects ofB. The code snippet follows.All types and identifiers are given in respect to example from the original question.
Bis ab interface,bis a reference. Code snippet is fromZbean.Now
newBreference is ready for use.