Book review: RESTful Java Web Services
Z Jacek Laskowski - Wiki Projektanta Java EE
RESTful Java Web Services by Jose Sandoval (Packt, November 2009)
No match for its title and below my expectations - half the book would make it better
Let me begin by acknowledging that although I've been playing with Java Web Services for a while I would hardly claimed myself fluent in the concepts of Web Services. I do lack extensive hands-on experience with Web Services in Java, and yet somehow, I passed Sun Certified Developer for Java Web Services (SCDJWS) 5. I've recently been asked to run the course SW502 Intermediate Web Services Using IBM Rational Application Developer V6 (its Polish code's XML48PL). That was when I truly touched the Java Web Services code accompanied with very old theory - mostly about JAX-RPC. It was as much devastating to my understanding of the latest Java Web Services developments (esp. JAX-WS that was not covered at all) as helpful since I finally found some spare cycles to fully delve into WS-I Basic Profile, syntax and semantics of SOAP protocol, WSDL and partially UDDI. It let me experience beloved Aha moment when gained real understanding of the differences between the Document vs RCP style binding as well as literal vs encoded use. It was very refreshing experience.
Shortly after it, I decided to read a book about Web Services in Java hoping to gain more current knowledge about the state of Java Web Services in Java EE 5 and the latest 6 editions. Contrary to the proverb "Don't judge a book by its cover", the cover of the book RESTful Java Web Services by Jose Sandoval seemed to have met my expectations. The title had all the words I was chasing understanding of (plus REST), and with its 234 pages seemed quite easy to digest. Entertained myself with the reading. Note, however, I completely lost the real meaning of the title and "RESTful Java Web Services" became "Java Web Services". I don't think it influenced my opinion about the book very much, though.
Long story short, I got a little disappointed. The book was too much concerned to cover "the most popular Java RESTful frameworks to date (Restlet, JAX-RS based frameworks Jersey and RESTEasy, and Struts 2)" (quoted from the book's website) and insisted on repeating the entire code snippets even though (quoting from the page 174 of the book) "all the details of the code have also been explained in Chapter 5. Nevertheless, we list all the code for the sake of completeness". It made its way to a few chapters meaning I read the book with all the patience needed throughout the chapters 1-5 (it took me a couple of days and was quite pleasant) and then suddenly found myself in the chapter 9 as the reading turned into flicking through the pages for the chapters 6-8. I enjoy reading technical books mostly for their introduction or guidance to the topic at hand and appreciate their comments woven into sections that can greatly influence their final outcome. Keeping the faith of finding something precious in a book while flicking pages is not an easy task as was the case for many parts of the book - it's more tough to pay attention to details knowing you may have read parts before and thus eventually may have lost attention altogether.
The book consists of 10 chapters and almost 240 pages. Quite a lot of complete, a few page-long code listings that was a waste of the book's space in this case. The author explained all the gory details of each class, with such care that you should be familiar with the Java language (quoted from the book's website) was buried in the book's requirements and was not assumed at all (not until the chapter 8).
Nonetheless, I must admit that the book provided some very useful information too. The first 2 chapters with REST principles (the chapter 1. "RESTful Architectures") and the use of Jakarta Commons HTTP Client library (the chapter 2. "Accessing RESTful Services - Part 1") took me minutes to read. They were very clear and comprehensible to introduce me to the world of RESTful Web Services and what it is to create a client to consume them.
The Chapter 3. "Accessing RESTful Services - Part 2" begun very promising with its use of Prototype JavaScript library (it's on my TODO list) to fall short after a mere 4 pages when the listings made their way and eventually polluted the content with unnecessary pieces. It turned out a complete waste of my time.
The following, 4rd chapter "RESTful Web Services Design" was way better and I could know about the difference between a web service and a web application, and about the URI Template specification. The book seemed to have gotten better.
The chapter 5. "Jersey: JAX-RS" was exactly as I wished the entire book should've been - JAX-RS and its reference implementation Jersey covered. A broad smile showed up on my face when db4o came on the scene "to make the implementation easier" (page 91). In a moment the earlier deficiencies vanished into thin air. I could hardly hide my happiness. It is by no means certain that the book paved the way for db4o in my projects. If only the chapter had showed the important bits without repeating itself, it would've been the best chapter of the book.
The following 2 chapters about Restlet I read with mixed feelings. I think it could be because I was not content with the coverage of JAX-RS and Jersey, and I was getting tired of reading code listings that differed in very small bits about frameworks I would barely find use. The chapter 6 "The Restlet Framework" should rather be 5- not 40-page long. Just read the first 5-10 pages and be done with it. The next chapter 7 about RESTEasy was the fastest chapter I've ever read in my entire life. It took me about 5 minutes without skipping any word. I wished the author had explained a bit more about RESTEasy, which "adds more functionality to fully integrate with JBoss technology stack" (page 179), but unfortunately it was "beyond the scope of the book" (page 179).
The chapter 8. "Struts 2 and the REST Plugin" didn't delve into very low-level details. I couldn't figure out how Struts 2 knows about the REST plugin in the configuration file, a little bit about the action's getModel() method as well as how the variable representation was resolved in a jsp file. It was like the chapter meant to attract greater attention to the action code than it was in the earlier chapters of the book where each and every detail (even trivial ones) were explained.
I liked the chapter 9 "Restlet Clients and Servers" where I could appreciate simplicity of Restlet and its server/client API. With the comments about embedding Restlet in a desktop application (page 215) or setting it up so different ports handle a subset of available REST actions (page 217) were very helpful. It looks the book covered Restlet in 2 chapters that's 60 pages in total placing it as THE framework of this book. I wished JAX-RS with Jersey had received such extensive coverage instead.
The last chapter 10 "Security and Performance" brought some information about the OAuth authentication protocol I'd never heard before and how to handle Basic Authentication with Jakarta Commons HTTP Client library. Unfortunately, the chapter suffered from a few small yet important mistake having stated "All the XML tags are Tomcat specific" (page 226) while explaining web deployment descriptor (web.xml) and its security-constraint stanza. As the author said in the beginning of the chapter "we take the point of view of the architect and not of the creator of the infrastructures supporting our applications" (page 219) so you can safely disregard this chapter unless you have to. Nonetheless, it helped me to realize I need a book about infrastructure with Cloud Computing (on-demand infrastructure) covered.
The very last sentence of the book says it all about how to gain the real understanding of the RESTful Java Web Services: "The only thing left is for you to put down the book, but come back for reference as needed, begin developing your own RESTful services, and make the Web a better place.". I couldn't say it better. It's so often that I look for books with a complete coverage and definitive answers not sorting out problems myself. Thanks Jose!
