use of com.google.inject.Provider in project che by eclipse.
the class ImportProjectWizardPresenter method getWizardForImporter.
/** Creates or returns import wizard for the specified importer. */
private ImportWizard getWizardForImporter(@NotNull ProjectImporterDescriptor importer) {
if (wizardsCache.containsKey(importer)) {
return wizardsCache.get(importer);
}
final ImportWizardRegistrar wizardRegistrar = wizardRegistry.getWizardRegistrar(importer.getId());
if (wizardRegistrar == null) {
// should never occur
throw new IllegalStateException("WizardRegistrar for the importer " + importer.getId() + " isn't registered.");
}
List<Provider<? extends WizardPage<MutableProjectConfig>>> pageProviders = wizardRegistrar.getWizardPages();
final ImportWizard importWizard = createDefaultWizard();
for (Provider<? extends WizardPage<MutableProjectConfig>> provider : pageProviders) {
importWizard.addPage(provider.get(), 1, false);
}
wizardsCache.put(importer, importWizard);
return importWizard;
}
use of com.google.inject.Provider in project nhin-d by DirectProject.
the class NHINDSecurityAndTrustMailet method getServiceSecurityManagerProvider.
/**
* Gets a custom service security manager provider. If this is null, the system will us a default provider.
* @return Gets a service security manager provider.
*/
protected Provider<ServiceSecurityManager> getServiceSecurityManagerProvider() {
Provider<ServiceSecurityManager> retVal = null;
String providerClazz = GatewayConfiguration.getConfigurationParam(SecurityAndTrustMailetOptions.SERVICE_SECURITY_MANAGER_PROVIDER, this, "");
if (providerClazz != null && !providerClazz.isEmpty()) {
try {
// create an instance of the provider
@SuppressWarnings("unchecked") Class<Provider<ServiceSecurityManager>> clazz = (Class<Provider<ServiceSecurityManager>>) getClass().getClassLoader().loadClass(providerClazz);
retVal = clazz.newInstance();
} catch (Exception e) {
LOGGER.warn("Failed to load service security manager provider class " + providerClazz + ": " + e.getMessage(), e);
retVal = new OpenServiceSecurityManagerProvider();
}
} else {
retVal = new OpenServiceSecurityManagerProvider();
}
if (retVal instanceof MailetAwareProvider)
((MailetAwareProvider) retVal).setMailet(this);
return retVal;
}
use of com.google.inject.Provider in project gerrit by GerritCodeReview.
the class Daemon method createSysInjector.
private Injector createSysInjector() {
final List<Module> modules = new ArrayList<>();
modules.add(SchemaVersionCheck.module());
modules.add(new DropWizardMetricMaker.RestModule());
modules.add(new LogFileCompressor.Module());
// Index module shutdown must happen before work queue shutdown, otherwise
// work queue can get stuck waiting on index futures that will never return.
modules.add(createIndexModule());
modules.add(new WorkQueue.Module());
modules.add(new StreamEventsApiListener.Module());
modules.add(new EventBroker.Module());
modules.add(test ? new H2AccountPatchReviewStore.InMemoryModule() : new JdbcAccountPatchReviewStore.Module(config));
modules.add(new ReceiveCommitsExecutorModule());
modules.add(new DiffExecutorModule());
modules.add(new MimeUtil2Module());
modules.add(cfgInjector.getInstance(GerritGlobalModule.class));
modules.add(new SearchingChangeCacheImpl.Module(slave));
modules.add(new InternalAccountDirectory.Module());
modules.add(new DefaultPermissionBackendModule());
modules.add(new DefaultCacheFactory.Module());
modules.add(cfgInjector.getInstance(MailReceiver.Module.class));
if (emailModule != null) {
modules.add(emailModule);
} else {
modules.add(new SmtpEmailSender.Module());
}
modules.add(new SignedTokenEmailTokenVerifier.Module());
modules.add(new PluginRestApiModule());
modules.add(new RestCacheAdminModule());
modules.add(new GpgModule(config));
modules.add(new StartupChecks.Module());
if (MoreObjects.firstNonNull(httpd, true)) {
modules.add(new CanonicalWebUrlModule() {
@Override
protected Class<? extends Provider<String>> provider() {
return HttpCanonicalWebUrlProvider.class;
}
});
} else {
modules.add(new CanonicalWebUrlModule() {
@Override
protected Class<? extends Provider<String>> provider() {
return CanonicalWebUrlProvider.class;
}
});
}
if (sshd) {
modules.add(SshKeyCacheImpl.module());
} else {
modules.add(NoSshKeyCache.module());
}
modules.add(new AbstractModule() {
@Override
protected void configure() {
bind(GerritOptions.class).toInstance(new GerritOptions(config, headless, slave, polyGerritDev));
if (test) {
bind(String.class).annotatedWith(SecureStoreClassName.class).toInstance(DefaultSecureStore.class.getName());
bind(SecureStore.class).toProvider(SecureStoreProvider.class);
}
}
});
modules.add(new GarbageCollectionModule());
if (!slave) {
modules.add(new ChangeCleanupRunner.Module());
}
return cfgInjector.createChildInjector(modules);
}
use of com.google.inject.Provider in project gerrit by GerritCodeReview.
the class OAuthWebFilter method selectProvider.
private void selectProvider(HttpServletRequest req, HttpServletResponse res, @Nullable String errorMessage) throws IOException {
String self = req.getRequestURI();
String cancel = MoreObjects.firstNonNull(urlProvider != null ? urlProvider.get() : "/", "/");
cancel += LoginUrlToken.getToken(req);
Document doc = header.parse(OAuthWebFilter.class, "LoginForm.html");
HtmlDomUtil.find(doc, "hostName").setTextContent(req.getServerName());
HtmlDomUtil.find(doc, "login_form").setAttribute("action", self);
HtmlDomUtil.find(doc, "cancel_link").setAttribute("href", cancel);
Element emsg = HtmlDomUtil.find(doc, "error_message");
if (Strings.isNullOrEmpty(errorMessage)) {
emsg.getParentNode().removeChild(emsg);
} else {
emsg.setTextContent(errorMessage);
}
Element providers = HtmlDomUtil.find(doc, "providers");
Set<String> plugins = oauthServiceProviders.plugins();
for (String pluginName : plugins) {
Map<String, Provider<OAuthServiceProvider>> m = oauthServiceProviders.byPlugin(pluginName);
for (Map.Entry<String, Provider<OAuthServiceProvider>> e : m.entrySet()) {
addProvider(providers, pluginName, e.getKey(), e.getValue().get().getName());
}
}
sendHtml(res, doc);
}
use of com.google.inject.Provider in project gerrit by GerritCodeReview.
the class Schema_150_to_151_Test method setUp.
@Before
public void setUp() throws Exception {
Injector injector = Guice.createInjector(new InMemoryModule());
injector.injectMembers(this);
lifecycle = new LifecycleManager();
lifecycle.add(injector);
lifecycle.start();
try (ReviewDb underlyingDb = inMemoryDatabase.getDatabase().open()) {
schemaCreator.create(underlyingDb);
}
db = schemaFactory.open();
Account.Id userId = accountManager.authenticate(AuthRequest.forUser("user")).getAccountId();
IdentifiedUser user = userFactory.create(userId);
requestContext.setContext(new RequestContext() {
@Override
public CurrentUser getUser() {
return user;
}
@Override
public Provider<ReviewDb> getReviewDbProvider() {
return Providers.of(db);
}
});
}
Aggregations