本文整理汇总了Java中com.google.gerrit.lifecycle.LifecycleModule类的典型用法代码示例。如果您正苦于以下问题:Java LifecycleModule类的具体用法?Java LifecycleModule怎么用?Java LifecycleModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LifecycleModule类属于com.google.gerrit.lifecycle包,在下文中一共展示了LifecycleModule类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: module
import com.google.gerrit.lifecycle.LifecycleModule; //导入依赖的package包/类
public static Module module() {
return new CacheModule() {
@Override
protected void configure() {
cache(CACHE_NAME, String.class, ProjectState.class).loader(Loader.class);
cache(CACHE_LIST, ListKey.class, new TypeLiteral<SortedSet<Project.NameKey>>() {})
.maximumWeight(1)
.loader(Lister.class);
bind(ProjectCacheImpl.class);
bind(ProjectCache.class).to(ProjectCacheImpl.class);
install(
new LifecycleModule() {
@Override
protected void configure() {
listener().to(ProjectCacheWarmer.class);
listener().to(ProjectCacheClock.class);
}
});
}
};
}
示例2: configure
import com.google.gerrit.lifecycle.LifecycleModule; //导入依赖的package包/类
@Override
protected void configure() {
bind(PluginUser.class).toInstance(plugin.getPluginUser());
bind(String.class).annotatedWith(PluginName.class).toInstance(plugin.getName());
bind(String.class)
.annotatedWith(PluginCanonicalWebUrl.class)
.toInstance(plugin.getPluginCanonicalWebUrl());
install(
new LifecycleModule() {
@Override
public void configure() {
PluginMetricMaker metrics =
new PluginMetricMaker(
serverMetrics,
MoreObjects.firstNonNull(
plugin.getMetricsPrefix(), String.format("plugins/%s/", plugin.getName())));
bind(MetricMaker.class).toInstance(metrics);
listener().toInstance(metrics);
}
});
}
示例3: configure
import com.google.gerrit.lifecycle.LifecycleModule; //导入依赖的package包/类
@Override
protected void configure() {
List<Module> modules = new ArrayList<>();
modules.add(new LifecycleModule() {
@Override
protected void configure() {
// For bootstrap we need to retrieve the ds type first
CiDataSourceTypeGuesser guesser =
injector.createChildInjector(
new CiDataSourceModule()).getInstance(
Key.get(CiDataSourceTypeGuesser.class));
// For the ds type we retrieve the underlying implementation
CiDataSourceType dst = injector.createChildInjector(
new CiDataSourceModule()).getInstance(
Key.get(CiDataSourceType.class,
Names.named(guesser.guessDataSourceType())));
// Bind the type to the retrieved instance
bind(CiDataSourceType.class).toInstance(dst);
bind(CiDataSourceProvider.Context.class).toInstance(
CiDataSourceProvider.Context.MULTI_USER);
bind(Key.get(DataSource.class, Names.named("CiDb"))).toProvider(
CiDataSourceProvider.class).in(SINGLETON);
listener().to(CiDataSourceProvider.class);
}
});
modules.add(new CiDatabaseModule());
for (Module module : modules) {
install(module);
}
}
示例4: module
import com.google.gerrit.lifecycle.LifecycleModule; //导入依赖的package包/类
public static Module module() {
return new LifecycleModule() {
@Override
protected void configure() {
listener().to(SchemaVersionCheck.class);
}
};
}
示例5: buildInjector
import com.google.gerrit.lifecycle.LifecycleModule; //导入依赖的package包/类
private Injector buildInjector(final Injector parent) {
List<Module> modules = new ArrayList<>();
modules.add(new LifecycleModule() {
@Override
protected void configure() {
// For bootstrap we need to retrieve the ds type first
CiDataSourceTypeGuesser guesser =
parent.createChildInjector(
new CiDataSourceModule()).getInstance(
Key.get(CiDataSourceTypeGuesser.class));
// For the ds type we retrieve the underlying implementation
CiDataSourceType dst = parent.createChildInjector(
new CiDataSourceModule()).getInstance(
Key.get(CiDataSourceType.class,
Names.named(guesser.guessDataSourceType())));
// Bind the type to the retrieved instance
bind(CiDataSourceType.class).toInstance(dst);
bind(CiDataSourceProvider.Context.class).toInstance(
CiDataSourceProvider.Context.MULTI_USER);
bind(Key.get(DataSource.class, Names.named("CiDb"))).toProvider(
CiDataSourceProvider.class).in(SINGLETON);
listener().to(CiDataSourceProvider.class);
}
});
modules.add(new CiDatabaseModule());
modules.add(new AbstractModule() {
@Override
protected void configure() {
bind(SchemaVersion.class).to(SchemaVersion.C);
bind(MetricMaker.class).to(DisabledMetricMaker.class);
}
});
return parent.createChildInjector(modules);
}
示例6: createDbInjector
import com.google.gerrit.lifecycle.LifecycleModule; //导入依赖的package包/类
private Injector createDbInjector() {
final List<Module> modules = new ArrayList<>();
AbstractModule secureStore = createSecureStoreModule();
modules.add(secureStore);
if (sitePath != null) {
Module sitePathModule =
new AbstractModule() {
@Override
protected void configure() {
bind(Path.class).annotatedWith(SitePath.class).toInstance(sitePath);
}
};
modules.add(sitePathModule);
Module configModule = new GerritServerConfigModule();
modules.add(configModule);
Injector cfgInjector = Guice.createInjector(sitePathModule, configModule, secureStore);
Config cfg = cfgInjector.getInstance(Key.get(Config.class, GerritServerConfig.class));
String dbType = cfg.getString("database", null, "type");
final DataSourceType dst =
Guice.createInjector(new DataSourceModule(), configModule, sitePathModule, secureStore)
.getInstance(Key.get(DataSourceType.class, Names.named(dbType.toLowerCase())));
modules.add(
new LifecycleModule() {
@Override
protected void configure() {
bind(DataSourceType.class).toInstance(dst);
bind(DataSourceProvider.Context.class)
.toInstance(DataSourceProvider.Context.MULTI_USER);
bind(Key.get(DataSource.class, Names.named("ReviewDb")))
.toProvider(DataSourceProvider.class)
.in(SINGLETON);
listener().to(DataSourceProvider.class);
}
});
} else {
modules.add(
new LifecycleModule() {
@Override
protected void configure() {
bind(Key.get(DataSource.class, Names.named("ReviewDb")))
.toProvider(ReviewDbDataSourceProvider.class)
.in(SINGLETON);
listener().to(ReviewDbDataSourceProvider.class);
}
});
// If we didn't get the site path from the system property
// we need to get it from the database, as that's our old
// method of locating the site path on disk.
//
modules.add(
new AbstractModule() {
@Override
protected void configure() {
bind(Path.class)
.annotatedWith(SitePath.class)
.toProvider(SitePathFromSystemConfigProvider.class)
.in(SINGLETON);
}
});
modules.add(new GerritServerConfigModule());
}
modules.add(new DatabaseModule());
modules.add(new NotesMigration.Module());
modules.add(new DropWizardMetricMaker.ApiModule());
return Guice.createInjector(PRODUCTION, modules);
}