Add a method to test if Nomulus is running on Jetty (#2382)

This commit is contained in:
Lai Jiang 2024-03-19 11:43:52 -04:00 committed by GitHub
parent e7bf74d91d
commit 3fdecde6e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 2 deletions

View file

@ -4,4 +4,8 @@
<Configure id="wac" class="org.eclipse.jetty.ee10.webapp.WebAppContext">
<Set name="contextPath">/</Set>
<Set name="war">./webapps/nomulus.war</Set>
<Call class="java.lang.System" name="setProperty">
<Arg>google.registry.jetty</Arg>
<Arg>true</Arg>
</Call>
</Configure>

View file

@ -47,6 +47,18 @@ public enum RegistryEnvironment {
*/
UNITTEST;
/** System property for configuring which environment we should use. */
private static final String PROPERTY = "google.registry.environment";
/**
* System property for if Nomulus is running on top of a self-hosted Jetty server (i.e., not in
* App Engine).
*/
private static final String JETTY_PROPERTY = "google.registry.jetty";
private static final boolean ON_JETTY =
Boolean.parseBoolean(System.getProperty(JETTY_PROPERTY, "false"));
/** Sets this enum as the name of the registry environment. */
public RegistryEnvironment setup() {
return setup(SystemPropertySetter.PRODUCTION_IMPL);
@ -66,6 +78,7 @@ public enum RegistryEnvironment {
return valueOf(Ascii.toUpperCase(System.getProperty(PROPERTY, UNITTEST.name())));
}
/** System property for configuring which environment we should use. */
private static final String PROPERTY = "google.registry.environment";
public static boolean isOnJetty() {
return ON_JETTY;
}
}