Java 在spring中使用条件连接点
在spring中如何使用条件连接点 在我的要求中,如果方法名称为insert,或者方法名称为update,或者方法名称为delete,并且该方法应该正好有三个参数,则必须应用切入点 这是我写的代码Java 在spring中使用条件连接点,java,spring,aop,pointcuts,aspect,Java,Spring,Aop,Pointcuts,Aspect,在spring中如何使用条件连接点 在我的要求中,如果方法名称为insert,或者方法名称为update,或者方法名称为delete,并且该方法应该正好有三个参数,则必须应用切入点 这是我写的代码 <aop:config> <aop:aspect ref="auditAOP"> <aop:pointcut id="insert" expression="execution(* .IbatisDAOSupportImpl.insert(*
<aop:config>
<aop:aspect ref="auditAOP">
<aop:pointcut id="insert" expression="execution(* .IbatisDAOSupportImpl.insert(*,*,*))" />
<aop:pointcut id="delete" expression="execution(* IbatisDAOSupportImpl.delete(*,*,*))" />
<aop:pointcut id="update" expression="execution(* IbatisDAOSupportImpl.update(*,*,*))" />
<aop:pointcut id="auditInsertUpdateOrDelete" expression="insert || delete || update"/>
<aop:after method="afterInsertUpdateOrDelete" pointcut-ref="auditInsertUpdateOrDelete"/>
</aop:aspect>
</aop:config>
下面的一行有问题;我得到一个错误,表示表达式格式不正确
<aop:pointcut id="auditInsertUpdateOrDelete" expression="insert || delete || update"/>
您需要一个复杂的切入点,它在一个表达式中包含所有逻辑。您试图引用表达式中的其他切入点,但这根本不起作用 您需要这样做:
<aop:config>
<aop:aspect ref="auditAOP">
<aop:pointcut id="auditInsertUpdateOrDelete" expression="within(*.IbatisDAOSupportImpl)
and (execution( * insert*(..)) or
execution( * delete*(..)) or
execution( * update*(..)))"/>
<aop:after method="afterInsertUpdateOrDelete" pointcut-ref="auditInsertUpdateOrDelete"/>
</aop:aspect>
</aop:config>