我有这个方面:
public privileged aspect Teste {
private ISupermarket supermarket;
@AfterReturning(pointcut = "execution(* ca1.business.SupermarketFactory.createSupermarket(..))", returning = "result")
public void afterCreateSupermarket(JoinPoint joinPoint, Object result) {
supermarket = (ISupermarket) result;
}
}
问题是我想用原生的AspectJ表示法编写它。
我搜索了但是我得到的最接近的是:
void after() returning(result) : pointcut(* ca1.business.SupermarketFactory.createSupermarket(..)) {
supermarket = (ISupermarket) result;
}
但这给了我一些错误,因为它编码不好。
任何人都可以帮我吗?
答案 0 :(得分:1)
我找到了答案:
pointcut afterCreateSupermarket():
call(ISupermarket ca1.business.SupermarketFactory.createSupermarket(..));
after() returning(Object result): afterCreateSupermarket() {
supermarket = (ISupermarket) result;
}
答案 1 :(得分:1)
如果你想摆脱演员和命名的切入点,你也可以这样做:
after() returning(ISupermarket result) : call(ISupermarket ca1.business.SupermarketFactory.createSupermarket(..)) {
supermarket = result;
}