
Beginning EJB 3
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
More details
Other editions
Additional editions

Persons
Content
- Cover
- Title Page
- Copyright Page
- Dedication Page
- Contents at a Glance
- Table of Contents
- About the Authors
- About the Technical Reviewer
- Preface
- Acknowledgments
- CHAPTER 1 Introduction to the EJB Architecture
- An Introduction to EJB
- What Is EJB?
- The EJB Component Model
- The EJB Container
- Core Features of the EJB Development Model
- Declarative Metadata
- Configuration by Exception
- Scalability
- Location Transparency
- Transactionality
- Multiuser Security
- Portability
- Reusability
- Persistence
- Progression of the EJB Spec
- EJB 1.0
- EJB 1.1
- EJB 2.0
- EJB 2.1
- EJB 3.0
- EJB 3.1
- EJB 3.2
- EJB 3 Simplified Development Model
- XML and Annotations
- Dependency Injection
- Interceptors: Callback Methods
- POJO Implementation
- Intelligent Use of Defaults
- Distributed Computing Model
- EJB Roles
- The Enterprise Bean Provider
- The Application Assembler
- The Deployer
- 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
- Starting NetBeans IDE
- Testing Using Sample Project
- Administrating the GlassFish Application Server
- Troubleshooting
- "No Compatible JDK was found" warning during installation
- Diagnosis
- Solution
- Unable to see GlassFish server's test page
- Diagnosis
- Solution
- Unable to resolve "localhost" hostname
- Diagnosis
- Solution
- Browser is unable to connect to "8080" port
- Diagnosis
- Solution
- Errors while compiling or executing sample application projects
- Diagnosis
- Solution
- Unable to send or receive the "wine order" mail
- Diagnosis
- Solution
- Conclusion
- CHAPTER 2 EJB Session Beans
- Introduction to Session Beans
- Types of Session Beans
- When Do You Use Session Beans?
- 3-Tier Architecture with Rich Client
- 3-Tier Architecture for a Web Application
- Stateless Session Beans
- The Bean Class
- The Business Interface
- Business Methods
- Asynchronous 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
- Container-Managed Concurrency
- Bean-Managed Concurrency
- 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
- The @Entity Annotation
- The @Id Annotation
- Comparison with EJB 2.x
- Configuration by Default
- An Entity with Defaults Exposed: Customer.java
- The @Table Annotation
- The @Column Annotation
- The @Basic Annotation
- Additional Field Types
- Coding Requirements
- The java.io.Serializable Interface
- Placing Annotations on Instance Variables vs. JavaBean Property Accessors
- Entity Data Access
- Property Name
- Example: Annotating Instance Variables
- The @Transient Annotation
- Example: Annotating Property Accessors
- Access Type Summary
- Declaring the Primary Key
- Simple Primary Key
- The @GeneratedValue Annotation
- Composite Primary Key
- The @IdClass Annotation
- The @EmbeddedId Annotation
- The @Embeddable Annotation
- Summary of Entity Examples
- The Persistence Archive
- The persistence.xml File
- The EntityManager
- Persistence Context
- Acquiring an EntityManager Instance
- A Session Bean Using Container Injection
- A Java SE Service Client Using an EntityManagerFactory
- Looking Up the EntityManager Through JNDI
- Transaction Support
- The Entity Life Cycle
- The Life Cycle of a New Entity Instance
- New Entity Instance
- Managed Entity Instance
- Detached Entity Instance
- Removed Entity Instance
- O/R Mapping
- The @Table Annotation (Revisited)
- The @Column Annotation (Revisited)
- Complex Mappings
- Entity Relationships
- @OneToOne
- @OneToMany and @ManyToOne
- @OneToMany:
- @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
- Prerequisites
- 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
- Sample Entity Hierarchy
- Object/Relational Inheritance Mapping Strategies
- The @GeneratedValue Annotation
- Single-Table-per-Class Inheritance Hierarchy (InheritanceType.SINGLE_TABLE)
- Example Entity Classes
- The @JoinColumn Annotation
- The @DiscriminatorColumn Annotation
- The @DiscriminatorValue Annotation
- Pros and Cons of the SINGLE_TABLE Strategy
- Design-Time Considerations
- Performance Impact
- Sample Client Code
- Common Base Table with Joined Subclass Tables (InheritanceType.JOINED)
- Example Entity Classes
- Pros and Cons of the JOINED Strategy
- Design-Time Considerations
- Performance Impact
- Single-Table-per-Outermost Concrete Entity Class (InheritanceType.TABLE_PER_CLASS)
- Example Entity Classes
- Pros and Cons of the TABLE_PER_CLASS Strategy
- Design-Time Considerations
- Performance Impact
- 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
- @Embedded and @Embeddable
- @ElementCollection
- 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
- Message Acknowledgment
- The Message Selector
- Message Destination
- Subscription Durability
- 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
- The &definitions& Element
- The &types& Element
- The &message& Element
- The &portType& Element
- The &binding& Element
- The &service& Element
- SOAP
- REST
- RESTful Web Services
- RESTful vs. SOAP-Based Web Services
- 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
- Creating a Bean Class
- Web Service Endpoint Interface
- 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
- Generating Web Service Proxy Classes
- Developing a Web Service Client Program
- Compiling the Client Class
- Running the Web Service Client
- 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
- Finding Customers
- Adding Wine Items
- Removing Wine Items
- Submitting Orders to the Order Processing Façade
- Retrieving the Customer's Cart Items
- The Order Processing Façade Component
- Credit Check
- Creating a Purchase Order
- Sending a Purchase Order to the Order Processing Service
- 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
- The EJBContext.setRollbackOnly and getRollbackOnly Methods
- 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
- Transaction Analysis
- Populating Test Data through a Transactional Java Facade
- Java Façade Using Application-Managed EntityManager
- Filtering Test Data Using a CMT Session Bean
- Creating New Customer and CartItem Entity Instances in the Client
- Persisting the Customer
- Creating the CustomerOrder
- Does This Pass the ACID Test?
- Atomicity
- Consistency
- Isolation
- Durability
- Benefits of This Approach
- Limitations of This Approach
- Stateful Session Beans with BMT Demarcation and Extended Persistence Context
- Transaction Analysis
- Session Bean Declaration
- Removing Previous Test Data
- Creating New Customer and CartItem Entity Instances in the Client
- Persisting the Customer
- Creating the CustomerOrder
- Benefits of This Approach
- Limitations of This Approach
- 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
- The Database
- Configuring Connections to Your Own Database
- The Grinder
- The Test Script
- Running the Simulated Users
- The Grinder Console
- 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
- Application Scope
- Request Scope
- Session Scope
- Conversation Scope
- Dependent Pseudo-Scope
- Dependency Injection with @Inject
- Bean Constructor Parameter Injection
- Initializer Method Parameter Injection
- Field Injection
- Dependency Resolution
- Qualifiers
- @Default
- @Named
- @New
- 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
- Testing the User-Defined Qualifier Client
- Testing the Any Qualifier Client
- Testing the Alternatives Client
- Testing the Producers Client
- Conclusion
- CHAPTER 11 EJB Packaging and Deployment
- A Note on Deployment Tools
- Overview of the Packaging and Deployment Processes
- The Provider
- The Assembler
- Grouping Components by Container Type to Produce Java EE Modules
- Defining Module-Level Deployment Descriptors (Optional)
- Packaging Components (with Optional Descriptors) into JAR Files
- Creating an Enterprise Archive (EAR) File (Optional)
- Assembler-Specific Tasks
- The Deployer
- Deployer-Specific Tasks
- Invoking the Application Server-Specific Deployment Tool
- Summary of Overview
- Java EE Deployment Infrastructure
- The Java EE Server
- The Java EE Containers
- Java EE Deployment Components
- The Java EE Application
- Java EE Module Types
- EJB Module
- EJBs in a WAR File
- Persistence Unit
- Web Application Module
- Resource Adapter Module
- Application Client Module
- Library Components
- Bundled Libraries
- Installed Libraries
- Versioning of Libraries
- Application Servers and Platform Independence
- Deployment Tools
- The Deployment Plan
- Deployment Roles
- The Application Assembler
- Defining and Describing External Dependencies
- Ensuring That All References Are Complete
- Resolving Conflicting and Redundant References
- Packaging
- The Application Deployer
- Unpackaging the Archive
- Deriving the Module Descriptors
- Binding External References
- Deploying to the Containers
- 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
- The Model-View-Controller Pattern
- JSF Architecture
- The JSF Lifecycle
- The JSF Application
- 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
- EJB Lite
- Embeddable EJB Container Client
- 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
- Using the "jdbc/__default" Connection
- The Unit Test Methods
- EJB Lookup through JNDI
- Building and Testing the Sample Code
- Prerequisites
- Opening the Sample Application
- Compiling the Sources
- Running the JUnit Tests
- Fixing the Test Cases
- Cascading MERGE Operations
- Returning Managed Objects from EJB Methods
- Conclusion
- Index
System requirements
File format: PDF
Copy protection: Watermark-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Use the free software Adobe Reader, Adobe Digital Editions, or any other PDF viewer of your choice (see eBook Help).
- Tablet/Smartphone (Android; iOS): Install the free app Adobe Digital Editions or another reading app for eBooks, e.g., PocketBook (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (only limited: Kindle).
The file format PDF always displays a book page identically on any hardware. This makes PDF suitable for complex layouts such as those used in textbooks and reference books (images, tables, columns, footnotes). Unfortunately, on the small screens of e-readers or smartphones, PDFs are rather annoying, requiring too much scrolling.
This eBook uses Watermark-DRM, a „soft” copy protection. This means that there are no technical restrictions to prevent illegal distribution. However, there is a personalised watermark embedded in the eBook that can be used to identify the purchaser of the eBook in the event of misuse and to provide evidence for legal purposes.
For more information, see our eBook Help page.