if (null == contextProvider) {
throw new IllegalStateException("ContextProvider is not available");
}
final InjectorWithContext injector = injectorsRepository
.getInjector(applicationName);
if (injector == null) {
throw new IllegalStateException("Guice injector not found: "
+ applicationName);
}
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();
}
}