1

我有这个方面:

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;
}

但这给了我一些错误,因为它没有很好地编码。

谁能帮我这个?

4

2 回答 2

1

我设法找到了答案:

pointcut afterCreateSupermarket():
    call(ISupermarket ca1.business.SupermarketFactory.createSupermarket(..));

after() returning(Object result): afterCreateSupermarket() {
    supermarket = (ISupermarket) result;
}
于 2017-03-19T04:35:59.080 回答
1

如果你想摆脱演员阵容和命名的切入点,你也可以这样做:

after() returning(ISupermarket result) : call(ISupermarket ca1.business.SupermarketFactory.createSupermarket(..)) {
    supermarket = result;
}
于 2017-03-19T06:46:51.663 回答