Install DefaultPermissionBackendModule at daemon level

Move the binding out of GerritGlobalModule so it's part of the daemons,
making it easier to swap to a different PermissionBackend.

Expose DefaultPermissionBackend class as public so another backend
could wrap and delegate to DefaultPermissionBackend by accepting it
as an argument to its constructor.

Change-Id: I01f10d8a65d8942e73354bcf055c26b17d2606f9
This commit is contained in:
Shawn Pearce
2017-04-28 11:27:31 +02:00
parent 78c4343e77
commit 0c80f2a6c3
6 changed files with 21 additions and 9 deletions

View File

@@ -160,7 +160,6 @@ import com.google.gerrit.server.patch.PatchSetInfoFactory;
import com.google.gerrit.server.plugins.ReloadPluginListener;
import com.google.gerrit.server.project.AccessControlModule;
import com.google.gerrit.server.project.CommentLinkProvider;
import com.google.gerrit.server.project.DefaultPermissionBackendModule;
import com.google.gerrit.server.project.PermissionCollection;
import com.google.gerrit.server.project.ProjectCacheImpl;
import com.google.gerrit.server.project.ProjectNode;
@@ -230,7 +229,6 @@ public class GerritGlobalModule extends FactoryModule {
install(new AccessControlModule());
install(new CmdLineParserModule());
install(new DefaultPermissionBackendModule());
install(new EmailModule());
install(new ExternalIdModule());
install(new GitModule());

View File

@@ -32,7 +32,7 @@ import java.util.EnumSet;
import java.util.Set;
@Singleton
class DefaultPermissionBackend extends PermissionBackend {
public class DefaultPermissionBackend extends PermissionBackend {
private final ProjectCache projectCache;
@Inject

View File

@@ -16,18 +16,26 @@ package com.google.gerrit.server.project;
import com.google.gerrit.extensions.config.FactoryModule;
import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.inject.AbstractModule;
import com.google.inject.Scopes;
/** Binds the default {@link PermissionBackend}. */
public class DefaultPermissionBackendModule extends FactoryModule {
public class DefaultPermissionBackendModule extends AbstractModule {
@Override
protected void configure() {
bind(PermissionBackend.class).to(DefaultPermissionBackend.class).in(Scopes.SINGLETON);
install(new LegacyControlsModule());
}
// TODO(sop) Hide ProjectControl, RefControl, ChangeControl related bindings.
bind(ProjectControl.GenericFactory.class);
factory(ProjectControl.AssistedFactory.class);
bind(ChangeControl.GenericFactory.class);
bind(ChangeControl.Factory.class);
/** Binds legacy ProjectControl, RefControl, ChangeControl. */
public static class LegacyControlsModule extends FactoryModule {
@Override
protected void configure() {
// TODO(sop) Hide ProjectControl, RefControl, ChangeControl related bindings.
bind(ProjectControl.GenericFactory.class);
factory(ProjectControl.AssistedFactory.class);
bind(ChangeControl.GenericFactory.class);
bind(ChangeControl.Factory.class);
}
}
}