- #include <cppmicroservices/cm/ManagedServiceFactory.hpp>
The ManagedServiceFactory interface is the interface that service factories should implement to receive updates from the ConfigurationAdmin implementation with the Configurations for the services that the Factory will provide.
The service.factoryPid ServiceProperty of the ManagedServiceFactory (or the component.name which is injected by DeclarativeServices if no service.factoryPid is provided) will be used to select all Configurations applicable to this factory. Per the OSGi Spec, the ManagedServiceFactory is intended to be used when multiple instances of a given Service will exist in the Framework, but each with different Configurations. For this reason, ManagedServiceFactory implementations are encouraged to mirror any properties (excluding security critical properties) into the ServiceProperty map when publishing the service with the Framework (if it is going to be published). Clients of the service can then filter on the properties they require.
The Updated method will be invoked once for each initial Configuration for this factory and then again whenever any of those Configurations change or whenever any new Configurations for this factory are added.
Updated(const std::string &pid, const AnyMap &properties) = 0¶
Can throw a ConfigurationException if there’s a problem with the properties. This exception will be logged by the ConfigurationAdminImpl to aid the application author’s investigation into the incorrect configuration.
Will be called asynchronously from the Service registration or an update to the Configuration.
The ManagedServiceFactory should update the corresponding service instance with the properties provided, and potentially update the properties of that service’s registration with the Framework (if it is registered).
If a corresponding service instance does not exist for this pid, the ManagedServiceFactory should create one with the properties provided. It should also register that new service with the Framework, if applicable.
Removed(const std::string &pid) = 0¶
Called whenever one of the Configurations for this service is removed from ConfigurationAdmin.
Will be called asynchronously from the removal of the Configuration.
pid: The unique pid for the Configuration to remove, of the form “$FACTORY_PID~$INSTANCE_NAME”