Add dagger map for injecting DnsWriter implementations

This is one of several CLs in a sequence for allowing per-TLD DNS
implementations.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=129445641
This commit is contained in:
Greg Shikhman 2016-08-05 08:45:02 -07:00 committed by Justine Tunney
parent 770fd35e20
commit a620d06239
24 changed files with 173 additions and 215 deletions

View file

@ -255,6 +255,16 @@ public class Registry extends ImmutableObject implements Buildable {
}
}
/** Backfill the Registry entities that were saved before this field was added. */
// TODO(shikhman): Remove this backfill once it is populated on all Registry entities.
@OnLoad
void backfillDnsWriter() {
if (dnsWriter == null) {
dnsWriter = "VoidDnsWriter";
}
}
/**
* The name of the pricing engine that this TLD uses.
*
@ -266,6 +276,14 @@ public class Registry extends ImmutableObject implements Buildable {
*/
String pricingEngineClassName;
/**
* The name of the DnsWriter that this TLD uses.
*
* <p>This must be a valid key for the map of DnsWriters injected by <code>
* @Inject Map<String, DnsWriter></code>
*/
String dnsWriter;
/**
* The unicode-aware representation of the TLD associated with this {@link Registry}.
*
@ -545,6 +563,10 @@ public class Registry extends ImmutableObject implements Buildable {
return pricingEngineClassName;
}
public String getDnsWriter() {
return dnsWriter;
}
public ImmutableSet<String> getAllowedRegistrantContactIds() {
return nullToEmptyImmutableCopy(allowedRegistrantContactIds);
}
@ -616,6 +638,12 @@ public class Registry extends ImmutableObject implements Buildable {
return this;
}
public Builder setDnsWriter(String dnsWriter) {
getInstance().dnsWriter = checkArgumentNotNull(dnsWriter);
return this;
}
public Builder setAddGracePeriodLength(Duration addGracePeriodLength) {
checkArgument(addGracePeriodLength.isLongerThan(Duration.ZERO),
"addGracePeriodLength must be non-zero");