Get Free Tech Books!
Join the DZone Review Team to share your opinion and expertise through published book reviews and Refcardz review discussions. You'll get free tech books and early access to Refcardz.
|This book is a terrific introduction to JBoss Seam, an impressive framework that is sweeping much of the competition before it. Part of Seam is even being formalized as JSR 299 (Web Beans). One can only give the book 5 stars for thoroughness, which is no easy feat with a framework that stretches tentacles into nearly every imaginable area of writing enterprise applications. If there is a downside, it is quite possibly the very thoroughness that one can also praise. The text has a tremendous amount to cover; even in nearly 600 pages (this doesn't include the free online chapters!), much has the feel of being crammed in. The writing is extremely dense, communicating as tersely as possible. This is very good in a reference work, but the whole is nearly unreadable straight through. This reviewer had to stop every few pages, just to digest. Web frameworks seem to sort themselves out into two camps these days: those that focus on HTTP and HTML, which often use JSP as a view technology; and more component- and event-oriented frameworks that seem to orient themselves around JSF and, even more recently, Facelets (the use of which Seam and the author strongly advise). I will admit my bias toward the first, but there are a number of Seam innovations that I certainly want to see introduced into my favorite frameworks.|
Part 1. Teeing off with Seam
Chapter 1. Seam unifies Java EE
The major concept behind Seam is to serve as an adjunct to Java EE. JSF, a relatively recent entrant to the specification, has not been uniformly a brilliant success; EJB has been a bitter pill for a long time; and other alternatives are rapidly gaining ground, such as Ruby on Rails. The Java EE specification has taken some important steps forward recently, including EJB 3.0, for instance; but we haven't yet reached the nirvana wherein JSF components cavort playfully on green fields with EJB components under the watchful gaze of JTA shepherds. Seam integrates and extends the out-of-box Java EE functionality with its own, in which the Seam context and EL play a major role. And best of all, Seam is not limited to JBoss alone!
Chapter 2. Putting seam-gen to work
One of the pluses of using Seam is how easy it is to set up your initial project structure. Seam-gen, the code generation engine of Seam, can reverse-engineer a database schema and generate a surprisingly functional web application automatically. This is both good and bad, of course: what we don't do ourselves we often don't clearly understand when it has outlived its usefulness. But it is a rush to see your data appear as though by magic on a screen. And seam-gen can be easily used from both NetBeans and Eclipse.
Part 2. Seam fundamentals
Chapter 3. The Seam life cycle
Seam steps in to support the developer concerned with the weaknesses of JSF, which are typically cases that depart from the simple HTTP request-and-response paradigm: redirects, navigation that depends upon context, and so forth. Seam handles these as close to effortlessly as could be managed, in part by participating in and adding to the JSF component life cycle. Whether it's intelligent navigation with an awareness of context, talking to EJBs, maintaining state across redirects, or one of the other deficiencies of JSF, Seam is typically there with an answer.
Chapter 4. Components and context
Context is all in Seam. The Seam context maintains variable values, injecting dependencies and retrieving values back to the context, looking up EJBs, maintaining persistence contexts (which all but eliminates those nasty LazyInitializationException messages), and so much more. The Seam context is where components are defined, initialized, and managed.
Chapter 5. The Seam component descriptor
Annotations are heavily used in Seam to avoid the use of XML descriptors where possible. But there are some things for which annotations (and possibly even Java code) are not the best solution, and Seam provides a great deal of functionality by way of configuration. This does require descent into the depths of XML, especially as Seam includes a number of built-in XML namespaces that help configure useful functionality from integration of email and user authentication to UI themes and persistence. Resource bundle management is another important feature of Seam descriptors.
Chapter 6. Absolute inversion of control
IoC and dependency injection (DI) is central to a number of important frameworks of late. Seam extends the idea of DI to include not only injection of values from the Seam context into an object when it is used (not only when it is created) but also out-jection of values from the object back into the Seam context once the operation has been performed (the combination is called bijection). This process is managed by method injectors that can, if needed, be disabled. Seam also allows the developer to raise events from components and pass those events to interested observers.
Part 3. Seam's state management
Chapter 7. The conversation: Seam's unit of work
One of the important additions of Seam to the management of user state is the concept of conversation. This is a scope, like the more familiar request and session scopes, but more long-lasting than the former and less so than the latter. Many use cases require interaction with a user over a series of pages; the conversation scope is perfect for holding state within such interactions. The user can even hold multiple conversations within different browser tabs or windows and Seam manages the lot! The developer also gets the benefit (over handling this with session variables) that Seam automatically cleans up after itself. Delineating conversation scope can be managed in the usual variety of ways.
Chapter 8. Understanding Java persistence
Seam supports both Hibernate, a mature object-relational management solution, and JPA, a rather newer but more standard one. Owing to Hibernate's relationship to JBoss, support for it is not too surprising; Hibernate also doubles as a JPA provider, so again support for it is unsurprising. Seam adds a special feature to the EntityManager in the latter, enabling it to remain open and available throughout the request to avoid issues with lazily initialized properties. In addition, because entities don't have to be detached, issues raised by merging can be completely avoided.
Chapter 9. Seam-managed persistence and transactions
The extended EntityManager does raise issues, however. Who opens it? Who closes it? What are the bounds of transactionality? All of these are issues Seam helps the developer to artfully handle. Transactionality is one area where Seam adds considerably to the defaults of Java EE, enabling separate transactions covering business logic and rendering-driven event handling. This avoids the all-too-frequently-encountered case where rendering errors might unexpectedly roll back successful business transactions. Seam also helps manage proper isolation and flushing of the persistence context.
Chapter 10. Rapid Seam development
Seam defines a subset of its classes (referred to in the text as a "framework within a framework") under the name Seam Application Framework. These classes taken together are the secret to Seam's being able to easily handle simple database applications. Learning to configure and use these is the subject of this chapter. Among the classes discussed are a number of extremely useful ones, including a Query component that is context-aware and can paginate effortlessly.
Part 4. Sinking the business requirements
Chapter 11. Securing Seam applications
You didn't really think that Seam was going to go this far and leave you high and dry as to user authentication and authorization, did you? Where JAAS stops and well before Acegi Security (now Spring Security) drops you into XML-land, Seam steps in. With the identity management module introduced in Seam 2.1, you can even manage most of the problem using annotations and configuration. Authorization in Seam is typically managed using roles assigned to users (even using Drools, the JBoss rules engine!) but roles can be adjusted if need be in specific use cases to allow users to do what they might not be able to otherwise.
Chapter 13. File, rich rendering, and email support
Chapter 14. Managing the business process (online)
Chapter 15. Spring integration (online)
Appendix A. Seam starter setThis appendix helps you get started with Seam by detailing the tools you will need to begin working. Setting up the JDK, an application server, even Seam itself is covered. And Seam can even be used with Maven 2 or Ivy!
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)