Add extension point to register JGit PostUploadHooks

Plugins may register PostUploadHook instances in order to get notified
after JGit is done uploading a pack.

Now that PostUploadHook can be registered using the DynamicSet, use that
mechanism to register UploadPackMetricsHook.

Change-Id: If848bddc85ca8923a5d55f7dd448ac218c910e1c
This commit is contained in:
Hugo Arès
2016-08-02 15:26:57 -04:00
parent 7acf5164ba
commit 41b4c0d3da
5 changed files with 28 additions and 11 deletions

View File

@@ -173,6 +173,7 @@ import com.google.inject.internal.UniqueAnnotations;
import org.apache.velocity.runtime.RuntimeInstance;
import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.transport.PostReceiveHook;
import org.eclipse.jgit.transport.PostUploadHook;
import org.eclipse.jgit.transport.PreUploadHook;
import java.util.List;
@@ -314,6 +315,7 @@ public class GerritGlobalModule extends FactoryModule {
DynamicSet.setOf(binder(), ReceivePackInitializer.class);
DynamicSet.setOf(binder(), PostReceiveHook.class);
DynamicSet.setOf(binder(), PreUploadHook.class);
DynamicSet.setOf(binder(), PostUploadHook.class);
DynamicSet.setOf(binder(), ChangeIndexedListener.class);
DynamicSet.setOf(binder(), NewProjectCreatedListener.class);
DynamicSet.setOf(binder(), ProjectDeletedListener.class);

View File

@@ -15,6 +15,9 @@
package com.google.gerrit.server.git;
import com.google.gerrit.extensions.config.FactoryModule;
import com.google.gerrit.extensions.registration.DynamicSet;
import org.eclipse.jgit.transport.PostUploadHook;
/** Configures the Git support. */
public class GitModule extends FactoryModule {
@@ -24,5 +27,7 @@ public class GitModule extends FactoryModule {
factory(MetaDataUpdate.InternalFactory.class);
bind(MetaDataUpdate.Server.class);
bind(ReceiveConfig.class);
DynamicSet.bind(binder(), PostUploadHook.class)
.to(UploadPackMetricsHook.class);
}
}