-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dependency-Injection for superclasses..... #65
Comments
+1 |
Additionally the injection context is applied after the injector has already instantiated default objects for injectable fields, which has the additional problem that if field is an interface or an abstract class the injectors default instance supplier falls over when it tries to instantiate the field throwing an IllegalStateException exception. Obviously you can set the instance supplier on the injector, but I think that only really solves it for fields that represent services. So we have:
I have a fix for 1) & 2) that also allows you to work around 3) by supplying an appropriate candidate in the injection context. The fix #85 works by passing the injection context to the injectMembers method which then prioritizes the injectionContext over the configurator and default instantiation. Note that the original injectMembers method has been preserved for backwards compatability. Modified instantiatePresenter, now performs field injection in one pass
Original method that now calls new injectMembers with an null injectionContext
New (reworked injectMembers) now takes an injectionContext, which is also propagated to super classes.
|
The current implementation of method
public static T instantiatePresenter(Class clazz, Function<String, Object> injectionContext)
in class "Injector" does not apply the injectionContext to superclasses of the passed controller-class "clazz".
Maybe it is possible to also inject superclass-fields like has been implemented in method
public static void injectMembers(Class<? extends Object> clazz, final Object instance) ????
Regards
Axel
The text was updated successfully, but these errors were encountered: