Bug 389634 - [INJECTION] Annotated & Instance Bindings
Summary: [INJECTION] Annotated & Instance Bindings
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 4.2   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: platform-runtime-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-14 15:04 EDT by Joseph Carroll CLA
Modified: 2012-09-14 16:06 EDT (History)
1 user (show)

See Also:


Attachments
TypedBinding's ver 0.1 (46.83 KB, patch)
2012-09-14 15:21 EDT, Joseph Carroll CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Carroll CLA 2012-09-14 15:04:44 EDT
The DI engine should support named and annotated injection as well as injection of instances.  Allowing both named and annotated injection will allow for greater reuse of annotations and provides greater flexibility.  The ability to support injection of instances would be very valuable in a number of different areas.
Comment 1 Joseph Carroll CLA 2012-09-14 15:21:21 EDT
Created attachment 221108 [details]
TypedBinding's ver 0.1
Comment 2 Joseph Carroll CLA 2012-09-14 15:21:35 EDT
This week I added support to the DI engine for, what I am calling, "TypedBindings."

TypedBinding's are very similar to Guice's bindings in that you are able to create a binding with a qualified name and a separate annotation and then bind to either an instance or implementation.

An example of a TypedBinding is:
  InjectorFactory.getDefault().addTypedBinding(String.class)
      .named(IConstants.NAME).annotatedWith(MyAnnotation.class)
      .toInstance("My string");

TypedBindings would replace the current Binding framework, and maintains complete backwards compatibility so there are no code changes necessary.

The attachment is a patch for the current release of TypedBindings.  The code is kept at GitHub:
http://github.com/jd-carroll/eclipse.platform.runtime/tree/TypedBindings/bundles/org.eclipse.core.runtime

All tests located in bundle o.e.e4.core.tests were successfully run and passed.

I will put together additional documentation that describes how to use TypedBinding's in the next few days.  I will also create several tests for the newly supported features.

JD