1. Trang chủ
  2. » Khoa Học Tự Nhiên

Professional java development withth

968 58 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 968
Dung lượng 5,09 MB

Nội dung

This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Professional Java Development with the Spring Framework byRod Johnsonet al John Wiley & Sons 2005 (672 pages) ISBN:0764574833 Written by the lead developers of the Spring Framework, this authoritative guide shows you not only what spring can but why, explaining its functionality and motivation to help you use all parts of the framework to develop successful applications Table of Contents Professional Java Development with the Spring Framework Introduction Chapter - Introducing the Spring Framework Chapter - The Bean Factory and Application Context Chapter - Advanced Container Concepts Chapter - Spring and AOP Chapter - DAO Support and JDBC Framework Chapter - Transaction and Resource Management Chapter - Object/Relational Mapping Chapter - Lightweight Remoting Chapter - Supporting Services Chapter 10 - Acegi Security System for Spring Chapter 11 - Spring and EJB Chapter 12 - Web MVC Framework Chapter 13 - Web View Technologies Chapter 14 - Integrating with Other Web Frameworks Chapter 15 - The Sample Application Chapter 16 - Conclusion Appendix A - Requirements for the Sample Application Index List of Figures List of Sidebars This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Back Cover The Spring Framework is a major open source application development framework that makes Java/J2EE development easier and more productive This book shows you not only what spring can but why, explaining its functionality and motivation to help you use all parts of the framework to develop successful applications You will be guided through all the Spring features and see how they form a coherent whole In turn, this will help you understand the rationale for Spring’s approach, when to use Spring, and how to follow best practices All this is illustrated with a complete sample application When you finish the book, you will be well equipped to use Spring effectively in everything from simple Web applications to complex enterprise applications What you will learn from this book The core Inversion of Control container and the concept of Dependency Injection Spring’s Aspect Oriented Programming (AOP) framework and why AOP is important in J2EE development How to use Spring’s programmatic and declarative transaction management services effectively Ways to access data using Spring’s JDBC functionality, iBATIS SQL Maps, Hibernate, and other O/R mapping frameworks Spring services for accessing and implementing EJBs Spring’s remoting framework This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Professional Java Development with the Spring Framework Rod Johnson Juergen Hoeller Alef Arendsen Thomas Risberg Colin Sampaleanu Professional Java™ Development with the Spring Framework Published by Wiley Publishing, Inc 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2005 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN-13: 978-0-7645-7483-2 ISBN-10: 0-7645-7483-3 Manufactured in the United States of America 10 1B/RV/QW/QV/IN Library of Congress Cataloging-in-Publication Data: Professional Java development with the Spring Framework/Rod Johnson [et al.] p cm Includes index ISBN-13: 978-0-7645-7483-2 (paper/website) ISBN-10: 0-7645-7483-3 (paper/website) Java (Computer program language) Application software –Development I Johnson, Rod, Ph.D QA76.73.J38P74585 2005 005.13'3–dc22 2005013970 No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600 Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at http://www.wiley.com/go/permissions LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN THEN THIS WORK WAS WRITTEN AND WHEN IT IS READ For general information on our other products and services please contact our Customer Care Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002 Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc and/or its affiliates, in the United States and other countries, and may not be used without written permission Java is a trademark of Sun Microsystems, Inc All other trademarks are the property of their respective owners Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book Wiley also publishes its books in a variety of electronic formats Some content that appears in print may not be available in electronic books About the Authors Rod Johnson is the founder of the Spring Framework and a well-known expert on Java and J2EE Rod holds a Ph.D from Sydney University Originally from a C/C++ background, he has been involved with Java and J2EE since their releases as a developer, architect, and consultant This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com He is the author of two of the most popular and influential books on J2EE: Expert One-on-One J2EE Design and Development (Wrox, 2002), and J2EE without EJB (Wrox, 2004, with Juergen Hoeller) Both have played a major role in the rise of "agile" J2EE, and the move away from overly complex traditional J2EE architecture Rod is co-lead of the Spring Framework He is a popular conference speaker and regularly appears at leading Java events in the US, Europe, and Asia He serves in the Java Community Process (JCP) on the expert groups of several JSRs He also has wide consulting experience in banking and finance, insurance, software, and media He is CEO of Interface21 (www.interface21.com ), a consultancy devoted to providing expert J2EE and Spring Framework services He is actively involved with client projects as well as Spring development For Kerry Juergen Hoeller is co-founder of Interface21, the company providing commercial Spring services from the source He is a key driver of Spring development and has been release manager since Spring's inception His special interests and responsibilities in the project cover a wide variety of topics, from the core container to transaction management, data access, and lightweight remoting Juergen has a Master's degree in computer science from the University of Linz, specializing in Java, OO modeling, and software engineering He is co-author of Expert One-on-One J2EE Development without EJB (Wiley, 2004) and regularly presents at conferences and other events He is also active in many community forums, including TheServerSide To Eva, for her continuing love and support, and for understanding that there is no separation between working time and spare time in the Spring world Alef Arendsen studied computer sciences at the University of Utrecht Later, also in Utrecht, Alef started his first company After this turned out to be too little a challenge, Alef went to work for SmartHaven, an Amsterdam-based VC- funded company providing J2EE components for knowledge management applications He was responsible for streamlining the development process and designing parts of the component infrastructure In early 2002, together with Joost van de Wijgerd, Alef founded JTeam, a software company providing J2EE development services Alef is a core Spring committer and, while remaining involved with JTeam, he is now a consultant for Interface21 He is a frequent speaker at public conferences Alef can be reached by email at alef@interface21.com You can also read his blog at http://blog.arendsen.net To Mas, my nephew, who frequently cheered me up and reminded me of things other than work Thomas Risberg is a database developer working for TargetrRx, a pharmaceutical market research company located in Horsham, Pennsylvania He has many years of experience working with both large and small organizations on various databaserelated projects ranging from simple data entry programs to large data warehousing implementations Thomas is a reformed COBOL programmer who came to Java via Xbase, Visual Basic, and PL/SQL He served as an Oracle DBA for a couple of years but decided that software development was really where his heart was Thomas has a B.A degree in information processing from the University of Stockhom, Sweden He is a certified Oracle Professional DBA and a Sun Certified Java Programmer and J2EE Architect Thomas joined the Spring Framework development team in early 2003 and is mostly involved in evolving the JDBC layer His noncomputer–related interests are soccer, photography, and travel Colin Sampaleanu has had a long and varied career spanning almost two decades—after a childhood spent tinkering with computers and software—including experience developing for and managing his own retail software company, other years in the C++ shrinkwrap and enterprise software space, experience with Java since the early days of the language, and a complete focus on enterprise Java since the late nineties Colin is a currently a principal partner at Interface21, which specializes in Spring training, consulting, and support Prior to joining Interface21, Colin was Chief Architect at a software incubator / VC As a core Spring developer and Interface21 principal, Colin spends much of his time talking and writing about the benefits of Spring, and promoting agile software development architectures and methodologies in general To Nina, for her continued love and support, and for understanding that despite our best intentions, in this field 9–5 is often just the first half of the workday To Alec and Maia, for their simple innocence and joy, and for reminding me that there are other things in life besides computers Credits Executive Editor Robert Elliott Development Editor Adaobi Obi Tulton Technical Editors Peter den Haan Qi Zhang Aleksandar Seovic Erik Janssens Copy Editor Nancy Rapoport Editorial Manager Mary Beth Wakefield Vice President & Executive Group Publisher Richard Swadley This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Vice President and Publisher Joseph B Wikert Project Coordinator Kristie Rees Graphics and Production Specialists April Farling Julie Trippetti Quality Control Technicians Leeann Harney Jessica Kramer Joe Niesen, Carl William Pierce Proofreading and Indexing TECHBOOKS Production Services Acknowledgments Rod Johnson: Many people helped in the writing of this book In particular, I thank my co-authors, each of whom played a valuable role in ensuring that we were able to achieve coverage of a wide range of Spring's large and growing feature set Thanks to Ben Alex, lead developer of Acegi Security for Spring, for contributing most of the material on Spring security Mark Pollack, Spring developer and lead of Spring.NET, also kindly contributed valuable material relating to Spring's services for JMS Dmitriy Kopylenko, also a Spring developer, helped with UML diagrams and examples for the AOP chapter Finally, thanks to the reviewers—especially Peter den Haan and Aleksander Seovic—for their attention to detail and many valuable suggestions Juergen Hoeller: I thank my co-authors, our reviewers, and our editor; it has been a pleasure working with you A special thank you goes to Peter den Haan for his extraordinarily thorough chapter reviews Last but not least, I express my gratitude to the entire Spring community: Without your active participation, the Spring project would not be what it is today A Arendsen: I thank all my co-workers at JTeam for their support Special thanks to Bram Smeets and Arjen Poutsma for providing valuable content on various topics I also owe a lot to Joost, the chap I originally started JTeam with Without him I couldn't have found the time to contribute to this book I also want to express my gratitude to Goof Kerling, who taught me a great deal about programming, how to it the right way, and life in general Thanks to Lars for cooking once every month, providing me with a place to stay until my house was finished, and joining me for the occasional beer Also, thanks to my family for their support and the technical editors for thoroughly reviewing the content and for pointing out that Dutch isn't the most widely used language in the world Thomas Risberg: I thank the entire Spring community—without you, neither the project nor this book would be what it is today Colin Sampaleanu: I thank my co-authors, my partners at Interface21, and the Spring team for setting the bar so high It's always a pleasure working with you I'm grateful for the many colleagues over the years who by being passionate about the art of software development have helped keep my own interest high I also thank my technical reviewers, Peter den Haan, Qi Zhang, and Jim Leask, who provided much valuable feedback This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Introduction The Spring Framework is a major open source application development framework that makes Java/J2EE development easier and more productive Spring offers services that you can use in a wide range of environments, from applets and standalone clients through web applications running in a simple servlet engine to complex enterprise applications running in a full-blown J2EE application server Spring enables a POJO programming model that decouples your code from its environment, protecting your investment in the face of change Spring works on JDK 1.3 and later, taking advantage of JDK 1.4 and 1.5 features if available Spring's J2EE services run on J2EE 1.2 and later This book will show you how you can use all the major parts of Spring to help you develop successful applications You'll learn not just what Spring does, but why You will gain insight into best practices when using the framework, and you will see a complete sample application Whom This Book Is For This book is for Java/J2EE architects and developers who want to gain a deep knowledge of the Spring Framework in order to use it effectively in applications from simple web applications up to complex enterprise applications If you're new to Spring, you will still be able to work your way through this book However, the coverage of advanced topics will ensure that even experienced Spring users will find information to help them use Spring effectively You will probably want to keep this book on your desk for reference as you develop applications using Spring This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Aims of This Book This book covers all major parts of the Spring framework, explaining the framework's functionality and motivation It aims to equip you to implement advanced applications using Spring This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com What This Book Covers This book covers most of the feature set of Spring 1.2 You will learn: What Spring offers Spring has a large feature set: We guide you through the features and show how they form a coherent whole Why Spring does what it does We discuss the motivation behind many Spring features and the rationale for Spring's approach When to use Spring features, and about best practices when using Spring We cover the following areas of Spring, with the background discussion necessary to put the Spring functionality in context: The core Inversion of Control container and the concept of Dependency Injection that underpins it Spring's lightweight container provides sophisticated configuration management, and a flexible backbone within which other services can be used Spring's Aspect-Oriented Programming (AOP) framework and why AOP is important in J2EE development Together with Spring's Dependency Injection capabilities, Spring AOP enables a POJO programming model, in which application code has minimal dependencies on Spring APIs, even when it enjoys Spring services Spring's approach to service abstraction, and the goals it achieves Transaction management: Core concepts, Spring's programmatic and declarative transaction management services, and how to use them effectively Data access using Spring: You'll see how Spring provides a sophisticated, consistent abstraction over a variety of popular data access technologies We'll look in detail at how to access data using Spring's JDBC functionality, iBATIS SQL Maps, and the Hibernate O/R mapping framework You will gain a solid conceptual understanding of Spring data access that is applicable to other supported persistence APIs such as TopLink Spring's MVC web framework Three chapters provide in-depth information about the motivation for Spring's MVC framework, how it compares with other popular web application frameworks such as Struts, and how to use it in scenarios from basic to advanced You will also see how to use Spring MVC to generate custom content types Spring services for exposing and accessing remote services Spring provides a unique remoting framework that works over a variety of protocols, but is entirely POJO-based Spring services for accessing and implementing EJBs Spring services relating to JMS Spring's integration with the open source Quartz scheduler and other popular open source and commercial products How Spring can be used in the design and implementation of a complete application, through our sample application Effective testing strategies for Spring applications One of the major advantages of a sophisticated Dependency Injection container is that it can enable effective unit testing of application code; Spring goes a step further by providing powerful integration testing features that also don't require a container, significantly increasing the speed of develop-test cycles Throughout, we discuss best practices Sophisticated frameworks such as Spring inevitably allow multiple ways to achieve the same end; we try to provide guidance as to how to make the best choice We also help you understand how Spring can provide a basis for a clean, layered architecture, and how appropriate use of Spring facilitates good OO design and architectural practice This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Assumed Knowledge This book assumes a working knowledge of core features such as JDBC Chapters related to J2EE topics such as EJB and JMS assume a basic grounding in those areas However, we provide suggestions on further reading at appropriate points, so don't worry too much now if you're not sure your knowledge is deep enough We assume sound knowledge of OO design and Java language features including reflection, inner classes, and dynamic proxies Existing Spring Framework knowledge is not required We assume a basic knowledge of SQL and relational database concepts An understanding of object relational mapping (ORM) is helpful but not essential If you've used a MVC web framework such as Struts, you will probably grasp the web content more quickly However, we begin our coverage of Spring MVC with a discussion of the concepts behind MVC web frameworks This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Recommended Reading Throughout the book we recommend further reading that will help you get a deeper grasp of concepts important to Spring development, such as Aspect-Oriented programming (AOP) You may find it helpful to read J2EE without EJB (Johnson/Hoeller, Wrox, 2004), which provides a detailed discussion of the architectural rationale for lightweight containers such as Spring However, this book is not purely a sequel to that book and can be understood entirely on its own There are many Spring Framework resources online You should find the following particularly helpful: The Spring Home page (www.springframework.org ): Portal for most Spring-related information, including the reference documentation and downloads Spring Forums (forum.springframework.org): The place to go to ask questions about Spring The Spring community is generally very welcoming and helpful This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com SingleConnectionDataSource interface,JDBC,179 single-resource transaction managers,243–248 singleton aspects,AspectJ,165–166 singleton attribute, bean element,55–56 singleton beans accessing container using,99 compared to non-singleton beans,55–56 in lifecycle of AOP proxies,140 singleton container access for EJBs,413–420 singleton property, AdvisedSupport class,137 SingletonBeanFactoryLocator class,99,414–416 SingletonTargetSource interface,144–145 SiteMesh,513 snapshot comparisons,Hibernate,268 SOAP,remoting using,307 SourceForge c3PO,252 source-level metadata for transactions,238–242 “Spring and AspectWerkz — A Happy Marriage" (Boner),169 Spring Framework advantages of,3,36,577 architecture of,21–29 definition of,1 environments supported by,37 future of,29–32,598–599 goals of,6–8 guidelines for development using application structure,589–592 layering best practices,583–588 technology choices,581–583 testing,592–594 history of,32–33 integration with other frameworks,19–21 JARs,list of,36 modules in,list of,5–6,33–36,578–580 related projects for,594–596 release schedule of,29 size of,36 techniques used by,18 technologies used by,8–18 Spring Framework community,33 The Spring Framework.NET,595 Spring IDE for Eclipse,595 The Spring Modules project,595 Spring MVC web framework See also controller objects; model objects; view objects choosing,523–524,587–588 comparing available frameworks controllers and interception handling,530–532 data binding,525–528 presentation layer,528–529 requirements for,524–525,532–533 integration with Spring,534–536 JSF web framework controllers,531 data binding,528 definition of,525 features of,528,529,531,533 integration with,20,547–548 interceptors,531 presentation layer,529 list of,20 requirements for,524 Spring MVC web framework application design using,427,430–431,440–441 architecture of,425–430 components of,430–436,440–441 controllers,530–531 data binding,461–463,526–527 definition of,5,35,580 example of,423–425,464–474 exception handling,438,456–458 features of,526–527,529,530–531,532–533 handler adapters,449 handler exception resolvers,456–458 handler interceptors,446–449 This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com handler mappings,441–446 handlers,extending,478 handling requests,436–439 Hibernate,Open Session in View,282–285 interceptors,530–531 locale resolution,454–455 presentation layer,529 pull model and,426 push model and,427 requirements for,428 testing controllers,481–485 testing web applications,485 uploading files,478–481 view resolvers,450–454 Struts web framework compared to Spring Framework,1,3 controllers,530 converting to Spring MVC,437 data binding,526 definition of,525 features of,526,528,530,532 integration with,20,537–543 interceptors,530 presentation layer,528 Tapestry web framework controllers,531 data binding,527 definition of,525 features of,527,529,531,533 integration with,20,543–547 interceptors,531 presentation layer,529 WebWork web framework controllers,530 definition of,596 features of,530,532 integration with,536–537 interceptors,530 Spring RCP (Rich Client Project),29,596 Spring Rich Client (RCP) project,29,596 Spring XMLDB,595 spring-beans.dtd file,53 spring:bind tag,498,499–501 spring:hasBindErrors tag,498 spring:htmlEscape tag,498 spring:message tag,498,502–503 spring-mock.jar file,481 spring:nestedPath tag,501 SpringObjectFactory class,536–537 spring:transform tag,498,501–502 SQL Maps (iBATIS) configuration file,265–266 DAO implementation for,263–265 DAO support class for,173 definition of,255,257,261,267–268 integration with,19 mapped statements (mapping file) for,261–263 Spring setup for,265–266 transaction management using,266–267 when to use,267,584 SQL queries,JDBC features for,175 with JdbcTemplate class,183–189,204–206 with RDBMS operation classes,189–194,206–209 SQL state code,JDBC,174 SQLErrorCodeSQLExceptionTranslator class, JDBC,201,202–203 SQLException class,JDBC,174,180–182 SqlMapClient API,iBATIS SQL Maps,263–265 SqlMapClientDaoSupport class,173,263 SqlMapClientFactoryBean class,265 SqlMapClientTemplate class, 263–265 sql-map-config.xml file, 265–266 SqlQuery class, JDBC, 189, 190–192 This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com SqlQuery class, JDBC, 189, 190–192 SqlUpdate class, JDBC, 189, 192–193, 206–208 standards,Spring Framework and,31–32 Stateful Session Beans,implementing,410–411 StatefulJob interface,350–351 StatefulService interface,410 stateless remoting,307 Stateless Session Beans implementing, 407–410 lookups, encapsulating, 402–406 Statement interface,JDBC,174 statement wrappers,with application servers,200–201 static pointcuts,127,129 staticAttributesMap property, AbstractView class,520 StaticMethodMatcherPointcut class,129 status of transaction,229 status.displayValue() method, BindStatus class,500 status.error() method, BindStatus class,500 status.errorCode() method, BindStatus class,500 status.errorCodes() method, BindStatus class,500 status.errorMessage() method, BindStatus class,500 status.errorMessages() method, BindStatus class,500–501 status.expression() method, BindStatus class,500 status.value() method, BindStatus class,500 stored procedures,JDBC,196–199,210–214 StoredProcedure class,JDBC,189,196–199,211–214 StringArrayPropertyEditor class,103 StringTrimmedEditor class,103 strongly typed operations,DAO,260 Struts Tiles,511–513 Struts web framework compared to Spring Framework,1,3 controllers,530 converting to Spring MVC,437 data binding,526 definition of,525 features of,526,528,530,532 integration with,20,537–543 interceptors,530 presentation layer,528 struts-config.xml file,539,541 stub lookups,RMI remoting,317,320–322 Subject class,JAAS,372 successView property, SimpleFormController class,468 supportedMethods property, WebContent Interceptor class,448 supports() method, HandlerAdapter interface,478 SUPPORTS transaction attribute,222 suppressValidation() method, SimpleForm Controller class,470 swap() method, HotSwappableTargetSource class,148 Swing-based applications,using Spring with,596 synchronous messaging,339 This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Index T tag files,504–505 tags,Spring,497–504 Tapestry web framework controllers,531 data binding,527 definition of,525 features of,527,529,531,533 integration with,20,543–547 interceptors,531 presentation layer,529 target object,AOP custom target sources,152 definition of,118–119,147–148 hot swapping,13,148–149 pooling,149–152 programmatic access to,152 when not to use,152–153 target property, AdvisedSupport class,135,138 TargetSource interface for autoproxy creation,144–145 custom,152 implementations of,147–153 programmatic access to,152 targetSource property, AdvisedSupport class,135 TargetSourceCreator interface,144–145 TDD (Test Driven Development),18 template (abstract parent bean definition),73 templates for resource management,17 Test Driven Development (TDD),18 testing AOP used for,159–161 container used in,106–108 ease of,Spring Framework support for,7 EJBs,420–422 guidelines for,592–594 integration testing AOP framework used for,160 in application server,421–422 container used for,106–108 guidelines for,593–594 support for,18 tools for,485 splitting container definitions into multiple files for,95–96 unit testing difficulty of,2 example of,103–106 features for,6,18 guidelines for,160,161,593 mock objects used for,104–106 TestMaker tool (Push2Test),485 ThemeResolver class,435 ThemeSource interface,50 thread safety advice and,123 AOP framework and,146 guidelines for,586–587 hot swapping and,148 of JdbcTemplate class,183 of RDBMS operation classes,189 of SingleConnectionDataSource interface,179 of StoredProcedure class,199 ThrowAwayController class,449,465 throws advice,124–125 ThrowsAdvice interface,122,124–125 tiles,511–513 This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com TilesConfigurer class,513 timeout for transaction,229 Timer class,345,346–348 TimerFactoryBean class,348 Timers,scheduling using,345,346–348 Tirsen,Jon (AOP Alliance founder),120 Tomcat server (Apache),552,574,575 TopLink API integration with,19 object query language used by,257 O/R mapping and,300–302 resource management for,16 TopLinkDaoSupport class,301 TopLinkTemplate class,301 TopLinkTransactionManager class,247,301 toProxyConfigString() method, Advised interface,160 TP monitor,220 transaction attributes,EJB,222 transaction demarcation declarative BeanNameAutoProxyCreator interface,237–238 definition of,225,227,233 guidelines for,242 performance of,242 ProxyFactoryBean interface and transaction inter- ceptor,233–235 source-level metadata,238–242 TransactionProxyFactoryBean interface,235–236 guidelines for,242 performance of,242 programmatic,225,227,230–232 strategies for,221–222,225,229–230 where to demarcate,230 transaction interceptors definition of,233–235 Hibernate,281–282 JDO,294–295 transaction management ACID requirements of,218–220 with application servers,200–201,220,249–251 atomicity,218–219 in business services layer,27 CMT (container-managed transactions),219,224 concurrency control,220 configuration for,226–229 as crosscutting concern,113–114 data source declaration,251–254 declarative transaction management,13,219,222,224 definition of,5,34,217–218,579 example of,222–224 global (distributed) transactions,221,260 guidelines for,585–586 isolation,219–220,228–229 for JMS (Java Message Service),343 JTA (Java Transaction API),224–225 JTA synchronization,278–280 JTS specification regarding,220–222 local transactions,221 for O/R mapping,260 for O/R mapping with Hibernate,276–282 for O/R mapping with iBATIS SQL Maps,266–267 for O/R mapping with JDO,293–294 programmatic transaction management,221 propagation behavior of transactions,227–228 read-only transactions,229 rollback rules,234–235 single-resource transaction managers,243–248 source-level metadata for,238–242 Spring features for,list of,224–226 status of transaction,229 strategies for list of,225–226 multiple resource,249–251 single resource,243–248 timeout for transaction,229 transaction context,221 This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com transaction propagation,221 where to apply transactions,230 transaction manager,220 TransactionAttribute interface,226 TransactionAwareDataSourceProxy class,244 TransactionDefinition interface,226 TransactionManager interface,250–251 TransactionProxyFactoryBean class,70,72 TransactionProxyFactoryBean interface,140,235–236,266,276 TransactionStatus interface,229 TransactionTemplate class,225,232,266,276 Transfer Objects disadvantages of,2 distribution and,582 remoting and,28,588 as unnecessary,23 transparent persistence,258 transparent recovery (retrying),13 trigger,Quartz scheduler,348–349,351–352 typed advice,125 This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Index U union() method, Pointcuts class,130 unit testing difficulty of,2 example of,103–106 features for,6,18 guidelines for,160,161,593 mock objects used for,104–106 UpdatableSqlQuery class,JDBC,193–194 update methods,24 update statements,in iBATIS SQL mapping file,263 uploading files,478–481 UrlBasedViewResolver class,450–451 URLEditor class,103 UrlFilenameViewController class,459–460 UrlResource class,85,92 URLs,as resources,84 useCacheControlHeader property, WebContent Interceptor class,448 useExpiresHeader property, WebContent Interceptor class,448 UserRoleAuthorizationInterceptor class,448–449 This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Index V validateOnBinding property, SimpleForm Controller class,469 validatePage() method, AbstractWizard FormController class,475 validator property, SimpleFormController class,468 value element,58–59 Velocity template engine configuring view resolver for,505–506 definition of,505 form simplification macros,507–510 integration with,21 for mail manager,356 Velocity Template Language (VTL),505–506 VelocityConfigurer class,513 version release schedule,29 View interface,430,492,520 view objects definition of,28,426 prefixes for,495–496 provided by Spring,430 rendering models,491–492 view resolvers configuring for FreeMarker,506–507 configuring for Velocity,505–506 MVC,430,445,450–454 view technologies AbstractView class,493–496 caching views,522 choosing,491 configuration for,488–489 custom views,519–522 document-based,515–519 example of,488–491 Excel-based,515–519 FreeMarker template engine,489–490,505–510 iText library,generating PDFs using,490–491 JavaServer Pages,489,496–505 tiles,511–513 Velocity template engine,505–510 View interface,488 ViewResolver interface,488 XML-based,514–515 XSLT-based,514–515 ViewResolver class definition of,435,440 example of,488 JSP and,497 multiple instances of,445 types of,450–454 Vlissides,John (Design Patterns),597 VTL (Velocity Template Language),505–506 This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Index W Wanghy Cache,595 weather data service example IoC version Constructor Injection,43–44 Method Injection,44–45 Setter Injection,41–43 JDBC used by,67–69 non-IoC version,40–41 web frameworks See also MVC web frameworks application dependency on,6 books about,597 integration with,20 web requests,security for,368,369–370 Web Service Definition Language (WSDL),307 Web Services with JAX-RPC accessing a service,326–328 custom application objects,330–332 definition of,324–325 exporting a service,328–330 support classes for,325 when to use,325,333 web tier,27–28 WebApplicationContext interface,50,430–431,432,434–436 WebApplicationObjectSupport class,435–436 WebContentGenerator interface,458 WebContentInterceptor class,447–448 WebLogic 7.0 and 8.1 server,transaction manager for,249,250 WebLogicJtaTransactionManager class,250 WebLogicServerTransactionManager FactoryBean class,250 websites Acegi Security,368 Apache Commons Pool,150 Apache OJB (Object relational Bridge),256 AspectWerkz AOP framework,169 Aurora MVC,595 Canoo WebTest tool,106,485 Cayenne O/R mapping project,302,596 EasyMock library,105,483 Hibernate,269 iBATIS SQL Maps,261 iText library,490 Jakarta Apache Cactus tool,106,421 Jakarta Commons FileUpload package,478 Jakarta POI,516 JavaDoc,597 JDBC RowSet Implementations tutorial,189 JDBC tutorial,171 jExcelApi,516 jMock library,106 JSF web framework,525 JSF-Spring,595 MockEJB framework,420 Mule framework,596 Oracle TopLink,256 sample application source code,551 SiteMesh,513 Spring documentation,597 The Spring Framework.NET,595 Spring IDE for Eclipse,595 The Spring Modules project,595 Spring XMLDB,595 Struts web framework,525 Tapestry web framework,525 TestMaker tool (Push2Test),485 TopLink,301 Velocity macros,510 Velocity template engine,356 Wanghy Cache,595 This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com WebWork web framework,525,596 WebSphere 4.0 and 5.x server,transaction manager for,249 WebSphereTransactionManagerFactoryBean class,250 WebWork web framework controllers,530 data binding,525–526 definition of,525,596 features of,525–526,528,530,532 integration with,20,536–537 interceptors,530 presentation layer,528 wizard-style forms,474–477 WSDL/SOAP,remoting using,307 See also Web Services with JAX-RPC This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Index X XDoclet,412 XML-based views,514–515 XmlBeanFactory class,52 XML-configured containers alternatives to,108–110 format of,53 initialization of beans and,57 loading,52 XMLDB,Spring,595 XmlViewResolver class,451,493 XmlWebApplicationContext interface,85,435,484 XP (Extreme Programming),18 XSLT-based views,514–515 XWork SpringObjectFactory,536–537 This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com List of Figures Chapter 1: Introducing the Spring Framework Figure 1-1 Chapter 2: The Bean Factory and Application Context Figure 2-1 Chapter 4: Spring and AOP Figure 4-1 Figure 4-2 Figure 4-3 Chapter 5: DAO Support and JDBC Framework Figure 5-1 Figure 5-2 Figure 5-3 Figure 5-4 Figure 5-5 Chapter 6: Transaction and Resource Management Figure 6-1 Figure 6-2 Chapter 10: Acegi Security System for Spring Figure 10-1 Figure 10-2 Figure 10-3 Figure 10-4 Figure 10-5 Figure 10-6 Figure 10-7 Figure 10-8 Chapter 12: Web MVC Framework Figure 12-1 Figure 12-2 Figure 12-3 Figure 12-4 Figure 12-5 Figure 12-6 Figure 12-7 Figure 12-8 Chapter 13: Web View Technologies This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Figure 13-1 Figure 13-2 Chapter 14: Integrating with Other Web Frameworks Figure 14-1 Chapter 15: The Sample Application Figure 15-1 Figure 15-2 Figure 15-3 Figure 15-4 Figure 15-5 Figure 15-6 Figure 15-7 Figure 15-8 Appendix A: Requirements for the Sample Application Figure A-1 Figure A-2 Figure A-3 Figure A-4 Figure A-5 Figure A-6 Figure A-7 Figure A-8 This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com List of Sidebars Chapter 9: Supporting Services Choosing an Implementation Language Chapter 16: Conclusion Web Tier Design Principles This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Professional Java Development with the Spring Framework byRod Johnsonet al John Wiley & Sons 2005 (672 pages) ISBN:0764574833 Written by the lead developers of the Spring Framework, this authoritative guide shows you not only what spring can but why, explaining its functionality and motivation to help you use all parts of the framework to develop successful applications Table of Contents Professional Java Development with the Spring Framework Introduction Chapter - Introducing the Spring Framework Chapter - The Bean Factory and Application Context Chapter - Advanced Container Concepts Chapter - Spring and AOP Chapter - DAO Support and JDBC Framework Chapter - Transaction and Resource Management Chapter - Object/Relational Mapping Chapter - Lightweight Remoting Chapter - Supporting Services Chapter 10 - Acegi Security System for Spring Chapter 11 - Spring and EJB Chapter 12 - Web MVC Framework Chapter 13 - Web View Technologies Chapter 14 - Integrating with Other Web Frameworks Chapter 15 - The Sample Application Chapter 16 - Conclusion Appendix A - Requirements for the Sample Application Index List of Figures List of Sidebars ... http://www.colorpilot.com Professional Java Development with the Spring Framework Rod Johnson Juergen Hoeller Alef Arendsen Thomas Risberg Colin Sampaleanu Professional Java Development with the... Data: Professional Java development with the Spring Framework/Rod Johnson [et al.] p cm Includes index ISBN-13: 978-0-7645-7483-2 (paper/website) ISBN-10: 0-7645-7483-3 (paper/website) Java (Computer... http://www.colorpilot.com Back Cover The Spring Framework is a major open source application development framework that makes Java/ J2EE development easier and more productive This book shows you not only what spring

Ngày đăng: 25/03/2019, 15:08