我怎么能触发我的自定义注解时调用的方法? [英] how can i trigger my custom annotation when method called?

查看:1185
本文介绍了我怎么能触发我的自定义注解时调用的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写我的网站自己的安全模块库,但我没有解决方案出头。例;我有一个类,有一个方法。方法有我的自定义注释。

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.

(例; Hibernate的验证程序,我们写的方法休眠注释,它的工作只是调用的方法)

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

顺便说一句我的英语不好:)

by the way my english is bad :)

推荐答案

注解不是触发......你必须写code,看起来他们的presence和采取行动。

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

在code可以在运行时执行,但更常用于的编译的使用的注释处理工具改变源注入额外的,通常的跨领域,code适合的注释。

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.

这篇关于我怎么能触发我的自定义注解时调用的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆