It depends on what you need, and the mechanism you use for dependency management. In short, - ManagedServiceFactory is a part of the Configuration Admin specification from the Compendium (section 104). It allows you to create zero or more services based on a configuration, in much the same way as you would configure exactly one service using a ManagedService. - ComponentFactory is a part of the Declarative Services specification (Compendium, 112), and is used for creating instances of a service on-demand (see 112.2.4).
If you need to generate services 'externally', for instance, you have a service that discloses information based on some file system paths, you can use a ManagedServiceFactory: you create a configuration for each of the paths. If you need to be able to create a service for each 'getting' of the service (so they don't get shared between components using the service), and you happen to use SCR as a dependency management mechanism, you can go with ComponentFactory. So, they are not necessarily comparable. What is your use case? Angelo On May 20, 2010, at 8:26 PM, Tom Kesling wrote: > Hello, > I'm trying to understand when to use a ManagedServiceFactory vs a > ComponentFactory. > > Any advice is appreciated. > > Thanks, > T > _______________________________________________ > OSGi Developer Mail List > [email protected] > https://mail.osgi.org/mailman/listinfo/osgi-dev _______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
