當前位置: 首頁>>代碼示例>>Java>>正文


Java LifecycleModule類代碼示例

本文整理匯總了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);
            }
          });
    }
  };
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:25,代碼來源:ProjectCacheImpl.java

示例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);
        }
      });
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:23,代碼來源:ServerPluginInfoModule.java

示例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);
  }
}
 
開發者ID:davido,項目名稱:gerrit-ci-plugin,代碼行數:32,代碼來源:GlobalModule.java

示例4: module

import com.google.gerrit.lifecycle.LifecycleModule; //導入依賴的package包/類
public static Module module() {
  return new LifecycleModule() {
    @Override
    protected void configure() {
      listener().to(SchemaVersionCheck.class);
    }
  };
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:9,代碼來源:SchemaVersionCheck.java

示例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);
}
 
開發者ID:davido,項目名稱:gerrit-ci-plugin,代碼行數:42,代碼來源:InitPlugin.java

示例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);
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:72,代碼來源:WebAppInitializer.java


注:本文中的com.google.gerrit.lifecycle.LifecycleModule類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。