Is it possible to do something like the following:
public void doStuff(@RequirePrivilege("foo") User user) {
}
code>
and does it work efficiently as if it were next?
public void doStuff(User user) {
if(!user.hasPrivilege("foo"))
throw new UserHasInsufficientPrivileges();
}
code>
I know that Spring has various kinds of AOP support, but the best I could find was AOP code that was annotated so that it would run before or after a specific method. I want to do the reverse and annotate the code that needs to be changed.
Ultimately, I could just do the above check inside the method, but the way of annotating makes the additional documentation, which makes it obvious that the user needs a certain privilege without having to synchronize the documentation with the code.
source
share