我有自定义注释,例如:
@AllowedForUserWithID
public myFunction (int userID) {
}
@PreAuthorize(CustomPermissionEvaluator.isUserWithID(principal, #userID))
public @interface AllowedForUserWithID {
}
public static boolean isUserWithID(UserDetails user, Integer userID) {
}
这些工作正常,我可以使用'#'获取方法参数。
但是,我的目标是注释如下:
@RequiresPermission(feature=SecurityFeature.SETTINGS, rights=AccessRights.WRITE)
public myFunction() {
}
@PreAuthorize(CustomPermissionEvaluator.hasAccessPermission(principal, feature, rights))
public @interface RequiresPermission {
SecurityFeature feature();
AccessRights rights();
}
public static boolean hasAccessPermission(UserDetails user, SecurityFeature feature, AccessRights rights) {
}
是否可以通过这种方式将参数传递给表达式?