Download as pdf
Download as pdf
You are on page 1of 489
Le document was created by an unregistered ChmMagic, please go to http:s/wmw.bisente.com to register it. Thanks| Agile Java Development with Spring, Hibernate and Eclipse By Anil Hemrajani Publisher: Sams Pub Date: May 09, 2006 Print ISBN-10:0-672-32896-8 Print ISBN-13:978-0-672-32896-1 Pages: 360 Overview Agile Java™ Development With Spring, Hibernate and Eclipses a book about robust technologies and effective methods which help bring simplicity back into the world of enterprise Java development. The three key technologies covered in his book, the Spring Framework, Hibernate and Ectpse, help reduce the complexity of enterprise Java development significant. Furthermore, these technologies enable plain old Java objects (POOs) to be deployed in light-weight containers versus heavy-handed remote objects that require heavy EJB containers. This book also extensively covers technologies such as Ant, JUnit, JSP tag lbraries and touches upon ther areas such as such logging, GUI based debugging, monitoring using JMX, job scheduling, emailing, and more. Also, Extreme Programing (XP), Agile Model Driven Development (AMDD) and refactoring are methods that can expecite the software development projec by reducing the amount of upfront requitements and design; hence these methods are embedded throughout the book but with Just enough details and examples to nt sidetrack the focus of this book. In adltion, tis book contains well separated, subjective material (pinion sidebars), comic ilusrations, tips and tricks, al of which provide real-world and practical perspectives on relevant topics. Last but not least, his book demonstrates the complete Iifecycle by building and following a sample apalication, Cchapter-by-chapter, stating from conceptualization to production using the technology and processes covered inthis book. In summary, ‘by using the technologies and methods covered in this book, the reader wil be able to effectively develop enterprise-class Java applications, in an agile manne hs document was created by an unregistered ChmMagic, please go to http:s/wmw.bisente.com to register it. Thanks| Agile Jv By Anil Hemrajani Development with Spring, Hibemate and Eclipse Publisher: Sams Pub Date: May 09, 2006 Print ISBN-10:0-672-32896-8 Print ISBN-13:978-0-672-32896-1 Pages: 360 [mead pyri ‘rewards bout the Author cknowledgment Pretac funman Recommended Resourced hcarnana oad Part il: Building the Sample Applicatior nats Covered in This Chapter fom User Stories to Desig xploring Classes Using CRG C: ara] ML Class Diag bampe Fie Named End-to-End Development Step: icceptance Test her Consideration funmay Pscommensed Resourced hapter 4. Environment Setup: JDK, Ant, and JUni hs document was created by an unregistered ChmMagic, please go to http:s/wmw.bisente.com to register it. Thanks| at's Covered in This Chapter lava Platform Standard Esition Development Kit (JDK Pirecioy structure] fal un ni To Mang he Tals Wak Top st Fis Design and ett] fiomay fsnnemamocomced ane 5. Vang penal or Peon Oi ats Govern Tis Chal Ove of Cet Relational apang OR] sg of Ou SamgeDalabas ere HSOLOS and Herts Fina Ou Ger cing vin Her ther Herat Feature fumnan fresnnenaea Recon agle 6_Oveniew he Sp Fanened nats Covered in This Chapte Jat is Sorina = Packaging ior Developmen] pring Packaging for Deploymen| werview of the Spring Module here Spring Framework Fis ino Our Arcitectur Fecommended Resourced hapler 7 The Spring Web MVG Framewor Jiat’s Covered in This Chapt Eoring Setup for Time Expression] Developing Tine Exression User irnes wih Sp aszaing Se Shet O55] imesee! List Ser: ANe Fam onal Bang Fite: ous Seer A Form Cooter Exam [ews win io Conte ring Hane 4 Sanpl Appicatein Aon ot Ta brain ing Frama fates a rane Fieconneniod Resouced apie 8 The Ease Phenomenal ats Govre in Tis Chal ne Eigse Fouad ne cipse Pom apd POS Feiss 0 once hs document was created by an unregistered ChmMagic, please go to http:s/wmw.bisente.com to register it. Thanks| [aamaeaed [etn U ipso Tie Epes ava Deveopen Tos JOT, Fea siaing he cise Web Tots Ptr (WTP Papin clgse Team Supper Fetes tee syste is and Ta rinsing cis folie Consent ai Pecommended Resourced Pasi, Advanced Feature apter 9. Loggng, Debugging Mion and Poin) whats Covered in This Chapte [ssing ve ska Commons Log ih Land and JDK Lena] Psouning Java Asleatons Us Eins ging Web User haces Using Feta ebvacing TimesheetManagerTest Endo End (Browser to Database IMX Management and Monitoring ava Prof Bebugging Tp fsoonena oul Sep 10-SeyrseBaih Tiss coves Tis Cup Fico Aces Jo enue fata ual fise re Sein Fan re Seg ars Herts amen) ISP Tag Ubraie etactrng ther Consaon ssid utvead jt About ve GUT THlk Glen Appleton ontgton Managemen CM Evtonnen VemctvonoisJevaSeitan XL ausx javadoc and Conmen faissesnos ua FissmenazaRosouan aot hatte ats Covered in Tis Crag pats th Tne Exreson Aa and AMDD-Based Software Developmen java Pato] bal hs document was created by an unregistered ChmMagic, please go to http:s/wmw.bisente.com to register it. Thanks| fused iverat he Spring Framewo cipee SD) cogging, Debugging, Monitoring, and Profi ating Hel P.Louick Note About Gode “Quality” Took Becommended Resourced hapler 12, Parting Thoughts Near Fue Pa ne Fue Agle Mts, lve Teco] ee Bar st: Rppendiced pendix A, Downloadable Code for This Boo ird-Party Libraries Shared Directory sample Application Directory (rapigavatimex) cfactored Sample Aopication Directory (rapidiavaltinex2) Boring Hibernate integration Demo Directory (rapdiava'sringhibernate) ndix B. Refactaring Dane to Sample Applicator SignlnContole java: JMX Monitoring imesheetl st Controle java: JMX Monitoring anager Classes: Sprng-Hibemate Inlegrato mesheetist jsp: Switch o Include File and Display nlerhours sp: Swith o Include File and Timex Tag Libra rest Classes and TimexTestCast ateuit java: New Method Jimexoss: New sive Jimexhsaldb xnt 82d Data Detect Fi pendix C. Java Code Convention pendix D._ Securing Web Applicaton pendix E. Sample Development Process Cheat Shee] eciec tat poration Pi pendix F, Agile Modeling Values, Practices, and Princinles Cheat Shee| pendix G. Extreme Programming (XP) Cheat Shee veri] pendix H_ Cool Took oss Platform Took crosott Windows-Based Took ac OS X-Ba5ed Took inux-8ased Tools (KDE] pendix L_ Visual Pattems Resear] he Probien| he Past: How We Have Been Kidding Oursel he Future: Agile Methos Perspective jin the Community’ fl This document was created by an unregistered ChmMagle, please go to hitp:/Awww.bisenter.com to register it. Thanks ra Copyright {Agile Java Development with Spring, Hibernate and Eclipse Copyright © 2006 by Sams Publishing All rights reserved. No part ofthis book shal be reproduced, sored in a fetrieval system, or transmitted by any means, electronic, ‘mechanical, photocopying, recording, or otherwise, without wtten permission from the publisher. No patent liabilly is assumed with respect othe use ofthe information contained herein, Although every precaution has been taken in the preparation of ths book, the publisher and author assume no responsiality for erors or omissions. Nor is any lablity assumed far damages resulting from the use of the information contained herein Library of Congress Catalog Card Number: 2005937888 Printed in the United States of America First Printing: May 2006 090807054321 Trademarks All terms mentioned inthis book that are known tobe trademarks or service marks have been appropriately capitalized, Sams Publishing cannot attest tothe accuracy ofthis information. Use ofa term inthis book should nat be regarded as affecting the valty of any trademark or sevice mark. Warning and Disclaimer Every effort has been made to make this book as complete and as accurate as possible, but no warranty or finess is implied. The information provided is on an ‘as is" basis. The author and the publisher shall have nether ialty nor responsibilty to any person or entity with respect to any loss or damages arising from the information contained inthis book. Bulk Sales ‘Sams Publishing ofers excellent discounts on this book when ordered in quantiy for buk purchases or special sales. For more information, please contact U.S. Corporate and Government Sales rpsales @pearsontechgroup.con| For sales outside ofthe U.S., please contact nternational@pearsoned.cor ‘Acquisitions Editor Jenny Watson [This document was created by an unregistered ChmMagic, please goto hitp:/www.bisente.com to register. Thanks] Development Editors Scott Meyers Songlin Qiu Managing Editor Patrick Kanouse Project Editor Mandie Frank Copy Editor Barbara Hacta Indexer Cheryl Lenser Proofreader Kathy Bidwell Technical Editor Bors Mirkin Publishing Coordinator Vanessa Evans Book Designer Gary Adair Page Layout Nonie Ratcit Agile Java Development wth Spring, Hibernate, and Eclipse is a welLunitten guide that covers numerous significant technologies, weaving them together using practical and proven methods that wil surely provide value to practitioners of every level Dan Malks, VP Solutions & Strategic Development, JackBe Inc; Author Core J2EE Patloms Anis relentiess dedication fo high qualty really shows. This isa very wel-witen Book! ost Sango, Conutent asiucon) ‘Ani has an uncanny abity fo cut tothe chase and ell you what you want to know. This book is one of those Jewels that appears only intrequenty. Instead of voluminous explanations of APIs, nil provides insightful Interpretation i highly visual terms, with a simple example that threads al the way through the book. Its 2 ‘masterwork of usability, as computer books go. Ci Berg founder of Assured by Design, co-founder of Digital Focus, author and consultant Dedication This is deaicated to my ioving and caring wife who has aways patiently supported me (and my odd ways). Thank you for taking care of ‘everyting during the times I was consumed by projects such as this book. This book would not be possible without you! And, of course, ‘to my dearest kids who brighten my every day r= This document was created by an unregistered ChmMagle, please go to hitp:/Aww.bisenter.com to register it. Thanks ra Forewords The true goal ofa foreword isto convince people to purchase the book. So, | guess you have three choices right now. First, you can save yoursel some time, stop reading this foreword right now, and simply take my word fort that buying this book's a good way to invest your hard-earned money. Second, you could not rust me, which franky isa smat thing to do because Im a consultant, and continue reading this foreword on the chance | might actualy say something that resonates with you and thereby motivate you to buy the book Third, you could decide to not purchase the book, which is kel a realy bad idea because the vast majoiy of Java programmers that | have met could really benef fom tis material |nmy opinion, the last hing thatthe Java community needs is another book describing some “really cool” Java technologies; there are hundreds of books out there already, thousands of magazine articles, and tens of thousands of web pages ateady covering realy cool Java technologies. Luckly, that's not wat this book is about. Agile Java Developments one of those rare books that teaches skis that you willuse throughout your career. Yes, it does cover the fundamentals of Spring, Hisemate, Ant, and a bunch of other stuff that you ‘need to succeed today. But, more important, it goes beyond the technology to describe agile techniques, adopted from Extreme Programming (XP) and Agile Modeling (AM), which enable you to succeed at modern software development. Most Java developers have heard about XP and many have adopted some ofits techniques, such as test-ven design (TDD), refactoring, and even air programming. This is @ ood start, but i's not enough. In this book, Anil brings his years of experience tothe table, describing wnat actually works in practice. This is diferent rom other books that often share a vision of what the author thinks will workin theory; but as we all know, theory and practice are often two ciferent things. \When Ani fist approached me tobe a technical reviewer ofthis book, the thing that most impressed me was his simple, yet effective, ‘approach to modeling on Java projects. n fact, you might want ofp through the book right now and take a quick look at some of the ‘madels. | think that youll notice that his diagrams are very similar to what you develop yoursel on actual projetsa rereshing change trom the advice presented in many of the modeling books available today. Youll also notice how Anil describes how to mave fom those simple models to the often-complex code that you wrte on a daily bass. This | think represents the greatest strength of this book: it Presents real-world advice that reflects what top-notch developers actually do in practice. The book also shows how many ofthe common tasks that we perform, such as acceptance testing, unit testing, objectelational ‘mapping, system integration, and refactoring, it into the sotware development picture. The book stats withthe "5,000 foot" process point of view, but dives down to ground level and describes how to use the tools n practice. Most baoks focus on ane view but not the other, but Agile Java Development pulls it off nicely and covers both views well Take afew minutes and browse the rest ofthis book. | think yout see what 'm talking about Scott W. Ambler Practice Leader, Agile Modeling This book isnot easly categorized. Let me explain why its unusual, and why it deserves your attention, Easily calegorizable books abound in our industry. They afe often books about a particular product or API. Some are good; some are bad. You can choose by the cover, the font, the publisher, the credibility ofthe authorbut you have already made a far more important choice: You know what book you are looking for. A good such commodity book may make you more efficent in a particular area, butts Unlikely to change the way you work. Books that are not easily categorzable are much rarer. They relate much more closely to ther author, and potentially to you ‘The present book shows how valuable such a book can be. Anil Hemrajani has dstiled his extensive experience as an architect and Ceveloper into a book that abounds inthe practical insights of a successful practioner. Like all the best books, its an effective communication between author and reader. As with all effective communication, the topic is nat limited tothe predictable, and ifs enjoyable: Anil has a natural wing style thats a pleasure to read This book has a remarkably broad scope. I tackles topics that are rarely tackled together, but shouldbe. The process we use to develop Le document was created by an unregistered ChmMagic, please goto http: bisenter.com to register it. Thanks software is inextricably linked to the way in which we structure our code and the tools we use to write that code. No effective developer works in 2 compartmentalized fashionthe many decisions to be made are intertwinedbut most books make ite attempt to paint te big Picture thats essential to geting results To develop Java software productively today, you need to understand key concepts such as O/R mapping and Dependency Injection you need to understand how and why to use techniques such as unit testing and automated builds; andequalysigifcantyou need to know the best tools forthe job, such as rameworks and IDEs. You also need to understand some of the pitfals to avoid, and how sometimes soft skils are as critical as technology. Anil has done a remarkable job of bringing these things together info a book that provides clarity n an area that many find confusing. It covers @ lot of ground, but never loses sight o its almto help readers complete successful projects see this book as a good map. It clearly shows you the path on your journey o successful enterprise Java development. Along the way, you may supplement it with mare detailed maps of particular areas. But you wll aways benef rom the direction it provides. | tecommend his book to anyone seting out to become an enterprise Java practioner today. It may well change the way you work, for the better. Rod Johnson CEO, inertaceat Founder, Spring Framework ra Le document was created by an unregistered ChmMagic, please go to http:s/wmw.bisente.com to register it. Thanks| ra About the Author ‘Anil Hemrajani has been working with Java Technology since late 1995 as a developer, entrepreneur, author, and trainer. He is the founder of Isavx Corporation, a successful IT service company (now Inscope Solutions), and isavix.net (now DeveloperHub.com), an award-winning online developer community that grew to more than 100,000 registered members. He has 20 years of experience inthe information technology community working with several Fortune 100 companies and also smaller organizations. He has published ‘humerous articles in well-known trade journals, presented at conferences and seminars around the world, and received the "Outstanding Contribution to the Growth ofthe Java Community” award trom Sun Microsystems, the "Best Java Client” award at JavaOne for BackOnlne, a Java-based online backup client/server product, 3 Computerworld-Smithsonian award fora tree online file storage service website, His more recent project isthe fanpater can webste ra

You might also like