I have one class named Class1. I don’t know what are the fields of such class neither but I do know that there are fields in such class that use the annotation @Inject, witch means that such fields need to have Object instances injected. What I do know is that the class has a Default Controller. I use such controller to instantiate the class via newInstance method:
Object class1Object = Class.forName("Class1").newInstance();
The problem is that, The dependencies of the “Class1” are not being injected to the object instance fields and I understand that Its completely normal as I’m instantiating the class manually. I need to get that dependencies injected, so, I need a magic method to do so:
CDI.injectAllDependencies(class1Object);
Any ideas? Please do not expect me to stop instantiating the class manually. My situation requires such approach. Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire