Java EE 7 教程 第一部分 简介 第1章 概述 第1.3节 分布式多层应用

原文:http://docs.oracle.com/javaee/7/tutorial/doc/overview003.htm
翻译:石卓林 shizhuolin@hotmail.com

1.3 Distributed Multitiered Applications

The Java EE platform uses a distributed multitiered application model for enterprise applications. Application logic is divided into components according to function, and the application components that make up a Java EE application are installed on various machines, depending on the tier in the multitiered Java EE environment to which the application component belongs.

Figure 1-1 shows two multitiered Java EE applications divided into the tiers described in the following list. The Java EE application parts shown in Figure 1-1 are presented in Java EE Components.

  • Client-tier components run on the client machine.
  • Web-tier components run on the Java EE server.
  • Business-tier components run on the Java EE server.
  • Enterprise information system (EIS)-tier software runs on the EIS server.

Although a Java EE application can consist of all tiers shown in Figure 1-1, Java EE multitiered applications are generally considered to be three-tiered applications because they are distributed over three locations: client machines, the Java EE server machine, and the database or legacy machines at the back end. Three-tiered applications that run in this way extend the standard two-tiered client-and-server model by placing a multithreaded application server between the client application and back-end storage.

Figure 1-1 Multitiered Applications

overview-multitieredapps

Description of “Figure 1-1 Multitiered Applications

1.3 分布式多层应用

Java EE平台使用分布式多层应用模型支持企业级应用, 应用逻辑是按功能划分的组件,并且Java EE应用组件被安装在不同的机器上,根据层次决定应用组件在多层Java EE环境的归属.

图 1-1 说明了下面列表中的描述的划分为两层的Java EE应用, 图1-1中包含Java EE组件中的Java EE应用部分.

  • 运行在客户计算机上的客户层组件.
  • 运行在Java EE服务器上的Web层组件
  • 运行在Java EE服务器上的业务层组件
  • 运行在EIS服务器上的企业信息系统(EIS)层软件

虽然 一个Java EE应用可以构成图1-1中的所有层, 但Java EE多层应用通常被分为三层,因为他们分布在三个不同的地方: 客户机计算机,Java EE服务器和数据库服务器或在后端的传统计算机, 三层应用以这种方式运行,它扩展了标准的客户机和服务器两层模型下的多线程应用服务器的客户端应用程序和后端存储.

图 1-1 多层应用

overview-multitieredapps

图1-1多层应用“的描述

1.3.1 Security

Although other enterprise application models require platform-specific security measures in each application, the Java EE security environment enables security constraints to be defined at deployment time. The Java EE platform makes applications portable to a wide variety of security implementations by shielding application developers from the complexity of implementing security features.

The Java EE platform provides standard declarative access control rules that are defined by the developer and interpreted when the application is deployed on the server. Java EE also provides standard login mechanisms so application developers do not have to implement these mechanisms in their applications. The same application works in a variety of security environments without changing the source code.

1.3.1 安全

虽然其他的企业应用模型需要在每个应用中有特定于平台的安全措施, 但Java EE 安全环境允许在部署时定义安全约束.Java EE平台使应用可移植到对应用开发者屏蔽复杂的安全功能的多种安全实现.当应用部署在服务器上时,

Java EE平台对开发者定义的标准访问控制规则声明提供解释, Java EE还提供标准的登陆机制,使得应用开发人员不必在他们自己的应用中实现这些机制. 同一个应用不需要改变源码就可工作于各种安全环境.

1.3.2 Java EE Components

Java EE applications are made up of components. A Java EE component is a self-contained functional software unit that is assembled into a Java EE application with its related classes and files and that communicates with other components.

The Java EE specification defines the following Java EE components:

  • Application clients and applets are components that run on the client.
  • Java Servlet, JavaServer Faces, and JavaServer Pages (JSP) technology components are web components that run on the server.
  • Enterprise JavaBeans (EJB) components (enterprise beans) are business components that run on the server.

Java EE components are written in the Java programming language and are compiled in the same way as any program in the language. The differences between Java EE components and “standard” Java classes are that Java EE components are assembled into a Java EE application, they are verified to be well formed and in compliance with the Java EE specification, and they are deployed to production, where they are run and managed by the Java EE server.

1.3.2 Java EE 组件

Java EE应用由组件构成. 每个Java EE组件都是由一组相关的类和文件组成的Java EE应用程序,并能同其他组件通讯.

Java EE规范定义了以下Java EE组件:

  • 应用客户端和applets(小程序)是运行在客户端上的组件.
  • Java Servlet,JavaServer Faces和JavaServer Pages(JSP)技术组件是运行在服务器上的WEB组件
  • 企业JavaBeans(EJB)组件(企业Beans)是运行在服务器上的业务组件

Java组件是用Java 程序语言编写和以同样方式编译在语言中的任何程序.Java EE组见和”标准”Java类之间的差别是Java EE组件用于组装一个Java EE应用程序.他们被证实能良好工作,且符合Java EE规范. 且他们从部署到生产,以及它们在那里运行都使用Java EE服务器进行管理.

1.3.3 Java EE Clients

A Java EE client is usually either a web client or an application client.

1.3.3 Java EE客户端

Java EE客户端通常是一个WEB客户端或一个客户端应用程序

1.3.3.1 Web Clients

A web client consists of two parts:

  • Dynamic web pages containing various types of markup language (HTML, XML, and so on), which are generated by web components running in the web tier
  • A web browser, which renders the pages received from the server

A web client is sometimes called a thin client. Thin clients usually do not query databases, execute complex business rules, or connect to legacy applications. When you use a thin client, such heavyweight operations are off-loaded to enterprise beans executing on the Java EE server, where they can leverage the security, speed, services, and reliability of Java EE server-side technologies.

1.3.3.1 WEB客户端

一个WEB客户端由两部分组成:

  • 包含各种类型的标记语言(HTML,XML,等)的动态WEB页面,它们由在WEB层运行的WEB组件生成.
  • 一个WEB浏览器,它显示从服务器接收到的页面.

WEB客户端有时被称为瘦客户端,瘦客户端通常不能查询数据库,不能执行复杂业务规则或连接传统应用程序, 当使用一个瘦客户端,重量级的操作被传递到Java EE服务器执行,在那里他们可以充分利用Java EE服务端技术的安全性,更快的速度和可靠性.

1.3.3.2 Application Clients

An application client runs on a client machine and provides a way for users to handle tasks that require a richer user interface than can be provided by a markup language. An application client typically has a graphical user interface (GUI) created from the Swing or the Abstract Window Toolkit (AWT) API, but a command-line interface is certainly possible.

Application clients directly access enterprise beans running in the business tier. However, if application requirements warrant it, an application client can open an HTTP connection to establish communication with a servlet running in the web tier. Application clients written in languages other than Java can interact with Java EE servers, enabling the Java EE platform to interoperate with legacy systems, clients, and non-Java languages.

1.3.3.2 客户端应用程序

一个客户端应用程序运行在一个客户端机器上,它为用户任务处理提供了一个比标记语言更丰富的的用户界面.客户端应用程序通常拥有使用Swing或抽象窗口工具包(AWT)API创建的图形界面(GUI),当然也有可能是命令行界面.

客户端应用程序直接访问运行在业务层的企业beans.然而,如果应用要求授权,客户端应用程序可以打开一个HTTP连接建立到运行于WEB层的servlet的通讯. 不是Java语言编写的客户端应用程序也可以与Java EE交互. 允许Java EE平台与传统系统,客户端,或其他非Java语言交互.

1.3.3.3 Applets

A web page received from the web tier can include an embedded applet. Written in the Java programming language, an applet is a small client application that executes in the Java virtual machine installed in the web browser. However, client systems will likely need the Java Plug-in and possibly a security policy file for the applet to successfully execute in the web browser.

Web components are the preferred API for creating a web client program, because no plug-ins or security policy files are needed on the client systems. Also, web components enable cleaner and more modular application design because they provide a way to separate applications programming from web page design. Personnel involved in web page design thus do not need to understand Java programming language syntax to do their jobs.

1.3.3.3 小程序

从WEB层接收到的网页可以嵌入一个使用Java程序语言编写的小程序, applet是一个通过WEB浏览器安装的虚拟机执行的小型客户端应用程序. 注意,客户端系统可能需要Java插件和安全策略文件才能成功在浏览器执行它.

WEB组件是创建WEB客户端程序的首选API.因为它不强制客户系统安装插件或者安全策略文件.并且WEB组件使用更清晰,更模块化的应用程序设计。因为他们提供了一种分离的网页设计方法,使得网页设计人员不需要了解Java程序语言就能完成他们的工作.

1.3.3.4 The JavaBeans Component Architecture

The server and client tiers might also include components based on the JavaBeans component architecture (JavaBeans components) to manage the data flow between the following:

  • An application client or applet and components running on the Java EE server
  • Server components and a database

JavaBeans components are not considered Java EE components by the Java EE specification.

JavaBeans components have properties and have get and set methods for accessing the properties. JavaBeans components used in this way are typically simple in design and implementation but should conform to the naming and design conventions outlined in the JavaBeans component architecture.

1.3.3.4 JavaBeans组件结构

客户端和服务器层可能还需要包含以下基于Java Beans组件结构(JavaBeans组件)的组件用于管理数据流:

  • 应用程序客户端或applet和运行在Java EE 服务器上的组件
  • 服务器组件和数据库

JavaBeans组件不是Java EE规范定义的Java EE组件.

JavaBeans组件有属性和用于设置和获取属性的方法, 以这种方式构建的组件通常在设计和实施上更简单,但应符合JavaBeans组件结构的命名和设计约定.

1.3.3.5 Java EE Server Communications

Figure 1-2 shows the various elements that can make up the client tier. The client communicates with the business tier running on the Java EE server either directly or, as in the case of a client running in a browser, by going through web pages or servlets running in the web tier.

Figure 1-2 Server Communication

overview-servercommunic

Description of “Figure 1-2 Server Communication

1.3.3.5 Java EE服务器通讯.

图 1-2显示了客户层上散布的各种元素. 客户端和在Java EE服务器上的运行的业务组件直接连接,在客户端浏览器中运行的小程序则通过WEB层运行的网页或servlets连接.

<

p style=”padding-left: 30px;”>图 1-2 服务通讯

overview-servercommunic

图 1-2 服务通讯“介绍

1.3.4 Web Components

Java EE web components are either servlets or web pages created using JavaServer Faces technology and/or JSP technology (JSP pages). Servlets are Java programming language classes that dynamically process requests and construct responses. JSP pages are text-based documents that execute as servlets but allow a more natural approach to creating static content. JavaServer Faces technology builds on servlets and JSP technology and provides a user interface component framework for web applications.

Static HTML pages and applets are bundled with web components during application assembly but are not considered web components by the Java EE specification. Server-side utility classes can also be bundled with web components and, like HTML pages, are not considered web components.

As shown in Figure 1-3, the web tier, like the client tier, might include a JavaBeans component to manage the user input and send that input to enterprise beans running in the business tier for processing.

Figure 1-3 Web Tier and Java EE Applications

overview-webtier

Description of “Figure 1-3 Web Tier and Java EE Applications

1.3.4 WEB组件

Java EE WEB组件包含servlets和使用JavaServer Faces技术,JSP技术(JSP页)创建的网页. Servlets是用于处理动态请求和结构化响应的Java语言类.JSP页是基于文本的文档,作为servlets执行,但允许更自然的方法来创建静态内容. JavaServer Faces是构建在servlets和JSP技术上且提供用户接口元件用于WEB应用程序的框架.

静态HTML页面和小程序在应用程序中装配成WEB组件,但这是Java EE规范没有周密考虑过的WEB组件. 服务端实用工具类也可以装配WEB组件,例如HTML网页,但这不被视为WEB组件.

图1-3 所示, WEB层,客户端层,可能还包括一个JavaBeans组件用于管理用户输入和发送输入到业务层处理运行的企业bean.

图 1-3 WEB层和Java EE应用程序

overview-webtier

图 1-3 WEB层和Java EE应用程序“介绍

1.3.5 Business Components

Business code, which is logic that solves or meets the needs of a particular business domain such as banking, retail, or finance, is handled by enterprise beans running in either the business tier or the web tier. Figure 1-4 shows how an enterprise bean receives data from client programs, processes it (if necessary), and sends it to the enterprise information system tier for storage. An enterprise bean also retrieves data from storage, processes it (if necessary), and sends it back to the client program.

Figure 1-4 Business and EIS Tiers

overview-businesseistiers

Description of “Figure 1-4 Business and EIS Tiers

1.3.5 业务组件

业务代码是满足特定业务领域需求的解决逻辑,例如银行,零售或金融业. 由运行在业务层或WEB层的企业bean处理. 图1-4显示了一个企业beans如何从客户端程序接收数据,处理它(如果有必要),并将其发送到企业信息系统层保存. 一个企业bean还从存储库检索数据,处理它(如果有必要)并将其发送回客户端程序.

图 1-4 业务和EIS层

overview-businesseistiers

图 1-4 业务和EIS层“介绍

1.3.6 Enterprise Information System Tier

The enterprise information system tier handles EIS software and includes enterprise infrastructure systems, such as enterprise resource planning (ERP), mainframe transaction processing, database systems, and other legacy information systems. For example, Java EE application components might need access to enterprise information systems for database connectivity.

1.3.6 企业信息系统层

企业信息系统层处理EIS软件,包括企业基础设施系统,如企业资源规划(ERP),大型机事务处理,数据库系统,以及其它传统的信息系统. 例如,Java EE应用程序组件可能需要访问企业信息系统的数据库连接.

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 www.gopiplus.com