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: 500
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 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:Problem on min/max of Parts
Next Topic:Re: e4 Eclipse 4 - about dialog
Goto Forum:
  


Current Time: Wed Sep 28 17:11:00 GMT 2016

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

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