I read this answer by Neil Bartlett that stated that DS is able to replace the old ManagedServiceFactory
approach of instantiating services:
A component can be used as either a singleton (i.e. MS) or a factory (i.e. MSF) by adding "configurationPolicy: require". If you create a factory config with a Factory PID the same as the component.name, then you get a factory.
As far as I am aware, creating a new configuration with a factory PID makes the Configuration Admin create a new instance of this service; indeed, this is what happens.
Say I have a factory PID of test
, and I then add a configuration for test-1
with felix-fileinstall
. This service is then correctly instantiated and activated when I add the corresponding configuration.
If I do
@Reference(target="(service.pid=test-1)")
Test test;
this obviously never gets resolved, as the created configuration is required to have a generated GUID.
How is it possible to obtain a reference to this service? Would I need to add an additional property to each configuration instance to filter by?