Aop和Mono争论

问题描述 投票:0回答:1

我有方法

Mono<ReceiptResponse> a01(Mono<DefaultBeneficiaryBankRequest> request)

和方面

    @Around("callAtMyServiceSecurityAnnotation(request)")
    @Order(1)
    public Object scheduleTimeout(ProceedingJoinPoint joinPoint, Mono<?> request) {
        Mono<?> retVal = (Mono)joinPoint.proceed();
        return retVal.doOnSuccess(i -> {
            ...
            someMethod(<request.value>)// <-- How I can get requets value here?
            ...
        });
    }

如何获得请求值作为someMethod的参数?

spring-aop project-reactor
1个回答
0
投票

你的问题中的信息并不完整,但在我看来,你的pointcut callAtMyServiceSecurityAnnotation(request) 已经捕捉到了请求,并将其转发给您的建议方法,作为 Mono<?> request 参数。所以你的问题的答案很简单。只要用 request 以获得对请求参数的访问。

你没有展示你的实际pointcut,但假设是这样的(未经测试,写的只是freestyle,因为我没有你的测试用例可以试一试

@Pointcut("within(my.package.MyTargetClass) && execution(* a01(*)) && args(request)")
public void callAtMyServiceSecurityAnnotation(Mono<?> request) {}

它应该只是工作。

© www.soinside.com 2019 - 2024. All rights reserved.