Java EE 安全性:注释与部署描述符
我有一个关于 Java EE 安全最佳实践的问题。 使用注释或部署描述符来定义 Web 应用程序的安全性有哪些优点和缺点? 是否存在您偏爱其中一种的情况?
先感谢您 :)
I have a question regarding Java EE security best practices.
What are the advantages and disadvantages of using either annotations or a deployment descriptor to define Security for a web application?
Are there cases where you favor one over the other?
Thank you in advance :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗯,这是时尚的问题。几年前,出现了大规模的“将应用程序检测与编程分离”的运动(例如,您可以阅读 EJB 规范,其中甚至有特殊角色,这个人甚至不必是程序员)。通过这种方式,认可了 XML 的使用(而不是纯 txt 文件或属性文件)。然后注释将这些 XML 文件带回到代码中。我认为这是由于 Spring 框架的质量。配置应用程序确实很难(没有好的方法来“调试”您的配置)。使用注释是进行配置的“轻量级”方式。在简单的场景中,您可以跳过定义组件之间的关系,因为可以从代码元素中推断出它们。
Well, it is mater of fashion. Some years ago there was massive movement "to sepearate application instrumentation from the programming" (you can read, for example, spec of EJB, where there is special role for this even, this person is not have to be even programmer). In this way use of XML was indorsed (instead of plain txt file or property files). And than annotations bring back those XML file to the code. I think it is due the mass in Spring framework. It was really hard to configure application (there was no good way to "debug" your configuration). Using annotation is "lightweight" way to make configuration. In simple scenarios you can skip defining relationships between your components, because they can be inferred from you code elements.
使用注释很优雅(您不需要额外的 XML 文件),但每次进行更改时都需要重新编译代码。
Using annotations is elegant (you do not require additional XML files) but requires to recompile your code every time you made a change.