in src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java [138:220]
protected Source(
Injector injector,
@Assisted SourceConfiguration cfg,
PluginUser pluginUser,
GitRepositoryManager gitRepositoryManager,
PermissionBackend permissionBackend,
Provider<CurrentUser> userProvider,
ProjectCache projectCache,
GroupBackend groupBackend,
ReplicationStateListeners stateLog,
GroupIncludeCache groupIncludeCache,
DynamicItem<EventDispatcher> eventDispatcher) {
config = cfg;
this.eventDispatcher = eventDispatcher;
gitManager = gitRepositoryManager;
this.permissionBackend = permissionBackend;
this.userProvider = userProvider;
this.projectCache = projectCache;
this.stateLog = stateLog;
CurrentUser remoteUser;
if (!cfg.getAuthGroupNames().isEmpty()) {
Builder<AccountGroup.UUID> builder = ImmutableSet.builder();
for (String name : cfg.getAuthGroupNames()) {
GroupReference g = GroupBackends.findExactSuggestion(groupBackend, name);
if (g != null) {
builder.add(g.getUUID());
addRecursiveParents(g.getUUID(), builder, groupIncludeCache);
} else {
repLog.warn("Group \"{}\" not recognized, removing from authGroup", name);
}
}
remoteUser = new RemoteSiteUser(new ListGroupMembership(builder.build()));
} else {
remoteUser = pluginUser;
}
Injector child =
injector.createChildInjector(
new FactoryModule() {
@Override
protected void configure() {
bindScope(RequestScoped.class, PerThreadRequestScope.REQUEST);
bind(PerThreadRequestScope.Propagator.class);
bind(Source.class).toInstance(Source.this);
bind(SourceConfiguration.class).toInstance(config);
install(new FactoryModuleBuilder().build(FetchOne.Factory.class));
install(new FactoryModuleBuilder().build(DeleteProjectTask.Factory.class));
Class<? extends Fetch> clientClass =
cfg.useCGitClient() ? CGitFetch.class : JGitFetch.class;
install(
new FactoryModuleBuilder()
.implement(Fetch.class, BatchFetchClient.class)
.implement(Fetch.class, FetchClientImplementation.class, clientClass)
.build(FetchFactory.class));
factory(UpdateHeadTask.Factory.class);
}
@Provides
public PerThreadRequestScope.Scoper provideScoper(
final PerThreadRequestScope.Propagator propagator) {
final RequestContext requestContext =
new RequestContext() {
@Override
public CurrentUser getUser() {
return remoteUser;
}
};
return new PerThreadRequestScope.Scoper() {
@Override
public <T> Callable<T> scope(Callable<T> callable) {
return propagator.scope(requestContext, callable);
}
};
}
});
child.getBinding(FetchFactory.class).acceptTargetVisitor(new CGitFetchValidator());
opFactory = child.getInstance(FetchOne.Factory.class);
threadScoper = child.getInstance(PerThreadRequestScope.Scoper.class);
deleteProjectFactory = child.getInstance(DeleteProjectTask.Factory.class);
updateHeadFactory = child.getInstance(UpdateHeadTask.Factory.class);
}