Skip to main content

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

That sounds like it could be nifty. It's a bit like the class-based @Singleton, but named.  Do you further inject the provided instance?

I assume it overrides any values provided from a supplier (e.g., context)?

Brian.

On 14-Sep-2012, at 3:39 PM, Joseph D Carroll Jr wrote:

I just released an enhancement for the DI engine that allows for the creation of (what I am calling) typed bindings:

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:


JD
_______________________________________________
e4-dev mailing list
e4-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/e4-dev


Back to the top