Beginning Spring Framework 2ISBN: 978-0-470-10161-2
Paperback
472 pages
December 2007
This title is out-of-print and not currently available for purchase from this site.
|
Acknowledgments x
Introduction xix
Chapter 1: Jump Start Spring 2 1
All About Spring 2
Focus on Simplicity 2
Applying Spring 2
Creating a Modularized Application 3
Using Spring to Configure a Modularized Application 8
Wiring Beans Automatically by Type 14
Understanding Spring’s Inversion of Control (IoC) Container 16
Adding Aspect-Oriented Programming to the Mix 20
Adding a Logging Aspect 21
Beyond Plumbing — Spring API Libraries 25
Using Spring APIs To Facilitate Application Creation 26
Summary 27
Chapter 2: Designing Spring Applications 29
Overview of the PIX Album-Management System 30
The PIX System Requirements 31
Discovering the Domain Model 33
The PixUser POJO 33
The Affiliate POJO 35
The Picture Object 36
The Album POJO 37
The Comment POJO 38
The POJO Relationships 39
The Importance of Unit Testing 45
POJO-Based Design and Containerless Unit Testing 46
Regression Testing 46
Working with a Unit-Testing Framework 47
Summary 52
Chapter 3: Spring Persistence Using JPA 53
Java Persistence 54
JDBC Architecture 54
Traditional JDBC Approach 56
DAO — Unifying Data Access 64
Spring DAO Support 64
Spring Exception Translation 73
Spring and JPA 74
Entities 74
Spring as a JPA Container 81
About JPA APIs 81
JPA the Easy Way — Using Annotations 81
SPRING JPA Exception Translation 82
SPRING JPA DAOs 83
Spring JPA Configuration 84
Persistence and the PIX Domain Model 87
Persisting The PixUser POJO 87
Implementing PixUser Repository DAO 89
Implementing the Album Repository DAO 90
Testing the Persistence Layer 91
Spring Test Support 92
Executing the Persistence Test Suite 92
Testing the PIX Repositories 92
Summary 93
Chapter 4: Using Spring MVC to Build Web Pages 95
The MVC Architectural Pattern 95
The Sample Application’s Architecture 96
Spring MVC Development 99
Processing Web Requests with Controllers 99
Presenting the Model with a View 105
Getting Data from the User with Forms 109
A Basic Form-Submission Workflow 109
Using the Form View 112
When Things Go Wrong 123
Summary 124
Chapter 5: Advanced Spring MVC 125
Submitting a Form Across Multiple Pages 126
Adding Pictures to an Album 126
Developing Wizard Form Pages 127
Implementing Wizard Form Actions 131
Validating Data Submitted Through a Wizard 132
Uploading Files 133
Getting More Stuff Done with the Same Controller 134
Creating a Different View 137
Your First View 138
Saving an Album to PDF 139
Generating an RSS Feed 142
Personalization 146
Retrieving Text Labels from a Message Source 146
Displaying Application Labels in a Different Language 148
Changing the Application’s Language Settings 150
Allowing the User to Personalize the Application 151
Summary 154
Chapter 6: Spring Web Flow 155
Examining a Sample Work Flow for Loan Applications 156
Introducing Spring Web Flow 157
How SWF Works with Spring MVC 158
Launching Flows 159
Implementing SWF in the PixWeb Application 161
The Login Flow 161
The Album Creation Flow 176
Implementing Actions 178
Implementing Views 181
Testing Flows 183
Architectural Overview 185
Advanced Topics 186
REST-Style URLs 187
Flow Execution Repositories 188
Flow Execution Repository Implementations 189
Subflows and Attribute Mappers 189
Flow Execution Listeners 189
Exception Handlers 190
Summary 190
Chapter 7: Ajax and Spring: Direct Web Remoting Integration 191
Web 2.0: The World of Ajax 192
Ajax Basics 192
Client-Side Ajax Development with JavaScript 194
The XMLHttpRequest Object 194
Introducing Direct Web Remoting 2 199
Downloading DWR 2 201
Working with DWR 2 202
Integrating Spring and DWR 2 210
Summary 229
Chapter 8: Spring and JMS — Message-Driven POJOs 231
JMS Concepts 232
JMS Messaging Domains 232
Point-To-Point Messaging 232
Publish/Subscribe Messaging 233
Persistence versus Durability 234
The JMS Message 234
Message Header 234
Message Properties 235
Message Selectors 235
Message Body 235
Producing JMS Messages 236
Consuming JMS Messages 236
Synchronous Message Consumption 236
Asynchronous Message Consumption 237
The Spring JMS Framework 238
The Spring JMS Packages 238
The JmsTemplate Class 239
Message Listener Containers 240
Destinations 241
Transactions 241
Configuring Message-Driven POJOS 241
Realizing the JMS Use Case 242
Modeling Message-Driven POJOs 242
The PIX Web POJOS 242
Changing the PIX Web POJOs Into Message-Driven POJOs 245
A JMS Provider — Apache ActiveMQ 247
The JMS Template in the PIX Web Application 253
Summary 256
Chapter 9: Spring Web Services and Remoting 259
Web Service Benefits 260
Introducing Web Services 260
Web Services Architecture 261
The Network Layer 261
XML 261
SOAP 262
WSDL 262
UDDI 264
Web Services Interactions 265
Web Services Interoperability 266
Java Web Service Technologies 266
Java Web Application Web Services 266
Spring Remoting 268
SOAP Frameworks 268
Java-to-XML Bindings 269
XFire 269
Spring Web Services with XFire 270
Realizing the PIX AffiliateManagement Use Case 270
Invoking Web Services 277
SOAP Handlers 278
Testing SOAP Handlers with XFire 278
Summary 284
Chapter 10: Web Service Consumer and Interoperation with .NET 285
Creating Web Service Consumers — Overview 286
Describing Web Services with WSDL 286
Creating a Web Service Consumer with XFire 287
The XFire Maven Plugin 287
Invoking Web Service Methods via XFire-Generated Stubs 287
Understanding the E-Mail-Validation Web Service Consumer in PIX 288
Examining a WSDL Document 290
WSDL Description of a Web Service Endpoint 291
Generating Web Service Stubs from WSDL Using XFire 292
The XFire WsGen Tool 294
Generated Interface for Invocation of Web Service 295
Creating a Web Service Consumer with XFire-Generated Stubs 295
Add a Web Service Consumer to PIX 300
Web Service Interoperability 304
WS-I and Web Service Interoperability 304
Expose PIX Service for .NET Web Service Consumers 304
Summary 313
Chapter 11: Rapid Spring Development with Spring IDE 315
Brief Feature Overview 316
Installing and Setting Up Your Eclipse Environment 317
Installing Spring IDE 317
Preparing an Eclipse Project 319
Support for Spring Beans Configuration Files 325
Viewing Spring Bean Definitions 325
Validating Spring Bean Definition Files 328
XML Editing 332
Searching for and Navigating to Bean Definitions 335
Visual Support for Spring AOP Configurations 337
Enabling AOP Support for Spring Projects 338
Working with Spring IDE’s AOP Support 339
Integration with the AspectJ Development Tools 343
Web Flow Development with Spring IDE 344
Setting Up Your Spring Web Flow Project 344
Validating Spring Web Flow Definition Files 348
Editing Spring Web Flow Definition Files 350
Graphical Editor for Web Flow Definitions 351
Summary 353
Chapter 12: Spring AOP and AspectJ 355
Comparing Aspect-Oriented Programming to Object-Oriented Programming 355
What Is AOP? 357
Crosscutting Concerns 357
AOP in Spring 361
XML Schema-Based Support 362
The AOP Namespace Explored 362
Advice Parameters 367
AspectJ Support 368
@AspectJ Explored 368
@AspectJ-Style Advice 372
Performance Monitoring with AOP and JETM 376
Summary 379
References 380
Chapter 13: More AOP: Transactions 381
Understanding Transactions 382
Understanding Spring Transaction Management 383
Spring Transaction Abstraction 384
Applying AOP to Transactions 387
Adding Spring Transaction Support to PIX 38
Selecting the Transaction Manager 389
Coding Spring Transactions 397
Global Transactions 405
Summary 406
Appendix A: Maven 2 Basics 407
Appendix B: Spring and Java EE 439
Appendix C: Getting Ready for the Code Examples 451
Index 453