Java Reference
In-Depth Information
In this chapter, you'll learn everything you need to know about launching the OSG i
framework. To help you reach this goal, we'll dissect the generic bundle launcher
you've been using to run the topic's examples. You'll also refactor the paint program to
see how to embed a framework instance inside an existing application. Let's get going.
13.1
Standard launching and embedding
As we mentioned back in chapter 3, you face a dilemma when you want to use a bun-
dle you've created. You need a BundleContext object to install your bundle into the
framework, but the framework only gives a BundleContext object to an installed and
started bundle. So you're in a chicken-and-egg situation where you need an installed
and started bundle to install and start your bundle. You need some way to bootstrap
the process.
Traditionally, OSG i framework implementations from Apache Felix, Equinox, and
Knopflerfish devised implementation-specific means for dealing with this situation.
This typically involved some combination of auto-deploy configuration properties for
each framework implementations' custom launchers and/or shells with textual or
graphical interfaces. These mechanisms worked reasonably well but weren't portable
across framework implementations.
With the release of the OSG i R4.2 specification, the OSG i Alliance defined a stan-
dard framework launching and embedding API . Although this isn't a major advance in
and of itself, it does help you create applications that are truly portable across frame-
work implementations. You may wonder if this is really necessary or all that common.
There are two main reasons why you may want to create your own framework instance:
Your application has custom startup requirements that aren't met by your
framework's default launcher.
1
For legacy reasons, you can't convert your entire application into a set of bun-
dles that run inside an OSG i framework.
2
Previously, if either of these applied to your project, you had to couple your project to
a specific framework implementation by using its custom API to launch it. Now, R4.2-
compliant frameworks share a common API for creating, configuring, and starting the
framework. Let's dive into its details.
13.1.1
Framework API overview
As we previously mentioned, at execution time the OSG i framework is internally repre-
sented as a special bundle, called the system bundle , with bundle identifier zero. This
means active bundles are able to interact with the framework using the standard
Bundle interface, which we reiterate in the following listing.
Listing 13.1 Standard Bundle interface
public interface Bundle {
String getSymbolicName();
Version getVersion();
Content-access
methods
 
Search WWH ::




Custom Search