Class SystemPropertiesManager

java.lang.Object
com.google.appengine.tools.development.SystemPropertiesManager

public class SystemPropertiesManager extends Object
Manager for a web applications System Properties.

In production each Server Instance has its own independent System Properties. In the Java Development Server the System Properties are shared.

We modify the system properties when the dev appserver is launched using key/value pairs defined in appengine-web.xml. This can make it very easy to leak state across tests that launch instances of the dev appserver, so we keep track of the original values all system properties at start-up. We then restore the values when we shutdown the server.

  • Method Details

    • setAppengineSystemProperties

      public void setAppengineSystemProperties(String release, String applicationId, String majorVersionId)
      Sets SystemProperty values for the current application.

      In a single server application (loaded from a single WAR):

        appId should be set to AppEngineWebXml.getAppId() .
      1. majorVersionId should be set to the AppEngineWebXml.getMajorVersionId().

      In a multi server application (loaded from an EAR):

      1. appId should be set to AppEngineApplicationXml.getApplicationId()
      2. .
      3. majorVersionId should be set to the AppEngineWebXml.getMajorVersionId() for the first web application in the EAR directory according to EarHelper.readEarInfo(String, File). This setting is for compatibility purposes. The value may not match the configuration for all servers in cases different servers have different major versions.
      Parameters:
      release - the SDK release (SdkInfo.getLocalVersion().getRelease()).
      applicationId - the application id.
      majorVersionId - the application version.
    • setSystemProperties

      public void setSystemProperties(com.google.apphosting.utils.config.AppEngineWebXml appEngineWebXml, File appengineWebXmlFile) throws com.google.apphosting.utils.config.AppEngineConfigException
      Throws:
      com.google.apphosting.utils.config.AppEngineConfigException
    • restoreSystemProperties

      public void restoreSystemProperties()
      Clears system properties we set in setSystemProperties(com.google.apphosting.utils.config.AppEngineWebXml, java.io.File). Also, restores system properties to their values at the time this SystemPropertiesManager was constructed. Additional system properties added after this SystemPropertiesManager was constructed are not cleared for historical reasons.

      Note that restoring system properties that have been set by non-user code we did not write could theoretically affect behavior.