Hi : I want to run an operation immediately after Guice "hydrates" my class with the necessary parameters. What is the idiomatic way to do this ? Is there an @after_running_constructor annotation... or something of the sort, that i can tag a "post-guice" initializer method ?
Normally, I would simply do this in an init() method or in the constructor itself, but it turns out that Guice is not injecting the necessary information into my class until the class's constructor has been run.
The only idiomatic way to make sure that your class got all the necessary "parameters" is to pass those parameters to the constructor. See a short discussion about mutability here.
If you have trouble to use constructor injection because the construction involve both injection and parameterization, you can either use the factory pattern, or AssistedInject.
If to wire some domain classes you need to be aware of Guice internals, my guess is that your approach should be revisited.
Guice does not have support for lifecycle methods. A similar question was asked here, and people there recommended the Guice extended library GuiceyFruit, but I'm not sure that project is being maintained any longer.
Also, the order that Guice injects is defined in the docs here.
I'm curious, why would you do both constructor and method injection for your class? I'm sure there are some use cases, but you could solve the init() problem by simply using solely constructor injection.