The support SAT provides for creating a Managed Service Factory is split between two classes:
ManagedServiceFactoryBundleActivator: This class is an
abstract subclass of BaseBundleActivator and an implementer
of OSGi's ManagedServiceFactory interface. The class
registers an instance of itself with the OSGi framework as a
ManagedServiceFactory.
ManagedServiceFactory
creates its activator as a concrete subclass of this class.
ManagedServiceFactoryBundleActivator class
implements getName() to return its fully qualified
class name.
ManagedServiceFactoryBundleActivator class
implements the updated(String, Dictionary) method and
knows how to manage the objects created for each configuration.
ConfigurationAdmin the
ManagedServiceFactoryBundleActivator class is capable
of deciding whether the updated method requires the creation of a
new object, or simply the updating of an existing object. For both
the creation of a new object and the updating of an existing object,
the ManagedServiceFactoryBundleActivator class
delegates to its advisor, an implementation of the interface
IManagedServiceFactoryAdvisor that concrete subclasses
are expected to create.
ManagedServiceFactoryBundleActivator class
implements deleted(String) by delegating to its
advisor.
ManagedServiceFactoryBundleActivator are required to
implement the method createAdvisor() that returns an
instance of the IManagedServiceFactoryAdvisor
interface. An abstract implementation of this interface is provided
by the class BaseManagedServiceFactoryAdvisor.
BaseManagedServiceFactoryAdvisor: This class is an abstract
implementation of the IManagedServiceFactoryAdvisor
interface. Concrete subclasses must provide behavior for managing an
object based on a configuration provided by
ConfigurationAdmin.
IManagedServiceFactoryAdvisor interface is as follows:
public interface IManagedServiceFactoryAdvisor {
Object create(String, Dictionary, IBundleActivationManager);
void createImportedServiceFilters(String, Dictionary, Dictionary, IBundleActivationManager);
void destroy(String, Object, Dictionary, IBundleActivationManager);
String[] getImportedServiceNames(String, Dictionary, Dictionary, IBundleActivationManager);
String[] getOptionalImportedServiceNames(String, Dictionary, Dictionary, IBundleActivationManager);
void handleAcquiredOptionalImportedService(String, Object, String, Object, IBundleActivationManager);
void handleReleasedOptionalImportedService(String, Object, String, Object, IBundleActivationManager);
Object update(String, Object, Dictionary, Dictionary, IBundleActivationManager);
void validateConfiguration(String, Dictionary) throws ConfigurationException;
}
IManagedServiceFactoryAdvisor API. The example is a
variation of VendorService example used elsewhere in the
SAT documentation.
Copyright © 2001, 2007 IBM Corporation and others. All Rights Reserved.