Results 1 to 2 of 2

Thread: advice for annotation on either class or method

  1. #1
    Join Date
    Nov 2012
    Posts
    1

    Default 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. #2
    Join Date
    Dec 2009
    Location
    India
    Posts
    108

    Default

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •