viii Contents Chapter 3 Transaction and Persistence Patterns.....................69 Version Number..........................................70 JDBC for Reading......... ...76 Data Access Command Beans 81 Dual Persistent Entity Bean 87 Chapter 4 Client-Side EJB Interaction Patterns......................91 EJBHomeFactory.........................................92 Business Delegate.........................................98 Chapter 5 Primary Key Generation Strategies......................105 Sequence Blocks.........................................106 UUIDforEJB............................................112 Stored Procedures for Autogenerated Keys .117 Part Two Best Practices for EJB Design and Implementation ...........................121 Chapter 6 From Requirements to Pattern-Driven Design .123 TheServerSide's Forum Messaging System Use Cases .........124 A Quick Referesher on Design Issues and Terminology .126 What Is a Domain Model? ..126 Understanding the Layers in a J2EE System...............127 Pattern-Driven EJB Architectures........................130 Domain and Persistence Layer Patterns...................130 Services Layer Patterns...... .133 Asychronous Use Cases 134 Synchronous Use Cases............................. .134 Other Services Layer Patterns 。年,。。。。。年。。。。。年。。g。 .137 Inter-Tier Data Transfer Patterns .137 Application Layer Patterns .. Summary ..142 Chapter 7 EJB Development Process:Building with Ant and Unit Testing with Junit.........................143 Order of Development ..... .144 Layer-Independent Code ..145 Domain First .146 Persistence Second .146 Services Third......... .148 Clients Last 148Chapter 3 Transaction and Persistence Patterns . . . . . . . . . . . . . . . . . . . . .69 Version Number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .70 JDBC for Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .76 Data Access Command Beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81 Dual Persistent Entity Bean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .87 Chapter 4 Client-Side EJB Interaction Patterns . . . . . . . . . . . . . . . . . . . . . .91 EJBHomeFactory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .92 Business Delegate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98 Chapter 5 Primary Key Generation Strategies . . . . . . . . . . . . . . . . . . . . . .105 Sequence Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .106 UUID for EJB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .112 Stored Procedures for Autogenerated Keys . . . . . . . . . . . . . . . . . .117 Part Two Best Practices for EJB Design and Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . .121 Chapter 6 From Requirements to Pattern-Driven Design . . . . . . . . . . . .123 TheServerSide’s Forum Messaging System Use Cases . . . . . . . . .124 A Quick Referesher on Design Issues and Terminology . . . . . . . .126 What Is a Domain Model? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .126 Understanding the Layers in a J2EE System . . . . . . . . . . . . . . .127 Pattern-Driven EJB Architectures . . . . . . . . . . . . . . . . . . . . . . . . . . .130 Domain and Persistence Layer Patterns . . . . . . . . . . . . . . . . . . .130 Services Layer Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133 Asychronous Use Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134 Synchronous Use Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134 Other Services Layer Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . .137 Inter-Tier Data Transfer Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . .137 Application Layer Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .141 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .142 Chapter 7 EJB Development Process: Building with Ant and Unit Testing with Junit . . . . . . . . . . . . . . . . . . . . . . . . .143 Order of Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .144 Layer-Independent Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .145 Domain First . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .146 Persistence Second . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .146 Services Third . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .148 Clients Last . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .148 viii Contents