Dependency Injection …and there is no magic

Dependency Injection is easier to implement, than to explain. In this 8 minute-screencast I explained what happens behind the scenes within an application server during initialization:

The screencast is actually the first 10 minutes of the workshop (Bootstrap). For unknown reasons, I referred to "side" with "size".I was too lazy to re-record it and recognized it after the fact...

Because DI is so easy, I built an injection "framework" for JavaFX:

See you at Java EE Workshops at MUC Airport!

See also other screencasts at: or subscribe to


Hi Adam,

what you've told is not completely the truth ;-)

#1 the container does not always look for injection points at runtime via reflection. Most often, it is done by using the annotation-processing-toolkit at deploy time. Then the container creates proxy-classes that are used as a kind of wrappers for the original instances.

#2 to show setAccessible(true) this way, is really dangerous, especially for Java-Novices. Instead, you should explain, that this must be done inside a PrivilegedAction and invoked by the SecurityManager.

(Not to mention, that setAccessible should not leave the accessible state to true, if it was false previously)...

See you at JAX ;-)

Posted by Robert on April 20, 2013 at 02:27 AM CEST #

it's esy..

Posted by on April 22, 2013 at 03:23 PM CEST #

Hi Adam

How would you go about injecting a implementation of the boundary if you only specified the interface on the Presenter?

One way I can think is to use the @Named annotation in conjunction with the @Inject and give it a string value which has the fully qualified class name of the implementation.


Posted by Rentius on April 22, 2013 at 03:55 PM CEST #

nice article !

Posted by moshe on April 23, 2013 at 02:45 PM CEST #


clone + pull-request :-)


Posted by Adam Bien on April 24, 2013 at 04:23 PM CEST #


Do you know any use case for injecting an interface? Do you really have at least two implementations of the presenter?

If yes, you could replace my injector with Google Guice. I started with Guice (code still in GIT), but didn't found any use cases for interface injection and built my own...



Posted by Adam Bien on April 24, 2013 at 04:26 PM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
...the last 150 posts
...the last 10 comments