AspectJ: parameter in a pointcut

后端 未结 5 1202
说谎
说谎 2021-01-01 01:54

I\'m using AspectJ to advice all the public methods which do have an argument of a chosen class. I tried the following:

pointcut permissionCheckMethods(Sessi         


        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-01 02:54

    Oh well... I worked that around with this nasty trick. Still waiting for someone to show up with an "official" pointcut definition.

    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);
    }
    

提交回复
热议问题