Injection of multiple service instances [message #997313] |
Sat, 05 January 2013 15:45 |
Štěpán Mík Messages: 1 Registered: January 2013 |
Junior Member |
|
|
As far as I know, eclipse framework is able to inject single instance of OSGi service if target site is properly annotated.
@Inject
private ISomeService service;
I'm wondering if there is a way how to inject ALL instances of service declared by interface ISomeService. As a wild guess I tried
@Inject
private ISomeService[] services;
@Inject
private List<ISomeService> services;
Both do not work. Is there an another solution? Or are there plans how to to achieve this?
I think that it is not uncommon situation when application wants to use all service implementations, not one selected by the framework. Even java CDI has the javax.enterprise.inject.Instance<T> that provides iterator over all candidates for injection.
BTW: It would be nice to have something like OSGi("query") qualifier to specify service being injected:
@Inject
@OSGi("LDAP expression")
private ISomeService[] services;
thank you for advices
Stepan
|
|
|
Powered by
FUDForum. Page generated in 0.03860 seconds