Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » How to retrieve/inject a list of services
How to retrieve/inject a list of services [message #722419] Mon, 05 September 2011 18:16 Go to next message
Hannes Niederhausen is currently offline Hannes Niederhausen
Messages: 14
Registered: July 2009
Junior Member
Hi,

I use services to implement extensions to my domain model. All extensions implement the same interface. The question is, how can I retrieve all the implementations?

I tried the @Inject annotation with a list/array of my interface but it didn't work.

Then I tried the get method of the IEclipseContext but also got only one instance.

Funny thing: if I inject a single instance via annotation and retrieve another instance using the context I get two different implementations.

Any hints or is just not possible right now?

Best regards and thanks in advance
Hannes

[Updated on: Mon, 05 September 2011 18:26]

Report message to a moderator

Re: Hot to retrieve/inject a list of services [message #722443 is a reply to message #722419] Mon, 05 September 2011 19:09 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5344
Registered: July 2009
Senior Member
The only possibility is to create a Component in your plugin which you
configure using DS to receive all services and let you inject exactly
this one component.

This also solves the dynamic aspect of OSGi-Services currently not solve
by e4 DI by default.

Tom

Am 05.09.11 20:16, schrieb Hannes Niederhausen:
> Hi,
>
> I use services to implement extensions to my domain model. All
> extensions implement the same interface. The question is, how can I
> retrieve all the implementations?
>
> I tried the @Inject annotation with a list/array of my interface but it
> didn't work.
>
> Then I tried the get method of the IEclipseContext but also got only one
> instance.
>
> Funny thing: if I inject a single instance via annotation and retrieve
> another instance using the context I get two different implementations.
>
> Any hints or is just not possible right now?
>
> Best regards and thanks in advance
> Hannes
Re: Hot to retrieve/inject a list of services [message #722444 is a reply to message #722419] Mon, 05 September 2011 19:09 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5344
Registered: July 2009
Senior Member
The only possibility is to create a Component in your plugin which you
configure using DS to receive all services and let you inject exactly
this one component.

This also solves the dynamic aspect of OSGi-Services currently not solve
by e4 DI by default.

Tom

Am 05.09.11 20:16, schrieb Hannes Niederhausen:
> Hi,
>
> I use services to implement extensions to my domain model. All
> extensions implement the same interface. The question is, how can I
> retrieve all the implementations?
>
> I tried the @Inject annotation with a list/array of my interface but it
> didn't work.
>
> Then I tried the get method of the IEclipseContext but also got only one
> instance.
>
> Funny thing: if I inject a single instance via annotation and retrieve
> another instance using the context I get two different implementations.
>
> Any hints or is just not possible right now?
>
> Best regards and thanks in advance
> Hannes
Re: Hot to retrieve/inject a list of services [message #722550 is a reply to message #722444] Tue, 06 September 2011 07:09 Go to previous message
Hannes Niederhausen is currently offline Hannes Niederhausen
Messages: 14
Registered: July 2009
Junior Member
Hi Tom,

thanks for the hint.

I was afraid it isn't possible at all in e4.

I still getting used to the component declarations, learning something new each day. Smile

Best regards
Hannes
Previous Topic:Ant Script for eclipse e4 application
Next Topic:Disable drag and drop to detached window?
Goto Forum:
  


Current Time: Tue Sep 30 20:07:20 GMT 2014

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

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