You are previewing EJB 3 Developer Guide.
O'Reilly logo
EJB 3 Developer Guide

Book Description

A Practical Guide for developers and architects to the Enterprise Java Beans Standard.

  • A rapid introduction to the features of EJB 3

  • EJB 3 features explored concisely with accompanying code examples

  • Easily enhance Java applications with new, improved Enterprise Java Beans

Table of Contents

  1. EJB 3 Developer Guide
  2. Credits
  3. About the Author
  4. About the Reviewers
  5. Preface
    1. What This Book Covers
    2. What You Need for This Book
    3. Who Is This Book For
    4. Approach of this Book
    5. Conventions
    6. Reader Feedback
    7. Customer Support
      1. Downloading the Example Code for the Book
      2. Errata
      3. Questions
  6. 1. Introduction to the EJB 3 Architecture
    1. Introduction to the Java EE Architecture
    2. The EJB 3 Architecture
      1. EJB Container Services
      2. The JPA Persistence Engine
      3. EJB 3 Compared with Earlier Versions
    3. Getting Started
      1. Installing GlassFish
      2. Testing the Installation
      3. Accessing the Administrator Console
      4. Shutting Down GlassFish
      5. Downloading Example Source Code
    4. Summary
  7. 2. Session Beans
    1. Introduction
    2. Stateless Session Beans
      1. Annotations
      2. Creating a Session Bean Client
      3. Running the Example
      4. The Program Directory Structure
      5. The Ant Build Script
      6. The Application Client Container
        1. Building the Application
      7. Stateless Session Bean's LifeCycle
    3. Stateful Session Beans
      1. Stateful Session Bean's LifeCycle
    4. Local Interfaces
    5. Summary
  8. 3. Entities
    1. Introduction
    2. EJB 3 Entities
      1. Comparison with EJB 2.x Entity Beans
      2. Mapping an Entity to a Database Table
    3. Introducing the EntityManager
    4. Packaging and Deploying Entities
      1. The Program Directory Structure
      2. Building the Application
    5. Field-Based Annotations
    6. Generating Primary Keys
      1. Table Strategy
      2. Sequence Strategy
      3. Identity Strategy
      4. Auto Strategy
    7. Overriding Metadata Defaults
    8. Summary
  9. 4. Object/Relational Mapping
    1. O/R Mapping Default Behavior
      1. A Banking Example Application
        1. Customer Entity
        2. Account Entity
        3. Address Entity
        4. Referee Entity
      2. Testing the Application
    2. O/R Mapping Overriding Defaults
      1. Customer Entity
      2. Account Entity
      3. Address Entity
      4. BankServiceBean
    3. O/R Mapping Additional Annotations
      1. Referee Class
      2. BankServiceBean
      3. Composite Primary Keys
    4. O/R Inheritance Mapping
      1. SINGLE_TABLE Strategy
      2. JOINED Strategy
      3. Table per Concrete Class Strategy
    5. Summary
  10. 5. The Java Persistence Query Language
    1. Introduction
    2. Simple Queries
    3. Projection
    4. Conditional Expressions
    5. Aggregate Functions
      1. GROUP BY
      2. HAVING
    6. Queries with Relationships
    7. Joins
      1. Inner Joins
      2. Outer Joins
      3. Fetch Joins
    8. Collection Comparison Expressions
    9. Constructor Expressions
    10. SubQueries
    11. Functions
      1. CONCAT
      2. SUBSTRING
      3. TRIM
      4. LOWER and UPPER
      5. LENGTH
      6. LOCATE
      7. ABS
      8. SQRT
      9. MOD
      10. SIZE
    12. Queries with Parameters
      1. Positional Parameters
      2. Named Parameters
    13. Named Queries
    14. Handling Date and Time
      1. @Temporal annotation
      2. Queries with Date Parameters
      3. Datetime Functions
    15. Bulk Update and Delete
    16. Native SQL
    17. Summary
  11. 6. Entity Manager
    1. Application-managed Entity Manager
    2. Entity Manager Merge
    3. Entity Manager Methods
      1. remove()
      2. contains()
      3. flush()
      4. setFlushMode()
      5. refresh()
      6. clear()
    4. Cascade Operations
      1. persist
      2. remove
      3. merge
      4. refresh
      5. all
    5. Extended Persistence Context
    6. Entity LifeCycle Callback Methods
      1. Entity Listeners
    7. Summary
  12. 7. Transactions
    1. Introduction
    2. Container-Managed Transaction Demarcation
      1. SUPPORTS
      2. NOT_SUPPORTED
      3. REQUIRED
      4. REQUIRES_NEW
      5. MANDATORY
      6. Never
    3. Examples of Transaction Attributes
      1. REQUIRED Example
      2. REQUIRES_NEW Example
      3. NOT_SUPPORTED Example
      4. SUPPORTS Example
      5. MANDATORY Example
      6. NEVER Example
    4. Controlling Container Managed Transactions
      1. SessionSynchronization Interface
      2. Doomed Transactions
    5. Concurrency and Database Locking
      1. Isolation Levels
      2. Lost Update Problem
      3. Versioning
      4. Read and Write Locking
    6. UserTransaction Interface
    7. Summary
  13. 8. Messaging
    1. Introduction
    2. Java Message Service (JMS) API
    3. Queue Producer and Consumer Examples
      1. Synchronous Queue Consumer Example
        1. Running the Queue Producer and Synchronous Queue Consumer Examples
      2. An Asynchronous Queue Consumer Example
        1. Running the Asynchronous Queue Consumer Example
    4. Topic Producer and Consumer Examples
      1. Synchronous Topic Consumer Example
        1. Running the Topic Producer and Synchronous Topic Consumer Examples
      2. An Asynchronous Topic Consumer Example
        1. Running the Asynchronous Topic Consumer Example
    5. Motivation for Message-Driven Beans
    6. A Simple Message-Driven Bean Example
      1. A Session Bean Queue Producer
      2. A Message-Driven Bean Queue Consumer
    7. MDB Activation Configuration Properties
      1. acknowledgeMode
      2. subscriptionDurability
      3. messageSelector
    8. MessageDrivenContext
    9. MDB LifeCycle
    10. MDB Example Revisited
    11. Sending Message Confirmation to a Client
    12. MDBs and Transactions
    13. Summary
  14. 9. EJB Timer Service
    1. Introduction
    2. Timer Service Examples
      1. A Single Event Example
      2. An Interval Event Example
    3. A Timer Interface Example
    4. Timers and Transactions
    5. Summary
  15. 10. Interceptors
    1. Interceptor Methods
    2. Interceptor Classes
    3. Default Interceptors
    4. Interceptor Communication
    5. Summary
  16. 11. Implementing EJB 3 Web Services
    1. Overview of Web Service Concepts
      1. The SOAP Protocol
      2. The WSDL Standard
      3. The UDDI Standard
      4. SOA and Web Services
    2. Creating a Java Application Web Service
      1. Creating an Endpoint Implementation Interface
      2. The WSDL Document
        1. The <portType> Element
        2. The <binding> Element
        3. The <service> Element
        4. The <message> and <types> Elements
      3. The GlassFish WSGEN Tool
      4. Deploying a Java Application as a Web Service
      5. The GlassFish Admin Console Test Harness
      6. Creating a Java Web Service Client
    3. Overriding JAX-WS Annotation Defaults
    4. Deploying an EJB Session Bean as a Web Service
      1. Packaging an EJB Web Service
      2. Creating an EJB Web Service Client
    5. Summary
  17. 12. EJB 3 Security
    1. Java EE Container Security
    2. Authentication
      1. GlassFish Authentication
      2. Mapping Roles to Groups
      3. Authenticating an EJB Application Client
    3. EJB Authorization
      1. Declarative Authorization
        1. Denying Authorization
        2. EJB Security Propagation
      2. Programmatic Authorization
    4. Java EE Web Container Security
      1. Web-Tier Authorization
      2. Transport Layer Security
      3. Web-Tier Authentication
      4. Example of Web-Tier Authentication and Authorization
    5. Summary
  18. A. Annotations and Their Corresponding Packages