Class LocalEnvironment

java.lang.Object
com.google.appengine.tools.development.LocalEnvironment
All Implemented Interfaces:
com.google.apphosting.api.ApiProxy.Environment
Direct Known Subclasses:
AbstractContainerService.LocalInitializationEnvironment, LocalHttpRequestEnvironment, LocalHttpRequestEnvironment

public abstract class LocalEnvironment extends Object implements com.google.apphosting.api.ApiProxy.Environment
LocalEnvironment is a simple ApiProxy.Environment that reads application-specific details (e.g. application identifer) directly from the custom deployment descriptor.
  • Field Details

    • TESTING_DEFAULT_PORT

      public static final Integer TESTING_DEFAULT_PORT
    • INSTANCE_ID_ENV_ATTRIBUTE

      public static final String INSTANCE_ID_ENV_ATTRIBUTE
      See Also:
    • PORT_ID_ENV_ATTRIBUTE

      public static final String PORT_ID_ENV_ATTRIBUTE
      See Also:
    • API_CALL_SEMAPHORE

      public static final String API_CALL_SEMAPHORE
      ApiProxy.Environment instances used with ApiProxyLocalFactory should have a entry in the map returned by getAttributes() with this key, and a Semaphore as the value. This is used internally to track asynchronous API calls.
      See Also:
    • REQUEST_ID

      public static final String REQUEST_ID
      The name of an attribute that contains a (String) unique identifier for the curent request.
      See Also:
    • START_TIME_ATTR

      public static final String START_TIME_ATTR
      The name of an attribute that contains a a Date object representing the time this request was started.
      See Also:
    • REQUEST_END_LISTENERS

      public static final String REQUEST_END_LISTENERS
      The name of an attribute that contains a Set<RequestEndListener>. The set of RequestEndListeners is populated by from within the service calls. The listeners are invoked at the end of a user request.
      See Also:
    • HTTP_SERVLET_REQUEST

      public static final String HTTP_SERVLET_REQUEST
      The name of an attribute that contains the HttpServletRequest instance.
      See Also:
    • DEFAULT_VERSION_HOSTNAME

      public static final String DEFAULT_VERSION_HOSTNAME
      In production, this is a constant that defines the attribute name that contains the hostname on which the default version is listening. In the local development server, the attribute contains the listening port in addition to the hostname, and is the one and only frontend app instance hostname and port.
      See Also:
    • MAIN_INSTANCE

      public static final int MAIN_INSTANCE
      Instance number for a main instance.

      Clients depend on this literal having the value -1 so do not change this value without making needed updates to clients.

      See Also:
  • Method Details

    • setInstance

      public static void setInstance(Map<String,Object> attributes, int instance)
      Sets the instance for the provided attributes.
    • setPort

      public static void setPort(Map<String,Object> attributes, Integer port)
      Sets the PORT_ID_ENV_ATTRIBUTE value to the provided port value or clears it if port is null.
    • getAppId

      public String getAppId()
      Specified by:
      getAppId in interface com.google.apphosting.api.ApiProxy.Environment
    • getModuleId

      public String getModuleId()
      Specified by:
      getModuleId in interface com.google.apphosting.api.ApiProxy.Environment
    • getVersionId

      public String getVersionId()
      Specified by:
      getVersionId in interface com.google.apphosting.api.ApiProxy.Environment
    • getAuthDomain

      public String getAuthDomain()
      Specified by:
      getAuthDomain in interface com.google.apphosting.api.ApiProxy.Environment
    • getRequestNamespace

      @Deprecated public final String getRequestNamespace()
      Deprecated.
      Specified by:
      getRequestNamespace in interface com.google.apphosting.api.ApiProxy.Environment
    • getAttributes

      public ConcurrentMap<String,Object> getAttributes()
      Specified by:
      getAttributes in interface com.google.apphosting.api.ApiProxy.Environment
    • callRequestEndListeners

      public void callRequestEndListeners()
    • getRemainingMillis

      public long getRemainingMillis()
      Specified by:
      getRemainingMillis in interface com.google.apphosting.api.ApiProxy.Environment
    • getMajorVersion

      public static String getMajorVersion(String versionId)
      Returns the major version component from the provided version id or null if the provided version id has no major version component.