I have a simple aspect (see below) with @Around
annotation.
(我有一个简单的方面(见下文),带有@Around
注释。)
This aspect works when the the application don't use reactive paradigm. (当应用程序不使用反应性范式时,此方面适用。)
But when the application returns Mono or Flux doesn't works properly. (但是,当应用程序返回Mono或Flux时,它将无法正常工作。)
I need to get the object returned from the method to generate a JSON object to use as log, generate events, etc.
(我需要从方法返回的对象生成一个JSON对象以用作日志,生成事件等。)
Here is my code that works in a non reactive classes:
(这是我的代码在非反应性类中的工作方式:)
@Around("@annotation(simpleEvent)")
public Object logExecutionTime(ProceedingJoinPoint joinPoint, SimpleEvent simpleEvent) throws Throwable {
final long start = System.currentTimeMillis();
Object proceed = null;
try {
proceed = joinPoint.proceed();
// here in the real life the object that transformed in json to do others actions
System.out.println(proceed);
final long executionTime = System.currentTimeMillis() - start;
System.out.println(joinPoint.getSignature() + " executed in " + executionTime + "ms");
return proceed;
} catch (Exception e) {
e.printStackTrace();
}
return proceed;
}
How to get the object returned from joinPoint.proceed()
when is Mono or Flux?
(当Mono或Flux时,如何从joinPoint.proceed()
返回的对象?)
Thanks in advance.
(提前致谢。)
ask by Maicon Luz translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…