Class HttpServer

  • All Implemented Interfaces:
    org.eclipse.jetty.server.Handler, org.eclipse.jetty.server.HandlerContainer, org.eclipse.jetty.util.Attributes, org.eclipse.jetty.util.component.Container, org.eclipse.jetty.util.component.Destroyable, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.component.LifeCycle, Server.AuxiliaryServer
    Direct Known Subclasses:
    EntityServletServer

    public class HttpServer
    extends org.eclipse.jetty.server.Server
    implements Server.AuxiliaryServer
    A simple Jetty based http file server
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.eclipse.jetty.server.handler.AbstractHandler

        org.eclipse.jetty.server.handler.AbstractHandler.ErrorDispatchHandler
      • Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

        org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener
      • Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container

        org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.Listener
      • Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

        org.eclipse.jetty.util.component.LifeCycle.Listener
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static PropertyValue<String> DOCUMENT_ROOT
      Specifies the document root for file serving
      .
      static PropertyValue<String> HTTP_SERVER_KEYSTORE_PASSWORD
      Specifies the password for the keystore used for securing http connections.
      Value type: String
      Default value: null
      static PropertyValue<String> HTTP_SERVER_KEYSTORE_PATH
      Specifies the keystore to use for securing http connections.
      Value type: String
      Default value: null
      static PropertyValue<Integer> HTTP_SERVER_PORT
      The port on which the http server is made available to clients.
      Value type: Integer
      Default value: 8080
      static PropertyValue<Boolean> HTTP_SERVER_SECURE
      Specifies whether https should be used.
      Value type: Boolean
      Default value: true
      • Fields inherited from class org.eclipse.jetty.server.handler.HandlerWrapper

        _handler
      • Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

        FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
      • Fields inherited from interface org.eclipse.jetty.util.component.Dumpable

        KEY
    • Constructor Summary

      Constructors 
      Constructor Description
      HttpServer​(Server connectionServer)
      Instantiates a new HttpServer on the given port.
      HttpServer​(Server connectionServer, String documentRoot, Integer port, Boolean useHttps)
      Instantiates a new HttpServer on the given port.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addHandler​(org.eclipse.jetty.server.Handler handler)
      Adds a handler to this http server
      protected Server getConnectionServer()  
      void startServer()
      Starts the server, returns when the server has completed the startup
      void stopServer()
      Stops the server, returns when the server has completed shutdown
      • Methods inherited from class org.eclipse.jetty.server.Server

        addConnector, clearAttributes, doStart, doStop, dump, getAttribute, getAttributeNames, getConnectors, getDateField, getErrorHandler, getRequestLog, getSessionIdManager, getStopAtShutdown, getThreadPool, getURI, getVersion, handle, handleAsync, handleOptions, isDumpAfterStart, isDumpBeforeStop, join, main, removeAttribute, removeConnector, setAttribute, setConnectors, setDumpAfterStart, setDumpBeforeStop, setErrorHandler, setRequestLog, setSessionIdManager, setStopAtShutdown, setStopTimeout, start, toString
      • Methods inherited from class org.eclipse.jetty.server.handler.HandlerWrapper

        destroy, expandChildren, getHandler, getHandlers, handle, insertHandler, setHandler
      • Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandlerContainer

        doShutdown, expandHandler, findContainerOf, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass, setServer
      • Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandler

        doError, getServer
      • Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle

        addBean, addBean, addBean, addEventListener, addManaged, contains, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, stop, unmanage, updateBean, updateBean, updateBeans
      • Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

        addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
      • Methods inherited from interface org.eclipse.jetty.util.component.Dumpable

        dumpSelf
      • Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle

        addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
    • Field Detail

      • HTTP_SERVER_PORT

        public static final PropertyValue<Integer> HTTP_SERVER_PORT
        The port on which the http server is made available to clients.
        Value type: Integer
        Default value: 8080
      • HTTP_SERVER_SECURE

        public static final PropertyValue<Boolean> HTTP_SERVER_SECURE
        Specifies whether https should be used.
        Value type: Boolean
        Default value: true
      • HTTP_SERVER_KEYSTORE_PATH

        public static final PropertyValue<String> HTTP_SERVER_KEYSTORE_PATH
        Specifies the keystore to use for securing http connections.
        Value type: String
        Default value: null
      • HTTP_SERVER_KEYSTORE_PASSWORD

        public static final PropertyValue<String> HTTP_SERVER_KEYSTORE_PASSWORD
        Specifies the password for the keystore used for securing http connections.
        Value type: String
        Default value: null
      • DOCUMENT_ROOT

        public static final PropertyValue<String> DOCUMENT_ROOT
        Specifies the document root for file serving
        . Value type: String
        Default value: null
    • Constructor Detail

      • HttpServer

        public HttpServer​(Server connectionServer)
        Instantiates a new HttpServer on the given port.
        Parameters:
        connectionServer - the Server serving the connection requests
      • HttpServer

        public HttpServer​(Server connectionServer,
                          String documentRoot,
                          Integer port,
                          Boolean useHttps)
        Instantiates a new HttpServer on the given port.
        Parameters:
        connectionServer - the Server serving the connection requests
        documentRoot - the document root, null to disable file serving
        port - the port on which to serve
        useHttps - true if https should be used
    • Method Detail

      • addHandler

        protected final void addHandler​(org.eclipse.jetty.server.Handler handler)
        Adds a handler to this http server
        Parameters:
        handler - the handler to add
      • getConnectionServer

        protected final Server getConnectionServer()
        Returns:
        the Server this http server is running alongside