Java EE 7 教程 第一部分 简介 第1章 概述 第1.7节 Java EE 7 APIs

原文:http://docs.oracle.com/javaee/7/tutorial/doc/overview007.htm
翻译:石卓林 shizhuolin@hotmail.com
注意:此章是1.8章前移而来,不知为何oracle删除了原1.7开发角色章节

1.7 Java EE 7 APIs

Figure 1-6 shows the relationships among the Java EE containers.

Figure 1-6 Java EE Containers

Java EE Containers

Description of “Figure 1-6 Java EE Containers

Figure 1-7 shows the availability of the Java EE 7 APIs in the web container.

Figure 1-7 Java EE APIs in the Web Container

Java EE APIs in the Web Container

Description of “Figure 1-7 Java EE APIs in the Web Container

Figure 1-8 shows the availability of the Java EE 7 APIs in the EJB container.

Figure 1-8 Java EE APIs in the EJB Container

Java EE APIs in the EJB Container

Description of “Figure 1-8 Java EE APIs in the EJB Container

Figure 1-9 shows the availability of the Java EE 7 APIs in the application client container.

Figure 1-9 Java EE APIs in the Application Client Container

Java EE APIs in the Application Client Container

Description of “Figure 1-9 Java EE APIs in the Application Client Container

The following sections give a brief summary of the technologies required by the Java EE platform and the APIs used in Java EE applications.

1.7 Java EE 7 APIs

图 1-6 显示了Java EE容器之间的关系.

图 1-6 Java EE 容器

Java EE 容器

图 1-6 Java EE 容器“简介

图 1-7 显示了在web容器中可以使用的Java EE 7 APIs.

图 1-7 Web容器中的 Java EE APIs

Web容器中的 Java EE APIs

图 1-7 Web容器中的 Java EE APIs“简介

图 1-8 显示了在EJB容器中可用的Java EE 7 APIs.

图 1-8 EJB容器中的Java EE APIs

EJB容器中的Java EE APIs

图 1-8 EJB容器中的Java EE APIs“简介

图 1-9显示了在应用客户端容器中可用的Java EE 7 APIs.

图 1-9 应用客户端容器中的Java EE 7 APIs

应用客户端容器中的Java EE 7 APIs

图 1-9 应用客户端容器中的Java EE 7 APIs“简介

以下章节简要叙述了Java EE平台所需技术和Java EE应用中使用的APIs.

1.7.1 Enterprise JavaBeans Technology

An Enterprise JavaBeans (EJB) component, or enterprise bean, is a body of code that has fields and methods to implement modules of business logic. You can think of an enterprise bean as a building block that can be used alone or with other enterprise beans to execute business logic on the Java EE server.

Enterprise beans are either session beans or message-driven beans.

  • A session bean represents a transient conversation with a client. When the client finishes executing, the session bean and its data are gone.
  • A message-driven bean combines features of a session bean and a message listener, allowing a business component to receive messages asynchronously. Commonly, these are Java Message Service (JMS) messages.

In the Java EE 7 platform, new enterprise bean features include the following:

  • Asynchronous local session beans in EJB Lite
  • Nonpersistent timers in EJB Lite

The Java EE 7 platform requires Enterprise JavaBeans 3.2 and Interceptors 1.2. The Interceptors specification is part of the EJB specification.

1.7.1 企业JavaBeans技术

一个 企业JavaBeans (EJB)组件企业bean是一段代码,其有业务逻辑实施模块的字段和方法.你可以认为一个企业bean是一个积木构件,它能被单独使用或作为其他Java EE服务器上的企业beans执行业务逻辑.

企业bean是会话bean或消息驱动bean:

  • 会话bean代表与客户端的一次短暂会话. 当客户端执行完毕, 会话bean和其数据都会消失.
  • 消息驱动 bean 结合了消息监听器和会话bean的功能, 语序业务组件接收异步消息,通常是Java消息服务(JMS)消息.

在Java EE 7平台中,企业bean包含以下新功能:

  • 在EJB精简版中的异步本地会话bean
  • 在EJB精简版中的非持久性计时器

Java EE 7平台要求企业JavaBeans 3.2和Interceptors(拦截器) 1.2. 该拦截器规范是EJB规范的一部分.

1.7.2 Java Servlet Technology

Java Servlet technology lets you define HTTP-specific servlet classes. A servlet class extends the capabilities of servers that host applications accessed by way of a request-response programming model. Although servlets can respond to any type of request, they are commonly used to extend the applications hosted by web servers.

In the Java EE 7 platform, new Java Servlet technology features include the following:

  • Nonblocking I/O
  • HTTP protocol upgrade

The Java EE 7 platform requires Servlet 3.1.

1.7.2 Java Servlet 技术

Java Servlet技术允许你定义基于HTTP规范的servlet类. servlet类作为服务器的功能延伸, 允许通过请求-响应编程模型的方式访问主机. Although 虽然servlet可以对任何类型的请求作出响应, 但他们通常被用于扩展web服务器托管的应用程序.

在Java EE 7平台中, Java Servlet技术包含以下新功能:

  • 非阻塞 I/O
  • HTTP协议升级

Java EE 7平台要求Servlet 3.1.

1.7.3 JavaServer Faces Technology

JavaServer Faces technology is a user interface framework for building web applications. The main components of JavaServer Faces technology are as follows:

  • A GUI component framework.
  • A flexible model for rendering components in different kinds of HTML or different markup languages and technologies. A Renderer object generates the markup to render the component and converts the data stored in a model object to types that can be represented in a view.
  • A standard RenderKit for generating HTML 4.01 markup.

The following features support the GUI components:

  • Input validation
  • Event handling
  • Data conversion between model objects and components
  • Managed model object creation
  • Page navigation configuration
  • Expression Language (EL)

All this functionality is available using standard Java APIs and XML-based configuration files.

In the Java EE 7 platform, new features of JavaServer Faces technology include the following:

  • HTML5-friendly markup
  • Faces Flows
  • Resource library contracts

The Java EE 7 platform requires JavaServer Faces 2.2 and Expression Language 3.0.

1.7.3 JavaServer Faces 技术

JavaServer Faces 技术是用于构建web应用的UI框架. 以下是JavaServer Faces技术的主要组成部分:

  • 一个GUI(图形用户界面)组件框架.
  • 一个可以在不同类型HTML或不同的标记语言和技术实现中渲染的弹性组件模型. 通过渲染对象为标记来显示组件并转换模型对象的存储数据为可在视图中显示的类型.
  • 一个用于生成HTML 4.01标记的标准渲染工具包

GUI组件支持以下功能:

  • 输入校验
  • 事件处理
  • 模型对象和组件之间的数据转换
  • 管理的模型对象的创建
  • 配置页面导航
  • 表达式语言(EL)

所有功能可以使用标准的Java API或基于XML的配置文件.

在Java EE 7平台中, JavaServer Faces技术包含以下新功能:

  • 友好HTML5标记
  • 瀑布流
  • 资源库契约

Java EE 7平台要求JavaServer Faces 2.2和Expression Language 3.0.

1.7.4 JavaServer Pages Technology

JavaServer Pages (JSP) technology lets you put snippets of servlet code directly into a text-based document. A JSP page is a text-based document that contains two types of text:

  • Static data, which can be expressed in any text-based format, such as HTML or XML
  • JSP elements, which determine how the page constructs dynamic content

For information about JSP technology, see the The Java EE 5 Tutorial at http://docs.oracle.com/javaee/5/tutorial/doc/.

The Java EE 7 platform requires JavaServer Pages 2.3 for compatibility with earlier releases but recommends the use of Facelets as the display technology in new applications.

1.7.4 JavaServer页面技术

JavaServer Pages (JSP) 技术让你可以在基于文本的文档中嵌入servlet代码片段. JSP页面是基于文本的文档,其包含两种文本类型:

  • 静态数据, 可以表达任意文本格式, 例如HTML或XML
  • JSP元素, 用其构建包含动态内容的页面

关于JSP技术的信息可以查看Java EE 5教程 at http://docs.oracle.com/javaee/5/tutorial/doc/.

Java EE 7 平台为兼容早期版本要求JavaServer Pages 2.3,但推荐在新应用中使用Facelets显示技术.

1.7.5 JavaServer Pages Standard Tag Library

The JavaServer Pages Standard Tag Library (JSTL) encapsulates core functionality common to many JSP applications. Instead of mixing tags from numerous vendors in your JSP applications, you use a single, standard set of tags. This standardization allows you to deploy your applications on any JSP container that supports JSTL and makes it more likely that the implementation of the tags is optimized.

JSTL has iterator and conditional tags for handling flow control, tags for manipulating XML documents, internationalization tags, tags for accessing databases using SQL, and tags for commonly used functions.

The Java EE 7 platform requires JSTL 1.2.

1.7.5 JavaServer页面标准标签库

JavaServer页面标准标签库(JSTL)封装多数JSP应用中常见的核心功能. 这样就不需要在你的JSP应用中混合使用来自不同厂商的各种标签. 它是单一的,标准的,标签集合. 这种标准化允许你部署应用到支持JSTL的任意JSP容器时感觉更容易,更易对标签实现进行优化.

JSTL有用于处理控制流的迭代和条件标签, 用于操作XML文档的标签,国际化标签,通过SQL访问数据库的标签和常用功能标签.

Java EE 7平台要求JSTL 1.2.

1.7.6 Java Persistence API

The Java Persistence API (JPA) is a Java standards–based solution for persistence. Persistence uses an object/relational mapping approach to bridge the gap between an object-oriented model and a relational database. The Java Persistence API can also be used in Java SE applications outside of the Java EE environment. Java Persistence consists of the following areas:

  • The Java Persistence API
  • The query language
  • Object/relational mapping metadata

The Java EE 7 platform requires Java Persistence API 2.1.

1.7.6 Java持久化API

Java持久化API (JPA)基于Java标准的持久化解决方案. 使用一个对象/关系映射方法将面向的对象模型和关系数据库桥接起来.Java持久化API也可以在非Java EE环境的Java SE应用中使用. Java持久化涉及以下方面:

  • Java持久化API
  • 查询语言
  • 对象/关系映射元数据

Java EE 7平台要求Java持久化API 2.1.

1.7.7 Java Transaction API

The Java Transaction API (JTA) provides a standard interface for demarcating transactions. The Java EE architecture provides a default auto commit to handle transaction commits and rollbacks. An auto commit means that any other applications that are viewing data will see the updated data after each database read or write operation. However, if your application performs two separate database access operations that depend on each other, you will want to use the JTA API to demarcate where the entire transaction, including both operations, begins, rolls back, and commits.

The Java EE 7 platform requires Java Transaction API 1.2.

1.7.7 Java 交易 API

Java 交易 API (JTA) 提供一个标准的标定交易界面. Java EE架构默认自动提交事务,当然也可以手动提交和回滚事务. 自动提交意味着其他任何应用都能及时看到每个数据库读写操作后的最新数据. 但是,如果您的应用执行依赖于两个相互独立的数据库访问操作, 你将需要使用JTA来标定整个事务交易, 包含两个操作, 开始, 回滚或提交.

Java EE 7平台要求Java交易API 1.2.

1.7.8 Java API for RESTful Web Services

The Java API for RESTful Web Services (JAX-RS) defines APIs for the development of web services built according to the Representational State Transfer (REST) architectural style. A JAX-RS application is a web application that consists of classes packaged as a servlet in a WAR file along with required libraries.

The Java EE 7 platform requires JAX-RS 2.0.

1.7.8 RESTful WEB服务 Java API

RESTful WEB服务 Java API(JAX-RS) 是为构建具象状态传输(REST)风格的WEB服务开发定义的API. JAX-RS应用是一个web应用,其是在WAR文件中由类封装并依赖相关库的servlet组成.

Java EE 7平台要求JAX-RS 2.0.

1.7.9 Managed Beans

Managed Beans, lightweight container-managed objects (POJOs) with minimal requirements, support a small set of basic services, such as resource injection, lifecycle callbacks, and interceptors. Managed Beans represent a generalization of the managed beans specified by JavaServer Faces technology and can be used anywhere in a Java EE application, not just in web modules.

The Managed Beans specification is part of the Java EE 7 platform specification (JSR 342). The Java EE 7 platform requires Managed Beans 1.0.

1.7.9 托管Bean

托管Bean最低需求的轻便容器管理对象(POJOs),支持最基本的服务, 例如资源注入, 生命周期回调和拦截器. JavaServer Faces技术中指定的托管bean为代表,它可以在任意Java EE应用中使用, 并不限于web模块.

托管bean规范是Java EE 7平台规范(JSR 342)的一部分. Java EE 7要求Managed Beans 1.0.

1.7.10 Contexts and Dependency Injection for Java EE

Contexts and Dependency Injection for Java EE (CDI) defines a set of contextual services, provided by Java EE containers, that make it easy for developers to use enterprise beans along with JavaServer Faces technology in web applications. Designed for use with stateful objects, CDI also has many broader uses, allowing developers a great deal of flexibility to integrate different kinds of components in a loosely coupled but typesafe way.

The Java EE 7 platform requires CDI 1.1.

1.7.10 Java EE的上文依赖注入

Java EE中的上下文依赖注入 (CDI) 定义了一组上下文服务,通过Java EE提供的容器,其让开发人员在web应用中使用JavaServer Faces技术时更容易使用企业bean. 通过状态化对象的使用使CDI具有更多的用途, 允许开发人员灵活的将不同类型组件以松散耦合但类型安全的形式集成在一起.

Java EE 7平台要求CDI 1.1.

1.7.11 Dependency Injection for Java

Dependency Injection for Java defines a standard set of annotations (and one interface) for use on injectable classes.

In the Java EE platform, CDI provides support for Dependency Injection. Specifically, you can use injection points only in a CDI-enabled application.

The Java EE 7 platform requires Dependency Injection for Java 1.0.

1.7.11 Java的依赖注入

Java的依赖注入为使用可注入类定义了一套标准的注解(或接口).

在Java EE平台中, CDI为依赖注入提供支持. 具体而言,你只能在启用CDI的应用中使用注入点.

Java EE 7平台要求Java依赖注入1.0.

1.7.12 Bean Validation

The Bean Validation specification defines a metadata model and API for validating data in JavaBeans components. Instead of distributing validation of data over several layers, such as the browser and the server side, you can define the validation constraints in one place and share them across the different layers.

The Java EE 7 platform requires Bean Validation 1.1.

1.7.12 Bean验证器

Bean验证器为在JavaBeans组件中校验数据定义了一套元数据模型和API. 替代了在不同的层分别验证数据的方式, 例如,在浏览器和服务器端中, 你可以在一个地方定义在不同层之间共享的验证约束.

Java EE 7平台要求Bean验证器1.1.

1.7.13 Java Message Service API

The Java Message Service (JMS) API is a messaging standard that allows Java EE application components to create, send, receive, and read messages. It enables distributed communication that is loosely coupled, reliable, and asynchronous.

In the platform, new features of JMS include the following.

  • A new, simplified API offers a simpler alternative to the previous API. This API includes a JMSContext object that combines the functions of a Connection and a Session.
  • All objects with a close method implement the java.lang.Autocloseable interface so that they can be used in a Java SE 7 try-with-resources statement.

The Java EE 7 platform requires JMS 2.0.

1.7.13 Java消息服务API

Java消息服务(JMS) API是一种消息标准,其允许Java EE应用组件创建,发送,接收和读取消息.支持分布式通讯且是松散耦合的,可靠的并支持异步.

在平台中,JMS包含以下新功能

  • 一个新的,简单的,简化API以替代先前的API. 此API包含一个JMS内容对象,其合并了连接与会话功能.
  • 所有对象均实现java.lang.Autocloseable结构的close方法,这使得它们可以同Java SE 7资源尝试声明一起使用.

Java EE 7平台要求JMS 2.0.

1.7.14 Java EE Connector Architecture

The Java EE Connector Architecture is used by tools vendors and system integrators to create resource adapters that support access to enterprise information systems that can be plugged in to any Java EE product. A resource adapter is a software component that allows Java EE application components to access and interact with the underlying resource manager of the EIS. Because a resource adapter is specific to its resource manager, a different resource adapter typically exists for each type of database or enterprise information system.

The Java EE Connector Architecture also provides a performance-oriented, secure, scalable, and message-based transactional integration of Java EE platform–based web services with existing EISs that can be either synchronous or asynchronous. Existing applications and EISs integrated through the Java EE Connector Architecture into the Java EE platform can be exposed as XML-based web services by using JAX-WS and Java EE component models. Thus JAX-WS and the Java EE Connector Architecture are complementary technologies for enterprise application integration (EAI) and end-to-end business integration.

The Java EE 7 platform requires Java EE Connector Architecture 1.7.

1.7.14 Java EE 连接器体系结构

Java EE 连接器体系结构被工具商和系统集成商用于创建资源适配器以支持访问企业信息系统,可以插入到任何Java EE产品. 一个资源适配器是一个软件组件,它允许Java EE应用组件通过EIS相关的资源适配管理器交互访问. 因为资源适配器是一个有针对性的资源管理器, 所以每个数据库和企业信息系统都有不同的资源适配器.

Java EE 连接器体系结构还提供现有EIS的Java EE平台WEB服务的性能导向, 安全, 可伸缩和基于消息的事务集成,它可以是同步或异步的. 要将现有应用和EIS集成通过Java EE连接器体系结构插入到Java EE平台,可以使用JAX-WS和Java EE组件模型暴露的基于XML的WEB服务实现. 因此,JAX-WS和Java EE连接器体系结构在为企业应用集成(EAI)和终端到终端的业务整合中是互补的技术.

Java EE 7平台要求Java EE连接器体系结构1.7.

1.7.15 JavaMail API

Java EE applications use the JavaMail API to send email notifications. The JavaMail API has two parts:

  • An application-level interface used by the application components to send mail
  • A service provider interface

The Java EE platform includes the JavaMail API with a service provider that allows application components to send Internet mail.

The Java EE 7 platform requires JavaMail 1.5.

1.7.15 JavaMail API

Java EE应用使用JavaMail API发送邮件通知. JavaMail API有两部分:

  • 一个用于应用组件发送邮件的应用级接口
  • 一个服务提供界面

Java EE platform平台包含提供服务的JavaMail API,其允许允许应用组件发送内部邮件.

Java EE 7平台要求JavaMail 1.5.

1.7.16 Java Authorization Contract for Containers

The Java Authorization Contract for Containers (JACC) specification defines a contract between a Java EE application server and an authorization policy provider. All Java EE containers support this contract.

The JACC specification defines java.security.Permission classes that satisfy the Java EE authorization model. The specification defines the binding of container-access decisions to operations on instances of these permission classes. It defines the semantics of policy providers that use the new permission classes to address the authorization requirements of the Java EE platform, including the definition and use of roles.

The Java EE 7 platform requires JACC 1.5.

1.7.16 Java容器认证约定

Java容器认证约定(JACC)规范定义了Java EE应用服务器和授权策略提供者之间的约定.所有Java EE服务器都支持此约定.

JACC规范定义java.security.Permission类,其符合Java EE的认证模型.该规范定义了权限类实例访问容器时从决定到操作的强制约束. 它定义新的策略语意,使用新的权限类处理Java EE平台授权需求, 包括角色的定义和使用.

Java EE 7平台要求JACC 1.5.

1.7.17 Java Authentication Service Provider Interface for Containers

The Java Authentication Service Provider Interface for Containers (JASPIC) specification defines a service provider interface (SPI) by which authentication providers that implement message authentication mechanisms may be integrated in client or server message-processing containers or runtimes. Authentication providers integrated through this interface operate on network messages provided to them by their calling containers. The authentication providers transform outgoing messages so that the source of each message can be authenticated by the receiving container, and the recipient of the message can be authenticated by the message sender. Authentication providers authenticate each incoming message and return to their calling containers the identity established as a result of the message authentication.

The Java EE 7 platform requires JASPIC 1.1.

1.7.17 Java容器认证服务提供接口

Java容器认证服务提供接口(JASPIC)为授权提供者规范定义了服务提供接口(SPI),其实现的消息认证机制可以集成到客户端,服务器消息处理容器或运行时中. 在他们呼叫容器时提供的网络消息上通过此接口提供集成验证操作. 认证程序转换输出消息,使接收容器可以验证每个消息来源, 并且消息接受者可以验证消息发送者身份. 验证提供程序验证每个传入的消息并把消息认证确定的身份返回给调用容器.

Java EE 7要求JASPIC 1.1.

1.7.18 Java API for WebSocket

WebSocket is an application protocol that provides full-duplex communications between two peers over TCP. The Java API for WebSocket enables Java EE applications to create endpoints using annotations that specify the configuration parameters of the endpoint and designate its lifecycle callback methods.

The WebSocket API is new to the Java EE 7 platform. The Java EE 7 platform requires Java API for WebSocket 1.0.

1.7.18 WebSocket的Java API

WebSocket是一种应用协议.它为两个等同TCP提供全双工通讯. WebSocket的Java API使Java EE应用程序可以使用指定端点的配置参数,并指定其生命周期回调方法的注解来创建端点.

Java EE 7平台支持WebSocket API. Java EE 7平台要求WebSocket API 1.0.

1.7.19 Java API for JSON Processing

JSON is a text-based data exchange format derived from JavaScript that is used in web services and other connected applications. The Java API for JSON Processing (JSON-P) enables Java EE applications to parse, transform, and query JSON data using the object model or the streaming model.

JSON-P is new to the Java EE 7 platform. The Java EE 7 platform requires JSON-P 1.0.

1.7.19 用于处理JSON的Java API

JSON是从JavaScript导出的基于文本的数据交换格式.其用于web服务或其他应用连接.用于JSON处理(JSON-P)的Java API使Java EE应用可以使用对象模型或流模型解析,转换和查询JSON数据.

Java EE 7平台支持JSON-P. Java EE 7平台要求JSON-P 1.0.

1.7.20 Concurrency Utilities for Java EE

Concurrency Utilities for Java EE is a standard API for providing asynchronous capabilities to Java EE application components through the following types of objects: managed executor service, managed scheduled executor service, managed thread factory, and context service.

Concurrency Utilities for Java EE is new to the Java EE 7 platform. The Java EE 7 platform requires Concurrency Utilities for Java EE 1.0.

1.7.20 Java EE并发工具

Java EE并发工具是为Java EE应用组件操作以下对象类型异步性能提供的标准API: 管理执行服务,管理计划执行服务,管理线程工厂和上下文服务.

Java EE 7平台支持Java EE并发工具. Java EE 7平台要求Java EE并发工具1.0.

1.7.21 Batch Applications for the Java Platform

Batch jobs are tasks that can be executed without user interaction. The Batch Applications for the Java Platform specification is a batch framework that provides support for creating and running batch jobs in Java applications. The batch framework consists of a batch runtime, a job specification language based on XML, a Java API to interact with the batch runtime, and a Java API to implement batch artifacts.

Batch Applications for the Java Platform is new to the Java EE 7 platform. The Java EE 7 platform requires Batch Applications for the Java Platform 1.0.

1.7.21 Java平台批处理应用

批处理作业是无需用户交互的执行任务.Java EE批处理应用是为在Java EE应用中创建和运行批处理作业提供支持的Java EE平台规范的批处理框架. 此批处理框架由批处理运行时构成, 一个基于XML的作业规范语言, 一组用于批处理运行时交互的Java API和一组用于实现批处理工件的Java API.

Java EE 7平台支持批处理应用. Java EE 7平台要求Java平台批处理应用1.0.

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