什么是“容器”在编程的背景下意味着什么? [英] What does "Container" mean in the context of programming?
问题描述
我正在学习Spring,术语Spring Container经常出现在文本中。但是,我知道容器不仅仅用在Spring(EJB容器等)中,所以在编程环境中使用它意味着什么?
I am learning Spring and the term "Spring Container" frequently shows up in the text. However, I know "container" is not used only in Spring (EJB container etc) so what does it mean when used in the context of programming?
推荐答案
容器是包含的东西。
In spring: Spring container contains beans (Java objects that are subject to dependency-injection)
Servlet容器包含 servlet,过滤器,监听器等,并管理它们状态和生命周期。还有类似的 portlet 容器
Servlet containers contain servlets, filters, listeners, etc. and manages their state and lifecycle. There are also similar portlet containers
EJB容器包含 EJB(无状态,有状态,消息驱动),并且如上所述,管理它们的池和生命周期
EJB containers contain EJBs (stateless, stateful, message-driven) and, as above, manage their pooling and lifecycle
java.awt.Container
是一个可以包含其他AWT组件的组件
正如您所看到的,容器的角色是拥有并管理一组对象,因此您不必不必直接实例化它们。
As you can see the role of the container is to own and manage a set of objects so you don't have to instantiate them directly.
这篇关于什么是“容器”在编程的背景下意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!