Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Eclipse custom DI
Eclipse custom DI [message #953829] Mon, 22 October 2012 15:10 Go to next message
Daniele Canavese is currently offline Daniele CanaveseFriend
Messages: 4
Registered: August 2012
Junior Member
Hi all!

I would like to start injecting my custom classes using the e4 dependency injection mechanism but I haven't had any luck so far.

I have a custom class called Coordinator containing an injected logger (from java.util.logging.Logger):
public class Coordinator
  @Inject private Logger logger;

As far I have understood I have to use the InjectorFactory to achieve the DI, such as:
Coordinator coordinator = InjectorFactory.getDefault().make(Coordinator.class, null);

But what are the addBinding() arguments? Or am I missing something?

Regards, Daniele
Re: Eclipse custom DI [message #955708 is a reply to message #953829] Wed, 24 October 2012 01:13 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 742
Registered: January 2012
Senior Member

You can use the InjectorFactory to cause certain class or name references to be resolved to a particular object. You could use that mechanism to map a java.util.logging.Logger to a particular instance.

If you want to control what is injected, look at the Context Functions. Or object suppliers.


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Re: Eclipse custom DI [message #962159 is a reply to message #955708] Sun, 28 October 2012 22:48 Go to previous message
Lars Vogel Unavailable until 15 August 2016 is currently offline Lars Vogel Unavailable until 15 August 2016Friend
Messages: 1051
Registered: July 2009
Senior Member

Not sure if that is your questions but the creation of your own objects via DI is described here: Eclipse 4 - Using dependency injection for your own Java objects
Previous Topic:Views problem
Next Topic:How to force the creation of instance of Part class URI?
Goto Forum:

Current Time: Wed May 23 09:26:58 GMT 2018

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

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

Back to the top