2011-11-29 61 views
0

我正在使用注解来指示需要将建议应用于该方法。在spring中使用批注切入点

我有一个接口,这两种方法称为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> 

这是给编译错误;你在配置中看到任何错误吗?

+0

“给出编译错误”你看到了什么错误? –

+0

java.lang.IllegalArgumentException:切入点结构不正确:在字符位置期待“名称模式”139 – user2434

回答

0

您应该使用“& &”而不是“和”来结合使用切点明示。

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

+0

我不认为这是问题所在。尝试了你的建议,但没有工作。 – user2434

0

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

within(IMaintenanceDAOSupport) && @annotation(AuditLogging)