Java EE 7 教程 第一部分 简介 第1章 概述 第1.4节 Java EE 容器


1.4 Java EE Containers

Normally, thin-client multitiered applications are hard to write because they involve many lines of intricate code to handle transaction and state management, multithreading, resource pooling, and other complex low-level details. The component-based and platform-independent Java EE architecture makes Java EE applications easy to write because business logic is organized into reusable components. In addition, the Java EE server provides underlying services in the form of a container for every component type. Because you do not have to develop these services yourself, you are free to concentrate on solving the business problem at hand.

1.4 Java EE 容器

通常情况下, 编写多层瘦客户端应用程序非常困难,因为这牵涉到大量复杂代码用于处理事务和状态管理,多线程,资源池和其他的复杂底层细节. 通过基于组件和和与平台无关的Java EE架构,使编写Java EE应用程序变得很容易, 因为业务逻辑被组织成可重用的组件,此外. Java EE服务器在容器中为每个组件提供底层服务, 因此你不必自己开发这些服务,可以把空闲精力集中起来解决手头的业务问题.

1.4.1 Container Services

Containers are the interface between a component and the low-level platform-specific functionality that supports the component. Before it can be executed, a web, enterprise bean, or application client component must be assembled into a Java EE module and deployed into its container.

The assembly process involves specifying container settings for each component in the Java EE application and for the Java EE application itself. Container settings customize the underlying support provided by the Java EE server, including such services as security, transaction management, Java Naming and Directory Interface (JNDI) API lookups, and remote connectivity. Here are some of the highlights.

  • The Java EE security model lets you configure a web component or enterprise bean so that system resources are accessed only by authorized users.
  • The Java EE transaction model lets you specify relationships among methods that make up a single transaction so that all methods in one transaction are treated as a single unit.
  • JNDI lookup services provide a unified interface to multiple naming and directory services in the enterprise so that application components can access these services.
  • The Java EE remote connectivity model manages low-level communications between clients and enterprise beans. After an enterprise bean is created, a client invokes methods on it as if it were in the same virtual machine.

Because the Java EE architecture provides configurable services, application components within the same Java EE application can behave differently based on where they are deployed. For example, an enterprise bean can have security settings that allow it a certain level of access to database data in one production environment and another level of database access in another production environment.

The container also manages nonconfigurable services, such as enterprise bean and servlet lifecycles, database connection resource pooling, data persistence, and access to the Java EE platform APIs (see Java EE 7 APIs).

1.4.1 容器服务

容器是组件和支持组件的底层平台特定功能之间的接口, 在它被执行前, 网络,企业Bean和客户端应用组件必须被组装成一个J2ee模块部署到它的容器.

装配过程包括指定容器中每个组件的设置,并为Java EE应用程序本身和容器设置定制Java EE服务器提供的相关支持. 包括服务的安全性,事务管理, Java 命名和目录接口(JNDI) API 的查询和远程连接.这里有一些要点:

  • Java EE安全模型允许你配置Web组件或企业Bean,使系统资源只能被授权的用户访问.
  • Java EE事务模型让你指定的一个或多个方法,使其成为一个单一的事务,这样在事务中的所有方法都被视为一个独立的,单一的单元.
  • JNDI查找服务提供统一的接口用于多个企业名称和目录服务. 这样应用组件可以访问这些服务.
  • Java EE 远程连接模型管理客户端和企业beans的底层通讯.创建一个企业bean后, 客户端调用其方法就可以了,就好像它是在同一个虚拟机中那样

因为Java EE架构提供可配置服务, 所以Java EE应用程序中的相同应用组件可以被基于不同的行为部署. 例如:一个企业bean可以有安全设置,允许它在某个生产环境可中访问数据库中的数据,或在另一个生产环境中有其他的数据库访问级别.

容器也可以管理管理不可配置服务. 例如企业bean的和servlet的生命周期,数据库连接池.数据持久化和访问Java EE平台 API(参阅Java EE 7 APIs)

1.4.2 Container Types

The deployment process installs Java EE application components in the Java EE containers as illustrated in Figure 1-5.

Figure 1-5 Java EE Server and Containers


Description of “Figure 1-5 Java EE Server and Containers

  • Java EE server: The runtime portion of a Java EE product. A Java EE server provides EJB and web containers.
  • Enterprise JavaBeans (EJB) container: Manages the execution of enterprise beans for Java EE applications. Enterprise beans and their container run on the Java EE server.
  • Web container: Manages the execution of web pages, servlets, and some EJB components for Java EE applications. Web components and their container run on the Java EE server.
  • Application client container: Manages the execution of application client components. Application clients and their container run on the client.
  • Applet container: Manages the execution of applets. Consists of a web browser and Java Plug-in running on the client together.

1.4.2 容器类型

图1-5 列举在Java EE容器中部署过程安装的Java EE应用组件

图1-5 Java EE服务器和容器


图1-5 Java EE服务器和容器“介绍

  • Java EE 服务器: Java EE产品的运行部分, Java EE服务器提供EJB和WEB容器.
  • 企业 JavaBeans(EJB) 容器: 管理和执行Java EE应用程序的企业beans. 企业beans和其容器在Java EE服务器上运行.
  • WEB 容器: 管理和执行网页,servlets,和若干Java EE应用程序的EJB组件. WEB组件和其容器在Java EE服务器上运行
  • 客户端应用容器: 管理和执行客户端应用组件, 客户端应用和其容器在客户机上运行.
  • Applet容器: 管理和运行Applet, 由web浏览器和java插件构成,他们在客户计算机上运行.

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload the CAPTCHA.

Proudly powered by WordPress   Premium Style Theme by
渝公网安渝公网安备 50010702500270号 渝ICP备09056628号-7