Java EE 7 教程 第一部分 简介 第2章 使用教程示例 第2.2节 启动和停止GlassFish服务器
原文：http://docs.oracle.com/javaee/7/tutorial/doc/usingexamples002.htm翻译：石卓林 shizhuolin@hotmail.com2.2 Starting and Stopping GlassFish ServerYou can start and stop GlassFish Server using either NetBeans IDE or the command line.2.2 启动和停止GlassFish服务器你可以使用NetBeans IDE或命令行启动和停止GlassFish服务器.2.2.1 To Start GlassFish Server Using NetBeans IDEClick the Services tab.Expand Servers.Right-click the GlassFish Server instance and select Start.2.2.1 使用NetBeans IDE启动GlassFish服务器点击Services选项卡.展开Servers.右键点击GlassFish服务器实例，选择Start.2.2.2 To Stop GlassFish Server Using NetBeans IDETo stop GlassFish Server using NetBeans IDE, right-click the GlassFish Server instance and select Stop.2.2.2 使用NetBeans IDE停止GlassFish服务器要使用NetBeans IDE停止服务器,请右键点击GlassFish服务器实例并选择Stop.2.2.3 To Start GlassFish Server Using the Command LineTo start GlassFish Server from the command line, open a terminal window or command prompt and execute the following:asadmin start-domain --verboseA domain is a set of one or more GlassFish Server instances managed by one administration server. The following elements are associated with a domain:The GlassFish Server port number: The default is 8080.The administration server's port number: The default is 4848.An administration user name and password: The default user name is admin, and by default no password is required.You specify these values when you install GlassFish Server. The examples in this tutorial assume that you chose the default ports as well as the default user name and lack of password.With no arguments, the start-domain command initiates the default domain, which is domain1. The --verbose flag causes all logging and debugging output to appear on the terminal window or command prompt. The output also goes into the server log, which is located in domain-dir/logs/server.log.Or, on Windows, from the Start menu, choose All Programs, then choose Java EE 7 SDK, then choose Start Application Server.2.2.3 使用命令行启动GlassFish服务器要从命令行启动GlassFish服务器, 打开一个终端窗口或命令提示框并执行以下操作:asadmin start-domain --verbose一个domain是管理服务中托管的一个或多个GlassFish服务器实例的集合，一个域有以下相关元素:GlassFish服务器端口: 默认是8080.服务器的管理端口: 默认是4848.一组管理用户名和密码: 默认用户名是admin, 默认是空密码.在你安装GlassFish服务器时指定这些值, 本教程中的示例假定你选择了默认端口,默认用户名和缺省密码.在不带参数的情况下,start-domain命令启动默认域, 就是domain1. 使用--verbose标志则将在终端窗口或命令提示框中显示所有的日志记录和调试输出. 这些输出也被写入服务器日志, 日志文件位于domain-dir/logs/server.log.如果在Windows平台启动, 访问Start菜单, 选择All Programs, 然后选择Java EE 7 SDK, 再选择Start Application Server.2.2.4 To Stop GlassFish Server Using the Command LineTo stop GlassFish Server, open a terminal window or command prompt and execute:asadmin stop-domain domain1Or, on Windows, from the Start menu, choose All Programs, then choose Java EE 7 SDK, then choose Stop Application Server.2.2.4 使用命令行停止GlassFish服务器要停止GlassFish服务器, 打开一个终端窗口或命令提示框并执行:asadmin stop-domain domain1或在Windows上, 访问Start菜单, 选择All Programs, 然后选择Java EE 7 SDK, 再选择Stop Application Server.
Java EE 7 教程 第一部分 简介 第2章 使用教程示例 第2.1节 需要的软件
原文：http://docs.oracle.com/javaee/7/tutorial/doc/usingexamples001.htm翻译：石卓林 shizhuolin@hotmail.com2.1 Required SoftwareThe following software is required to run the examples:Java Platform, Standard EditionJava EE 7 Software Development KitJava EE 7 Tutorial ComponentNetBeans IDEApache Maven2.1 需要的软件以下是运行示例需要的软件:Java平台,标准版Java EE 7软件开发工具包Java EE 7教程组件NetBeans IDEApache Maven2.1.1 Java Platform, Standard EditionTo build, deploy, and run the examples, you need a copy of the Java Platform, Standard Edition 7 Development Kit (JDK 7). Some distributions of the Java EE 7 SDK include JDK 7. You can download JDK 7 software separately from http://www.oracle.com/technetwork/java/javase/downloads/index.html.2.1.1 Java平台,标准版要构建，部署和运行此示例, 你需要一个Java平台副本, 标准版 7开发工具包(JDK 7). 在一些Java EE 7 SDK发行版中包含JDK 7. 你可以在 http://www.oracle.com/technetwork/java/javase/downloads/index.html 单独下载JDK7.2.1.2 Java EE 7 Software Development KitGlassFish Server Open Source Edition 4 is targeted as the build and runtime environment for the tutorial examples. To build, deploy, and run the examples, you need a copy of GlassFish Server and, optionally, NetBeans IDE. To obtain GlassFish Server, you must install the Java EE 7 Software Development Kit (SDK), which you can download from http://www.oracle.com/technetwork/java/javaee/downloads/index.html. Make sure that you download the Java EE 7 SDK, not the Java EE 7 Web Profile SDK. There are distributions of the Java EE 7 SDK with and without the Java Platform, Standard Edition 7 Development Kit.2.1.2 Java EE 7软件开发工具包GlassFish服务器开源版4是针对本示例的构建和运行环境.要构建，部署和运行本示例, 你需要一份GlassFish服务器副本和可选的NetBeans IDE. 要获得GlassFish服务器,你必须安装Java EE 7软件开发工具包(SDK), 你可以在 http://www.oracle.com/technetwork/java/javaee/downloads/index.html 下载这些软件. 确认你下载的是Java EE 7 SDK而不是Java EE 7 Web Profile SDK. 这些是Java EE 7 SDK发行而不是Java平台标准版7软件开发包.2.1.2.1 SDK Installation TipsDo the following during the installation of the SDK.Allow the installer to download and configure the Update Tool. If you access the Internet through a firewall, provide the proxy host and port.Configure the GlassFish Server administration user name as admin, and specify no password. This is the default setting.Accept the default port values for the Admin Port (4848) and the HTTP Port (8080).Do not select the check box to create an operating system service for the domain.You can leave the check box to start the domain after creation selected if you wish, but this is not required.This tutorial refers to as-install-parent, the directory where you install GlassFish Server. For example, the default installation directory on Microsoft Windows is C:\glassfish4, so as-install-parent is C:\glassfish4. GlassFish Server itself is installed in as-install, the glassfish directory under as-install-parent. So on Microsoft Windows, as-install is C:\glassfish4\glassfish.After you install GlassFish Server, add the following directories to your PATH to avoid having to specify the full path when you use commands:as-install-parent/binas-install/bin2.1.2.1 SDK安装提示在SDK安装过程中注意下几点.允许安装程序下载和配置更新工具. 如果你通过防火墙访问internet,可能需要提供代理主机和端口.配置GlassFish服务器管理用户名为admin且不设置密码. 这是默认设置.同意Admin端口(4848)和HTTP端口(8080)的默认端口值.不要选择复选框以免为域创建操作系统服务.如果你想要的话，你可以在启动域后选中创建复选筐，但这不是必须的.本教程被放到as-install-parent中, 此目录就是你安装GlassFish服务器的地方.例如,在Microsoft Windows上默认安装目录是C:\glassfish4, 所有 as-install-parent 就是 C:\glassfish4. GlassFish服务器自己被安装到as-install中, glassfish目录在as-install-parent内. 所有在Microsoft Windows上as-install就是C:\glassfish4\glassfish.安装GlassFish服务器后, 添加以下目录到你的PATH中，以避免你使用命令时需要输入全部的路径:as-install-parent/binas-install/bin2.1.3 Java EE 7 Tutorial ComponentThe tutorial example source is contained in the tutorial component. To obtain the tutorial component, use the Update Tool.2.1.3 Java EE 7 教程组件本教程示例源码包含在教程组件中.可以使用更新工具获取教程组件.2.1.3.1 To Obtain the Tutorial Component Using the Update ToolStart the Update Tool by performing one of the following actions.From the command line, enter the command updatetool.On a Windows system, from the Start menu, choose All Programs, then choose Java EE 7 SDK, then choose Start Update Tool.Expand the Java EE 7 SDK node.Select Available UpdatesFrom the list, select the Java EE 7 Tutorial check box.Click Install.Accept the license agreement.After installation, the Java EE 7 Tutorial appears in the list of installed components. The tool is installed in the as-install-parent/docs/javaee-tutorial directory, which is referred to throughout the tutorial as tut-install. This directory contains two subdirectories: docs and examples. The examples directory contains subdirectories for each of the technologies discussed in the tutorial.Next StepsUpdates to the Java EE 7 Tutorial are published periodically. For details on obtaining these updates, see Getting the Latest Updates to the Tutorial.2.1.3.1 使用更新工具获取教程组件通过执行以下操作之一启动更新工具.在命令行中输入命令 updatetool.在Windows系统上, 点击开始菜单, 选择所有程序, 再选择Java EE 7 SDK, 在选择Start Update Tool.展开Java EE 7 SDK节点.选择Available Updates在列表中选中Java EE 7 Tutorial复选筐.点击Install.同意许可协议. 安装后, Java EE 7 教程出现在已安装组件列表中. 工具被安装在as-install-parent/docs/javaee-tutorial目录, 那些被提到的教程在tut-install. 此目录包含两个子目录:docs和examples. examples目录包含教程中提到的每个技术子目录.下一步Java EE 7教程更新会定期发布. 要获取有关更新的信息, 请查看获取教程的最近更新.2.1.4 NetBeans IDEThe NetBeans integrated development environment (IDE) is a free, open-source IDE for developing Java applications, including enterprise applications. NetBeans IDE supports the Java EE platform. You can build, package, deploy, and run the tutorial examples from within NetBeans IDE.To run the tutorial examples, you need the latest version of NetBeans IDE. You can download NetBeans IDE from https://www.netbeans.org/downloads/index.html Make sure that you download the Java EE bundle.2.1.4 NetBeans IDENetBeans 集成开发环境是一个免费的,发展中的开源IDE和Java应用程序, 包括企业应用. NetBeans IDE支持Java EE 平台. 你可以在NetBeans IDE中构建，打包，部署和运行教程示例.要运行教程示例, 你需要NetBeans IDE的最新版本. 你可以在 https://www.netbeans.org/downloads/index.html 下载NetBeans IDE. 确保您下载的是Java EE包.2.1.4.1 To Install NetBeans IDE without GlassFish ServerWhen you install NetBeans IDE, do not install the version of GlassFish Server that comes with NetBeans IDE. To skip the installation of GlassFish Server, follow these steps.On the first page of the NetBeans IDE Installer wizard, deselect the check box for GlassFish Server and click OK.Accept both the License Agreement and the Junit License Agreement.A few of the tutorial examples use the Junit library, so you should install it.Continue with the installation of NetBeans IDE.2.1.4.1 安装不含GlassFish服务器的NetBeans IDE要安装NetBeans IDE,但是不想安装NetBeans IDE附带的GlassFish服务器版本. 也就是说想跳过GlassFish服务器安装,请参看以下步骤.在NetBeans IDE安装向导第一页,脱选GlassFish服务器复选框,点击OK.同时接受许可协议和Junit许可协议.有少数学习示例使用Junit库,所以你需要安装它.继续NetBeans IDE安装进程.2.1.4.2 To Add GlassFish Server as a Server Using NetBeans IDETo run the tutorial examples in NetBeans IDE, you must add your GlassFish Server as a server in NetBeans IDE. Follow these instructions to add GlassFish Server to NetBeans IDE.From the Tools menu, choose Servers.In the Servers wizard, click Add Server.Under Choose Server, select GlassFish Server and click Next.Under Server Location, browse to the location of the Java EE 7 SDK and click Next.Under Domain Location, select Register Local Domain.Click Finish.2.1.4.2 添加GlassFish服务器作为NetBeans IDE用服务器为了在NetBeans IDE中运行学习示例,你必须添加你的GlassFish服务器作为NetBeans IDE中的服务器. 以下介绍了如何添加GlassFish服务器到NetBeans IDE.在Tools菜单中选择Servers.在服务器向导中点击Add Server.在Choose Server内选择GlassFish Server并且点击Next.在Server Location内定位到Java EE 7 SDK并且点击Next.在Domain Location中选择Register Local Domain.点击Finish.2.1.5 Apache MavenMaven is a Java technology–based build tool developed by the Apache Software Foundation and is used to build, package, and deploy the tutorial examples. To run the tutorial examples from the command line, you need Maven 3.0 or higher. If you do not already have Maven, you can install it from: http://maven.apache.orgBe sure to add the maven-install/bin directory to your path.If you are using NetBeans IDE to build and run the examples, it includes a copy of Maven.2.1.5 Apache MavenMaven是一个基于Java技术的构建工具,由Apache软件基金会开发.用于其构建,打包和部署学习示例.为了在命令行中运行学习示例,你需要Maven 3.0或更高版本. 如果你没有准备好Maven,你可以从: http://maven.apache.org 获取并安装它确认添加maven-install/bin目录到你的path.如果你使用NetBeans IDE构建和运行示例,则不需要做额外工作,因为它已经包含Maven副本.
Java EE 7 教程 第一部分 简介 第2章 使用教程示例
原文：http://docs.oracle.com/javaee/7/tutorial/doc/usingexamples.htm翻译：石卓林 shizhuolin@hotmail.com2 Using the Tutorial ExamplesThis chapter tells you everything you need to know to install, build, and run the examples.The following topics are addressed here:Required SoftwareStarting and Stopping GlassFish ServerStarting the Administration ConsoleStarting and Stopping the Java DB ServerBuilding the ExamplesTutorial Example Directory StructureJava EE 7 Maven Archetypes in the TutorialGetting the Latest Updates to the TutorialDebugging Java EE Applications2 使用教程示例本章将告诉你你需要知道的安装，构建和运行示例的一切.以下是话题链接:需要的软件启动和停止GlassFish服务器启动管理控制台启动和停止Java DB服务器构建示例学习示例的目录结构教程中的Java EE 7 Maven原型获取最新的教程更新调试Java EE应用程序
Java EE 7 教程 第一部分 简介 第1章 概述 第1.9节 GlassFish服务器工具
原文：http://docs.oracle.com/javaee/7/tutorial/doc/overview009.htm翻译：石卓林 shizhuolin@hotmail.com1.9 GlassFish Server ToolsGlassFish Server is a compliant implementation of the Java EE 7 platform. In addition to supporting all the APIs described in the previous sections, GlassFish Server includes a number of Java EE tools that are not part of the Java EE 7 platform but are provided as a convenience to the developer.This section briefly summarizes the tools that make up GlassFish Server. Instructions for starting and stopping GlassFish Server, starting the Administration Console, and starting and stopping the Java DB server are in Chapter 2, "Using the Tutorial Examples".GlassFish Server contains the tools listed in Table 1-1. Basic usage information for many of the tools appears throughout the tutorial. For detailed information, see the online help in the GUI tools. *Table 1-1 GlassFish Server Tools* Tool Description Administration Console A web-based GUI GlassFish Server administration utility. Used to stop GlassFish Server and to manage users, resources, and applications. asadmin A command-line GlassFish Server administration utility. Used to start and stop GlassFish Server and to manage users, resources, and applications. appclient A command-line tool that launches the application client container and invokes the client application packaged in the application client JAR file. capture-schema A command-line tool to extract schema information from a database, producing a schema file that GlassFish Server can use for container-managed persistence. package-appclient A command-line tool to package the application client container libraries and JAR files. Java DB database A copy of the Java DB server. xjc A command-line tool to transform, or bind, a source XML schema to a set of JAXB content classes in the Java programming language. schemagen A command-line tool to create a schema file for each namespace referenced in your Java classes. wsimport A command-line tool to generate JAX-WS portable artifacts for a given WSDL file. After generation, these artifacts can be packaged in a WAR file with the WSDL and schema documents, along with the endpoint implementation, and then deployed. wsgen A command-line tool to read a web service endpoint class and generate all the required JAX-WS portable artifacts for web service deployment and invocation. 1.9 GlassFish服务器工具GlassFish服务器是Java EE 7平台的一种兼容实现. 除了支持前面章节介绍的所有API, 为了方便开发者,GlassFish服务器还包含不属于Java EE平台的一部分的Java EE工具.此章节简单叙述了整理自GlassFish服务器的工具.在第2章, "使用教学示例"中介绍了如何启动和停止GlassFish服务器, 启动管理控制台,启动和停止Java DB服务器 .表 1-1中列举了GlassFish服务器包含的工具.出现在本教程中的工具的基本信息. 欲了解详细信息,请查看GUI工具在线帮助. *表 1-1 GlassFish服务器工具* 工具 说明 管理控制台 一个基于WEB的GUI多功能实用管理工具.用于停止GlassFish服务器和管理用户,资源,应用. asadmin 一个命令行的多功能实用管理工具. 用于启动和停止GlassFish服务器和管理用户,资源,应用. appclient 一个命令行工具,用于启动应用客户端容器并调用封装在应用客户端JAR文件中的客户端应用. capture-schema 一个用于从数据库中提取架构信息的命令行工具, 产生GlassFish服务器可用的容器管理持久化架构文件. package-appclient 一个用于打包应用客户端容器库和JAR文件的命令行工具. Java DB数据库 一份Java DB服务器拷贝. xjc 一个用于转换,绑定XML架构源到Java程序语言JAXB内容类的命令行工具 schemagen 一个命令行工具,用于为你的Java类中每个命名空间引用创建架构文件 wsimport 一个命令行工具,用于为特定WSDL文件生成JAX-WS可移植工件. 生成后这些工件后, 这些工件可以和WSDL,架构文档一起打包到WAR文件中, 然后联同终端实现一起部署. wsgen 一个命令行工具,用于读取WEB服务终端类并为web服务部署和调用生成所有必须的JAX-WS可移植工件.
Java EE 7 教程 第一部分 简介 第1章 概述 第1.8节 Java平台中的Java EE 7 API, 标准版7
原文：http://docs.oracle.com/javaee/7/tutorial/doc/overview008.htm翻译：石卓林 shizhuolin@hotmail.com1.8 Java EE 7 APIs in the Java Platform, Standard Edition 7Several APIs that are required by the Java EE 7 platform are included in the Java Platform, Standard Edition 7 (Java SE 7) and are thus available to Java EE applications.1.8 Java平台中的Java EE 7 API, 标准版 7Java EE 7平台所必须的Several API包含在Java平台标准版7(Java SE 7)中,从而可用于Java EE应用.1.8.1 Java Database Connectivity APIThe Java Database Connectivity (JDBC) API lets you invoke SQL commands from Java programming language methods. You use the JDBC API in an enterprise bean when you have a session bean access the database. You can also use the JDBC API from a servlet or a JSP page to access the database directly without going through an enterprise bean.The JDBC API has two parts:An application-level interface used by the application components to access a databaseA service provider interface to attach a JDBC driver to the Java EE platformThe Java SE 7 platform requires JDBC 4.1.1.8.1 Java数据库连接APIJava数据库连接(JDBC) API让你可以在Java程序语言方法中调用SQL命令. 当你有一个会话bean访问数据库时你可以在企业bean中使用JDBC API. 当然你也可以在servlet或jsp页面中使用JDBC API直接连接数据库而不需要通过企业bean.JDBC API包含两部分:一个用于应用组件访问数据库的应用级接口一个用于在Java EE平台中附加JDBC驱动的服务提供接口Java SE 7平台要求JDBC 4.1.1.8.2 Java Naming and Directory Interface APIThe Java Naming and Directory Interface (JNDI) API provides naming and directory functionality, enabling applications to access multiple naming and directory services, such as LDAP, DNS, and NIS. The JNDI API provides applications with methods for performing standard directory operations, such as associating attributes with objects and searching for objects using their attributes. Using JNDI, a Java EE application can store and retrieve any type of named Java object, allowing Java EE applications to coexist with many legacy applications and systems.Java EE naming services provide application clients, enterprise beans, and web components with access to a JNDI naming environment. A naming environment allows a component to be customized without the need to access or change the component's source code. A container implements the component's environment and provides it to the component as a JNDI naming context.The naming environment provides four logical namespaces: java:comp, java:module, java:app, and java:global for objects available to components, modules, or applications or shared by all deployed applications. A Java EE component can access named system-provided and user-defined objects. The names of some system-provided objects, such as a default JDBC DataSource object, a default JMS connection factory, and a JTA UserTransaction object, are stored in the java:comp namespace. The Java EE platform allows a component to name user-defined objects, such as enterprise beans, environment entries, JDBC DataSource objects, and messaging destinations.A Java EE component can also locate its environment naming context by using JNDI interfaces. A component can create a javax.naming.InitialContext object and look up the environment naming context in InitialContext under the name java:comp/env. A component's naming environment is stored directly in the environment naming context or in any of its direct or indirect subcontexts.1.8.2 Java命名和目录接口APIJava命名和目录接口(JNDI) API提供命名和目录服务功能, 使应用可以访问多个命名和目录服务,例如LDAP, DNS和NIS. 此JNDI API提供了应用和方法以处理标准目录操作, 例如对象属性访问和使用属性搜索对象. 使用JNDI,Java EE应用可以存储和恢复任意Java命名对象类型, 允许Java EE应用与很多传统应用和系统共存.Java EE命名服务为应用客户端,企业bean和web组件访问JNDI命名提供环境. 一个命名环境允许自定义组件访问而不需要更改组件源码. 容器实现组件的环境,并将其提供给该组件作为JNDI命名上下文.此命名环境为所有部署应用中的有效组件，模块，应用或共享等对象提供四种逻辑命名空间: java:comp, java:module, java:app和java:global. 一个Java EE组件可以访问系统命名提供的或用户定义的对象. 一些系统提供的对象的名称, 例如一个默认的JDBC数据源对象,一个默认的JMS连接工厂和默认的JTA用户事务对象, 包括被存储在java：comp命名空间中的对象. Java EE 平台允许用户定义组件为命名对象,例如企业bean,环境项, JDBC数据源对象和消息目的地.在Java EE组件中还可以通过使用JNDI接口找到它的环境命名上下文. 一个组件可以创建一个javax.naming.InitialContext对象并且在InitialContext中的java:comp/env名称中查询环境命名上下文.组件的命名环境是直接存储在环境命名上下文或任何直接或间接的子上下文中.1.8.3 JavaBeans Activation FrameworkThe JavaBeans Activation Framework (JAF) is used by the JavaMail API. JAF provides standard services to determine the type of an arbitrary piece of data, encapsulate access to it, discover the operations available on it, and create the appropriate JavaBeans component to perform those operations.1.8.3 JavaBeans活化框架JavaBeans活化框架(JAF)用于JavaMail API. JAF提供标准服务以确定任意数据类型,封装其访问,发现其可用操作并且创建相应的JavaBean组件来执行这些操作.1.8.4 Java API for XML ProcessingThe Java API for XML Processing (JAXP), part of the Java SE platform, supports the processing of XML documents using Document Object Model (DOM), Simple API for XML (SAX), and Extensible Stylesheet Language Transformations (XSLT). JAXP enables applications to parse and transform XML documents independently of a particular XML-processing implementation.JAXP also provides namespace support, which lets you work with schemas that might otherwise have naming conflicts. Designed to be flexible, JAXP lets you use any XML-compliant parser or XSL processor from within your application and supports the Worldwide Web Consortium (W3C) schema. You can find information on the W3C schema at http://www.w3.org/XML/Schema.1.8.4 用于XML处理的Java API用于XML处理的Java API(JAXP)是Java SE平台的一部分,其支持使用文档对象模型(DOM)处理XML文档, XML简单API(SAX)和扩展样式语言转换(XSLT). JAXP使应用程序可以使用特定XML处理实现做到独立解析和转换XML文档.JAXP也提供命名空间支持, 可以在你有可能的命名冲突时使用架构工作.通过灵活设计, JAXP让你可以在你的应用中使用任意的适合的XML解析器和XSL处理器,并且支持万维网WEB联盟(W3C)架构.你可以在W3C计划 http://www.w3.org/XML/Schema 中找到相关信息.1.8.5 Java Architecture for XML BindingThe Java Architecture for XML Binding (JAXB) provides a convenient way to bind an XML schema to a representation in Java language programs. JAXB can be used independently or in combination with JAX-WS, in which case it provides a standard data binding for web service messages. All Java EE application client containers, web containers, and EJB containers support the JAXB API.The Java EE 7 platform requires JAXB 2.2.1.8.5 用于XML绑定的Java体系结构用于XML绑定的体系结构(JAXB)为在Java语言程序中绑定XML架构到表现层提供便捷方法. JAXB可以单独使用或与JAX-WS组合使用, 它在一些案例中为web服务消息提供标准的数据绑定. 所有Java EE应用客户端容器,web容器和EJB容器支持JAXB API.Java EE 7平台要求JAXB 2.2.1.8.6 Java API for XML Web ServicesThe Java API for XML Web Services (JAX-WS) specification provides support for web services that use the JAXB API for binding XML data to Java objects. The JAX-WS specification defines client APIs for accessing web services as well as techniques for implementing web service endpoints. The Implementing Enterprise Web Services specification describes the deployment of JAX-WS-based services and clients. The EJB and Java Servlet specifications also describe aspects of such deployment. JAX-WS-based applications can be deployed using any of these deployment models.The JAX-WS specification describes the support for message handlers that can process message requests and responses. In general, these message handlers execute in the same container and with the same privileges and execution context as the JAX-WS client or endpoint component with which they are associated. These message handlers have access to the same JNDI namespace as their associated component. Custom serializers and deserializers, if supported, are treated in the same way as message handlers.The Java EE 7 platform requires JAX-WS 2.2.1.8.6 用于XML Web服务的Java API用于XML Web服务的Java API(JAX-WS)规范为在WEB服务中使用JAXB绑定XML数据和Java对象提供支持. JAX-WS规范为web服务客户端访问web服务的技术实现定义客户端API.实现了企业web服务规范化的基于JAX-WS的服务服务和客户端部署描述 . EJB和Java Servlet规范也为部署提供部分描述.基于JAX-WS的应用可以使用任意部署模型部署.JAX-WS规范描述为处理消息请求和响应的消息处理程序提供支持. 在通常情况中, 这些消息处理程序在同一个容器中用相同的权限和执行上下文的JAX-WS客户端或与其关联的终端组件一起执行. 这些消息处理程序可以访问相同的JNDI命名空间及其相关组件. 如果支持自定义序列化和反序列化的话, 则以同样的方式对待消息处理程序.Java EE 7平台要求JAX-WS 2.2.1.8.7 SOAP with Attachments API for JavaThe SOAP with Attachments API for Java (SAAJ) is a low-level API on which JAX-WS depends. SAAJ enables the production and consumption of messages that conform to the SOAP 1.1 and 1.2 specifications and the SOAP with Attachments note. Most developers do not use the SAAJ API, instead using the higher-level JAX-WS API.1.8.7 Java中附带的SOAP APIJava中附带的SOAP API(SAAJ)是一种依赖JAX-WS的低级API. SAAJ使消息的生产和消费尊从SOAP 1.1/1.2规范和附带的SOAP注释. 多数开发人员不使用SAAJ API,反而使用高级JAX-WS API.1.8.8 Java Authentication and Authorization ServiceThe Java Authentication and Authorization Service (JAAS) provides a way for a Java EE application to authenticate and authorize a specific user or group of users to run it.JAAS is a Java programming language version of the standard Pluggable Authentication Module (PAM) framework, which extends the Java platform security architecture to support user-based authorization.1.8.8 Java认证和认证服务Java和认证服务(JAAS)为Java EE应用授权和验证运行它的特定用户或组提供方法.JAAS是标准可插入认证模块框架的Java程序语言版本, 那些扩展的Java平台安全体系支持基于用户的认证.1.8.9 Common Annotations for the Java PlatformAnnotations enable a declarative style of programming in the Java platform.The Java EE 7 platform requires Common Annotations for the Java Platform 1.2.1.8.9 Java平台通用注解注解使得在Java平台中可以使用编程的方式声明样式.Java EE 7平台要求Java平台通用注解 1.2.
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 APIsFigure 1-6 shows the relationships among the Java EE containers.Figure 1-6 Java EE ContainersDescription 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 ContainerDescription 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 ContainerDescription 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 ContainerDescription 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 容器"图 1-6 Java EE 容器"简介图 1-7 显示了在web容器中可以使用的Java EE 7 APIs.图 1-7 Web容器中的 Java EE APIs"图 1-7 Web容器中的 Java EE APIs"简介图 1-8 显示了在EJB容器中可用的Java EE 7 APIs.图 1-8 EJB容器中的Java EE APIs"图 1-8 EJB容器中的Java EE APIs"简介图 1-9显示了在应用客户端容器中可用的Java EE 7 APIs.图 1-9 应用客户端容器中的Java EE 7 APIs"图 1-9 应用客户端容器中的Java EE 7 APIs"简介以下章节简要叙述了Java EE平台所需技术和Java EE应用中使用的APIs.1.7.1 Enterprise JavaBeans TechnologyAn 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 LiteNonpersistent timers in EJB LiteThe 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 TechnologyJava 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/OHTTP protocol upgradeThe 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/OHTTP协议升级Java EE 7平台要求Servlet 3.1.1.7.3 JavaServer Faces TechnologyJavaServer 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 validationEvent handlingData conversion between model objects and componentsManaged model object creationPage navigation configurationExpression 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 markupFaces FlowsResource library contractsThe 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 TechnologyJavaServer 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 XMLJSP elements, which determine how the page constructs dynamic contentFor 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或XMLJSP元素, 用其构建包含动态内容的页面关于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 LibraryThe 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 APIThe 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 APIThe query languageObject/relational mapping metadataThe Java EE 7 platform requires Java Persistence API 2.1.1.7.6 Java持久化APIJava持久化API (JPA)基于Java标准的持久化解决方案. 使用一个对象/关系映射方法将面向的对象模型和关系数据库桥接起来.Java持久化API也可以在非Java EE环境的Java SE应用中使用. Java持久化涉及以下方面:Java持久化API查询语言对象/关系映射元数据Java EE 7平台要求Java持久化API 2.1.1.7.7 Java Transaction APIThe 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 交易 APIJava 交易 API (JTA) 提供一个标准的标定交易界面. Java EE架构默认自动提交事务,当然也可以手动提交和回滚事务. 自动提交意味着其他任何应用都能及时看到每个数据库读写操作后的最新数据. 但是,如果您的应用执行依赖于两个相互独立的数据库访问操作, 你将需要使用JTA来标定整个事务交易, 包含两个操作, 开始, 回滚或提交.Java EE 7平台要求Java交易API 1.2.1.7.8 Java API for RESTful Web ServicesThe 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 APIRESTful WEB服务 Java API(JAX-RS) 是为构建具象状态传输(REST)风格的WEB服务开发定义的API. JAX-RS应用是一个web应用,其是在WAR文件中由类封装并依赖相关库的servlet组成.Java EE 7平台要求JAX-RS 2.0.1.7.9 Managed BeansManaged 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 EEContexts 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 JavaDependency 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 ValidationThe 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 APIThe 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消息服务APIJava消息服务(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 ArchitectureThe 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 APIJava 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 mailA service provider interfaceThe 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 APIJava EE应用使用JavaMail API发送邮件通知. JavaMail API有两部分:一个用于应用组件发送邮件的应用级接口一个服务提供界面Java EE platform平台包含提供服务的JavaMail API,其允许允许应用组件发送内部邮件.Java EE 7平台要求JavaMail 1.5.1.7.16 Java Authorization Contract for ContainersThe 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 ContainersThe 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 WebSocketWebSocket 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 APIWebSocket是一种应用协议.它为两个等同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 ProcessingJSON 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 APIJSON是从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 EEConcurrency 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 PlatformBatch 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.
测试条件: I3 380M + 4G + Windows7 + iis7 + PHP5.4(fastcgi) + Zend2.3网站设置: 使用默认的模块和控制器,配置config和module缓存. 不连接任何服务和数据库.为避免带宽不足清空view测试软件: Jmeter 20并发用户.测试机和被测试机是不同的电脑，它们之间用100M5类线直连在测试结果中,平均响应时间需要0.637秒,每秒处理30个请求.这个数据比zf1低一半. 同一台机zf1可以达到每秒60多个请求我看到这个测试结果后有点想放弃zf2,可是在开发灵活和便捷性上zf2确实要比zf1要好得多. 分析发现,在zf2中路由，派遣和服务注册，模块注册拖累了整个速度. 以前做项目用到过yaf,发现yaf性能挺好的,于是计划用yaf代替zf2的mvc模块.一. 在yaf项目中加载zf2类库首先你得有一个能正常运行的yaf项目.在这个基础上改动以增加zf2支持.可以参考yaf官方教程做一个yaf的基本架构站点. 这里假设你已按照官方教程架设好yaf站点1. 在yaf项目中使用composeryaf官网示范中默认没有zf2的类加载器，考虑到今后还要加载其它的类库代码，这里使用composer加载zf2依赖. 要在yaf项目中引用composer需要对yaf项目的/public/index.php和/conf/application.ini做少量改动.<?php /** * This makes our life easier when dealing with paths. Everything is relative * to the application root now. */ chdir(dirname(__DIR__)); // Decline static file requests back to the PHP built-in webserver if (php_sapi_name() === 'cli-server' && is_file(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))) { return false; } // Setup autoloading require 'init_autoloader.php'; // Define path to application directory define("APP_PATH", dirname(__DIR__)); // Create application, bootstrap, and run $app = new Yaf_Application(APP_PATH . "/conf/application.ini"); $app->bootstrap() ->run();改动后的文件和yaf默认文件主要的区别:要增加chdir(dirname(__DIR__)). 目的是让zf2能正常读取配置文件require 'init_autoloader.php'; 这个文件是在ZendSkeletonApplication.zip中复制出来的，目的是引用composer, zf2类库就要通过这个文件加载进来.$app->bootstrap() 必须要有引导器，因为后面要在bootstrap里面加载zf2配置和服务因为yaf默认会禁用spl加载器，这会造成无法加载非yaf前缀命名的类.所以我们还需要更改yaf运行配置.在/conf/application.ini中设置 application.system.use_spl_autoload = true[product] application.directory = APP_PATH "/application/" application.dispatcher.catchException = true application.system.use_spl_autoload = true总结一下，你需要更改 index.php,application.ini增加init_autoloader.php文件，哦!别忘记了编辑composer.json在其中增加zf2依赖配置. 我这里用的是zf2.3. 然后更新composer依赖. 等待composer依赖更新完成后测试项目，看看在yaf项目中是否可以用zf2的类库,这里应该可以引用，如果还是不行就请下载本文后面提供的完整代码.<?php /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ /** * This autoloading setup is really more complicated than it needs to be for most * applications. The added complexity is simply to reduce the time it takes for * new developers to be productive with a fresh skeleton. It allows autoloading * to be correctly configured, regardless of the installation method and keeps * the use of composer completely optional. This setup should work fine for * most users, however, feel free to configure autoloading however you'd like. */ // Composer autoloading if (file_exists('vendor/autoload.php')) { $loader = include 'vendor/autoload.php'; } $zf2Path = false; if (is_dir('vendor/ZF2/library')) { $zf2Path = 'vendor/ZF2/library'; } elseif (getenv('ZF2_PATH')) { // Support for ZF2_PATH environment variable or git submodule $zf2Path = getenv('ZF2_PATH'); } elseif (get_cfg_var('zf2_path')) { // Support for zf2_path directive value $zf2Path = get_cfg_var('zf2_path'); } if ($zf2Path) { if (isset($loader)) { $loader->add('Zend', $zf2Path); } else { include $zf2Path . '/Zend/Loader/AutoloaderFactory.php'; Zend\Loader\AutoloaderFactory::factory(array( 'Zend\Loader\StandardAutoloader' => array( 'autoregister_zf' => true ) )); } } if (!class_exists('Zend\Loader\AutoloaderFactory')) { throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.'); } "require": { "php": ">=5.3.3", "zendframework/zendframework": "2.3.*" }2. 让Yaf项目中的zf2配置文件起作用上面的改动完成后在yaf中可以使用zf2的类库了，这还不够，我们还要在项目中使用zf2的框架配置和服务管理器. 在改动前需要先了解yaf的限制.yaf是c语言写的mvc框架，配置文件默认是applicatin.ini. yaf并不像zf2那样包含各种功能模块,特别是yaf不能直接使用zf2的配置文件.也就是说zf2的配置在yaf上是没有效果的.为了让zf2配置起作用，我们需要在yaf中调用zf2的服务管理模块以读取配置, 然后把配置好的服务模块注册到yaf_register中.zf2如果除开mvc模块（这里我们用yaf代替了zf2-mvc），最核心的就是servermanager。所有的配置项，所有的服务类，包括事件等都是由servermanager管理，如需在yaf中使用zf2配置，就要把servermanager移植到yaf中. 在zf2中servermanager是最先被执行的，并且把实例作为参数由各种后续对象传递，在yaf中我们使用yaf_regisger传递servermanager实例. 由于我们用yaf代替了zf2的mvc模块，所以在我们移植后的项目中zf2配置中的mvc部分是没有作用的我们先把zf2的配置文件复制到/conf中，注意zf2配置文件默认在/config目录，而yaf配置是在/conf中，为了让配置文件能正常工作，请把zf2应用配置文件application.config.php中的config_glob_paths配置文件路径由/config改为/conf. 除此以外其它的配置项不需要做任何更改.接下来需要改动yaf的Bootstrap.php文件,还记得index.php中的bootstrap()么?,那就是为了运行这个文件准备的. 在这个文件中所有_init开头的方法都会被自动执行,我们把注册servermanager和读取zf2配置的方法写在这里,这样yaf项目启动的时候配置文件就起作用了. 然后在这里把通过配置生成的servermanager对象注册给yaf_regisger.这样在整个yaf中就可以像zf2那样使用服务管理器调用各种功能(不能调用mvc相关模块).<?php use Zend\ServiceManager\ServiceManager; use Zend\Mvc\Service\ServiceManagerConfig; use Zend\ModuleManager\Listener\ConfigListener; use Zend\ModuleManager\Listener\ListenerOptions; use Zend\ModuleManager\ModuleEvent; class Bootstrap extends Yaf_Bootstrap_Abstract { public function _initConfig() { $config = Yaf_Application::app()->getConfig(); Yaf_Registry::set("config", $config); } public function _initServiceManager() { $configuration = require APP_PATH . '/conf/application.config.php'; $smConfig = isset($configuration['service_manager']) ? $configuration['service_manager'] : array(); $serviceManager = new ServiceManager(new ServiceManagerConfig($smConfig)); $serviceManager->setService('ApplicationConfig', $configuration); $configListener = new ConfigListener(new ListenerOptions($configuration['module_listener_options'])); // If not found cache, merge config if (!$configListener->getMergedConfig(false)) $configListener->onMergeConfig(new ModuleEvent); // If enabled, update the config cache if ($configListener->getOptions()->getConfigCacheEnabled() && !file_exists($configListener->getOptions()->getConfigCacheFile())) { $configFile = $configListener->getOptions()->getConfigCacheFile(); $content = "<?php\nreturn " . var_export($configListener->getMergedConfig(false), 1) . ';'; file_put_contents($configFile, $content); } $serviceManager->setService('config', $configListener->getMergedConfig(false)); Yaf_Registry::set('ServiceManager', $serviceManager); } public function _initSessionManager() { Yaf_Registry::get('ServiceManager')->get('Zend\Session\SessionManager'); } public function _initPlugin(Yaf_Dispatcher $dispatcher) { $user = new UserPlugin(); $dispatcher->registerPlugin($user); } }二. 在yaf项目使用zf2服务管理器调用数据库,cache,日志调用各种zf2的服务功能时,需要先确保你的zf2配置中有对应的设置,具体设置参考zf2官方手册,本文后面也有示例代码下载.<?php use Zend\Session\Container as SessionContainer; use Zend\Db\TableGateway\TableGateway; class IndexController extends Yaf_Controller_Abstract { public function indexAction() { if (!isset($session->n)) { $session->n = 0; } $session->n++; echo $session->n; $adapter = $this->getDbAdapter(); $table = new TableGateway('admin', $adapter); $entities = $table->select(); foreach ($entities as $entity) { var_dump($entity->username); } $cache = $this->getStorage(); $cache->setItem('asdfas', 'asdfasdf'); $this->getLogger()->alert('asdfasd'); $this->getView()->assign("content", "Hello World"); } /** * db adapter * @return \Zend\Db\Adapter\Adapter */ public function getDbAdapter() { return Yaf_Registry::get('ServiceManager')->get('Zend\Db\Adapter\Adapter'); } /** * storage * @return \Zend\Cache\Storage\StorageInterface */ protected function getStorage() { return Yaf_Registry::get('ServiceManager')->get('Zend\Cache\Storage\StorageInterface'); } /** * logger * @return \Zend\Log\Zend\Log\Logger */ protected function getLogger() { return Yaf_Registry::get('ServiceManager')->get('Zend\Log\Logger'); } }三. 测试yaf集成zf2后的性能我们使用jmeter测试改动后的yaf项目性能,测试条件和参数与上次测试zf2相同,结果如下:现在测试数据好看多了,平均响应时间提高到81毫秒, 每秒响应请求数提高到241个. 其实我还测试过没有集成zf2服务管理器的yaf性能,每秒请求数可以达到1200(这是11年的I3移动版CPU的老笔记本电脑,每秒1200已经很强了),但是不提供服务的项目性能再好都没有意义.这是一个完整的yaf集成zf2的项目示例.下载后请把把其中的dist配置文件复制并去掉.dist扩展名. yaf-sample-d771c9a.tar
原文：http://docs.oracle.com/javaee/7/tutorial/doc/overview007.htm翻译：石卓林 shizhuolin@hotmail.com1.7 Development RolesReusable modules make it possible to divide the application development and deployment process into distinct roles so that different people or companies can perform different parts of the process.The first two roles, Java EE product provider and tool provider, involve purchasing and installing the Java EE product and tools. After software is purchased and installed, Java EE components can be developed by application component providers, assembled by application assemblers, and deployed by application deployers. In a large organization, each of these roles might be executed by different individuals or teams. This division of labor works because each of the earlier roles outputs a portable file that is the input for a subsequent role. For example, in the application component development phase, an enterprise bean software developer delivers EJB JAR files. In the application assembly role, another developer may combine these EJB JAR files into a Java EE application and save it in an EAR file. In the application deployment role, a system administrator at the customer site uses the EAR file to install the Java EE application into a Java EE server.The different roles are not always executed by different people. If you work for a small company, for example, or if you are prototyping a sample application, you might perform tasks in every phase.1.7 开发角色可重复使用的模块制作尽可能划分为不同的应用开发和部署过程以分配给不同的角色,让不同的人或公司可以执行其过程的不同部分.前两个角色, Java EE产品提供商和工具提供商,涉及购买和安装Java EE产品与工具, 在购买并安装软件后,Java EE组件可以由应用组件开发人员开发, 由应用装配人员打包, 由应用部署人员部署. 在大型组织中.每个角色可以由不同的个人或团队来执行.在分工工作中，因为每个角色前面的输出文件是后续作用的输入. 例如,在应用组件的开发阶段，企业Bean软件开发人员提供EJB JAR文件.在应用打包过程中，另一个开发人员可以将这些EJB JAR文件包含到Java EE应用程序中并将其保存为一个EAR文件。在应用部署时，系统管理员在客户现场把EAR文件格式的Java EE应用程序安装到Java EE服务器.不同的角色并不总是由不同的人执行.如果你工作在一家小公司，例如，或者如果你是编写一个示例应用程序，您可能会执行每一个阶段任务.1.7.1 Java EE Product ProviderThe Java EE product provider is the company that designs and makes available for purchase the Java EE platform APIs and other features defined in the Java EE specification. Product providers are typically application server vendors that implement the Java EE platform according to the Java EE 7 Platform specification.1.7.1 Java EE 产品提供商Java EE产品提供商是设计和实现Java EE 平台API和Java EE规范定义功能的公司.产品供应商通常是根据Java EE平台规范实现Java EE平台应用服务器的供应商.1.7.2 Tool ProviderThe tool provider is the company or person who creates development, assembly, and packaging tools used by component providers, assemblers, and deployers.1.7.2 工具提供商工具提供商是为组件提供商,集成商和部署人员提供开发,集成和打包工具的个人或公司.1.7.3 Application Component ProviderThe application component provider is the company or person who creates web components, enterprise beans, applets, or application clients for use in Java EE applications.1.7.3 应用组件提供商应用组件提供商是创建应用于Java EE应用程序的web组件,企业beans,小程序或企业客户端的公司或个人.1.7.3.1 Enterprise Bean DeveloperAn enterprise bean developer performs the following tasks to deliver an EJB JAR file that contains one or more enterprise beans:Writes and compiles the source codeSpecifies the deployment descriptor (optional)Packages the .class files and deployment descriptor into the EJB JAR file1.7.3.1 企业bean开发人员一个企业bean开发人员执行以下任务以交付一个EJB JAR文件, 其内含有一个或多个企业beans:编写并编译源码指定部署描述符(可选)打包.class文件和部署描述符到EJB JAR文件中1.7.3.2 Web Component DeveloperA web component developer performs the following tasks to deliver a WAR file containing one or more web components:Writes and compiles servlet source codeWrites JavaServer Faces, JSP, and HTML filesSpecifies the deployment descriptor (optional)Packages the .class, .jsp, and.html files and deployment descriptor into the WAR file1.7.3.2 Web组件开发人员web组件开发人员执行以下任务以交付WAR文件,其内包含一个或多个web组件:编写并编译servlet源码编写JavaServer Faces,JSP和HTML文件指定部署描述符(可选)打包.class, .jsp,.html文件和部署描述符到WAR文件中1.7.3.3 Application Client DeveloperAn application client developer performs the following tasks to deliver a JAR file containing the application client:Writes and compiles the source codeSpecifies the deployment descriptor for the client (optional)Packages the .class files and deployment descriptor into the JAR file1.7.3.3 应用客户端开发人员一个企业客户端开发人员执行以下任务以交付内含应用客户端的JAR文件:编写并编译源码指定客户端部署描述符(可选)打包.class文件和部署描述符到JAR文件中1.7.4 Application AssemblerThe application assembler is the company or person who receives application modules from component providers and may assemble them into a Java EE application EAR file. The assembler or deployer can edit the deployment descriptor directly or can use tools that correctly add XML tags according to interactive selections.A software developer performs the following tasks to deliver an EAR file containing the Java EE application:Assembles EJB JAR and WAR files created in the previous phases into a Java EE application (EAR) fileSpecifies the deployment descriptor for the Java EE application (optional)Verifies that the contents of the EAR file are well formed and comply with the Java EE specification1.7.4 应用集成人员应用集成人员是接受来自组件提供者的可装配应用模块并将其放入Java EE应用EAR文件中公司或个人. 装配人员或部署人员可以直接编辑部署描述符或使用工具根据交互选项添加正确的XML标记.一个软件开发人员执行以下任务以交付一个包含Java EE应用的EAR文件:集成已完成的EJB,JAR和WAR文件到Java EE应用(EAR文件)中为Java EE应用制订部署描述符(可选)核实EAR文件的内容和检验其是否符合Java EE规范1.7.5 Application Deployer and AdministratorThe application deployer and administrator is the company or person who configures and deploys application clients, web applications, Enterprise JavaBeans components, and Java EE applications, administers the computing and networking infrastructure where Java EE components and applications run, and oversees the runtime environment. Duties include setting transaction controls and security attributes and specifying connections to databases.During configuration, the deployer follows instructions supplied by the application component provider to resolve external dependencies, specify security settings, and assign transaction attributes. During installation, the deployer moves the application components to the server and generates the container-specific classes and interfaces.A deployer or system administrator performs the following tasks to install and configure a Java EE application or components:Configures the Java EE application or components for the operational environmentVerifies that the contents of the EAR, JAR, and/or WAR filesare well formed and comply with the Java EE specificationDeploys (installs) the Java EE application or components into the Java EE server应用部署人员和管理人员应用部署人员和管理人员是配置和部署应用客户端,web应用程序,企业JavaBeans组件和Java EE应用程序的公司或个人,管理Java EE组件或应用程序运行时的计算机操作和基础网络设施.监管运行环境, 其职责包含设置事务控制,安全属性和连接到指定数据库.在配置过程中.部署人员遵照应用组件提供商提供的说明解决外部依赖,指定安全设置和确定事务属性. 在安装过程中, 部署人员移动应用组件到服务器并且生成特定容器类和接口.部署人员和系统管理人员执行以下任务以安装配置Java EE应用和组件:在运行环境中配置Java EE应用或组件核实EAR,JAR或WAR文件的内容是否正常和符合Java EE规范在Java EE服务器中部署(安装)Java EE应用或组件