java - J2EE 中的容器究竟是什么,它有什么帮助?

标签 java jakarta-ee

我现在正在阅读 J2EE 1.4 规范,有很多术语我不明白做什么。 这是来自容器的规范:

Containers provide the runtime support for J2EE application components. Containers provide a federated view of the underlying J2EE APIs to the application components. J2EE application components never interact directly with other J2EE application components. They use the protocols and methods of the container for interacting with each other and with platform services. Interposing a container between the application components and the J2EE services allows the container to transparently inject the services defined by the components’ deployment descriptors, such as declarative transaction management, security checks, resource pooling, and state management.

由于我来自 Web 开发世界,我无法理解这究竟是做什么的以及容器的用途是什么。提供运行时支持是什么意思?它如何使 J2EE 在可扩展性、架构方面成为更好的系统?

最佳答案

J2EE/Java EE 应用程序不是自包含的。为了被执行,它们需要被部署在一个容器中。换句话说,容器在 JVM 之上提供了一个执行环境。

此外,应用程序依赖于几个 API,如 JPA、EJB、servlet、JMS、JNDI 等。符合 EE 的容器的作用是提供所有或部分这些 API 的标准实现。这意味着您理论上可以在任何容器之上运行您的应用程序,只要它依赖于标准 API。

从技术角度来看,容器只是另一个具有 main() 方法的 Java SE 应用程序。另一方面,EE 应用程序是服务/bean/servlet/等的集合。容器找到这些组件并运行它们,提供 API 实现、监控、可扩展性、可靠性等。

关于java - J2EE 中的容器究竟是什么,它有什么帮助?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8210692/

相关文章:

java - 关于 Grails map 的帮助

java - ConcurrentLinkedHashMap.Builder如何处理删除和获取?

java - 使用 EJB 注入(inject)用户实体

java - 如何使用不同的类作为方法中的参数

java - Jboss-Maven-Plugin 无法启动?

java - Maven 仍然可以成功构建并出现已知错误

java - Hibernate-无法加载 Hibernate 配置 </mapping> 条目中声明的类

java - jaxb:意外元素(uri :"",本地 :"head")- 没有 "head"元素

java - 在 JPA Criteria Builder 中按 Oracle 函数排序

Java EE 5 程序化身份验证