| Eclipse Service with DI [message #1009790] |
Fri, 15 February 2013 13:08  |
Kai Zimmermann Messages: 9 Registered: October 2012 |
Junior Member |
|
|
I want to develop a service in the eclipse application level that will be initialized with dependency injection.
This is a schematic illustration:

I've added a workbench model processor to start my service. Is this the best approach?

I have added my sample code (breadservice.zip).
[Updated on: Fri, 15 February 2013 13:12] Report message to a moderator
|
|
|
| Re: Eclipse Service with DI [message #1010484 is a reply to message #1009790] |
Sun, 17 February 2013 07:47   |
Brian de Alwis Messages: 122 Registered: January 2012 |
Senior Member |

|
|
If your bakery service is independent of the UI, but is not intended to be instantiated on a 1-1 basis with thr UI, then I'd recommend configuring it as an OSGi service, and post your events directly to the EventAdmin service instead. If you do want to use the IEventBroker for posting, do it from an addon that is introduced by a model processor -- the model processors originally had a very limited lifetime, created and then torn down, and something changed. Addons are part of the model, on the other hand, and have the same lifetime as the model itself.
Brian,
|
|
|
| Re: Eclipse Service with DI [message #1010497 is a reply to message #1010484] |
Sun, 17 February 2013 08:35   |
Thomas Schindl Messages: 4463 Registered: July 2009 |
Senior Member |
|
|
Another way if you need access to the IEventBroker (=you can't simply
contribute as an OSGi-Service) is to register an IContextFunction
providing the service interface through DS.
In 4.3 we are registering our E4Workbench as an OSGi-Application which
allows you to get access to the MApplication which allows you to get
access to the IEclipseContext which allows you to access IEventBroker
even from OSGi.
Tom
Am 17.02.13 13:47, schrieb Brian de Alwis:
> If your bakery service is independent of the UI, but is not intended to
> be instantiated on a 1-1 basis with thr UI, then I'd recommend
> configuring it as an OSGi service, and post your events directly to the
> EventAdmin service instead. If you do want to use the IEventBroker for
> posting, do it from an addon that is introduced by a model processor --
> the model processors originally had a very limited lifetime, created
> and then torn down, and something changed. Addons are part of the model,
> on the other hand, and have the same lifetime as the model itself.
>
> Brian,
|
|
|
| Re: Eclipse Service with DI [message #1010515 is a reply to message #1010497] |
Sun, 17 February 2013 09:44  |
Kai Zimmermann Messages: 9 Registered: October 2012 |
Junior Member |
|
|
I will google about IContextFunction, because I never heard about it. I found eclipse.org/forums/index.php/m/734956/, but IEventBroker is only an example, I'd like to use the whole DI functionality, not especially the messaging service 
Hint for me
- grepcode.com/file/repository.grepcode.com/java/eclipse.org/4.2/org.eclipse.e4.core/contexts/1.1.0/org/eclipse/e4/core/contexts/IContextFunction.java#IContextFunction.compute%28org.eclipse.e4.core.contexts.IEclipseContext%29
- stackoverflow.com/questions/12996698/example-on-how-to-use-icontextfunction-in-eclipse-4
- toedter.com/blog/?p=222
Thank you!
[Updated on: Sun, 17 February 2013 09:44] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.05826 seconds