public void run()

in src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/InitPlugin.java [85:119]


  public void run() throws Exception {
    ui.header("SQL Database for CI plugin");

    Set<String> allowedValues = Sets.newTreeSet();
    Injector i = Guice.createInjector(PRODUCTION, new DatabaseConfigModule(site));

    List<Binding<DatabaseConfigInitializer>> dbConfigBindings =
        i.findBindingsByType(new TypeLiteral<DatabaseConfigInitializer>() {});
    for (Binding<DatabaseConfigInitializer> binding : dbConfigBindings) {
      Annotation annotation = binding.getKey().getAnnotation();
      if (annotation instanceof Named) {
        allowedValues.add(((Named) annotation).value());
      }
    }

    if (!Strings.isNullOrEmpty(configSection.get("dbUrl"))
        && Strings.isNullOrEmpty(configSection.get("dbType"))) {
      configSection.set("dbType", "h2");
    }

    String dbType = configSection.select("Database server type", "dbType", "h2", allowedValues);

    DatabaseConfigInitializer dci =
        i.getInstance(Key.get(DatabaseConfigInitializer.class, Names.named(dbType.toLowerCase())));

    /**
     * TODO(davido): We probably don't need that, as CI database would be from the same type as
     * ReviewDb. So we expect that the needed libraries were already installed.
     *
     * <p>if (dci instanceof MySqlInitializer) { libraries.mysqlDriver.downloadRequired(); } else if
     * (dci instanceof OracleInitializer) { libraries.oracleDriver.downloadRequired(); } else if
     * (dci instanceof DB2Initializer) { libraries.db2Driver.downloadRequired(); }
     */
    dci.initConfig(configSection);
  }