简体   繁体   中英

how can i trigger my custom annotation when method called?

I want to write my own Secure module library for web but i not solution somethings. Example; I have a class and have a method. Method have my custom annotation.

class example{
  @Admin
  public void go(){
    syso("working");
  }
 }

When This method called , how can i trigger my annotation.

(Example; Hibernate Validators. We write hibernate annotation on method , it working only method called)

by the way my english is bad :)

Annotations are not "triggered"... you have to write code that looks for their presence and takes action.

The "code" can either be executed at runtime, but is more commonly executed at compile time using the Annotation Processing Tool to alter the source to inject extra, typically cross-cutting , code appropriate for the annotation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM