I have a Class with fields annotated with @Inject. I instantiate the Class using reflection, but I want the CDI to inject instances to do the Class instance fields. Is there a way of doing it?
Object myInstanceWithDependecies = Class.forName(“com.package.MyClass").newInstance();
CDI.injectAll(myInstanceWithDependecies);//This is what i want
Does someone know how to do this? I would appreciate if there was a way of doing it without scanning each field using reflection.
Thanks in advance.
This gets the Job done
SomeBean bean = CDI.current().select(SomeBean.class).get();