简体   繁体   English

Java注释和代码在运行时执行

[英]Java annotation and code execution at runtime

Annotations supposedly are markers/provide metadata, so for example how does the @RolesAllowed annotation in JAX-RS work? 注释应该是标记/提供的元数据,例如,JAX-RS中的@RolesAllowed注释如何工作? This annotation "executes" code since it checks that the user is authenticated and has the required roles, at runtime (when an annotated method is called). 该批注“执行”代码,因为它在运行时(调用带批注的方法时)检查用户是否已通过身份验证并具有所需的角色。

No. There is code that checks if the annotation exists and performs operations based on it. 否。有一些代码可以检查注释是否存在并根据注释执行操作。 The annotation itself just lies there. 注释本身就在那里。 The code that performs the checking and operations is executed around the method call. 执行检查和操作的代码围绕方法调用执行。

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

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