Initialize Guice after the environment has been set#76
Conversation
|
Does that mean, that we don't need to build our Guice bundle with Edit: |
|
The change is very simple and its only about the time when guice is being initialized. This works for singletons that need the environment, so far nothing broke, but I haven't tested anything else. If I find a moment Ill look into tests from #70. |
|
This almost works but unfortunately breaks an important feature of dropwizard-guice that many people are depending on. You can't just move the call to Over time, however, we've found that auto config actually does more harm than good and we've moved away from it towards a more explicit model (auto config makes it hard/impossible to do conditional binding like this). We have another library, HubSpot/dropwizard-guicier, that doesn't support auto config. It builds the injector during the run phase, runs in |
|
I see... we could not use autoconfig for another reason and maybe for this reason it did not give problems. |
|
Unfortunately I don't think we'll be able to fix this issue in dropwizard-guice, but I'd recommend checking out HubSpot/dropwizard-guicier |
This is a simple way to achieve a lazier initialization of the guice injector. There are no tests that proof the singletons are working correctly. If you are willing to accept the pull request I might add some:).