Make RestApiModule inherit FactoryModule
This saves some typing in modules that need to do both things. Change-Id: If5f343cc7081a39a23707e4f60eed60d04b8966d
This commit is contained in:
@@ -16,14 +16,14 @@ package com.google.gerrit.extensions.restapi;
|
||||
|
||||
import com.google.gerrit.extensions.annotations.Export;
|
||||
import com.google.gerrit.extensions.annotations.Exports;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.gerrit.extensions.config.FactoryModule;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.binder.LinkedBindingBuilder;
|
||||
import com.google.inject.binder.ScopedBindingBuilder;
|
||||
|
||||
/** Guice DSL for binding {@link RestView} implementations. */
|
||||
public abstract class RestApiModule extends AbstractModule {
|
||||
public abstract class RestApiModule extends FactoryModule {
|
||||
protected static final String GET = "GET";
|
||||
protected static final String PUT = "PUT";
|
||||
protected static final String DELETE = "DELETE";
|
||||
|
@@ -23,7 +23,6 @@ import static com.google.gerrit.server.account.AccountResource.STARRED_CHANGE_KI
|
||||
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
import com.google.gerrit.extensions.restapi.RestApiModule;
|
||||
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
||||
|
||||
public class Module extends RestApiModule {
|
||||
@Override
|
||||
@@ -85,7 +84,7 @@ public class Module extends RestApiModule {
|
||||
delete(STARRED_CHANGE_KIND).to(StarredChanges.Delete.class);
|
||||
bind(StarredChanges.Create.class);
|
||||
|
||||
install(new FactoryModuleBuilder().build(CreateAccount.Factory.class));
|
||||
install(new FactoryModuleBuilder().build(CreateEmail.Factory.class));
|
||||
factory(CreateAccount.Factory.class);
|
||||
factory(CreateEmail.Factory.class);
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,6 @@ import static com.google.gerrit.server.change.FileResource.FILE_KIND;
|
||||
import static com.google.gerrit.server.change.ReviewerResource.REVIEWER_KIND;
|
||||
import static com.google.gerrit.server.change.RevisionResource.REVISION_KIND;
|
||||
|
||||
import com.google.gerrit.extensions.config.FactoryModule;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
import com.google.gerrit.extensions.restapi.RestApiModule;
|
||||
import com.google.gerrit.server.account.AccountLoader;
|
||||
@@ -119,17 +118,12 @@ public class Module extends RestApiModule {
|
||||
get(CHANGE_EDIT_KIND, "/").to(ChangeEdits.Get.class);
|
||||
get(CHANGE_EDIT_KIND, "meta").to(ChangeEdits.GetMeta.class);
|
||||
|
||||
install(new FactoryModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
factory(ReviewerResource.Factory.class);
|
||||
factory(AccountLoader.Factory.class);
|
||||
factory(EmailReviewComments.Factory.class);
|
||||
factory(ChangeInserter.Factory.class);
|
||||
factory(PatchSetInserter.Factory.class);
|
||||
factory(ChangeEdits.Create.Factory.class);
|
||||
factory(ChangeEdits.DeleteFile.Factory.class);
|
||||
}
|
||||
});
|
||||
factory(ReviewerResource.Factory.class);
|
||||
factory(AccountLoader.Factory.class);
|
||||
factory(EmailReviewComments.Factory.class);
|
||||
factory(ChangeInserter.Factory.class);
|
||||
factory(PatchSetInserter.Factory.class);
|
||||
factory(ChangeEdits.Create.Factory.class);
|
||||
factory(ChangeEdits.DeleteFile.Factory.class);
|
||||
}
|
||||
}
|
||||
|
@@ -26,7 +26,6 @@ import com.google.gerrit.server.group.AddIncludedGroups.UpdateIncludedGroup;
|
||||
import com.google.gerrit.server.group.AddMembers.UpdateMember;
|
||||
import com.google.gerrit.server.group.DeleteIncludedGroups.DeleteIncludedGroup;
|
||||
import com.google.gerrit.server.group.DeleteMembers.DeleteMember;
|
||||
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
||||
|
||||
public class Module extends RestApiModule {
|
||||
@Override
|
||||
@@ -67,7 +66,7 @@ public class Module extends RestApiModule {
|
||||
put(INCLUDED_GROUP_KIND).to(UpdateIncludedGroup.class);
|
||||
delete(INCLUDED_GROUP_KIND).to(DeleteIncludedGroup.class);
|
||||
|
||||
install(new FactoryModuleBuilder().build(CreateGroup.Factory.class));
|
||||
factory(CreateGroup.Factory.class);
|
||||
|
||||
DynamicSet.bind(binder(), GroupMemberAuditListener.class).to(
|
||||
DbGroupMemberAuditListener.class);
|
||||
|
@@ -24,7 +24,6 @@ import static com.google.gerrit.server.project.TagResource.TAG_KIND;
|
||||
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
import com.google.gerrit.extensions.restapi.RestApiModule;
|
||||
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
||||
|
||||
public class Module extends RestApiModule {
|
||||
@Override
|
||||
@@ -65,7 +64,7 @@ public class Module extends RestApiModule {
|
||||
get(BRANCH_KIND).to(GetBranch.class);
|
||||
delete(BRANCH_KIND).to(DeleteBranch.class);
|
||||
post(PROJECT_KIND, "branches:delete").to(DeleteBranches.class);
|
||||
install(new FactoryModuleBuilder().build(CreateBranch.Factory.class));
|
||||
factory(CreateBranch.Factory.class);
|
||||
get(BRANCH_KIND, "reflog").to(GetReflog.class);
|
||||
child(BRANCH_KIND, "files").to(FilesCollection.class);
|
||||
get(FILE_KIND, "content").to(GetContent.class);
|
||||
@@ -81,7 +80,7 @@ public class Module extends RestApiModule {
|
||||
get(DASHBOARD_KIND).to(GetDashboard.class);
|
||||
put(DASHBOARD_KIND).to(SetDashboard.class);
|
||||
delete(DASHBOARD_KIND).to(DeleteDashboard.class);
|
||||
install(new FactoryModuleBuilder().build(CreateProject.Factory.class));
|
||||
factory(CreateProject.Factory.class);
|
||||
|
||||
get(PROJECT_KIND, "config").to(GetConfig.class);
|
||||
put(PROJECT_KIND, "config").to(PutConfig.class);
|
||||
|
Reference in New Issue
Block a user