ABOUT THIS BOOK
xxi
In part 1 of the book, we focus on explaining the most common aspects of the OSGi
core specification from the user’s perspective. We introduce OSGi according to its
three-layer architecture: module, lifecycle, and services. This isn’t the only approach
to take in explaining
OSGi; most explanations of OSGi start out with a simple bundle
implementing a simple service. The downside of this type of approach, in our view, is
that it cuts across all three
OSGi layers at once, which would require us to explain all
three layers at once.
The advantage of following a layered approach is that doing so creates a clear divi-
sion among the concepts we need to discuss. For example, the modularity chapter
focuses on modularity concepts and can largely ignore lifecycle and services. This
approach also creates a natural progression, because modularity is the foundation of
OSGi, lifecycle builds on it, and services are on top of lifecycle. We can also highlight
how to use lower layers of the OSGi architecture without using the upper layers, which
is sometimes worthwhile.
Part 2 of the book takes the knowledge about the
OSGi core specification from
part 1 and shows how you can use the technology from a more pragmatic viewpoint.
We look into converting existing
JAR files to bundles as well as testing, debugging,
and managing bundles. These first two parts of the book should be of general inter-
est to anyone wanting to learn more about using
OSGi.
Part 3 covers various advanced topics, such as service-oriented component models,
framework launching, security, and distributed computing technologies. This last part
serves as a springboard to the world of possibilities available to you in the
OSGi universe.
Roadmap
Chapter 1 presents a high-level view of OSGi technology and the issues it’s intended to
address. To keep the chapter from being totally abstract, we present a few “Hello,
world!” examples to illustrate the different layers of the
OSGi framework, but the real
meat of our OSGi discussion is in the following chapters. We also look at the state of
modularity support in Java as well as in some related technologies.
Chapter 2 explores the module layer of the
OSGi framework. We start with a general
discussion of modularity in computing and then continue by describing OSGi’s module
concept, called a bundle. We present OSGi’s declarative metadata-based approach for
creating modules and show how to use it to modularize a simple paint program. We also
investigate one of the key
OSGi tasks: bundle dependency resolution.
Chapter 3 looks at the lifecycle layer of the OSGi framework. We discuss lifecycle
management in general and describe how OSGi provides dynamic lifecycle manage-
ment of bundles. We present OSGi’s lifecycle-related APIs by creating a simple OSGi
shell and also adapt our paint program to make it lifecycle aware.
Chapter 4 examines the services layer of the
OSGi framework. We describe what
services are and discuss why and when you need them. We walk you through providing
and using services with some toy examples and then take an iterative approach to
describing how to deal with the unique aspect of service dynamism. We finish our ser-
vice discussion by adapting the paint program, this time to use dynamic services.