Clever use of Silk DI (or Guice) with really simple on-demand new instances

if you write this

static class $ {
public static T create (final Class type, final Object... additionalParameters) {
return ApplicationInjector.instantiate (type, additionalParameters);

public static T select (final Class type) {
return ApplicationInjector.getBean (type);

private $ () {


then you will feel how simple a Dependency Injector can be ! Think of some brillant frameworks like JQuery or prototype in JS. They rely on the fact that the most used features must be call with the least effort possible.
(for example in jquery, if you want a link markup inside a div, do this : $(« div > a »))

With this simple code, you can have an instance of any impl-dependant bean.
If you want to instantiate an AudioFormatParser (an impl-dependant bean), just do that :

AudioFormatParser parser = $.select (AudioFormatParser.class);

If you want to create an instance of an object using some beans, but not injected itself, just do that :

MyService service = $.create (MyService.class, "myarg1", 1, true);

This will actually use any constructor with the enclosed parameters, plus the beans needed to achieve the instantiation.
For example, the code above will be able to call this constructor without any other pain :

public MyService (AudioFormatParser audioFormatParser, AComplicatedRepository repository, String arg1, int arg2, boolean arg3)

Just have a look at my current project using this facility :

You can also see the classes $ and ApplicationInjector that provide this idea :