There you’ll find for the moment 3 enhancements that I contributed:
- named annotation support
- injection for interface
- ability to plug-in external DI framework (CDI, guice, spring, …)
Named annotation support
This addition was the first Pull Request I submitted to afterburner.fx.
It is very simple and allows for injection of values which cannot be directly tied to a java attribute because of java naming conventions.
It can be also necessary to use the
@Named if you use program argument injection and that you have complex argument names.
This addition, tracked behind PR-34, allows the resolution of injection point that use an interface instead of a class type.
I provided it while thinking on how to plug external DI framework ; I thought first why not allow the already existing JRE service provider, ServiceLoader, to work with afterburner.fx.
Finally, if you have attributes declared using interface, whith this addition they will be resolved via the ServiceLoader by looking at your declared services in
External DI framework support
Finally the third contribution, external DI support.
It allows you to use afterburner.fx with your preferred DI framework and not the internal afterburner.fx one.
Adam already thought about such kind of features by allowing to plug in afterburner an external function acting as instance provider for injection points & FXML controllers. This contribution extends this by enhancing a little bit this concept by defining a real InstanceProvider contract allowing to:
- provide Object instances (that’s the first goal isn’t it ;-) )
- bypass afterburner.fx internals for:
- resolution of injection points
Using afterburner.fx with your preferred DI framework is now possible and easy! Here is what you need to do in order to plug CDI (weld-se implementation). You have then the idea if you want to plug other DI framework.
Thank you Adam for providing this stuff to the community.
@AGFA healthcare we are still evaluating if we will finally use this or if we will go for a pure CDI solution, but if you use it with any external DI, please let me and Adam know about that.