CHAPTER 1
PART 1 Patterns and J2EE 2
Introduction 4
What Is J2EE? 6
What Are Patterns? 7
Historical References 7
Defining a Pattern 7
Categorizing Patterns 9
J2EE Pattern Catalog 10
Continuous Evolution 10
How to Use the J2EE Pattern Catalog 11
Benefits of Using Patterns 12
Patterns, Frameworks, and Reuse 14
Summary 15
ContentsForeword 15
CHAPTER 2 J2EE Platform Overview 16
Preface 17
A Brief Perspective 17
Application Servers—The New Breed 19
Convergence of Java Technologies 19
The Rise of the J2EE Platform 20
J2EE Value Proposition 21
J2EE Platform 22
J2EE Architecture 22
Acknowledgments 24
Java 2 Standard Edition 24
J2EE Application Components and Containers 25
Standard Services 26
J2EE Platform Roles 27
Deployment Descriptors 29
J2EE Patterns and J2EE Platform 30
Summary 31
PART 2 Design Considerations, Bad Practices, and Refactorings 32
CHAPTER 3 Presentation Tier Design Considerations and Bad Practices 34
Presentation Tier Design Considerations 35
Session Management 35
Controlling Client Access 38
Validation 43
Helper Properties—Integrity and Consistency 46
Presentation Tier Bad Practices 49
Control Code in Multiple Views 49
Exposing Presentation-Tier Data Structures to Business Tier 50
Allowing Duplicate Form Submissions 51
Exposing Presentation-Tier Data Structures to Domain Objects 51
Exposing Sensitive Resources to Direct Client Access 52
Assuming
Creating Fat Controllers 53
CHAPTER 4 Business Tier Design Considerations and Bad Practices 54
Business Tier Design Considerations 55
Using Session Beans 55
Using Entity Beans 59
Caching Enterprise Bean Remote References and Handles 62
Business and Integration Tiers Bad Practices 63
Mapping Object Model Directly to Entity Bean Model 63
Mapping Relational Model Directly to Entity Bean Model 63
Mapping Each Use Case to a Session Bean 64
Exposing All Enterprise Bean Attributes via Getter/Setter Methods 65
Embedding Service Lookup in Clients 65
Using Entity Bean as Read-Only Object 66
Using Entity Beans as Fine-Grained Objects 67
Storing Entire Entity Bean-Dependent Object Graph 68
Exposing EJB-related Exceptions to Non-EJB Clients 68
Using Entity Bean Finder Methods to Return a Large Results Set 69
Client Aggregates Data from Business Components 70
Using Enterprise Beans for Long-Lived Transactions 70
Stateless Session Bean Reconstructs Conversational State for Each Invocation 71
CHAPTER 5 J2EE Refactorings 72
Presentation Tier Refactorings 73
Introduce a Controller 74
Introduce Synchronizer Token 77
Localize Disparate Logic 83
Hide Presentation Tier-Specific Details From the Business Tier 91
Remove Conversions from View 96
Hide Resource From a Client 100
Business and Integration Tier Refactorings 104
Wrap Entities With Session 104
Introduce Business Delegate 106
Merge Session Beans 108
Eliminate Inter-Entity Bean Communication 110
Move Business Logic to Session 112
General Refactorings 113
Separate Data Access Code 113
Refactor Architecture by Tiers 116
Use A Connection Pool 119
PART 3 J2EE Pattern Catalog 122
CHAPTER 6 J2EE Patterns Overview 124
What Is a Pattern? 126
Identifying a Pattern 127
The Tiered Approach 128
J2EE Patterns 130
Presentation Tier Patterns 130
Business Tier Patterns 131
Integration Tier Patterns 132
Guide to the Catalog 132
Terminology 132
Use of UML 137
Pattern Template 138
J2EE Pattern Relationships 140
Relationship to Known Patterns 143
Patterns Roadmap 144
Summary 149
CHAPTER 7 Presentation Tier Patterns 150
Problem 152
Context 152
Intercepting Filter 152
Forces 153
Solution 153
Consequences 170
Related Patterns 170
Front Controller 172
Context 172
Problem 172
Forces 172
Solution 173
Consequences 184
Related Patterns 185
Solution 186
Forces 186
Problem 186
View Helper 186
Context 186
Consequences 201
Related Patterns 202
Composite View 203
Context 203
Problem 203
Forces 203
Solution 203
Consequences 212
Sample Code 213
Related Patterns 215
Problem 216
Forces 216
Context 216
Service to Worker 216
Solution 217
Consequences 222
Sample Code 222
Related Patterns 230
Dispatcher View 231
Context 231
Problem 231
Forces 231
Solution 232
Consequences 238
Sample Code 239
Related Patterns 244
CHAPTER 8 Business Tier Patterns 246
Business Delegate 248
Context 248
Problem 248
Forces 248
Solution 249
Consequences 254
Sample Code 256
Related Patterns 260
Value Object 261
Context 261
Problem 261
Forces 261
Solution 262
Consequences 274
Sample Code 276
Related Patterns 289
Session Facade 291
Context 291
Problem 291
Forces 292
Solution 293
Consequences 298
Sample Code 301
Related Patterns 309
Composite Entity 310
Context 310
Problem 310
Forces 312
Solution 313
Consequences 321
Sample Code 323
Related Patterns 335
Value Object Assembler 339
Context 339
Problem 339
Forces 340
Solution 341
Consequences 345
Sample Code 347
Related Patterns 351
Value List Handler 353
Context 353
Problem 353
Solution 354
Forces 354
Consequences 358
Sample Code 360
Related Patterns 366
Service Locator 367
Context 367
Problem 367
Forces 369
Solution 369
Consequences 379
Sample Code 380
Related Patterns 385
CHAPTER 9 Integration Tier Patterns 388
Context 390
Problem 390
Data Access Object 390
Forces 391
Solution 391
Consequences 397
Sample Code 399
Related Patterns 407
Service Activator 408
Context 408
Problem 408
Forces 409
Solution 409
Consequences 413
Sample Code 414
Related Patterns 420
EPILOGUEJ2EE Patterns Applied 422
PSA Overview 423
Use Case Model 424
Use Cases, Patterns, and Pattern Frameworks 426
Create Project Use Case 426
Pattern Identification 426
Pattern Realization 428
Reserve Resource Use Case 430
Pattern Identification 430
Pattern Realization 431
Find Available Resources Use Case 433
Pattern Identification 434
Pattern Realization 435
Bibliography 439
Apache Software License 443
Index 445