concept configuration in category osgi

This is an excerpt from Manning's book OSGi in Depth.
OSGi provides a new development platform, based on modular decoupled components and a pluggable dynamic service model. In this book, you’ll learn that OSGi is the ideal platform for the development of full-fledged, enterprise-grade, maintainable applications. Furthermore, we’ll look in depth at how OSGi applications can use a plethora of carrier-grade infrastructure services, such as HTTP, configuration, deployment, event handling, transactions, persistence, RMI, naming and directory services, and management.
Next, you need to associate a unique identification with the Notification Broker service. The configuring clients use this identification to link the configuration object to a managed service. We’ll use the service’s persistent identifier (PID), as defined in chapter 4, for this purpose. Remember that the PID is associated with a service through service properties during the service registration in the OSGi service registry, as shown in the following listing.
In this case, the PID for the Notification Broker service is "manning.osgi.notification.broker"
. For the reasons pointed out previously, you register the activator itself as the target service for the notification broker. Notice how you only specify the ManagedService interface in the call to register and not the NotificationBroker interface. This means that a consuming bundle that retrieves this service can’t cast it to the NotificationBroker interface. In other words, this service can only be used to configure the NotificationBroker and not to actually send events or subscribe to events. The separation of the configuration interface from the service interface is a useful one and is one of the advantages we discussed of using the Configuration Admin service.
The first option is to proactively provide better metadata about the configuration, so that the configuring bundle has a better chance of setting the correct data. We’ll look at this option in detail in section 5.7.
The second option is to check in the OSGi service registry itself for the service that has been supposedly configured. In our case, the configuring bundle could use a service reference filter whereby it specifies the port configuration that was set. If the filter comes back with no references from the OSGi service registry, then it’s a good indication that the configuration may have been invalid. There are a couple of caveats in this option. First, you need to be careful with the timing; the target service configuration is handled asynchronously, so there’s a chance that the service is still being created. Second, the failure to find the service in the OSGi service registry may be due to some other unforeseen reason and may not be related to any problems in the configuration object itself.
It also handles the durability of the configuration. When a configuring bundle updates the configuration in the Admin through the org.osgi.service.cm. Configuration interface, the Admin first persists the configuration properties and only then returns from the call. This means that the configuration isn’t lost if the platform is shut down before the configuration is handed over to the target services. Furthermore, during the start of the platform, all the target services are updated with the latest configuration; the target services themselves don’t need to worry about persisting their configuration.

This is an excerpt from Manning's book OSGi in Action: Creating Modular Applications in Java.
This is a good issue to keep in mind when you’re modularizing applications. Optional components or components with the potential to have multiple alternative implementations are good candidates to be in separate bundles. Breaking your application into multiple bundles gives you more flexibility, because you’re limited to deploying configurations of your application based on the granularity of your defined bundles. Sounds good, right? You may then wonder why you don’t divide your applications into as many bundles as you can.
You pay a price for the flexibility afforded by dividing an application into multiple bundles. Lots of bundles mean you have lots of artifacts that are versioning independently, creating lots of dependencies and configurations to manage. So it’s probably not a good idea to create a bundle out of each of your project’s packages, for example. You need to analyze and understand your needs for flexibility when deciding how best to divide an application. There is no single rule for every situation.
In the remainder of this section, we’ll introduce you to these configuration-related services and show you how you can manage configurations. We’ll start with the Configuration Admin Service.
How does this work? The Configuration Admin Service maintains a database of Configuration objects, each of which has an associated set of name-value pair properties. The Configuration Admin Service follows the whiteboard pattern and monitors the service registry for two different managed services: ManagedService and Managed-ServiceFactory. If you have a bundle that needs configuration data, it must register one of these two services defined in the Configuration Admin specification. The difference between these two is that a ManagedService accepts one configuration to configure a single service, whereas a ManagedServiceFactory accepts any number of configurations and configures a different service instance for each configuration; figure 9.5 illustrates this difference.
. For the reasons pointed out previously, you register the activator itself as the target service for the notification broker. Notice how you only specify the ManagedService interface in the call to register and not the NotificationBroker interface. This means that a consuming bundle that retrieves this service can’t cast it to the NotificationBroker interface. In other words, this service can only be used to configure the NotificationBroker and not to actually send events or subscribe to events. The separation of the configuration interface from the