POJO、EJB、EJB 3
有谁有 Java 类作为 POJO、EJB 和 EJB 3 的示例吗? 我正在尝试了解这些 java 技术,但遇到了麻烦。 我希望如果我能看到这三种方法的实现会是什么样子,将会有所帮助。
Does anyone have any example of what a Java Class might look like as a POJO, EJB, and EJB 3? I'm trying to understand these java technologies but am having trouble. I was hoping it would help if I could see what an implementation of all three would look like.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
POJO 代表 Plain-Old-Java-Object - 只是一个普通的 Java 类,而不是需要以特定方式更改类以使其与框架一起工作的旧技术。
因此,POJO 可以在任何可以使用普通类的地方使用。 但是,如果您想用它们构建企业应用程序,您仍然需要一些框架 - Spring 就是一个很好的例子一个可以直接与 POJO 一起工作的框架。
EJB2 不再相关,因此您可以忽略它 - 除非您需要维护一些遗留代码。 为了满足您的好奇心,与上面相同的示例需要多个类和 xml 描述符才能运行 - 很容易看出为什么它变得过时。
EJB3 是开发企业应用程序的最新标准,它取代了 EJB2,基于获取 POJO 并对其进行注释的概念,以便它们可以在企业应用程序中使用。
正如您所看到的,它与 POJO 非常相似。 事实上,大多数为 EJB3 编写的应用程序都可以轻松转换为与 Spring 一起使用,通常其他方式也可以工作。
POJO stands for Plain-Old-Java-Object - just a normal Java class as opposed to older technologies that required changing the class in specific ways to make it work with their framework.
As such POJOs can be used anywhere a normal class can be used. However if you want to build an enterprise application out of them you still need some framework - Spring is a good example of a framework that can work directly with POJOs.
EJB2 is no longer relevant so you can ignore it - unless you need to maintain some legacy code. To satisfy your curiosity the same example as above would require several classes and xml descriptors to make it run - it's easy to see why it became obsolete.
EJB3 is the latest standard for developing enterprise applications which replaces EJB2 and is based on concept of taking POJOs and annotating them so that they can be used in enterprise app.
As you can see it's very similar to POJOs. In fact most application written for EJB3 can easily be converted to work with Spring, and usually the other way works too.
通过: http://swik.net/POJO+ejb3
例如: http://www.laliluna.de/ejb-3-教程-jboss.html
via: http://swik.net/POJO+ejb3
for the example: http://www.laliluna.de/ejb-3-tutorial-jboss.html
POJO
这也可以用作EJB3。
关于EJB2,请忘记它的存在,并且不要在其上投入任何时间,除非您绝对必须这样做(例如处理遗留代码)。
POJO
This can be used as an EJB3 as well.
Regarding EJB2 please forget that it exists and do not invest any time on it unless you absolutely have to (e.g work on legacy code).
即使上面提到的这个类(@Stateless class MyService)与POJO类似,它也不是传统定义的POJO,因为它依赖于javax.ejb包。 我希望这种依赖关系就像软引用(数据库概念)一样,而不是必需的。 本文提到了一些与此相关的想法:如何修复Java POJO 注解
Even this class (@Stateless class MyService) mentioned above is similar to POJO, it is not a traditionally-definied POJO since it has dependency on the javax.ejb package. I wish this dependency was just like a soft reference (DB concept) instead of being required. This article mentioned some ideas regarding this: How to Fix Java POJO Annotations