Announcement Announcement Module
Collapse
No announcement yet.
advice for annotation on either class or method Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • advice for annotation on either class or method

    Hi,

    I have the following problem:

    I have create annotation for Security:

    Code:
    @Retention(RetentionPolicy.RUNTIME)
    @Target({ElementType.METHOD, ElementType.TYPE})
    @Inherited
    @Documented
    public @interface Security {
    
    	Role[] roles();
    }
    I am now annotating classes and methods with this annotation. In some cases the class is annotated with this annotation and specific method within this class is also annotated with @Security with different roles.

    How can create @Before advice that will catch either methods annotated with @Security ot methods within classes annotated with @Security, and also to get the more specific definition in case there are annotation on both the class and method.

    I obviously need also the content of the annotation as well (the roles).

    Is it possible?

    Is it also possible in cases that I have inhertience between classes that all of them have the @Security annotation to get the most specific definition?

    Yosi

  • #2
    I think, you're missing big time on the reference docs of spring AOP. I made the similar mistake and was stuck until I went back over the reference docs. All you want is certainly doable so you just need to read through a bit more.

    Comment

    Working...
    X