Tuesday, December 6, 2016

CDI context dependency injection

CDI is a powerful concept, but as usual implementation is pathetic (Spring, Java EE, whatever).
Annotations make code less readable, they leak concern, are extremely hard to debug (ever tried to find out why one of your references if not getting injected?). Read this excellent article https://www.javacodegeeks.com/2016/11/java-annotations-big-mistake.html
XML is easily broken, has to be mostly manually maintained, quickly becomes unmanageable and unstructured.
I still prefer a pure coded approach, where dependencies and injected by an "injector" bean, but in a Java EE container this would not retain the specific features of the bean. So it's not a choice available for now (maybe yes, I should investigate)

This is a quite decent introduction on CDI in a Java EE (CDI) container:









No comments: