Bug 500693 - [DI] Injector should support a factory for creating a class instance
Summary: [DI] Injector should support a factory for creating a class instance
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 4.7   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: platform-runtime-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 500689
  Show dependency tree
 
Reported: 2016-09-01 12:40 EDT by Brian de Alwis CLA
Modified: 2016-09-01 12:40 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brian de Alwis CLA 2016-09-01 12:40:37 EDT
Currently our DI Injector creates an instance by looking at the class instance for a 0-argument constructor or constructors with @Inject.   We should support registering a factory for a class instance to support integrating non-DI aware classes.  This approach mimics the Extension Registry's IExecutableExtensionFactory.

This could be done by providing a binding?  For example:

   injector.addBinding(MyObject.class).createBy(new MyObjectFactory());

(Unfortunately I've forgotten what my original usecase was for this enhancement.  It had to do with bridging in objects from an existing library.)