Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Listing / choosing from multiple implementations of a service
Listing / choosing from multiple implementations of a service [message #1699852] Sat, 27 June 2015 10:19 Go to next message
Niklas Henrich is currently offline Niklas HenrichFriend
Messages: 1
Registered: June 2015
Junior Member
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 #1699961 is a reply to message #1699852] Mon, 29 June 2015 13:22 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Listing / choosing from multiple implementations of a service [message #1700085 is a reply to message #1699961] Tue, 30 June 2015 05:12 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
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.
Previous Topic:product launch and feature dependencies
Next Topic:Gradle as Build Tool for Eclipse plugin development
Goto Forum:
  


Current Time: Fri Apr 26 03:26:11 GMT 2024

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

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

Back to the top