First of all I would not inject a model. Model classes are not
meant to be handled with DI.
Second you can use assisted injection to use constructor injection
if you have both parameters and dependencies in a constructor.
Non of the above helps clarify you question. But maybe it helps you think about your design.
Regarding your code:
Guice has no hidden mechanism which magically does things if you
do not ask for it.
So after your framework has called injectMembers() guice will not
change the controller unless your ask it to do it again.
I assume there is no other code which will later set the model
back to null.
This boils it down to one most likely scenario"
Something happens before your framework calls injectMembers().
This something triggers the listener.propertyChange() method.
To be able to debug this a little better I would suggest that you
add a setter for model and annotate the setter method with @Inject
instead of the field.
This way you can add a breakpoint (and/or log output) to the
setter. Do the same with the init() and the propertyChange()
method and watch carefully in which order they are called.
Another less likely scenario is that you have more than one instance of MyController. In one instance you have a model and in the other instance model is null.
If you code is open source I can have a look into the issue
--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice...@googlegroups.com.
To post to this group, send email to google...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/e66a5a5e-5fad-4605-9ae7-71b2634212d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
First of all I would not inject a model. Model classes are not meant to be handled with DI.
Second you can use assisted injection to use constructor injection if you have both parameters and dependencies in a constructor.
Something happens before your framework calls injectMembers(). This something triggers the listener.propertyChange() method.