Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Cover
Title
Copyright
Dedication
Contents at a Glance
Contents
About the Authors
About the Technical Reviewer
Preface
Acknowledgments
Chapter 1: Introduction to the EJB Architecture
An Introduction to EJB
What Is EJB?
Core Features of the EJB Development Model
Progression of the EJB Spec
EJB 3 Simplified Development Model
Distributed Computing Model
How This Book Is Organized
Chapter 1: Introduction to the EJB 3 Architecture
Chapter 2: EJB Session Beans
Chapter 3: Entities and the Java Persistence API
Chapter 4: Advanced Persistence Features
Chapter 5: EJB Message-Driven Beans
Chapter 6: EJB and Web Services
Chapter 7: Integrating Session Beans, Entities, Message-Driven Beans, and Web Services
Chapter 8: Transaction Support in EJB
Chapter 9: EJB Performance and Testing
Chapter 10: Contexts and Dependency Injection
Chapter 11: EJB Packaging and Deployment
Chapter 12: EJB Client Applications
Chapter 13: Testing in an Embeddable EJB Container
Getting Started
Downloading the NetBeans IDE
Installing NetBeans IDE and Its Integrated GlassFish Server
Testing the NetBeans IDE and GlassFish Installation
Administrating the GlassFish Application Server
Troubleshooting
Conclusion
Chapter 2: EJB Session Beans
Introduction to Session Beans
Types of Session Beans
When Do You Use Session Beans?
Stateless Session Beans
The Bean Class
The Business Interface
Business Methods
Dependency Injection
Lifecycle Callback Methods
Interceptors
Stateful Session Beans
The Bean Class
The Business Interface
Business Methods
Lifecycle Callback Methods
Interceptors
Exception Handling
Singleton Session Beans
The Bean Class
The Business Interface
Business Methods
Lifecycle Callback Methods
Concurrency Management
Error Handling
Timer Service
Calendar-Based Time Expressions
Examples of Calendar-Based Time Expressions
Timer Persistence
Client View for Session Beans
Compiling, Deploying, and Testing the Session Beans
Prerequisites
Compiling the Session Beans and their Clients
Deploying the Session Beans and their Clients
Running the Client Programs
Conclusion
Chapter 3: Entities and the Java Persistence API
An Entity Example
A Simple JavaBean: Customer.java
A Simple Entity: Customer.java
An Entity with Defaults Exposed: Customer.java
Coding Requirements
Entity Data Access
Property Name
Example: Annotating Instance Variables
Example: Annotating Property Accessors
Declaring the Primary Key
Simple Primary Key
Composite Primary Key
Summary of Entity Examples
The Persistence Archive
The persistence.xml File
The EntityManager
Persistence Context
Acquiring an EntityManager Instance
Transaction Support
The Entity Life Cycle
The Life Cycle of a New Entity Instance
O/R Mapping
The @Table Annotation (Revisited)
The @Column Annotation (Revisited)
Complex Mappings
Entity Relationships
@OneToOne
@OneToMany and @ManyToOne
@ManyToMany
Lazy vs. Eager Field Bindings
Cascading Operations
Java Persistence Query Language (JPQL)
@NamedQuery and @NamedQueries
Binding Query Parameters
Dynamic Queries
Bulk Update and Delete Operations
Complex Queries
Persistence vs. Adaption
Forward Generation—Persistence
Reverse Engineering—Adaption
Which One Is Right for Your Project?
Example Application: CustomerOrderManager
Customer.java
Compiling, Deploying, and Testing the JPA Entities
Opening the Sample Application
Creating the Database Connection and Sample Schema
Compiling the Entities, EJBs, and the Client
Deploying the JPA Persistence Unit, the EJB Module, and the Servlet
Running the Client Programs
Conclusion
Chapter 4: Advanced Persistence Features
Mapping Entity Inheritance Hierarchies
Getting Started
Entity Inheritance Mapping Strategies
Single-Table-per-Class Inheritance Hierarchy (InheritanceType.SINGLE_TABLE)
Common Base Table with Joined Subclass Tables (InheritanceType.JOINED)
Single-Table-per-Outermost Concrete Entity Class (InheritanceType.TABLE_PER_CLASS)
Comparison of O/R Implementation Approaches
Using Abstract Entities, Mapped Superclasses, and Non-Entity Classes in an Inheritance Hierarchy
Abstract Entity Class
Mapped Superclass (@MappedSuperclass)
Non-entity Class
Non-entity Single-value and Collection Fields
Polymorphic Relationships
Relationship Mapping
Polymorphic JPQL Queries
Using Native SQL Queries
The Query Criteria API
Composite Primary Keys and Nested Foreign Keys
Using an Embedded Composite Key (@EmbeddedId)
Exposing Composite Key Class Fields Directly on the Entity Class (@IdClass)
Mapping Relationships That Use Composite Keys
Support for Optimistic Locking (@Version)
Support for Autogenerated Primary Key Values (@GeneratedValue)
Interceptors: Entity Callback Methods
Compiling, Deploying, and Testing the JPA Entities
Prerequisites
Opening the Sample Application
Creating the Database Connection
Compiling the Sources
Running the Client Programs
Testing the Other Persistence Examples
Conclusion
Mapping Entity Inheritance Hierarchies
Using Abstract Entities, Mapped Superclasses, and Non-Entity Classes in an Inheritance Hierarchy
Polymorphic Relationships
Polymorphic JPQL Queries
Using Native SQL Queries
Using the Query Criteria API
Composite Primary Keys and Nested Foreign Keys
Support for Optimistic Locking
Support for Autogenerated Primary Automatic Key Values
Interceptors: Entity Callback Methods
Chapter 5: EJB Message-Driven Beans
Message-Oriented Architecture
What Is JMS?
Messaging Application Architecture
Using MDBs
When Do You Use MDBs?
MDB Classes
Configuration Properties
Dependency Injection in MDBs
Lifecycle Callback Methods
Interceptors
Exception Handling
Client View
Compiling, Deploying, and Testing MDBs
Prerequisites
Compiling the Session Beans and MDBs
Creating the JMS and JavaMail Resources
Deploying the Session Beans, MDBs, and their Clients
Running the Client Programs
Conclusion
Chapter 6: EJB and Web Services
What Are Web Services?
UDDI
WSDL
SOAP
REST
When Do You Use Web Services?
Java EE and Web Services
JAX-WS
JAX-RS
JAXB
JAXR
SAAJ
JSR 181
EJB Stateless Session Beans as Web Services
Developing a New Web Service
Packaging, Deploying, and Testing Web Services
Prerequisites
Compiling the Session Bean
Deploying the Session Bean-Based Web Service
Testing the Credit Service
Web Service Client View
Developing a Java Client That Accesses the Web Service
Session Beans as Web Service Clients
Conclusion
Chapter 7: Integrating Session Beans, Entities, Message-Driven Beans, and Web Services
Introduction
Application Overview
Application Components and Services
The Shopping Cart Component
The Search Façade Component
The Customer Façade Component
The Order Processing Façade Component
Persistence Services
The E-mail Service
The Credit Service
The Order Processing Service
The Wines Online Application Business Process
In-Depth Component/Service Walkthrough
Persistence Services
The Customer Façade Component
The Search Façade Component
The Shopping Cart Component
The Order Processing Façade Component
The Order Processing Service
The E-mail Service
The Credit Service
The Database Schema
Building, Deploying, and Testing the Application
Prerequisites
Creating the Database Connection
Creating the JMS and JavaMail Resources
Opening the Sample Application
Configuring the EJB Web Service
The wineapp@yahoo.com Account and the user.properties File
Building, Deploying, and Executing the Sample Application
The Servlet Output
The Resulting E-mail
Conclusion
Chapter 8: Transaction Support in EJB
What Is a Transaction?
Distributed Transactions
The ACID Properties of a Transaction
The Java Transaction API (JTA)
The Two-Phase Commit Protocol
Transaction Support in EJB
EJB Transaction Services
Session Bean Transactional Behavior in the Service Model
Container-Managed Transaction (CMT) Demarcation
Bean-Managed Transaction (BMT) Demarcation
Implicit Commit vs. Explicit Commit
Using Transactions with JPA Entities
Relationship Between Entities and a Transaction Context
Container-Managed vs. Application-Managed Persistence Context
Transaction-Scoped Persistence Context vs. Extended Persistence Context
JTA vs. Resource-Local EntityManagers
Two Sample Scenarios
Stateless Session Beans with CMT Demarcation
Java Façade Using Application-Managed EntityManager
Filtering Test Data Using a CMT Session Bean
Stateful Session Beans with BMT Demarcation and Extended Persistence Context
Building, Deploying, and Testing: A Transactional Scenario from the Wines Online Application
Prerequisites
Opening the Sample Application
Creating the Database Connection
Compiling the Sources
Deploying and Running the Client Programs
Conclusion
Chapter 9: EJB 3 Performance and Testing
The Testing Methodology
Performance Criteria
Simulating Application Usage
Defining Test Metrics
The Grinder
The Test Application
The Performance Test
The Test Environment
The Test Script
Setup
Preliminary Tests
Sample Size
Calibration
The Actual Test Runs
Analyzing the Results
Conclusion
Chapter 10: Contexts and Dependency Injection
What Is CDI?
Relationship with EJB
CDI Concepts
Beans and beans.xml
Scope
Dependency Injection with @Inject
Dependency Resolution
Alternatives
Producers
Interaction with Session Beans
Session Bean Scope
Resolving Session Bean Ambiguity
Limitations
Compiling, Deploying, and Testing the CDI Application
Prerequisites
Structure of the Sample Code
Compiling the CDI Beans and Their Clients
Deploying and Running the CDI Clients
Conclusion
Chapter 11: EJB Packaging and Deployment
A Note on Deployment Tools
Overview of the Packaging and Deployment Processes
The Provider
The Assembler
The Deployer
Java EE Deployment Infrastructure
The Java EE Server
The Java EE Containers
Java EE Deployment Components
The Java EE Application
Java EE Module Types
Library Components
Application Servers and Platform Independence
Deployment Tools
The Deployment Plan
Deployment Roles
The Application Assembler
The Application Deployer
Assembling an EJB JAR Module
Naming Scope
Assembling a Persistence Unit
Naming Scope
Conclusion
Chapter 12: EJB Client Applications
Application Architecture
JSF
Evolution of Java EE Web Technologies
JSF Architecture
JSF Tools and Components
Developing Web Applications Using JSF and EJB
The Login Page
The New Customer Registration Page
The Links Page
The Search Page
The Wine List Page
The Display Selected Wine Details Page
The Display Cart Items Page
The Notification Page
Compiling, Deploying, and Testing the JSF Application
Prerequisites
Compiling the JSF Application
Deploying and Running the Wine Store Application
The Application Client Container
Conclusion
Chapter 13: Testing in an Embeddable EJB Container
Test Clients
EJB Lite
Embeddable EJB Container
How This Chapter Is Organized
Concepts
JUnit Tests
WineAppServiceTest: A JUnit test class for the WineAppService EJB
Instantiating the Embeddable EJB Container and Starting Derby
Initializing Data in the Persistence Unit
The Unit Test Methods
Building and Testing the Sample Code
Prerequisites
Opening the Sample Application
Compiling the Sources
Running the JUnit Tests
Conclusion
Index
← Prev
Back
Next →
← Prev
Back
Next →