Chapter 3. Learning lifecycle

 

This chapter covers

  • Understanding software lifecycle management
  • Introducing the lifecycle of a bundle
  • Exploring the lifecycle layer API
  • Extending an application to make it lifecycle aware
  • Explaining the relationship between the module and lifecycle layers

In the last chapter, we looked at the OSGi module layer and introduced you to bundles: a bundle is OSGi terminology for a module, which is a JAR file with the extra modularity metadata. You use bundles to define both the logical (code encapsulation and dependencies) and physical (deployable units) modularity of an application.

The OSGi module layer goes to great lengths to ensure that class loading happens in a consistent and predictable way. But to avoid putting the cart before the horse, in chapter 2 we glossed over the details of how you install bundles into an OSGi framework. No longer: in this chapter, we’ll look at the next layer of the OSGi stack—the lifecycle layer.

As we mentioned in chapter 2, to use a bundle you install it into a running instance of the OSGi framework. So creating a bundle is the first half of leveraging OSGi’s modularity features; the second half is using the OSGi 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.

3.1. Introducing lifecycle management

3.2. OSGi bundle lifecycle

3.3. Using the lifecycle API in your bundles

3.4. Dynamically extending the paint program

3.5. Lifecycle and modularity

3.6. Summary

sitemap