Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Injection of multiple service instances(OSGi allows to register more instances of same service. Is it possible to inject them all?)
Injection of multiple service instances [message #997313] Sat, 05 January 2013 15:45
Štěpán Mík is currently offline Štěpán MíkFriend
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
Previous Topic:Eclipse 4 user interface testing with SWTBot
Next Topic:e(fx)clipse 0.8.0 - e4 for JavaFX
Goto Forum:
  


Current Time: Sat Dec 20 23:14:19 GMT 2014

Powered by FUDForum. Page generated in 0.01542 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software