xxvi ABOUT THIS BOOK Roadmap This book is divided into five parts. Part 1 provides an overview of EJB.Chapter 1 introduces EJB3 and EJB types and makes the case for EJB 3.Chapter 2 explores core concepts such as metadata annotations,dependency injection,and provides code examples ofeach EJB type. Part 2 covers the building of business logic with session beans and MDB Chapter 3 dives into the details of session beans and outlines best practices. Chapter 4 gives a quick introduction to messaging,JMS,and covers MDB in detail.Chapter 5 covers advanced topics such as dependency injection,intercep- tors,and timers.Chapter 6 discusses transaction and security. Part 3 provides in-depth coverage of the EJB 3 Java Persistence API.Chapter 7 introduces concepts on domain modeling and describes implementing domain models with JPA.Chapter 8 covers object-relational mapping with JPA.Chapter 9 provides in-depth coverage manipulating entities using EntityManager API. Chapter 10 covers querying entities using Query API and JPQL. Part 4 provides guidelines for effectively using EJB3 in your enterprise appli- cations.Chapter 11 discusses packaging of EJBs and entities.It introduces all XML descriptors.Chapter 12 covers using EJB 3 design patterns and JPA from other application tiers.Chapter 13 turns toadvanced topics such as entity lock- ing and performance tuning of EJB 3 applications. Part 5 looks at interoperability and integration issues with EJB 3 and other frameworks.Chapter 14 covers interoperability with EJB 2 and migra- tion of EJB 2 applications to EJB 3.Chapter 15 introduces web services and discusses web services applications with EJB 3 and JAX WS 2.0.Chapter 16 uncovers how you can integrate EJB 3 with the Spring framework to build great enterprise applications. The book has five appendixes.Appendix A is a tutorial on JNDI and RMI and appendix B provides a primer to databases.Appendixes C and D cover refer- ences to annotations and XML descriptors.We also provide instructions on how to install and configure Java EE RI(Glassfish)and how to deploy the code sam- ples in appendix E. Source Code Downloads In addition to the setup instructions for the Java EE 5 Reference Implementa tion server based on Glassfish and the Oracle Application Server,the publisher's website houses all of the source code presented in this book.The source code for
xxvi ABOUT THIS BOOK Roadmap This book is divided into five parts. Part 1 provides an overview of EJB. Chapter 1 introduces EJB 3 and EJB types and makes the case for EJB 3. Chapter 2 explores core concepts such as metadata annotations, dependency injection, and provides code examples of each EJB type. Part 2 covers the building of business logic with session beans and MDB. Chapter 3 dives into the details of session beans and outlines best practices. Chapter 4 gives a quick introduction to messaging, JMS, and covers MDB in detail. Chapter 5 covers advanced topics such as dependency injection, interceptors, and timers. Chapter 6 discusses transaction and security. Part 3 provides in-depth coverage of the EJB 3 Java Persistence API. Chapter 7 introduces concepts on domain modeling and describes implementing domain models with JPA. Chapter 8 covers object-relational mapping with JPA. Chapter 9 provides in-depth coverage manipulating entities using EntityManager API. Chapter 10 covers querying entities using Query API and JPQL. Part 4 provides guidelines for effectively using EJB 3 in your enterprise applications. Chapter 11 discusses packaging of EJBs and entities. It introduces all XML descriptors. Chapter 12 covers using EJB 3 design patterns and JPA from other application tiers. Chapter 13 turns to advanced topics such as entity locking and performance tuning of EJB 3 applications. Part 5 looks at interoperability and integration issues with EJB 3 and other frameworks. Chapter 14 covers interoperability with EJB 2 and migration of EJB 2 applications to EJB 3. Chapter 15 introduces web services and discusses web services applications with EJB 3 and JAX WS 2.0. Chapter 16 uncovers how you can integrate EJB 3 with the Spring framework to build great enterprise applications. The book has five appendixes. Appendix A is a tutorial on JNDI and RMI and appendix B provides a primer to databases. Appendixes C and D cover references to annotations and XML descriptors. We also provide instructions on how to install and configure Java EE RI (Glassfish) and how to deploy the code samples in appendix E. Source Code Downloads In addition to the setup instructions for the Java EE 5 Reference Implementation server based on Glassfish and the Oracle Application Server, the publisher’s website houses all of the source code presented in this book. The source code for
ABOUT THIS BOOK xxvii each chapter is downloadable as a separate zip file,each one containing instruc- tions on how to deploy the code to an application server and get it running.You can download the code from the book's web page:www.manning.com/panda or www.manning.com/EJB3inAction.com. Source Code Conventions Because of the example-driven style of this book,the source code was given a great deal of attention.Larger sections of code in the chapters are presented as their own listings.All code is formatted using the fixed-width courier font for visibility.All inside code,such as XML element names,method names,Java type names,package names,variable names,and so on are also formatted using the Courier font.Some code is formatted as courier Bold to highlight important sec- tions.In some cases,we've abbreviated the code to keep it short and simple.In all cases,the full version of the abbreviated code is contained in the download- able zip files.We encourage you to set up your development environment for each chapter before you begin reading it.The setup instructions for the develop- ment environment are also included on the website. Author Online Purchase of E/B 3 in Action includes free access to a private web forum run by Man- ning Publications where you can make comments about the book,ask technical questions,and receive help from the authors and from other users.To access the forum and subscribe to it,point your web browser to www.manning.com/panda. This page provides information on how to get on the forum once you are regis- tered,what kind of help is available,and the rules of conduct on the forum. Manning's commitment to our readers is to provide a venue where a mean- ingful dialog between individual readers and between readers and the author can take place.It is not a commitment to any specific amount of participation on the part of the authors,whose contribution to the AO remains voluntary (and unpaid).We suggest you try asking the authors some challenging questions,lest their interest stray The Author Online forum and the archives of previous discussions will be accessible from the publisher's website as long as the book is in print
ABOUT THIS BOOK xxvii each chapter is downloadable as a separate zip file, each one containing instructions on how to deploy the code to an application server and get it running. You can download the code from the book’s web page: www.manning.com/panda or www.manning.com/EJB3inAction.com. Source Code Conventions Because of the example-driven style of this book, the source code was given a great deal of attention. Larger sections of code in the chapters are presented as their own listings. All code is formatted using the fixed-width Courier font for visibility. All inside code, such as XML element names, method names, Java type names, package names, variable names, and so on are also formatted using the Courier font. Some code is formatted as Courier Bold to highlight important sections. In some cases, we’ve abbreviated the code to keep it short and simple. In all cases, the full version of the abbreviated code is contained in the downloadable zip files. We encourage you to set up your development environment for each chapter before you begin reading it. The setup instructions for the development environment are also included on the website. Author Online Purchase of EJB 3 in Action includes free access to a private web forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the authors and from other users. To access the forum and subscribe to it, point your web browser to www.manning.com/panda. This page provides information on how to get on the forum once you are registered, what kind of help is available, and the rules of conduct on the forum. Manning’s commitment to our readers is to provide a venue where a meaningful dialog between individual readers and between readers and the author can take place. It is not a commitment to any specific amount of participation on the part of the authors, whose contribution to the AO remains voluntary (and unpaid). We suggest you try asking the authors some challenging questions, lest their interest stray! The Author Online forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print
xxviii ABOUT THIS BOOK About the Authors DEBU PANDA is a Lead Product Manager of the Oracle Application Server devel- opment team where he drives development of the Java EE container.He has more than 15 years of experience in the rr industry and has published numerous articles on enterprise Java technologies in several magazines and has presented at many conferences.His J2EE-focused weblog can be found at debupanda.com REZA RAHMAN is an architect at Tripod Technologies.Reza has been working with Java EE since its inception in the mid-nineties.He has developed enterprise systems in the publishing,financial,telecommunications,and manufacturing industries and has worked with Enterprise Java Beans,Spring,and Hibernate. DEREK LANE is the CTO for Semantra,Inc.He has over 20 years'experience in the IT arena.He is the founder of both the Dallas/Fort Worth,Texas MicroJava User Group and the Oklahoma City Java User Groups,and is active in numerous technology groups in the southwestern United States. About the Title By combining introductions,overviews,and how-to examples,the In Action books are designed to help learning and remembering.According to research in cogni- tive science,the things people remember are things they discover during self motivated exploration. Although no one at Manning is a cognitive scientist,we are convinced that for learning to become permanent it must pass through stages of exploration,play and,interestingly,re-telling of what is being learned.People understand and remember new things,which is to say they master them,only after actively exploring them.Humans learn in action.An essential part of an In Action guide is that it is example-driven.It encourages the reader to try things out,to play with new code,and explore new ideas. There is another,more mundane,reason for the title of this book:our readers are busy.They use books to do a job or solve a problem.They need books that allow them to jump in and jump out easily and learn just what they want just when they want it.They need books that aid them in action.The books in this series are designed for such readers
xxviii ABOUT THIS BOOK About the Authors DEBU PANDA is a Lead Product Manager of the Oracle Application Server development team where he drives development of the Java EE container. He has more than 15 years of experience in the IT industry and has published numerous articles on enterprise Java technologies in several magazines and has presented at many conferences. His J2EE-focused weblog can be found at debupanda.com. REZA RAHMAN is an architect at Tripod Technologies. Reza has been working with Java EE since its inception in the mid-nineties. He has developed enterprise systems in the publishing, financial, telecommunications, and manufacturing industries and has worked with Enterprise Java Beans, Spring, and Hibernate. DEREK LANE is the CTO for Semantra, Inc. He has over 20 years’ experience in the IT arena. He is the founder of both the Dallas/Fort Worth, Texas MicroJava User Group and the Oklahoma City Java User Groups, and is active in numerous technology groups in the southwestern United States. About the Title By combining introductions, overviews, and how-to examples, the In Action books are designed to help learning and remembering. According to research in cognitive science, the things people remember are things they discover during selfmotivated exploration. Although no one at Manning is a cognitive scientist, we are convinced that for learning to become permanent it must pass through stages of exploration, play, and, interestingly, re-telling of what is being learned. People understand and remember new things, which is to say they master them, only after actively exploring them. Humans learn in action. An essential part of an In Action guide is that it is example-driven. It encourages the reader to try things out, to play with new code, and explore new ideas. There is another, more mundane, reason for the title of this book: our readers are busy. They use books to do a job or solve a problem. They need books that allow them to jump in and jump out easily and learn just what they want just when they want it. They need books that aid them in action. The books in this series are designed for such readers
ABOUT THIS BOOK xxix About the Cover Illustration The figure on the cover of E/B3 in Action is a"Russian Girl with Fur,"taken from a French travel book,Encyclopedie des Voyages by J.G.St.Saveur,published in 1796. Travel for pleasure was a relatively new phenomenon at the time and travel guides such as this one were popular,introducing both the tourist as well as the armchair traveler to the inhabitants of other regions of France and abroad. The diversity of the drawings in the Encyclopedie des Voyages speaks vividly of the uniqueness and individuality of the world's towns and provinces just 200 years ago.This was a time when the dress codes of two regions separated by a few dozen miles identified people uniquely as belonging to one or the other.The travel guide brings to life a sense of isolation and distance of that period and of every other historic period except our own hyperkinetic present. Dress codes have changed since then and the diversity by region,so rich at the time,has faded away.It is now often hard to tell the inhabitant of one conti- nent from another.Perhaps,trying to view it optimistically,we have traded a cul- tural and visual diversity for a more varied personal life.Or a more varied and interesting intellectual and technical life. We at Manning celebrate the inventiveness,the initiative,and the fun of the computer business with book covers based on the rich diversity of regional life two centuries ago brought back to life by the pictures from this travel guide
ABOUT THIS BOOK xxix About the Cover Illustration The figure on the cover of EJB 3 in Action is a “Russian Girl with Fur,” taken from a French travel book, Encyclopedie des Voyages by J. G. St. Saveur, published in 1796. Travel for pleasure was a relatively new phenomenon at the time and travel guides such as this one were popular, introducing both the tourist as well as the armchair traveler to the inhabitants of other regions of France and abroad. The diversity of the drawings in the Encyclopedie des Voyages speaks vividly of the uniqueness and individuality of the world’s towns and provinces just 200 years ago. This was a time when the dress codes of two regions separated by a few dozen miles identified people uniquely as belonging to one or the other. The travel guide brings to life a sense of isolation and distance of that period and of every other historic period except our own hyperkinetic present. Dress codes have changed since then and the diversity by region, so rich at the time, has faded away. It is now often hard to tell the inhabitant of one continent from another. Perhaps, trying to view it optimistically, we have traded a cultural and visual diversity for a more varied personal life. Or a more varied and interesting intellectual and technical life. We at Manning celebrate the inventiveness, the initiative, and the fun of the computer business with book covers based on the rich diversity of regional life two centuries ago brought back to life by the pictures from this travel guide
Part 1 Overview of the EB landscape his book is about EJB 3,the shiny new version of the Enterprise Java- Beans standard.The timely rebirth of EJB is made possible through innova- tions introduced in Java SE 5,such as metadata annotations as well as the adoption of ideas like dependency injection and object-relational mapping (ORM)-based persistence. Chapter 1 introduces EJB as a technology.The chapter also touches on the unique strengths EJB has as a development platform and the great new fea- tures that promote productivity and ease of use.Chapter 2 provides realistic code samples and presents the ActionBazaar application,the imaginary enterprise system developed throughout the book.Chapter 2 is easily the most code-intensive chapter in the book.Our goal is to give you a feel for how EJB 3 looks as quickly and as easily as possible. This part presents EJB 3 as a powerful and highly usable platform worth its place as the de facto standard for mission-critical enterprise development. We also offer a first glimpse into the impressive Java Persistence APL,a prom- ising technology that aims to standardize Java ORM and expand EJB 3 beyond the traditional boundaries of web-based client-server applications managed by containers
Part 1 Overview of the EJB landscape This book is about EJB 3, the shiny new version of the Enterprise JavaBeans standard. The timely rebirth of EJB is made possible through innovations introduced in Java SE 5, such as metadata annotations as well as the adoption of ideas like dependency injection and object-relational mapping (ORM)-based persistence. Chapter 1 introduces EJB as a technology. The chapter also touches on the unique strengths EJB has as a development platform and the great new features that promote productivity and ease of use. Chapter 2 provides realistic code samples and presents the ActionBazaar application, the imaginary enterprise system developed throughout the book. Chapter 2 is easily the most code-intensive chapter in the book. Our goal is to give you a feel for how EJB 3 looks as quickly and as easily as possible. This part presents EJB 3 as a powerful and highly usable platform worth its place as the de facto standard for mission-critical enterprise development. We also offer a first glimpse into the impressive Java Persistence API, a promising technology that aims to standardize Java ORM and expand EJB 3 beyond the traditional boundaries of web-based client-server applications managed by containers