Enterprise Java Development@TOPIC@

Enterprise Java (JavaEE) Course Notes

Revision: v2019-08-08

2019-08-22 07:12 EST

Abstract

This book contains course notes covering Enterprise Computing with Java. This comprehensive course explores a variety of modern Java frameworks and technologies that can be used for developing mission-critical complex enterprise applications. The emphasis is on use of the latest Java EE platform, its set of underlying specifications, designing and developing server-side application components. Students will learn thru having hands-on experience in building multi-tier distributed enterprise applications, comparing and using variety of Java EE design patterns, rich set of server-side components and technologies, and web-enabled by modern design practices and communication protocols. Students will learn to:

  • Implement a data access tier to a relational database using Java Persistence API (JPA), Java Database Connectivity (JDBC) API, and variety of data modeling and access patterns.

  • Implement synchronous and asynchronous server-side business logic using stateless and stateful session EJBs, message-driven EJBs and the EJB Timer service.

  • Integrate server-side logic with the web-tier components using legacy server-side and more modern RESTful API approaches that include JSON and XML.

Other critical Java EE infrastructure services will be discussed, including the Java Naming and Directory Interface (JNDI), the Java Message Service (JMS), the Java Transaction (JTA) API, and Java EE security. Using modern development tools, commercial persistence providers, and application servers, students will design and implement several significant programming projects using the above-mentioned technologies and deploy them to a Java EE environment that they will manage.

The course is being actively updated to JavaEE 8 (JPA 2.2, EJB 3.2, JAX-RS 2.1, and JMS 2.0) but a few order APIs and legacy examples remain. The development environment used in class is based on the Wildfly application server and is JavaSE 8 and JavaEE 7-compliant with the ability to preview some JavaEE 8-specific features.


I. Enterprise Computing with Java (605.784.31) Course Syllabus
1. Course Description
1.1. Meeting Times/Location
1.2. Description
1.3. Student Background
1.4. Student Commitment
1.5. Course Text(s)
1.6. Required Software
1.7. References
1.8. Grading
1.9. Grading Policy
1.10. Academic Integrity
1.11. Instructor Availability
2. Syllabus
3. Course Projects
3.1. Project 0: Sanity Check
3.2. Project 1: Data Access Tier and Business Logic
3.3. Project 2: N-Tier Application
3.4. Project 3: Secure and Asynchronous Application
3.5. General Requirements
3.6. Submission Guidelines
II. Java Enterprise Edition (JavaEE) Intro
Purpose
1. Goals
2. Objectives
4. Java Technology Levels
4.1. Java Standard Edition(tm) (JavaSE or JSE)
4.2. Java Micro Edition(tm) (JavaME)
4.3. Java Enterprise Edition(tm) (JavaEE, JEE, EE4J, or Jakarta EE)
5. Why Enterprise?
6. JavaEE Architecture
6.1. Profiles
6.1.1. Web Profile
6.1.2. Micro Profile (coming?)
6.2. Application Components
6.2.1. Application Clients
6.2.2. Applets
6.2.3. Servlets/JSPs/JSF
6.2.4. Enterprise JavaBeans(tm) (EJB)
6.3. Containers
6.3.1. Servers
6.4. Resource Adapters
6.5. Databases
7. JavaEE Specifications
8. JavaEE Version Highlights
9. Summary
A. Sources
III. Development Environment Overview
Purpose
1. Goals
2. Objectives
10. Maven Basics
10.1. Directory Structure
10.1.1. Source Tree
10.1.2. Build Tree
10.2. Maven POM
10.2.1. Packaging
10.2.2. Project Identity
10.2.3. Maven Repositories
10.2.4. Properties
10.2.5. Dependencies
10.2.6. Build Definition
10.3. Maven Commands
11. Maven Profiles
11.1. Profile Definition
11.2. Activation
11.2.1. Explicit Activation/Deactivation
11.2.2. Activation/Deactivation By Rule
12. Maven Modules
12.1. POM Inheritance
12.2. Submodules
13. Dependency/Plugin Management
13.1. Dependency Management
13.2. Plugin Management
14. Maven Eclipse Integration
14.1. Project Import
14.2. Project Update
14.3. Project Refresh
15. Eclipse
15.1. Project Organization
15.2. Project Testing
15.2.1. Maven test from Eclipse
15.2.2. Raw JUnit within Eclipse
15.3. Program Debugging
15.3.1. Debugging within Eclipse
15.3.2. Debugging Maven test from Eclipse
IV. eSport Semester Projects
V. Business Logic
Purpose
1. Goals
2. Objectives
30. Session Facade Pattern
30.1. Context
30.2. Problem
30.3. Forces
30.4. Solution
30.5. Consequences
31. Using Business Logic for Requirements
31.1. Business Interfaces Capture Functional Requirements
31.2. Business Objects Capture Data Requirements
31.3. Test Cases as Executable Requirements
31.4. Sample Project Layout
VI. Data Access Objects (DAOs)
Purpose
1. Goals
2. Objectives
32. Data Access Object (DAO) Pattern
32.1. Context
32.2. Problem
32.3. Forces
32.4. Solution
32.5. DAO Implementation Structure
32.6. Consequences
33. DAO Interface
33.1. DAO Interface
33.2. DAO Exceptions
33.3. DAO Implementation
33.4. DAO Test
34. Data Transfer Object (DTO) Pattern
34.1. Context
34.2. Problem
34.3. Forces
34.4. Solution
34.5. Consequences
35. RDBMS Schema
35.1. RDBMS
35.1.1. Background
35.1.2. Tables/Columns
35.1.3. Constraints
35.1.4. Relationships
35.1.5. Indexes
35.2. Data Definition Language (DDL)
35.2.1. Create Table
35.2.2. Drop Table
35.2.3. Create Foreign Key Constraint
35.2.4. Drop Foreign Key Constraint
35.2.5. Create Index
35.2.6. Drop Index
35.3. DDL Files in Maven Module
36. SQL Basics
36.1. Create/INSERT
36.2. Read/SELECT
36.3. Update/UPDATE
36.4. Delete/DELETE
37. Working with Native SQL
37.1. Java Database Connectivity (JDBC)
37.2. Java Persistence API (JPA) Native SQL
VII. Java Persistence API
Purpose
1. Goals
2. Objectives
38. JPA Overview
38.1. Background
38.2. EntityManager
38.3. Entity
38.4. JPA Example
38.5. Entity States
38.5.1. Managed
38.5.2. Detached
38.6. Persistence Context
38.7. Persistence Unit
38.8. Example Layout
38.9. Persistence.xml
38.9.1. Application Example
38.9.2. Server Example
38.9.3. Optional hibernate.properties
38.9.4. Sample orm.xml
38.9.5. persistence.xml Elements
38.9.6. Entity Discovery
38.10. Schema Generation
38.10.1. Hibernate DDL Generation Example
38.10.2. javax.persistence Schema Generation
38.11. Basic Testing Usage Steps
38.12. Entity Manager Methods
38.12.1. Basic CRUD Operations
38.12.2. Membership Operations
38.12.3. State Synchronization Operations
38.12.4. Locking Operations
38.12.5. Query Operations
38.12.6. Other Operations
39. Entity Manager CRUD Methods
39.1. persist()
39.2. find()
39.3. getReference()
39.4. merge()
39.5. remove()
40. Entity Manager Membership Methods
40.1. contains()
40.2. clear()
40.3. detach()
41. Entity Manager State Synchronization Methods
41.1. flush()
41.2. FlushMode
41.3. refresh()
42. Entity Manager Locking Methods
42.1. Primary Lock Types
42.2. LockModeType
42.3. lock()
42.4. find(lock)
42.5. refresh(lock)
42.6. getLockMode()
43. Entity Manager Query Methods
43.1. JPA Queries
43.2. Native Queries
43.3. Criteria Queries
44. Other Entity Manager Methods
44.1. isOpen()
44.2. close()
44.3. getTransaction()
44.4. joinTransaction()
44.5. unwrap()
44.6. getDelegate()
44.7. getMetaModel()
44.8. getEntityManagerFactory()
44.9. setProperties()/getProperties()
45. JPA Maven Environment
45.1. JPA Maven Dependencies
45.1.1. JPA API classes
45.1.2. JPA Provider classes
45.1.3. Database
45.2. Supplying Runtime Properties
45.2.1. Turn on Resource Filtering in pom.xml
45.2.2. Use ${variable} References in Resource Files
45.2.3. Define Property Values in Parent pom.xml
45.2.4. Run with Filtered Values
VIII. Java Persistence API: Entities
Purpose
1. Goals
2. Objectives
46. Identifying Entity Classes
46.1. Entities
46.2. Entity Name
46.3. Field/Property Access
46.3.1. Access Types
46.3.2. Defining Access using @Annotations
46.3.3. Defining Access using orm.xml
46.4. Approaches
46.4.1. Java First
46.4.2. Schema First
47. Mapping Entity Classes
47.1. Core Mappings
47.2. More Detailed Property Mappings
47.3. Entity Mapping Example
47.3.1. Example Schema
47.3.2. Mapping Entity Class with Annotations
47.3.3. Mapping Entity Class with orm.xml
47.4. More on Precision/Scale
47.5. Transient Properties
47.6. Lob Properties
47.7. Temporal and Enumerated Properties
47.7.1. Temporals
47.7.2. Enums
47.7.3. Temporal/Enum Example
48. Primary Keys
48.1. Generated Simple Primary Keys
48.1.1. GenerationType.AUTO
48.1.2. GenerationType.IDENTITY
48.1.3. GenerationType.SEQUENCE
48.1.4. GenerationType.TABLE
49. Composite Primary Keys
49.1. Example Composite Primary Key Class
49.2. Composite @IdClass
49.3. Composite @EmbeddedId
49.4. Composite Overrides
49.5. Composite Primary Key Summary
50. Multi-table Mapping
50.1. Multi-table Example
50.2. Summary
51. Embedded Object
51.1. Embedded Object Example
51.2. Summary
IX. Validation API
Purpose
52. Core Validation API
52.1. Validation Goals
52.2. Constraints
52.2.1. Annotating Class
52.2.2. Validating Instances
52.3. Constraint Groups
52.3.1. Uses
52.3.2. Defining Groups
52.3.3. Groups Applied to Classes
52.3.4. Validating with Groups
52.4. Custom Validators
52.4.1. Annotation
52.4.2. Validator
52.4.3. Annotating Class
52.4.4. Example Usage
52.5. Composite Constraints
52.5.1. Multiple Constraints
52.5.2. Replace With Composite
52.5.3. Composite Annotation
52.5.4. Composed Validations Individually Reported
52.5.5. @ReportAsSingleViolation
52.6. Group Sequences
52.6.1. Validation Groups and Sequence
52.6.2. Assign Constraints from Sequence
52.6.3. Sample Execution
52.6.4. Optionally Assign Sequence to be Default for Class
52.7. Validating Types
52.7.1. Annotation
52.7.2. Validator
52.7.3. Validator
52.8. Cascade Validation
52.8.1. Trigger Validation Cascade with @Valid
52.8.2. Validation
52.9. XML Descriptor
52.9.1. POJO Bean Class
52.9.2. META-INF/validation.xml
52.9.3. Constraint Mapping
52.10. Summary
53. JPA Persistence Lifecycle
53.1. Callbacks
53.2. Listeners
53.3. Summary
54. Validation API/JPA Integration
54.1. Entity Class
54.2. Persistence Unit
54.3. Validation
54.4. Validation with JPA
54.5. Summary
55. Validation API Build/Maven Aspects
55.1. Adding POM Dependencies
X. Java Persistence API: Relations
Purpose
1. Goals
2. Objectives
56. One-to-One Relationships
56.1. One-to-One: Uni-directional
56.2. @OneToOne Annotation
56.3. @JoinColumn Annotation
56.4. @JoinColumns Annotation
56.5. One-to-One: Bi-directional
56.6. Bi-directional Relationships and Ownership
56.7. Other Topics
56.8. Summary
57. One-to-Many Relationships
57.1. One-to-Many: Uni-directional
57.2. @OneToMany Annotation
57.3. One-to-Many: Bi-directional
57.4. @ManyToOne Annotation
57.5. One-to-Many: Element Collection
57.6. @ElementCollection Annotation
57.7. Other Topics
57.8. Summary
58. Relationship Capabilities
58.1. Fetching
58.1.1. fetch=LAZY
58.1.2. fetch=EAGER
58.2. Cascades
58.3. Orphan Removal
58.4. Summary
59. Object Collections
59.1. Object Identity
59.1.1. Instance Id
59.1.2. Primary Key Id
59.1.3. Switching Ids
59.1.4. Business Id
59.2. Collection Types
59.3. Summary
60. Foreign Keys
60.1. Primary Key Join
60.1.1. @PrimaryKeyJoin Annotation
60.2. Using Composite Primary Key Property as Foreign Key
60.2.1. Using @IdClass Composite Primary Key Property as Foreign Key
60.2.2. Using @EmbeddedId Composite Primary Key Property as Foreign Key
60.3. Using Foreign Key in Composite Primary Key
60.3.1. Using Foreign Key in @IdClass Composite Primary Key
60.3.2. Using Foreign Key in @EmbeddedId Composite Primary Key (@MapsId)
60.4. Join Tables
60.4.1. @JoinTable Annotation
60.5. Summary
61. Many-to-One Relationships
61.1. Many-to-One: Uni-directional
61.2. Summary
62. Many-to-Many Relationships
62.1. Many-to-Many: Uni-directional
62.2. Many-to-Many: Bi-directional
62.3. Summary
XI. Java Persistence API: Inheritance
Purpose
1. Goals
2. Objectives
63. Inheritance Strategy: Single Table
63.1. Single Table Strategy Overview
63.2. Single Table Example Database Schema
63.3. Single Table Example Java Mapping
63.4. Single Table Example Usage
63.5. @DiscriminatorColumn Annotation
63.6. Summary
64. Inheritance Strategy:Table per Concrete Class
64.1. Table per Concrete Class Strategy Overview
64.2. Table per Concrete Class Example Database Schema
64.3. Table per Concrete Class Example Java Mapping
64.4. Table per Concrete Class Example Usage
64.5. Summary
65. Inheritance Strategy:Join
65.1. Join Strategy Overview
65.2. Join Example Database Schema
65.3. Join Example Java Mapping
65.4. Join Example Usage (Persist)
65.5. Summary
66. Inheritance Strategy:Non-Entity
66.1. Non-Entity Strategy Overview
66.2. Non-Entity Example Database Schema
66.3. Non-Entity Example Java Mapping
66.4. Non-Entity Example Usage (Persist)
66.5. Summary
67. Mixed Inheritance Strategies
67.1. Which Strategy Gets Used for Subclass?
67.2. Generated Database Schema
67.3. Summary
XII. JPA Queries
Purpose
1. Goals
2. Objectives
XIII. JPA Tuning
Topics
76. SQL Tuning
76.1. Reasons for Inefficient SQL Performance
76.2. Execution Plan
76.3. Diagnostic Tools
76.3.1. Client/DAO Result
76.3.2. EXPLAIN PLAN
76.3.3. AUTOTRACE
76.3.4. Display Cursor Execution Plan within V$PLAN
76.4. Summary
77. Example Domain Model: Movies
77.1. Class Model
77.2. Database Schema
77.3. Database Size
77.4. Prepare DB Between Tests
78. Table Access
78.1. Full Table Scan
78.1.1. Full Table Scan: Unconstrained Access
78.1.2. Full Table Scan: Using Where (without Index)
78.1.3. RowId Scan: Using Where (with Index)
78.1.4. Full Table Scan: Invalidating Index using Function applied to Row Column
78.1.5. RowId Scan: Using Index with Function applied to Row Column
78.1.6. Full Table Scan: Invalidating Index by using Leading Wildcards
78.2. Order By
78.2.1. Order By using Sort
78.2.2. Order By using Index
78.2.3. Order By using Index DESC
78.2.4. Order By using Reverse Index DESC
78.3. Summary
79. Indexes
79.1. Index Range Scan
79.2. Unique Index Scan
79.3. Composite Index
79.3.1. Query Parts
79.3.2. First Term Indexed
79.3.3. First and Second Term Indexed (using Composite Index)
79.4. Index Fast Full Scan (with Composite Index)
79.4.1. Query Parts
79.4.2. Option: Use Range Scan and RowId Access
79.4.3. Option: Use Range Scan Alone with Composite Index
79.4.4. Option: Fast Full Scan
79.5. Summary
80. Joins
80.1. Foreign Keys
80.1.1. Query Parts
80.1.2. No Indexes
80.1.3. Perform Query with Support for Foreign Key Index
80.1.4. Foreign Key and Where Columns Indexed
80.1.5. Foreign Key, Where, and Join Columns Indexed
80.2. Join Types
80.2.1. Nested Loop Join
80.2.2. Hash Join
80.2.3. Sort Merge Join
80.3. Summary
81. JPA
81.1. Lazy and Eager Fetching
81.1.1. Get Parent
81.1.2. Get Parent and Children
81.2. Obtaining Instance Counts
81.2.1. Query Parts
81.2.2. Collection Size in DAO from Relation
81.2.3. Row Count in DAO from Query
81.2.4. Row Count in DB using Count() Query
81.2.5. Row Count in DB using Count Query without JOIN
81.3. Query Loops
81.3.1. Query Parts
81.3.2. Query Loops in DAO
81.3.3. Query Loops using DB Subquery
81.4. Paging
81.4.1. Query Parts
81.4.2. Paging within DAO
81.4.3. Paging within DB
81.5. Summary
82. H2 Execution Plans
82.1. Column Index
82.2. Summary
83. JPA/SQL Tuning Summary
83.1. Other Topics
XIV. Enterprise JavaBeans (EJB) Overview
Purpose
1. Goals
2. Objectives
84. Why Enterprise?
84.1. Related Patterns
84.1.1. Pattern: Session Facade
84.2. Pattern: Remote Facade
84.2.1. Context
84.2.2. Problem
84.2.3. Forces
84.2.4. Solution
84.2.5. Consequences
84.3. Pattern: Data Transfer Object (DTO)
84.3.1. Context
84.3.2. Problem
84.3.3. Forces
84.3.4. Solution
84.3.5. Consequences
85. Overview of EJB Styles
85.1. EJB Uses
85.2. EJB Granularity
85.3. EJB Bean Types
85.3.1. Entities (formerly Entity EJB)
85.3.2. Stateless Session EJB
85.3.3. Stateful Session EJB
85.3.4. Singleton Session EJB
85.3.5. Message Driven EJB (MDB)
85.4. EJB Interface Styles
85.4.1. Business Interface
85.4.2. Remote Interface
85.4.3. Local Interface
85.4.4. No Interface EJB
85.4.5. Other Interface Types
85.5. EJB Deployments
85.5.1. EJB Module
85.5.2. Naked EJB Deployment
85.5.3. EJB EAR Deployment
85.5.4. EJB WAR ("flexible") Deployment
85.5.5. EAR Deployment Class Loaders
B. Sources
XV. Basic Session EJB
Purpose
1. Goals
2. Objectives
86. Basic Session EJB POJO Aspects
86.1. POJO Class
86.1.1. Bean Class
86.1.2. Business Method
86.1.3. Interface
86.1.4. Serializable DTO
86.1.5. Business Exceptions
86.2. POJO Unit Test
86.2.1. JUnit Test Case
86.2.2. JUnit Test Method(s)
86.3. POJO Module
86.3.1. Built POJO Archive
86.3.2. Source POJO Module
86.4. Unit Test Execution
86.5. Maven Aspects: POJO
86.6. Summary
87. Basic Session EJB Component
87.1. Making POJO an EJB
87.1.1. Annotate Bean class with @javax.ejb.Stateless
87.1.2. Annotate Interface with @javax.ejb.Remote
87.1.3. Optionally Annotate Empty Interface Extending POJO Business Interface
87.1.4. @PostConstruct/@PreDestory
87.2. EJB Module
87.2.1. Source EJB Module
87.3. Naked EJB-based Deployment
87.4. Maven Aspects: EJB
87.5. JBoss Session EJB Pooling
87.6. Summary
88. EAR Deployment
88.1. EAR Artifact
88.1.1. EAR META-INF/application.xml
88.2. EAR-based EJB Deployment
88.3. Maven Aspects: EAR
88.3.1. EAR Module Build
88.3.2. EAR Module Cleanup
88.3.3. IT Test Module
88.4. Summary
89. WAR Deployment
89.1. WAR Artifact
89.1.1. WEB-INF/jboss-web.xml
89.2. WAR-based EJB Deployment
89.3. Maven Aspects: WAR
89.3.1. WAR Module Build
89.3.2. IT Test Module
89.4. Summary
90. IT Testing
90.1. EJB Access
90.1.1. JNDI
90.1.2. JBoss Remoting
90.1.3. EJB Client
90.1.4. Blending JBoss Remoting and EJB Client
90.2. Integration Test Session EJB
90.2.1. Integration Test (IT) JUnit Class
90.2.2. @Test Methods
90.3. IT Module
90.4. IT Test Execution
90.5. Summary
XVI. EJB Development Scenarios
Purpose
1. Goals
2. Objectives
91. Application Server
91.1. Server Configuration
91.1.1. Logger
91.2. Standalone Server
91.2.1. Standalone Server Start
91.2.2. Standalone Server Stop
91.3. Embedded Server
91.3.1. Embedded Server Setup
91.3.2. Embedded Server Start
91.3.3. Embedded Server Stop
91.4. Summary
92. Build Commands
92.1. Example Source Tree
92.2. Unit Tests
92.2.1. Resources Plugin
92.2.2. Surefire Plugin
92.3. Integration (IT) Tests
92.3.1. Cargo Plugin
92.3.2. Failsafe Plugin
92.4. Summary
93. IT Testing with IDE
93.1. Run IT Tests Against Server
93.2. Debug Code Running on Server
93.3. Summary
XVII. Configuring EJBs using ENC and JNDI
Topics
94. Global JNDI and the Enterprise Naming Context (ENC)
94.1. Java Naming and Directory Interface
94.2. Global JNDI Naming Context
94.2.1. Remote JNDI Naming Context
94.2.2. Local JNDI Naming Context
94.3. Enterprise Naming Context (ENC)
94.4. Summary
95. Injecting Specific EJB Resources without ENC
95.1. Injecting EJB SessionContext
95.2. Injecting JDBC Resources
95.3. Injecting JPA Resources
95.4. Injecting EJB Resources
95.5. Summary
XVIII. Context and Dependency Injection (CDI) Configuration
Purpose
1. Goals
2. Objectives
96. Context and Dependency Injection (CDI) JSR-299
96.1. History
96.2. Injection Concept
96.2.1. Beans
96.2.2. Injection
96.2.3. Ambiguity Error
96.2.4. Qualifiers and Qualified Injection
96.2.5. Qualifier Annotation
96.3. CDI Activation
96.3.1. beans.xml
96.4. Summary
97. CDI Injection
97.1. Producer Field
97.2. Producer Method
97.3. Other Producers
97.3.1. Example JNDI Resource Lookup Producer
97.3.2. Example String Resource Producer
97.4. @Any Instance
97.5. Bean Types
97.6. Named Beans
97.7. Summary
XIX. JPA Server-Side Deployment
Purpose
98. Server-side Resources
98.1. SQL DataSource (defined in Server - standalone.xml)
98.2. Server-side Persistence Units
98.2.1. transaction-type=JTA (default)
98.2.2. transaction-type=RESOURCE_LOCAL
98.3. persistence.xml Placement
98.3.1. EJB persistence.xml Placement
98.3.2. WAR persistence.xml Placement
98.4. Reference External @Entities
98.4.1. Reference External @Entities: EAR Deploy
98.4.2. Reference External @Entities: WAR Deploy
98.5. Summary
99. Persistence Unit/Context Injection
99.1. @PersistenceContext Injection
99.2. @PersistenceUnit Injection
99.3. Context and Dependency Injection (CDI)
99.4. Summary
100. Managed Entities and Remote Interfaces
100.1. Problem: Provider Proxy Classes Marshaled to Client
100.1.1. Potential Solution: Add JPA Provider Classes to Client Classpath
100.1.2. More Scenario Details
100.1.3. Candidate Solution: Cleansed DTOs
100.2. Problem: Lazy Load Exception
100.2.1. Lazy Load Scenario Details
100.2.2. Candidate Solution: Load thru "Touching" Object Tree in Remote Facade
100.2.3. Candidate Solution: Load thru Fetching Object Tree in Query
100.2.4. Candidate Solution: Abstract Remote Interface View with DTO
100.3. Summary
101. Persistence Context Propagation
101.1. Stateless Persistence Context Interaction
101.1.1. Stateless EJB Example Check-in
101.1.2. Stateless EJB Example Client Check-in
101.1.3. EJB Gets Available Rooms from DB
101.1.4. EJB Gets Specific Room
101.1.5. EJB Adds Guest
101.1.6. EJB associates Guest with Room
101.2. Stateful Facade Persistence Context Interaction
101.2.1. Example Stateful Reservation EJB Caches Guest Requests for Client
101.2.2. Example Stateful Reservation EJB Acting on Cached State
101.2.3. Stateful EJB Example Client Check-in
101.2.4. Stateful EJB Persists Guests Prior to Active JTA Transaction
101.2.5. Stateless EJB Populates Propagated Persistence Context with Rooms
101.2.6. Stateful EJB Method Activates Transaction and flush()es Guests in EntityManager Cache
101.2.7. Stateful EJB uses pre-loaded Rooms and Guests without accessing DB (until association)
101.3. Transaction Rollbacks
101.3.1. Stateless Transaction Rollback
101.3.2. Stateful Transaction Rollback
101.4. Pessamistic Locking
101.5. Summary
XX. EJB Transactions and Concurrency
Purpose
1. Goals
2. Objectives
102. Transactions
102.1. Transaction Examples
102.2. Transaction ACID Properties
102.3. EJB Transaction Scenarios
102.3.1. Scenario: Multiple DB Updates
102.3.2. Scenario: Update Multiple Databases
102.3.3. Scenario: Coordinate JMS with Database Transaction
102.4. Transaction Terms
102.5. JTA and JTS Specifications
102.5.1. Java Transaction API (JTA)
102.5.2. Java Transaction API (JTA) and Java Transaction Service (JTS)
102.6. EJB Transactions
102.6.1. Container-Managed Transactions (default)
102.6.2. Bean-Managed Transactions
102.7. Summary
103. Container-Managed Transactions
103.1. Transaction Scope
103.1.1. Transaction Not Supported
103.1.2. Transaction Required
103.1.3. Transaction Supports
103.1.4. Transaction Requires New
103.1.5. Transaction Mandatory
103.1.6. Transaction Never
103.1.7. All Transaction Scopes
103.2. @Asynchronous Methods and Transactions
103.3. EJB Lifecycle Methods
103.4. Callback Methods
103.4.1. Message Driven Callback
103.4.2. Timer Callbacks @Asynchronous
103.5. EJB Control of Container-Managed Transactions
103.5.1. EJBContext
103.6. Exceptions
103.6.1. Checked/Application Exceptions
103.6.2. Checked/Application Exception Rollback
103.7. Persistence Context Propagation
103.8. Summary
104. Bean-Managed Transactions
104.1. UserTransaction
104.2. Message-Driven Callbacks and Bean-Managed Transactions
104.3. Summary
105. Stateful Session Synchronization
105.1. Stateful Session Synchronization Events
105.2. Additional Stateful Rules
105.3. Summary
XXI. Web-enabled EJBs
Purpose
1. Goals
2. Objectives
106. REST-like Concepts
106.1. REST
106.2. "REST-like"
106.3. HTTP Protocol embraced
106.4. Resource
106.5. Uniform Resource Indentifiers (URIs)
106.6. Methods
106.6.1. Method Safety
106.6.2. Idempotent
106.7. Response Codes
106.8. Links
106.9. Summary
107. JAX-RS Basics
107.1. JAX-RS Client Basics
107.2. JAX-RS Server Basics
107.3. JAX-RS Maven Aspects
107.4. Summary
108. JAX-RS Resource/EJB Integration
108.1. EJB Injection
108.2. Candidate EJB/Business Tier Exceptions for Web API Status
108.2.1. Client Error
108.2.2. Service Error
108.3. Resource/EJB method
108.4. Summary
109. JAX-RS Content
109.1. JSON Content
109.1.1. JSON-B JSON Marshaling/Demarshaling
109.1.2. Jackson JSON Marshaling/Demarshaling
109.2. XML Content
109.2.1. Common JAXB Annotations
109.2.2. JAXB Maven Aspects
109.3. Content Handling
109.3.1. Client Marshal Request Content
109.3.2. API Receive Request Content
109.3.3. API Send Response Content
109.3.4. Demarshal Response Content
109.4. JAX-RS Client Maven Aspects
109.5. Summary
110. Resource Examples
110.1. JAX-RS Resource Class
110.2. JAX-RS GET Resource Collection
110.2.1. Server-side GET Resource Collection
110.2.2. Client-side GET Resource Collection
110.3. JAX-RS Resource POST Method
110.3.1. Server-side POST Resource Collection
110.3.2. Client-side POST Resource Collection
110.4. JAX-RS GET Resource Single Method
110.4.1. Server-side GET Single Resource
110.4.2. Client-side GET Single Resource
110.5. JAX-RS PUT (Nested) Resource Method
110.5.1. Server-Side JAX-RS PUT Resource Method
110.5.2. Client-side JAX-RS PUT Resource Method
110.6. JAX-RS DELETE Resource Method
110.6.1. Server-side JAX-RS DELETE Resource Method
110.6.2. Client-side JAX-RS DELETE Resource Method
110.7. Summary
XXII. JavaEE Security
Purpose
1. Goals
2. Objectives
111. JavaEE Security Access Control Points
112. EJB Security
112.1. Declarative EJB Access Control
112.2. Programmatic Security
112.3. Optional Role Mapping: ejb-jar.xml
112.4. EJB Security Setup: META-INF/jboss-ejb3.xml
112.5. Summary
113. JBoss/Wildfly Security
113.1. Security Realm
113.2. Security Realm References
113.3. Security Domain
113.3.1. "other" Security Domain
113.4. Wildfly Built-in Authentication and Authorization
113.5. Summary
114. EJB Security RMI Client
114.1. JBoss Remoting
114.1.1. jndi.properties
114.1.2. JBoss Remoting JNDI Name
114.1.3. JBoss Remoting Authentication with JNDI InitialContext
114.1.4. Example Changing Users with JBoss Remoting
114.1.5. Optional Fixed Credentials
114.2. EJBClient
114.2.1. jndi.properties
114.2.2. EJBClient JNDI Name
114.2.3. EJBClient Authentication with JNDI InitialContext
114.2.4. Example Changing Users with EJBClient
114.2.5. Optional Fixed Credentials
114.3. Security Sanity Check
114.3.1. whoAmI
114.3.2. isCallerInRole
114.3.3. Client Issues Security Query Calls
114.3.4. Example Access Violation
114.3.5. Example Access Granted
114.4. Summary
115. run-as
115.1. Default security-identity: use-caller-identity
115.2. Run-as security-identity: role-name
115.3. Run-as principal: identity
115.4. Invoking Protected EJB thru Run-as Proxy
115.5. Summary
116. JAX-RS Resource Security
116.1. Web Security Setup
116.1.1. Assign WAR security-domain: jboss-web.xml
116.1.2. Assign WAR auth-method: web.xml
116.2. JAX-RS Resource Class
116.2.1. JAX-RS Debug Methods
116.3. JAX-RS Client Authentication
116.3.1. Authorization Header
116.3.2. JAX-RS Client Authorization Filter
116.3.3. JAX-RS Client Authorization Filter Registration
116.3.4. Protect BASIC Credentials with HTTPS
116.4. Declarative Access Control
116.4.1. Two intermediate contexts defined to access Nested Pinger Resource
116.4.2. Same Nested Pinger Resource Exposed
116.4.3. Declarative Access Control Constraints
116.4.4. Nested Resource Called from Two URIs
116.5. Summary
117. Web Tier Access Control
117.1. Authentication
117.2. Security Constraints (web.xml)
117.3. FORM-based Login
117.4. BASIC Authentication
117.5. Summary
XXIII. JavaEE Interceptors
Purpose
1. Goals
2. Objectives
118. EJB Interceptors
118.1. Business Method Callbacks
118.1.1. Sample Business Method being Intercepted
118.1.2. Sample Business Method Interceptor
118.1.3. Sample Output
118.2. InvocationContext
118.2.1. InvocationContext Interface
118.3. Lifecycle Callbacks
118.3.1. Lifecycle Callbacks
118.4. Timer Callbacks
118.4.1. Timer Interceptor
118.5. Activating Interceptors
118.5.1. EJB Descriptor (ejb-jar.xml) Activation
118.5.2. @Interceptor(s) Annotation Activation
118.6. Summary
119. CDI Interceptors
119.1. @InterceptorBinding Annotation
119.2. Interceptor Class
119.3. CDI Bean Class
119.4. CDI Descriptor (beans.xml) Activation
119.5. Summary
120. Interceptor Example: Input Normalization and Validation
120.1. EJB Method Creates Contact
120.2. Non-normalized Caller Data
120.3. Partial Solution: Validation API
120.4. PrePersistCheck
120.5. PostNormalizedCheck
120.6. PreNormalizedCheck
120.7. Validator Interceptors
120.8. Normalization Interceptor
120.9. Bean Class
120.10. CDI Activation (bean.xml)
120.11. Example Output
120.12. Summary
XXIV. Java Messaging Service (JMS) 2.0 API
Purpose
1. Goals
2. Objectives
121. Messaging
121.1. MOM Architecture: Direct Connections
121.2. MOM Architecture: Unicast Connections
121.3. MOM Architecture: Broker-based
121.4. MOM Architecture: Multi-Broker
121.5. Messaging Key Concepts
121.6. Message Queuing
121.7. Publish/Subscribe
121.8. Request/Reply
121.9. Messaging and Transactions
121.10. Messaging Summary
122. JMS
122.1. JMS Background
122.2. Not Specified by JMS
122.3. JMS History
122.4. JMS Demonstrations
122.4.1. JMS Topic Demonstration: JMS Notifier
122.4.2. JMS Queue Demonstration: JMS Scheduler
122.5. Chapter Summary
123. JMS API
123.1. JMS API Classes
123.2. ConnectionFactory
123.3. JMSContext
123.4. Destinations
123.4.1. JNDI Lookup
123.4.2. Injected Destination
123.5. Send Message
123.6. Receive Message
123.6.1. Poll from JMSConsumer
123.6.2. JMSConsumer Listener
123.6.3. Message Driven Bean (MDB)
123.7. Message Acknowledgement
123.7.1. Message Acknowledgement: AUTO_ACKNOWLEDGE
123.7.2. Message Acknowledgement: DUPS_OK_ACKNOWLEDGE
123.7.3. Message Acknowledgement: CLIENT_ACKNOWLEDGE
123.7.4. Message Acknowledgement: SESSION_TRANSACTED
123.8. JMS API Summary
124. JMS Maven Aspects
124.1. JMS API Maven Aspects
124.2. JMS Testing Maven Aspects
C. Sources
XXV. Asynchronous Methods
Purpose
1. Goals
2. Objectives
125. Asynchronous Overview
125.1. Asynchronous Scenario
125.2. Potential Asynchronous Solution: Manually Spawn Thread
125.2.1. Threads Solution Analysis
125.3. Potential Asynchronous Solution: JMS
125.3.1. JMS Solution Details
125.3.2. JMS Solution Analysis
125.4. Potential Asynchronous Solution: Asynchronous Methods
125.4.1. Asynchronous Method Solution Details
125.4.2. Asynchronous Method Solution Analysis
125.5. Asynchronous Summary
126. Asynchronous Methods Example
126.1. Synchronous Example
126.1.1. Synchronous Example: Client
126.1.2. Synchronous Example: Worker
126.1.3. Synchronous Example: Results
126.2.
126.2.1. Asynchronous Example: Client
126.2.2. Asynchronous Example: Worker
126.2.3. Asynchronous Example: Results
126.3. Asynchronous Example Summary
D. Sources
XXVI. EJB Timers
Purpose
1. Goals
2. Objectives
127. EJB Timers Overview
127.1. EJB Timer History
127.2. EJB Timer Service
127.3. Single Action EJB Timers
127.4. Interval EJB Timers
127.5. Calendar EJB Timers
127.6. EJB Timer Summary
128. EJB Timers Example
128.1. Declarative Calendar
128.2. Programmatic Calendar
128.3. Chapter Summary
E. Sources