Monday, December 26, 2011
Book Review for "Java EE 6 with GlassFish Application Server"
I work with Enterprise Java a lot. I'm a support engineer working in the SOA workspace. This means I get regular exposure to web services, JMS, and other parts of the JEE stack. But here's the thing-- I almost always work with the same parts. For every part I usually work with (JMS, SOAP web services), there's at least one other part I don't work much with (JSF, RESTful web services, web-tier stuff.) So what's happened is I have become well versed in parts of the JEE stack, but have failed to keep up with the rest.
I chased the Enterprise Java rabbit all the way down the hole back in the J2EE 4 days. Quite a bit of what I learned then-- early EJBs, enterprise patterns, and so on-- is now thankfully useless. I knew there were lots of programming productivity-enhancers put in since JEE 6, but I just didn't want to take the time to read the internet again to once again become whole-stack proficient. So I picked up a copy of "Java EE 6 with GlassFish 3 Application Server" by David Heffelfinger.
I'd read David's work before, so I was expecting an easy to read book that contained plenty of minimal examples I could run and experiment with. I wasn't disappointed, this was exactly what I found.
The book divides the JEE stack into slices and explains each in turn. Each chapter contains several Maven-driven examples that can be easily compiled and quickly deployed. In this regard, the book does exceptionally well.
The first chapter is really basic-- downloading the tools you need, and a quick overview of GlassFish.
The second chapter covers Servlets. There are several basic examples that show web tier basics like extracting HTML form parameters, saving data in scope, and forwarding requests. There are also newer features like web-xml fragment processing, asynchronous processing (good for AJAX), filters and annotations instead of configuration. This chapter reminds me of an old book I learned a lot from, "Core Servlets and JavaServer Pages". Did you use that one? This chapter has the same ease of reading and practical applicability.
Chapter 3 was again a lot of basic web-tier stuff. JSP fragment includes, Custom Tag Libraries, Unified Expression Language, XML syntax and JSP syntax are covered. Reading this taught me a few new things, validated some of what I remembered.
Chapter 4 was about JSP's Standard Tag Library, including core features (i.e. iterator, looping, etc.), formatting (I18N with bundles), SQL, using XML JSTL (instead of JSP), and JSTL functions like split(), length(), toUpperCase(), etc.
Chapter 5 was the JPA chapter. I've done a little JPA work, so I'm not totally stuck in the Entity Bean era, but it was nice to have this chapter to outline modern Java persistence. In particular, the explanations of entity cardinality and the way to use annotations on your entity classes was well done.
Chapter 6 covered JSF, which was something I needed. I remembered the old Servlets and JSP way of doing things, but I haven't been in the web tier a lot since JSF came around. This chapter Explained tags, validation (including custom validation) and error messages. The explanations were easy to follow and very well done. I was especially happy to read the section on combining JPA and JSF, as it shows how sensible defaults connect the JSF page to a controller bean. Hurray, JEE can do a lot of wiring for you, using sensible defaults! (Once you understand what they are, it's easy to see how a few lines of code can accomplish a lot. But if you don't know what the conventions are, you'd have a hard time guessing what can be done for you by JEE!)
Chapter 7 was a JMS chapter. I work here a lot, so there weren't a lot of surprises for me. For those that don't work with JMS a lot, it'll be good.
Chapter 8 was about JEE security. As usual, well explained. (There seemed to be quite a bit of Glassfish specific stuff here, I wish that could have been reduced.)
Chapter 9 was the EJB chapter. Stateful, Stateless, MDBs, Singletons, Timers. Transactions (and how to have more than one transaction with UserTransaction). Easily understandable, modern EJBs make business logic fun.
Chapter 10 covered Contexts and Dependency Injection. Modern JEE servers are moving into the space traditionally inhabited by Spring, and this chapter explains how to use DI in a JEE container.
Chapter 11 covers Jax-WS web services. I spend plenty of time in this workspace, so I found most of it familiar. You can certainly find aspects of JEE that are not covered in this book (Jax-WS leaves quite a few nooks and crannies to explore), but this chapter covers the basics well.
Chapter 12 was about Jax-RS (REST web services). This is another chapter that illuminated an area I had experimented with in the past, enjoying mixed success. The 'convention over configuration' aspects are explained, which makes example Jax-RS snippets much easier to understand. This is one of the chapters I'm sure I'll refer to in the future.
There are also a couple of appendices, one on email in JEE and one on IDE usage.
The book's about a year old, but JEE 6 is still the current spec and will be on the upswing for quite a while. The book is very much relevant.
So, what's the final verdict? It's a doozy: This book will have a spot on my nearest bookshelf, because it is an excellent and easy to read reference for the whole JEE stack. What makes this remarkable is that I don't even use GlassFish! Ok, for this book I downloaded a copy and kept it right next to JBoss AS 7, my preferred JEE 6 container. It's a tribute to the JEE spec writers that I was able to run the majority of the sample applications with virtually no changes for the app server-- just compile via Maven, then plop the deployable artifact onto whichever server you want. (By the way, if you haven't used one of these new JEE servers yet, you're in for a small, fast surprise! Please try JBoss AS 7, you'll see what I mean.)
For coders like me-- those who don't spend a lot of time across the whole JEE stack-- I'd recommend this book as a quick way to be comfortable wherever you find yourself in the JEE stack.
The book can be found here.
Happy Productively Programming!