Java Reference
In-Depth Information
As we mentioned in chapter 2, to use a bundle you install it into a running instance
of the OSG i framework. So creating a bundle is the first half of leveraging OSG i's mod-
ularity features; the second half is using the OSG i framework as a runtime to manage
and execute bundles. The lifecycle layer is unique in allowing you to create externally
(and remotely) managed applications or completely self-managed applications (or
any combination of the two). It also introduces dynamism that isn't normally part of
an application.
This chapter will familiarize you with the features of the lifecycle layer and explain
how to effectively use them. In the next section, we'll take a closer look at what lifecy-
cle management is and why you should care about it, followed by the definition of the
OSG i bundle lifecycle. In subsequent sections, you'll learn about the API for managing
the lifecycle of bundles. Throughout this chapter, we'll bring all the points home via
examples of a simple OSG i shell and a lifecycle-aware version of the paint program.
3.1
Introducing lifecycle management
The OSG i lifecycle layer provides a management API and a well-defined lifecycle for
bundles at execution time in the OSG i framework. The lifecycle layer serves two differ-
ent purposes:
External to your application, the lifecycle layer precisely defines the bundle lifecy-
cle operations . These lifecycle operations allow you to manage and evolve your
application by dynamically changing the composition of bundles inside a run-
ning framework.
Internal to your application, the lifecycle layer defines how your bundles gain access
to their execution context , which provides them with a way to interact with the OSG i
framework and the facilities it provides at execution time.
But let's take a step back. It's fine to state what the OSG i lifecycle layer does, but this
won't necessarily convince you of its worth. Instead, let's look at a quick example of
how it can improve your applications with a real-world scenario.
3.1.1
What is lifecycle management?
Imagine you have a business application that can report management events via JMX .
Do you always want to enable or even install the JMX layer? Imagine running in a light-
weight configuration and only enabling the JMX notifications on demand. The lifecy-
cle layer allows you to install, start, update, stop, and uninstall different bundles
externally, to customize your application's configuration at execution time.
Further, imagine that a critical failure event in your application must trigger the
JMX layer to send out a notification regardless of whether the administrator previ-
ously enabled or installed the layer. The lifecycle layer also provides programmatic
access to bundles so they can internally modify their application's configuration at
execution time.
Search WWH ::




Custom Search