Class DevAppServerImpl

java.lang.Object
com.google.appengine.tools.development.DevAppServerImpl
All Implemented Interfaces:
DevAppServer

public class DevAppServerImpl extends Object implements DevAppServer
DevAppServer launches a local Jetty server (by default) with a single hosted web application. It can be invoked from the command-line by providing the path to the directory in which the application resides as the only argument.
  • Field Details

  • Constructor Details

    • DevAppServerImpl

      public DevAppServerImpl(File appDir, File externalResourceDir, File webXmlLocation, File appEngineWebXmlLocation, String address, int port, boolean useCustomStreamHandler, Map<String,Object> requestedContainerConfigProperties, String applicationId)
      Constructs a development application server that runs the application located in the given WAR or EAR directory.
      Parameters:
      appDir - The location of the application to run.
      externalResourceDir - If not null, a resource directory external to the appDir. This will be searched before appDir when looking for resources.
      webXmlLocation - The location of a file whose format complies with http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd. If null, defaults to /WEB-INF/web.xml
      appEngineWebXmlLocation - The name of the app engine config file. If null, defaults to /WEB-INF/appengine-web.xml
      address - The address on which to run
      port - The port on which to run
      useCustomStreamHandler - If true (typical), install StreamHandlerFactory.
      requestedContainerConfigProperties - Additional properties used in the configuration of the specific container implementation.
      applicationId - The custom application ID. If null, defaults to use the primary module's application ID.
  • Method Details

    • setServiceProperties

      public void setServiceProperties(Map<String,String> properties)
      Sets the properties that will be used by the local services to configure themselves. This method must be called before the server has been started.
      Specified by:
      setServiceProperties in interface DevAppServer
      Parameters:
      properties - a, maybe null, set of properties.
      Throws:
      IllegalStateException - if the server has already been started.
    • getServiceProperties

      public Map<String,String> getServiceProperties()
      Description copied from interface: DevAppServer
      Get the properties that are used by the local services to configure themselves.
      Specified by:
      getServiceProperties in interface DevAppServer
      Returns:
      service properties.
    • start

      public CountDownLatch start() throws Exception
      Starts the server.
      Specified by:
      start in interface DevAppServer
      Returns:
      a latch that will be decremented to zero when the server is shutdown.
      Throws:
      IllegalStateException - If the server has already been started or shutdown.
      com.google.apphosting.utils.config.AppEngineConfigException - If no WEB-INF directory can be found or WEB-INF/appengine-web.xml does not exist.
      Exception
    • setInboundServicesProperty

      public void setInboundServicesProperty()
    • restart

      public CountDownLatch restart() throws Exception
      Description copied from interface: DevAppServer
      Restart the server to reload disk and class changes.
      Specified by:
      restart in interface DevAppServer
      Returns:
      a latch that will be decremented to zero when the server is shutdown or restarted.
      Throws:
      Exception
    • shutdown

      public void shutdown() throws Exception
      Description copied from interface: DevAppServer
      Shut down the server.
      Specified by:
      shutdown in interface DevAppServer
      Throws:
      Exception
    • gracefulShutdown

      public void gracefulShutdown() throws IllegalStateException
      Description copied from interface: DevAppServer
      Shut down the server after all outstanding requests have completed.
      Specified by:
      gracefulShutdown in interface DevAppServer
      Throws:
      IllegalStateException
    • getPort

      public int getPort()
      Specified by:
      getPort in interface DevAppServer
      Returns:
      the servlet container listener port number.
    • getAppContext

      public AppContext getAppContext()
      Description copied from interface: DevAppServer
      Returns the AppContext for the main container. Useful in embedding scenarios to allow the embedder to install servlets, etc. Any such modification should be done before calling DevAppServer.start().
      Specified by:
      getAppContext in interface DevAppServer
      See Also:
    • getCurrentAppContext

      public AppContext getCurrentAppContext()
      Description copied from interface: DevAppServer
      Returns the AppContext corresponding to the HTTP request (or background thread) associated with the current thread, or null if the current thread is not associated with any HTTP request (or background thread).
      Specified by:
      getCurrentAppContext in interface DevAppServer
    • setThrowOnEnvironmentVariableMismatch

      public void setThrowOnEnvironmentVariableMismatch(boolean throwOnMismatch)
      Description copied from interface: DevAppServer
      Reset the container EnvironmentVariableMismatchSeverity.
      Specified by:
      setThrowOnEnvironmentVariableMismatch in interface DevAppServer