Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Eclipse Service with DI
Eclipse Service with DI [message #1009790] Fri, 15 February 2013 18:08 Go to next message
Kai Zimmermann is currently offline Kai ZimmermannFriend
Messages: 16
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:
index.php/fa/13433/0/

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

index.php/fa/13436/0/

I have added my sample code (breadservice.zip).

[Updated on: Fri, 15 February 2013 18:12]

Report message to a moderator

Re: Eclipse Service with DI [message #1010484 is a reply to message #1009790] Sun, 17 February 2013 12:47 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 194
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,


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Re: Eclipse Service with DI [message #1010497 is a reply to message #1010484] Sun, 17 February 2013 13:35 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5487
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 14:44 Go to previous message
Kai Zimmermann is currently offline Kai ZimmermannFriend
Messages: 16
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 Wink

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 14:44]

Report message to a moderator

Previous Topic:IEventBroker inside of the LifeCycle?
Next Topic:Hide View Tab
Goto Forum:
  


Current Time: Mon Dec 22 05:54:21 GMT 2014

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

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