Java EE 容器与 Web 容器 [英] Java EE Containers vs Web Containers

查看:30
本文介绍了Java EE 容器与 Web 容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Java EE/EJB 比较陌生,我阅读了很多关于 Java EE 容器的文章.我有使用 Web 容器(JBoss 中的 WAR 文件)的经验.我也知道 JBoss 也可以用作 Java EE 容器.

I'm relatively new to Java EE/EJB, and I've been reading a lot regarding Java EE containers. I've had experience working with a web container (WAR file in JBoss). I am also aware that JBoss can also be used as a Java EE container.

Java EE 容器与 Web 容器有什么区别?

What is the difference between a Java EE container against a web container?

我知道 Java EE 也可以包含 .war 文件.它们有什么不同,它们的区别是什么?是否有任何特定于供应商的偏好哪个更好?

I know Java EE is also able to contain a .war file. Are they different and what are their differences? Are there any preferences vendor specific-wise which is better?

推荐答案

首先,J2EE"是一个过时的缩写,现在简称为Java Enterprise Edition"或 Java EE.

First of all, "J2EE" is an obsolete abbreviation, it is now simply called "Java Enterprise Edition" or Java EE.

与 servlet 容器(例如 Tomcat)相反,完整的"Java EE 应用服务器还包含一个 EJB 容器.EJB 是企业 Java Bean,您可以阅读很多关于它们的信息,例如 此处(第四章).EJB 现在的版本是 3.2(Java EE 7 和 Java EE 8),之前的版本是 3.1(Java EE 6)和 3.0(Java EE 5);但是最大的区别是在 v2 和 v3 之间.

Contrary to the servlet container (e.g. Tomcat), "full" Java EE application servers contain also an EJB container. EJB are Enterprise Java Beans and you can read a lot about them for example here (chapter IV). EJBs are now in version 3.2 (Java EE 7 and Java EE 8), previous versions are 3.1 (Java EE 6) and 3.0 (Java EE 5); however the greatest difference is between v2 and v3.

EJB 旨在保留应用程序的业务逻辑.例如,无状态会话 bean 可以计算某些内容,或表示 Web 服务或您的应用程序需要执行的任何操作.消息驱动 bean 可以侦听消息队列,因此如果您想要异步通信,它们非常有用.单例 bean 保证每个 bean 一个实例等

EJBs are designed to keep a business logic of your application. For example, stateless session bean can calculate something, or represent a Web service or whatever your application needs to do. Message-driven beans can listen on message queues, therefore they are useful if you want asynchronous communication. Singleton beans guarantee one instance per bean etc.

关于文件类型,EJB被打包成.jar文件,Web应用程序被打包成.war文件,如果你想将它们混合在一个应用程序中,那就是.ear文件(企业档案").

Regarding the file type, EJB is packed into a .jar file, Web application into a .war file, and if you want to mix them in a single application, that would be the .ear file ("enterprise archive").

除了 EJB 之外,完整"应用服务器还负责事务、安全性、JDBC 资源……我强烈建议在 servlet 容器上使用它,但好处是复杂性,因此您必须花费合理的时间学习如何处理例如的时间Websphere (PayaraWildFly 更简单,也是我的最爱).JBossWeblogic 也很流行,如果您熟悉 Tomcat,请查看 TomEE.

Beside EJBs, "full" application server also takes care about transactions, security, JDBC resources... I would highly recommend using it over a servlet container, but the benefits come with the complexity so you will have to spend a reasonable amount of time to learn how to deal with e.g. Websphere (Payara and WildFly are much simpler, and are my favourite). JBoss and Weblogic are also quite popular, and if you are familiar with Tomcat take a look at TomEE.

这篇关于Java EE 容器与 Web 容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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