How does aspect influence static method in Spring?

375 Views Asked by At
public class Secured {
    @RolesAllowed("ADMIN")
    public static void staticJsr250() {
        System.out.println("@RolesAllowed in static");
        System.out.println("The class is: " + new Object() {}.getClass().getEnclosingClass());
    }
}

Without role ADMIN, the method won't output anything.

With role ADMIN, it will output:

@RolesAllowed in static
The class is: class Secured

I don't know why it works.

For non-static method, it should work because the implicit parameter is a proxy, instead of a truely Secured object.

But there is proxy for static method?

How to explain it?

0

There are 0 best solutions below