Quarkus中如何通过@AroundInvoke获取方法参数的值?
How to get the value of method arguments via @AroundInvoke in Quakus?
@AroundInvoke
Object logInvocation(InvocationContext context) throws Exception {
Method method = context.getMethod();
String methodName = context.getMethod().getName();
String genName = context.getMethod().toGenericString();
// ...log before
Object ret = context.proceed();
// ...log after
return ret;
}
我想用quarkus的@AroundInvoke
来记录方法调用日志,在SpringBoot中可以通过AOP
实现,但是Quarkus让我有点迷茫
如何获取方法中的参数值?
有人可以帮助我吗?
您必须使用 getParameters() 方法,检查 this documentation。
@AroundInvoke
Object logInvocation(InvocationContext context) throws Exception {
Method method = context.getMethod();
String methodName = context.getMethod().getName();
String genName = context.getMethod().toGenericString();
// ...log before
Object ret = context.proceed();
// ...log after
return ret;
}
我想用quarkus的@AroundInvoke
来记录方法调用日志,在SpringBoot中可以通过AOP
实现,但是Quarkus让我有点迷茫
如何获取方法中的参数值?
有人可以帮助我吗?
您必须使用 getParameters() 方法,检查 this documentation。