没有合适的资源?快使用搜索试试~ 我知道了~
首页深入学习JavaEE 7:官方指南英文版PDF
深入学习JavaEE 7:官方指南英文版PDF
需积分: 20 25 下载量 181 浏览量
更新于2024-07-25
2
收藏 14.34MB PDF 举报
"JavaEE 7 Tutorial (JavaEE 7 官方指南)" 是一本针对 Java Enterprise Edition 7(JavaEE 7)平台的技术指南,旨在帮助开发者提升技术水平和英文阅读能力。这本书由 Eric Jendrock、Ricardo Cervera-Navarro、Ian Evans、Devika Gollapudi、Kim Haase、William Markito 和 Chinmayee Srivathsa 等主要作者编写,并有其他贡献者参与。
JavaEE 7 是一个用于构建企业级 web 应用程序的框架,它包含了多个组件和服务,如 Servlet、JSP、EJB(Enterprise JavaBeans)、JPA(Java Persistence API)、CDI(Contexts and Dependency Injection)、JSF(JavaServer Faces)、JAX-RS(Java API for RESTful Web Services)等。这个教程涵盖了这些核心组件的详细使用方法和最佳实践。
在 JavaEE 7 中,一些重要的更新包括:
1. Servlet 3.1: 提供了异步处理能力的增强,使得服务器可以更有效地处理高并发请求。
2. JAX-RS 2.0: 引入了响应式编程模型,增强了客户端API,以及支持超媒体作为应用程序状态的驱动(HATEOAS)。
3. WebSocket API: 为实时双向通信提供了标准支持,使得应用程序能够实现低延迟的数据交换。
4. JPA 2.1: 增加了对JSON存储和查询的支持,以及对NoSQL数据库的更好集成。
5. CDI 1.1: 提供了更多的扩展性和可定制性,简化了依赖注入的使用。
6. JSF 2.2: 更新了组件库,支持HTML5和CSS3,以及改进了移动设备的适配。
本书的内容可能涵盖以下主题:
- 平台概述:介绍 JavaEE 7 的架构、目标和开发环境设置。
- Web 组件:讲解如何使用 Servlet 和 JSP 创建动态网页。
- 企业 Bean:详述 EJB 3.2 的使用,包括会话bean、消息驱动bean和实体bean。
- 持久性:介绍JPA的概念、配置和查询语言(JPQL)。
- 面向服务:探讨RESTful服务的创建,包括JAX-RS的使用。
- CDI 和依赖注入:解释如何管理对象的生命周期和依赖关系。
- 测试和部署:提供有关单元测试、集成测试和应用程序部署的信息。
- 安全性:覆盖了身份验证、授权和安全约束的配置。
该教程还可能涉及实际示例代码、最佳实践、常见问题解答和调试技巧,以帮助读者深入理解并应用 JavaEE 7 的各种技术。对于任何想要学习或精通 JavaEE 7 开发的人来说,这是一份宝贵的资源。请确保遵循版权规定,在合法的许可下使用和分发这份材料。如果你在阅读过程中发现任何错误,应当书面报告给出版商。
xvi
20.2.3 Retrieving Localized Messages....................................................................................... 20-3
20.3 Date and Number Formatting................................................................................................ 20-4
20.4 Character Sets and Encodings................................................................................................ 20-4
20.4.1 Character Sets.................................................................................................................... 20-4
20.4.2 Character Encoding.......................................................................................................... 20-5
Part IV Web Services
21 Introduction to Web Services
21.1 What Are Web Services?......................................................................................................... 21-1
21.2 Types of Web Services............................................................................................................. 21-1
21.2.1 "Big" Web Services............................................................................................................ 21-1
21.2.2 RESTful Web Services ...................................................................................................... 21-2
21.3 Deciding Which Type of Web Service to Use ...................................................................... 21-3
22 Building Web Services with JAX-WS
22.1 Creating a Simple Web Service and Clients with JAX-WS ................................................ 22-2
22.1.1 Requirements of a JAX-WS Endpoint............................................................................ 22-2
22.1.2 Coding the Service Endpoint Implementation Class .................................................. 22-3
22.1.3 Building, Packaging, and Deploying the Service......................................................... 22-4
22.1.3.1 To Build, Package, and Deploy the Service Using NetBeans IDE...................... 22-4
22.1.3.2 To Build, Package, and Deploy the Service Using Maven .................................. 22-4
22.1.4 Testing the Methods of a Web Service Endpoint......................................................... 22-4
22.1.4.1 To Test the Service without a Client....................................................................... 22-4
22.1.5 A Simple JAX-WS Application Client............................................................................ 22-5
22.1.5.1 Coding the Application Client................................................................................. 22-5
22.1.5.2 Running the Application Client .............................................................................. 22-6
22.1.6 A Simple JAX-WS Web Client ........................................................................................ 22-6
22.1.6.1 Coding the Servlet..................................................................................................... 22-6
22.1.6.2 Running the Web Client ........................................................................................... 22-8
22.2 Types Supported by JAX-WS................................................................................................. 22-8
22.2.1 Schema-to-Java Mapping................................................................................................. 22-9
22.2.2 Java-to-Schema Mapping................................................................................................. 22-9
22.3 Web Services Interoperability and JAX-WS....................................................................... 22-10
22.4 Further Information about JAX-WS .................................................................................... 22-10
23 Building RESTful Web Services with JAX-RS
23.1 What Are RESTful Web Services? ......................................................................................... 23-1
23.2 Creating a RESTful Root Resource Class.............................................................................. 23-2
23.2.1 Developing RESTful Web Services with JAX-RS ......................................................... 23-2
23.2.2 Overview of a JAX-RS Application................................................................................ 23-3
23.2.3 The @Path Annotation and URI Path Templates......................................................... 23-5
23.2.4 Responding to HTTP Methods and Requests .............................................................. 23-6
23.2.4.1 The Request Method Designator Annotations...................................................... 23-6
23.2.4.2 Using Entity Providers to Map HTTP Response and Request Entity Bodies... 23-8
23.2.5 Using @Consumes and @Produces to Customize Requests and Responses ........... 23-9
xvii
23.2.5.1 The @Produces Annotation...................................................................................... 23-9
23.2.5.2 The @Consumes Annotation.................................................................................. 23-10
23.2.6 Extracting Request Parameters..................................................................................... 23-11
23.3 Example Applications for JAX-RS....................................................................................... 23-14
23.3.1 Creating A Simple RESTful Web Service.................................................................... 23-14
23.3.1.1 To Create a RESTful Web Service Using NetBeans IDE.................................... 23-14
23.3.2 The rsvp Example Application..................................................................................... 23-15
23.3.2.1 Components of the rsvp Example Application................................................... 23-15
23.3.2.2 Running the rsvp Example Application............................................................... 23-16
23.3.3 Real-World Examples..................................................................................................... 23-17
23.4 Further Information about JAX-RS...................................................................................... 23-17
24 Accessing REST Resources with the JAX-RS Client API
24.1 Overview of the Client API .................................................................................................... 24-1
24.2 Creating a Basic Client Request using the Client API ........................................................ 24-1
24.2.1 Obtaining the Client Instance ......................................................................................... 24-2
24.2.2 Setting the Client Target.................................................................................................. 24-2
24.2.2.1 Setting Path Parameters in Targets......................................................................... 24-2
24.2.3 Invoking the Request ....................................................................................................... 24-3
24.3 Using the Client API in the JAX-RS Example Applications .............................................. 24-4
24.3.1 The Client API in the
rsvp
Example Application ........................................................ 24-4
24.3.2 The Client API in the
customer
Example Application................................................ 24-5
24.4 Advance Features of the Client API...................................................................................... 24-6
24.4.1 Configuring the Client Request...................................................................................... 24-6
24.4.1.1 Setting Message Headers in the Client Request.................................................... 24-6
24.4.1.2 Setting Cookies in the Client Request..................................................................... 24-7
24.4.1.3 Adding Filters to the Client...................................................................................... 24-7
24.4.2 Asynchronous Invocations in the Client API ............................................................... 24-8
24.4.2.1 Using Custom Callbacks in Asynchronous Invocations...................................... 24-9
25 JAX-RS: Advanced Topics and Example
25.1 Annotations for Field and Bean Properties of Resource Classes ...................................... 25-1
25.1.1 Extracting Path Parameters............................................................................................. 25-2
25.1.2 Extracting Query Parameters.......................................................................................... 25-2
25.1.3 Extracting Form Data....................................................................................................... 25-3
25.1.4 Extracting the Java Type of a Request or Response..................................................... 25-3
25.2 Validating Resource Data with Bean Validation................................................................. 25-4
25.2.1 Using Constraint Annotations on Resource Methods................................................. 25-4
25.2.2 Validating Entity Data ..................................................................................................... 25-5
25.2.3 Validation Exception Handling and Response Codes ................................................ 25-6
25.3 Subresources and Runtime Resource Resolution................................................................ 25-7
25.3.1 Subresource Methods....................................................................................................... 25-7
25.3.2 Subresource Locators ....................................................................................................... 25-7
25.4 Integrating JAX-RS with EJB Technology and CDI ............................................................ 25-8
25.5 Conditional HTTP Requests................................................................................................... 25-9
25.6 Runtime Content Negotiation.............................................................................................. 25-10
xviii
25.7 Using JAX-RS With JAXB ..................................................................................................... 25-11
25.7.1 Using Java Objects to Model Your Data...................................................................... 25-13
25.7.2 Starting from an Existing XML Schema Definition ................................................... 25-14
25.7.3 Using JSON with JAX-RS and JAXB ............................................................................ 25-16
25.8 The customer Example Application.................................................................................... 25-16
25.8.1 Overview of the customer Example Application....................................................... 25-17
25.8.2 The Customer and Address Entity Classes................................................................. 25-17
25.8.3 The CustomerService Class........................................................................................... 25-19
25.8.4 Using the JAX-RS Client in the CustomerBean Classes............................................ 25-21
25.8.5 Running the customer Example ................................................................................... 25-22
25.8.5.1 To Build, Package, and Deploy the customer Example Using NetBeans IDE 25-22
25.8.5.2 To Build, Package, and Deploy the customer Example Using Maven ............ 25-22
Part V Enterprise Beans
26 Enterprise Beans
26.1 What Is an Enterprise Bean?................................................................................................... 26-1
26.1.1 Benefits of Enterprise Beans............................................................................................ 26-1
26.1.2 When to Use Enterprise Beans........................................................................................ 26-2
26.1.3 Types of Enterprise Beans ............................................................................................... 26-2
26.2 What Is a Session Bean? .......................................................................................................... 26-2
26.2.1 Types of Session Beans..................................................................................................... 26-2
26.2.1.1 Stateful Session Beans............................................................................................... 26-2
26.2.1.2 Stateless Session Beans.............................................................................................. 26-3
26.2.1.3 Singleton Session Beans............................................................................................ 26-3
26.2.2 When to Use Session Beans............................................................................................. 26-3
26.3 What Is a Message-Driven Bean? .......................................................................................... 26-4
26.3.1 What Makes Message-Driven Beans Different from Session Beans?........................ 26-4
26.3.2 When to Use Message-Driven Beans............................................................................. 26-5
26.4 Accessing Enterprise Beans.................................................................................................... 26-5
26.4.1 Using Enterprise Beans in Clients .................................................................................. 26-6
26.4.1.1 Portable JNDI Syntax ................................................................................................ 26-6
26.4.2 Deciding on Remote or Local Access............................................................................. 26-7
26.4.3 Local Clients ...................................................................................................................... 26-7
26.4.3.1 Accessing Local Enterprise Beans Using the No-Interface View ....................... 26-8
26.4.3.2 Accessing Local Enterprise Beans That Implement Business Interfaces........... 26-8
26.4.4 Remote Clients .................................................................................................................. 26-9
26.4.5 Web Service Clients........................................................................................................ 26-10
26.4.6 Method Parameters and Access.................................................................................... 26-10
26.4.6.1 Isolation..................................................................................................................... 26-10
26.4.6.2 Granularity of Accessed Data................................................................................ 26-10
26.5 The Contents of an Enterprise Bean.................................................................................... 26-11
26.6 Naming Conventions for Enterprise Beans........................................................................ 26-11
26.7 The Lifecycles of Enterprise Beans...................................................................................... 26-11
26.7.1 The Lifecycle of a Stateful Session Bean...................................................................... 26-11
26.7.2 The Lifecycle of a Stateless Session Bean .................................................................... 26-12
26.7.3 The Lifecycle of a Singleton Session Bean................................................................... 26-13
xix
26.7.4 The Lifecycle of a Message-Driven Bean..................................................................... 26-13
26.8 Further Information about Enterprise Beans..................................................................... 26-14
27 Getting Started with Enterprise Beans
27.1 Creating the Enterprise Bean.................................................................................................. 27-1
27.1.1 Coding the Enterprise Bean Class .................................................................................. 27-1
27.1.2 Creating the converter Web Client................................................................................. 27-2
27.1.3 Running the converter Example..................................................................................... 27-3
27.1.3.1 To Run the converter Example in NetBeans IDE.................................................. 27-3
27.1.3.2 To Run the converter Example Using Maven ....................................................... 27-3
27.2 Modifying the Java EE Application....................................................................................... 27-4
27.2.1 To Modify a Class File...................................................................................................... 27-4
28 Running the Enterprise Bean Examples
28.1 The cart Example...................................................................................................................... 28-1
28.1.1 The Business Interface...................................................................................................... 28-2
28.1.2 Session Bean Class............................................................................................................ 28-2
28.1.2.1 Lifecycle Callback Methods ..................................................................................... 28-4
28.1.2.2 Business Methods...................................................................................................... 28-4
28.1.3 The @Remove Method ..................................................................................................... 28-5
28.1.4 Helper Classes................................................................................................................... 28-5
28.1.5 Running the cart Example............................................................................................... 28-5
28.1.5.1 To Run the cart Example Using NetBeans IDE..................................................... 28-6
28.1.5.2 To Run the cart Example Using Maven ................................................................. 28-6
28.2 A Singleton Session Bean Example: counter........................................................................ 28-7
28.2.1 Creating a Singleton Session Bean ................................................................................. 28-7
28.2.1.1 Initializing Singleton Session Beans........................................................................ 28-7
28.2.1.2 Managing Concurrent Access in a Singleton Session Bean................................. 28-8
28.2.1.3 Handling Errors in a Singleton Session Bean...................................................... 28-11
28.2.2 The Architecture of the counter Example ................................................................... 28-11
28.2.3 Running the counter Example ...................................................................................... 28-13
28.2.3.1 To Run the counter Example Using NetBeans IDE............................................ 28-13
28.2.3.2 To Run the counter Example Using Maven......................................................... 28-13
28.3 A Web Service Example: helloservice................................................................................. 28-14
28.3.1 The Web Service Endpoint Implementation Class .................................................... 28-14
28.3.2 Stateless Session Bean Implementation Class............................................................. 28-14
28.3.3 Running the helloservice Example............................................................................... 28-15
28.3.3.1 To Build, Package, and Deploy the helloservice Example Using NetBeans IDE........
28-15
28.3.3.2 To Build, Package, and Deploy the helloservice Example Using Maven........ 28-15
28.3.3.3 To Test the Service without a Client..................................................................... 28-15
28.4 Using the Timer Service........................................................................................................ 28-16
28.4.1 Creating Calendar-Based Timer Expressions............................................................. 28-16
28.4.1.1 Specifying Multiple Values in Calendar Expressions........................................ 28-17
28.4.2 Programmatic Timers..................................................................................................... 28-18
28.4.2.1 The @Timeout Method ........................................................................................... 28-18
xx
28.4.2.2 Creating Programmatic Timers............................................................................. 28-19
28.4.3 Automatic Timers ........................................................................................................... 28-20
28.4.4 Canceling and Saving Timers ....................................................................................... 28-20
28.4.5 Getting Timer Information............................................................................................ 28-21
28.4.6 Transactions and Timers................................................................................................ 28-21
28.4.7 The timersession Example............................................................................................. 28-21
28.4.8 Running the timersession Example.............................................................................. 28-23
28.4.8.1 To Run the timersession Example Using NetBeans IDE ................................... 28-24
28.4.8.2 To Build, Package, and Deploy the timersession Example Using Maven ...... 28-24
28.4.8.3 To Run the Web Client............................................................................................ 28-24
28.5 Handling Exceptions ............................................................................................................. 28-24
29 Using the Embedded Enterprise Bean Container
29.1 Overview of the Embedded Enterprise Bean Container.................................................... 29-1
29.2 Developing Embeddable Enterprise Bean Applications.................................................... 29-1
29.2.1 Running Embedded Applications.................................................................................. 29-2
29.2.2 Creating the Enterprise Bean Container........................................................................ 29-2
29.2.2.1 Explicitly Specifying Enterprise Bean Modules to be Initialized ....................... 29-3
29.2.3 Looking Up Session Bean References ............................................................................ 29-3
29.2.4 Shutting Down the Enterprise Bean Container............................................................ 29-3
29.3 The standalone Example Application................................................................................... 29-4
29.3.1 Runing the standalone Example Application in NetBeans IDE ................................ 29-5
29.3.2 Running the standalone Example Application using Maven .................................... 29-5
30 Using Asynchronous Method Invocation in Session Beans
30.1 Asynchronous Method Invocation........................................................................................ 30-1
30.1.1 Creating an Asynchronous Business Method .............................................................. 30-1
30.1.2 Calling Asynchronous Methods from Enterprise Bean Clients................................. 30-2
30.1.2.1 Retrieving the Final Result from an Asynchronous Method Invocation .......... 30-2
30.1.2.2 Cancelling an Asynchronous Method Invocation ................................................ 30-3
30.1.2.3 Checking the Status of an Asynchronous Method Invocation ........................... 30-3
30.2 The async Example Application ............................................................................................ 30-3
30.2.1 Architecture of the async Example Application .......................................................... 30-3
30.2.2 Running the async Example............................................................................................ 30-4
30.2.2.1 To Configure the Keystore and Truststore in GlassFish Server ......................... 30-4
30.2.2.2 To Run the async Example Application Using NetBeans IDE............................ 30-5
30.2.2.3 To Run the async Example Application Using Maven........................................ 30-6
Part VI Contexts and Dependency Injection for Java EE
31 Introduction to Contexts and Dependency Injection for Java EE
31.1 Getting Started.......................................................................................................................... 31-2
31.2 Overview of CDI...................................................................................................................... 31-3
31.3 About Beans.............................................................................................................................. 31-4
31.4 About CDI Managed Beans.................................................................................................... 31-4
31.5 Beans as Injectable Objects...................................................................................................... 31-5
剩余917页未读,继续阅读
2013-10-05 上传
2017-04-04 上传
2010-02-09 上传
2011-01-21 上传
2021-07-01 上传
2009-07-16 上传
2008-03-26 上传
2010-06-30 上传
2021-05-14 上传
司青-已停止更新
- 粉丝: 675
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Java集合ArrayList实现字符串管理及效果展示
- 实现2D3D相机拾取射线的关键技术
- LiveLy-公寓管理门户:创新体验与技术实现
- 易语言打造的快捷禁止程序运行小工具
- Microgateway核心:实现配置和插件的主端口转发
- 掌握Java基本操作:增删查改入门代码详解
- Apache Tomcat 7.0.109 Windows版下载指南
- Qt实现文件系统浏览器界面设计与功能开发
- ReactJS新手实验:搭建与运行教程
- 探索生成艺术:几个月创意Processing实验
- Django框架下Cisco IOx平台实战开发案例源码解析
- 在Linux环境下配置Java版VTK开发环境
- 29街网上城市公司网站系统v1.0:企业建站全面解决方案
- WordPress CMB2插件的Suggest字段类型使用教程
- TCP协议实现的Java桌面聊天客户端应用
- ANR-WatchDog: 检测Android应用无响应并报告异常
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功