Tải bản đầy đủ (.pdf) (625 trang)

Manning seam in action jun 2008 ISBN 1933988401 pdf

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (11.13 MB, 625 trang )


Seam in Action



Seam in Action
DAN ALLEN

MANNING
Greenwich
(74° w. long.)


To my wife Sarah, without whom this book would not have been possible.
Thanks for giving up everything.
I love you forever.

For online information and ordering of this and other Manning books, please visit
www.manning.com. The publisher offers discounts on this book when ordered in quantity.
For more information, please contact
Special Sales Department
Manning Publications Co.
Sound View Court 3B fax: (609) 877-8256
Greenwich, CT 06830 email:
©2009 by Manning Publications Co. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in
any form or by means electronic, mechanical, photocopying, or otherwise, without prior written
permission of the publisher.

Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in the book, and Manning


Publications was aware of a trademark claim, the designations have been printed in initial caps
or all caps.
Recognizing the importance of preserving what has been written, it is Manning’s policy to have
the books we publish printed on acid-free paper, and we exert our best efforts to that end.
Recognizing also our responsibility to conserve the resources of our planet, Manning books are
printed on paper that is at least 15% recycled and processed without the use of elemental chlorine.

Manning Publications Co.
Sound View Court 3B
Greenwich, CT 06830

Development Editor:
Copyeditor:
Typesetter:
Cover designer:
Proofreader:

ISBN 1933988401
Printed in the United States of America
1 2 3 4 5 6 7 8 9 10 – MAL – 13 12 11 10 09 08

Cynthia Kane
Liz Welch
Gordan Salinovic
Leslie Haimes
Katie Tennant


brief contents
PART 1


PART 2

PART 3

TEEING OFF WITH SEAM .....................................................1
1



Seam unifies Java EE 3

2



Putting seam-gen to work

29

SEAM FUNDAMENTALS ......................................................81
3



The Seam life cycle 83

4




Components and contexts

5



The Seam component descriptor 179

6



Absolute inversion of control

130
219

SEAM’S STATE MANAGEMENT ...........................................271
7



The conversation: Seam’s unit of work 273

8



Understanding Java persistence 325


9



Seam-managed persistence and transactions

10



Rapid Seam development

v

380

352


PART 4

SINKING THE BUSINESS REQUIREMENTS .............................431
11



Securing Seam applications 433

12




Ajax and JavaScript remoting 475

13



File, rich rendering, and email support

511


contents
foreword xvii
preface xix
acknowledgments xxi
about this book xxiv
about the cover illustration xxxiv

PART 1

1

TEEING OFF WITH SEAM ........................................1
Seam unifies Java EE 3
1.1

Which framework should I use?


4

Choosing Seam 5 A complete application stack 5
Why Seam was created 6 Debunking the “vendor lock-in”
myth 7 Making the case for Seam 8






1.2

Seam’s approach to unification 9
Seam integrates JSF, JPA, and POJO components
The contextual component model 11

1.3

Your first swings with Seam

9

14

Entity classes serving as backing beans 14 An
all-in-one component 15 Binding components to the
view 17 Retrieving data on demand 19 Clickable
lists 19 Integration tests designed for JSF 20











vii


viii

CONTENTS

1.4

Seam’s core competencies

22

Turns JSF into a pro 22 Gets you rich quick
an agile environment 26

25




1.5

2

Summary



Fosters

27

Putting seam-gen to work 29
2.1

The Open 18 prototype

30

Consider yourself tasked 30
schema 31

2.2

Mapping entities to the database

Letting seam-gen do the initial work
seam-gen’s specialty

2.3




35



34

Features that seam-gen provides

36

Kick off your project with seam-gen 37
A look at the seam-gen commands 38 A Q&A session with seamgen 40 Creating a basic project structure 43 Generating the
CRUD 44




2.4



Deploying the project to JBoss AS

46

To deploy… 46 …or to explode 48 Switching between
environments 49 Launching JBoss AS 50







2.5

Show and tell, change, and repeat 51
Walking the course 52 Guiding the reverse-engineering
process 58 Exploring the structure of the generated project




2.6

Rapidly developing a seam-gen project
Incremental hot deployment
by using an IDE 70

2.7

PART 2

3

Summary

65




61

65

Accelerating development

79

SEAM FUNDAMENTALS ..........................................81
The Seam life cycle
3.1

83

Exploring how Seam participates in a request 84
Flipping Seam’s switch 85 The JSF servlet, the workhorse of
Seam 85 Serving collateral resources via the Seam resource
servlet 91 Seam’s chain of servlet filters 92 The Seam
phase listener 95






3.2




The JSF life cycle sans Seam

96

The JSF life-cycle phases 97 The initial request 98 The
postback 100 Shortcomings of the JSF life cycle 101







ix

CONTENTS

3.3

Seam’s page-oriented life-cycle additives 103
Advanced orchestration with pages.xml 104 Intelligent
navigation 105 Seam UI command components 109
parameters 110 Page actions: execute me first! 114







Page



3.4

Combining page actions with navigation

116

Sanity checking a request 117 Built-in page
actions 118 Search engine–friendly URLs 120




3.5

The JSF life cycle with Seam

122

Phase listeners versus servlet filters 122
augmented life cycle 122

3.6




Stepping through the

A try-catch block around the life cycle

126

Failing gracefully or with intentional crudeness 126 Registering
an exception handler 126 Handling the exception at the
source 127




3.7

4

Summary

129

Components and contexts 130
4.1

Seam’s contextual naming container

131

Seam’s context model 131 Unifying the Java servlet
contexts 132 Seam’s new stateful contexts 133 Seam’s

enhanced servlet contexts 134




4.2



Sorting out components

135

Components vs. component instances
components 137

4.3



Defining components using annotations
Giving a component a @Name 139
in @Scope 140

4.4

135




Seam manages

138

Putting a component

A comprehensive component example

141

Creating the entity components 141 Preparing an action
bean component 145 Integration testing
components 146 Hooking components into JSF 148






4.5

A component’s life

150

Loading component definitions 151 When to
@Install a component 152 Giving a component multiple
@Roles 155 Instantiating components at
@Startup 156 Component life-cycle callbacks 157
Wiring components together 159 Where all components go

to die 161











x

CONTENTS

4.6

Using EJB 3 session beans in Seam

161

Whose component is it, anyway? 162 The making of a Seam
session bean component 162 The mechanics of the
interaction 164




4.7


Accessing components 168
Access modes

4.8

5

Summary

169



Access strategies

177

The Seam component descriptor
5.1

170

179

Defining components using XML 180
Choosing your descriptor strategy 181 The structure of the
component descriptor 182 Fine-grained component
descriptors 184





5.2

XML namespaces in the component descriptor

185

The purpose of XML namespace declarations 185 Defining an
XML @Namespace for components in a package 189 How XML
namespaces are interpreted 190 Importing a context variable
prefix 193






5.3

Configuring component properties

195

Component definitions as object prototypes 195 Where
component properties are defined 196 Property value
types 202 Wiring components together 209







5.4

Component definitions vs. component configuration
Avoiding conflicts with an existing definition 212
configuration between annotations and XML 213

5.5

6

212

Dividing the

Configuring and enabling built-in components 214
Using the component descriptor to control Seam 214
Seam’s internationalization support 215

5.6



Summary




Configuring

218

Absolute inversion of control 219
6.1

Bijection: dependency injection evolved 220
Introducing bijection 220 Bijection on the golf
course 222 Activating bijection 222




6.2

Dynamic dependency @In-jection 224
Declaring an injection point 224 The injection process 226
Mixing scopes and serializability 228 Injection variants 229





xi

CONTENTS

6.3


@Out-jecting context variables

231

The outjection process 232 Outjection use cases 233
Built-in @DataModel support 235


6.4

Bypassing bijection

244

Internal method calls 244 The mystical method context 245
Reentrant method calls 246 Disabling bijection by disabling
interceptors 248




6.5

Component events

249

Raising an event from a component 250
Defining an event @Observer 252 Raising events
on page transitions 253 Built-in events 254





6.6

Custom method interceptors
Two sides to the interceptor coin
interceptor 257

6.7

PART 3

7

Defining a Seam



Factory and manager components
A context variable @Factory

6.8

255
255

Summary


259

259

Components that @Unwrap 266



270

SEAM’S STATE MANAGEMENT ...............................271
The conversation: Seam’s unit of work
7.1

Learning to appreciate conversational state
Redefining the unit of work

7.2

273

275



275

The conversation context 278
Carving a workspace out of the HTTP session 278
might store in a conversation 281


7.3

274

The burden of managing state

Establishing conversation boundaries



What you

281

A conversation’s state 282 Beginning a long-running
conversation 286 Keeping the conversation going 292
Enlisting objects in a conversation 294 Ending a long-running
conversation 298






7.4

Putting the conversation aside 300
Abandoning a conversation


7.5

300



Switching between conversations

Creating nested conversations

305

The conversation as a workspace 305 Giving conversations a
description 307 Using the built-in conversation switchers 308




301


xii

CONTENTS

7.6

Driving the conversation with a page flow

314


Setting up a page flow 315 Learning your way around a page
flow 315 Advancing the page flow 318 Addressing the back
button 320




7.7



Ad hoc conversations
Open for business

7.8

8

Summary

321

321


Show me what you’ve got 322

323


Understanding Java persistence 325
8.1

Java persistence principles
Establishing expectations
persistence 327

8.2

326

326

Entities and relationships



The four pillars of Java

328

Mapping metadata 329 Transitive persistence 329
annotations to the persistence layer 330


8.3

The persistence unit




Bringing

331

Defining a JCA data source 332 The persistence unit
descriptor 332 The persistence manager factory 334




8.4

The persistence manager

335

Obtaining a persistence manager 335 The management
functions of a persistence manager 336 Persistence context
scoping 337




8.5

Transactions

338


Sorting out the transaction APIs 338
work 339 ACID abridged 340



Atomic units of



8.6

Managing persistence in the enterprise
Introducing the extended persistence context
an extended persistence context 342

8.7

Choosing between JPA and Hibernate

341
341



The benefits of

348

How Hibernate relates to JPA 348 What sets Hibernate and JPA
apart 349 Seam’s hybrid approach 350





8.8

9

Summary

351

Seam-managed persistence and transactions 352
9.1

Getting persistence context management right 353
Respecting the persistence manager
persistence context 354

353



Managing an extended


xiii

CONTENTS


9.2

Enhancing the capabilities of the persistence manager
Seam’s standard enhancements
through 359

9.3

357

356

Letting Hibernate shine



Setting up a persistence unit in Seam

361

Seam’s persistence manager factories 361 Seam-managed persistence
contexts 364 Sharing the persistence manager factory through
JNDI 366 Validating the persistence context at startup 368






9.4


Seam’s transaction support

369

Global transactions 370 Seam’s transaction abstraction
layer 371 Controlling Seam-managed
transactions 373 Application transactions 376






9.5

10

Summary

379

Rapid Seam development 380
10.1

A framework within a framework

381

Wrapping the persistence API 382 The persistence

controllers 383 Two ways to play 385




10.2

Stateful CRUD using the Home component

386

Remedying the Anemic Domain Model 386 Giving the domain
object a Home 387 Putting Home to work 391 Venturing
away from home 403 CRUD a la XML 408








10.3

Providing feedback

410

Customizing the status messages 410 Creating i18n-compliant
messages 412 Transaction success events 413





10.4

Smarter queries with the Query component

413

Creating a result set listing 414 Paging the result
set 417 Deleting multiple records at once 420 Putting the
results in order 420 Placing restrictions on the result set 422








10.5

PART 4

11

Summary

429


SINKING THE BUSINESS REQUIREMENTS .................431
Securing Seam applications 433
11.1

Authentication jump-start

434

Giving the user an identity 434 Implementing
authentication in three steps 436 A glimpse at Seam’s identity
management 443 Even more “Basic” authentication 444







xiv

CONTENTS

11.2

Securing pages

446

The challenge with JSF security 447 Requiring

authentication 448 Serving pages securely 453




11.3

Role-based authorization
Expressing restrictions

11.4

456

455


Declaring role-based restrictions

Rule-based authorization using Drools

458

462

Rules vs. roles 462 Setting up Drools 462 Creating rules
with Drools 464 Automatic context detection 469







11.5

Separating the computers from the humans 472
An overview of CAPTCHA
to forms 472

11.6

12

Summary

472



Adding a CAPTCHA challenge

473

Ajax and JavaScript remoting 475
12.1

Using Ajax with JSF

476


Embracing a server-centric application model 476 Ajax4jsf and
ICEfaces open a communication channel to JSF 477 Seam’s role
in Ajax-based JSF requests 482




12.2

Partial form submits

484

Live validation 484 Business-savvy validations 486
Working alongside the user to fill out a form 487


12.3
12.4

Ajax Push with ICEfaces 489
JavaScript remoting to Seam 491
Transparent Ajax 491 Giving the browser access to Seam
components 493 Making calls to a server-side
component 496 Local stubs 500







12.5

Conversational remoting calls

503

Joining the conversation in progress 504 Striking up a
conversation 504 Storing up requests for a shipment 506




12.6

Responding to GWT remoting calls

506

A quick introduction to GWT integration 507 Preparing the remoting
service 507 Making a GWT service call through Seam remoting 508




12.7

13

Summary


509

File, rich rendering, and email support 511
13.1

Uploading files and rendering dynamic images 512
Accepting file uploads

512



Rendering images from raw data

515


xv

CONTENTS

13.2

PDF generation with iText

517

Laying out a PDF with UI components 517 Working with tables
and cells 521 Adding a splash of color 524 Graceful failures

and friendly file extensions 525 Serving dynamic documents 526








13.3

Quick and easy charting with JFreeChart 528
Chart basics 528
charts 532

13.4



Bar charts 529

Composing email the Seam way



Line charts 530



Pie


533

Sending your first message 533 Adding an entourage to the
message 536 Setting up JavaMail in Seam 540 Publishing
newsfeeds 543




13.5

Customizing the UI with resource bundles
Getting Seam to speak the right language 544

13.6
appendix A



Summary

549

Seam starter set 551
resources 562
index 565




544
Themes 548



foreword
The most challenging part of being a developer on the Seam project isn’t writing the
code—it’s trying to explain Seam to new users. There’s a large gap that a Seam neophyte must cross to really “get” what Seam is about. The problem isn’t that Seam is
overly complex, or that it requires an esoteric skill set. Seam puts together a number
of ideas that are unfamiliar to mainstream Java developers. Many of those ideas challenge the common wisdom of enterprise Java development.
To start with, Seam fills a gap not many Java developers realize exists. We are so
accustomed to working with a half dozen disintegrated technologies that a truly integrated application framework seems foreign to us. This disintegration is most painfully clear at the persistence layer. Where ineffective caching and lazy instantiation
issues plague most applications, Seam actually gets it right. When you consider that
the creators of Seam were the brains behind Hibernate, that’s not hard to believe!
Then you’ve got Seam’s dynamic bidirection injection (bijection), which is radically different from the static injection offered by the popular dependency injection
frameworks. And we haven’t even mentioned the clever stateful components in a
world where the prevailing technologies force all applications into a multilayered
stateless architecture regardless of whether that architecture suits the application
being developed.
We’re just scratching the surface, and already we can see that Seam offers a vision
that’s so different from the status quo that guiding a new Seam user becomes a huge
challenge. As a result, few introductions to Seam go beyond the basics, presenting the
ABCs of the technology without showing how to put the letters together to make words
and sentences. Seam in Action is the first Seam book to capture the spirit of Seam and

xvii


xviii


FOREW ORD

show you how to put those words and sentences together the way we on the Seam
team intended the technology to be used.
What impresses me most about the book you’re holding in your hands is that it
doesn’t blindly toe the Seam party line. Dan Allen has painstakingly broken Seam
down to its core concepts and reassembled them in a way that is fresh and unique.
Seam in Action isn’t a simple-minded regurgitation of the Seam reference documentation. Instead, it’s a perfect companion to it, showing how to understand Seam and
best apply it to your own applications.
Seam can help you code better, more functional applications. It can help you work
faster, and it can help you code your applications with a simpler, easier-to-manage
architecture. But you’ll only reap those benefits if you take the time to learn how to
best apply the technology. Seam in Action is the perfect guide to get you to the point
where you can apply Seam to its full potential.
If you’re up to the challenge, then, to shamelessly borrow the analogy of the book,
I invite you to step up to the first tee—and take a swing.
NORMAN RICHARDS

Senior Engineer, Red Hat


preface
We can’t solve problems by using the same kind of thinking we used when we created them.
—Albert Einstein
As I write this passage, I’m flying over the Atlantic Ocean on my way back from Europe
to the United States for the second time in a month. This trip was to Tuscany for a meeting to discuss Seam’s future; the previous trip had been to Zurich, where I spoke about
Seam at the Jazoon ’08 conference. The first trip was especially significant to me because
it marked the first time in the 30 years of my life that I’ve traveled outside of North America. I was beginning to think that day would never come, but it did, thanks to Seam. (And
because my brother purchased the ticket to get me there. Thanks, Kevin!)
You might think I’m ridiculous for attributing this milestone to Seam. After all, how

can a framework motivate a person to embark on an unprecedented trip? Before you
call me crazy, let me explain how I got involved in Seam and how it influenced me to
expand my horizons.
Around the time Seam was being developed, I was spending my days banging my
head on a project built using Spring and JSF. For more than a year, I felt stuck in a rut
trying to manage the application’s state, wrestling with irrelevant decisions such as
whether to name a business object a Manager or a Service, and rationalizing how many
layers to use and which layer should take ownership of a given task. All of these distractions held back the project and my growth. I kept looking for some way out.
The spark that attracted me to Seam is the fine-grained control it provides over JSF
requests through its page descriptor. The reason I stuck with Seam (and ultimately
decided to write about it) goes well beyond the voids it filled for me at the time.

xix


xx

PREFACE

Seam has clout because it follows a consistent approach without imposing arbitrary restrictions. It leverages annotations, interceptors, XHTML-based templates, and
JSF components to give you the most bang for your keystroke. It provides access to
objects when and where you need them and manages them so you don’t have to. It
also helps establish continuity from one page request to the next. Above all, it gives
you freedom to organize the application as it suits you and to choose the tools you
want to use to build it: Java or Groovy, XML or annotations, JavaScript or rich widgets, built-in or custom components, and so on.
But we have a tendency to get caught up in the word framework and forget the real
reason we’re writing software: to serve the needs of our users or our clients’ users.
That’s the angle you have to take going into learning one of these tools.
Users don’t want to spend their days paging through endless result sets and could
care less if you’re having a problem with lazy initialization exceptions in the view. They

want mature software. They want advanced searches, reports in PDF or Excel, charts,
emails, file uploads, dynamic graphics, wizards, workspaces, and so on. Basically, they
want the stuff that’s really hard to develop, or at least harder than feeding the database
through a CRUD generation tool. Seam gives you the CRUD generation tool, which gets
you developing immediately, and it also provides the extra stuff.
Seam is worth knowing because it touches on nearly every aspect of Java EE. Sure,
you have a lot to learn, but Seam makes every facet of the platform remarkably accessible and gets you working on the advanced parts of your application early in the project. You no longer have to dread those wild and crazy requirements that the user
dreams up. Instead, you feel empowered to write applications—and you’ll get to the
feature wish lists.
As an integration framework, Seam keeps a vast number of technologies close at
hand and accessible. As a result, you find yourself trying out technologies you never
thought you’d use, and you witness your application and skill set maturing quickly. You
also start introducing new styles of interaction into your application, such as the eventobserver model or something as revolutionary as Ajax Push. You get used to venturing
into new territory, without having to abandon the familiar, and it affects your general
attitude toward life.
That brings me back to my original statement. Seam is the driver that finally
launched me out of North America. It also kick-started my writing and consulting
career, got me involved in a successful open source project, and allowed me to meet
interesting and talented people. How will Seam change your career? How will it change
your life?
Somewhere over the Atlantic, July 2008


acknowledgments
While writing this book, I made many promises to myself and others about what I’d
do when I finished. The most important of those promises was to acknowledge everyone who made this book possible. Of course, I’m grateful to have you as a reader. But
you should appreciate those people who got this book out on the shelves and into
your hands.
The first and last person I want to thank is my wife, Sarah. If it weren’t for her help,
you wouldn’t be holding this book. I have no idea where to even begin thanking her.

She pushed me to believe in myself, kept me motivated when the end kept moving
further away, tolerated being inundated with Seam and my relentless questioning
about how to structure the book, edited drafts, assembled the index, provided therapy, made sure I ate, and took care of countless chores I let slip. What meant the most
is that she put my project before her own, something I look forward to doing for her
now. Please help me in thanking her.
Writing a book puts a tremendous strain on relationships. I would like to thank all
my friends and family for supporting me in this endeavor and having faith that I would
eventually come out of my hole and once again answer phone calls, hang out, and talk
about something other than writing a book. I am forever indebted to my parents, James
and Mary Allen, for extending me every opportunity in my life to be successful. You
only get one childhood and they made it both a rewarding and a memorable one. Mom
and Dad, thanks for passing on to me your relentless perseverance and strong desire to
learn and for always being there to support me in my endeavors.
Rewinding to the origin of this book, I want to thank Andrew Glover for introducing me to Jennifer Aloi from IBM developerWorks, who in turn launched my technical
xxi


xxii

ACKNOW LEDGM ENTS

writing career by sponsoring the Seamless JSF series. Much of the credit for that series’
success goes to Athen O’Shea for doing a superb job of editing and helping me find
the right words. Little did I know that I would soon be buried deep in turning those
ideas into a book.
I want to thank Marjan Bace and Michael Stephens for taking a chance on me and
trusting that I would finish as I blew past one deadline after the next. Something tells
me they had the real schedule hidden in a drawer and had already anticipated the 15
months that would elapse over the course of this project. I’m also grateful to Andy Kapit
and Andrew Van Etten of CodeRyte, Inc., for endorsing this book in its early stages.

Moving along chronologically, I’d like to acknowledge Cynthia Kane for helping
me see the big picture and for reminding me that I had a book to write when I started
to daydream. I was fortunate to have an ambitious and talented set of reviewers who
donated their time and insight to help make this the best Seam resource available:
Peter Johnson, Doug Warren, Peter Pavlovich, Devon Hillard, Nikolaos Kaintantzis,
Hung Tang, Michael Smolyak, Benjamin Muschko, Kevin Galligan, Judy Guglielmin,
Valentin Crettaz, Carol McDonald, Ara Abrahamian, Horaci Macias, Norman Richards, Ted Goddard, Costantino Cerbo, Mark Eagle, Carlo Bottiglieri, and Jord Sonneveld. Thanks to Karen Tegtmeyer for seeking out the reviewers, conducting the
reviews, and scaring the volunteers into actually sending back their comments. Special
thanks to Benjamin Muschko, Pete Pavlovich, and Ray Van Eperen for thoroughly
reading the book and giving me line-by-line edits and advice; thanks to Michael
Youngstrom for reviewing chapter 15; thanks to Ted Goddard and Judy Guglielmin for
their help with chapter 12 and the development of the source code for the ICEfaces
example; and thanks to Valerie Griffin and Daniel Hinojosa for providing last-minute
corrections and feedback. I also want to thank all my loyal MEAP readers and forum
participants, especially those who were there from the very beginning, patiently waiting for this book to materialize into print.
The heroes of this project are the production team, under the leadership of Mary
Piergies, who coaxed me out of rewriting hell and worked in overdrive to get this book
into print. The person who took on the biggest burden in this transition was Liz
Welch, my copy editor. I want to extend enormous thanks to Liz for weeding out all
the inconsistencies in the book and tolerating my pursuit of perfection. I also want to
thank Norman Richards, my technical editor, for challenging me to get all my facts
about Seam straight and steering me away from giving readers impractical advice. I’d
like to recognize the tremendous work done by the remaining members of the production and postproduction team: Katie Tennant for proofreading the manuscript,
squashing all of those “writing bugs”; Dottie Marsico and Gordan Salinovic for morphing the chapters from office document format into the professional layout that you
see in front of you in record time; Leslie Haimes for making the book look eye-catching on the shelves and enticing readers, like yourself, to dive into it; Tiffany Taylor for
maintaining the document templates; Gabriel Dobrescu for handling the book’s web
presence on manning.com; and Steven Hong for continued support in publicizing
the book and preparing marketing materials.



ACKNOW LEDGM ENTS

xxiii

Join me in thanking Gavin King for sharing his vision of Seam and its contextual
component model with the world as an open source project and to all the Seam developers that matured his vision into the robust integration framework that it is today.
I would like to thank Panera Bread in Laurel, MD, for serving as my retreat/second
office when my house was trying to stifle my writing. I am grateful for the bottomless
tea and free wireless internet. I wish more companies were as progressive as yours.
I’m happy to say that each and every person mentioned in this passage, and sadly
those I overlooked, helped me complete the most ambitious goal of my life. Thanks
again to my wife for standing by me during this project.


about this book
If you’re ready to become an expert on Seam, I can guarantee you that this book will
get you there. I don’t use terms that confuse you just to make myself feel smart. I don’t
say “trust me on this; it will all work out.” I don’t distract you with an outline of the
next chapter when you’re trying to focus on the current material. And especially, I
don’t sprinkle @In and @Out annotations over a class and expect that you’ll know what
they will do. Nope. I lay down the facts. I show you the steps. I reveal the logic. I diagram the flow. What I like most about programming is that each thing happens for a
reason. The exciting challenge is learning what that reason is and then turning
around and discovering how to make practical use of it. Some areas of Seam are hard
to get, I’ll admit. But trust that with guidance, you will get it. Never settle for less than
the facts, and don’t give up!
Not only do I teach you how Seam works, I also teach you the how and the why so
you can go off and teach Seam to others. I’ve traveled into each and every corner of
Seam, and I want to share with you what I’ve experienced to motivate you to travel
there yourself. I want to give you what Seam gave me: the ability to reach my true
potential as a developer. This is the best resource to help you understand Seam without gaps.


Roadmap
The goal of this book is to get you started with Seam quickly. It’s divided into four
parts. The first part does a flyover of Seam and gets you ready to learn about it. The
second part focuses in on the core concepts until you can see the blades of grass. The
third part studies Seam’s state-management solution and Java persistence support.

xxiv


×