AspectJ MethodSignature 为 getParameterNames() 返回 null
我有一个方面,它根据目标方法的详细信息进行各种计算,因此预先提取这些信息,如下所示:
@Around("execution(* com.xyz.service.AccountService.*(..))")
public void validateParams(ProceedingJoinPoint joinPoint) throws Throwable {
final MethodSignature signature = (MethodSignature) joinPoint.getSignature();
final String methodName = signature.getName();
final String[] parameterNames = signature.getParameterNames();
final Object[] arguments = joinPoint.getArgs();
...
...
...
joinPoint.proceed();
}
在提取的详细信息中,除了始终返回 null 的parameterNames 之外,所有详细信息都反映了预期信息。我希望它按照下面的签名返回 {accountDetails} 。有人知道我可能缺少什么,还是这是一个错误?
这是我正在处理的目标方法的签名:
Long createAccount(RequestAccountDetails accountDetails);
I have an aspect that does various computations based on the target method's details, and therefore extracts these upfront as follows:
@Around("execution(* com.xyz.service.AccountService.*(..))")
public void validateParams(ProceedingJoinPoint joinPoint) throws Throwable {
final MethodSignature signature = (MethodSignature) joinPoint.getSignature();
final String methodName = signature.getName();
final String[] parameterNames = signature.getParameterNames();
final Object[] arguments = joinPoint.getArgs();
...
...
...
joinPoint.proceed();
}
Of the extracted details, all reflect the expected info except parameterNames which always returns null. I would expect it to return {accountDetails} as per the signature below. Would anyone know what I may be missing, or is this a bug?
Here's the signature of the target method I am working against:
Long createAccount(RequestAccountDetails accountDetails);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对我有用:
输出:
paramName: accountDetails
我已将 validateParams 的签名更改为:
public Object validateParams(ProceedingJoinPoint joinPoint) 会抛出 Throwable
,因为createAccount()
返回一个 Long。否则,我会收到错误:申请不返回 void 的连接点:{0}
works for me:
output:
paramName: accountDetails
I have changed the signature of validateParams to:
public Object validateParams(ProceedingJoinPoint joinPoint) throws Throwable
becausecreateAccount()
returns a Long. Otherwise I get the error:applying to join point that doesnt return void: {0}