问题
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