简体   繁体   English

当方法调用时,如何触发我的自定义注释?

[英]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. 我想为web编写自己的安全模块库,但我没有解决问题。 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) (例子; Hibernate验证器。我们在方法上编写hibernate注释,它只用于调用方法)

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. “代码”可以在运行时执行,但更常见的是在编译时使用注释处理工具执行以更改源以注入适用于注释的额外(通常是交叉)代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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