Skip to main content



      Home
Home » Eclipse Projects » Eclipse 4 » Eclipse custom DI
Eclipse custom DI [message #953829] Mon, 22 October 2012 11:10 Go to next message
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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: Tue Jul 22 20:12:34 EDT 2025

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

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

Back to the top