Pointcut is not being applied to Abstract method

一曲冷凌霜 提交于 2020-01-23 09:13:45

问题


I am trying to apply pointcut to an implemented method in childclass but the AspectMethod is not being invoked around this pointcut. Following is my configuration and code:

public abstract class ParentClass {
  protected abstract void buildResponse(QueryResponse qryResp,ContentSearchServiceResponseImpl cssResp);
}


public class ChildClass extends ParentClass {
@override    
public void buildResponse(QueryResponse qryResp,ContentSearchServiceResponseImpl  ssResp){
//doSomething
}

Pointcuts:

<aop:pointcut id="pointcutId"
            expression="execution(public * ParentClass.buildResponse(..))" />

OR

<aop:pointcut id="pointcutId"
            expression="execution(protected * ParentClass.buildResponse(..))" />

OR

<aop:pointcut id="pointcutId"
            expression="execution(public * ParentClass+.buildResponse(..))" />

For any of the configurations of pointcuts above Aspect is not being created.I have tried almost everything.If anyone has some idea on this...I can not use Child Class's name directly because in my case multiple child classes are implementing this abstract method


回答1:


Try

execution(public * buildResponse(..)) && within(ParentClass+)

or

execution(public * buildResponse(..)) && target(ParentClass+)

Also keep in mind that internal calls inside a class (one method calling another method in the same class) are not subject to any advices if you are using the "standard" spring proxy-based AOP.



来源:https://stackoverflow.com/questions/13172673/pointcut-is-not-being-applied-to-abstract-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!