我有两个使用 AspectJ 编译时间编织的不同注释,比如
1) 用于重试——如果抛出特定异常,该方法将自行重试
2) 转换异常——即如果抛出特定异常会将源异常转换为目标异常作为指定
我如何定义这两个注释的工作顺序。两个注释都是使用 aspectj 实现的,并使用 @around 建议。
我怎样才能实现这种功能`
Case 1
@retry(IllegalArgumentException.class)
@translate(source = IllegalArgumentException , target = IllegalStateException)
void method() {
//if it throws IllegalArgument exception
//method should retry and translate it to IllegalState after it
}
case2
@translate(source = IllegalArgumentException , target = IllegalStateException)
@retry(IllegalStateException.class)
void method() {
//methodthrows IllegalArgument exception which gets translated to IllegalState
//method should retry for IllegalStateException after it
}
`
有没有一种方法可以保证注解的操作顺序。
现在,当我运行代码重试注释时,首先运行,然后异常翻译注释起作用。