BrokerApi dynamic item setup BrokerApi dynamic item setup is provided by events-broker library. This change allows standalone setup of websession-broker. Feature: Issue 11600 Change-Id: Ic81902ab30112858c3b9417ac763db4c2509dee4
diff --git a/BUILD b/BUILD index cdd7f31..f0fff60 100644 --- a/BUILD +++ b/BUILD
@@ -15,7 +15,6 @@ ], manifest_entries = [ "Gerrit-PluginName: websession-broker", - "Gerrit-Module: com.googlesource.gerrit.plugins.websession.broker.Module", "Gerrit-HttpModule: com.googlesource.gerrit.plugins.websession.broker.BrokerBasedWebSession$Module", "Implementation-Title: Broker WebSession", "Implementation-URL: https://review.gerrithub.io/admin/repos/GerritForge/plugins_websession-broker",
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl index 09762f2..bd74d75 100644 --- a/external_plugin_deps.bzl +++ b/external_plugin_deps.bzl
@@ -16,8 +16,8 @@ maven_jar( name = "events-broker", - artifact = "com.gerritforge:events-broker:3.0.4", - sha1 = "350b438f532678b1f9a277b7e7b6fa9da4b725b3", + artifact = "com.gerritforge:events-broker:3.0.5", + sha1 = "7abf72d2252f975baff666fbbf28b7036767aa81", ) maven_jar(
diff --git a/src/main/java/com/googlesource/gerrit/plugins/websession/broker/BrokerBasedWebSessionCache.java b/src/main/java/com/googlesource/gerrit/plugins/websession/broker/BrokerBasedWebSessionCache.java index ba543ba..6dc1689 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/websession/broker/BrokerBasedWebSessionCache.java +++ b/src/main/java/com/googlesource/gerrit/plugins/websession/broker/BrokerBasedWebSessionCache.java
@@ -223,6 +223,9 @@ @Override public void start() { + if (brokerApi == null || brokerApi.get() == null) { + throw new IllegalStateException("Cannot find binding for BrokerApi"); + } brokerApi.get().receiveAsync(webSessionTopicName, this::processMessage); brokerApi.get().replayAllEvents(webSessionTopicName); }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/websession/broker/Module.java b/src/main/java/com/googlesource/gerrit/plugins/websession/broker/Module.java deleted file mode 100644 index b3a9c7e..0000000 --- a/src/main/java/com/googlesource/gerrit/plugins/websession/broker/Module.java +++ /dev/null
@@ -1,36 +0,0 @@ -// Copyright (C) 2019 The Android Open Source Project -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.googlesource.gerrit.plugins.websession.broker; - -import com.gerritforge.gerrit.eventbroker.BrokerApi; -import com.google.gerrit.extensions.registration.DynamicItem; -import com.google.gerrit.lifecycle.LifecycleModule; -import com.google.inject.Inject; - -public class Module extends LifecycleModule { - DynamicItem<BrokerApi> brokerApi; - - @Override - protected void configure() { - if (brokerApi == null) { - DynamicItem.itemOf(binder(), BrokerApi.class); - } - } - - @Inject(optional = true) - public void setBrokerApi(DynamicItem<BrokerApi> brokerApi) { - this.brokerApi = brokerApi; - } -}
diff --git a/src/main/resources/Documentation/about.md b/src/main/resources/Documentation/about.md index cb65323..f488afa 100644 --- a/src/main/resources/Documentation/about.md +++ b/src/main/resources/Documentation/about.md
@@ -12,6 +12,15 @@ For the masters: * Install and configure @PLUGIN@ plugin + @PLUGIN@ plugin requires message broker dynamic item setup. + To fulfil this requirement events-broker needs to be installed as a library + module in all the masters' `$GERRIT_SITE/lib` directory and the following + property must be added to the `$GERRIT_SITE/etc/gerrit.config` + +``` +[gerrit] + installModule = com.gerritforge.gerrit.eventbroker.BrokerApiModule +``` For further information and supported options, refer to [config](config.md) documentation.