JSF 2 / Seam 中的 EJB 3 与 POJO 服务
EJB 3 服务和 EJB 3 服务之间有什么区别? POJO服务?现在 EJB 是轻量级的易于开发并且与 JPA 配合良好?
1) 好处 2) 性能
两者都注入了 EntityManager
与 EJB 和性能结果的任何链接; POJO服务
What is the difference between EJB 3 services & POJO services? Now that EJB is light & easy to develop with and works well with JPA ?
1) Benefits
2) Performace
Both have EntityManager injected in them
Any links to performace results with EJB & POJO services
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如今,EJB3 会话 Bean 可以被视为 POJO。
如果您使用 XML 来启用它们上的服务,它们基本上会传递每个 POJO 定义。如果您使用注释,它们会传递 POJO 的较弱定义。
与其他通过服务增强 POJO 的框架(如 CDI)的主要区别在于,在 CDI 中,服务可以应用得更细粒度。使用 EJB 会话 Bean,一个注释可以一次性为您提供大量服务。中长期计划似乎是将 EJB 改造为 CDI 服务的集合( http:// java.net/jira/browse/EJB_SPEC-26 就是一个很好的例子,具体示例例如 http://java.net/jira/browse/EJB_SPEC-1 )。
另一方面,如果“POJO 服务”是指没有通过框架(EJB、CDI、Spring 等)应用任何类型的服务的类,那么答案是框架添加的那些服务是通用的否则你必须自己实现的事情。
您将要么构建自己的框架来完成完全相同的事情,但可能没有那么好,因为您不太可能与整个团队一起开发该框架,或者您在服务中一次又一次地实现这些问题。这会使它们变得混乱,使它们更加冗长,并且可能意味着您将一遍又一遍地复制/粘贴它们。
EJB3 session beans can be considered POJOs these days.
If you use XML to enable services on them, they basically pass every POJO definition out there. If you use annotations, they pass the weaker definition of being a POJO.
A major difference with other frameworks that enhance POJOs with services (like CDI) is that in CDI services can be applied more fined grained. With EJB session beans, one single annotation gives you a lot of services in one go. The medium to long term plan seems to be to retrofit EJB as a collection of CDI services ( http://java.net/jira/browse/EJB_SPEC-26 is a prime example of this, with specific examples such as http://java.net/jira/browse/EJB_SPEC-1 ).
On the other hand, if with "POJO services" you mean classes without any kind of services being applied to them by a framework (EJB, CDI, Spring, etc), then the answer is that those services being added by the framework are general things that you otherwise would have to implement yourself.
You will be either building your own framework that does the exact same thing, but possibly not as good since you are not likely to work on just that framework with a whole team, OR you are implementing those concerns again and again in your services. This will clutter them, make them more verbose and probably means you will copy/paste them over and over again.
EJB 具有自由事务、生命周期和拦截器,而 POJO 则没有。
EJBs have free transactions, lifecycle, and interceptors, whereas POJOs don't.