Reduce duplicate code in the servlets

Currently, all 4 servlets (backend, frontend, pubapi, tools) have duplicates of
the same exact code.

That's an anti-pattern!

Created a ServletBase they can all extend which has the duplicate code.

As a bonus, the tools servlet now runs the metric reporter, meaning tool
related metrics will now be reported!

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=219792176
This commit is contained in:
guyben 2018-11-02 06:59:50 -07:00 committed by Michael Muller
parent 545b68ad9a
commit 3f6585fccc
10 changed files with 31 additions and 183 deletions

View file

@ -14,7 +14,9 @@
package google.registry.module.tools;
import com.google.monitoring.metrics.MetricReporter;
import dagger.Component;
import dagger.Lazy;
import google.registry.config.CredentialModule;
import google.registry.config.RegistryConfig.ConfigModule;
import google.registry.export.DriveModule;
@ -29,6 +31,7 @@ import google.registry.keyring.api.DummyKeyringModule;
import google.registry.keyring.api.KeyModule;
import google.registry.keyring.kms.KmsModule;
import google.registry.module.tools.ToolsRequestComponent.ToolsRequestComponentModule;
import google.registry.monitoring.whitebox.StackdriverModule;
import google.registry.request.Modules.DatastoreServiceModule;
import google.registry.request.Modules.Jackson2Module;
import google.registry.request.Modules.NetHttpTransportModule;
@ -62,6 +65,7 @@ import javax.inject.Singleton;
KmsModule.class,
NetHttpTransportModule.class,
ServerTridProviderModule.class,
StackdriverModule.class,
SystemClockModule.class,
SystemSleeperModule.class,
ToolsRequestComponentModule.class,
@ -70,4 +74,6 @@ import javax.inject.Singleton;
})
interface ToolsComponent {
ToolsRequestHandler requestHandler();
Lazy<MetricReporter> metricReporter();
}