I've been a zone leader with DZone since 2008, and I'm crazy about community. Every day I get to work with the best that JavaScript, HTML5, Android and iOS has to offer, creating apps that truly make at difference, as principal front-end architect at Avego. James is a DZone Zone Leader and has posted 639 posts at DZone. You can read more from them at their website. View Full User Profile

OSGi and Equinox: Creating Highly Modular Java Systems

  • submit to reddit
Published by: Addison-Wesley
ISBN: 0321585712

Reviewer Ratings




Buy it now

One Minute Bottom Line

Knowing OSGi is essential for a real understanding of how Eclipse and Equinox work. As such, Eclipse plug-in developers will find this book indispensible. The book applies to the wider community too, and gives a real-world, practical insight into OSGi and how it works.

Overall, this book is essential to any developer who wants to create an OSGi based, modular system. The combined experience of all the authors really shows, and makes the seemingly daunting world of OSGi accessible to everyone. If you are to buy only one book related to OSGi or Eclipse development, this should be the one.


The first part of the book goes through an introduction to OSGi and Equinox, starting of with an introduction into OSGi and how the approach to modularisation in Eclipse aligned perfectly with what was going on in OSGi. The benefits of modularity are presented, along with a discussion on how OSGi benefits Java. The OSGi Concepts chapter gives the reader an introduction into the core OSGi concepts, most importantly, giving a solid definition of what an OSGi bundle consists of, and how it works. 

With the introductions out of the way, the second part of the book brings the user through OSGi by Example. Using the Toast(Telematics on a Stick) example, you'll see how to use Eclipse for OSGi development, and get a full tutorial into creating your own OSGi bundles. The Toast example is made up of a client and a backend, integrating with a simulated GPS and airbag, as well as Google Earth integration. 

The tutorial starts by getting you started with an Eclipse workspace to do write the application, showing how to split up your application into three seperate bundles, to give you a better idea of the power of modular application development. From there, the user is introduced to services and communicating between bundles, with a fosus on the OSGi service registry. OSGi bundles and services have a defined lifecycle, and this is explained very well in the Dynamic Services chapter, which includes some information on Declarative Services for those who wish to avoid using Service Trackers to maintain the state of the OSGi bundles in their application. 

The tutorial will have brought you to a stage where you have a standalone OSGi application working, but the example is pushed further by getting the client to interact with an OSGi-based control center over HTTP. The chapter on testing really highlights the benefits of modularity. It also helps to point out the simplicity in the OSGi approach - having used POJOs, dependency injection and clearly defined APIs. The packaging chapter shows how to distribute your application outside of the workspace with the complete build/publish lifecycle covered. 

Pluggable services shows even more modularity advantages - all the services that you have used so far (GPS and Airbag) are simulated services.  This chapter shows how split out the service implementation from the service interface. Most importantly, you will see that application development can be done in parallel, allowing developers to focus on implementation given a clear service interface. SWT is used in chapter 11 to provide an extendable, pluggable user interface. 

p2 is introduced as a means to deploy your application. This is a valuable chapter for anyone using the Eclipse platform, as it gives a good introduction and explanation behind p2 provisioning. 

The third part of the book is a series of "Deep Dives", taking a closer look at some of the most fundmental parts of the OSGi specification, and how they can be used in Equinox.  Declarative Services and the Extension Registry are explained. This is very useful to the Eclipse developer as it highlights the difference between both the service and extension approaches. Logging and HTTP Support are both given full chapter explanations, before we get on to Server Side OSGi. This is really interesting, as it shows how to embed your OSGi bundles into web applications, and also covers Remote Services. This is a huge benefit to OSGi, as the same source code can run on the desktop as well as on your application server.  The Release Engineering chapter brings the reader through a detailed approach to automated builds of OSGi applications using PDE build. 

Finally, part four of the book consists of a reference section covering best practices, the Equinox console and a Declarative Services Reference. 

Overall, this book is essential to any developer who wants to create an OSGi based, modular system. The combined experience of all the authors really shows, and makes the seemingly daunting world of OSGi accessible to everyone.