ServiceManager - Complex dependencies.
I have been registering some basic services though plugin.xml e.g.
<applicationService
serviceInterface="foo"
serviceImplementation="foo"
/>
I now have more complex project level services that themeless have dependencies on other services and values from the user configurable plugin settings. Is there a way to programatically register these service with the ServiceManager outside of plugin.xml and clear the lazy loading when the plugins settings have been changed. I currently solve this with my own container.
Please sign in to leave a comment.
Why do you need to register services programmatically? Note that even if a service is registered in plugin.xml, it's loaded lazily when getService method is called for a first time, see the docs for details.
Say for example the service Foo registered above in the plugin.xml has a dependency on a list of classes implementing an interface Bar. How does the service manager auto-wire this dependency before initialising service Foo. At the moment I think this produces "has unsatisfied dependency: interface java.util.List among unsatisfiable dependencies: [[interface java.util.List]]"
If there are several implementations of an interface Bar in the plugins, you should declare Bar as an extension point, see the docs for details.
Neither Foo nor Bar need to be shared across plugins so I don't think an extension point would be necessary. The ServiceManager documentation only shows examples of services that have no dependencies.
Any ideas? It might be that the ServiceManager is capable of auto wiring dependencies but I can’t find anything in the documentation. The alternative would be to create my own container in the plugin to manage dependencies.