Building Spring 2 Enterprise Applications.pdf
(
2993 KB
)
Pobierz
374083693 UNPDF
Building Spring 2
Enterprise Applications
Interface 21
with Bram Smeets and Seth Ladd
Building Spring 2 Enterprise Applications
Copyright © 2007 by Interface 21, Bram Smeets, Seth Ladd
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval
system, without the prior written permission of the copyright owner and the publisher.
ISBN-13 (pbk): 978-1-59059-918-1
ISBN-10 (pbk): 1-59059-918-7
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence
of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark
owner, with no intention of infringement of the trademark.
Java
™
and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc., in
the US and other countries. Apress, Inc., is not affiliated with Sun Microsystems, Inc., and this book was
written without endorsement from Sun Microsystems, Inc.
Lead Editors: Matthew Moodie, Steve Anglin
Technical Reviewer: Rob Harrop
Editorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jason Gilmore,
Jonathan Hassell, Chris Mills, Matthew Moodie, Jeffrey Pepper, Ben Renow-Clarke,
Dominic Shakeshaft, Matt Wade, Tom Welsh
Project Manager: Kylie Johnston
Copy Edit Manager: Nicole Flores
Copy Editor: Marilyn Smith
Assistant Production Director: Kari Brooks-Copony
Production Editor: Laura Cheu
Compositors: Dina Quan, Linda Weidemann
Proofreader: April Eddy
Indexer: Becky Hornyak
Artist: Kinetic Publishing Services, LLC
Cover Designer: Kurt Krames
Manufacturing Director: Tom Debolski
Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor,
New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail
orders-ny@springer-sbm.com
, or
visit
http://www.springeronline.com
.
For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600,
Berkeley, CA 94705. Phone 510-549-5930, fax 510-549-5939, e-mail
info@apress.com
, or visit
http://www.apress.com
.
The information in this book is distributed on an “as is” basis, without warranty. Although every precau-
tion has been taken in the preparation of this work, neither the author(s) nor Apress shall have any
liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly
or indirectly by the information contained in this work.
The source code for this book is available to readers at
http://www.apress.com
in the Source Code/
Download section.
Contents at a Glance
Introduction
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
■
CHAPTER 1
A Gentle Introduction to the Spring Framework
. . . . . . . . . . . . . . . . . . . . . . . 1
■
CHAPTER 2
The Core Container
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
■
CHAPTER 3
Aspect-Oriented Programming
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
■
CHAPTER 4
Spring AOP 2.0
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
■
CHAPTER 5
Introduction to Data Access
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
■
CHAPTER 6
Persistence with JDBC
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
■
CHAPTER 7
Transaction Management
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
■
CHAPTER 8
Spring MVC
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
■
CHAPTER 9
View Technologies
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
■
CHAPTER 10
Testing
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
■
APPENDIX
Installing the Eclipse Web Tools Platform
. . . . . . . . . . . . . . . . . . . . . . . . . . . 303
■
INDEX
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
iii
Contents
Introduction
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
■
CHAPTER 1
A Gentle Introduction to the Spring Framework
. . . . . . . . . . . . . . 1
Building a Business Application
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Java Platform Hurdles
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Enter the Spring Framework
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Introducing the Spring Framework Modules
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Introducing the Sample Application
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Managing Dependencies in Applications
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
A Use Case That Has Dependencies
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Dealing with the Dependencies in Plain Java
. . . . . . . . . . . . . . . . . . . . . . . . . 9
Looking Up Dependencies with JNDI
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Using the Spring Framework to Provide Dependencies
. . . . . . . . . . . . . . . . 12
Integrating the Spring Framework with Java EE
. . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Spring Framework Integration with Java EE Technologies
. . . . . . . . . . . . . 19
Spring and EJB
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Setting Up the Spring Framework in Your Applications
. . . . . . . . . . . . . . . . . . . . . 21
Summary
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
■
CHAPTER 2
The Core Container
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
How Do Factories Work?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Factory Methods
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Factory Objects
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Introducing the BeanFactory
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Creating a BeanFactory Object
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Using Dependency Lookup
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Using Dependency Injection
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Using XML Tags for Bean Configuration
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Examining the Bean Life Cycle
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Bean Scope: Singleton or Prototype
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Bean Initialization
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Bean Destruction
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Using Factory Methods and Factory Objects in the Container
. . . . . . . . . . . . . . . . 54
Implementing Factory Methods
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Implementing Factory Objects
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Implementing Factory Objects with the FactoryBean Interface
. . . . . . . . . 57
v
Plik z chomika:
elrafb
Inne pliki z tego folderu:
User Interfaces with CSharp Windows Forms and Custom Controls.pdf
(22178 KB)
Using and Understanding Java Data Objects.chm
(5797 KB)
Using Microsoft Windows Small Business Server 2003.pdf
(7476 KB)
Virtualization From the Desktop to the Enterprise.chm
(12465 KB)
Visual Basic 2005 Recipes.pdf
(10845 KB)
Inne foldery tego chomika:
Linux Foundation - (LFCS)
Linux Video
O'Reilly
Prasa
Zgłoś jeśli
naruszono regulamin