Chapter 5. Configuring OSGi applications

 

This chapter covers

  • The reasons for configuration
  • The advantages of handling configuration through the Configuration Admin service
  • Validation of configuration data
  • Transaction-ability of configuration changes

As you’ll see, most applications need some form of configuration. This configuration includes not only IT-related configuration, such as server names and TCP/IP ports, but also business-related configuration, such as custom or localized labels.

The OSGi platform provides several services, including the Configuration Admin service, the OSGi Log service, and the OSGi Metatype service, that collectively can be used as a configuration framework for OSGi applications.

In this chapter, we’ll look into these services and see how they can be used collectively to configure an application. We’ll start by confronting the configuration problem systematically.

5.1. The configuration problem

Before we look into how to configure a service in OSGi, you should understand why and when configuration is needed. To do this, we’ll use an example—the Notification Broker service.

5.1.1. The Notification Broker service

5.2. The Configuration Admin service

5.3. Configuring using complex data types

5.4. Deleting configuration

5.5. Configuring multiple services

5.6. When configuration update fails

5.7. Management agents

5.8. Summary