Mark ApprovalCopier, ApprovalsUtil and LabelNormalizer as singleton
These have no per-request state and are held by several REST API views that are themselves singletons. Instead of making one copy per REST view, make these singletons for the server. Change-Id: I2f343d29c4bed8a862b3794323916ca46b8b1f99
This commit is contained in:
@@ -38,6 +38,7 @@ import com.google.gerrit.server.project.ProjectState;
|
|||||||
import com.google.gerrit.server.query.change.ChangeData;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import org.eclipse.jgit.lib.ObjectId;
|
import org.eclipse.jgit.lib.ObjectId;
|
||||||
import org.eclipse.jgit.lib.Repository;
|
import org.eclipse.jgit.lib.Repository;
|
||||||
@@ -56,6 +57,7 @@ import java.util.TreeMap;
|
|||||||
* database at submit time, or refreshed on demand, as when reading approvals
|
* database at submit time, or refreshed on demand, as when reading approvals
|
||||||
* from the notedb.
|
* from the notedb.
|
||||||
*/
|
*/
|
||||||
|
@Singleton
|
||||||
public class ApprovalCopier {
|
public class ApprovalCopier {
|
||||||
private final GitRepositoryManager repoManager;
|
private final GitRepositoryManager repoManager;
|
||||||
private final ProjectCache projectCache;
|
private final ProjectCache projectCache;
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ import com.google.gerrit.server.project.ChangeControl;
|
|||||||
import com.google.gerrit.server.util.TimeUtil;
|
import com.google.gerrit.server.util.TimeUtil;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -70,6 +71,7 @@ import java.util.Set;
|
|||||||
* <p>
|
* <p>
|
||||||
* The methods in this class only modify the gwtorm database.
|
* The methods in this class only modify the gwtorm database.
|
||||||
*/
|
*/
|
||||||
|
@Singleton
|
||||||
public class ApprovalsUtil {
|
public class ApprovalsUtil {
|
||||||
private static Ordering<PatchSetApproval> SORT_APPROVALS = Ordering.natural()
|
private static Ordering<PatchSetApproval> SORT_APPROVALS = Ordering.natural()
|
||||||
.onResultOf(new Function<PatchSetApproval, Timestamp>() {
|
.onResultOf(new Function<PatchSetApproval, Timestamp>() {
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import com.google.gerrit.server.IdentifiedUser;
|
|||||||
import com.google.gerrit.server.project.ChangeControl;
|
import com.google.gerrit.server.project.ChangeControl;
|
||||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -46,6 +47,7 @@ import java.util.List;
|
|||||||
* is originally made and a later point, for example when a change is submitted.
|
* is originally made and a later point, for example when a change is submitted.
|
||||||
* This class normalizes old votes against current project configuration.
|
* This class normalizes old votes against current project configuration.
|
||||||
*/
|
*/
|
||||||
|
@Singleton
|
||||||
public class LabelNormalizer {
|
public class LabelNormalizer {
|
||||||
public static class Result {
|
public static class Result {
|
||||||
private final ImmutableList<PatchSetApproval> unchanged;
|
private final ImmutableList<PatchSetApproval> unchanged;
|
||||||
|
|||||||
Reference in New Issue
Block a user