Move EventHandler binding from lib module to plugin module

Lib module binding happens before the plugins bindings. This means
that all EventsListeners defined in lib modules are executed before
EventsListeners defined in plugin module.

When multi-site works with pull-replication or other plugins,
the EventHandler listener should be executed respecting the priority
of loading and execution of the plugins, defined by the plugin filename
alphabetical ordering.

Historically, for sake of simplicity, the EventModule was put inside the
libModule of the multi-site, even if it was originally as part of the plugin
module. There is no special reason for the EventModule to be loaded
early on as libModule, and there are even drawbacks on the plugin
priority execution.

Move back the EventModule where it was originally.

Change-Id: I02355a50c896e7b971686873f46d8e3917ce6630
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/Module.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/Module.java
index afdb41c..9392077 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/Module.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/Module.java
@@ -21,7 +21,6 @@
 import com.google.inject.spi.Message;
 import com.googlesource.gerrit.plugins.multisite.broker.BrokerModule;
 import com.googlesource.gerrit.plugins.multisite.cache.CacheModule;
-import com.googlesource.gerrit.plugins.multisite.event.EventModule;
 import com.googlesource.gerrit.plugins.multisite.forwarder.ForwarderModule;
 import com.googlesource.gerrit.plugins.multisite.forwarder.router.RouterModule;
 import com.googlesource.gerrit.plugins.multisite.index.IndexModule;
@@ -56,7 +55,6 @@
       brokerRouterNeeded = true;
     }
     if (config.event().synchronize()) {
-      install(new EventModule(config));
       brokerRouterNeeded = true;
     }
     if (config.index().synchronize()) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/PluginModule.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/PluginModule.java
index c650691..db06c9f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/PluginModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/PluginModule.java
@@ -30,6 +30,7 @@
 import com.googlesource.gerrit.plugins.multisite.consumer.MultiSiteConsumerRunner;
 import com.googlesource.gerrit.plugins.multisite.consumer.ReplicationStatusModule;
 import com.googlesource.gerrit.plugins.multisite.consumer.SubscriberModule;
+import com.googlesource.gerrit.plugins.multisite.event.EventModule;
 import com.googlesource.gerrit.plugins.multisite.forwarder.broker.BrokerForwarderModule;
 
 public class PluginModule extends LifecycleModule {
@@ -56,10 +57,10 @@
 
   @Override
   protected void configure() {
-
     if (config.index().synchronize()
         || config.cache().synchronize()
         || config.event().synchronize()) {
+      install(new EventModule(config));
       bind(BrokerApiWrapper.class).in(Scopes.SINGLETON);
       install(new SubscriberModule());