Book review: OSGi and Equinox: Creating Highly Modular Java Systems

Z Jacek Laskowski - Wiki Projektanta Java EE

Grafika:bookcover-OSGiandEquinoxCreatingHighlyModularJavaSystems.png OSGi and Equinox: Creating Highly Modular Java Systems by Jeff McAffer, Paul VanderLei, Simon Archer (Addison-Wesley Professional, February 2010)

Inspiring and informatory yet often too Eclipse-centric

Before judging "OSGi and Equinox: Creating Highly Modular Java Systems" from the point of my review I should point out that, contrary to the book's authors' suggestions, I did not follow it along while live coding. The book was vital to my OSGi understanding, but for the authors doing is often more important than the reading alone (of which I'm a strong proponent, too). I've already set myself out for the other reading of the book focusing on live development with Eclipse and I'm deeply sure my opinion will surely change.

This is the book that introduced me to OSGi in a more practical approach where understanding sample code of the Toast application is as important as the reading itself. I enjoyed its reading, but it was a bit annoying when many pages referred to the development aspects of OSGi focusing on code while I was merely reading along with no Eclipse in front of me. It was the most frustrating in the part 2 of the book which assumed Eclipse IDE ready and live coding as reading. I read with no coding, but it doesn't take long to find out it was not the authors' intentions.

The chapter "About This Book" eloquently describes what the book covers. Just read the chapter and jump to appropriate chapters or sections of choice. There's the natural, writing order of explaining the OSGi inner workings, but a more seasoned OSGi developer can use the book as a reference for the different parts of OSGi ecosystem without losing much while skipping different sections. I found the book heavily focused on the development side of OSGi with Eclipse PDE.

What it does not do is that in the book the term "OSGi" means, Eclipse Equinox and Eclipse PDE so a reader is quite often exposed to Eclipse-specific extensions that help as well as go far from what the OSGi specifications propose. That's the main differentiator between this and the other books about OSGi - "OSGi and Equinox: Creating Highly Modular Java Systems" is heavily focused on the Eclipse ecosystem. The goal of the book is mostly achieved and people who enjoy reading books as a guide throughout the stages of application development will find it deeply engaging. Developing and delivering a OSGi-based Toast application is explained in enough details to explain the Eclipse and OSGi concepts.

Many aside notes make reading more pleasant so in addition to technical information a reader gets acquainted with the reasoning underlying OSGi. There are also many figures and screenshots that further help understanding the covered material. They're clear and to the point.

The book's split on four parts.

The 1st part introduces to OSGi and Equinox in a more academic approach where you learn about the history of OSGi, its concepts, and what issues people meant to tackle as they designed it. The book goes as far as calling a single section "The Java Lie", which is short yet sets the tone for the rest of the book in which you will find a lot of useful tips how to strengthen modularity of your applications, but present them as "Missing Impossible" without OSGi. It takes mere 25 pages so it's clear the authors didn't mean to explain OSGi in theory, but in practice.

That's when the real fun begins - Part 2 enters the scene. It presents "a tutorial-style guide to building Toast" (page xxvi). The Toast application is a real GUI system leveraging OSGi and many features of Eclipse tooling, with Eclipse Equinox as the OSGi platform of choice and Eclipse IDE as an integrated development environment with Eclipse PDE being its main player. The 220 pages will make anyone content. Every stage of OSGi application development is laid out and explained "in an informal tutorial style" (page 29). The goal of the chapter (and of the entire book) is to "develop a fully functional OSGi-based application, Toast" and the authors took every step to achieve the goal. They finally donated the application to Eclipse to facilitate further development in a collaborative matter. Quickly and without much ado a reader is asked to fire up Eclipse and install the Samples Manager which is a way to manage all chapters of the book with their sample code. Importing a ready to use sample for a chapter, comparing your own code with the expected one is a matter of using "Compare with Workspace" feature of the Samples Manager. The authors did much to ensure a smooth entry point to every chapter.

That's where the chapter falls short at delivering its value to readers who merely read it without digesting its content during live coding. People who are only interested in learning OSGi by reading may find it quite troublesome. It's certainly not easy to read with no coding in this part of the book.

The 3rd part is where you learn about the advanced topics of OSGi with OSGi Declarative Services, the Extension Registry of Eclipse Equinox, OSGi Log Service, OSGi HTTP Service with a simple HTTP service of Equinox and the more sophisticated Eclipse Jetty, OSGi Remote Services (RFC 119). Explanation assumes that the code is heavily developed or at least consulted.

The last, 4th part, called "Reference" goes into the details of the Extender Pattern, StartLevel Service, turning JARs into useable OSGi bundles with Eclipse PDE (with a mere half a page about bnd with no sample!), Eclipse Console and the way it can be extended, and few other topics.

Reading the book will let you learn the basics of OSGi, but it also devotes the chapters to the Service Tracker, Service Activator Toolkit (SAT) and OSGi Dynamic Services (the chapter 6) examining the advantages and disadvantages of every approach. In part 3, you learn about OSGi Declarative Services and PDE tooling to support it.

There's a lot about how to use Eclipse PDE to fully leverage its power for developing OSGi-based applications. No other IDEs are ever mentioned.

The book introduced me to the vast array of possible solutions when OSGi is utilized I had not heard before or had not understood their goals - Eclipse Communication Framework (ECF), Eclipse p2, the provisioning system of Eclipse Equinox and the other tools from the Eclipse community. I'm really glad I read the book and would recommend it to anyone who wishes to learn OSGi as much as Eclipse offering supporting it.

Osobiste