Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[e4-dev] DI TypedBinding's Implementation

I just released an enhancement for the DI engine that allows for the creation of (what I am calling) typed bindings:
http://bugs.eclipse.org/bugs/show_bug.cgi?id=389634

Here is an example of what you are able to do with typed bindings:
injector.addTypedBinding(String.class).toInstance("My string");
injector.addTypedBinding(String.class).named("NAMED").toInstance("Some other string");
injector.addTypedBinding(FooBar.class).annotatedWith(MyAnnotation.class).toInstance(myFooBarImpl);
injector.addTypedBinding(FooBar.class).named("NAMED").annotatedWith(ExecuteMe.class).toInstance(someOtherFooBarImpl);
injector.addTypedBinding(FooBar.class).annotatedWith(MyOtherAnnotation.class).named("NAMED").toImplementation(FooBar.class);
injector.addTypedBinding(TestSingleton.class);

I am certainly open to, and looking for, comments and will continue to make enhancements and any fixes.  In the next few days I will put together a little better documentation.
This implementation is also 100% backwards compatible with the current bindings.  

The code is hosted here:
http://github.com/jd-carroll/eclipse.platform.runtime/tree/TypedBindings/bundles/org.eclipse.e4.core.di


JD

Back to the top