Implementing the ManagedServiceFactory Interface

When a bundle needs to create objects based on varying runtime configuration data, the OSGi specification states that a Managed Service Factory should be used.

Managed Service Factory Overview

OSGi defines the ManagedServiceFactory interface as follows:

  public interface ManagedServiceFactory {
    String getName();
    void updated(String, Dictionary) throws ConfigurationException;
    void deleted(String);
  }

A bundle would implement this interface and register the ManagedServiceFactory object with the OSGi framework. The factory will be notified by the ConfigurationAdmin bundle when a configuration is created, updated or deleted.

Creating a ManagedServiceFactory as described above is only really feasible for the simplest cases. In fact, even simple cases can be complicated to implement. Consider the following problems that must be addressed:

These problems are not new to users of OSGi. Users of SAT already have support for working appropriately with imported services, exported services and LDAP filters, but none of these benefits are available to implementers of the ManagedServiceFactory interface.