Listing / choosing from multiple implementations of a service [message #1699852] |
Sat, 27 June 2015 06:19  |
Eclipse User |
|
|
|
Hello!
I am writing my first Eclipse RCP application, and I am not quite sure how to proceed ...
The problem is as follows: I have defined a service interface which my application is to use. But there should be different implementations of the service and the user should freely choose at runtime from one of the service implementations.
My approach now is to implement the services as "declarative plugin-ins". In the OSGI component description I state that the plugin provides the service.
My understanding is that via dependency injection of a service into my application, there are certain rules as to which implementation will be choosen.
But I want to get a list of all the possible implementations and let the user decide.
I have read something about low-level OSGI services, but I am not quite sure if this is the way to go.
Any help is greatly appreciated!
Cheers,
Niklas
|
|
|
|
Re: Listing / choosing from multiple implementations of a service [message #1700085 is a reply to message #1699961] |
Tue, 30 June 2015 01:12  |
Eclipse User |
|
|
|
Brian is true in general but I wanted to add that e(fx)clipse has DI
addons who provide you access to the full list of OSGi-Services
including all the dynamics they involve.
See
https://wiki.eclipse.org/Efxclipse/Runtime/Recipes#Injection_of_OSGi-Services
You can use this part of e(fx)clipse also in SWT-RCP applications.
Tom
On 29.06.15 15:22, Brian de Alwis wrote:
> Niklas Henrich wrote on Sat, 27 June 2015 06:19
>> My understanding is that via dependency injection of a service into my
>> application, there are certain rules as to which implementation will
>> be choosen.
>
>
> Providing you've setup your DI IEclipseContext hierarchy to include the
> special OSGi Services-based context (which is the context setup used by
> E4 workbench apps), the service is chosen using OSGi's
> BundleContext#getServiceReference() and so governed by the
> service.ranking property to prioritize the available OSGi Services.
>
> Quote:
>> But I want to get a list of all the possible implementations and let
>> the user decide.
>
>
> You can't have both. DI is a behind-the-scenes technology, and not
> intended to prompt the user for decision making. In this case, I think
> you'd need to deal with OSGi Services directly and present to the user.
> You could then explicitly set their selected service in your
> IEclipseContext hierarchy.
>
> Brian.
|
|
|
Powered by
FUDForum. Page generated in 0.04914 seconds