没有合适的资源?快使用搜索试试~ 我知道了~
首页Java EE 6 教程:权威指南
Java EE 6 教程:权威指南
需积分: 9 3 下载量 142 浏览量
更新于2024-07-27
收藏 12.63MB PDF 举报
"这是一份关于J2EE的详细使用教程,源自电子版教科书,由Oracle公司出版,适用于2012年的Java EE 6版本。教程包含了开发企业级Java应用程序的指导文档和示例代码,同时也明确了版权和使用许可条款。"
在Java EE(Java Platform, Enterprise Edition)这个强大的平台上,开发者可以构建可扩展且高度模块化的服务器端应用。这份《Java EE 6 Tutorial》是Oracle公司发布的权威资料,旨在帮助开发者掌握如何利用Java EE 6来开发企业级应用。
Java EE 6引入了许多新特性和改进,例如:
1. **简化开发**:通过简化API和引入预配置的"Web Profile",降低了对新手开发者的入门难度。Web Profile是一个轻量级的子集,包含开发大多数Web应用所需的核心组件。
2. **CDI(Contexts and Dependency Injection)**:CDI是一种依赖注入框架,允许开发者声明性地管理组件的生命周期和依赖关系,减少了手动管理对象的复杂性。
3. **JSF 2.0(JavaServer Faces)**:更新的用户界面框架提供了更丰富的组件库,支持Facelets视图技术,以及更灵活的编程模型。
4. **EJB 3.1**:企业级JavaBean的最新版本增强了轻量化特性,如无状态会话bean的简化,以及引入了定时器服务和异步方法调用。
5. **JPA 2.0(Java Persistence API)**:提升了ORM(对象关系映射)功能,包括多态性支持、 Criteria查询和更多的元数据注解。
6. **RESTful Web服务**:通过JAX-RS(Java API for RESTful Web Services),Java EE 6支持创建符合REST原则的Web服务,使得与各种客户端(如浏览器或移动设备)的集成变得更加简单。
7. **WebSocket**:Java EE 6引入了对WebSocket协议的支持,为实时双向通信提供了基础。
8. ** profiles**:Java EE 6引入了profiles的概念,允许厂商提供更针对性的实现,比如Web Profile,满足不同规模和需求的应用场景。
教程中提供的示例代码可以帮助读者更好地理解这些概念,并动手实践。需要注意的是,这些示例代码遵循特定的许可协议,即Berkeley许可证,使用者应仔细阅读并遵守相关的使用和披露限制。
这份《Java EE 6 Tutorial》是一份全面的学习资源,涵盖了从基础到高级的Java EE开发知识,对于任何希望在Java EE平台上开发企业级应用的人来说,都是宝贵的参考资料。通过深入学习,开发者可以掌握构建高效、可维护的企业级系统的技巧和最佳实践。
Accessing Enterprise Beans .............................................................................................................. 445
Using Enterprise Beans in Clients ............................................................................................ 445
Deciding on Remote or Local Access ....................................................................................... 446
Local Clients ............................................................................................................................... 447
Remote Clients ........................................................................................................................... 449
Web Service Clients ................................................................................................................... 450
Method Parameters and Access ................................................................................................ 451
The Contents of an Enterprise Bean ............................................................................................... 451
Packaging Enterprise Beans in EJB JAR Modules .................................................................. 451
Packaging Enterprise Beans in WAR Modules ...................................................................... 452
Naming Conventions for Enterprise Beans ................................................................................... 453
The Lifecycles of Enterprise Beans .................................................................................................. 454
The Lifecycle of a Stateful Session Bean .................................................................................. 454
The Lifecycle of a Stateless Session Bean ................................................................................. 455
The Lifecycle of a Singleton Session Bean ............................................................................... 455
The Lifecycle of a Message-Driven Bean ................................................................................. 456
Further Information about Enterprise Beans ................................................................................ 457
23 Getting Started with Enterprise Beans .......................................................................................... 459
Creating the Enterprise Bean ........................................................................................................... 459
Coding the Enterprise Bean Class ............................................................................................ 460
Creating the converter Web Client ........................................................................................ 460
Building, Packaging, Deploying, and Running the converter Example ............................ 461
Modifying the Java EE Application ................................................................................................. 462
▼ To Modify a Class File ................................................................................................................ 462
24 Running the Enterprise Bean Examples ........................................................................................ 465
The cart Example ............................................................................................................................. 465
The Business Interface ............................................................................................................... 466
Session Bean Class ..................................................................................................................... 467
The @Remove Method ................................................................................................................. 470
Helper Classes ............................................................................................................................. 470
Building, Packaging, Deploying, and Running the cart Example ...................................... 470
A Singleton Session Bean Example: counter ................................................................................. 472
Creating a Singleton Session Bean ........................................................................................... 472
Contents
The Java EE 6 Tutorial • July 201216
The Architecture of the counter Example .............................................................................. 476
Building, Packaging, Deploying, and Running the counter Example ................................ 479
A Web Service Example: helloservice ......................................................................................... 480
The Web Service Endpoint Implementation Class ................................................................ 480
Stateless Session Bean Implementation Class ........................................................................ 481
Building, Packaging, Deploying, and Testing the helloservice Example ........................ 481
Using the Timer Service .................................................................................................................... 483
Creating Calendar-Based Timer Expressions ........................................................................ 483
Programmatic Timers ............................................................................................................... 486
Automatic Timers ...................................................................................................................... 487
Canceling and Saving Timers ................................................................................................... 488
Getting Timer Information ...................................................................................................... 489
Transactions and Timers .......................................................................................................... 489
The timersession Example ..................................................................................................... 489
Building, Packaging, Deploying, and Running the timersession Example ...................... 492
Handling Exceptions ......................................................................................................................... 493
25 A Message-Driven Bean Example ...................................................................................................495
simplemessage Example Application Overview ........................................................................... 495
The simplemessage Application Client ......................................................................................... 496
The Message-Driven Bean Class ..................................................................................................... 497
The onMessage Method ............................................................................................................. 498
Packaging, Deploying, and Running the simplemessage Example ............................................ 499
Administered Objects for the simplemessage Example ....................................................... 499
▼ To Build, Deploy, and Run the simplemessage Application Using NetBeans IDE ........... 500
▼ To Build, Deploy, and Run the simplemessage Application Using Ant ............................. 500
Removing the Administered Objects for the simplemessage Example .............................. 501
26 Using the Embedded Enterprise Bean Container ........................................................................ 503
Overview of the Embedded Enterprise Bean Container ............................................................... 503
Developing Embeddable Enterprise Bean Applications ............................................................... 503
Running Embedded Applications ............................................................................................ 504
Creating the Enterprise Bean Container ................................................................................. 504
Looking Up Session Bean References ...................................................................................... 506
Shutting Down the Enterprise Bean Container ..................................................................... 506
Contents
17
The standalone Example Application ........................................................................................... 506
▼ Running the standalone Example Application ..................................................................... 507
27 Using Asynchronous Method Invocation in Session Beans ....................................................... 509
Asynchronous Method Invocation ................................................................................................. 509
Creating an Asynchronous Business Method ......................................................................... 510
Calling Asynchronous Methods from Enterprise Bean Clients ........................................... 511
The async Example Application ...................................................................................................... 512
Architecture of the async Example Application .................................................................... 512
▼ Conguring the Keystore and Truststore in GlassFish Server ............................................. 513
▼ Running the async Example Application in NetBeans IDE ................................................. 514
▼ Running the async Example Application Using Ant ............................................................ 515
Part V Contexts and Dependency Injection for the Java EE Platform ...................................................517
28 Introduction to Contexts and Dependency Injection for the Java EE Platform .......................519
Overview of CDI ................................................................................................................................ 520
About Beans ....................................................................................................................................... 521
About CDI Managed Beans .............................................................................................................. 521
Beans as Injectable Objects ............................................................................................................... 522
Using Qualiers ................................................................................................................................. 523
Injecting Beans ................................................................................................................................... 524
Using Scopes ...................................................................................................................................... 524
Overriding the Scope of a Bean at the Point of Injection .............................................................. 526
Giving Beans EL Names .................................................................................................................... 526
Adding Setter and Getter Methods .................................................................................................. 527
Using a Managed Bean in a Facelets Page ....................................................................................... 528
Injecting Objects by Using Producer Methods .............................................................................. 528
Conguring a CDI Application ....................................................................................................... 529
Using the @PostConstruct and @PreDestroy Annotations With CDI Managed Bean
Classes ................................................................................................................................................. 529
▼ To Initialize a Managed Bean Using the @PostConstruct Annotation .............................. 529
▼ To Prepare for the Destruction of a Managed Bean Using the @PreDestroy Annotation 530
Further Information about CDI ...................................................................................................... 530
Contents
The Java EE 6 Tutorial • July 201218
29 Running the Basic Contexts and Dependency Injection Examples .......................................... 531
The simplegreeting CDI Example ................................................................................................ 531
The simplegreeting Source Files ........................................................................................... 532
The Facelets Template and Page ............................................................................................... 532
Conguration Files .................................................................................................................... 533
Building, Packaging, Deploying, and Running the simplegreeting CDI Example ......... 534
The guessnumber CDI Example ...................................................................................................... 535
The guessnumber Source Files ................................................................................................. 536
The Facelets Page ....................................................................................................................... 540
Building, Packaging, Deploying, and Running the guessnumber CDI Example ............... 541
30 Contexts and Dependency Injection for the Java EE Platform: AdvancedTopics ...................543
Using Alternatives in CDI Applications ......................................................................................... 543
Using Specialization .................................................................................................................. 544
Using Producer Methods, Producer Fields, and Disposer Methods in CDI Applications ....... 545
Using Producer Methods .......................................................................................................... 546
Using Producer Fields to Generate Resources ........................................................................ 547
Using a Disposer Method .......................................................................................................... 547
Using Predened Beans in CDI Applications ................................................................................ 548
Using Events in CDI Applications ................................................................................................... 549
Dening Events .......................................................................................................................... 549
Using Observer Methods to Handle Events ............................................................................ 549
Firing Events ............................................................................................................................... 550
Using Interceptors in CDI Applications ......................................................................................... 551
Using Decorators in CDI Applications ........................................................................................... 553
Using Stereotypes in CDI Applications .......................................................................................... 554
31 Running the Advanced Contexts and Dependency Injection Examples ................................. 557
The encoder Example: Using Alternatives .................................................................................... 557
The Coder Interface and Implementations ............................................................................. 558
The encoder Facelets Page and Managed Bean ...................................................................... 558
Building, Packaging, Deploying, and Running the encoder Example ................................ 560
The producermethods Example: Using a Producer Method To Choose a Bean
Implementation ................................................................................................................................. 562
Components of the producermethods Example .................................................................... 563
Contents
19
Building, Packaging, Deploying, and Running the producermethods Example ............... 564
The producerfields Example: Using Producer Fields to Generate Resources ........................ 565
The Producer Field for the producerfields Example .......................................................... 566
The producerfields Entity and Session Bean ...................................................................... 567
The producerfields Facelets Pages and Managed Bean ..................................................... 568
Building, Packaging, Deploying, and Running the producerfields Example ................. 570
The billpayment Example: Using Events and Interceptors ........................................................ 572
The PaymentEvent Event Class ................................................................................................ 572
The PaymentHandler Event Listener ....................................................................................... 572
The billpayment Facelets Pages and Managed Bean ............................................................ 573
The LoggedInterceptor Interceptor Class ............................................................................ 575
Building, Packaging, Deploying, and Running the billpayment Example ........................ 576
The decorators Example: Decorating a Bean ............................................................................... 578
Components of the decorators Example .............................................................................. 578
Building, Packaging, Deploying, and Running the decorators Example .......................... 579
Part VI Persistence ..........................................................................................................................................581
32 Introduction to the Java Persistence API ...................................................................................... 583
Entities ................................................................................................................................................ 583
Requirements for Entity Classes .............................................................................................. 584
Persistent Fields and Properties in Entity Classes .................................................................. 584
Primary Keys in Entities ............................................................................................................ 589
Multiplicity in Entity Relationships ......................................................................................... 591
Direction in Entity Relationships ............................................................................................. 591
Embeddable Classes in Entities ................................................................................................ 594
Entity Inheritance .............................................................................................................................. 595
Abstract Entities ......................................................................................................................... 595
Mapped Superclasses ................................................................................................................. 595
Non-Entity Superclasses ........................................................................................................... 596
Entity Inheritance Mapping Strategies .................................................................................... 596
Managing Entities .............................................................................................................................. 599
The EntityManager Interface .................................................................................................. 599
Persistence Units ........................................................................................................................ 603
Querying Entities ............................................................................................................................... 604
Contents
The Java EE 6 Tutorial • July 201220
剩余1001页未读,继续阅读
点击了解资源详情
点击了解资源详情
点击了解资源详情
2007-06-22 上传
2007-08-17 上传
2013-03-05 上传
ITCHN
- 粉丝: 3
- 资源: 15
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- PyPI 官网下载 | luma.oled-3.2.0-py2.py3-none-any.whl
- 【推荐】城市云数据大屏
- NDISCfg.zip_网络编程_Visual_C++_
- 重点:受鲍里斯启发的程序,通过对视频的视觉检查来记录观察结果
- notes-client:用React编写的Markdown编辑器
- 微博小助手-crx插件
- notes-python:中文Python笔记
- nitpick-styles:nitpick样式的集合
- 教育科研-学习工具-一种COG邦定机对位平台.zip
- pycrashcourse:这是Python Crash Course的存储库
- Hide That-crx插件
- node-rplidar
- 多选按钮代码matlab-guyezi.github.io:IT日志:http://guyezi.github.io或
- BOTBUKI
- sassy-exists:Sass中的实体检查
- 6-1JavaJDBC.rar_Java编程_Java_
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功