我使用 AspectJ 来建议所有具有所选类参数的公共方法。我尝试了以下方法:
pointcut permissionCheckMethods(Session sess) :
(execution(public * *(.., Session)) && args(*, sess));
这对于至少有 2 个参数的方法非常有效:
public void delete(Object item, Session currentSession);
但它不适用于以下方法:
public List listAll(Session currentSession);
我如何更改切入点以建议这两种方法的执行?换句话说:我期望“..”通配符代表“零个或多个参数”,但看起来它的意思是“一个或多个”......
哦,好吧……我用这个讨厌的把戏解决了这个问题。仍在等待有人给出“官方”切入点定义。
pointcut permissionCheckMethods(EhealthSession eheSess) :
(execution(public * *(.., EhealthSession)) && args(*, eheSess))
&& !within(it.___.security.PermissionsCheck);
pointcut permissionCheckMethods2(EhealthSession eheSess) :
(execution(public * *(EhealthSession)) && args(eheSess))
&& !within(it.___.security.PermissionsCheck)
&& !within(it.___.app.impl.EhealthApplicationImpl);
before(EhealthSession eheSess) throws AuthorizationException : permissionCheckMethods(eheSess)
{
Signature sig = thisJoinPointStaticPart.getSignature();
check(eheSess, sig);
}
before(EhealthSession eheSess) throws AuthorizationException : permissionCheckMethods2(eheSess)
{
Signature sig = thisJoinPointStaticPart.getSignature();
check(eheSess, sig);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)