Samuel
Samuel

Reputation: 879

Spring AOP pointcut expression / including methods of parent class

I am using expresssions like the following in my Spring configuration file:

<aop:pointcut expression="within(my.app.dao.impl.*)" id="commonDaoOperation"/>
or
<aop:pointcut expression=" execution(public * my.app.dao.impl.*.*(..))" id="commonDaoOperation"/>

The classes I am trying to match (DAOs in that case) extend a common class which is in another package.

Are the pointcut expressions above also supposed to match the methods of the parent class of my classes ?

Or do I need to add expressly the parent class in the expression to have its methods matched:

|| within(my.app.dao.common.MyParentClass)

thanks,

Upvotes: 4

Views: 3865

Answers (1)

Samuel
Samuel

Reputation: 879

After more investigation, I can confirm that the parent class must be added to the pointcut expression (unless the parent methods are overriden in the children classes):

<aop:pointcut expression="within(my.app.dao.impl.*) || within(my.app.dao.common.MyParentClass)" id="commonDaoOperation"/>

Upvotes: 3

Related Questions