protected void configure()

in src/main/java/com/googlesource/gerrit/plugins/replication/pull/PullReplicationModule.java [70:136]


  protected void configure() {

    bind(RevisionReader.class).in(Scopes.SINGLETON);
    bind(ApplyObject.class);

    install(new PullReplicationApiModule());

    install(new FetchRefReplicatedEventModule());

    install(
        new FactoryModuleBuilder()
            .implement(HttpClient.class, SourceHttpClient.class)
            .build(SourceHttpClient.Factory.class));

    install(new FactoryModuleBuilder().build(Source.Factory.class));
    install(new FactoryModuleBuilder().build(FetchRestApiClient.Factory.class));

    bind(FetchReplicationMetrics.class).in(Scopes.SINGLETON);

    bind(OnStartStop.class).in(Scopes.SINGLETON);
    bind(LifecycleListener.class).annotatedWith(UniqueAnnotations.create()).to(OnStartStop.class);
    bind(LifecycleListener.class)
        .annotatedWith(UniqueAnnotations.create())
        .to(PullReplicationLogFile.class);
    bind(CredentialsFactory.class)
        .to(AutoReloadSecureCredentialsFactoryDecorator.class)
        .in(Scopes.SINGLETON);
    bind(CapabilityDefinition.class)
        .annotatedWith(Exports.named(START_REPLICATION))
        .to(StartReplicationCapability.class);

    install(new FactoryModuleBuilder().build(FetchAll.Factory.class));
    install(new FactoryModuleBuilder().build(ReplicationState.Factory.class));

    bind(EventBus.class).in(Scopes.SINGLETON);
    bind(ReplicationSources.class).to(SourcesCollection.class);
    DynamicSet.bind(binder(), ProjectDeletedListener.class).to(ReplicationQueue.class);
    DynamicSet.bind(binder(), HeadUpdatedListener.class).to(ReplicationQueue.class);

    bind(ReplicationQueue.class).in(Scopes.SINGLETON);
    bind(ObservableQueue.class).to(ReplicationQueue.class);
    bind(LifecycleListener.class)
        .annotatedWith(UniqueAnnotations.create())
        .to(ReplicationQueue.class);

    DynamicSet.bind(binder(), GitReferenceUpdatedListener.class).to(ReplicationQueue.class);

    bind(ConfigParser.class).to(SourceConfigParser.class).in(Scopes.SINGLETON);

    if (getReplicationConfig().getBoolean("gerrit", "autoReload", false)) {
      bind(ReplicationConfig.class)
          .annotatedWith(MainReplicationConfig.class)
          .to(getReplicationConfigClass());
      bind(ReplicationConfig.class).to(AutoReloadConfigDecorator.class).in(Scopes.SINGLETON);
      bind(LifecycleListener.class)
          .annotatedWith(UniqueAnnotations.create())
          .to(AutoReloadConfigDecorator.class);
    } else {
      bind(ReplicationConfig.class).to(getReplicationConfigClass()).in(Scopes.SINGLETON);
    }

    DynamicSet.setOf(binder(), ReplicationStateListener.class);
    DynamicSet.bind(binder(), ReplicationStateListener.class).to(PullReplicationStateLogger.class);
    EventTypes.register(FetchRefReplicatedEvent.TYPE, FetchRefReplicatedEvent.class);
    EventTypes.register(FetchRefReplicationDoneEvent.TYPE, FetchRefReplicationDoneEvent.class);
    EventTypes.register(FetchReplicationScheduledEvent.TYPE, FetchReplicationScheduledEvent.class);
  }