About this Book – OSGi in Depth

About this Book

In this book, I show how the OSGi technology can be used to write better software, and in particular, how OSGi can be used to write better platforms for the development of better software.

Most importantly, I focus on real problems and on how OSGi can be used to solve them. Instead of just explaining OSGi’s API for modularization, I first show you the problems that arise due to the lack of modularization. Instead of simply giving you OSGi’s transaction API, I show you why and when you need to use transactions, and what the implications are of using transactions in a modularized service-oriented fashion in OSGi. As you read this book, you’ll acquire in-depth knowledge of OSGi, and learn how to create containers that can manage transactions and persistence for applications!

Several years ago, it was inconceivable for a developer to write their own enterprise-grade development container or platform. OSGi has drastically changed this; it allows you to create your own domain-specific platform. OSGi is to domain-specific platforms what yacc is to domain-specific languages (DSLs).

Finally, in this book, I tackle some basic problems, but I don’t shy away from the complex ones. You’ll learn OSGi in depth. You won’t just be looking at OSGi’s API, but rather at the reason why the API is what it is, how you can best use it, and when not to use it. You’ll even learn about open OSGi issues and what can be expected to change.

OSGi is an extraordinary technology. More than that, it’s a game changer in the way large software is developed. To fully understand the reason for this, you need to understand OSGi in depth.

Who should read this book?

First and foremost, this book is aimed at developers, especially Java developers, who are interested in learning how to write better maintainable and extensible software.

The book will be of particular interest to enterprise-level developers and architects who are learning better ways of putting their software together, reusing components from different vendors, and extending the usable life of their systems, while decreasing their costs. Enterprise developers and architects will learn how to seamlessly leverage enterprise services, such as persistence, transactions, and remote communication from different vendors.

Finally, the book is aimed at experienced developers and architects who have either built or want to learn how to build their own development platforms and software frameworks.

The book is not targeted to a particular OSGi implementation or vendor, but it does use Apache Felix and, to a lesser extent, Eclipse Equinox for the examples in the book.

The book is based upon OSGi Service Platform 4.2 and some aspects of the recently published 4.3 version.

Ultimately, I like to think this is a book for programmers and architects who wish to learn how to build better systems.


The book can be divided into two main parts. Chapters 1 to 4 focus on the OSGi framework. Chapters 5 to 13 focus on OSGi services.

Chapter 1 provides a high-level description of OSGi and a rationale for using it. It also highlights the state of the art in terms of players and vendors in the market.

Chapter 2 provides a quick but complete primer on the OSGi framework.

In chapter 3, you explore a case study for a real OSGi application. At the end of this chapter, several shortcomings are highlighted, such as the lack of persistence, which you’ll learn how to solve throughout the book.

In chapter 4, you take an in-depth look at advanced features of the OSGi framework.

In chapter 5, you learn how to configure OSGi applications.

In chapter 6, you learn how to send and receive OSGi events.

In chapter 7, you learn about persistence bundles.

In chapter 8, you take your first steps toward learning how to write your own containers by developing a container-managed transaction bundle.

In chapter 9, you learn how to use JNDI to integrate OSGi and JEE.

In chapter 10, you learn about remote services and how OSGi can be used for cloud computing.

In chapter 11, you learn how to use JMX to manage in-production OSGi applications.

In chapter 12, you learn about start levels, and how to abstract OSGi from end users.

Finally, in chapter 13, you take your second step towards learning how to write containers by extending the Blueprint service. Here you revisit the application from chapter 3, improving it by putting together everything you’ve learned in the book.

For reference, appendix A describes all the OSGi manifest headers used in this book.

Code conventions and downloads

All code in the book is presented in a fixed-width font like this to separate it from ordinary text. Code annotations accompany many of the listings, highlighting important concepts. In some cases, numbered bullets link to explanations that follow the listing.

You will find the full code for all the examples in the book available for download from the publisher’s website at www.manning.com/OSGinDepth.

Author Online

The purchase of OSGi in Depth includes free access to a private forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the author and other users. You can access and subscribe to the forum at www.manning.com/OSGiinDepth. This page provides information on how to get on the forum once you’re registered, what kind of help is available, and the rules of conduct in the forum.

Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the author can take place. It isn’t a commitment to any specific amount of participation on the part of the author, whose contributions to the book’s forum remain voluntary (and unpaid). We suggest you try asking the author some challenging questions, lest his interest stray!

The Author Online forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.