0

我正在使用注释来指示需要将建议应用于该方法。

我在一个名为的接口中有两种方法IMaintenanceDAOSupport

@AuditLogging
void insert(M domainobject, IntResponse response, String statementName);

@AuditLogging
int delete(M domainobject, IntResponse response, String statementName);

我们如何为要应用的方面配置 xml?

目前我有

<aop:config>
  <aop:aspect  ref="auditAOP">
    <aop:pointcut id="im-insert"  
                  expression="within(IMaintenanceDAOSupport)and execution(@annotation(AuditLogging))"/>
    <aop:after method="afterInsertUpdateOrDelete" pointcut-ref="im-insert"/>
  </aop:aspect>
</aop:config>

它给出了编译错误;您在配置中看到任何错误吗?

4

2 回答 2

0

@annotation不需要 execution() 块。尝试:

within(IMaintenanceDAOSupport) && @annotation(AuditLogging)
于 2013-02-15T15:20:14.300 回答
0

您应该使用“&&”而不是“and”来组合切入点表达式。

切入点表达式可以使用 '&&'、'||' 组合 和 '!'。

于 2011-11-29T14:16:30.833 回答