if (null == contextProvider) {
throw new IllegalStateException("ContextProvider is not available");
}
final InjectorWithContext injector = injectorsRepository.getInjector(injectorName);
if (injector == null) {
throw new IllegalStateException("Guice injector not found: " + injectorName);
}
injector.pushContextProvider(contextProvider);
try {
final ModelProvider modelProvider = injector.getInstance(ModelProvider.class);
final Resource resource = request.getResource();
return (T) modelProvider.get(type, resource);
} finally {
injector.popContextProvider();
}
}