【发布时间】:2012-07-30 17:56:27
【问题描述】:
我正在尝试定义一个切入点表达式以匹配包含使用特定注释注释的参数的方法,而不管参数在什么位置。在我的情况下,我正在寻找 @Constraint 注释。例如:
匹配方法:
public void method1(@Constraint Car car)
public void method2(String id, @Constraint Plane plane)
public void method3(Wheel wheel, @Constraint List<Train> trains, @Constraint Plane plane)
public void method4(Motor motor, @Constraint Set<Train> trains, Bicycle bike, Wheel wheel)
public void method5(Wing wing, Motorcycle moto, @Constraint Truck truck, Bicycle bike, Wheel wheel)
到目前为止,我尝试了以下表达式,但没有成功:
@Before("execution(public * *.*(..)) and @args(com.example.Constraint)") // there can be only one parameter
@Before("execution(public * *.*(..)) and @args(..,com.example.Constraint)") // parameter must be in last position
@Before("execution(public * *.*(..)) and @args(com.example.Constraint,..)") // parameter must be in first position
@Before("execution(public * *.*(..)) and (@args(com.example.Constraint,..) or @args(..,com.example.Constraint))") // parameter must be in first or last position, nothing in between
@Before("execution(public * *.*(..)) and @args(..,com.example.Constraint,..)") // Invalid
有人能指出正确的解决方案吗?有可能吗?
【问题讨论】:
标签: java spring aop aspectj spring-aop