Java Platform, Enterprise Edition The Java EE Tutorial Java Platform, Enterprise Edition, Release 8 (original) (raw)
Title and Copyright Information
Preface
- Audience
- Documentation Accessibility
- Before You Read This Book
- Related Documentation
- Conventions
- Default Paths and File Names
Part I Introduction
1 Overview
- Introduction to Java EE
- Java EE 8 Platform Highlights
- Java EE Application Model
- Distributed Multitiered Applications
- Java EE Containers
- Web Services Support
- Java EE Application Assembly and Deployment
- Java EE 8 APIs
- Enterprise JavaBeans Technology
- Java Servlet Technology
- JavaServer Faces Technology
- JavaServer Pages Technology
- JavaServer Pages Standard Tag Library
- Java Persistence API
- Java Transaction API
- Java API for RESTful Web Services
- Managed Beans
- Contexts and Dependency Injection for Java EE
- Dependency Injection for Java
- Bean Validation
- Java Message Service API
- Java EE Connector Architecture
- JavaMail API
- Java Authorization Contract for Containers
- Java Authentication Service Provider Interface for Containers
- Java EE Security API
- Java API for WebSocket
- Java API for JSON Processing
- Java API for JSON Binding
- Concurrency Utilities for Java EE
- Batch Applications for the Java Platform
- Java EE 8 APIs in the Java Platform, Standard Edition 8
- Java Database Connectivity API
- Java Naming and Directory Interface API
- JavaBeans Activation Framework
- Java API for XML Processing
- Java Architecture for XML Binding
- Java API for XML Web Services
- SOAP with Attachments API for Java
- Java Authentication and Authorization Service
- Common Annotations for the Java Platform
- GlassFish Server Tools
2 Using the Tutorial Examples
- Required Software
- Starting and Stopping GlassFish Server
- Starting the Administration Console
- Starting and Stopping Apache Derby
- Building the Examples
- Tutorial Example Directory Structure
- Java EE Maven Archetypes in the Tutorial
- Debugging Java EE Applications
Part II Platform Basics
4 Injection
- Resource Injection
- Dependency Injection
- The Main Differences between Resource Injection and Dependency Injection
5 Packaging
- Packaging Applications
- Packaging Enterprise Beans
- Packaging Web Archives
- Packaging Resource Adapter Archives
Part III The Web Tier
6 Getting Started with Web Applications
- Web Applications
- Web Application Lifecycle
- A Web Module That Uses JavaServer Faces Technology: The hello1 Example
- To View the hello1 Web Module Using NetBeans IDE
* Introduction to Scopes - Packaging and Deploying the hello1 Web Module
* To Build and Package the hello1 Web Module Using NetBeans IDE
* To Build and Package the hello1 Web Module Using Maven - Viewing Deployed Web Modules
* To View Deployed Web Modules Using the Administration Console
* To View Deployed Web Modules Using the asadmin Command
* To View Deployed Web Modules Using NetBeans IDE - Running the Deployed hello1 Web Module
* Dynamic Reloading of Deployed Modules - Undeploying the hello1 Web Module
* To Undeploy the hello1 Web Module Using NetBeans IDE
* To Undeploy the hello1 Web Module Using Maven
- To View the hello1 Web Module Using NetBeans IDE
- A Web Module That Uses Java Servlet Technology: The hello2 Example
- Configuring Web Applications
- Setting Context Parameters
* To Add a Context Parameter Using NetBeans IDE
* To Create a web.xml File Using NetBeans IDE - Declaring Welcome Files
- Mapping Errors to Error Screens
* To Set Up Error Mapping Using NetBeans IDE - Declaring Resource References
* Declaring a Reference to a Resource
* Declaring a Reference to a Web Service
- Setting Context Parameters
- Further Information about Web Applications
7 JavaServer Faces Technology
- Introduction to JavaServer Faces Technology
- What Is a JavaServer Faces Application?
- JavaServer Faces Technology Benefits
- A Simple JavaServer Faces Application
- User Interface Component Model
- Navigation Model
- The Lifecycle of a JavaServer Faces Application
- Partial Processing and Partial Rendering
- Further Information about JavaServer Faces Technology
8 Introduction to Facelets
- What Is Facelets?
- The Lifecycle of a Facelets Application
- Developing a Simple Facelets Application: The guessnumber-jsf Example Application
- Creating a Facelets Application
* Developing a Managed Bean
* Creating Facelets Views - Configuring the Application
- Running the guessnumber-jsf Facelets Example
* To Build, Package, and Deploy the guessnumber-jsf Example Using NetBeans IDE
* To Build, Package, and Deploy the guessnumber-jsf Example Using Maven
* To Run the guessnumber-jsf Example
- Creating a Facelets Application
- Using Facelets Templates
- Composite Components
- Web Resources
- Relocatable Resources
- Resource Library Contracts
- HTML5-Friendly Markup
- Using Pass-Through Elements
- Using Pass-Through Attributes
- The reservation Example Application
* The Facelets Pages for the reservation Application
* The Managed Bean for the reservation Application
* To Build, Package, and Deploy the reservation Example Using NetBeans IDE
* To Build, Package, and Deploy the reservation Example Using Maven
* To Run the reservation Example
9 Expression Language
- Overview of the EL
- Immediate and Deferred Evaluation Syntax
- Value and Method Expressions
- Operations on Collection Objects
- Operators
- Reserved Words
- Examples of EL Expressions
- Further Information about the Expression Language
10 Using JavaServer Faces Technology in Web Pages
- Setting Up a Page
- Adding Components to a Page Using HTML Tag Library Tags
- Common Component Tag Attributes
* The id Attribute
* The immediate Attribute
* The rendered Attribute
* The style and styleClass Attributes
* The value and binding Attributes - Adding HTML Head and Body Tags
- Adding a Form Component
- Using Text Components
* Rendering a Field with the h:inputText Tag
* Rendering a Password Field with the h:inputSecret Tag
* Rendering a Label with the h:outputLabel Tag
* Rendering a Link with the h:outputLink Tag
* Displaying a Formatted Message with the h:outputFormat Tag - Using Command Component Tags for Performing Actions and Navigation
* Rendering a Button with the h:commandButton Tag
* Rendering a Link with the h:commandLink Tag - Adding Graphics and Images with the h:graphicImage Tag
- Laying Out Components with the h:panelGrid and h:panelGroup Tags
- Displaying Components for Selecting One Value
* Displaying a Check Box Using the h:selectBooleanCheckbox Tag
* Displaying a Menu Using the h:selectOneMenu Tag - Displaying Components for Selecting Multiple Values
- Using the f:selectItem and f:selectItems Tags
* Using the f:selectItems Tag
* Using the f:selectItem Tag - Displaying the Results from Selection Components
- Using Data-Bound Table Components
- Displaying Error Messages with the h:message and h:messages Tags
- Creating Bookmarkable URLs with the h:button and h:link Tags
- Using View Parameters to Configure Bookmarkable URLs
- The bookmarks Example Application
* To Build, Package, and Deploy the bookmarks Example Using NetBeans IDE
* To Build, Package, and Deploy the bookmarks Example Using Maven
* To Run the bookmarks Example - Resource Relocation Using h:outputScript and h:outputStylesheet Tags
- Common Component Tag Attributes
- Using Core Tags
11 Using Converters, Listeners, and Validators
- Using the Standard Converters
- Registering Listeners on Components
- Using the Standard Validators
- Referencing a Managed Bean Method
12 Developing with JavaServer Faces Technology
- Managed Beans in JavaServer Faces Technology
- Writing Bean Properties
- Writing Properties Bound to Component Values
* UIInput and UIOutput Properties
* UIData Properties
* UISelectBoolean Properties
* UISelectMany Properties
* UISelectOne Properties
* UISelectItem Properties
* UISelectItems Properties - Writing Properties Bound to Component Instances
- Writing Properties Bound to Converters, Listeners, or Validators
- Writing Properties Bound to Component Values
- Writing Managed Bean Methods
13 Using Ajax with JavaServer Faces Technology
- Overview of Ajax
- Using Ajax Functionality with JavaServer Faces Technology
- Using Ajax with Facelets
- Sending an Ajax Request
- Monitoring Events on the Client
- Handling Errors
- Receiving an Ajax Response
- Ajax Request Lifecycle
- Grouping of Components
- Loading JavaScript as a Resource
- The ajaxguessnumber Example Application
- The ajaxguessnumber Source Files
* The ajaxgreeting.xhtml Facelets Page
* The UserNumberBean Backing Bean
* The DukesNumberBean CDI Managed Bean - Running the ajaxguessnumber Example
* To Build, Package, and Deploy the ajaxguessnumber Example Using NetBeans IDE
* To Build, Package, and Deploy the ajaxguessnumber Example Using Maven
* To Run the ajaxguessnumber Example
- The ajaxguessnumber Source Files
- Further Information about Ajax in JavaServer Faces Technology
14 Composite Components: Advanced Topics and an Example
- Attributes of a Composite Component
- Invoking a Managed Bean
- Validating Composite Component Values
- The compositecomponentexample Example Application
- The Composite Component File
- The Using Page
- The Managed Bean
- Running the compositecomponentexample Example
* To Build, Package, and Deploy the compositecomponentexample Example Using NetBeans IDE
* To Build, Package, and Deploy the compositecomponentexample Example Using Maven
* To Run the compositecomponentexample Example
15 Creating Custom UI Components and Other Custom Objects
- Introduction to Creating Custom Components
- Determining Whether You Need a Custom Component or Renderer
- Understanding the Image Map Example
- Steps for Creating a Custom Component
- Creating Custom Component Classes
- Delegating Rendering to a Renderer
- Implementing an Event Listener
- Handling Events for Custom Components
- Defining the Custom Component Tag in a Tag Library Descriptor
- Using a Custom Component
- Creating and Using a Custom Converter
- Creating and Using a Custom Validator
- Binding Component Values and Instances to Managed Bean Properties
- Binding Converters, Listeners, and Validators to Managed Bean Properties
16 Configuring JavaServer Faces Applications
- Introduction to Configuring JavaServer Faces Applications
- Using Annotations to Configure Managed Beans
- Application Configuration Resource File
- Using Faces Flows
- Packaging Flows in an Application
- The Simplest Possible Flow: The simple-flow Example Application
* To Build, Package, and Deploy the simple-flow Example Using NetBeans IDE
* To Build, Package, and Deploy the simple-flow Example Using Maven
* To Run the simple-flow Example - The checkout-module Example Application
* The Facelets Pages for the checkout-module Example
* Using a Configuration File to Configure a Flow
* Using a Java Class to Configure a Flow
* The Flow-Scoped Managed Beans
* To Build, Package, and Deploy the checkout-module Example Using NetBeans IDE
* To Build, Package, and Deploy the checkout-module Example Using Maven
* To Run the checkout-module Example
- Configuring Managed Beans
- Using the managed-bean Element
- Initializing Properties Using the managed-property Element
* Referencing a Java Enum Type
* Referencing a Context Initialization Parameter
* Initializing Map Properties
* Initializing Array and List Properties
* Initializing Managed Bean Properties - Initializing Maps and Lists
- Registering Application Messages
- Using Default Validators
- Registering a Custom Validator
- Registering a Custom Converter
- Configuring Navigation Rules
- Registering a Custom Renderer with a Render Kit
- Registering a Custom Component
- Basic Requirements of a JavaServer Faces Application
17 Using WebSockets with JavaServer Faces Technology
- About WebSockets in JSF
- Configuring WebSockets
- Using the f:websocket Tag
- WebSocket Scopes and Users
- Conditionally Connecting WebSockets
- WebSocket Security Considerations
- Using Ajax With WebSockets
18 Java Servlet Technology
- What Is a Servlet?
- Servlet Lifecycle
- Sharing Information
- Creating and Initializing a Servlet
- Writing Service Methods
- Filtering Requests and Responses
- Invoking Other Web Resources
- Accessing the Web Context
- Maintaining Client State
- Finalizing a Servlet
- Uploading Files with Java Servlet Technology
- Asynchronous Processing
- Nonblocking I/O
- Protocol Upgrade Processing
- Server Push
- HTTP Trailer
- The mood Example Application
- The fileupload Example Application
- The dukeetf Example Application
- Further Information about Java Servlet Technology
19 Java API for WebSocket
- Introduction to WebSocket
- Creating WebSocket Applications in the Java EE Platform
- Programmatic Endpoints
- Annotated Endpoints
- Sending and Receiving Messages
- Maintaining Client State
- Using Encoders and Decoders
- Path Parameters
- Handling Errors
- Specifying an Endpoint Configurator Class
- The dukeetf2 Example Application
- The websocketbot Example Application
- Architecture of the websocketbot Example Application
* The CDI Bean
* The WebSocket Endpoint
* The Application Messages
* The Encoder Classes
* The Message Decoder
* The HTML Page - Running the websocketbot Example Application
* To Run the websocketbot Example Application Using NetBeans IDE
* To Run the websocketbot Example Application Using Maven
* To Test the websocketbot Example Application
- Architecture of the websocketbot Example Application
- Further Information about WebSocket
20 JSON Processing
- Introduction to JSON
- JSON Processing in the Java EE Platform
- Using the Object Model API
- Using the Streaming API
- JSON in Java EE RESTful Web Services
- The jsonpmodel Example Application
- The jsonpstreaming Example Application
- Further Information about the Java API for JSON Processing
21 JSON Binding
- JSON Binding in the Java EE Platform
- Overview of the JSON Binding API
- Running the jsonbbasics Example Application
- Further Information about the Java API for JSON Binding
22 Internationalizing and Localizing Web Applications
- Java Platform Localization Classes
- Providing Localized Messages and Labels
- Date and Number Formatting
- Character Sets and Encodings
Part IV Bean Validation
23 Introduction to Bean Validation
- Overview of Bean Validation
- Using Bean Validation Constraints
- Validating Null and Empty Strings
- Validating Constructors and Methods
- Further Information about Bean Validation
24 Bean Validation: Advanced Topics
- Creating Custom Constraints
- Customizing Validator Messages
- Grouping Constraints
- Using Method Constraints in Type Hierarchies
Part V Contexts and Dependency Injection for Java EE
25 Introduction to Contexts and Dependency Injection for Java EE
- Getting Started
- Overview of CDI
- About Beans
- About CDI Managed Beans
- Beans as Injectable Objects
- Using Qualifiers
- Injecting Beans
- Using Scopes
- Giving Beans EL Names
- Adding Setter and Getter Methods
- Using a Managed Bean in a Facelets Page
- Injecting Objects by Using Producer Methods
- Configuring a CDI Application
- Using the @PostConstruct and @PreDestroy Annotations with CDI Managed Bean Classes
- Further Information about CDI
26 Running the Basic Contexts and Dependency Injection Examples
- Building and Running the CDI Samples
- The simplegreeting CDI Example
- The guessnumber-cdi CDI Example
- The guessnumber-cdi Source Files
* The @MaxNumber and @Random Qualifier Interfaces
* The Generator Managed Bean
* The UserNumberBean Managed Bean - The Facelets Page
- Running the guessnumber-cdi Example
* To Build, Package, and Deploy the guessnumber-cdi Example Using NetBeans IDE
* To Build, Package, and Deploy the guessnumber-cdi Example Using Maven
* To Run the guessnumber Example
- The guessnumber-cdi Source Files
27 Contexts and Dependency Injection for Java EE: Advanced Topics
- Packaging CDI Applications
- Using Alternatives in CDI Applications
- Using Producer Methods, Producer Fields, and Disposer Methods in CDI Applications
- Using Predefined Beans in CDI Applications
- Using Events in CDI Applications
- Using Interceptors in CDI Applications
- Using Decorators in CDI Applications
- Using Stereotypes in CDI Applications
- Using the Built-In Annotation Literals
- Using the Configurators Interfaces
29 Running the Advanced Contexts and Dependency Injection Examples
- Building and Running the CDI Advanced Examples
- The encoder Example: Using Alternatives
- The Coder Interface and Implementations
- The encoder Facelets Page and Managed Bean
- Running the encoder Example
* To Build, Package, and Deploy the encoder Example Using NetBeans IDE
* To Run the encoder Example Using NetBeans IDE
* To Build, Package, and Deploy the encoder Example Using Maven
* To Run the encoder Example Using Maven
- The producermethods Example: Using a Producer Method to Choose a Bean Implementation
- The producerfields Example: Using Producer Fields to Generate Resources
- The Producer Field for the producerfields Example
- The producerfields Entity and Session Bean
- The producerfields Facelets Pages and Managed Bean
- Running the producerfields Example
* To Build, Package, and Deploy the producerfields Example Using NetBeans IDE
* To Build, Package, and Deploy the producerfields Example Using Maven
* To Run the producerfields Example
- The billpayment Example: Using Events and Interceptors
- Overview of the billpayment Example
- The PaymentEvent Event Class
- The PaymentHandler Event Listener
- The billpayment Facelets Pages and Managed Bean
- The LoggedInterceptor Interceptor Class
- Running the billpayment Example
* To Build, Package, and Deploy the billpayment Example Using NetBeans IDE
* To Build, Package, and Deploy the billpayment Example Using Maven
* To Run the billpayment Example
- The decorators Example: Decorating a Bean
Part VI Web Services
30 Introduction to Web Services
31 Building Web Services with JAX-WS
- Overview of Java API for XML Web Services
- Creating a Simple Web Service and Clients with JAX-WS
- Basic Steps for Creating a Web Service and Client
- Requirements of a JAX-WS Endpoint
- Coding the Service Endpoint Implementation Class
- Building, Packaging, and Deploying the Service
* To Build, Package, and Deploy the Service Using NetBeans IDE
* To Build, Package, and Deploy the Service Using Maven - Testing the Methods of a Web Service Endpoint
* To Test the Service without a Client - A Simple JAX-WS Application Client
* Coding the Application Client
* Running the Application Client - A Simple JAX-WS Web Client
* Coding the Servlet
* Running the Web Client
- Types Supported by JAX-WS
- Web Services Interoperability and JAX-WS
- Further Information about JAX-WS
32 Building RESTful Web Services with JAX-RS
- What Are RESTful Web Services?
- Creating a RESTful Root Resource Class
- Developing RESTful Web Services with JAX-RS
- Overview of a JAX-RS Application
- The @Path Annotation and URI Path Templates
- Responding to HTTP Methods and Requests
* The Request Method Designator Annotations
* Using Entity Providers to Map HTTP Response and Request Entity Bodies - Using @Consumes and @Produces to Customize Requests and Responses
* The @Produces Annotation
* The @Consumes Annotation - Extracting Request Parameters
- Configuring JAX-RS Applications
* Configuring a JAX-RS Application Using a Subclass of Application
* Configuring the Base URI in web.xml
- Example Applications for JAX-RS
- Further Information about JAX-RS
33 Accessing REST Resources with the JAX-RS Client API
- Overview of the Client API
- Using the Client API in the JAX-RS Example Applications
- Advanced Features of the Client API
- Configuring the Client Request
* Setting Message Headers in the Client Request
* Setting Cookies in the Client Request
* Adding Filters to the Client - Asynchronous Invocations in the Client API
* Using Custom Callbacks in Asynchronous Invocations
* Using Reactive Approach in Asynchronous Invocations - Using Server-Sent Events
- Overview of the SSE API
- Broadcasting Using SSE
- Listening and Receiving Events
- Configuring the Client Request
34 JAX-RS: Advanced Topics and an Example
- Annotations for Field and Bean Properties of Resource Classes
- Validating Resource Data with Bean Validation
- Subresources and Runtime Resource Resolution
- Integrating JAX-RS with EJB Technology and CDI
- Conditional HTTP Requests
- Runtime Content Negotiation
- Using JAX-RS with JAXB
- The customer Example Application
- Overview of the customer Example Application
- The Customer and Address Entity Classes
- The CustomerService Class
- Using the JAX-RS Client in the CustomerBean Classes
- Running the customer Example
* To Build, Package, and Deploy the customer Example Using NetBeans IDE
* To Build, Package, and Deploy the customer Example Using Maven
Part VII Enterprise Beans
35 Enterprise Beans
- What Is an Enterprise Bean?
- What Is a Session Bean?
- What Is a Message-Driven Bean?
- Accessing Enterprise Beans
- Using Enterprise Beans in Clients
* Portable JNDI Syntax - Deciding on Remote or Local Access
- Local Clients
* Accessing Local Enterprise Beans Using the No-Interface View
* Accessing Local Enterprise Beans That Implement Business Interfaces - Remote Clients
- Web Service Clients
- Method Parameters and Access
* Isolation
* Granularity of Accessed Data
- Using Enterprise Beans in Clients
- The Contents of an Enterprise Bean
- Naming Conventions for Enterprise Beans
- The Lifecycles of Enterprise Beans
- Further Information about Enterprise Beans
36 Getting Started with Enterprise Beans
37 Running the Enterprise Bean Examples
- Overview of the EJB Examples
- The cart Example
- A Singleton Session Bean Example: counter
- Creating a Singleton Session Bean
* Initializing Singleton Session Beans
* Managing Concurrent Access in a Singleton Session Bean
* Handling Errors in a Singleton Session Bean - The Architecture of the counter Example
- Running the counter Example
* To Run the counter Example Using NetBeans IDE
* To Run the counter Example Using Maven
- Creating a Singleton Session Bean
- A Web Service Example: helloservice
- The Web Service Endpoint Implementation Class
- Stateless Session Bean Implementation Class
- Running the helloservice Example
* To Build, Package, and Deploy the helloservice Example Using NetBeans IDE
* To Build, Package, and Deploy the helloservice Example Using Maven
* To Test the Service without a Client
- Using the Timer Service
- Creating Calendar-Based Timer Expressions
* Specifying Multiple Values in Calendar Expressions - Programmatic Timers
* The @Timeout Method
* Creating Programmatic Timers - Automatic Timers
- Canceling and Saving Timers
- Getting Timer Information
- Transactions and Timers
- The timersession Example
- Running the timersession Example
* To Run the timersession Example Using NetBeans IDE
* To Build, Package, and Deploy the timersession Example Using Maven
* To Run the Web Client
- Creating Calendar-Based Timer Expressions
- Handling Exceptions
38 Using the Embedded Enterprise Bean Container
- Overview of the Embedded Enterprise Bean Container
- Developing Embeddable Enterprise Bean Applications
- The standalone Example Application
39 Using Asynchronous Method Invocation in Session Beans
Part VIII Persistence
40 Introduction to the Java Persistence API
- Overview of the Java Persistence API
- Entities
- Requirements for Entity Classes
- Persistent Fields and Properties in Entity Classes
* Persistent Fields
* Persistent Properties
* Using Collections in Entity Fields and Properties
* Validating Persistent Fields and Properties - Primary Keys in Entities
- Multiplicity in Entity Relationships
- Direction in Entity Relationships
* Bidirectional Relationships
* Unidirectional Relationships
* Queries and Relationship Direction
* Cascade Operations and Relationships
* Orphan Removal in Relationships - Embeddable Classes in Entities
- Entity Inheritance
- Managing Entities
- Querying Entities
- Database Schema Creation
- Further Information about Persistence
41 Running the Persistence Examples
- Overview of the Persistence Examples
- The order Application
- Entity Relationships in the order Application
* Self-Referential Relationships
* One-to-One Relationships
* One-to-Many Relationship Mapped to Overlapping Primary and Foreign Keys
* Unidirectional Relationships - Primary Keys in the order Application
* Generated Primary Keys
* Compound Primary Keys - Entity Mapped to More Than One Database Table
- Cascade Operations in the order Application
- BLOB and CLOB Database Types in the order Application
- Temporal Types in the order Application
- Managing the order Application’s Entities
* Creating Entities
* Finding Entities
* Setting Entity Relationships
* Using Queries
* Removing Entities - Running the order Example
* To Run the order Example Using NetBeans IDE
* To Run the order Example Using Maven
- Entity Relationships in the order Application
- The roster Application
- Relationships in the roster Application
* The Many-To-Many Relationship in roster - Entity Inheritance in the roster Application
- Criteria Queries in the roster Application
* Metamodel Classes in the roster Application
* Obtaining a CriteriaBuilder Instance in RequestBean
* Creating Criteria Queries in RequestBean’s Business Methods - Automatic Table Generation in the roster Application
- Running the roster Example
* To Run the roster Example Using NetBeans IDE
* To Run the roster Example Using Maven
- Relationships in the roster Application
- The address-book Application
42 The Java Persistence Query Language
- Overview of the Java Persistence Query Language
- Query Language Terminology
- Creating Queries Using the Java Persistence Query Language
- Simplified Query Language Syntax
- Example Queries
- Simple Queries
* A Basic Select Query
* Eliminating Duplicate Values
* Using Named Parameters - Queries That Navigate to Related Entities
* A Simple Query with Relationships
* Navigating to Single-Valued Relationship Fields
* Traversing Relationships with an Input Parameter
* Traversing Multiple Relationships
* Navigating According to Related Fields - Queries with Other Conditional Expressions
* The LIKE Expression
* The IS NULL Expression
* The IS EMPTY Expression
* The BETWEEN Expression
* Comparison Operators - Bulk Updates and Deletes
* Update Queries
* Delete Queries
- Simple Queries
- Full Query Language Syntax
- BNF Symbols
- BNF Grammar of the Java Persistence Query Language
- FROM Clause
* Identifiers
* Identification Variables
* Range Variable Declarations
* Collection Member Declarations
* Joins - Path Expressions
* Examples of Path Expressions
* Expression Types
* Navigation - WHERE Clause
* Literals
* Input Parameters
* Conditional Expressions
* Operators and Their Precedence
* BETWEEN Expressions
* IN Expressions
* LIKE Expressions
* NULL Comparison Expressions
* Empty Collection Comparison Expressions
* Collection Member Expressions
* Subqueries
* Functional Expressions
* Case Expressions
* NULL Values
* Equality Semantics - SELECT Clause
* Return Types
* The DISTINCT Keyword
* Constructor Expressions - ORDER BY Clause
- GROUP BY and HAVING Clauses
43 Using the Criteria API to Create Queries
- Overview of the Criteria and Metamodel APIs
- Using the Metamodel API to Model Entity Classes
- Using the Criteria API and Metamodel API to Create Basic Typesafe Queries
- Creating a Criteria Query
- Query Roots
- Querying Relationships Using Joins
- Path Navigation in Criteria Queries
- Restricting Criteria Query Results
* The Expression Interface Methods
* Expression Methods in the CriteriaBuilder Interface - Managing Criteria Query Results
* Ordering Results
* Grouping Results - Executing Queries
* Single-Valued Query Results
* Collection-Valued Query Results
45 Controlling Concurrent Access to Entity Data with Locking
46 Creating Fetch Plans with Entity Graphs
- Overview of Using Fetch Plans and Entity Graphs
- Entity Graph Basics
- Using Named Entity Graphs
- Using Entity Graphs in Query Operations
47 Using a Second-Level Cache with Java Persistence API Applications
- Overview of the Second-Level Cache
- Specifying the Cache Mode Settings to Improve Performance
- Setting the Cache Retrieval and Store Modes
* Cache Retrieval Mode
* Cache Store Mode
* Setting the Cache Retrieval or Store Mode - Controlling the Second-Level Cache Programmatically
* Overview of the javax.persistence.Cache Interface
* Checking whether an Entity’s Data Is Cached
* Removing an Entity from the Cache
* Removing All Data from the Cache
- Setting the Cache Retrieval and Store Modes
Part IX Messaging
48 Java Message Service Concepts
- Overview of the JMS API
- Basic JMS API Concepts
- The JMS API Programming Model
- JMS Administered Objects
* JMS Connection Factories
* JMS Destinations - Connections
- Sessions
- JMSContext Objects
- JMS Message Producers
- JMS Message Consumers
* JMS Message Listeners
* JMS Message Selectors
* Consuming Messages from Topics
* Creating Durable Subscriptions
* Creating Shared Subscriptions - JMS Messages
* Message Headers
* Message Properties
* Message Bodies - JMS Queue Browsers
- JMS Exception Handling
- JMS Administered Objects
- Using Advanced JMS Features
- Controlling Message Acknowledgment
- Specifying Options for Sending Messages
* Specifying Message Persistence
* Setting Message Priority Levels
* Allowing Messages to Expire
* Specifying a Delivery Delay
* Using JMSProducer Method Chaining - Creating Temporary Destinations
- Using JMS Local Transactions
- Sending Messages Asynchronously
- Using the JMS API in Java EE Applications
- Overview of Using the JMS API
- Creating Resources for Java EE Applications
- Using Resource Injection in Enterprise Bean or Web Components
* Injecting a ConnectionFactory, Queue, or Topic
* Injecting a JMSContext Object - Using Java EE Components to Produce and to Synchronously Receive Messages
* Managing JMS Resources in Web and EJB Components
* Managing Transactions in Session Beans - Using Message-Driven Beans to Receive Messages Asynchronously
- Managing JTA Transactions
- Further Information about JMS
49 Java Message Service Examples
- Building and Running Java Message Service Examples
- Overview of the JMS Examples
- Writing Simple JMS Applications
- Overview of Writing Simple JMS Application
- Starting the JMS Provider
- Creating JMS Administered Objects
* To Create Resources for the Simple Examples - Building All the Simple Examples
* To Build All the Simple Examples Using NetBeans IDE
* To Build All the Simple Examples Using Maven - Sending Messages
* General Steps Performed in the Example
* The Producer.java Client
* To Run the Producer Client - Receiving Messages Synchronously
* The SynchConsumer.java Client
* To Run the SynchConsumer and Producer Clients - Using a Message Listener for Asynchronous Message Delivery
* Writing the AsynchConsumer.java and TextListener.java Clients
* To Run the AsynchConsumer and Producer Clients - Browsing Messages on a Queue
* The MessageBrowser.java Client
* To Run the QueueBrowser Client - Running Multiple Consumers on the Same Destination
- Acknowledging Messages
* To Run the ClientAckConsumer Client
- Writing More Advanced JMS Applications
- Writing High Performance and Scalable JMS Applications
- Sending and Receiving Messages Using a Simple Web Application
- The websimplemessage Facelets Pages
- The websimplemessage Managed Beans
- Running the websimplemessage Example
* Creating Resources for the websimplemessage Example
* To Package and Deploy websimplemessage Using NetBeans IDE
* To Package and Deploy websimplemessage Using Maven
* To Run the websimplemessage Example
- Receiving Messages Asynchronously Using a Message-Driven Bean
- Overview of the simplemessage Example
- The simplemessage Application Client
- The simplemessage Message-Driven Bean Class
* The onMessage Method - Running the simplemessage Example
* Creating Resources for the simplemessage Example
* To Run the simplemessage Example Using NetBeans IDE
* To Run the simplemessage Example Using Maven
- Sending Messages from a Session Bean to an MDB
- Writing the Application Components for the clientsessionmdb Example
* Coding the Application Client: MyAppClient.java
* Coding the Publisher Session Bean
* Coding the Message-Driven Bean: MessageBean.java - Running the clientsessionmdb Example
* To Run clientsessionmdb Using NetBeans IDE
* To Run clientsessionmdb Using Maven
- Writing the Application Components for the clientsessionmdb Example
- Using an Entity to Join Messages from Two MDBs
- Overview of the clientmdbentity Example Application
- Writing the Application Components for the clientmdbentity Example
* Coding the Application Client: HumanResourceClient.java
* Coding the Message-Driven Beans for the clientmdbentity Example
* Coding the Entity Class for the clientmdbentity Example - Running the clientmdbentity Example
* To Run clientmdbentity Using NetBeans IDE
* To Run clientmdbentity Using Maven
* Viewing the Application Output
- Using NetBeans IDE to Create JMS Resources
Part X Security
50 Introduction to Security in the Java EE Platform
- Overview of Java EE Security
- Security Mechanisms
- Securing Containers
- Using Pluggable Providers
- Securing GlassFish Server
- Working with Realms, Users, Groups, and Roles
- Working with Identity Stores
- Establishing a Secure Connection Using SSL
- Further Information about Security
51 Getting Started Securing Web Applications
- Overview of Web Application Security
- Securing Web Applications
- Overview of Securing Web Applications
- Specifying Security Constraints
* Specifying a Web Resource Collection
* Specifying an Authorization Constraint
* Specifying a Secure Connection
* Specifying Security Constraints for Resources - Specifying Authentication Mechanisms
* HTTP Basic Authentication
* Form-Based Authentication
* Digest Authentication - Specifying an Authentication Mechanism in the Deployment Descriptor
- Declaring Security Roles
- Using Programmatic Security with Web Applications
- Examples: Securing Web Applications
- Overview of Examples of Securing Web Applications
- To Set Up Your System for Running the Security Examples
- The hello2-basicauth Example: Basic Authentication with a Servlet
* Specifying Security for Basic Authentication Using Annotations
* To Build, Package, and Deploy the hello2-basicauth Example Using NetBeans IDE
* To Build, Package, and Deploy the hello2-basicauth Example Using Maven
* To Run the hello2-basicauth Example - The hello1-formauth Example: Form-Based Authentication with a JavaServer Faces Application
* Creating the Login Form and the Error Page
* Specifying Security for the Form-Based Authentication Example
* To Build, Package, and Deploy the hello1-formauth Example Using NetBeans IDE
* To Build, Package, and Deploy the hello1-formauth Example Using Maven and the asadmin Command
* To Run the hello1-formauth Example
52 Getting Started Securing Enterprise Applications
- Basic Security Tasks for Enterprise Applications
- Securing Enterprise Beans
- Securing an Enterprise Bean Using Declarative Security
* Specifying Authorized Users by Declaring Security Roles
* Specifying an Authentication Mechanism and Secure Connection - Securing an Enterprise Bean Programmatically
- Propagating a Security Identity (Run-As)
* Configuring a Component’s Propagated Security Identity
* Trust between Containers - Deploying Secure Enterprise Beans
- Securing an Enterprise Bean Using Declarative Security
- Examples: Securing Enterprise Beans
- The cart-secure Example: Securing an Enterprise Bean with Declarative Security
* Annotating the Bean
* To Run the cart-secure Example Using NetBeans IDE
* To Run the cart-secure Example Using Maven - The converter-secure Example: Securing an Enterprise Bean with Programmatic Security
* Modifying ConverterBean
* Modifying ConverterServlet
* To Run the converter-secure Example Using NetBeans IDE
* To Run the converter-secure Example Using Maven
* To Run the converter-secure Example
- The cart-secure Example: Securing an Enterprise Bean with Declarative Security
53 Using the Java EE Security API
- About the Java EE Security API
- Overview of the HTTP Authentication Mechanism Interface
- Overview of the Identity Store Interfaces
- Running the Built-In Database Identity Store Example
- Overview of the Built-In Database Identity Store Example
* Define the Users and Groups in the Identity Store
* Map the DatabaseIdentityStore to the Default Data source
* Specify the Authentication Mechanism
* Declare Roles in the Servlet Container - Running the built-in-db-identity-store Example
* To Build, Package, and Deploy the built-in-db-identity-store Example Using NetBeans IDE
* To Build, Package, and Deploy the built-in-db-identity-store Example Using Maven
* To Run the built-in-db-identity-store Example
- Overview of the Built-In Database Identity Store Example
- Running the Custom Identity Store Example
- Overview of the Custom Identity Store Example
* Define the Users and Groups in the Identity Store
* Specify the Authentication Mechanism
* Declare Roles in the Servlet Container - Running the custom-identity-store Example
* To Build, Package, and Deploy the custom-identity-store Example Using NetBeans IDE
* To Build, Package, and Deploy the custom-identity-store Example Using Maven
* To Run the custom-identity-store Example
- Overview of the Custom Identity Store Example
54 Java EE Security: Advanced Topics
- Working with Digital Certificates
- Authentication Mechanisms
- Using the JDBC Realm for User Authentication
- Securing HTTP Resources
- Securing Application Clients
- Securing Enterprise Information Systems Applications
- Configuring Security Using Deployment Descriptors
- Further Information about Advanced Security Topics
Part XI Java EE Supporting Technologies
55 Transactions
- Overview of Transactions
- Transactions in Java EE Applications
- What Is a Transaction?
- Container-Managed Transactions
- Transaction Attributes
* Required Attribute
* RequiresNew Attribute
* Mandatory Attribute
* NotSupported Attribute
* Supports Attribute
* Never Attribute
* Summary of Transaction Attributes
* Setting Transaction Attributes - Rolling Back a Container-Managed Transaction
- Synchronizing a Session Bean’s Instance Variables
- Methods Not Allowed in Container-Managed Transactions
- Transaction Attributes
- Bean-Managed Transactions
- Transaction Timeouts
- Updating Multiple Databases
- Transactions in Web Components
- Further Information about Transactions
56 Resource Adapters and Contracts
- What Is a Resource Adapter?
- Metadata Annotations
- Common Client Interface
- Using Resource Adapters with Contexts and Dependency Injection for Java EE (CDI)
- Further Information about Resource Adapters
57 The Resource Adapter Examples
58 Using Java EE Interceptors
- Overview of Interceptors
- Using Interceptors
- Intercepting Method Invocations
* Using Multiple Method Interceptors
* Accessing Target Method Parameters from an Interceptor Class - Intercepting Lifecycle Callback Events
* Using AroundConstruct Interceptor Methods
* Using Multiple Lifecycle Callback Interceptors - Intercepting Timeout Events
* Using Multiple Timeout Interceptors - Binding Interceptors to Components
* Declaring the Interceptor Bindings on an Interceptor Class
* Binding a Component to an Interceptor - Ordering Interceptors
- Intercepting Method Invocations
- The interceptor Example Application
59 Batch Processing
- Introduction to Batch Processing
- Batch Processing in Java EE
- Simple Use Case
- Using the Job Specification Language
- Creating Batch Artifacts
- Submitting Jobs to the Batch Runtime
- Packaging Batch Applications
- The webserverlog Example Application
- Architecture of the webserverlog Example Application
* The Job Definition File
* The LogLine and LogFilteredLine Items
* The Chunk Step Batch Artifacts
* The Listener Batch Artifacts
* The Task Step Batch Artifact
* The JavaServer Faces Pages
* The Managed Bean - Running the webserverlog Example Application
* To Run the webserverlog Example Application Using NetBeans IDE
* To Run the webserverlog Example Application Using Maven
- Architecture of the webserverlog Example Application
- The phonebilling Example Application
- Architecture of the phonebilling Example Application
* The Job Definition File
* The CallRecord and PhoneBill Entities
* The Call Records Chunk Step
* The Phone Billing Chunk Step
* The JavaServer Faces Pages
* The Managed Bean - Running the phonebilling Example Application
* To Run the phonebilling Example Application Using NetBeans IDE
* To Run the phonebilling Example Application Using Maven
- Architecture of the phonebilling Example Application
- Further Information about Batch Processing
60 Concurrency Utilities for Java EE
- Concurrency Basics
- Main Components of the Concurrency Utilities
- Concurrency and Transactions
- Concurrency and Security
- The jobs Concurrency Example
- Running the jobs Example
* To Configure GlassFish Server for the Basic Concurrency Example
* To Build, Package, and Deploy the jobs Example Using NetBeans IDE
* To Build, Package, and Deploy the jobs Example Using Maven
* To Run the jobs Example and Submit Jobs with Low Priority
* To Run the jobs Example and Submit Jobs with High Priority
- Running the jobs Example
- The taskcreator Concurrency Example
- Further Information about the Concurrency Utilities
Part XII Case Studies
61 Duke’s Bookstore Case Study Example
- Design and Architecture of Duke’s Bookstore
- The Duke’s Bookstore Interface
- Running the Duke’s Bookstore Case Study Application
62 Duke’s Tutoring Case Study Example
- Design and Architecture of Duke’s Tutoring
- Main Interface
- Administration Interface
- Running the Duke’s Tutoring Case Study Application
63 Duke’s Forest Case Study Example
- Overview of the Duke’s Forest Case Study Example
- Design and Architecture of Duke’s Forest
- The events Project
- The entities Project
- The dukes-payment Project
- The dukes-resources Project
- The Duke’s Store Project
* Enterprise Beans Used in Duke’s Store
* Facelets Files Used in the Main Interface of Duke’s Store
* Facelets Files Used in the Administration Interface of Duke’s Store
* Managed Beans Used in Duke’s Store
* Helper Classes Used in Duke’s Store
* Qualifiers Used in Duke’s Store
* Event Handlers Used in Duke’s Store
* Deployment Descriptors Used in Duke’s Store - The Duke’s Shipment Project
* Enterprise Beans Used in Duke’s Shipment
* Facelets Files Used in Duke’s Shipment
* Managed Beans Used in Duke’s Shipment
* Helper Class Used in Duke’s Shipment
* Qualifier Used in Duke’s Shipment
* Deployment Descriptors Used in Duke’s Shipment
- Building and Deploying the Duke’s Forest Case Study Application
- Running the Duke’s Forest Application