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 11:10 Go to next message
Daniele Canavese is currently offline Daniele Canavese
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:
InjectorFactory.getDefault().addBinding(Logger.class).implementedBy(what?);
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] Tue, 23 October 2012 21:13 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de Alwis
Messages: 127
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.

Brian.
Re: Eclipse custom DI [message #962159 is a reply to message #955708] Sun, 28 October 2012 18:48 Go to previous message
Lars Vogel is currently offline Lars Vogel
Messages: 1048
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:Problem on min/max of Parts
Next Topic:Re: e4 Eclipse 4 - about dialog
Goto Forum:
  


Current Time: Wed Apr 16 06:48:39 EDT 2014

Powered by FUDForum. Page generated in 0.02063 seconds