Java Reference
In-Depth Information
the bundle-based dynamism of the lifecycle layer with service-based dynamism—services
can appear or disappear at any time. The result is a programming model eschewing the
monolithic and brittle approaches of the past, in favor of being modular and flexible.
This sounds well and good, but you may still be wondering how these three layers
fit together and how you go about using them to create an application on top of them.
In the next couple of sections, we'll explore how these layers fit together using some
small example programs.
1.2.2
Putting it all together
The OSG i framework is made up of layers, but how do you use these layers in applica-
tion development? We'll make it clearer by outlining the general approach you'll use
when creating an OSG i-based application:
Design your application by breaking it down into service interfaces (normal
interface-based programming) and clients of those interfaces.
1
Implement your service provider and client components using your preferred
tools and practices.
2
Package your service provider and client components into (usually) separate
JAR files, augmenting each JAR file with the appropriate OSG i metadata.
3
Start the OSG i framework.
4
Install and start all your component JAR files from step 3.
5
If you're already following an interface-based approach, the OSG i approach will feel
familiar. The main difference will be how you locate your interface implementations
(that is, your services). Normally, you might instantiate implementations and pass
around references to initialize clients. In the OSG i world, your services will publish
themselves in the service registry, and your clients will look up available services in the
registry. After your bundles are installed and started, your application will start and
execute as normal, but with several advantages. Underneath, the OSG i framework pro-
vides more rigid modularity and consistency checking, and its dynamic nature opens
up a world of possibilities.
Don't fret if you don't or can't use an interfaced-based approach for your develop-
ment. The first two layers of the OSG i framework still provide a lot of functionality; in
truth, the bulk of OSG i framework functionality lies in these first two layers, so keep
reading. Enough talk: let's look at some code.
1.3
“Hello, world!” examples
Because OSG i functionality is divided over the three layers mentioned previously
(modularity, lifecycle, and service), we'll show you three different “Hello, world!”
examples that illustrate each of these layers.
1.3.1
Module layer example
The module layer isn't related to code creation as such; rather, it's related to the pack-
aging of your code into bundles. You need to be aware of certain code-related issues
Search WWH ::




Custom Search