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:
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] Wed, 24 October 2012 01:13 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 194
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.


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 is currently offline Lars VogelFriend
Messages: 1049
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: Mon Nov 24 14:01:46 GMT 2014

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

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