Books in the series promise to bring you the key technical information you need to analyze Eclipse, high-quality insight into this powerful technology, and the practical advice you need
Trang 2ECLIPSE WEB TOOLS PLATFORM
Trang 3For more information on books in this series visit www.awprofessional.com/series/eclipse
SERIES EDITORS Erich Gamma ■ Lee Nackman ■ John Wiegand
Eclipse is a universal tool platform, an open extensible integrated development ronment (IDE) for anything and nothing in particular Eclipse represents one of the most exciting initiatives hatched from the world of application development in a long time, and it has the considerable support of the leading companies and organ- izations in the technology sector Eclipse is gaining widespread acceptance in both the commercial and academic arenas.
envi-The Eclipse Series from Addison-Wesley is the definitive series of books dedicated
to the Eclipse platform Books in the series promise to bring you the key technical information you need to analyze Eclipse, high-quality insight into this powerful technology, and the practical advice you need to build tools to support this evolu- tionary Open Source platform Leading experts Erich Gamma, Lee Nackman, and John Wiegand are the series editors.
Titles in the Eclipse Series
John Arthorne and Chris Laffra
Official Eclipse 3.0 FAQs
0-321-26838-5
Frank Budinsky, David Steinberg, Ed Merks, Ray Ellersick, and Timothy J Grose
Eclipse Modeling Framework
0-131-42542-0
David Carlson
Eclipse Distilled
0-321-28815-7
Eric Clayberg and Dan Rubel
Eclipse: Building Commercial-Quality Plug-Ins, Second Edition
0-321-42672-X
Adrian Colyer, Andy Clement, George Harley, and Matthew Webster
Eclipse AspectJ: Aspect-Oriented Programming with AspectJ and the Eclipse AspectJ Development Tools
0-321-24587-3
Erich Gamma and Kent Beck
Contributing to Eclipse: Principles, Patterns, and Plug-Ins
0-321-20575-8
Jeff McAffer and Jean-Michel Lemieux
Eclipse Rich Client Platform: Designing, Coding, and Packaging Java ™ Applications
0-321-33461-2
Steve Northover and Mike Wilson
SWT:The Standard Widget Toolkit,Volume 1
0-321-25663-8
Diana Peh, Alethea Hannemann, Paul Reeves, and Nola Hague
BIRT: A Field Guide to Reporting
0-321-44259-8
Jason Weathersby, Don French,Tom Bondur, Jane Tatchell, and Iana Chatalbasheva
Integrating and Extending BIRT
0-321-44385-3
Trang 4ECLIPSE WEB TOOLS
Trang 5The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty
of any kind and assume no responsibility for errors or omissions No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein.
The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests For more information, please contact:
U.S Corporate and Government Sales
Visit us on the Web: www.awprofessional.com
Library of Congress Cataloging-in-Publication Data
Dai, Naci.
Eclipse Web tools platform : developing Java Web applications / Naci Dai, Lawrence Mandel, Arthur Ryman.
p cm.
Includes bibliographical references and index.
ISBN 978-0-321-39685-3 (pbk : alk paper) 1 Web site development 2 Java (Computer program language)
3 Internet programming I Mandel, Lawrence II Ryman, Arthur III Title
TK5105.888.D32 2007
006.7'6—dc22
2007010167 Copyright © 2007 Pearson Education, Inc.
All rights reserved Printed in the United States of America This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission
in any form or by any means, electronic, mechanical, photocopying, recording, or likewise For information regarding permissions, write to:
Pearson Education, Inc.
Rights and Contracts Department
75 Arlington Street, Suite 300
Boston, MA 02116
Fax: (617) 848-7047
ISBN 13: 978-0-321-39685-3
ISBN 10: 0-321-39685-5
Text printed in the United States on recycled paper at Courier in Stoughton, Massachusetts.
First printing, May 2007
Trang 6To my wife and best friend, Karen, who encourages and helps me in all my endeavors, and to my daughters, Maya and Ela, for letting me use their weekends and playtime
for writing this book I love you all.
—N.D.
To my wife, Elana, who inspires, encourages, and challenges me to try new things,
computer and who I know would have thought this stuff was so cool.
Trang 8Foreword xviiPreface xixAcknowledgments xxiii
Java Web Application Development and Eclipse 3
Trang 9The Installable Components of WTP 91
Trang 10Installation via Update Manager 95
Chapter 5 Web Application Architecture and Design 113
Model View Controller (MVC) for the Web 123
Providing Services: The Service Layer 130
Web Project Types and J2EE Applications 138
Trang 11Example Projects 165
Dividing a Web Module into Multiple Projects 171Using Maven for Web Application Development 180
Trang 12The TCP/IP Monitor 290Viewing HTTP Sessions with the TCP/IP Monitor 291Modifying and Resending a Message 293
Use JDBC APIs to Map Objects to a Database 371Use Entity Beans to Map Objects to a Database 372Use Object-Relational Frameworks to Map
Trang 13Iteration 2: Data Layer 386
Preparing JBoss, Derby, and XDoclet 393
Adding ejbCreate and finder Methods 401Adding the Ice Hockey CMP Data Access Object 408
Testing with the Web Services Explorer 451
Trang 14Test the User Interface 491
Iteration 1: Unit Testing with JUnit 512
Overview of Adding a Generic Server Adapter 554
Adding Support for a New Server Runtime 558Adding a New Server Type for a Runtime 561
Trang 15Extending the Server Tools UI 565
Creating the DocBook Extension Plug-in 585
Implementing the DocBook Validator 587
Customizing the Look of Extensibility Elements in the Editor’s Design View 614Adding Extensibility Elements to the Editor 617Adding Custom Actions to the WSDL Editor
Contributing to WSDL 1.1 Validation 636Contributing Custom Validation Rules 640
Creating the Resource Resolution Extension Plug-in 647Contributing Resources to the XML Catalog 648
Adding a Single Resource to the XML Catalog 651Adding a Catalog of Resources to the XML
Catalog 654Implementing a Custom Resource Resolution Strategy 657
Trang 16Part IV ❍ Products and Plans 667
Eclipse Data Tools Platform (DTP) Project 678Eclipse JavaServer Faces (JSF) Tools Project 678Eclipse Dali Java Persistence Architecture (JPA)
Eclipse AJAX Tools Framework (ATF) Project 679
Eclipse PHP Development Tools Project 680Eclipse SOA Tools Platform (STP) Project 681
Glossary 683References 689
Trang 18complemen-On the Open Source project side, WTP has garnered contributions frommany organizations and companies To list just a few of the prominent ones:WTP has active participation from ObjectWeb Lomboz developers such as NaciDai, it has been ably led by Tim Wagner from BEA, it has seen contributions ofcode and committers from Oracle in both the JavaServer Faces (JSF) and object-relational persistence (Dali ORM), and—last but not least—has had major sup-port from IBM in terms of code, committers, and leadership from LawrenceMandel, Arthur Ryman, David Williams, and others For the full story, I highlyrecommend reading the WTP Is Born section in Chapter 2.
In short, Web Tools has been a wonderful community effort, an effort thathas been rewarded with many shipped products And in the Eclipse community,this is truly the measure of a successful project
The simple fact that so many organizations—many of them fierce tors in the marketplace—cooperate on the development of WTP and ship prod-ucts on top of it is a testament to the WTP project leadership It is also one of thestrongest proof-points that the Eclipse community’s model of “collaborate onthe platform and compete on the product’’ is the correct one for today’s world of
Trang 19competi-highly complex software, faster time-to-market requirements, and shrinkingdevelopment budgets Each of the products listed earlier (WebLogic Workshop,RAD, JBuilder, NetWeaver, and so forth) is highly differentiated, yet they sharethe same Eclipse Web Tools Platform base.
Since the project’s inception, the WTP team has been working toward ing both a strong set of tools for developer productivity and a stable platform ontop of which tool builders can ship products Neither of these are simple goals,and that WTP has been successful on both fronts speaks volumes about the hardwork of the committers on the project Both topics are covered in the book, withPart II focusing on using the tools, and Part III describing how to extend WTPfor additional servers, filetypes, and the like
creat-I hope Eclipse Web Tools Platform: Developing Java Web Applications will
make you a more productive Java developer Please pay special attention to theContributing to WTP section in Chapter 2 Eclipse is all about active communityinvolvement, and we hope to welcome you soon as an active contributor to WTPand other projects at Eclipse As you work with WTP and the capabilitiesdescribed in this book, I’d encourage you to communicate your successes back tothe community, and perhaps consider contributing any interesting extensionsyou may develop The WTP Web site may be found at
http://www.eclipse.org/webtools/
It includes pointers to the WTP newsgroup, where you can communicateand share your results with other WTP developers, and pointers to the Eclipseinstallation of Bugzilla, where you can contribute your extensions
—Mike Milinkovich Executive Director Eclipse Foundation
Trang 20xix
Our goal in writing this book was to help build the community around the EclipseWeb Tools Platform (WTP) Project We decided to write this book soon afterWTP was approved by the Eclipse Foundation At that time, the project was in itsformative stages and there was virtually nothing written about WTP We believedthat a book on how to use and extend WTP would help promote its adoption
We naively hoped that we would have this book finished soon after WTP 0.7was released in July 2005 However, since we were all actively engaged in devel-oping WTP, work on this book got delayed Also, many significant changes in thedesign of WTP were planned, so we felt it was better to have the book describethe next major version, WTP 1.5, which was part of the Eclipse 3.2 Callistosimultaneous release in June 2006
Allowing WTP to mature also gave us more time to develop and refine thematerial in this book Much of the material in this book has been test-driven at sev-eral major software development conferences including EclipseCon, EclipseWorld,Rational Software Development Conference, and Colorado Software Summit.Attendees at those events provided valuable feedback that has improved the con-tent of this book
Since the WTP 1.5 release, there has been increasing adoption of WTP byboth commercial and Open Source tool developers This activity has generated astream of maintenance releases As we went into production, this book accu-rately reflected the content of WTP 1.5.2, but by the time it appears in print, thelatest release should be WTP 1.5.3 However, each maintenance release shouldonly contain bug fixes and not affect the user interface This book should there-fore also be accurate for WTP 1.5.3 and future maintenance releases Andalthough WTP 2.0, which is planned for June 2007, will certainly contain manyenhancements, we expect that most of the content of this book will still be valid
Trang 21About This Book
This book is divided into four parts: Getting Started, Java Web Application
Development, Extending WTP, and Products and Plans.
In Part I, Getting Started, we introduce you to WTP We give a brief overview
of the history and architecture of the project and discuss how you can contribute toits development By being an active contributor as well as a user, you can helpimprove WTP and ensure its long-term success We also introduce you to LeaguePlanet, a fictitious amateur sport Web site, which serves as the inspiration for theprogramming examples in the rest of the book Next we take you on a Quick Tour
of WTP in which you build a simple Web application that includes dynamic contentgenerated by servlets and JSPs running on Tomcat, JDBC database access to Derby,and Web services running on Axis We conclude with a detailed discussion of how
to install WTP and tailor it to your needs using its many preferences At the end ofthis part, you’ll be able to start building your own Java Web applications with WTP.Part II, Java Web Application Development, is for Java Web applicationdevelopers We describe the architecture of Java Web applications and how tobuild them using WTP We start with a discussion of how to set up your project,including the use of Maven for automated builds We then discuss architecture insome detail Java Web applications have a multi-tiered architecture, and each ofthe presentation, business logic, and persistence tiers is addressed in its ownchapter The presentation tier chapter covers tools for HTML, CSS, JavaScript,XML, DTD, and XSLT The business logic tier chapter discusses tools for EJBsand XDoclet The persistence tier chapter describes tools for SQL Next we focus
on developing Web services, including tools for SOAP, WSDL, XSD, and UDDI
We close with a discussion of testing, including JUnit, Cactus, HttpUnit, and theEclipse Test and Performance Tools Platform (TPTP)
In Part III, Extending WTP, we shift attention to developing Eclipse plug-ins thatextend WTP This part of the book is aimed at tool developers WTP contains manyplug-ins and extension points, so the coverage here serves mainly to illustrate theprocess A comprehensive treatment of all the APIs in WTP would itself fill severalbooks We start with the important example of adding a new server runtime toWTP, and illustrate this by adding support for GlassFish, the reference implementa-tion for Java Enterprise Edition 5 (Java EE 5) Next, we show how to add supportfor new file types and do so for DocBook, the XML format used for authoringbooks (such as this one) We follow that by describing how to support new WSDLextensions and add a new SOAP binding as an example We conclude this subject
by extending the URI resolution framework, which enables XML processors tolocate resources
The book wraps up with Part IV, Products and Plans We begin with a briefsurvey of commercial and Open Source Eclipse-based Web development products
Trang 22that can be used with WTP Although WTP contains a core set of useful tools, it isalso a platform intended to be built on by others After you master WTP, you mayfind that your tool needs are not fully satisfied Perhaps you want to develop withStruts, Hibernate, or Spring Or you may want to use a different Web developmentlanguage, such as PHP, Python, or Ruby, in conjunction with Java Fortunately,there are many products available to round out your Web development IDE Weend the book with a preview of functions we expect to be added to WTP in futurereleases WTP is currently hosting subprojects for JavaServer Faces (JSF), JavaPersistence Architecture (Dali), and AJAX (ATF) In addition, WTP is planningtighter integration with other Eclipse projects, as well as support for Java EE 5 Ofcourse, the future of WTP largely depends on you By becoming an active user andcontributor, you will influence the continuing support and evolution of WTP.
Audience
This book is primarily written for Java Web application developers We assumethat you have a working knowledge of Java programming and some experienceusing Eclipse There are many excellent books available that cover both topics.Some experience in Java Web application development is also desirable Wehave made an attempt to introduce the subject of Java Web application devel-opment in addition to describing the tools available in WTP Although thisbook deals with WTP, it will also be of use to users of products built on WTP.And remember, one of the best ways you can contribute to WTP is by report-ing bugs If you hit a bug while using WTP, please report it to the EclipseBugzilla system at
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Web+Tools
This book also includes material for Eclipse plug-in developers who want toextend WTP Experience in plug-in development is assumed Several availablebooks cover the topic of Eclipse plug-in development for those who need somebackground information Although we expect commercial and Open Source proj-ects to extend WTP, we also expect individuals to do so If you develop a coolplug-in that fits within the scope of the WTP charter, please consider contributing
it to WTP To do so, start by sending a note to the WTP developers mailing list at
Trang 23All of the example code used throughout this book can be downloaded fromthere The site will also provide an errata list, and other news related to the book The following Eclipse components are required to run the examples in thisbook:
All of the above are available from
http://www.eclipse.org/webtools/downloads
Conventions
We use a sans serif font for user interface elements such as menu items, buttons,and labels We use a monospace font for programmatic elements such as filenames, source code listings, URLs, package names, and XML content Examples
of these conventions are listed below
Feedback
We’ve set up an e-mail address to receive feedback about this book Please sendyour comments on this book to
<feedback@eclipsewtp.org>
Trang 24We’d like to begin by thanking the people who directly contributed to the ration of this book Our technical reviewers, Simon Archer, John Arthorne,Michael Elder, Jane Fung, Daniel Holt, and Kimberley Peter, gave us highly valu-able, in-depth comments that greatly improved the contents of this book MikeMilinkovich graciously provided us with an inspiring Foreword We receivedauthoritative feedback on the accuracy of the project and product descriptionscontained in Chaper 16, Other Web Tools Based on Eclipse, from Jens Eckels,Matthew Gammie, Axel Kramer, Jochen Krause, Kyle Shank, Greg Stachnick,and Fabio Zadrozny And, of course, Greg Doench and Michelle Housely, ourwonderful editors at Addison-Wesley, were a continuous source of support andencouragement We are grateful to you all
prepa-We would also like to acknowledge our fellow members of the WTP ment project, since their contributions gave us something well worth writing about WTP was created as the result of a three-way collaboration between IBM,ObjectWeb, and the Eclipse Foundation From IBM, we’d like to thank the exec-utive team of Lee Nackman, Hayden Lindsey, and Karen Hunt for approving thecontribution of part of Rational Application Developer V6.0 and supporting itsongoing development in WTP Also at IBM, we’d like to thank Dave Thomson,John Wiegand, and Scott Rich for contributing to the initial formulation of theproject At ObjectWeb, we’d like to thank Christophe Ney for leading the proj-ect creation effort Christophe was instrumental in enabling the contribution ofLomboz from eteration, a member of ObjectWeb At Eclipse, we’d like to thankMike Milinkovich for supporting the creation of WTP, and John Wiegand andBjorn Freeman-Benson for shepherding WTP through the creation process Next, we’d like to thank the WTP leadership team Bjorn Freeman-Benson,Christophe Ney, and Tim Wagner co-led the Project Management Committee(PMC); Dominique de Vito, Jochen Krause, Mitch Sonies, Raghu Srinivasan, and
develop-xxiii
Trang 25David Williams served on the PMC; Chris Brealey, Chuck Bridgham, Der-PingChou, Tim de Boer, Craig Salter, Sheila Sholars, and David Williams led compo-nent teams; and Jeffrey Liu was the lead release engineer
Finally, we would like to thank all of the many committers and contributorswho have made WTP such a memorable experience and huge success For thecomplete list, see
http://www.eclipse.org/webtools/people/
Trang 26About the Authors
Naci Dai, eteration
Naci is a founder of the WTP project, a member of its Project ManagementCommittee (PMC), and the leader of the J2EE Standards Tools (JST) subproject.Naci is the Chief Scientist and Managing Director of eteration, a.s Turkey eter-ation is a member of the ObjectWeb Consortium Naci is an object mentor and
an educator He is the founder of ObjectLearn and one of the initiators of theeteration network He wrote Lomboz, a tool for J2EE development Prior to eter-ation, he was with BEA Systems Inc and The Object People as a managing direc-tor with their professional services organizations He teaches object technology,Web development, and distributed computing His background is in appliedengineering and computational physics He received his Ph.D from CarletonUniversity, Ottawa, Canada
Lawrence Mandel, IBM
Lawrence is a WTP committer and was the leader of documentation and tem development until the release of WTP 1.5.2 Lawrence is a software architectand developer at the IBM Toronto Lab He is currently the Web SubsystemArchitect for a new Enterprise Portfolio Management product under development
ecosys-at IBM Recosys-ational Up until accepting his current position, Lawrence worked onJava Web application development tools including WebSphere Studio ApplicationDeveloper and Rational Application Developer Throughout this time his devel-opment efforts focused on building XML and Web services tools for Eclipse Inaddition, he is leading the Apache Woden project, which is developing a referenceimplementation of WSDL 2.0 Lawrence holds an Hon B.Sc in computer scienceand human biology from the University of Toronto
xxv
Trang 27Arthur Ryman, IBM
Arthur is a founder of WTP, a member of its PMC, and was the leader of the WebStandard Tools (WST) subproject up until the release of WTP 1.5 Arthur is asoftware development manager and architect at the IBM Toronto Lab where hehas worked since 1982 He led the IBM contribution to WTP from the inception
of the project until the release of WTP 1.5 He is currently the Chief Architectfor a new Enterprise Portfolio Management product under development at IBMRational Arthur was previously responsible for Web Service, XML, Java Connectortools, and performance analysis for Rational Application Developer Prior to that,
he worked on WebSphere Studio Application Developer and VisualAge for Java.Arthur is a member of the W3C Web Service Description Working Group and
an editor of the WSDL 2.0 Specification and Test Suite He is a committer on the Apache Woden project, which is developing a reference implementation ofWSDL 2.0 He is a member of the IBM Academy of Technology, an adjunct pro-fessor of computer science at York University in Toronto, and a senior member ofthe IEEE Arthur received his B.Sc in mathematics and physics from YorkUniversity, his M.Sc in mathematics from London University, and his Ph.D inmathematics from Oxford University
Trang 28Getting Started
Our goal in Part I of this book is to get you started using the Eclipse Web ToolsPlatform (WTP) project to develop Java Web applications We begin with anoverview of the structure of the book and then introduce you to the fictitiousLeague Planet Web site, which serves as the inspiration for the programmingexamples used throughout We follow this with some background information
on WTP, including its genesis and architecture Next, we give you a QuickTour of WTP, which touches on most of its main tools After taking the QuickTour, you should be able to start using WTP in your development projects Weconclude this part with a more in-depth discussion of how to download andconfigure WTP
PART I
1
Trang 30CHAPTER 1
IntroductionNobody will ever need more than 640K RAM!
—Bill Gates, 1981
Java Web Application Development and Eclipse
We are living in a Golden Age of software development The Internet has opened
up fantastic new opportunities for applications There is an abundance of erful, inexpensive personal computers and mobile devices that can access theInternet and run these new applications And, to fuel their creation and deploy-ment, the Open Source movement has created an unprecedented array of high-quality, freely available middleware and tools It is truly a great time to be asoftware developer We are limited only by our imagination and our ability tomaster the skills demanded by this rich environment
pow-Java technology and the pow-Java 2 Enterprise Edition (J2EE) have emerged asone of the dominant platforms on which to build Web applications NumerousOpen Source and commercial products support and extend J2EE middleware.And, in the tool arena, Eclipse has emerged as one of the most popular Java inte-grated development environments (IDE) The main focus of this book is the WebTools Platform (WTP), a top-level Eclipse project As the name implies, WTPextends Eclipse into the domain of Web applications WTP includes both a set ofcore tools for Web application developers and a set of platform application pro-gramming interfaces (API) for tool vendors
The purpose of this book is to assist you in your quest to become a highlyproductive Java Web application developer In the following chapters, we’lldescribe all the tools that make up WTP and discuss how they can be extended.We’ll also talk about Java Web application architecture and the pragmatics ofhow to run your development project
3
Trang 31If you’re a typical programmer, you probably want to dive right in and startdeveloping your first Web application with WTP The best way for you to get afeel for WTP is to take the Quick Tour (see Chapter 3) By all means, feel free toskip ahead and take the Quick Tour now You can return here to get more back-ground information later.
What This Book Contains
One of our guiding principles in selecting content for this book was to notreproduce standard reference material that was easily obtained elsewhere Wewanted this book to provide substantial added value above and beyond thatwhich you can derive from reading the WTP online Help or the articles, tutori-als, and presentations that are available on the WTP Web site After all, whywould anyone read a book if it simply duplicated available material? And even
if we wanted to include extensive reference information in this book, it wouldsoon be out-of-date since WTP, like all healthy Open Source projects, undergoesconstant improvement and refinement Programmers really want referenceinformation while they are programming, so the best place for it is in the Helpsystem where it can be retrieved in the correct context with a few keystrokes.There are a couple of immediate consequences of this decision First, thisbook does not contain an exhaustive list of every menu, command, keyboardshortcut, view, editor, perspective, or preference Check the online Help for thatinformation If it isn’t there, open a bug or, better yet, contribute a nice write-upyourself! Second, this book does not contain Javadoc listings for API informa-tion The Javadoc listings are included in the online Help If you find the Javadocunclear, open a bug or, better yet, submit a source code patch The online Helpand source code are the definitive sources of reference information
Having decided not to write a reference book, we instead wrote a book thatpresented WTP in the context of developing actual Web applications As eachelement of Web application development is introduced, we discuss the corre-sponding parts of WTP in enough depth to accomplish some small amount ofreal work In general, we do not discuss any part of WTP in exhaustive detail.You’ll have to consult the online Help or source code for the full story
Another of our guiding principles was to use realistic examples for purposes
of illustration Many programming books adopt the practice of using examples
worth discussing at all, then there must be some realistic situation that motivates
it, so why not use that? The one exception to this rule is the “Hello, world”example in Chapter 3, which follows the long-standing tradition honored inmany programming books We have therefore created a realistic, albeit fictitious,
Trang 32Web site named “League Planet” at the domain leagueplanet.comto serve as thesource of inspiration for our examples We’ll describe League Planet at the end
of this chapter
The programming examples within a chapter are as self-contained as ble We provide the source code files (see “Source Code Examples”) required tostart each chapter so that you can work through the chapters independently and
possi-in the order you desire However, you may need some of the skills developed possi-in earlier chapters, such as how to add a server or create a project, to proceed.Within a chapter, the programming examples are broken down into a sequence
of iterations that build on each other Each iteration consists of a sequence of
steps that result in running code You should work through the iterationssequentially
How This Book Is Organized
This book is divided into the following parts:
Part I, Getting Started, introduces you to WTP Its goal is to quickly give you
an overview of the tools in WTP, both as an IDE for Java Web application opment and as an Eclipse Open Source development project Part I contains thefollowing chapters:
the book and introduces League Planet, the fictitious Web site used as theinspiration for examples throughout the book
history, goals, and economics of the project; its division into the WebStandard Tools (WST) and Java Standard Tools (JST) subprojects; andways in which you can contribute to WTP
by walking you through the creation of a simple “Hello, world” JavaWeb application
install WTP and how to customize your workspace by setting preferences.These tips will help you optimize WTP performance
Trang 33Part II, Java Web Application Development, is really the heart of the book.
It presents the WTP tools from the point of view of developing a Java Webapplication Part II contains the following chapters:
on how to structure a Web application into multiple tiers that implementpresentation, business logic, and persistence It also includes a discussion
of Web services and Service Oriented Architecture (SOA) These designprinciples provide a roadmap for building Web applications
Practices for organizing your code into projects that can be developed in ateam environment, built automatically, and tested automatically CVS,Subversion, Ant, Maven, and CruiseControl are discussed here
inter-face and the Web and J2EE technologies used to implement it Theseinclude HTML, CSS, JavaScript, XML, servlets, JSP, and JSF
appli-cation’s business rules and processes, including guidance on when and how
to use EJBs as well as techniques, such as XDoclet, for developing them
data in your Web application, including how to configure and access bases JDBC and Apache Derby are discussed here
functions via Web services and how to create clients that access them.XSD, WSDL, JAX-RPC, UDDI, WSIL, and Apache Axis are
to release IDEs based on WTP We have already seen WTP appear in severalproducts (see Chapter 16), including the products of some major vendors, such
as IBM and BEA, which have released IDEs based on WTP Although creating anIDE based on WTP is a major undertaking, WTP does provide several extension
Trang 34points that allow some degree of customization by individuals In general, ever, writing extensions boils down to understanding the APIs provided by WTP.The chapters in this part go into some detail for several extension points andAPIs This information should help you get started developing WTP extensions.Part III contains the following chapters:
new Web and J2EE application servers using the Server Tools extensionpoints and API
and validators for new file types using the Validation Framework andEclipse Platform APIs
WSDL editor and validator to support WSDL extensions such as bindingsfor alternate Web service invocation protocols
URI Resolution Framework with new resource resolution strategies.Finally, Part IV, Products and Plans, concludes the book with an overview ofother Eclipse-based products for Web application development Some of thesetools currently extend WTP or plan to do so in the future WTP provides a coreset of tools, and these will be complemented by a wide variety of commercial andOpen Source extensions The time you invest in becoming a skilled WTP userwill give you a solid foundation for using these more advanced IDEs Part IValso gives you a glimpse into the future releases of WTP There are many newspecifications, such as Java EE 5 and WSDL 2.0, on the horizon, and WTP willcontinually strive to keep current In addition, as Eclipse grows as an OpenSource community, new projects, such as the Data Tools Platform (DTP), willaffect the architecture of WTP Part IV contains the following chapters:
Web application development IDEs that are based on Eclipse Many ofthese are currently based on WTP or will be in future releases
planned in upcoming WTP releases
The book includes some useful reference material The glossary defines many
of the acronyms and terms used in this book If you can’t find a definition there,try Wikipedia at
http://www.wikipedia.org
Trang 35The reference section lists useful articles, books, and standards If you can’tfind a particular reference there, try Google at
http://www.google.com
or your favorite search engine
Source Code Examples
Source code examples are the lifeblood of programming books We have takengreat care to ensure that all source code listings actually work In fact, the sourcecode listings are automatically generated from working source code files as part
of the book production process
As you go through the programming iterations in this book, you will beasked to create files and write code at various steps By all means, do this Youshould try your hand at implementing the examples However, before you go on
to the next step, you should import the working example code that is provided
We decided to not include the example code on a CD with the book so thatwe’d have the opportunity to constantly improve it Instead, we created a Website where you can obtain the code and other information related to this book.You can obtain the example code from
http://www.eclipsewtp.org
convenient directory
The examples are organized by chapter, iteration, and Eclipse project For
in the directory
examples/ch03/iteration1/Web1
The directory layout of each example exactly matches that of the correspondingproject, so you can simply import the file For example, to import the example
hello-world.jspfile into the WebContentdirectory of the Web1, do the following:
Select File System from the General category as the source of the import
2 Select the directory
examples/ch03/iteration1/Web1
as the source of the import
Trang 363 Select the file
WebContent/hello-world.jsp
Introducing League Planet
As just mentioned, the examples throughout this book are inspired by the tious, yet realistic League Planet Web site This section will introduce you to it.One approach to creating a successful Web business is to first think of someinteresting content that will attract large numbers of visitors, and then develop abusiness model for deriving profit from it If the content is compelling and thebusiness model is sound, the next step is to design the application and build it.Here we’ll just discuss the content and business model We’ll work on the designand implementation in the following chapters
ficti-The simple idea behind League Planet is to serve the many people who are ested in sports, both as players and as fans League Planet offers the facilities to set
inter-up amateur or recreational sports leagues Anyone can go to the League Planet Website and create a new league where they can record their teams, players, schedules,venues, scores, statistics, and other kinds of information The Web site will be vis-ited by players, their friends, and their family members Since amateur and recre-ational sports are played in every country by people of all ages, there is a potentiallyhuge user community for League Planet
The business model behind League Planet is that use of the site is completelyfree to players and fans Anyone can set up a league at no cost Revenue is gener-ated by leveraging the content in many ways Here are some of the potentialapplications and opportunities for profit
The most obvious way to generate profit is via merchandising Much tion is available about the visitors to the site, for example, what sports they areinterested in, their age group, and where they live This provides us with the infor-mation required to do targeted marketing We can place ads on the site according
informa-to the profile of the visiinforma-tors For example, a page that displays Little League ball scores for a team in New York City might display ads for baseball videogames, tickets to New York Yankee games, and books about famous New YorkYankee players The ads would link to sites such as Amazon or eBay via Web serv-ices, and League Planet would get commissions on sales The site could also hostads that were paid for by sponsors
Trang 37The player and team information on the site can be exploited in many ways.For example, lists of player names and clothing sizes can be sent to uniformmanufacturers or T-shirt companies Teams can benefit from this informationthrough fundraising activities For example, teams can be sponsored by localbusinesses The site can help match up teams and sponsors In return for a spon-sorship fee, the team can place the sponsor’s name and logo on its uniforms andWeb pages Individual player statistics can also be used for fundraising Forexample, personalized baseball cards can be created and sold to raise money forteam activities What child wouldn’t want his or her picture on a baseball card?Proud parents can also purchase the cards and hand them out to friends and rel-atives The site can also provide game program printing services, coordinateteam photos, and help schedule award banquets at the end of the season, withtie-ins to banquet halls and trophy companies.
The site provides opportunities for many novel applications For example,the site can send out e-mail or text messages to subscribers when games getrained out or moved to different venues Parents generally appreciate any servicethat helps them stay on top of their children’s schedules, so they will certainlyappreciate this type of service The site can provide real-time score notifications.Imagine a scorekeeper sending in results via a PDA and the site then relayingthem to parents away on business trips Cell phone companies will undoubtedly
be interested in sponsoring such an application
The site can expand into a service for professional sports clubs In addition
to hosting league information, the site can be used for booking courts, arranginggames, and running tournaments Professional sports clubs would pay a fee forthis type of service
There is also the potential to get seed money to start League Planet fromgovernment grants Fitness is a major concern today, yet the Internet and per-sonal computers have been blamed for creating a generation of inactive, out-of-shape children With League Planet, children should be highly motivated to playsports and achieve their own personal Web presence The site can run pilot pro-grams with schools to host their sports house leagues and probably qualify forpublic funds from government education and health departments
We hope you find this description of League Planet both realistic and ing We’ll develop parts of the League Planet Web site in the following chapters
interest-Summary
The goal of this book is to provide you with information about WTP that plements the online Help, source code, and Web site In particular, this book
Trang 38com-does not reproduce reference information Rather, you are encouraged to refer toand contribute to the online sources of reference information.
All source code examples listed in this book are working code and are vided for your use You can obtain the example code from the Web at
pro-http://www.eclipsewtp.org
This book is organized into four parts Part I provides a quick introduction
to WTP and some background information Part II describes how to use WTPfor Java Web application development Part III describes several ways that WTPcan be extended Part IV concludes with a survey of related products and a sneakpreview of future WTP enhancements
The examples used in this book are based on the development of the tious League Planet Web site that possesses many aspects of real Web sites
Trang 40WTP formally began life in the spring of 2003 as a proposal from IBM toEclipse.org At that time IBM was working on the Eclipse-based WebSphereStudio product family and had already shipped several releases of it IBM proposed to contribute a core set of plug-ins from WebSphere Studio ApplicationDeveloper The thinking behind this proposal was that the time had come to takeEclipse to the next level of support for Java development Eclipse had achieved agood level of maturity and success for J2SE development, but the killer applica-tion for Java is J2EE development However, the J2EE tool space was very frag-mented Although there was a vibrant ecosystem of Eclipse plug-in providers, noother major J2EE application server vendor had adopted Eclipse as its primaryIDE platform.
From a customer perspective, having lots of vendors to choose from can beeither a good or a bad thing It’s a good thing if it means that competition betweenvendors produces better quality at lower prices It’s also a good thing if it meansthat niche vendors can cheaply enter the market and fill gaps However, it’s a badthing if it means that vendors waste resources reinventing the wheel by implement-ing the same base functionality for each IDE platform It’s also a bad thing if cus-tomers can’t integrate tools from different vendors into a complete solution
13