Get AOP proxy from the object itself

后端 未结 3 518
伪装坚强ぢ
伪装坚强ぢ 2020-11-27 15:13

Is possible to get the proxy of a given object in Spring? I need to call a function of a subclass. But, obviously, when I do a direct call, the aspects aren\'t applied. Here

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-27 15:40

    This hack is extremely awkward, please consider refactoring your code or using AspectJ weaving. You may feel warned, here is the solution

    AopContext.currentProxy()
    

    JavaDoc. I blogged about it here and here.

提交回复
热议问题