Java Reference
In-Depth Information
As we mentioned, a bundle can be in different states. The lifecycle layer defines the
following six states:
INSTALLED : The bundle has been installed in the OSG i container.
RESOLVED : All package requirements are fulfilled and the bundle is ready to
be started.
STARTING : The bundle is in the process of starting.
ACTIVE : The bundle has started.
STOPPING : The bundle is in the process of stopping. After this, the bundle will
be in the RESOLVED state.
UNINSTALLED : OSG i has removed the bundle from the container.
It may seem a bit confusing now, but the example we provide will clear things up, so
let's move on and implement our first OSG i service.
16.2
Our first OSGi service
In the first chapter of the topic, we implemented a simple calculator application.
That application was simple enough to demonstrate the basic concepts of unit test-
ing. We take the same approach in this chapter. We implement the calculator
application as an OSG i service. We also implement a sample client for that service
and a test bundle for the client. Finally, we install the three bundles in the Apache
Felix environment.
Apache Felix—open source implementation of the service platform
The OSGi alliance defines a number of specifications for the OSGi service plat-
form. The implementation of these specifications can be done by anyone. In this
chapter, we use the Apache Software Foundation implementation Apache Felix
( http://felix.apache.org/). Th e installation of the Felix project is easy. Start by
downloading the latest distribution. Extract the archive and create an environ-
ment variable called FELIX_HOME pointing to the Felix folder. The Felix folder
should contain the following:
bin—This folder contains only one JAR file, called felix.jar. This JAR is used to
instantiate the Felix console to remotely operate the different services.
bundle—This folder contains the various Felix bundles.
conf—This folder contains the Felix configuration file.
doc—This folder contains the documentation.
The implementation of our calculator service starts with the interface in listing 16.1.
Every OSG i service is defined by an interface.
 
 
 
 
 
 
 
 
 
Search WWH ::




Custom Search