-
-
Notifications
You must be signed in to change notification settings - Fork 202
Closed
Labels
Milestone
Description
Hello,
Just updated to Jooby 4, and noticed that the dependency injection for Provider<Context> fails.
I think I found the root cause:
- The
GuiceModuleis alateInitmodule - It creates the injector by adding
JoobyModuleas well - The
JoobyModuleadds the registered services to the DI container - The
ContextAsServiceInitializeris applied byRouterImpl::start - The problem is that the Guice module is installed before the router is started, thus the
Contextprovider is not yet available in the registry, thus will not be available through DI.
Do you have any suggestion how we should proceed?
We created a helper Guice module as a workaround:
public class JoobyContextGuiceModule extends AbstractModule {
@Override
protected void configure() {
bind(Context.class).toProvider(ContextAsServiceInitializer.INSTANCE);
}
}