Tuesday 27 December 2011

Book Review: OSGi in Depth

OSGi in Depth Cover
A few weeks ago I got my hands on OSGi in Depth from Manning. The book is well written and I would give it a 4 out of 5. The book is not targeted for beginners but rather to developers who know the basics of OSGi and are now planning to develop an enterprise application using OSGi. I found the introduction to OSGi slightly lacking in my opinion, however the rest of the book discusses topics which are very interesting and which I had a hard time to find details elsewhere.

The first 4 chapters introduce OSGi and the case study. The interesting parts start from chapter 6 onwards. Chapter 6 introduces events and how they can be used to decouple your modules. I found chapter 7 very useful since it discusses how to do persistence in an OSGi environment. This chapters discusses how to make available database connection factories without needing to import the specific packages and how to do JPA. I will be using this knowledge pretty soon in a project I am working on so I am quite happy to have found this topic discussed in detail here together with the accompanying lab.

Transactions are discussed in the following chapter, chapter 8. What I found interesting was not the discussion about transactions but rather how you can create a container to delegate the transactional related calls to the container instead of having it scattered in your business logic. The method introduced here will be polished as we go through the book, but what I found interesting was that the author showed that any behaviour that you want shared across bundles can be packaged nicely in extensions that can be applied to the bundles through facilities that OSGi provides. I found this refreshing and made me look at OSGi application development in a different way.

Chapter 9 discussed how OSGi can be made to work with JavaEE through JNDI. This was quite an interesting topic but not much to me personally. The same I can say about chapter 10, well written but I typically would use some other mechanism to invoke remote services, but, never the less it was interesting to see how one would invoke remote services using OSGi. The following chapter grabbed my interest again. Material about the best ways to deploy OSGi applications is slightly limiting. The discussion about how to handle misbehaving bundles was quite interesting, but something that I will be probably using is the File Install which the author introduced here. The file install gives you the possibility to manage you application bundles in the same way as you would manage your web applications through an install directory. For more information you can read about the Apache Felix File Install here.

The JMX discussion in chapter 12 was interesting but not as good as chapter 13 where the author extends Blueprint. This was a very interesting chapter cause it shows a very good way of packaging code that cross cuts multiple bundles and how to have it declaratively applied to the business logic in these bundles. The discussion about blueprint is limited, in fact the author directs you to the book OSGi in Action for a more complete discussion of blueprint. However I believe that the author fills in a gap since he explains how blueprint works underneath the hood and shows how you can do a similar extension, but finally this extension is integrated nicely with blueprint, including a custom XML namespace. In short, reading the entire book was worth it for the final chapter!

To wrap things up, this is quite a good book for anybody who wants to implement enterprise OSGi applications. If you are a beginner and would like to learn OSGi for its own right, I would go with some other book, however, from this book, I would say that the chapters about persistence, transactions, deployment and blueprint are very useful. I also liked the way that the author focused on showing how to create application containers which run on OSGi in which you can run your own custom applications. I guess that is why the author called the book, OSGi in depth.

No comments:

Post a Comment