Always Learning

Advanced Search

Java EE 6 Tutorial, The

Java EE 6 Tutorial, The

Advanced Topics
4th Edition

Eric Jendrock, Ricardo Cervera-Navarro, Ian Evans, Devika Gollapudi, Kim Haase, William Markito, Chinmayee Srivathsa

Jan 2013, Paperback, 560 pages
ISBN13: 9780137081868
ISBN10: 0137081863
This title is no longer available.

This title cannot be purchased online
  • Print pagePrint page
  • Email this pageEmail page
  • Share

The Java EE 6 Tutorial: Advanced Topics, Fourth Edition, is a task-oriented, example-driven guide to developing enterprise applications for the Java Platform, Enterprise Edition 6 (Java EE 6). Written by members of the Java EE 6 documentation team at Oracle, this book provides new and intermediate Java programmers with a deep understanding of the platform.

This guide–which builds on the concepts introduced in The Java EE 6 Tutorial: Basic Concepts, Fourth Edition–contains advanced material, including detailed introductions to more complex platform features and instructions for using the latest version of the NetBeans IDE and the GlassFish Server, Open Source Edition.

This book introduces the Java Message Service (JMS) API and Java EE Interceptors. It also describes advanced features of JavaServer Faces, Servlets, JAX-RS, Enterprise JavaBeans components, the Java Persistence API, Contexts and Dependency Injection for the Java EE Platform, web and enterprise application security, and Bean Validation. The book culminates with three new case studies that illustrate the use of multiple Java EE 6 APIs.

Preface xxi

Part I: Introduction 1

Chapter1: Overview 3

Java EE 6 Platform Highlights 4

Java EE Application Model 5

Distributed Multitiered Applications 6

Java EE Containers 13

Web Services Support 15

Java EE Application Assembly and Deployment 17

Packaging Applications 17

Development Roles 19

Java EE 6 APIs 21

Java EE 6 APIs in the Java Platform, Standard Edition 6 and 7 32

GlassFish Server Tools 35

Chapter 2: Using the Tutorial Examples 37

Required Software 37

Starting and Stopping the GlassFish Server 41

Starting the Administration Console 42

Starting and Stopping the Java DB Server 43

Building the Examples 43

Tutorial Example Directory Structure 44

Getting the Latest Updates to the Tutorial 45

Debugging Java EE Applications 45

Part II: The Web Tier 47

Chapter 3: JavaServer Faces Technology: Advanced Concepts 49

The Lifecycle of a JavaServer Faces Application 50

Partial Processing and Partial Rendering 56

The Lifecycle of a Facelets Application 56

User Interface Component Model 57

Chapter 4: Using Ajax with JavaServer Faces Technology 69

Overview of Ajax 70

Using Ajax Functionality with JavaServer Faces Technology 70

Using Ajax with Facelets 71

Sending an Ajax Request 73

Monitoring Events on the Client 75

Handling Errors 76

Receiving an Ajax Response 77

Ajax Request Lifecycle 78

Grouping of Components 78

Loading JavaScript as a Resource 79

The ajaxguessnumber Example Application 81

Further Information about Ajax in JavaServer Faces Technology 85

Chapter 5: Composite Components: Advanced Topics and Example 87

Attributes of a Composite Component 87

Invoking a Managed Bean 88

Validating Composite Component Values 89

The compositecomponentlogin Example Application 89

Chapter 6: Creating Custom UI Components and Other Custom Objects 95

Determining Whether You Need a Custom Component or Renderer 97

Understanding the Image Map Example 100

Steps for Creating a Custom Component 105

Creating Custom Component Classes 106

Delegating Rendering to a Renderer 114

Implementing an Event Listener 117

Handling Events for Custom Components 119

Defining the Custom Component Tag in a Tag Library Descriptor 120

Using a Custom Component 121

Creating and Using a Custom Converter 123

Creating and Using a Custom Validator 128

Binding Component Values and Instances to Managed Bean Properties 133

Binding Converters, Listeners, and Validators to Managed Bean Properties 138

Chapter 7: Configuring JavaServer Faces Applications 141

Using Annotations to Configure Managed Beans 142

Application Configuration Resource File 144

Configuring Managed Beans 146

Registering Application Messages 155

Using Default Validators 159

Registering a Custom Validator 159

Registering a Custom Converter 160

Configuring Navigation Rules 161

Registering a Custom Renderer with a Render Kit 165

Registering a Custom Component 167

Basic Requirements of a JavaServer Faces Application 168

Chapter 8: Uploading Files with Java Servlet Technology 175

The @MultipartConfigAnnotation 175

The getPartsand getPart Methods 176

The fileuploadExample Application 177

Chapter 9: Internationalizing and Localizing Web Applications 183

Java Platform Localization Classes 183

Providing Localized Messages and Labels 184

Date and Number Formatting 187

Character Sets and Encodings 188

Part III: Web Services 191

Chapter 10: JAX-RS: Advanced Topics and Example 193

Annotations for Field and Bean Properties of Resource Classes 193

Subresources and Runtime Resource Resolution 197

Integrating JAX-RS with EJB Technology and CDI 198

Conditional HTTP Requests 199

Runtime Content Negotiation 200

Using JAX-RS with JAXB 202

The customer Example Application 209

Part IV: Enterprise Beans 225

Chapter 11: A Message-Driven Bean Example 227

Overview of the simplemessage Example 227

The simplemessage Application Client 228

The Message-Driven Bean Class 229

Running the simplemessage Example 231

Chapter 12: Using the Embedded Enterprise Bean Container 235

Overview of the Embedded Enterprise Bean Container 235

Developing Embeddable Enterprise Bean Applications 236

The standalone Example Application 239

Chapter 13: Using Asynchronous Method Invocation in Session Beans 241

Asynchronous Method Invocation 241

The async Example Application 244

Part V: Contexts and Dependency Injection for the Java EE Platform 249

Chapter 14: Contexts and Dependency Injection for the Java EE Platform: Advanced Topics 251

Using Alternatives in CDI Applications 251

Using Producer Methods, Producer Fields, and Disposer Methods in CDI Applications 254

Using Predefined Beans in CDI Applications 256

Using Events in CDI Applications 257

Using Interceptors in CDI Applications 260

Using Decorators in CDI Applications 262

Using Stereotypes in CDI Applications 263

Chapter 15: Running the Advanced Contexts and Dependency Injection Examples 265

The encoder Example: Using Alternatives 265

The producermethods Example: Using a Producer Method to Choose a Bean Implementation


The producerfields Example: Using Producer Fields to Generate Resources 273

The billpayment Example: Using Events and Interceptors 280

The decorators Example: Decorating a Bean 286

Part VI: Persistence 291

Chapter 16: Creating and Using String-Based Criteria Queries 293

Overview of String-Based Criteria API Queries 293

Creating String-Based Queries 294

Executing String-Based Queries 295

Chapter 17: Controlling Concurrent Access to Entity Data with Locking 297

Overview of Entity Locking and Concurrency 297

Lock Modes 299

Chapter 18: Using a Second-Level Cache with Java Persistence API Applications 303

Overview of the Second-Level Cache 303

Specifying the Cache Mode Settings to Improve Performance 305

Part VII: Security 309

Chapter 19: Java EE Security: Advanced Topics 311

Working with Digital Certificates 311

Authentication Mechanisms 316

Using Form-Based Login in JavaServer Faces Web Applications 321

Using the JDBC Realm for User Authentication 324

Securing HTTP Resources 328

Securing Application Clients 331

Securing Enterprise Information Systems Applications 332

Configuring Security Using Deployment Descriptors 336

Further Information about Security 337

Part VIII: Java EE Supporting Technologies 339

Chapter 20: Java Message Service Concepts 341

Overview of the JMS API 341

Basic JMS API Concepts 345

The JMS API Programming Model 348

Creating Robust JMS Applications 359

Using the JMS API in Java EE Applications 368

Further Information about JMS 376

Chapter 21: Java Message Service Examples 377

Writing Simple JMS Applications 378

Writing Robust JMS Applications 406

An Application That Uses the JMS API with a Session Bean 416

An Application That Uses the JMS API with an Entity 421

An Application Example That Consumes Messages from a Remote Server 429

An Application Example That Deploys a Message-Driven Bean on Two Servers 436

Chapter 22: Bean Validation: Advanced Topics 449

Creating Custom Constraints 449

Customizing Validator Messages 450

Grouping Constraints 451

Chapter 23: Using Java EE Interceptors 453

Overview of Interceptors 453

Using Interceptors 455

The interceptor Example Application 460

Chapter 24: The Resource Adapter Example 463

The Resource Adapter 463

The Message-Driven Bean 464

The Web Application 464

Running the mailconnector Example 465

Part IX: Case Studies 469

Chapter 25: Duke’s Bookstore Case Study Example 471

Design and Architecture of Duke’s Bookstore 471

The Duke’s Bookstore Interface 472

Running the Duke’s Bookstore Case Study Application 477

Chapter 26: Duke’s Tutoring Case Study Example 479

Design and Architecture of Duke’s Tutoring 479

Main Interface 481

Administration Interface 486

Running the Duke’s Tutoring Case Study Application 487

Chapter 27: Duke’s Forest Case Study Example 491

Design and Architecture of Duke’s Forest 492

Building and Deploying the Duke’s Forest Case Study Application 506

Running the Duke’s Forest Application 509

Index 513

Eric Jendrock leads the Java EE Tutorial team and documents Java Servlet technology and Java security.

Ricardo Cervera-Navarro improved examples and added content in the JAX-RS and resource connections technology areas.

Ian Evans documents Enterprise JavaBeans, Java Persistence API, Bean Validation, Java Transaction API, JAX-RS, and JAX-WS.

Devika Gollapudi documented JavaServer Faces technology.

Kim Haase documents Contexts and Dependency Injection for the Java EE platform, JavaServer Faces technology, and Java Message Service (JMS).

William Markito, a member of the Platform Technology Solutions group at Oracle, created and documented the Duke’s Forest case study and also created examples for some of the technologies.

Chinmayee Srivathsa documents resource connections.