将方面转换为本机 AspectJ 表示法

Convert aspect to native AspectJ notation

我有这个方面:

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

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

谁能帮我解决这个问题?

我找到了答案:

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

after() returning(Object result): afterCreateSupermarket() {
    supermarket = (ISupermarket) result;
}

如果你想摆脱转型和命名切入点,你也可以这样做:

after() returning(ISupermarket result) : call(ISupermarket ca1.business.SupermarketFactory.createSupermarket(..)) {
    supermarket = result;
}