Extract Guice Module into a new file
De-compose the main Guice Module into a separate file.
This is a prepration work to make the module more configurable
based on the audit configuration entries in gerrit.config.
Change-Id: I1e037de24a57c3a7725e6ef34d538de8be899c5b
diff --git a/BUILD b/BUILD
index 669b735..69730a6 100644
--- a/BUILD
+++ b/BUILD
@@ -12,7 +12,7 @@
manifest_entries = [
"Gerrit-PluginName: audit-sl4j",
"Gerrit-ReloadMode: reload",
- "Gerrit-Module: com.googlesource.gerrit.plugins.auditsl4j.LoggerAudit$Module",
+ "Gerrit-Module: com.googlesource.gerrit.plugins.auditsl4j.Module",
"Implementation-Title: Gerrit Audit provider for SLF4J",
"Implementation-URL: https://gerrit.googlesource.com/plugins/audit-sl4j/",
],
diff --git a/src/main/java/com/googlesource/gerrit/plugins/auditsl4j/LoggerAudit.java b/src/main/java/com/googlesource/gerrit/plugins/auditsl4j/LoggerAudit.java
index 54e004d..7328c60 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/auditsl4j/LoggerAudit.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/auditsl4j/LoggerAudit.java
@@ -16,8 +16,6 @@
import com.google.gerrit.audit.AuditEvent;
import com.google.gerrit.audit.AuditListener;
-import com.google.gerrit.extensions.registration.DynamicSet;
-import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@@ -41,13 +39,6 @@
"EventId | EventTS | SessionId | User | Protocol data | Action | Parameters | Result | StartTS | Elapsed");
}
- public static class Module extends AbstractModule {
- @Override
- protected void configure() {
- DynamicSet.bind(binder(), AuditListener.class).to(LoggerAudit.class);
- }
- }
-
@Override
public void onAuditableAction(AuditEvent auditEvent) {
String auditString = auditRenderer.render(auditEvent);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/auditsl4j/Module.java b/src/main/java/com/googlesource/gerrit/plugins/auditsl4j/Module.java
new file mode 100644
index 0000000..ba76f93
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/auditsl4j/Module.java
@@ -0,0 +1,26 @@
+// Copyright (C) 2018 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.auditsl4j;
+
+import com.google.gerrit.audit.AuditListener;
+import com.google.gerrit.extensions.registration.DynamicSet;
+import com.google.inject.AbstractModule;
+
+public class Module extends AbstractModule {
+ @Override
+ protected void configure() {
+ DynamicSet.bind(binder(), AuditListener.class).to(LoggerAudit.class);
+ }
+}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/auditsl4j/LoggerAuditTest.java b/src/test/java/com/googlesource/gerrit/plugins/auditsl4j/LoggerAuditTest.java
index 19a86e9..5470641 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/auditsl4j/LoggerAuditTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/auditsl4j/LoggerAuditTest.java
@@ -29,12 +29,12 @@
@TestPlugin(
name = "audit-sl4j",
- sysModule = "com.googlesource.gerrit.plugins.auditsl4j.LoggerAuditTest$Module")
+ sysModule = "com.googlesource.gerrit.plugins.auditsl4j.LoggerAuditTest$TestModule")
public class LoggerAuditTest extends LightweightPluginDaemonTest {
@Inject @CanonicalWebUrl private String webUrl;
- public static class Module extends LoggerAudit.Module {
+ public static class TestModule extends Module {
@Override
protected void configure() {